forked from mongodb/mongo-java-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.gradle
163 lines (144 loc) · 5.61 KB
/
publish.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
* Copyright 2008-present MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Configures publishing of the main java projects
*/
// Publishing helpers
ext {
configurePom = { project ->
{ ->
name = project.hasProperty('pomName') ? project.getProperty('pomName') : project.name
description = project.description
url = project.hasProperty('pomURL') ? project.getProperty('pomURL') : 'https://www.mongodb.com/'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
scm {
url = 'https://github.com/mongodb/mongo-java-driver'
connection = 'scm:https://github.com/mongodb/mongo-java-driver.git'
developerConnection = 'scm:git@github.com:mongodb/mongo-java-driver.git'
}
developers {
developer {
name = 'Various'
organization = 'MongoDB'
}
}
}
}
configureMavenRepositories = { project ->
{ ->
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
maven {
url = project.version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username project.hasProperty('nexusUsername') ? project.getProperty('nexusUsername') : ''
password project.hasProperty('nexusPassword') ? project.getProperty('nexusPassword') : ''
}
}
maven {
url = "$rootDir/build/repo"
}
}
}
configureJarManifestAttributes = { project ->
{ ->
manifest.attributes['-exportcontents'] = "*;-noimport:=true"
manifest.attributes['Build-Version'] = project.gitVersion
manifest.attributes['Bundle-Version'] = project.version
manifest.attributes['Bundle-Name'] = project.archivesBaseName
manifest.attributes['Bundle-SymbolicName'] = project.group + '.' + project.archivesBaseName
}
}
}
def projectsNotPublishedToMaven = project(":util").allprojects + project(":driver-benchmarks") + project("driver-workload-executor") + project("driver-lambda") + project(":graalvm-native-image-app")
def publishedProjects = subprojects - projectsNotPublishedToMaven
def scalaProjects = publishedProjects.findAll { it.name.contains('scala') }
def javaProjects = publishedProjects - scalaProjects
def projectsWithManifest = publishedProjects.findAll {it.name != 'driver-legacy' }
configure(javaProjects) { project ->
apply plugin: 'maven-publish'
apply plugin: 'signing'
task sourcesJar(type: Jar) {
from project.sourceSets.main.allJava
classifier = 'sources'
}
task javadocJar(type: Jar) {
from javadoc
classifier = 'javadoc'
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = project.archivesBaseName
from project.components.java
artifact sourcesJar
artifact javadocJar
suppressPomMetadataWarningsFor("dateTimeSupportApiElements")
suppressPomMetadataWarningsFor("dateTimeRuntimeElements")
}
}
repositories configureMavenRepositories(project)
}
afterEvaluate {
publishing.publications.mavenJava.artifactId = project.archivesBaseName
publishing.publications.mavenJava.pom configurePom(project)
signing {
useInMemoryPgpKeys(findProperty("signingKey"), findProperty("signingPassword"))
sign publishing.publications.mavenJava
}
}
}
configure(scalaProjects) { project ->
apply plugin: 'maven-publish'
apply plugin: 'signing'
task sourcesJar(type: Jar) {
from project.sourceSets.main.allScala
classifier = 'sources'
}
task scaladocJar(type: Jar) {
from scaladoc
classifier = 'javadoc'
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = project.archivesBaseName.contains('bson') ? 'mongo-scala-bson' : 'mongo-scala-driver'
from project.components.java
artifact sourcesJar
artifact scaladocJar
}
}
repositories configureMavenRepositories(project)
}
afterEvaluate {
publishing.publications.mavenJava.pom configurePom(project)
signing {
useInMemoryPgpKeys(findProperty("signingKey"), findProperty("signingPassword"))
sign publishing.publications.mavenJava
}
}
}
configure(projectsWithManifest) { project ->
apply plugin: 'biz.aQute.bnd.builder'
afterEvaluate {
jar configureJarManifestAttributes(project)
}
}