forked from timtiemens/secretshare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
292 lines (252 loc) · 9.45 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
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
// target: 'build' - does not run integration tests
// target: 'integTest' - runs integration tests (about 5 minutes worth)
// target: 'publish' - push to local (archiva, as guest)
// target: 'uploadArchives' - push to maven central (sonatype, as user)
// target: 'jacocoTestReport' - code coverage from unit tests
// target: 'jacocoIntegTestReport' - coverage from integration tests and UTs
// target: 'sonarRunner' - publish data to locally running SonarCube
// target: 'signArchives' - test signature operation
//
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply from: "$rootDir/gradle/versioning.gradle"
apply plugin: 'jacoco'
apply plugin: 'sonar-runner'
apply plugin: 'signing'
apply plugin: 'maven'
group = 'com.tiemens'
archivesBaseName = 'secretshare'
version = '1.4.4-SNAPSHOT'
project.ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
sourceCompatibility = 1.6
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}
repositories {
if (project.hasProperty('archivaBaseUrl') ) {
maven { url project.archivaBaseUrl + "/internal" }
maven { url project.archivaBaseUrl + "/snapshots" }
} else {
mavenCentral()
}
}
sourceSets {
integTest {
java.srcDir file("src/integTest/java")
resources.srcDir file("src/integTest/resources")
compileClasspath =
sourceSets.main.output +
sourceSets.test.output +
configurations.testRuntime
runtimeClasspath = output + compileClasspath
}
}
jacoco {
toolVersion = "0.7.2.201409121644"
reportsDir = file("$buildDir/reports/jacoco")
}
test {
exclude '**/*IntegTest.class'
reports.html.destination = file ("$reports.html.destination/test")
reports.junitXml.destination = file ("$reports.junitXml.destination/test")
}
task integTest(type: Test, group: 'Build') {
testClassesDir = sourceSets.integTest.output.classesDir
classpath = sourceSets.integTest.runtimeClasspath
include '**/*IntegTest.class'
reports.html.destination = file ("$reports.html.destination/integTest")
reports.junitXml.destination = file ("$reports.junitXml.destination/integTest")
// Your choice on when to run integTest:
// a) check.dependsOn integTest -
// causes 'build' -> check -> integTest and runs in 5 minutes
// b) comment out // check.dependsOn integTest -
// causes 'build' -> check and runs in 12 seconds
//comment out// check.dependsOn integTest
}
jacocoTestReport {
dependsOn 'test'
reports {
xml {
enabled true
destination "$buildDir/reports/jacoco/jacocoTestReport.xml"
}
csv.enabled false
html {
enabled true
destination "$buildDir/reports/jacoco/jacocoTestReport"
}
}
}
task jacocoIntegTestReport(type: JacocoReport) {
dependsOn integTest
sourceSets sourceSets.main
executionData integTest
reports {
xml {
enabled true
destination "$buildDir/reports/jacoco/jacocoIntegTestReport.xml"
}
csv.enabled false
html {
enabled true
destination "$buildDir/reports/jacoco/jacocoIntegTestReport"
}
}
}
jar {
manifest {
attributes("Main-Class" : "com.tiemens.secretshare.main.cli.Main")
}
}
// Used in publishing:
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
// Used in publishing:
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives jar
archives sourcesJar
archives javadocJar
}
signing {
required {
isReleaseVersion &&
gradle.taskGraph.hasTask("uploadArchives") &&
project.hasProperty("ossrhUsername")
}
sign configurations.archives
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"
}
// A: reference: http://forums.gradle.org/gradle/topics/maven_publishing_plugin_doesnt_upload_generated_pom_file
// B: reference: http://books.sonatype.com/nexus-book/reference/bundles.html
// C: reference: http://blog.sonatype.com/2009/09/maven-tips-and-tricks-using-github/
// D: reference https://github.com/resteasy/Resteasy/blob/master/jaxrs/pom.xml
pom.withXml {
def root = asNode()
root.appendNode('description',
"Shamir's Secret Share in Java")
root.appendNode('url',
'https://github.com/timtiemens/secretshare')
// strange packaging is missing:
root.appendNode('packaging', 'jar')
root.appendNode('name', "SecretShare core")
def scm = root.appendNode('scm')
scm.appendNode('url',
//D: 'http://github.com/resteasy/Resteasy/tree/master/'
'https://github.com/timtiemens/secretshare/tree/' +
'v' + version + '/')
scm.appendNode('connection',
//A: 'scm:https://[email protected]/bmuschko/gradle-cloudbees-plugin.git'
//B: 'scm:git:git://github.com/sonatype/sample-project.git')
//C: 'scm:git:[email protected]:tobrien/git-demo.git'
//D: 'scm:git:git://github.com/resteasy/Resteasy.git'
'scm:git:git://github.com/timtiemens/secretshare.git')
scm.appendNode('developerConnection',
//A: 'scm:git://github.com/bmuschko/gradle-cloudbees-plugin.git'
//B: 'scm:git:git://github.com/sonatype-sample-project.git')
//C: 'scm:git:[email protected]:tobrien/git-demo.git'
//D: 'scm:git:[email protected]:resteasy/Resteasy.git'
'scm:git:[email protected]:timtiemens/secretshare.git')
def license = root.appendNode('licenses').appendNode('license')
license.appendNode('name',
'GNU Lesser General Public License (LGPL), Version 2.1')
license.appendNode('url',
'https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html')
license.appendNode('distribution', 'repo')
def developer = root.appendNode('developers').appendNode('developer')
developer.appendNode('id', 'timtiemens')
developer.appendNode('name', 'Tim Tiemens')
// developer.appendNode('email', '[email protected]')
developer.appendNode('url', 'https://github.com/timtiemens')
}
}
}
repositories {
maven {
if (project.hasProperty('publishBaseUrl')) {
if (! project.ext.isReleaseVersion) {
url project.publishBaseUrl + "/snapshots"
} else {
url project.publishBaseUrl + "/internal"
}
} else {
// this is a notice that 'publish' requires .publishBaseUrl
url "http://you.must.configure.project.publishBaseUrl"
}
}
}
}
ext.useOssrhUsername =
project.hasProperty("ossrhUsername") ? ossrhUsername : "fake"
ext.useOssrhPassword =
project.hasProperty("ossrhPassword") ? ossrhPassword : "fake"
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: useOssrhUsername, password: useOssrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: useOssrhUsername, password: useOssrhPassword)
}
pom.project {
name 'SecretShare core'
packaging 'jar'
// optionally artifactId can be defined here
description "Shamir's Secret Share in Java"
url 'https://github.com/timtiemens/secretshare'
scm {
connection 'scm:git:git://github.com/timtiemens/secretshare.git'
developerConnection 'scm:git:[email protected]:timtiemens/secretshare.git'
url 'https://github.com/timtiemens/secretshare/tree/' +
'v' + version + '/'
}
licenses {
license {
name 'GNU Lesser General Public License (LGPL), Version 2.1'
url 'https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html'
}
}
developers {
developer {
id 'timtiemens'
name 'Tim Tiemens'
email '[email protected]'
url 'https://github.com/timtiemens'
}
}
}
}
}
}
buildscript {
repositories {
}
}
sonarRunner {
sonarProperties {
property 'sonar.projectName', 'secretshare'
property 'sonar.projectDescription', "Shamir's Secret Share in Java"
property 'sonar.sourceEncoding', 'UTF-8'
properties['sonar.tests'] += sourceSets.integTest.allSource.srcDirs
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.2.1'
}