forked from stevesaliman/gradle-properties-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
259 lines (225 loc) · 7.52 KB
/
build.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
#!groovy
// The above triggers groovy syntax highlighting in vim
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:0.5'
classpath 'com.gradle.publish:plugin-publish-plugin:0.9.1'
classpath 'org.codehaus.groovy:groovy-all:2.3.4'
}
}
plugins {
id 'net.saliman.cobertura' version '2.2.7'
}
apply plugin: "groovy"
apply plugin: "maven"
apply plugin: "signing"
apply plugin: "idea"
apply plugin: "eclipse"
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.gradle.plugin-publish'
sourceCompatibility = 1.6
targetCompatibility = 1.6
// Release version that won't conflict with the bintray plugin
def releaseVersion = "1.4.6"
group = "net.saliman"
archivesBaseName = 'gradle-properties-plugin'
version = releaseVersion
ext.isSnapshot = releaseVersion.endsWith("SNAPSHOT")
if ( isSnapshot ) {
println "using snapshot"
ext.mavenCentralUploadUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
} else {
println "using staging"
ext.mavenCentralUploadUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}
configurations {
archives
}
repositories {
jcenter()
mavenCentral()
mavenLocal()
}
dependencies {
compile gradleApi()
compile localGroovy()
testCompile "junit:junit:4.12"
archives "org.apache.maven.wagon:wagon-ssh:2.2"
archives "org.apache.maven.wagon:wagon-ssh-external:2.2"
}
task sourceJar(type: Jar) {
description = "An archive of the source code for Maven Central"
classifier = "sources"
from sourceSets.main.groovy
}
task groovydocJar(type: Jar) {
description = "An archive of the GroovyDocs for Maven Central"
classifier = 'javadoc'
from groovydoc
}
artifacts {
archives jar, groovydocJar, sourceJar
}
signing {
sign configurations.archives
}
// Only *require* signing if we are uploading a non snapshot version. If we
// do need to sign, make sure we've got the properties we need to do the
// signing.
import org.gradle.plugins.signing.Sign
gradle.taskGraph.whenReady { taskGraph ->
tasks.withType(org.gradle.plugins.signing.Sign).all {
required = taskGraph.hasTask(":uploadArchives") && !isSnapshot
if ( required ) {
// Use Java 6's console to read from the console (no good for a CI
// environment)
Console console = System.console()
console.printf "\n\nWe have to sign some things in this build...\n\n"
if ( !project.hasProperty('signing.keyId') ) {
def id = console.readLine("PGP Key Id: ")
allprojects { ext."signing.keyId" = id }
}
if ( !project.hasProperty('signing.secretKeyRingFile') ) {
ef file = console.readLine("PGP Secret Key Ring File (absolute path): ")
allprojects { ext."signing.secretKeyRingFile" = file }
}
if ( !project.hasProperty('signing.password') ) {
def password = console.readPassword("PGP Private Key Password: ")
allprojects { ext."signing.password" = password }
}
//def x = ext."signing.keyId"
//println "using key ${x}"
console.printf "\nThanks.\n\n"
}
}
}
uploadArchives {
// We can't use taskGraph.whenReady because it doesn't resolve until after
// configuration. The startParameter is not as good, but it probably
// good enough for our purposes.
if ( gradle.startParameter.taskNames.contains("uploadArchives") ) {
// Use Java 6's console to read from the console (no good for a CI
// environment)
Console console = System.console()
console.printf "\n\nWe have to upload some things in this build...\n\n"
if ( !project.hasProperty('mavenCentralUsername') ) {
def mavenCentralUsername = console.readLine("Maven Central Username: ")
allprojects { ext."mavenCentralUsername" = mavenCentralUsername }
}
if ( !project.hasProperty('mavenCentralPassword') ) {
def mavenCentralPassword = console.readLine("Maven Central Password: ")
allprojects { ext."mavenCentralPassword" = mavenCentralPassword }
}
repositories {
mavenDeployer {
if ( signing.signatory ) {
beforeDeployment { signing.signPom(it) }
}
configuration = configurations.archives
//repository(url: "file://$buildDir/m2repo")
repository(url: mavenCentralUploadUrl) {
authentication(userName: mavenCentralUsername,
password: mavenCentralPassword)
releases(updatePolicy: "always")
snapshots(updatePolicy: "always")
}
pom.project(pomConfiguration)
}
}
}
}
idea {
module {
//if you prefer different output folders
inheritOutputDirs = false
outputDir = file('build/idea/out')
testOutputDir = file('build/idea/testOut')
//if you love browsing Javadoc
downloadJavadoc = true
//and hate reading sources :)
downloadSources = false
}
}
// Configure Idea plugin so that it generates project files that use git for
// source control. Thank you to Eric Wendelin for showing me this trick.
idea.project.ipr.withXml { provider ->
def node = provider.asNode()
def vcsConfig = node.component.find { it.'@name' == 'VcsDirectoryMappings' }
vcsConfig.mapping[0].'@vcs' = 'Git'
// set gradle home
def gradleSettings = node.appendNode('component',[name: 'GradleSettings'])
gradleSettings.appendNode('option', [name: 'SDK_HOME', value: gradle.gradleHomeDir.absolutePath])
}
// Create POM config and return for use by other tasks.
//
def getPomConfiguration() {
return {
name 'Gradle Properties Plugin'
packaging 'jar'
description "A Gradle plugin for loading and working with properties, enhancing Gradle's built in functionality."
url 'https://github.com/stevesaliman/gradle-properties-plugin'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'stevesaliman'
name 'Steven C. Saliman'
email '[email protected]'
}
}
scm {
connection 'scm:https://[email protected]/stevesaliman/gradle-properties-plugin'
developerConnection 'scm:[email protected]:stevesaliman/gradle-properties-plugin.git'
url 'https://github.com/stevesaliman/gradle-properties-plugin'
}
}
}
bintray {
user = project.hasProperty('bintrayUsername') ? project.getProperty('bintrayUsername') : ''
key = project.hasProperty('bintrayApiKey') ? project.getProperty('bintrayApiKey') : ''
configurations = [ 'archives' ]
pkg {
repo = 'maven'
name = 'gradle-properties-plugin'
desc = "A Gradle plugin for loading and working with properties, enhancing Gradle's built in functionality."
licenses = [ 'Apache-2.0' ]
websiteUrl = 'https://github.com/stevesaliman/gradle-properties-plugin'
issueTrackerUrl = 'https://github.com/stevesaliman/gradle-properties-plugin/issues'
vcsUrl = 'https://github.com/stevesaliman/gradle-properties-plugin.git'
labels = [ 'gradle', 'properties' ]
publicDownloadNumbers = true
version {
//name = version
// desc = 'version specific desc'
vcsTag = "Release_${releaseVersion}"
attributes = [
'gradle-plugin': 'net.saliman.properties:net.saliman:gradle-properties-plugin'
]
}
}
}
// configuration for publishing to the Gradle plugins portal
pluginBundle {
website = 'https://github.com/stevesaliman/gradle-properties-plugin'
vcsUrl = 'https://github.com/stevesaliman/gradle-properties-plugin.git'
description = 'A Gradle plugin for loading and working with properties, enhancing Gradle\'s built in functionality.'
tags = [ 'gradle', 'properties' ]
plugins {
propertiesPlugin {
id = 'net.saliman.properties'
displayName = 'Gradle Properties plugin'
}
}
}