forked from syncany/syncany
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
293 lines (221 loc) · 7.55 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
292
293
//
// Build script for main project
//
// Global Helpers //////////////////////////////////////////////////////////////
String execAndGetOutput(String command) {
try {
def stdout = new ByteArrayOutputStream()
exec {
workingDir rootProject.projectDir
commandLine command.split()
standardOutput = stdout
}
return stdout.toString().trim()
}
catch (Exception e) {
return null
}
}
String getRevision() {
String currentCommit = execAndGetOutput("git rev-parse --short HEAD")
return (currentCommit != null) ? currentCommit : "UNKNOWN"
}
boolean isApplicationRelease() {
// Note: This must work for detached commits (git checkout -qf <commit>)
String currentBranches = execAndGetOutput("git log -n 1 --pretty=%d HEAD")
return currentBranches.contains("origin/master")
}
// Global Settings /////////////////////////////////////////////////////////////
project.ext {
applicationVersion = "0.1.1-alpha"
applicationRelease = isApplicationRelease()
applicationDate = new Date()
applicationRevision = getRevision()
applicationVersionSnapshot = (!applicationRelease) ? "-SNAPSHOT+${applicationDate.format('yyMMddHHmm')}git${applicationRevision}" : ""
applicationVersionFull = "${applicationVersion}${applicationVersionSnapshot}"
}
repositories {
mavenCentral()
}
// Coverage (Cobertura) ////////////////////////////////////////////////////////
// Run as: gradle testGlobal coberturaReport performCoverageCheck
apply plugin: 'cobertura'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'net.saliman:gradle-cobertura-plugin:2.2.2'
}
}
cobertura {
coverageFormats = ['html', 'xml']
coverageReportDatafile = file("build/cobertura/cobertura.ser")
coverageReportDir = file("build/reports/coverage")
coverageDirs = []
coverageSourceDirs = []
coverageMergeDatafiles = []
rootProject.subprojects.each {
coverageFormats = ['html', 'xml']
coverageDirs << file("${it.buildDir}/classes/main")
coverageSourceDirs << file("${it.projectDir}/src/main/java")
coverageMergeDatafiles << file("${it.buildDir}/cobertura/cobertura.ser")
}
}
// JavaDoc Requirements ////////////////////////////////////////////////////////
configurations {
doclet
}
dependencies {
doclet group: 'org.jboss.apiviz', name: 'apiviz', version: '1.3.2.GA'
}
// Sub-Project Settings and Hooks //////////////////////////////////////////////
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'cobertura'
group = 'org.syncany'
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenCentral()
}
sourceSets {
main {
java { srcDir 'src/main/java'}
resources { srcDir 'src/main/resources'}
}
test {
java { srcDir 'src/test/java'}
resources { srcDir 'src/test/resources'}
}
}
task testAllLong(type: Test, dependsOn: testClasses, group: 'Verification') {
description = "Test long running scenarios"
ignoreFailures = true
maxParallelForks = 2
testLogging { events 'started', 'passed'}
include '**/LongRunning*'
}
task testScenario(type: Test, dependsOn: testClasses, group: 'Verification') {
description = "Test all scenarios"
ignoreFailures = true
maxParallelForks = 2
testLogging { events 'started', 'passed'}
include '**/*ScenarioTest*'
}
task testAll(type: Test, dependsOn: testClasses, group: 'Verification') {
description = "All tests"
ignoreFailures = true
maxParallelForks = 2
testLogging { events 'started', 'passed'}
exclude '**/*TestSuite*'
}
task testAllButLongCrypto(type: Test, dependsOn: testClasses, group: 'Verification') {
jvmArgs '-Dcrypto.enable=true'
description = "All tests except long running with crypto"
ignoreFailures = true
maxParallelForks = 2
testLogging { events 'started', 'passed'}
exclude '**/LongRunning*', '**/*TestSuite*'
}
test {
group = "verification"
description = "All tests except long running"
ignoreFailures = true
maxParallelForks = 2
testLogging { events 'started', 'passed'}
exclude '**/LongRunning*', '**/*TestSuite*'
}
// JAR /////////////////////////////////////////////////////////////////////
jar {
baseName = "${project.name}"
version = "$applicationVersion"
}
// Test JARs ///////////////////////////////////////////////////////////////
task testJar(type: Jar, dependsOn: testClasses) {
baseName = "test-${project.archivesBaseName}"
from sourceSets.test.output
}
configurations {
tests
}
artifacts {
tests testJar
}
// Eclipse Settings and Hooks //////////////////////////////////////////////
eclipse {
classpath {
downloadSources = true
}
jdt {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
}
task eclipseSettings(type: Copy) {
from rootProject.files(
"gradle/eclipse/org.eclipse.jdt.ui.prefs",
"gradle/eclipse/org.eclipse.jdt.core.prefs"
)
into project.file('.settings/')
outputs.upToDateWhen {
false
}
}
task cleanEclipseJdtUi(type: Delete) {
delete project.file(".settings/")
delete project.file("bin/")
}
tasks["cleanEclipse"].dependsOn(cleanEclipseJdtUi)
tasks["eclipse"].dependsOn(eclipseSettings)
}
// JavaDoc /////////////////////////////////////////////////////////////////////
task javadocAll(type: Javadoc) {
group = "documentation"
description = "Creates the JavaDoc for all subprojects and puts it into build/javadoc"
source subprojects.collect { project -> project.sourceSets.main.allJava }
classpath = files(subprojects.collect { project -> project.sourceSets.main.compileClasspath })
destinationDir = new File(projectDir, 'build/javadoc')
doFirst {
subprojects.each { project -> project.sourceSets.main.output.each { dir -> dir.mkdirs() } }
}
options.linkSource = true
options.addStringOption('sourceclasspath', files(subprojects.collect { project -> project.sourceSets.main.output }).getAsPath())
configure(options) {
doclet "org.jboss.apiviz.APIviz"
docletpath file(configurations.doclet.asPath)
windowTitle = 'Syncany API Documentation'
docTitle = "Syncany JavaDoc ($applicationVersion)"
bottom = " \
<span style=\"font-size: 13px\"><br /> \
<a href=\"http://www.syncany.org/\" target=\"_top\">Syncany</a> is an open-source cloud storage and filesharing application.<br /><br /> \
Code located at <a href=\"https://github.com/binwiederhier/syncany\" target=\"_top\">https://github.com/binwiederhier/syncany</a><br /> \
JavaDoc for version $applicationVersion generated based on commit <a href=\"https://github.com/binwiederhier/syncany/tree/$applicationRevision\" target=\"_top\">$applicationRevision</a> at $applicationDate<br /><br /> \
Copyright © 2011-2014 <a href=\"http://www.philippheckel.com/\" target=\"_top\">Philipp C. Heckel</a> \
</span> \
"
}
}
task cleanJavadocAll(type: Delete) {
group = "documentation"
description = "Deletes the all subprojects from build/javadoc (completent to javadocAll)"
delete 'build/javadoc'
}
// Gradle Wrapper Tasks (for local gradlew scripts) ////////////////////////////
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
jarFile = 'gradle/wrapper/wrapper.jar'
}
// Task to clean build folder on project root //////////////////////////////////
task cleanBuildDir(type: Delete) {
delete 'build'
}
tasks["clean"].dependsOn(cleanBuildDir)
// Global Tests ////////////////////////////////////////////////////////////////
task testGlobal(type: TestReport) {
group = "verification"
description = "All the results from the 'test' task in all subprojects (global report!)"
destinationDir = file("$buildDir/reports/tests")
reportOn subprojects*.test
}