forked from workcraft/workcraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
309 lines (237 loc) · 8 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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
plugins {
id 'java'
id 'org.javacc.javacc'
id 'com.github.kt3k.coveralls'
id 'de.aaschmid.cpd'
id 'com.github.jk1.dependency-license-report'
}
repositories {
mavenCentral()
}
java {
sourceCompatibility = gradle.javaSourceVersion
targetCompatibility = gradle.javaTargetVersion
}
subprojects {
repositories {
mavenCentral()
}
apply plugin: 'java'
sourceSets {
main.java.srcDirs = ['src', 'src-gen']
main.resources.srcDirs = ['res']
test.java.srcDirs = ['test-src']
test.resources.srcDirs = ['test-res']
}
compileJava {
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:deprecation"
if (JavaVersion.current().isJava9Compatible()) {
options.release = gradle.javaReleaseVersion
}
}
apply plugin: 'org.javacc.javacc'
compileJavacc {
inputDirectory = file('javacc')
outputDirectory = file('src-gen')
include '**/*.jj'
arguments = [grammar_encoding: 'UTF-8', static: 'false']
}
task cleanJavacc(type: Delete) {
delete compileJavacc.outputDirectory
}
apply plugin: 'java-library'
configurations {
lib
}
dependencies {
lib fileTree(dir: gradle.libDir, include: ['**/*.jar'])
configurations.api.extendsFrom(configurations.lib)
testImplementation gradle.junit
testRuntimeOnly gradle.junitPlatformLauncher
javacc gradle.javacc
}
test {
useJUnitPlatform()
workingDir = rootDir
testLogging {
events "failed"
exceptionFormat "full"
// Uncomment the next two lines to show stdout and stderr of tests
/* outputs.upToDateWhen {false} */
/* showStandardStreams = true */
}
}
apply plugin: 'checkstyle'
checkstyle {
toolVersion = gradle.checkstyleVersion
configFile = file("${project.rootDir}/config/checkstyle/checkstyle.xml")
}
checkstyleMain.exclude gradle.javaccExclude
task checkstyle(dependsOn: tasks.withType(Checkstyle)*.name)
apply plugin: 'pmd'
pmd {
toolVersion = gradle.pmdVersion
consoleOutput = true
incrementalAnalysis = true
ruleSetFiles = files("${project.rootDir}/config/pmd/rules.xml")
ruleSets = []
}
pmdMain.exclude gradle.javaccExclude
task pmd(dependsOn: tasks.withType(Pmd)*.name)
apply plugin: 'de.aaschmid.cpd'
cpd {
toolVersion = gradle.pmdVersion
minimumTokenCount = 250
}
cpdCheck {
dependsOn compileJavacc
source = sourceSets.main.allJava
exclude gradle.javaccExclude
}
apply plugin: 'jacoco'
jacoco {
toolVersion = gradle.jacocoVersion
}
jacocoTestReport {
reports {
xml.required = true /* XML report for coveralls */
html.required = false /* skip human readable report */
}
}
afterEvaluate {project ->
task copyLibs(type: Copy) {
from configurations.lib
into "$buildDir/$gradle.libDir"
include '*.jar'
}
jar {
dependsOn copyLibs
destinationDirectory = file("$buildDir/bin")
manifest {
attributes 'Class-Path': configurations.lib.collect {
"../$gradle.libDir/" + it.name
}.join(' ')
}
}
}
apply plugin: 'eclipse'
eclipse {
classpath {
defaultOutputDir = file('build/eclipse/bin/')
file.whenMerged {
entries.each {
if (it.kind == 'src' && it.hasProperty('output')) {
it.output = it.output.replace('bin/', 'build/eclipse/')
}
}
}
}
}
eclipseClasspath.dependsOn compileJavacc
apply plugin: 'idea'
idea.module {
sourceDirs = [file('src'), file('javacc'), file('src-gen')]
generatedSourceDirs = [file('src-gen')]
resourceDirs = [file('res'), file('models')]
testSourceDirs = [file('test-src')]
testResourceDirs = [file('test-res')]
excludeDirs = [file('.gradle'), file('.settings'), file('bin'), file('build'), file('gradle')]
inheritOutputDirs = false
outputDir = file('build/idea/')
}
ideaModule.dependsOn compileJavacc
task cleanAll(dependsOn: ['clean', 'cleanEclipse', 'cleanIdea', 'cleanJavacc'])
}
apply plugin: 'java'
cpdCheck {
dependsOn compileJavacc
source = sourceSets.main.allJava
exclude gradle.javaccExclude
}
apply plugin: 'jacoco'
jacoco {
toolVersion = gradle.jacocoVersion
}
def coverageProjects = subprojects.findAll {
it.name ==~ ~(gradle.coverageProjects.join('|'))
}
task jacocoRootReport(type: JacocoReport) {
dependsOn(coverageProjects.test)
evaluationDependsOnChildren()
sourceDirectories.from = coverageProjects.sourceSets.main.allSource.srcDirs
additionalSourceDirs.from = coverageProjects.sourceSets.main.allSource.srcDirs
classDirectories.from = coverageProjects.sourceSets.main.output
executionData.from = coverageProjects.jacocoTestReport.executionData
reports {
xml.required = true // XML report for coveralls
html.required = true // human readable report
}
afterEvaluate {
ext.jacocoExclude = [gradle.javaccExclude]
subprojects {
if (it.hasProperty('excludeFromCoverage')) {
jacocoExclude += it.excludeFromCoverage
}
}
classDirectories.from = classDirectories.files.collect {
fileTree(dir: it, exclude: jacocoExclude)
}
}
doLast {
println 'Excluding from coverage:'
jacocoExclude.each { println " - " + it }
}
}
coveralls {
sourceDirs = coverageProjects.sourceSets.main.allSource.srcDirs.flatten()
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
}
tasks.coveralls {
group = 'Verification'
description = 'Generate coverage report for all subprojects with tests.'
dependsOn jacocoRootReport
}
apply plugin: 'com.github.jk1.dependency-license-report'
import com.github.jk1.license.filter.*
licenseReport {
configurations = ['runtimeClasspath', 'compileClasspath']
renderers = [new com.github.jk1.license.render.InventoryHtmlReportRenderer()]
allowedLicensesFile = new File("${project.rootDir}/config/license/allowed.json")
filters = [new ReduceDuplicateLicensesFilter(), new LicenseBundleNormalizer()]
}
checkLicense.group = 'Verification'
generateLicenseReport.group = 'Verification'
checkLicensePreparation.group = null
// License checking takes too long (>2min), has deprecated calls and may run out of memory
/* check.dependsOn checkLicense */
apply plugin: 'idea'
idea.module {
excludeDirs = [file('.gradle'), file('config'), file('dist-template'), file('doc'), file('gradle')]
outputDir = file('build/idea/')
}
def workcraftRunConfiguration = '''
<configuration default="false" name="Workcraft" type="Application" factoryName="Application" singleton="true">
<option name="MAIN_CLASS_NAME" value="org.workcraft.Console" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<module name="WorkcraftRunner" />
</configuration>
'''
idea.workspace.iws {
withXml { workspace ->
def runManagerNode = workspace.node.component.find { it.@name == 'RunManager' }
def workcraftRunNode = runManagerNode.find { it.@name == 'Workcraft' }
if (workcraftRunNode != null) runManagerNode?.remove(workcraftRunNode)
runManagerNode?.append(new XmlParser().parseText(workcraftRunConfiguration))
}
}
tasks.cleanIdea.doLast {
project.delete 'workcraft.iws'
}
task cleanAll(dependsOn: 'cleanIdea')
allprojects {
javadoc.group = null // Exclude javadoc from the list of tasks
}
tasks.cleanAll.doLast {
project.delete 'build/' // Remove root build directory (left untouched by other clean tasks)
}