-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathecs-publish.gradle
310 lines (269 loc) · 9.61 KB
/
ecs-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
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
/*
* Copyright (c) 2015-2016, EMC Corporation.
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* + Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* + Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* + The name of EMC Corporation may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* --- Please put the following in ~/.gradle/gradle.properties ---
# path to Java 6 jre/lib (if installed)
java6Lib=
# set these if you plan on publishing. note: you will be prompted for passwords if necessary
sonatypeUsername=
githubUsername=
gitUsername=
# Located on the signing server. KeyId can be found using gpg --list-keys
signingKeyId=
signingSecretKeyRingFile=
*/// --- END ---
/* --- Set the following in your project's build.gradle along with any necessary custom logic ---
description 'Description of this project'
version '1.0.0'// omit the version to enable automated semantic versioning based on tags
// if your github project is different than your origin project
ext.githubProjectName = 'my-project-java'
// if your license is different than the default (BSD 3-Clause)
ext.licenseName = 'My License Name'
ext.licenseUrl = 'http://opensource.org/licenses/My-License'
buildscript {
// set the version of the common build script you will use
ext.commonBuildVersion = '1.5'
ext.commonBuildDir = "https://raw.githubusercontent.com/EMCECS/ecs-common-build/v$commonBuildVersion"
apply from: "$commonBuildDir/ecs-publish.buildscript.gradle", to: buildscript
}
allprojects {
apply from: "$commonBuildDir/ecs-publish.gradle"
}
// replace below with your project's actual dependencies
dependencies {
compile 'com.emc.ecs:smart-client:2.0.8'
testCompile 'junit:junit:4.11'
}
*/// --- END ---
group 'com.emc.ecs'
if (!hasProperty('githubProjectName')) ext.githubProjectName = project.name
if (!hasProperty('scmUrl')) ext.scmUrl = "https://github.com/EMCECS/${githubProjectName}"
if (!hasProperty('scmConnection')) ext.scmConnection = "scm:git@github.com:EMCECS/${githubProjectName}.git"
if (!hasProperty('githubUrl')) ext.githubUrl = "https://github.com/EMCECS/${githubProjectName}.git"
ext.aggregatedDocsDir = "$buildDir/aggregatedDocs"
if (!hasProperty('licenseName')) ext.licenseName = 'The BSD 3-Clause License'
if (!hasProperty('licenseUrl')) ext.licenseUrl = 'http://opensource.org/licenses/BSD-3-Clause'
buildscript {
apply from: "$commonBuildDir/ecs-publish.buildscript.gradle", to: buildscript
}
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: 'net.saliman.cobertura'
apply plugin: 'distribution'
apply plugin: 'signing'
apply plugin: 'maven'
defaultTasks 'distZip'
def isRootProject = (project == rootProject)
configurations {
jars.extendsFrom(signatures)
export // specifies additional artifacts in the root distribution
tools // specifies tool artifacts for the root distribution (in the tools/ directory)
}
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(':uploadJars')) {
if (!rootProject.hasProperty('signingPass')) {
rootProject.ext.signingPass = new String(System.console().readPassword('\nSigning key passphrase: '))
rootProject.ext.sonatypePass = new String(System.console().readPassword('\nSonatype password: '))
}
ext.'signing.keyId' = signingKeyId
ext.'signing.secretKeyRingFile' = signingSecretKeyRingFile
ext.'signing.password' = rootProject.ext.signingPass
uploadJars.repositories.mavenDeployer.repository.authentication.password = rootProject.ext.sonatypePass
}
if (isRootProject) {
if (taskGraph.hasTask(':publishGhPages')) {
githubPages.credentials.password = new String(System.console().readPassword('\nGithub password: '))
}
if (taskGraph.hasTask(':release')) {
def gitPassword = new String(System.console().readPassword('\nOrigin password: '))
System.setProperty('org.ajoberstar.grgit.auth.username', gitUsername)
System.setProperty('org.ajoberstar.grgit.auth.password', gitPassword)
}
}
}
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
compileJava {
sourceCompatibility = 1.6
targetCompatibility = 1.6
if (project.hasProperty('java6Lib')) {
options.fork = true
options.bootClasspath = new File(java6Lib).listFiles(
[accept:{d, f-> f ==~ /.*\.jar/ }] as FilenameFilter
).join(File.pathSeparator)
}
}
repositories {
mavenCentral()
mavenLocal()
}
test {
jvmArgs '-XX:-UseSplitVerifier' // required for cobertura and Java 1.7
}
def projectPom = {
project {
name project.name
description project.description
url 'https://community.emc.com/community/products/vipr#developer'
scm {
url scmUrl
connection scmConnection
developerConnection scmConnection
}
licenses {
license {
name licenseName
url licenseUrl
distribution 'repo'
}
}
developers {
developer {
id 'EMCECS'
name 'EMC ViPR'
}
}
}
}
task writePom {
ext.pomFile = file("$buildDir/pom.xml")
outputs.file pomFile
doLast {
pom(projectPom).writeTo pomFile
}
}
jar {
doFirst {
manifest {
attributes 'Implementation-Version': project.version,
'Class-Path': configurations.runtime.collect { it.getName() }.join(' ')
}
}
into("META-INF/maven/$project.group/$project.name") {
from writePom
}
}
javadoc {
if (JavaVersion.current() >= JavaVersion.VERSION_1_8) options.addStringOption('Xdoclint:none', '-quiet')
else options.quiet()
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from "${docsDir}/javadoc"
}
javadocJar.dependsOn javadoc
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
jars jar
jars javadocJar
jars sourcesJar
}
distributions {
main {
contents {
from configurations.jars.artifacts.files
from configurations.export.artifacts.files
from { subprojects.configurations.export.artifacts.files }
into('tools') {
from configurations.tools.artifacts.files
from { subprojects.configurations.tools.artifacts.files }
}
from('.') {
include '*.txt'
}
into('3rd-party-licenses') {
from '3rd-party-licenses'
}
into('lib') {
from configurations.runtime
}
}
}
}
signing {
required { gradle.taskGraph.hasTask(':uploadJars') }
sign configurations.jars
}
uploadJars {
repositories {
mavenDeployer {
beforeDeployment { deployment -> signing.signPom(deployment) }
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
authentication(userName: sonatypeUsername, password: '')
}
pom projectPom
}
}
}
task aggregateDocs << {
def docSubDir = isRootProject ? '' : "/${project.name}"
if (project.hasProperty('release.stage') && project.ext['release.stage'] == 'final') {
copy {
from docsDir
into "${rootProject.aggregatedDocsDir}/latest${docSubDir}"
}
}
copy {
from docsDir
into "${rootProject.aggregatedDocsDir}/${project.version}${docSubDir}"
}
}
aggregateDocs.dependsOn javadoc
aggregateDocs.dependsOn { subprojects.collect { it.tasks['aggregateDocs'] } }
// we can't release or publish sub-projects
if (isRootProject) {
apply plugin: 'base'
apply plugin: 'org.ajoberstar.grgit'
apply plugin: 'org.ajoberstar.github-pages'
apply plugin: 'org.ajoberstar.release-opinion'
githubPages {
repoUri = githubUrl
targetBranch = 'gh-pages'
credentials {
username = githubUsername
password = ''
}
pages {
from aggregatedDocsDir
}
deleteExistingFiles = false
}
publishGhPages.dependsOn aggregateDocs, test
tasks.release.dependsOn test, uploadJars, publishGhPages, distZip
} else {
task publishGhPages << {}
task release << {}
tasks.release.dependsOn test
}
clean {
delete aggregatedDocsDir
}
task wrapper(type: Wrapper) {
gradleVersion = '2.14'
}