From a89eb59043f8d8c7b6d7621fc17dfb1703f64258 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Wed, 3 Apr 2024 20:15:15 -0700 Subject: [PATCH] Cleaned up java agent loading to fully support other (TestNG) extensions. Closes #2 --- examples/lib/bld/bld-wrapper.properties | 2 +- .../src/bld/java/com/example/ExamplesBuild.java | 2 ++ .../bld/extension/JacocoReportOperationBuild.java | 3 ++- .../rife/bld/extension/JacocoReportOperation.java | 14 +++++--------- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/examples/lib/bld/bld-wrapper.properties b/examples/lib/bld/bld-wrapper.properties index 92b7bdd..d0deea8 100644 --- a/examples/lib/bld/bld-wrapper.properties +++ b/examples/lib/bld/bld-wrapper.properties @@ -1,6 +1,6 @@ bld.downloadExtensionJavadoc=false bld.downloadExtensionSources=true -bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.4 +bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.5 bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.downloadLocation= bld.version=1.9.0 diff --git a/examples/src/bld/java/com/example/ExamplesBuild.java b/examples/src/bld/java/com/example/ExamplesBuild.java index 7dca92f..a58fb0d 100644 --- a/examples/src/bld/java/com/example/ExamplesBuild.java +++ b/examples/src/bld/java/com/example/ExamplesBuild.java @@ -17,6 +17,8 @@ public ExamplesBuild() { name = "Examples"; version = version(0, 1, 0); + javaRelease = 17; + downloadSources = true; autoDownloadPurge = true; diff --git a/src/bld/java/rife/bld/extension/JacocoReportOperationBuild.java b/src/bld/java/rife/bld/extension/JacocoReportOperationBuild.java index 77da4d1..073f2af 100644 --- a/src/bld/java/rife/bld/extension/JacocoReportOperationBuild.java +++ b/src/bld/java/rife/bld/extension/JacocoReportOperationBuild.java @@ -34,9 +34,10 @@ public class JacocoReportOperationBuild extends Project { public JacocoReportOperationBuild() { pkg = "rife.bld.extension"; name = "JacocoReportOperation"; - version = version(0, 9, 4); + version = version(0, 9, 5); javaRelease = 17; + downloadSources = true; autoDownloadPurge = true; repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES); diff --git a/src/main/java/rife/bld/extension/JacocoReportOperation.java b/src/main/java/rife/bld/extension/JacocoReportOperation.java index 77cae06..2114450 100644 --- a/src/main/java/rife/bld/extension/JacocoReportOperation.java +++ b/src/main/java/rife/bld/extension/JacocoReportOperation.java @@ -203,16 +203,12 @@ public void execute() throws IOException { } if (execFiles.isEmpty()) { -// project.testOperation().fromProject(project).javaOptions().javaAgent( -// Path.of(project.libBldDirectory().getPath(), "org.jacoco.agent-" -// + JaCoCo.VERSION.substring(0, JaCoCo.VERSION.lastIndexOf('.')) + "-runtime.jar").toFile(), -// "destfile=" + destFile.getPath()); - project.testOperation().fromProject(project).javaOptions().add("-javaagent:" + - Path.of(project.libBldDirectory().getPath(), "org.jacoco.agent-" - + JaCoCo.VERSION.substring(0, JaCoCo.VERSION.lastIndexOf('.')) + "-runtime.jar") - + "=destfile=" + destFile.getPath()); + var testOperation = project.testOperation().fromProject(project); + testOperation.javaOptions().javaAgent(Path.of(project.libBldDirectory().getPath(), + "org.jacoco.agent-" + JaCoCo.VERSION.substring(0, JaCoCo.VERSION.lastIndexOf('.')) + + "-runtime.jar").toFile(), "destfile=" + destFile.getPath()); try { - project.testOperation().execute(); + testOperation.execute(); } catch (InterruptedException | ExitStatusException e) { throw new IOException(e); }