Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude protobuf 4.x from armeria-grpc module #5992

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,7 @@ allprojects {
}
}
}

configure(projectsWithFlags('java', 'publish')) {
failOnVersionConflict(libs.protobuf.java)
}
34 changes: 34 additions & 0 deletions gradle/scripts/lib/common-dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ allprojects { p ->
managedVersions = getManagedVersions(p.rootProject)
findLibrary = this.&findLibrary.curry(p.rootProject)
findPlugin = this.&findPlugin.curry(p.rootProject)
failOnVersionConflict = this.&failOnVersionConflict.curry(p)
}
}

Expand Down Expand Up @@ -331,3 +332,36 @@ final class GentlePlainTextReporter implements Reporter {
return delegate.getFileExtension()
}
}

/**
* A custom version of failOnVersionConflict which can limit which dependencies should be checked for conflict.
* Heavily inspired https://github.com/gradle/gradle/issues/8813.
*/
static def failOnVersionConflict(Project project, ProviderConvertible<MinimalExternalModuleDependency> providerConvertible) {
return failOnVersionConflict(project, providerConvertible.asProvider())
}

static def failOnVersionConflict(Project project, Provider<MinimalExternalModuleDependency> dependencyProvider) {
if (!dependencyProvider.isPresent()) {
return
}
def targetDependency = dependencyProvider.get()
project.configurations.configureEach { config ->
incoming.afterResolve {
resolutionResult.allComponents {ResolvedComponentResult result ->
if (selectionReason.conflictResolution && moduleVersion != null) {
// we don't care if the selected version is the one specified in dependencies.toml
if (targetDependency.module == moduleVersion.module && targetDependency.version != moduleVersion.version) {
def msg = "Project '${project.name}:${config.name}' resolution failed " +
"for '${targetDependency.module}' with '${getSelectionReason()}"
if (project.rootProject.hasProperty('debugDeps')) {
project.logger.lifecycle(msg)
} else {
throw new IllegalStateException(msg)
}
}
}
}
}
}
}
4 changes: 3 additions & 1 deletion grpc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ dependencies {
optionalImplementation libs.grpc.kotlin
optionalImplementation libs.kotlin.coroutines.core

api libs.protobuf.jackson
api(libs.protobuf.jackson) {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
}

testImplementation(libs.gax.grpc) {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
Expand Down
Loading