-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
141 lines (123 loc) · 4.76 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
if (!hasProperty("releasesRepoUsername")
|| !hasProperty("releasesRepoPassword")) {
ant.fail "You should define a ~/.gradle/gradle.properties containing properties 'releasesRepoUsername' and 'releasesRepoPassword' to access 4SH releases repository !"
}
// For gradle release
apply from: "https://launchpad.net/gradle-release/trunk/1.0/+download/apply.groovy"
task wrapper(type: Wrapper) {
gradleVersion = '1.2'
}
subprojects {
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'sonar'
apply plugin: 'maven'
// For cobertura
def cobSerFile = "${project.buildDir}/reports/tests/cobertura.ser"
def srcOriginal = "${sourceSets.main.output.classesDir}"
def srcCopy = "${srcOriginal}-copy"
def COVERAGE_SYS_PROPERTY = "test.coverage.activated"
// Sysprop allowing to ignore test failures during the build
def IGNORE_TEST_FAILURES_SYS_PROPERTY = "test.ignore.failures";
group = "fr.4sh.jewas"
sourceCompatibility = 1.7
targetCompatibility = 1.7
if (System.getProperty("jdk") != null) {
sourceCompatibility = System.getProperty("jdk")
targetCompatibility = System.getProperty("jdk")
}
test {
ignoreFailures = "true".equalsIgnoreCase(System.getProperty(IGNORE_TEST_FAILURES_SYS_PROPERTY))
}
configurations {
deployerJars
}
repositories {
maven {
credentials {
username releasesRepoUsername
password releasesRepoPassword
}
url "http://repo.4sh.fr/libs/"
artifactUrls "http://repo.4sh.fr/libs/"
}
}
task packageJavadoc(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task packageSources(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
artifacts {
archives(packageJavadoc) {
type = 'javadoc'
extension = 'jar'
}
archives(packageSources)
}
uploadArchives {
repositories.mavenDeployer {
configuration = configurations.deployerJars
snapshotRepository(url: "http://repo.4sh.fr/libs-snapshot-local") {
authentication(userName: releasesRepoUsername, password: releasesRepoPassword)
}
repository(url: "http://repo.4sh.fr/libs-release-local/") {
authentication(userName: releasesRepoUsername, password: releasesRepoPassword)
}
}
}
release {
// Define here custom commit messages
newVersionCommitMessage = "Re-snapshoted project to version "
preTagCommitMessage = "Preparing version for release "
tagCommitMessage = "Tag for version "
}
createReleaseTag.dependsOn uploadArchives
// Allows to generate USER_HOME idea variable uniformely on every OS
idea {
pathVariables("USER_HOME": file(System.getProperty("user.home")))
}
// For cobertura ...
if ("true".equals(System.getProperty(COVERAGE_SYS_PROPERTY))) {
gradle.taskGraph.beforeTask { task ->
if (task == test) {
ant {
// delete data file for cobertura, otherwise coverage would be added
delete(file: cobSerFile, failonerror: false)
// delete copy of original classes
delete(dir: srcCopy, failonerror: false)
// import cobertura task, so it is available in the script
taskdef(resource: 'tasks.properties', classpath: configurations.testRuntime.asPath)
// create copy (backup) of original class files
copy(todir: srcCopy) {
fileset(dir: srcOriginal)
}
// instrument the relevant classes in-place
'cobertura-instrument'(datafile: cobSerFile) {
fileset(dir: srcOriginal,
includes: "**/*.class")
}
}
}
}
gradle.taskGraph.afterTask { task ->
if (task == test && new File(srcCopy).exists()) {
// replace instrumented classes with backup copy again
ant {
delete(file: srcOriginal)
move(file: srcCopy,
tofile: srcOriginal)
}
// create cobertura reports
ant.'cobertura-report'(destdir: "${project.buildDirName}/reports/tests/",
format: 'xml', srcdir: "src/main/java", datafile: cobSerFile)
}
}
test {
ignoreFailures = true
systemProperties["net.sourceforge.cobertura.datafile"] = cobSerFile
}
}
}