Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
87 lines (70 loc) · 2.9 KB
/
Copy pathbuild.gradle
File metadata and controls
87 lines (70 loc) · 2.9 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
// This root Gradle project is used for:
//
// - Checking that every test suite compiles against its corresponding reference implementation;
// - Checking that every reference implementation passes its corresponding test suite;
// - Checking that every provided starter implementation compiles.
//
// This file is never delivered to Exercism users.
def generatedTestSourceDir = "build/gen/test/java"
subprojects {
apply plugin: "checkstyle"
// Add a task that copies test source files into a build directory. All @Ignore annotations
// are removed during this copying, so that when we run the copied tests, none are skipped and
// all should execute.
//
// Note that journey-test.sh also strips @Ignore annotations using sed. The
// stripping implementations here and in journey-test.sh should be kept
// consistent.
task copyTestsFilteringIgnores(type: Copy) {
from "src/test/java"
into generatedTestSourceDir
filter { line ->
line.contains("@Ignore") ? null : line
}
}
afterEvaluate { project ->
// skip project named 'concept' or 'practice'
// they are only folders containing exercises
if(project.name == 'concept' || project.name == 'practice')
return;
sourceSets {
// Set the directory containing the reference solution as the default source set. Default
// compile tasks will now run against this source set.
main {
java.srcDirs = [".meta/src/reference/java"]
}
// Define a custom source set named "starterSource" that points to the starter implementations
// delivered to users. We can then use the generated "compileStarterSourceJava" task to verify
// that the starter source compiles as-is.
starterSource {
java.srcDirs = ["src/main/java"]
}
// Set the directory containing the @Ignore-stripped tests as the default test source set.
// Default test tasks will now run against this source set.
test {
java.srcDirs = [generatedTestSourceDir]
}
// Log the source paths associated with each source set to verify they are what we expect.
logCompileTaskSourcePath(project, "compileJava") // Corresponds to the "main" source set.
logCompileTaskSourcePath(project, "compileStarterSourceJava")
logCompileTaskSourcePath(project, "compileTestJava")
}
// configuration of the linter
checkstyle {
toolVersion '7.8.1'
configFile file("checkstyle.xml")
sourceSets = [project.sourceSets.main, project.sourceSets.test]
}
checkstyleTest {
source = "src/test/java"
}
// When running the standard test task, make sure we prepopulate the test source set with the
// @Ignore-stripped tests.
test.dependsOn(copyTestsFilteringIgnores)
}
}
def logCompileTaskSourcePath(Project project, String taskName) {
project[taskName].doFirst { compileTask ->
println " (source = ${compileTask.source.asPath})"
}
}