-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
89 lines (70 loc) · 2.91 KB
/
build.gradle
File metadata and controls
89 lines (70 loc) · 2.91 KB
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
import java.nio.file.Files
plugins { id 'java' }
wrapper {
gradleVersion = "$wrapperVersion"
distributionType = Wrapper.DistributionType.ALL
}
def printOutput(def output) {
println "#educational_plugin_checker_version 1"
def separator = System.lineSeparator()
Collection<String> lines = output.toString().split("(?<=${separator})|(?=${separator})")
lines.forEach { println "#educational_plugin" + it }
}
rootProject.afterEvaluate {
File gradlewFixed = file "$rootDir/util/resource/gradlew.java"
File gradlew = file "$rootDir/gradlew.bat"
if (!gradlew.exists() || (Files.size(gradlew.toPath()) != Files.size(gradlewFixed.toPath()))) {
println "Update gradlew.bat"
copy { from gradlewFixed; into rootDir; rename("gradlew.java", "gradlew.bat") }
}
}
subprojects {
apply plugin: 'application'
apply plugin: 'java'
if (project.findProperty('educationalRun') ?: false) {
def runOutput = new ByteArrayOutputStream()
tasks.run.setStandardOutput(runOutput)
tasks.run.doLast { printOutput(runOutput) }
}
project.mainClassName = project.findProperty('mainClass') ?: "Main"
sourceCompatibility = JavaVersion.VERSION_11
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }
repositories { mavenCentral() }
configurations.all {
resolutionStrategy.eachDependency {
if (requested.group.contains('org.junit.jupiter')) useVersion junitVersion
if (requested.group.contains('org.hamcrest')) useVersion hamcrestVersion
}
}
dependencies {
testImplementation 'org.hamcrest:hamcrest'
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testImplementation 'org.junit.jupiter:junit-jupiter-params'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
if (name != 'util') {
implementation project(':util')
testImplementation project(':util')
}
}
sourceSets {
main { java.srcDir 'src'; resources.srcDir 'resource' }
test { java.srcDir 'test' }
}
test {
useJUnitPlatform()
systemProperties << ['junit.jupiter.extensions.autodetection.enabled': true,
'courseLocale' : findProperty("courseLocale") ?: 'en']
testLogging { events 'PASSED', 'FAILED', 'SKIPPED' }
reports.html.required = false
reports.junitXml.required = false
String home = "$gradle.gradleUserHomeDir/.tmp/${project.name.hashCode()}/build"
String test = "$home/test"
def main = "$home/main"
doFirst {
copy { from sourceSets.test.output.files; into test }
copy { from sourceSets.main.output.files; into main }
}
doLast { delete(test, main) }
classpath = files(main, test) + (sourceSets.test.runtimeClasspath - (sourceSets.test.output + sourceSets.main.output))
}
}