Repository navigation
Conversation
Replace the deprecated `task` DSL, eager `tasks.create` calls and `tasks.findAll` wiring with lazy `tasks.register`, keeping the returned `TaskProvider`s in variables and inlining the task names that were previously built as separate string locals. `dependsOn`, `onlyIf`, `finalizedBy` and `mustRunAfter` are now set in `configure` blocks, the aggregate `runMavenTest` depends on the per-config variants via `tasks.named`, and the JDK log line is attached through `tasks.configureEach` instead of eagerly realizing every task during configuration. Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
`allprojects` within `archunit-maven-test` only contains the project itself, so the lookup of release projects for `mustRunAfter` wiring always returned an empty list. The lookup was correct when it was introduced in 7a1cc96, as the code then lived in `build-steps/maven-integration-test/` and was applied from the root project, where `allprojects` spans the whole build. It silently broke when 4779b3a moved the build config verbatim into the `archunit-maven-test` subproject, changing the project context of the script. Use `rootProject.allprojects` to consider the whole build again. Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
Redirect `executeRules` stdout and stderr into a log file under `verificationResultArchivePath/<config.identifier>/`, keeping the console output limited to the echoed command. Also print the `verifyRules` command and the `cleanUpMavenTest` copy destination for better traceability of the Maven integration test run. Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
| def logFile = new File(logPath, "${name}.log") | ||
| logStream = new FileOutputStream(logFile) | ||
| standardOutput = logStream | ||
| errorOutput = logStream |
There was a problem hiding this comment.
I like this idea. One thing I'm wondering about is debugging CI: In case this fails in the CI, do we want to publish these files as build artifacts? Otherwise, the output might not be obtainable.
| dependsOn prepareMavenTest | ||
| } | ||
| executeRules.configure mavenExec { | ||
| commandLine mavenCommand('clean', 'test', '-P', 'execute-rules') |
There was a problem hiding this comment.
nitpick: do we want to move the commandLine between doFirst and doLast to make reading more intuitive? Applies to other tasks as well.
| } | ||
| } | ||
| return result; | ||
| assertThat(failedArchitectureTests).as("actual failures").hasSameElementsAs(givenTestClasses.tests); |
| // Run cleanUp even if task fails | ||
| [tasks[prepareMavenTest], tasks[verifyRules], tasks[executeRules]]*.finalizedBy tasks[cleanUpMavenTest] | ||
| [prepareMavenTest, verifyRules, executeRules].each { taskProvider -> | ||
| taskProvider.configure { finalizedBy cleanUpMavenTest } | ||
| } |
There was a problem hiding this comment.
Side note: The "Run cleanUp even if task fails" does not work in either the old or new code (to test: comment out the for loop in TestResultTest.java:getFailedTests and execute runMavenTest). But I'm not sure I'd even want it, since not cleaning up can facilitate debugging. Leaving it up to you if you want to try to fix or remove it.
However: Now that we're cleaning up here, what do you think about a .gitignore in this directory for the temporary files? The following content works well:
/src
/pom.xml
TestResultTest.assertMatchWith, show context of failure