Repository navigation
Clean up root build script #644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,67 @@ | ||
| subprojects { project -> | ||
| apply plugin: "java" | ||
|
|
||
| sourceSets { | ||
| // Verify that the tests are working by running them against the example code. | ||
| // By replacing the "main" sourceSet with the example code we avoid any collisions | ||
| // with solution code that may have been included as a "starter" (e.g. etl). | ||
| main { | ||
| java.srcDirs = ["src/example/java"] | ||
| } | ||
| project["compileJava"].doFirst { compileTask -> | ||
| println " (source = ${compileTask.source.asPath})" | ||
| } | ||
| // This root Gradle project is used for: | ||
| // | ||
| // - Checking that every test suite compiles against its corresponding example implementation; | ||
| // - Checking that every example implementation passes its corresponding test suite; | ||
| // - Checking that every provided starter implementation compiles. | ||
| // | ||
| // This file is never delivered to Exercism users. | ||
|
|
||
| starterSource { | ||
| java.srcDirs = ["src/main/java"] | ||
| } | ||
| project["compileStarterSourceJava"].doFirst { compileTask -> | ||
| println " (source = ${compileTask.source.asPath})" | ||
| } | ||
| def generatedTestSourceDir = "build/gen/test/java" | ||
|
|
||
| // In lieu of being able to disable @Ignore in JUnit tests, we filter | ||
| // those annotations, placing the edited tests in the path named here. | ||
| test { | ||
| java.srcDirs = ["build/gen/test/java"] | ||
| } | ||
| project["compileTestJava"].doFirst { compileTask -> | ||
| println " (source = ${compileTask.source.asPath})" | ||
| } | ||
| } | ||
| 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 "build/gen/test/java" | ||
| into generatedTestSourceDir | ||
| filter { line -> | ||
| line.contains("@Ignore") ? "" : line | ||
| line.contains("@Ignore") ? null : line | ||
| } | ||
| } | ||
|
|
||
| afterEvaluate { project -> | ||
|
|
||
| sourceSets { | ||
| // Set the directory containing the example implementation as the default source set. Default | ||
| // compile tasks will now run against this source set. | ||
| main { | ||
| java.srcDirs = ["src/example/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) | ||
| } | ||
|
|
||
| test.dependsOn(copyTestsFilteringIgnores) | ||
| } | ||
|
|
||
| def logCompileTaskSourcePath(Project project, String taskName) { | ||
| project[taskName].doFirst { compileTask -> | ||
| println " (source = ${compileTask.source.asPath})" | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nullhere just skips the line, rather than including an unnecessary blank line.