-
Notifications
You must be signed in to change notification settings - Fork 0
/
gradle-mvn-push.gradle
executable file
·184 lines (159 loc) · 5.3 KB
/
gradle-mvn-push.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
apply plugin: 'maven-publish'
apply plugin: 'signing'
final isSnapshot = version.contains('SNAPSHOT')
final skipTestFixtures() {
components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) {
skip()
}
components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) {
skip()
}
}
final sharedPublicationConfiguration(publication) {
publication.from components.java
publication.pom {
name = POM_NAME
description = 'T. J. Watson Libraries for Analysis'
inceptionYear = '2006'
url = 'https://github.com/wala/WALA'
ciManagement {
system = 'Travis CI'
url = 'https://travis-ci.org/wala/WALA'
}
developers {
[
// Current WALA maintainers, alphabetical by ID
juliandolby: 'Julian Dolby',
liblit : 'Ben Liblit',
msridhar : 'Manu Sridharan',
sjfink : 'Stephen Fink',
].each { entry ->
developer {
id = entry.key
name = entry.value
url = "https://github.com/$entry.key"
}
}
}
issueManagement {
system = 'GitHub'
url = "${publication.pom.url.get()}/issues"
}
licenses {
license {
name = 'Eclipse Public License v2.0'
url = "${publication.pom.url.get()}/blob/master/LICENSE"
}
}
mailingLists {
[
'commits',
'wala',
].each { topic ->
mailingList {
name = "wala-$topic"
archive = "https://sourceforge.net/p/wala/mailman/wala-$topic"
subscribe = "https://sourceforge.net/projects/wala/lists/wala-$topic"
unsubscribe = "https://sourceforge.net/projects/wala/lists/wala-$topic/unsubscribe"
post = "[email protected]"
}
}
}
scm {
url = publication.pom.url
connection = 'scm:git:git://github.com/wala/WALA.git'
developerConnection = 'scm:git:ssh://[email protected]/wala/WALA.git'
}
}
}
publishing {
publications {
// Everything we want to publish to remote repositories. That includes code, sources, and
// Javadoc for main sourceSet, but not tests or test fixtures.
remote(MavenPublication) {
sharedPublicationConfiguration it
skipTestFixtures()
}
// Everything we want to publish to local installations. That includes code, sources, and
// Javadoc for the both main and test-fixtures sourceSets, but not tests.
local(MavenPublication) {
sharedPublicationConfiguration it
if (sourceSets.testFixtures.allSource.isEmpty()) {
// Test-fixtures jar would be empty except for the manifest, so skip it.
skipTestFixtures()
} else {
// Test-fixtures jar will have real contents, so add Javadoc and sources
final testFixturesJavadoc = tasks.named('testFixturesJavadoc') {
destinationDir = file("$docsDir/testFixturesJavadoc")
}
tasks.register('testFixturesJavadocJar', Jar) {
classifier = 'test-fixtures-javadoc'
from testFixturesJavadoc.map { it.destinationDir }
}
tasks.register('testFixturesSourcesJar', Jar) {
classifier = 'test-fixtures-sources'
from sourceSets.testFixtures.allSource
}
// For each subproject with test fixtures, the `artifact` calls below trigger
// creation of three tasks during configuration: `testFixturesJar`,
// `testFixturesJavadocJar`, and `testFixturesSourcesJar`. Configuring those lazily
// instead will require a fix to <https://github.com/gradle/gradle/issues/6246>.
artifact testFixturesJar
artifact testFixturesJavadocJar
artifact testFixturesSourcesJar
}
}
}
repositories {
maven {
url = (isSnapshot
? project.properties.getOrDefault('SNAPSHOT_REPOSITORY_URL', 'https://oss.sonatype.org/content/repositories/snapshots/')
: project.properties.getOrDefault('RELEASE_REPOSITORY_URL', 'https://oss.sonatype.org/service/local/staging/deploy/maven2/')
)
credentials {
username = project.properties.get('SONATYPE_NEXUS_USERNAME')
password = project.properties.get('SONATYPE_NEXUS_PASSWORD')
}
}
maven {
name = 'fakeRemote'
url = "file://$rootProject.buildDir/maven-fake-remote-repository"
}
}
}
signing {
// Use external gpg cmd. This makes it easy to use gpg-agent,
// to avoid being prompted for a password once per artifact.
useGpgCmd()
// If anything about signing is misconfigured, fail loudly rather than quietly continuing with
// unsigned artifacts.
required = true
// Only sign publications sent to remote repositories; local install installatios are unsigned.
// The `sign` invocation below causes eager creation of three tasks per subproject:
// `signRemotePublication` is created immediately and `generateMetadataFileForRemotePublication`
// and `generatePomFileForRemotePublication` are created during configuration. Creating these
// lazily instead will require a fix to <https://github.com/gradle/gradle/issues/8796>.
sign publishing.publications.remote
}
// Only sign releases; snapshots are unsigned.
tasks.withType(Sign).configureEach {
onlyIf {
!isSnapshot
}
}
java {
withJavadocJar()
withSourcesJar()
}
// Remote publication set goes to remote repositories, so we don't publicly publish test fixtures.
tasks.withType(PublishToMavenRepository).configureEach {
onlyIf {
publication == publishing.publications.remote
}
}
// Local publication set goes to local installations, so we can reuse test fixtures locally.
tasks.withType(PublishToMavenLocal).configureEach {
onlyIf {
publication == publishing.publications.local
}
}