-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
203 lines (171 loc) · 6.78 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
apply plugin: 'base'
apply plugin: 'java'
// warning: [options] bootstrap class path not set in conjunction with -source 1.6 can be ignored
// meaning: we use not the 1.6 JDK but the 1.7 JDK, thus in effect we are cross compiling to Java 1.6
sourceCompatibility = '1.6'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
task wrapper(type: Wrapper, description: 'Creates and deploys the Gradle wrapper to the current directory.') {
gradleVersion = '4.3'
}
if (!hasProperty('mainClass')) {
ext.mainClass = 'eu.mihosoft.vrl.codetools.Main'
}
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
def loadProperties(String sourceFileName) {
def config = new Properties()
def propFile = new File(projectDir,sourceFileName)
if (propFile.isFile()) {
config.load(new FileInputStream(propFile))
for (Map.Entry property in config) {
ext.set(property.key, property.value)
}
}
}
// loads the property file
loadProperties('build.properties')
// add dependencies
dependencies {
/// testing dependencies (from maven)
testCompile group: 'junit', name: 'junit', version: '4.10'
testCompile group: 'org.easymock', name: 'easymock', version: '2.5.2'
/// add mockito dependencies here if necessary
/// VRL dependencies (local dependencies)
compile files(vrldir+'/plugins/VRL-JFreeChart.jar');
compile files(vrldir+'/plugins/Density-Vis.jar');
compile (group: 'eu.mihosoft.vrl', name: 'vrl', version: '0.4.2.8.5-SNAPSHOT')
/// project lombok and levy's kd tree implementation (local dependencies)
compile fileTree(dir: "jars/", includes:['*.jar']);
}
// create a fat-jar (class files plus dependencies
// excludes VRL.jar (plugin jar files must not start with 'vrl-\\d+')
jar {
// dependencies except VRL
from configurations.runtime.asFileTree.
filter({file->return !file.name.startsWith("vrl-0")}).
filter({file->return !file.name.startsWith("Density-Vis.jar")}).
filter({file->return !file.name.startsWith("VRL-JFreeChart.jar")}).
filter({file->return !file.name.startsWith("VRL-SWC-Density-Vis.jar")}).
files.collect { zipTree(it) }
// project class files compiled from source
from files(sourceSets.main.output.classesDir)
}
// compiles and installs the vrl plugin to the specified folder
task installVRLPlugin(dependsOn: [clean,jar]) << {
println(">> copying vrl plugin to: " + vrldir+"/plugin-updates")
copy {
from buildDir.getPath()+"/libs/"+rootProject.name + ".jar"
into vrldir+"/plugin-updates"
include '**/*.jar'
}
}
apply plugin: 'jacoco'
apply plugin: 'com.github.kt3k.coveralls'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.1'
}
}
// override the files which should be included in the test report
// somehow the difference operator for FileCollection does not work,
// therefore i include all classes in a positive way
jacocoTestReport.doFirst {
def base_dir = 'build/classes/main/edu/gcsc/vrl/swcdensityvis';
def all_files = files('build/classes/main/edu/gcsc/vrl/swcdensityvis/');
def exclude = files('build/classes/main/edu/gcsc/vrl/swcdensityvis/ComputeSWCDensity.class',
'build/classes/main/edu/gcsc/vrl/swcdensityvis/KDTreeDemo.class',
'build/classes/main/edu/gcsc/vrl/swcdensityvis/ComputeSWCDensity.class',
'build/classes/main/edu/gcsc/vrl/swcdensityvis/ImageVoxels.class',
'build/classes/main/edu/gcsc/vrl/swcdensityvis/SWCLoadStackComponent.class'
);
/// this does not work:
/// classDirectories = all_files - exclude;
classDirectories = files(base_dir+'/Cuboid.class', base_dir+'/CuboidUtility.class',
base_dir+'/DensityImpl.class', base_dir+'/DensityUtil.class',
base_dir+'/Edge.class', base_dir+'/EdgeUtility.class',
base_dir+'/SWCCompartmentInformation.class', base_dir+'/SWCUtility.class',
base_dir+'/SwappablePair.class', base_dir+'/SwappablePairUtility.class'
);
}
jacocoTestReport {
description = "Generates Jacoco coverage reports for unit tests"
reports {
xml.enabled = true // coveralls plugin depends on xml format report
html.enabled = true
}
}
//
// Add support for a global test report
// source https://github.com/kercheval/GradleCMPlugin/wiki/Create-Test-Report-in-Root-Project-with-Gradle
//
task testReport(type: TestReport) {
setDescription('Generates a test report from all subproject test tasks')
setGroup(JavaBasePlugin.DOCUMENTATION_GROUP)
//
// Keep track of total failure count for later test and output
//
def testFailures = 0
//
// Place the output in the root build reports directory by default
//
destinationDir = file("$buildDir/reports/allTests")
//
// Include the results from the `test` task in all subprojects.
// The TestReport task does not handle things well if a subproject
// does not have the binary output, so this task assumes all subprojects
// include the gradle java plugin!
//
reportOn subprojects*.test
//
// Every subproject should ignore test failures, but here we add a
// test suite failure filter to ensure we keep track of the fact that
// failures have occurred (for the build failure check below)
//
subprojects {
test {
ignoreFailures true
afterSuite { td, tr ->
if (td.getParent() == null) {
testFailures += tr.getFailedTestCount()
}
}
}
}
//
// The last thing to do in this task is to check for failures.
// The build as a whole should fail if any tests failed.
//
doLast {
if (testFailures > 0) {
throw new Exception("There were ${testFailures} test failures")
}
}
}
/*
/// add git dependencies (remote dependencies like maven)
/// for now we add dependency as jars, but we could also
/// make use of https://github.com/bat-cha/gradle-plugin-git-dependencies
/// which provides a way to add github projects as dependencies
apply plugin: 'git-dependencies'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.batcha.gradle.plugins:git-dependencies:0.2'
}
}
dependencies {
compile('edu.gcsc.vrl.densityvis:Density-Vis').ext.git = 'https://github.com/NeuroBox3D/VRL-Density-Vis.git'
compile('edu.gcsc.vrl.jfreechart:JFreeChart').ext.git = 'https://github.com/miho/VRL-JFreeChart.git'
compile('eu.mihosoft.vrl:vrl').ext.git = 'https://github.com/VRL-Studio/VRL.git'
compile('eu.mihosoft.jcsg').ext.git = 'https://github.com/miho/JCSG/tree/java6.git'
}
*/