1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- // 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 {
-
- // 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 ->
-
- 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")
- }
-
- // 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})"
- }
- }
|