Skip to content

Commit

Permalink
Revert back to registerFeature('optional')
Browse files Browse the repository at this point in the history
With a `components.java.addVariantsFromConfiguration(configurations.optional)` and `io.spring.dependency-management`
combination the version is not published for `optional` dependencies.
Does not look like there is an easy way to extract that version somehow.

So, revert back to the `registerFeature('optional')` for time being.
Even if it is reported as deprecated in Gradle

(cherry picked from commit 54400b2)

# Conflicts:
#	build.gradle
  • Loading branch information
artembilan committed Aug 16, 2024
1 parent 0a93dd5 commit a9687ca
Showing 1 changed file with 21 additions and 38 deletions.
59 changes: 21 additions & 38 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -131,25 +131,12 @@ configure(javaProjects) { subproject ->

def scopeAttribute = Attribute.of('dependency.scope', String)

configurations {
optional {
attributes {
attribute(scopeAttribute, 'optional')
}
}

compileClasspath.extendsFrom(optional)
testCompileClasspath.extendsFrom(optional)
testRuntimeClasspath.extendsFrom(optional)
}

components.java.addVariantsFromConfiguration(configurations.optional) {
mapToOptional()
}

java {
withJavadocJar()
withSourcesJar()
registerFeature('optional') {
usingSourceSet(sourceSets.main)
}
}

compileJava {
Expand All @@ -166,10 +153,6 @@ configure(javaProjects) { subproject ->

// dependencies that are common across all java projects
dependencies {
attributesSchema {
attribute(scopeAttribute)
}

implementation "com.google.code.findbugs:jsr305:$googleJsr305Version"
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
Expand All @@ -186,7 +169,7 @@ configure(javaProjects) { subproject ->
exclude group: 'org.hamcrest'
}
testImplementation "org.hamcrest:hamcrest-core:$hamcrestVersion"
optional "org.assertj:assertj-core:$assertjVersion"
optionalApi "org.assertj:assertj-core:$assertjVersion"
}

// enable all compiler warnings; individual projects may customize further
Expand Down Expand Up @@ -292,27 +275,27 @@ project ('spring-kafka') {
exclude group: 'org.springframework'
}
api "org.apache.kafka:kafka-clients:$kafkaVersion"
optional "org.apache.kafka:kafka-streams:$kafkaVersion"
optional 'com.fasterxml.jackson.core:jackson-core'
optional 'com.fasterxml.jackson.core:jackson-databind'
optional 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8'
optional 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
optional 'com.fasterxml.jackson.datatype:jackson-datatype-joda'
optional ('com.fasterxml.jackson.module:jackson-module-kotlin') {
optionalApi "org.apache.kafka:kafka-streams:$kafkaVersion"
optionalApi 'com.fasterxml.jackson.core:jackson-core'
optionalApi 'com.fasterxml.jackson.core:jackson-databind'
optionalApi 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8'
optionalApi 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
optionalApi 'com.fasterxml.jackson.datatype:jackson-datatype-joda'
optionalApi ('com.fasterxml.jackson.module:jackson-module-kotlin') {
exclude group: 'org.jetbrains.kotlin'
}

// Spring Data projection message binding support
optional ("org.springframework.data:spring-data-commons") {
optionalApi ("org.springframework.data:spring-data-commons") {
exclude group: 'org.springframework'
exclude group: 'io.micrometer'
}
optional "com.jayway.jsonpath:json-path:$jaywayJsonPathVersion"
optionalApi "com.jayway.jsonpath:json-path:$jaywayJsonPathVersion"

optional 'io.projectreactor:reactor-core'
optional 'io.projectreactor.kafka:reactor-kafka'
optional 'io.micrometer:micrometer-core'
optional 'io.micrometer:micrometer-tracing'
optionalApi 'io.projectreactor:reactor-core'
optionalApi 'io.projectreactor.kafka:reactor-kafka'
optionalApi 'io.micrometer:micrometer-core'
optionalApi 'io.micrometer:micrometer-tracing'

testImplementation project (':spring-kafka-test')
testImplementation 'io.projectreactor:reactor-test'
Expand Down Expand Up @@ -379,12 +362,12 @@ project ('spring-kafka-test') {
}
api 'org.junit.jupiter:junit-jupiter-api'
api 'org.junit.platform:junit-platform-launcher'
optional "org.hamcrest:hamcrest-core:$hamcrestVersion"
optional "org.mockito:mockito-core:$mockitoVersion"
optional ("junit:junit:$junit4Version") {
optionalApi "org.hamcrest:hamcrest-core:$hamcrestVersion"
optionalApi "org.mockito:mockito-core:$mockitoVersion"
optionalApi ("junit:junit:$junit4Version") {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
optional "org.apache.logging.log4j:log4j-core:$log4jVersion"
optionalApi "org.apache.logging.log4j:log4j-core:$log4jVersion"
}
}

Expand Down

0 comments on commit a9687ca

Please sign in to comment.