Upgraded to RIFE2 1.7.0
This commit is contained in:
parent
2eb6bac66b
commit
3f7018096e
11 changed files with 88 additions and 26 deletions
4
.idea/libraries/bld.xml
generated
4
.idea/libraries/bld.xml
generated
|
@ -2,11 +2,11 @@
|
||||||
<library name="bld">
|
<library name="bld">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||||
<root url="jar://$USER_HOME$/.rife2/dist/rife2-1.6.2.jar!/" />
|
<root url="jar://$USER_HOME$/.bld/dist/bld-1.7.0.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="jar://$USER_HOME$/.rife2/dist/rife2-1.6.2-sources.jar!/" />
|
<root url="jar://$USER_HOME$/.bld/dist/bld-1.7.0-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
<excluded>
|
<excluded>
|
||||||
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
||||||
|
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
@ -7,7 +7,7 @@
|
||||||
],
|
],
|
||||||
"java.configuration.updateBuildConfiguration": "automatic",
|
"java.configuration.updateBuildConfiguration": "automatic",
|
||||||
"java.project.referencedLibraries": [
|
"java.project.referencedLibraries": [
|
||||||
"${HOME}/.rife2/dist/rife2-1.6.2.jar",
|
"${HOME}bld-1.7.0-SNAPSHOT.jar",
|
||||||
"lib/compile/*.jar",
|
"lib/compile/*.jar",
|
||||||
"lib/runtime/*.jar",
|
"lib/runtime/*.jar",
|
||||||
"lib/test/*.jar"
|
"lib/test/*.jar"
|
||||||
|
|
4
examples/.idea/libraries/bld.xml
generated
4
examples/.idea/libraries/bld.xml
generated
|
@ -2,11 +2,11 @@
|
||||||
<library name="bld">
|
<library name="bld">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||||
<root url="jar://$USER_HOME$/.rife2/dist/rife2-1.6.1.jar!/" />
|
<root url="jar://$USER_HOME$/.bld/dist/bld-1.7.0.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="jar://$USER_HOME$/.rife2/dist/rife2-1.6.1-sources.jar!/" />
|
<root url="jar://$USER_HOME$/.bld/dist/bld-1.7.0-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
<excluded>
|
<excluded>
|
||||||
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
||||||
|
|
2
examples/.vscode/settings.json
vendored
2
examples/.vscode/settings.json
vendored
|
@ -7,7 +7,7 @@
|
||||||
],
|
],
|
||||||
"java.configuration.updateBuildConfiguration": "automatic",
|
"java.configuration.updateBuildConfiguration": "automatic",
|
||||||
"java.project.referencedLibraries": [
|
"java.project.referencedLibraries": [
|
||||||
"${HOME}/.rife2/dist/rife2-1.6.1.jar",
|
"${HOME}bld-1.7.0-SNAPSHOT.jar",
|
||||||
"lib/compile/*.jar",
|
"lib/compile/*.jar",
|
||||||
"lib/runtime/*.jar",
|
"lib/runtime/*.jar",
|
||||||
"lib/test/*.jar"
|
"lib/test/*.jar"
|
||||||
|
|
Binary file not shown.
|
@ -2,5 +2,5 @@ bld.downloadExtensionJavadoc=false
|
||||||
bld.downloadExtensionSources=true
|
bld.downloadExtensionSources=true
|
||||||
bld.extension-pmd=com.uwyn.rife2:bld-jacoco-report:0.9.0-SNAPSHOT
|
bld.extension-pmd=com.uwyn.rife2:bld-jacoco-report:0.9.0-SNAPSHOT
|
||||||
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
||||||
rife2.downloadLocation=
|
bld.downloadLocation=
|
||||||
rife2.version=1.6.1
|
bld.version=1.7.0
|
|
@ -19,8 +19,8 @@ public class ExamplesBuild extends Project {
|
||||||
repositories = List.of(MAVEN_CENTRAL);
|
repositories = List.of(MAVEN_CENTRAL);
|
||||||
|
|
||||||
scope(test)
|
scope(test)
|
||||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 9, 2)))
|
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 9, 3)))
|
||||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 9, 2)));
|
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 9, 3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
Binary file not shown.
|
@ -2,5 +2,5 @@ bld.downloadExtensionJavadoc=false
|
||||||
bld.downloadExtensionSources=true
|
bld.downloadExtensionSources=true
|
||||||
bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.1-SNAPSHOT
|
bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.1-SNAPSHOT
|
||||||
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
||||||
rife2.downloadLocation=
|
bld.downloadLocation=
|
||||||
rife2.version=1.6.2
|
bld.version=1.7.0
|
|
@ -23,7 +23,9 @@ import rife.bld.publish.PublishDeveloper;
|
||||||
import rife.bld.publish.PublishLicense;
|
import rife.bld.publish.PublishLicense;
|
||||||
import rife.bld.publish.PublishScm;
|
import rife.bld.publish.PublishScm;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static rife.bld.dependencies.Repository.*;
|
import static rife.bld.dependencies.Repository.*;
|
||||||
import static rife.bld.dependencies.Scope.*;
|
import static rife.bld.dependencies.Scope.*;
|
||||||
|
@ -41,9 +43,11 @@ public class JacocoReportOperationBuild extends Project {
|
||||||
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
|
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
|
||||||
|
|
||||||
var jacocoVersion = new VersionNumber(0, 8, 10);
|
var jacocoVersion = new VersionNumber(0, 8, 10);
|
||||||
|
var rife2 = version(1,7,0);
|
||||||
scope(compile)
|
scope(compile)
|
||||||
.include(dependency("org.jacoco", "jacoco", jacocoVersion).exclude("*", "org.jacoco.doc"))
|
.include(dependency("org.jacoco", "jacoco", jacocoVersion).exclude("*", "org.jacoco.doc"))
|
||||||
.include(dependency("com.uwyn.rife2", "rife2", version(1, 6, 2)));
|
.include(dependency("com.uwyn.rife2", "rife2", rife2))
|
||||||
|
.include(dependency("com.uwyn.rife2", "bld", rife2));
|
||||||
scope(runtime)
|
scope(runtime)
|
||||||
.include(dependency("org.jacoco", "jacoco", jacocoVersion).exclude("*", "org.jacoco.doc"));
|
.include(dependency("org.jacoco", "jacoco", jacocoVersion).exclude("*", "org.jacoco.doc"));
|
||||||
scope(test)
|
scope(test)
|
||||||
|
@ -59,8 +63,8 @@ public class JacocoReportOperationBuild extends Project {
|
||||||
.link("https://rife2.github.io/rife2/");
|
.link("https://rife2.github.io/rife2/");
|
||||||
|
|
||||||
publishOperation()
|
publishOperation()
|
||||||
.repository(MAVEN_LOCAL)
|
|
||||||
// .repository(version.isSnapshot() ? repository("rife2-snapshot") : repository("rife2"))
|
// .repository(version.isSnapshot() ? repository("rife2-snapshot") : repository("rife2"))
|
||||||
|
.repository(MAVEN_LOCAL)
|
||||||
.info()
|
.info()
|
||||||
.groupId("com.uwyn.rife2")
|
.groupId("com.uwyn.rife2")
|
||||||
.artifactId("bld-jacoco-report")
|
.artifactId("bld-jacoco-report")
|
||||||
|
|
|
@ -20,6 +20,8 @@ import org.jacoco.core.analysis.Analyzer;
|
||||||
import org.jacoco.core.analysis.CoverageBuilder;
|
import org.jacoco.core.analysis.CoverageBuilder;
|
||||||
import org.jacoco.core.analysis.IBundleCoverage;
|
import org.jacoco.core.analysis.IBundleCoverage;
|
||||||
import org.jacoco.core.data.ExecutionDataStore;
|
import org.jacoco.core.data.ExecutionDataStore;
|
||||||
|
import org.jacoco.core.instr.Instrumenter;
|
||||||
|
import org.jacoco.core.runtime.OfflineInstrumentationAccessGenerator;
|
||||||
import org.jacoco.core.tools.ExecFileLoader;
|
import org.jacoco.core.tools.ExecFileLoader;
|
||||||
import org.jacoco.report.*;
|
import org.jacoco.report.*;
|
||||||
import org.jacoco.report.csv.CSVFormatter;
|
import org.jacoco.report.csv.CSVFormatter;
|
||||||
|
@ -30,6 +32,8 @@ import rife.bld.operations.JUnitOperation;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -37,7 +41,6 @@ import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,10 +53,12 @@ public class JacocoReportOperation extends JUnitOperation {
|
||||||
private static final Logger LOGGER = Logger.getLogger(JacocoReportOperation.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(JacocoReportOperation.class.getName());
|
||||||
private final List<File> classFiles = new ArrayList<>();
|
private final List<File> classFiles = new ArrayList<>();
|
||||||
private final List<File> execFiles = new ArrayList<>();
|
private final List<File> execFiles = new ArrayList<>();
|
||||||
|
private final List<File> instrumentedFiles = new ArrayList<>();
|
||||||
private final List<File> sourceFiles = new ArrayList<>();
|
private final List<File> sourceFiles = new ArrayList<>();
|
||||||
private File csv;
|
private File csv;
|
||||||
private String encoding;
|
private String encoding;
|
||||||
private File html;
|
private File html;
|
||||||
|
private Instrumenter instrumenter;
|
||||||
private String name = "JaCoCo Coverage Report";
|
private String name = "JaCoCo Coverage Report";
|
||||||
private BaseProject project;
|
private BaseProject project;
|
||||||
private boolean quiet;
|
private boolean quiet;
|
||||||
|
@ -70,6 +75,22 @@ public class JacocoReportOperation extends JUnitOperation {
|
||||||
return builder.getBundle(name);
|
return builder.getBundle(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
|
||||||
|
private void buildInstrumentedFiles(File dest) throws IOException {
|
||||||
|
var total = 0;
|
||||||
|
for (var f : classFiles) {
|
||||||
|
if (f.isFile()) {
|
||||||
|
total += instrument(f, new File(dest, f.getName()));
|
||||||
|
} else {
|
||||||
|
total += instrumentRecursive(f, dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (LOGGER.isLoggable(Level.INFO) && !quiet) {
|
||||||
|
LOGGER.log(Level.INFO, "{0} classes instrumented to {1}.",
|
||||||
|
new Object[]{total, dest.getAbsolutePath()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the locations of Java class files.
|
* Sets the locations of Java class files.
|
||||||
**/
|
**/
|
||||||
|
@ -115,18 +136,10 @@ public class JacocoReportOperation extends JUnitOperation {
|
||||||
} else {
|
} else {
|
||||||
var buildJacocoReportsDir = Path.of(project.buildDirectory().getPath(), "reports", "jacoco", "test").toFile();
|
var buildJacocoReportsDir = Path.of(project.buildDirectory().getPath(), "reports", "jacoco", "test").toFile();
|
||||||
var buildJacocoExecDir = Path.of(project.buildDirectory().getPath(), "jacoco").toFile();
|
var buildJacocoExecDir = Path.of(project.buildDirectory().getPath(), "jacoco").toFile();
|
||||||
var buildJacocoTestExec = new File(buildJacocoExecDir, "test.exec");
|
var buildJacocoClassesDir = Path.of(buildJacocoExecDir.getPath(), "classes").toFile();
|
||||||
|
|
||||||
if (execFiles.isEmpty()) {
|
instrumenter = new Instrumenter(new OfflineInstrumentationAccessGenerator());
|
||||||
execFiles.add(buildJacocoTestExec);
|
instrumenter.setRemoveSignatures(true);
|
||||||
|
|
||||||
//noinspection ResultOfMethodCallIgnored
|
|
||||||
buildJacocoExecDir.mkdirs();
|
|
||||||
|
|
||||||
javaOptions().javaAgent(new File(project.libBldDirectory(), "jacocoagent.jar"),
|
|
||||||
"destfile=" + buildJacocoTestExec +
|
|
||||||
",includes=" + classFiles.stream().map(File::toString).collect(Collectors.joining(",")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sourceFiles.isEmpty()) {
|
if (sourceFiles.isEmpty()) {
|
||||||
sourceFiles.add(project.srcDirectory());
|
sourceFiles.add(project.srcDirectory());
|
||||||
|
@ -150,6 +163,17 @@ public class JacocoReportOperation extends JUnitOperation {
|
||||||
csv = new File(buildJacocoReportsDir, "jacocoTestReport.csv");
|
csv = new File(buildJacocoReportsDir, "jacocoTestReport.csv");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (execFiles.isEmpty()) {
|
||||||
|
//noinspection ResultOfMethodCallIgnored
|
||||||
|
buildJacocoClassesDir.mkdirs();
|
||||||
|
|
||||||
|
buildInstrumentedFiles(buildJacocoClassesDir);
|
||||||
|
var files = buildJacocoClassesDir.listFiles();
|
||||||
|
if (files != null) {
|
||||||
|
instrumentedFiles.addAll(Arrays.asList(files));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//noinspection ResultOfMethodCallIgnored
|
//noinspection ResultOfMethodCallIgnored
|
||||||
buildJacocoReportsDir.mkdirs();
|
buildJacocoReportsDir.mkdirs();
|
||||||
|
|
||||||
|
@ -162,6 +186,7 @@ public class JacocoReportOperation extends JUnitOperation {
|
||||||
/**
|
/**
|
||||||
* Configure the operation from a {@link BaseProject}.
|
* Configure the operation from a {@link BaseProject}.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public JacocoReportOperation fromProject(BaseProject project) {
|
public JacocoReportOperation fromProject(BaseProject project) {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
return this;
|
return this;
|
||||||
|
@ -175,6 +200,39 @@ public class JacocoReportOperation extends JUnitOperation {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int instrument(final File src, final File dest) throws IOException {
|
||||||
|
//noinspection ResultOfMethodCallIgnored
|
||||||
|
dest.getParentFile().mkdirs();
|
||||||
|
try (InputStream input = Files.newInputStream(src.toPath())) {
|
||||||
|
try (OutputStream output = Files.newOutputStream(dest.toPath())) {
|
||||||
|
return instrumenter.instrumentAll(input, output,
|
||||||
|
src.getAbsolutePath());
|
||||||
|
}
|
||||||
|
} catch (final IOException e) {
|
||||||
|
//noinspection ResultOfMethodCallIgnored
|
||||||
|
dest.delete();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
|
||||||
|
private int instrumentRecursive(final File src, final File dest)
|
||||||
|
throws IOException {
|
||||||
|
var total = 0;
|
||||||
|
if (src.isDirectory()) {
|
||||||
|
var listFiles = src.listFiles();
|
||||||
|
if (listFiles != null) {
|
||||||
|
for (var child : listFiles) {
|
||||||
|
total += instrumentRecursive(child,
|
||||||
|
new File(dest, child.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
total += instrument(src, dest);
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
private ExecFileLoader loadExecFiles() throws IOException {
|
private ExecFileLoader loadExecFiles() throws IOException {
|
||||||
var loader = new ExecFileLoader();
|
var loader = new ExecFileLoader();
|
||||||
if (execFiles.isEmpty() && LOGGER.isLoggable(Level.WARNING) && !quiet) {
|
if (execFiles.isEmpty() && LOGGER.isLoggable(Level.WARNING) && !quiet) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue