Skip to content

Commit 70dffed

Browse files
committed
Updated Maven deployment configuration. Extracted Osgi configuration.
1 parent 3d56e42 commit 70dffed

5 files changed

Lines changed: 98 additions & 106 deletions

File tree

build.gradle

Lines changed: 6 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ configure(subprojects.findAll {it.name != 'util'}) {
2525
apply plugin: 'checkstyle'
2626
apply plugin: 'pmd'
2727
apply plugin: 'findbugs'
28-
apply plugin: 'osgi'
2928
apply plugin: 'jacoco'
3029

3130
evaluationDependsOn(':util')
@@ -117,22 +116,11 @@ configure(subprojects.findAll {it.name != 'util'}) {
117116

118117
tasks.matching { (it instanceof FindBugs) || (it instanceof Pmd) }.all {
119118
reports {
120-
xml.enabled = project.hasProperty('xmlReportsEnabled')
121-
html.enabled = !project.hasProperty('xmlReportsEnabled')
119+
xml.enabled = project.hasProperty('xmlReportsEnabled') && project.property('xmlReportsEnabled').toBoolean()
120+
html.enabled = !xml.enabled
122121
}
123122
}
124123

125-
/* Artifacts */
126-
task sourcesJar(type: Jar) {
127-
classifier = 'sources'
128-
from sourceSets.main.allSource
129-
}
130-
131-
task javadocJar(type: Jar, dependsOn: javadoc) {
132-
classifier = 'javadoc'
133-
from javadoc
134-
}
135-
136124
javadoc {
137125
dependsOn project(':util').compileJava //We need taglets to be compiled
138126
options.author = true
@@ -142,27 +130,13 @@ configure(subprojects.findAll {it.name != 'util'}) {
142130
options.taglets 'ManualTaglet'
143131
}
144132

145-
artifacts {
146-
archives sourcesJar
147-
archives javadocJar
148-
}
149133
}
150134

151135
//////////////////////////////////////////
152136
// Project specific behavior //
153137
//////////////////////////////////////////
154138

155-
project(':bson') {
156-
157-
jar {
158-
manifest {
159-
attributes(
160-
'Bundle-License': 'http://www.apache.org/licenses/LICENSE-2.0.txt',
161-
'Bundle-Name': 'BSON'
162-
)
163-
}
164-
}
165-
}
139+
project(':bson') { }
166140

167141
project(':driver') {
168142

@@ -180,19 +154,6 @@ project(':driver') {
180154
acceptanceCompile sourceSets.functional.runtimeClasspath
181155
}
182156

183-
jar {
184-
from project(':bson').sourceSets.main.output
185-
manifest {
186-
attributes(
187-
'Bundle-License': 'http://www.apache.org/licenses/LICENSE-2.0.txt',
188-
'Bundle-Name': 'MongoDB Java Driver',
189-
'Bundle-SymbolicName': 'org.mongodb.driver',
190-
'Import-Package': 'javax.management, javax.net, javax.net.ssl',
191-
192-
)
193-
}
194-
}
195-
196157
task functionalTest(type: Test, dependsOn: test) {
197158
testClassesDir = sourceSets.functional.output.classesDir
198159
classpath = sourceSets.functional.runtimeClasspath
@@ -202,14 +163,6 @@ project(':driver') {
202163
testClassesDir = sourceSets.acceptance.output.classesDir
203164
classpath = sourceSets.acceptance.runtimeClasspath
204165
}
205-
206-
sourcesJar {
207-
from project(':bson').sourceSets.main.allSource
208-
}
209-
210-
javadoc {
211-
source project(':bson').sourceSets.main.allJava
212-
}
213166
}
214167

215168
project(':driver-compat') {
@@ -229,29 +182,6 @@ project(':driver-compat') {
229182
failOnSrcError = false
230183
}
231184

232-
jar {
233-
from project(':bson').sourceSets.main.output
234-
from project(':driver').sourceSets.main.output
235-
manifest {
236-
attributes(
237-
'Bundle-License': 'http://www.apache.org/licenses/LICENSE-2.0.txt',
238-
'Bundle-Name': 'MongoDB Java Driver',
239-
'Bundle-SymbolicName': 'org.mongodb.mongo-java-driver',
240-
'Import-Package': 'javax.management, javax.net, javax.net.ssl'
241-
)
242-
}
243-
}
244-
245-
sourcesJar {
246-
from project(':bson').sourceSets.main.allSource
247-
from project(':driver').sourceSets.main.allSource
248-
}
249-
250-
javadoc {
251-
source project(':bson').sourceSets.main.allJava
252-
source project(':driver').sourceSets.main.allJava
253-
}
254-
255185
checkstyle {
256186
configFile = new File("$configDir/checkstyle-lite.xml")
257187
}
@@ -275,5 +205,6 @@ gradle.buildFinished { BuildResult result ->
275205
gradle.rootProject.logger.error("\n* Warning:\nJDK ${JavaVersion.VERSION_1_7} is minimal requirement for building the driver. You have ${JavaVersion.current()}.")
276206
}
277207

278-
apply from: 'gradle/ide-configuration.gradle'
279-
apply from: 'gradle/maven-configuration.gradle'
208+
apply from: 'gradle/ide-settings.gradle'
209+
apply from: 'gradle/maven-deployment.gradle'
210+
apply from: 'gradle/osgi-compatibility.gradle'

buildSrc/src/main/groovy/org/gradle/api/plugins/clirr/ClirrPlugin.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ class ClirrPlugin implements Plugin<Project> {
102102
) {
103103
origfiles(file: baseJar.getPath())
104104
newfiles(dir: jarTask.destinationDir, includes: jarTask.archiveName)
105+
newClassPath {
106+
pathElement(path: project.configurations.compile.asPath)
107+
}
108+
105109
extension.formats.each { format ->
106110
if (format != 'html'){
107111
formatter(type: format, outfile: "$extension.reportsDir/report.${format == 'xml' ? 'xml' : 'txt'}")
Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,58 @@
1414
* limitations under the License.
1515
*/
1616

17-
configure(subprojects.findAll {it.name != 'util'}) {
17+
configure(subprojects.findAll { it.name != 'util' }) {
1818
apply plugin: 'maven'
1919
apply plugin: 'signing'
2020

21-
project.ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
21+
/* Artifacts */
22+
task sourcesJar(type: Jar) {
23+
classifier = 'sources'
24+
from sourceSets.main.allSource
25+
}
26+
27+
task javadocJar(type: Jar) {
28+
classifier = 'javadoc'
29+
from javadoc
30+
}
31+
32+
artifacts {
33+
archives sourcesJar
34+
archives javadocJar
35+
}
2236

2337
signing {
24-
required { project.isReleaseVersion && gradle.taskGraph.hasTask("deploy") }
38+
required { gradle.taskGraph.hasTask("uploadArchives") }
2539
sign configurations.archives
2640
}
2741

42+
project.ext.mavenDeployers = []
43+
44+
def pom = { config ->
45+
project.mavenDeployers*.pom config
46+
}
47+
2848
install {
29-
project.ext.installer = repositories.mavenInstaller
49+
project.mavenDeployers << repositories.mavenInstaller
3050
}
3151

3252
uploadArchives {
33-
project.ext.deployer = repositories.mavenDeployer {
34-
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots')
53+
project.mavenDeployers << repositories.mavenDeployer {
54+
def sonatypeCredentials = [
55+
userName: project.properties.sonatypeUsername,
56+
password: project.properties.sonatypePassword
57+
]
58+
59+
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots') {
60+
authentication(sonatypeCredentials)
61+
}
3562
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
36-
if (project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')) {
37-
authentication(
38-
userName: project.property('sonatypeUsername'),
39-
password: project.property('sonatypePassword')
40-
)
41-
}
63+
authentication(sonatypeCredentials)
4264
}
4365
}
4466
}
4567

46-
[project.installer, project.deployer]*.pom {
68+
project.mavenDeployers*.pom {
4769

4870
project {
4971
scm {
@@ -67,51 +89,45 @@ configure(subprojects.findAll {it.name != 'util'}) {
6789
}
6890
}
6991

70-
whenConfigured { pom ->
71-
pom.dependencies.removeAll { dep -> dep.scope != 'compile' }
72-
pom.dependencies*.scope = null
92+
whenConfigured { resultPom ->
93+
resultPom.dependencies.removeAll { dep -> dep.scope != 'compile' }
94+
resultPom.dependencies*.scope = null
7395
}
7496
}
7597
}
7698

7799
project(':bson') {
78-
[project.installer, project.deployer]*.pom {
100+
pom {
79101
project {
80102
name 'BSON'
81103
description 'The BSON libs'
82104
url 'http://bsonspec.org/'
83105
}
84-
85-
whenConfigured { pom ->
86-
pom.dependencies.removeAll { true }
87-
}
88106
}
89107
}
90108

91109
project(':driver') {
92-
[project.installer, project.deployer]*.pom {
110+
111+
archivesBaseName = 'mongodb-driver'
112+
113+
pom {
93114
project {
94115
name 'MongoDB Java Driver'
95116
description 'The MongoDB Java Driver'
96117
url 'http://www.mongodb.org'
97118
}
98-
99-
whenConfigured { pom ->
100-
pom.dependencies.removeAll { true }
101-
}
102119
}
103120
}
104121

105122
project(':driver-compat') {
106-
[project.installer, project.deployer]*.pom {
123+
124+
archivesBaseName = 'mongo-java-driver'
125+
126+
pom {
107127
project {
108128
name 'MongoDB Java Driver'
109129
description 'The MongoDB Java Driver'
110130
url 'http://www.mongodb.org'
111131
}
112-
113-
whenConfigured { pom ->
114-
pom.dependencies.removeAll { true }
115-
}
116132
}
117133
}

gradle/osgi-compatibility.gradle

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
configure(subprojects.findAll {it.name != 'util'}) {
2+
apply plugin: 'osgi'
3+
}
4+
5+
project(':bson') {
6+
jar {
7+
manifest {
8+
attributes(
9+
'Bundle-License': 'http://www.apache.org/licenses/LICENSE-2.0.txt',
10+
'Bundle-Name': 'BSON'
11+
)
12+
}
13+
}
14+
}
15+
16+
project(':driver') {
17+
jar {
18+
manifest {
19+
attributes(
20+
'Bundle-License': 'http://www.apache.org/licenses/LICENSE-2.0.txt',
21+
'Bundle-Name': 'MongoDB Java Driver',
22+
'Bundle-SymbolicName': 'org.mongodb.mongodb-driver',
23+
'Import-Package': 'javax.management, javax.net, javax.net.ssl',
24+
25+
)
26+
}
27+
}
28+
}
29+
30+
project(':driver-compat') {
31+
jar {
32+
manifest {
33+
attributes(
34+
'Bundle-License': 'http://www.apache.org/licenses/LICENSE-2.0.txt',
35+
'Bundle-Name': 'MongoDB Java Driver',
36+
'Bundle-SymbolicName': 'org.mongodb.mongo-java-driver',
37+
'Import-Package': 'javax.management, javax.net, javax.net.ssl'
38+
)
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)