Skip to content

Commit 7a3fbd7

Browse files
committed
Resolve difference in META-INF/MANIFEST.MF files between 3.x and 4.x
JAVA-3566
1 parent c83a3ae commit 7a3fbd7

File tree

8 files changed

+62
-71
lines changed

8 files changed

+62
-71
lines changed

bson-scala/build.gradle

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ description = "A Scala wrapper / extension to the bson library"
1818
archivesBaseName = 'mongo-scala-bson'
1919

2020
dependencies {
21-
compile project(':bson')
21+
compile project(path: ':bson', configuration: 'default')
2222
}
2323

2424
sourceSets {
@@ -48,11 +48,4 @@ test {
4848
maxParallelForks = 1
4949
}
5050

51-
jar {
52-
bnd (
53-
'-exportcontents': "*;-noimport:=true",
54-
'Automatic-Module-Name': 'org.mongodb.scala.mongo-scala-bson',
55-
'Build-Version': project.gitVersion,
56-
'Import-Package': 'org.bson.*'
57-
)
58-
}
51+
jar.manifest.attributes['Import-Package'] = 'org.bson.*'

bson/build.gradle

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,4 @@ ext {
2222
pomURL = 'https://bsonspec.org'
2323
}
2424

25-
jar {
26-
bnd (
27-
'-exportcontents': "*;-noimport:=true",
28-
'Automatic-Module-Name': 'org.mongodb.bson',
29-
'Build-Version': project.gitVersion,
30-
'Import-Package': 'org.slf4j;resolution:=optional'
31-
)
32-
}
25+
jar.manifest.attributes['Import-Package'] = 'org.slf4j;resolution:=optional'

build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ configure(javaProjects) {
9090

9191
configure(scalaProjects) {
9292
apply plugin: 'scala'
93-
apply plugin: 'biz.aQute.bnd.builder'
9493
apply plugin: 'idea'
9594
apply plugin: "com.adtran.scala-multiversion-plugin"
9695
apply plugin: "com.diffplug.gradle.spotless"
@@ -110,6 +109,7 @@ configure(scalaProjects) {
110109
testCompile('ch.qos.logback:logback-classic:1.1.3')
111110
testCompile('org.reflections:reflections:0.9.10')
112111
}
112+
113113

114114
spotless {
115115
scala {
@@ -130,7 +130,6 @@ configure(scalaProjects) {
130130
}
131131

132132
configure(javaMainProjects) {
133-
apply plugin: 'biz.aQute.bnd.builder'
134133
apply plugin: 'nebula.optional-base'
135134

136135
dependencies {

driver-core/build.gradle

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ext {
3131
sourceSets.main.resources.srcDirs = ['src/resources']
3232

3333
dependencies {
34-
compile project(':bson')
34+
compile project(path: ':bson', configuration: 'default')
3535

3636
compile "com.github.jnr:jnr-unixsocket:$jnrUnixsocketVersion", optional
3737
compile "io.netty:netty-buffer:$nettyVersion", optional
@@ -52,28 +52,25 @@ buildConfig {
5252
packageName = 'com.mongodb.internal.build'
5353
}
5454

55-
jar {
56-
bnd(
57-
'-exportcontents': "*;-noimport:=true",
58-
'Automatic-Module-Name': 'org.mongodb.driver.core',
59-
'Build-Version': project.gitVersion,
60-
'Import-Package': [
61-
'org.bson.*', // unfortunate that this is necessary, but if it's left out then it's not included
62-
'javax.crypto.*',
63-
'javax.crypto.spec.*',
64-
'javax.management.*',
65-
'javax.naming.*',
66-
'javax.naming.directory.*',
67-
'javax.net.*',
68-
'javax.net.ssl.*',
69-
'javax.security.sasl.*',
70-
'javax.security.auth.callback.*',
71-
'org.ietf.jgss.*',
72-
'io.netty.*;resolution:=optional',
73-
'org.xerial.snappy.*;resolution:=optional',
74-
'com.github.luben.zstd.*;resolution:=optional',
75-
'org.slf4j;resolution:=optional',
76-
'jnr.unixsocket;resolution:=optional'
77-
].join(',')
78-
)
55+
afterEvaluate {
56+
jar.manifest.attributes['Automatic-Module-Name'] = 'org.mongodb.driver.core'
57+
jar.manifest.attributes['Bundle-SymbolicName'] = 'org.mongodb.driver-core'
58+
jar.manifest.attributes['Import-Package'] = [
59+
'org.bson.*', // unfortunate that this is necessary, but if it's left out then it's not included
60+
'javax.crypto.*',
61+
'javax.crypto.spec.*',
62+
'javax.management.*',
63+
'javax.naming.*',
64+
'javax.naming.directory.*',
65+
'javax.net.*',
66+
'javax.net.ssl.*',
67+
'javax.security.sasl.*',
68+
'javax.security.auth.callback.*',
69+
'org.ietf.jgss.*',
70+
'io.netty.*;resolution:=optional',
71+
'org.xerial.snappy.*;resolution:=optional',
72+
'com.github.luben.zstd.*;resolution:=optional',
73+
'org.slf4j;resolution:=optional',
74+
'jnr.unixsocket;resolution:=optional'
75+
].join(',')
7976
}

driver-reactive-streams/build.gradle

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ description = "A Reactive Streams implementation of the MongoDB Java driver"
1818
archivesBaseName = 'mongodb-driver-reactivestreams'
1919

2020
dependencies {
21-
compile project(':bson')
22-
compile project(':driver-core')
21+
compile project(path: ':bson', configuration: 'default')
22+
compile project(path: ':driver-core', configuration: 'default')
2323

2424
compile 'org.reactivestreams:reactive-streams:1.0.2'
2525

@@ -59,11 +59,8 @@ ext {
5959
pomName = 'The MongoDB Reactive Streams Driver'
6060
}
6161

62-
jar {
63-
bnd (
64-
'-exportcontents': "*;-noimport:=true",
65-
'Automatic-Module-Name': 'org.mongodb.driver.reactivestreams',
66-
'Build-Version': project.gitVersion,
67-
'Import-Package': 'org.bson.*,com.mongodb.*'
68-
)
62+
afterEvaluate {
63+
jar.manifest.attributes['Import-Package'] = 'org.bson.*,com.mongodb.*'
64+
jar.manifest.attributes['Automatic-Module-Name'] = 'org.mongodb.driver.reactivestreams'
65+
jar.manifest.attributes['Bundle-SymbolicName'] = 'org.mongodb.driver-reactivestreams'
6966
}

driver-scala/build.gradle

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ description = "A Scala wrapper / extension to the bson library"
1818
archivesBaseName = 'mongo-scala-driver'
1919

2020
dependencies {
21-
compile project(':bson-scala')
22-
compile project(':driver-reactive-streams')
21+
compile project(path: ':bson', configuration: 'default')
22+
compile project(path: ':bson-scala', configuration: 'default')
23+
compile project(path: ':driver-core', configuration: 'default')
24+
compile project(path: ':driver-reactive-streams', configuration: 'default')
25+
compile project(path: ':driver-sync', configuration: 'default')
26+
27+
compile 'org.reactivestreams:reactive-streams:1.0.2'
2328

2429
testCompile project(':util')
2530
testCompile project(':driver-sync')
@@ -91,11 +96,7 @@ ext {
9196
pomName = 'Mongo Scala Driver'
9297
}
9398

94-
jar {
95-
bnd (
96-
'-exportcontents': "*;-noimport:=true",
97-
'Automatic-Module-Name': 'org.mongodb.scala.mongo-scala-driver',
98-
'Build-Version': project.gitVersion,
99-
'Import-Package': 'org.bson.*,com.mongodb.*'
100-
)
99+
afterEvaluate {
100+
jar.manifest.attributes['Import-Package'] = 'org.bson.*,com.mongodb.*'
101+
jar.manifest.attributes['Automatic-Module-Name'] = 'org.mongodb.scala.mongo-scala-driver'
101102
}

driver-sync/build.gradle

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ ext {
2121
}
2222

2323
dependencies {
24-
compile project(':bson')
25-
compile project(':driver-core')
24+
compile project(path: ':bson', configuration: 'default')
25+
compile project(path: ':driver-core', configuration: 'default')
2626

2727
testCompile project(':bson').sourceSets.test.output
2828
testCompile project(':driver-core').sourceSets.test.output
@@ -41,11 +41,8 @@ tasks.withType(Checkstyle) {
4141
classpath = files(project(':driver-core').sourceSets.main.output, sourceSets.main.output)
4242
}
4343

44-
jar {
45-
bnd (
46-
'-exportcontents': "*;-noimport:=true",
47-
'Automatic-Module-Name': 'org.mongodb.driver.sync.client',
48-
'Build-Version': project.gitVersion,
49-
'Import-Package': 'org.bson.*,com.mongodb.*'
50-
)
44+
afterEvaluate {
45+
jar.manifest.attributes['Import-Package'] = 'org.bson.*,com.mongodb.*'
46+
jar.manifest.attributes['Automatic-Module-Name'] = 'org.mongodb.driver.sync.client'
47+
jar.manifest.attributes['Bundle-SymbolicName'] = 'org.mongodb.driver-sync'
5148
}

gradle/publish.gradle

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,23 @@ ext {
5757
}
5858
}
5959
}
60+
configureJarManifestAttributes = { project ->
61+
{ ->
62+
manifest.attributes['-exportcontents'] = "*;-noimport:=true"
63+
manifest.attributes['Automatic-Module-Name'] = project.group + '.' + project.archivesBaseName
64+
manifest.attributes['Build-Version'] = project.gitVersion
65+
manifest.attributes['Bundle-Version'] = project.version
66+
manifest.attributes['Bundle-Name'] = project.archivesBaseName
67+
manifest.attributes['Bundle-SymbolicName'] = project.group + '.' + project.archivesBaseName
68+
}
69+
}
6070
}
6171

6272
def scalaProjects = subprojects.findAll { it.name.contains('scala') }
6373
def javaProjects = subprojects.findAll { !scalaProjects.contains(it) && !['util', 'driver-benchmarks'].contains(it.name) }
6474

6575
configure(javaProjects) { project ->
76+
apply plugin: 'biz.aQute.bnd.builder'
6677
apply plugin: 'maven-publish'
6778
apply plugin: 'signing'
6879

@@ -92,6 +103,7 @@ configure(javaProjects) { project ->
92103
}
93104

94105
afterEvaluate {
106+
jar configureJarManifestAttributes(project)
95107
publishing.publications.mavenJava.artifactId = project.archivesBaseName
96108
signing {
97109
sign publishing.publications.mavenJava
@@ -100,6 +112,7 @@ configure(javaProjects) { project ->
100112
}
101113

102114
configure(scalaProjects) { project ->
115+
apply plugin: 'biz.aQute.bnd.builder'
103116
apply plugin: 'maven-publish'
104117
apply plugin: 'signing'
105118

@@ -130,6 +143,7 @@ configure(scalaProjects) { project ->
130143
}
131144

132145
afterEvaluate {
146+
jar configureJarManifestAttributes(project)
133147
signing {
134148
sign publishing.publications.mavenJava
135149
}

0 commit comments

Comments
 (0)