From 403e86b1c55dfbee344dd7a65bb8a1651e3648ff Mon Sep 17 00:00:00 2001 From: Viacheslav Babanin Date: Thu, 26 Oct 2023 00:44:04 -0700 Subject: [PATCH] Add explicit automatic module name configuration. (#1232) JAVA-5213 JAVA-5202 --- bson-kotlin/build.gradle.kts | 2 ++ bson-kotlinx/build.gradle.kts | 2 ++ bson-scala/build.gradle | 11 +++++++---- bson/build.gradle | 5 ++++- driver-kotlin-coroutine/build.gradle.kts | 2 ++ driver-kotlin-sync/build.gradle.kts | 2 ++ driver-scala/build.gradle | 2 +- gradle/publish.gradle | 1 - 8 files changed, 20 insertions(+), 7 deletions(-) diff --git a/bson-kotlin/build.gradle.kts b/bson-kotlin/build.gradle.kts index ee9358c0c72..3840b3169cf 100644 --- a/bson-kotlin/build.gradle.kts +++ b/bson-kotlin/build.gradle.kts @@ -148,3 +148,5 @@ tasks.javadocJar.configure { // Sources publishing configuration // =========================== tasks.sourcesJar { from(project.sourceSets.main.map { it.kotlin }) } + +afterEvaluate { tasks.jar { manifest { attributes["Automatic-Module-Name"] = "org.mongodb.bson.kotlin" } } } diff --git a/bson-kotlinx/build.gradle.kts b/bson-kotlinx/build.gradle.kts index 278c9988aa9..bb9dd42e10b 100644 --- a/bson-kotlinx/build.gradle.kts +++ b/bson-kotlinx/build.gradle.kts @@ -152,3 +152,5 @@ tasks.javadocJar.configure { // Sources publishing configuration // =========================== tasks.sourcesJar { from(project.sourceSets.main.map { it.kotlin }) } + +afterEvaluate { tasks.jar { manifest { attributes["Automatic-Module-Name"] = "org.mongodb.bson.kotlinx" } } } diff --git a/bson-scala/build.gradle b/bson-scala/build.gradle index e2c48a87d77..6606dec5a89 100644 --- a/bson-scala/build.gradle +++ b/bson-scala/build.gradle @@ -58,7 +58,10 @@ test { maxParallelForks = 1 } -jar.manifest.attributes['Import-Package'] = [ - '!scala.*', - '*' -].join(',') +afterEvaluate { + jar.manifest.attributes['Automatic-Module-Name'] = 'org.mongodb.bson.scala' + jar.manifest.attributes['Import-Package'] = [ + '!scala.*', + '*' + ].join(',') +} diff --git a/bson/build.gradle b/bson/build.gradle index 005c1f92411..d2b2ed3ba0e 100644 --- a/bson/build.gradle +++ b/bson/build.gradle @@ -22,4 +22,7 @@ ext { pomURL = 'https://bsonspec.org' } -jar.manifest.attributes['Import-Package'] = 'org.slf4j.*;resolution:=optional' +afterEvaluate { + jar.manifest.attributes['Automatic-Module-Name'] = 'org.mongodb.bson' + jar.manifest.attributes['Import-Package'] = 'org.slf4j.*;resolution:=optional' +} diff --git a/driver-kotlin-coroutine/build.gradle.kts b/driver-kotlin-coroutine/build.gradle.kts index a7958fc2f4b..1467c832abe 100644 --- a/driver-kotlin-coroutine/build.gradle.kts +++ b/driver-kotlin-coroutine/build.gradle.kts @@ -193,3 +193,5 @@ tasks.javadocJar.configure { // Sources publishing configuration // =========================== tasks.sourcesJar { from(project.sourceSets.main.map { it.kotlin }) } + +afterEvaluate { tasks.jar { manifest { attributes["Automatic-Module-Name"] = "org.mongodb.driver.kotlin.coroutine" } } } diff --git a/driver-kotlin-sync/build.gradle.kts b/driver-kotlin-sync/build.gradle.kts index f9aafc091cf..05b20b4803b 100644 --- a/driver-kotlin-sync/build.gradle.kts +++ b/driver-kotlin-sync/build.gradle.kts @@ -188,3 +188,5 @@ tasks.javadocJar.configure { // Sources publishing configuration // =========================== tasks.sourcesJar { from(project.sourceSets.main.map { it.kotlin }) } + +afterEvaluate { tasks.jar { manifest { attributes["Automatic-Module-Name"] = "org.mongodb.driver.kotlin.sync" } } } diff --git a/driver-scala/build.gradle b/driver-scala/build.gradle index 0c721d6d1d9..f9852968f05 100644 --- a/driver-scala/build.gradle +++ b/driver-scala/build.gradle @@ -117,7 +117,7 @@ ext { } afterEvaluate { - jar.manifest.attributes['Automatic-Module-Name'] = 'org.mongodb.scala.mongo-scala-driver' + jar.manifest.attributes['Automatic-Module-Name'] = 'org.mongodb.driver.scala' jar.manifest.attributes['Import-Package'] = [ '!scala.*', '*' diff --git a/gradle/publish.gradle b/gradle/publish.gradle index 561e76957a5..2047ef26800 100644 --- a/gradle/publish.gradle +++ b/gradle/publish.gradle @@ -60,7 +60,6 @@ ext { configureJarManifestAttributes = { project -> { -> manifest.attributes['-exportcontents'] = "*;-noimport:=true" - manifest.attributes['Automatic-Module-Name'] = project.group + '.' + project.archivesBaseName manifest.attributes['Build-Version'] = project.gitVersion manifest.attributes['Bundle-Version'] = project.version manifest.attributes['Bundle-Name'] = project.archivesBaseName