/
chapter08.gradle
executable file
·75 lines (66 loc) · 1.96 KB
/
chapter08.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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.junit.platform:junit-platform-gradle-plugin:$junit5PluginVersion"
}
}
group 'com.apress.bgn.ch8'
ext.moduleName = 'chapter.eight'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.junit.platform.gradle.plugin'
dependencies {
testImplementation testing.junit
}
jar {
manifest {
attributes(
"Created-By": System.getProperty('java.version'),
"Specification-Title": "Java for Absolute Beginners",
"Implementation-Version": version,
"Class-Path": configurations.compile.collect { it.getName() }.join(' ')
)
}
}
afterEvaluate {
repositories {
jcenter()
}
compileJava {
inputs.property("moduleName", moduleName)
doFirst {
options.compilerArgs = [
'-proc:none',
'--module-path', classpath.asPath,
]
classpath = files()
}
}
compileTestJava {
inputs.property("moduleName", moduleName)
doFirst {
options.compilerArgs = [
'-proc:none',
'--module-path', classpath.asPath,
'--add-modules', 'org.junit.jupiter.engine',
'--add-reads', "$moduleName=org.junit.jupiter.engine",
'--patch-module', "$moduleName=" + files(sourceSets.test.java.srcDirs).asPath,
]
classpath = files()
}
}
test {
inputs.property("moduleName", moduleName)
doFirst {
jvmArgs = [
'--module-path', classpath.asPath,
'--add-modules', 'ALL-MODULE-PATH',
'--add-reads', "$moduleName=junit",
'--patch-module', "$moduleName=" + files(sourceSets.test.java.outputDir).asPath,
]
classpath = files()
}
}
}