-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig.gradle
284 lines (241 loc) · 7.68 KB
/
config.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
import org.gradle.plugins.signing.Sign
project.ext.artifactMapping = [
'git-state-plugin': 'de.huxhorn.gradle.git-state-plugin'
]
buildscript {
apply from: 'dependencyDefinitions.gradle'
project.ext.localReleaseRepoFile = new File("${System.properties.'user.home'}/local-gradle-repository/release")
project.ext.localSnapshotRepoFile = new File("${System.properties.'user.home'}/local-gradle-repository/snapshot")
project.ext.localReleaseRepo = localReleaseRepoFile.toURL().toString()
project.ext.localSnapshotRepo = localSnapshotRepoFile.toURL().toString()
repositories {
mavenLocal()
mavenCentral()
maven {
url localReleaseRepo
}
maven {
url localSnapshotRepo
}
}
dependencies {
// needed for syncSnapshot and syncStaging
classpath "org.apache.maven.wagon:wagon-webdav-jackrabbit:2.2"
}
}
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.allTasks.any { it instanceof Sign }) {
String pgpPassword = System.properties.'pgpPassword'
if(!pgpPassword) {
java.io.Console console = System.console()
pgpPassword = new String(console.readPassword("\nPGP Private Key Password: "))
}
allprojects { ext.'signing.keyId' = '740A1840' }
allprojects { ext.'signing.secretKeyRingFile' = new File("${System.properties['user.home']}/.gnupg/secring.gpg").absolutePath }
allprojects { ext."signing.password" = pgpPassword }
}
}
if(!System.properties.'release') {
defaultTasks 'build', 'uploadPublished'
} else {
defaultTasks 'build', 'uploadPublished', 'signJavadocZip', 'signSourceZip'
}
allprojects {
defaultTasks 'clean', 'build', 'uploadArchives'
group = 'de.huxhorn.gradle'
}
project(':git-state-plugin') {
version = '0.0.3'
if(!System.properties.'release')
{
version = version + '-SNAPSHOT'
}
}
subprojects {
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'signing'
signing {
if (System.properties.'release') {
sign configurations.archives
}
}
task sourceJar(type: Jar) { from sourceSets.main.allSource; classifier = 'sources' }
task javadocJar(type: Jar) { from javadoc.outputs.files; classifier = 'javadoc' }
artifacts { archives sourceJar, javadocJar }
project.ext.defaultProject = {
url 'http://gradle.huxhorn.de'
name 'gradle-pgp-plugin'
description 'Plugin providing the ability to sign artifacts and pom before uploading to a repository.'
inceptionYear '2010'
packaging 'jar' // does not work, fixed below
// See http://jira.codehaus.org/browse/GRADLE-1200
scm {
connection 'scm:git:git://github.com/huxi/huxi-gradle-plugins.git'
developerConnection 'scm:git:ssh://[email protected]:huxi/huxi-gradle-plugins.git'
url 'http://github.com/huxi/huxi-gradle-plugins/'
}
licenses {
license {
name 'GNU Lesser General Public License v3 (LGPL)'
url 'http://www.gnu.org/copyleft/lesser.html'
distribution 'repo'
}
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'huxhorn'
email '[email protected]'
name 'Joern Huxhorn'
organization = 'Joern Huxhorn' // = is workaround for http://jira.codehaus.org/browse/GRADLE-1200
organizationUrl 'http://lilith.huxhorn.de'
roles {
role 'Developer'
}
}
}
properties {
'project.build.sourceEncoding' 'UTF-8'
'project.reporting.outputEncoding' 'UTF-8'
}
}
repositories {
mavenLocal()
mavenCentral()
maven {
url localReleaseRepo
}
maven {
url localSnapshotRepo
}
}
def mapped=artifactMapping[project.name];
if(!mapped)
{
throw new IllegalStateException("${project.name} does not have an entry in artifactMapping!");
}
archivesBaseName=mapped
configurations {
all*.exclude group: 'commons-logging', module: 'commons-logging'
published.extendsFrom archives, signatures
}
dependencies {
compile gradleApi()
compile localGroovy()
testCompile libraries.junit
testCompile libraries.'slf4j-api'
testRuntime libraries.'logback-classic'
}
jar {
manifest.attributes provider: 'gradle'
}
def deployer = null
// the following is a workaround for http://jira.codehaus.org/browse/GRADLE-443
uploadArchives {
deployer = repositories.mavenDeployer {
repository(url: localReleaseRepo)
snapshotRepository(url: localSnapshotRepo)
pom.whenConfigured { pom ->
// dep is a native Maven dependency object (With properties artifactId, groupId, ...)
for(dep in pom.dependencies) {
//println(dep.artifactId)
def mapping=artifactMapping[dep.artifactId];
if(mapping) {
//println("Mapping ${dep.artifactId} to ${mapping}...")
dep.artifactId=mapping
}
}
}
beforeDeployment { MavenDeployment deployment ->
if(System.properties.'release') {
signing.signPom(deployment)
}
}
}
}
def installer = install.repositories.mavenInstaller
installer.pom.project defaultProject
deployer.pom.project defaultProject
// The following fixes the broken packaging
// See http://jira.codehaus.org/browse/GRADLE-1200
// Thanks xlson
installer.pom.withXml { XmlProvider xmlProvider ->
def xml = xmlProvider.asString()
def pomXml = new XmlParser().parseText(xml.toString())
pomXml.version[0] + { packaging('jar') }
def newXml = new StringWriter()
def printer = new XmlNodePrinter(new PrintWriter(newXml))
printer.preserveWhitespace = true
printer.print(pomXml)
xml.setLength(0)
xml.append(newXml.toString())
}
deployer.pom.withXml { XmlProvider xmlProvider ->
def xml = xmlProvider.asString()
def pomXml = new XmlParser().parseText(xml.toString())
pomXml.version[0] + { packaging('jar') }
def newXml = new StringWriter()
def printer = new XmlNodePrinter(new PrintWriter(newXml))
printer.preserveWhitespace = true
printer.print(pomXml)
xml.setLength(0)
xml.append(newXml.toString())
}
}
def deleteClosure
deleteClosure = {
// delete content of it recursively
it.eachDir( deleteClosure );
it.eachFile {
it.delete()
}
}
task cleanStaging doLast({
deleteClosure(localReleaseRepoFile)
})
task cleanSnapshot doLast({
deleteClosure(localSnapshotRepoFile)
})
task syncStaging doLast({
if (project.hasProperty('remoteUsername') && project.hasProperty('remotePassword')) {
def stagingRepos = new org.apache.maven.wagon.repository.Repository('staging', 'https://oss.sonatype.org/service/local/staging/deploy/maven2')
def auth = new org.apache.maven.wagon.authentication.AuthenticationInfo()
auth.userName = remoteUsername
auth.password = remotePassword
def wagon = new org.apache.maven.wagon.providers.webdav.WebDavWagon()
wagon.connect(stagingRepos, auth)
localReleaseRepoFile.eachFile {
if (it.directory) {
wagon.putDirectory(it, it.name)
} else {
wagon.put(it, it.name)
}
}
} else {
println "Can't sync staging as credentials aren't set. Set with -PremoteUsername=user -PremotePassword=password."
}
})
task syncSnapshot doLast({
if (project.hasProperty('remoteUsername') && project.hasProperty('remotePassword')) {
def snapshotRepos = new org.apache.maven.wagon.repository.Repository('snapshot', 'https://oss.sonatype.org/content/repositories/snapshots')
def auth = new org.apache.maven.wagon.authentication.AuthenticationInfo()
auth.userName = remoteUsername
auth.password = remotePassword
def wagon = new org.apache.maven.wagon.providers.webdav.WebDavWagon()
wagon.connect(snapshotRepos, auth)
localSnapshotRepoFile.eachFile {
if (it.directory) {
wagon.putDirectory(it, it.name)
} else {
wagon.put(it, it.name)
}
}
} else {
println "Can't sync snapshots as credentials aren't set. Set with -PremoteUsername=user -PremotePassword=password."
}
})