diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties index d1179fb..1645ccd 100644 --- a/lib/bld/bld-wrapper.properties +++ b/lib/bld/bld-wrapper.properties @@ -4,7 +4,7 @@ bld.downloadLocation= bld.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.10-SNAPSHOT bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.4-SNAPSHOT bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.5 -bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.10 +bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.11-SNAPSHOT bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.sourceDirectories= diff --git a/src/bld/java/net/thauvin/erik/bitly/BitlyShortenBuild.java b/src/bld/java/net/thauvin/erik/bitly/BitlyShortenBuild.java index dda144b..44ed5e7 100644 --- a/src/bld/java/net/thauvin/erik/bitly/BitlyShortenBuild.java +++ b/src/bld/java/net/thauvin/erik/bitly/BitlyShortenBuild.java @@ -58,6 +58,7 @@ import static rife.bld.dependencies.Scope.compile; import static rife.bld.dependencies.Scope.test; public class BitlyShortenBuild extends Project { + static final String TEST_RESULTS_DIR = "build/test-results/test/"; final File srcMainKotlin = new File(srcMainDirectory(), "kotlin"); public BitlyShortenBuild() { @@ -184,10 +185,60 @@ public class BitlyShortenBuild extends Project { @BuildCommand(summary = "Generates JaCoCo Reports") public void jacoco() throws Exception { - new JacocoReportOperation() - .fromProject(this) - .sourceFiles(srcMainKotlin) - .execute(); + var op = new JacocoReportOperation().fromProject(this); + op.testToolOptions("--reports-dir=" + TEST_RESULTS_DIR); + + Exception ex = null; + try { + op.execute(); + } catch (Exception e) { + ex = e; + } + + renderWithXunitViewer(); + + if (ex != null) { + throw ex; + } + } + + @BuildCommand(value = "pom-root", summary = "Generates the POM file in the root directory") + public void pomRoot() throws FileUtilsErrorException { + PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(), + new File(workDirectory, "pom.xml")); + } + + private void renderWithXunitViewer() throws Exception { + var xunitViewer = new File("/usr/bin/xunit-viewer"); + if (xunitViewer.exists() && xunitViewer.canExecute()) { + var reportsDir = "build/reports/tests/test/"; + + Files.createDirectories(Path.of(reportsDir)); + + new ExecOperation() + .fromProject(this) + .command(xunitViewer.getPath(), "-r", TEST_RESULTS_DIR, "-o", reportsDir + "index.html") + .execute(); + } + } + + @Override + public void test() throws Exception { + var op = testOperation().fromProject(this); + op.testToolOptions().reportsDir(new File(TEST_RESULTS_DIR)); + + Exception ex = null; + try { + op.execute(); + } catch (Exception e) { + ex = e; + } + + renderWithXunitViewer(); + + if (ex != null) { + throw ex; + } } @Override @@ -213,31 +264,4 @@ public class BitlyShortenBuild extends Project { super.publishLocal(); pomRoot(); } - - @BuildCommand(value = "pom-root", summary = "Generates the POM file in the root directory") - public void pomRoot() throws FileUtilsErrorException { - PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(), - new File(workDirectory, "pom.xml")); - } - - @Override - public void test() throws Exception { - var testResultsDir = "build/test-results/test/"; - - var op = testOperation().fromProject(this); - op.testToolOptions().reportsDir(new File(testResultsDir)); - op.execute(); - - var xunitViewer = new File("/usr/bin/xunit-viewer"); - if (xunitViewer.exists() && xunitViewer.canExecute()) { - var reportsDir = "build/reports/tests/test/"; - - Files.createDirectories(Path.of(reportsDir)); - - new ExecOperation() - .fromProject(this) - .command(xunitViewer.getPath(), "-r", testResultsDir, "-o", reportsDir + "index.html") - .execute(); - } - } }