-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.gradle
268 lines (222 loc) · 6.94 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
plugins{
id 'java'
id 'java-library'
id 'jacoco-report-aggregation'
id 'eclipse'
id 'application'
id 'base'
}
/*
* define global parameters here, e.g. versions numbers of tools which need to be consistent for all subprojects
* they are all accesible via project.parametername e.g. project.opt4jJavaVersion to get the used java version for Opt4J
*/
ext{
openDseJavaVersion = "21"
guiceVersion = "7.0.0"
sat4jVersion = "2.3.5"
junitVersion = "5.10.2"
mockitoVersion = "5.10.0"
jacocoVersion = "0.8.11"
xomVersion = "1.3.9"
glazedListsVersion = "1.10.0"
jungVersion = "2.1.1"
opt4jVersion = "v3.4.0"
opt4jVersionDoc = "3.4.0"
collectionsVersion = "4.01"
coltVersion = "1.2.0"
}
jacoco{
toolVersion = project.jacocoVersion
}
java {
sourceCompatibility = project.openDseJavaVersion
targetCompatibility = project.openDseJavaVersion
toolchain {
languageVersion.set(JavaLanguageVersion.of(project.openDseJavaVersion))
}
}
/*
* Gets the version name from the latest Git tag
*/
def getVersionName = {
->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--first-parent'
standardOutput = stdout
ignoreExitValue true
}
version=stdout.toString().trim()
if (version.count('-') > 1 || version.isEmpty())
version += '-SNAPSHOT'
if (version.getAt(0) == 'v')
version = version.substring(1)
return version
}
version=getVersionName()
def descriptions = [
'opendse-generator' : 'The test case generator module of OpenDSE',
'opendse-io' : 'The IO module of OpenDSE',
'opendse-model' : 'The algorithms module of OpenDSE',
'opendse-visualization' : 'The visualization module of OpenDSE',
'opendse-optimization' : 'The optimization module of OpenDSE',
'opendse-tutorial' : 'The tutorial module of OpenDSE',
'opendse-realtime' : 'The real-time module of OpenDSE'
]
allprojects {
group = 'net.sf.opendse'
repositories {
mavenCentral()
mavenLocal()
maven {
name "jitpack"
url 'https://jitpack.io' }
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'eclipse'
apply plugin: 'jacoco'
version = parent.version
task sourcesJar(type: Jar, dependsOn:classes) {
from sourceSets.main.allSource
archiveClassifier.set('sources')
}
task javadocJar(type: Jar, dependsOn:javadoc) {
from javadoc.destinationDir
archiveClassifier.set('javadoc')
}
java {
sourceCompatibility = project.openDseJavaVersion
targetCompatibility = project.openDseJavaVersion
toolchain {
languageVersion.set(JavaLanguageVersion.of(project.openDseJavaVersion))
}
}
test {
// Enable JUnit 5 (Gradle 4.6+).
useJUnitPlatform()
//exclude the realtime subproject from the test task for now
//because there are no unit tests in it but junit5 tries to run the two classes anyway
//which results in failure of build due to failing tests
exclude 'net/sf/opendse/realtime/et/test/*'
// Always run tests, even when nothing changed.
dependsOn 'cleanTest'
// Show test results.
testLogging {
events "passed", "skipped", "failed"
}
}
jacoco {
toolVersion = project.jacocoVersion
}
jacocoTestReport {
getAdditionalSourceDirs().setFrom(sourceSets.main.allSource.srcDirs)
getSourceDirectories().setFrom(sourceSets.main.allSource.srcDirs)
getClassDirectories().setFrom(sourceSets.main.output)
reports {
html.required = true
csv.required = true
xml.required = true
}
}
}
/* for now ignore all javadoc errors in case of Java 8 */
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
ext {
dateISO = new Date().format("yyyy-MM-dd")
}
mainClassName = 'org.opt4j.core.start.Opt4J'
task fatjar(dependsOn: subprojects.jar, type: Jar) {
destinationDirectory = new File(project.buildDir, 'fatjar')
from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it)
} }
manifest {
attributes 'Main-Class': mainClassName
}
}
dependencies {
implementation project(':opendse-model')
implementation project(':opendse-io')
implementation project(':opendse-visualization')
implementation project(':opendse-optimization')
implementation project(':opendse-realtime')
}
jar {
manifest {
attributes 'Main-Class': mainClassName
}
}
task alldocs(type: Javadoc) {
title = "OpenDSE $version Project API Documentation"
destinationDir = new File(project.buildDir, 'docs/javadoc')
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PUBLIC
options.links "https://docs.oracle.com/en/java/javase/${project.openDseJavaVersion}/docs/api/","http://google.github.io/guice/api-docs/${project.guiceVersion}/javadoc/",
"https://sdarg.github.io/opt4j/javadoc/${project.opt4jVersionDoc}/","https://javadoc.io/doc/net.sf.jung/jung-algorithms/${project.jungVersion}/",
"https://javadoc.io/doc/net.sf.jung/jung-api/${project.jungVersion}/","https://javadoc.io/doc/net.sf.jung/jung-graph-impl/${project.jungVersion}/",
"https://javadoc.io/doc/net.sf.jung/jung-visualization/${project.jungVersion}/"
subprojects.each {subproject ->
source subproject.sourceSets.main.java
}
subprojects.each { subproject ->
if( classpath ) {
classpath += subproject.sourceSets.main.output + subproject.sourceSets.main.compileClasspath
} else {
classpath = subproject.sourceSets.main.output + subproject.sourceSets.main.compileClasspath
}
}
}
import org.apache.tools.ant.filters.ReplaceTokens
task copyWebsite(type: Copy, dependsOn: getTasksByName('copyWebsite', true)){
from('src/main/website/') {
include '**/*.html'
filter(ReplaceTokens, tokens: [version : project.version, date : project.dateISO])
}
from('src/main/website/') {
exclude '**/*.html'
}
subprojects.each { subproject ->
from new File(subproject.buildDir, 'website')
}
into 'build/website/'
}
task copyJavadoc(type: Copy, dependsOn: alldocs){
from new File(project.buildDir, 'docs/javadoc')
into 'build/website/javadoc/'+version
}
task website(dependsOn: [copyWebsite, copyJavadoc]) {}
task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
dependsOn = subprojects.test
getAdditionalSourceDirs().setFrom(subprojects.sourceSets.main.allSource.srcDirs)
getSourceDirectories().setFrom(subprojects.sourceSets.main.allSource.srcDirs)
getClassDirectories().setFrom(subprojects.sourceSets.main.output)
executionData.from = files(subprojects.jacocoTestReport.executionData)
reports {
xml.required = true
xml.outputLocation = file("${buildDir}/reports/jacoco/rootReport.xml")
html.required = true
html.outputLocation = file("${buildDir}/reports/jacoco")
csv.required = true
csv.outputLocation = file("${buildDir}/reports/jacoco/rootReport.csv")
}
onlyIf = {
true
}
afterEvaluate {
getClassDirectories().setFrom(classDirectories.files.collect {
fileTree(dir: it, exclude: [
'ptolemy/**',
'org/opt4j/tutorial/**',
'org/opt4j/viewer/**',
'org/opt4j/core/config/visualization/**'
])
})
}
}