-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
237 lines (207 loc) · 6.83 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
plugins {
id 'idea'
id 'eclipse'
id 'java'
id 'net.saliman.cobertura' version '4.0.0'
id 'distribution'
id 'com.github.johnrengelman.shadow' version '6.1.0'
id 'com.github.jk1.dependency-license-report' version '1.19'
id 'signing'
id 'maven'
id 'org.ajoberstar.git-publish' version '3.0.1'
id 'nebula.release' version '15.3.1'
}
group 'com.emc.ecs'
description = 'The purpose of the bucket-wipe tool is to enumerate a bucket and delete its contents in parallel threads. At the end the bucket is optionally deleted.'
// name of the github project repository
ext.githubProjectName = project.name
// URL to github project
ext.githubProjectUrl = "https://github.com/EMCECS/${githubProjectName}"
// git remote scm address
ext.githubScmUrl = "scm:[email protected]:EMCECS/${githubProjectName}.git"
// git remote https address
ext.githubRemoteUrl = "https://github.com/EMCECS/${githubProjectName}.git"
// license info
ext.licenseName = 'Apache License 2.0'
ext.licenseUrl = 'http://www.apache.org/licenses/'
// main execution class
ext.mainClass = 'com.emc.ecs.tool.BucketWipe'
defaultTasks 'distZip'
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
implementation 'com.emc.ecs:object-client:3.4.4'
implementation 'com.emc.ecs:smart-client-ecs:3.0.1'
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.19.0'
implementation 'commons-cli:commons-cli:1.5.0'
testImplementation 'junit:junit:4.13.2'
}
configurations {
jars.extendsFrom(signatures)
}
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceCompatibility = 1.8
def projectPom = {
project {
name project.name
description project.description
url githubProjectUrl
scm {
url githubProjectUrl
connection githubScmUrl
developerConnection githubScmUrl
}
licenses {
license {
name licenseName
url licenseUrl
distribution 'repo'
}
}
developers {
developer {
id 'EMCECS'
name 'Dell EMC ECS'
}
}
}
}
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
}
}
shadowJar {
classifier ''
mergeServiceFiles()
manifest {
attributes 'Main-Class': mainClass,
'Implementation-Version': project.version,
'Class-Path': { configurations.runtime.collect { it.getName() }.join(' ') }
}
}
javadoc {
options.addStringOption('Xdoclint:none', '-quiet')
}
task javadocJar(type: Jar) {
archiveClassifier = 'javadoc'
from "${docsDir}/javadoc"
}
tasks.javadocJar.dependsOn javadoc
task sourcesJar(type: Jar) {
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
jars jar
jars javadocJar
jars sourcesJar
}
generateLicenseReport.dependsOn 'compileJava'
distributions {
main {
contents {
from('.') {
include '*.txt'
}
into('3rd-party-licenses') {
from generateLicenseReport
}
from shadowJar
into('doc') {
from javadocJar
}
into('src') {
from sourcesJar
}
}
}
}
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: '', password: '')
}
pom projectPom
}
}
}
ext.aggregatedDocsDir = "$buildDir/aggregatedDocs"
task aggregateDocs {
doLast {
if (project.hasProperty('release.stage') && project.ext['release.stage'] == 'final') {
copy {
from docsDir
into "${aggregatedDocsDir}/latest"
}
}
copy {
from docsDir
into "${aggregatedDocsDir}/${project.version}"
}
}
}
tasks.aggregateDocs.dependsOn javadoc
gitPublish {
repoUri = githubRemoteUrl
branch = 'gh-pages'
contents {
from aggregatedDocsDir
}
preserve { include '**/*' }
}
tasks.gitPublishPush.dependsOn aggregateDocs
tasks.release.dependsOn test, uploadJars, gitPublishPush, distZip
clean {
delete aggregatedDocsDir
}
// allow typing in credentials
// note: this only works when run without the Gradle daemon (--no-daemon)
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(':uploadJars')) {
if (!rootProject.hasProperty('signingSecretKeyRingFile'))
rootProject.ext.signingSecretKeyRingFile = new String(System.console().readLine('\nSecret key ring file: '))
if (!rootProject.hasProperty('signingKeyId'))
rootProject.ext.signingKeyId = new String(System.console().readLine('\nSigning key id: '))
if (!rootProject.hasProperty('signingPass'))
rootProject.ext.signingPass = new String(System.console().readPassword('\nSigning key passphrase: '))
if (!rootProject.hasProperty('sonatypeUser'))
rootProject.ext.sonatypeUser = new String(System.console().readLine('\nSonatype username: '))
if (!rootProject.hasProperty('sonatypePass'))
rootProject.ext.sonatypePass = new String(System.console().readPassword('\nSonatype password: '))
ext.'signing.keyId' = rootProject.ext.signingKeyId
ext.'signing.secretKeyRingFile' = rootProject.ext.signingSecretKeyRingFile
ext.'signing.password' = rootProject.ext.signingPass
uploadJars.repositories.mavenDeployer.repository.authentication.userName = rootProject.ext.sonatypeUser
uploadJars.repositories.mavenDeployer.repository.authentication.password = rootProject.ext.sonatypePass
}
if (taskGraph.hasTask(':gitPublishPush') || taskGraph.hasTask(':release')) {
if (!rootProject.hasProperty('gitUsername'))
rootProject.ext.gitUsername = new String(System.console().readLine('\nGit username: '))
if (!rootProject.hasProperty('gitPassword'))
rootProject.ext.gitPassword = new String(System.console().readPassword('\nGit password: '))
System.setProperty('org.ajoberstar.grgit.auth.username', rootProject.ext.gitUsername)
System.setProperty('org.ajoberstar.grgit.auth.password', rootProject.ext.gitPassword)
}
}