Skip to content

Commit

Permalink
Updated with support for latest JUnit in a backwards compatible way.
Browse files Browse the repository at this point in the history
Updated some other blueprint dependencies.
  • Loading branch information
gbevin committed Oct 20, 2023
1 parent 6230db6 commit 84a2bb3
Show file tree
Hide file tree
Showing 8 changed files with 255 additions and 160 deletions.
2 changes: 1 addition & 1 deletion src/bld/java/rife/BldBuild.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public BldBuild()

repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
scope(test)
.include(dependency("org.json", "json", version(20230618)));
.include(dependency("org.json", "json", version(20231013)));

var core_directory = new File(workDirectory(), "core");
var core_src_directory = new File(core_directory, "src");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/rife/bld/blueprints/BlankProjectBlueprint.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public BlankProjectBlueprint(File work, String packageName, String projectName,
downloadSources = true;
repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS);
scope(test)
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5,9,3)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,9,3)));
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5,10,0)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,10,0)));
}
}
8 changes: 4 additions & 4 deletions src/main/java/rife/bld/blueprints/Rife2ProjectBlueprint.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public Rife2ProjectBlueprint(File work, String packageName, String projectName,
scope(compile)
.include(dependency("com.uwyn.rife2", "rife2", version(1,7,2)));
scope(test)
.include(dependency("org.jsoup", "jsoup", version(1,16,1)))
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5,9,3)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,9,3)));
.include(dependency("org.jsoup", "jsoup", version(1,16,2)))
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5,10,0)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,10,0)));
scope(standalone)
.include(dependency("org.eclipse.jetty", "jetty-server", version(11,0,15)))

This comment has been minimized.

Copy link
@ethauvin

ethauvin Oct 20, 2023

Contributor

Should probably be updated to 12.x

This comment has been minimized.

Copy link
@gbevin

gbevin Oct 20, 2023

Author Contributor

Step by step, this is a delicate process of dependencies

.include(dependency("org.eclipse.jetty", "jetty-servlet", version(11,0,15)))
.include(dependency("org.slf4j", "slf4j-simple", version(2,0,7)));
.include(dependency("org.slf4j", "slf4j-simple", version(2,0,9)));

precompileOperation().templateTypes(TemplateType.HTML);
}
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/rife/bld/operations/JUnitOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
package rife.bld.operations;

import rife.bld.BaseProject;
import rife.tools.FileUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

/**
* Tests a Java application with JUnit.
Expand All @@ -24,6 +29,39 @@ protected JUnitOptions createTestToolOptions() {
return new JUnitOptions();
}

@Override
protected List<String> executeConstructProcessCommandList() {
if (mainClass() == null) {
throw new IllegalArgumentException("ERROR: Missing main class for test execution.");
}

var args = new ArrayList<String>();
args.add(javaTool());
args.addAll(javaOptions());
args.add("-cp");
var classpath = FileUtils.joinPaths(classpath());
args.add(classpath);
args.add(mainClass());
// the JUnit console launcher syntax changed in v1.10.x,
// this logic defaults to the new syntax but if it finds an older
// JUnit jar in the classpath, uses the old syntax
var junit_version_1_10_and_later = true;
var junit_version_pattern = Pattern.compile("junit-platform-console-standalone-(\\d+)\\.(\\d+)\\.");
var junit_version_matcher = junit_version_pattern.matcher(classpath);
if (junit_version_matcher.find() &&
(Integer.parseInt(junit_version_matcher.group(1)) < 1 ||
(Integer.parseInt(junit_version_matcher.group(1)) == 1 &&
Integer.parseInt(junit_version_matcher.group(2)) < 10))) {
junit_version_1_10_and_later = false;
}
if (junit_version_1_10_and_later) {
args.add("execute");
}
args.addAll(testToolOptions());

return args;
}

@Override
public JUnitOperation fromProject(BaseProject project) {
super.fromProject(project);
Expand Down
128 changes: 64 additions & 64 deletions src/test/java/rife/bld/operations/TestCreateBlankOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,22 @@ void testExecute()
/myapp/lib/test
/myapp/lib/test/apiguardian-api-1\\.1\\.2-sources\\.jar
/myapp/lib/test/apiguardian-api-1\\.1\\.2\\.jar
/myapp/lib/test/junit-jupiter-5\\.9\\.3-sources\\.jar
/myapp/lib/test/junit-jupiter-5\\.9\\.3\\.jar
/myapp/lib/test/junit-jupiter-api-5\\.9\\.3-sources\\.jar
/myapp/lib/test/junit-jupiter-api-5\\.9\\.3\\.jar
/myapp/lib/test/junit-jupiter-engine-5\\.9\\.3-sources\\.jar
/myapp/lib/test/junit-jupiter-engine-5\\.9\\.3\\.jar
/myapp/lib/test/junit-jupiter-params-5\\.9\\.3-sources\\.jar
/myapp/lib/test/junit-jupiter-params-5\\.9\\.3\\.jar
/myapp/lib/test/junit-platform-commons-1\\.9\\.3-sources\\.jar
/myapp/lib/test/junit-platform-commons-1\\.9\\.3\\.jar
/myapp/lib/test/junit-platform-console-standalone-1\\.9\\.3-sources\\.jar
/myapp/lib/test/junit-platform-console-standalone-1\\.9\\.3\\.jar
/myapp/lib/test/junit-platform-engine-1\\.9\\.3-sources\\.jar
/myapp/lib/test/junit-platform-engine-1\\.9\\.3\\.jar
/myapp/lib/test/opentest4j-1\\.2\\.0-sources\\.jar
/myapp/lib/test/opentest4j-1\\.2\\.0\\.jar
/myapp/lib/test/junit-jupiter-5\\.10\\.0-sources\\.jar
/myapp/lib/test/junit-jupiter-5\\.10\\.0\\.jar
/myapp/lib/test/junit-jupiter-api-5\\.10\\.0-sources\\.jar
/myapp/lib/test/junit-jupiter-api-5\\.10\\.0\\.jar
/myapp/lib/test/junit-jupiter-engine-5\\.10\\.0-sources\\.jar
/myapp/lib/test/junit-jupiter-engine-5\\.10\\.0\\.jar
/myapp/lib/test/junit-jupiter-params-5\\.10\\.0-sources\\.jar
/myapp/lib/test/junit-jupiter-params-5\\.10\\.0\\.jar
/myapp/lib/test/junit-platform-commons-1\\.10\\.0-sources\\.jar
/myapp/lib/test/junit-platform-commons-1\\.10\\.0\\.jar
/myapp/lib/test/junit-platform-console-standalone-1\\.10\\.0-sources\\.jar
/myapp/lib/test/junit-platform-console-standalone-1\\.10\\.0\\.jar
/myapp/lib/test/junit-platform-engine-1\\.10\\.0-sources\\.jar
/myapp/lib/test/junit-platform-engine-1\\.10\\.0\\.jar
/myapp/lib/test/opentest4j-1\\.3\\.0-sources\\.jar
/myapp/lib/test/opentest4j-1\\.3\\.0\\.jar
/myapp/src
/myapp/src/bld
/myapp/src/bld/java
Expand Down Expand Up @@ -178,22 +178,22 @@ void testExecute()
/myapp/lib/test
/myapp/lib/test/apiguardian-api-1\\.1\\.2-sources\\.jar
/myapp/lib/test/apiguardian-api-1\\.1\\.2\\.jar
/myapp/lib/test/junit-jupiter-5\\.9\\.3-sources\\.jar
/myapp/lib/test/junit-jupiter-5\\.9\\.3\\.jar
/myapp/lib/test/junit-jupiter-api-5\\.9\\.3-sources\\.jar
/myapp/lib/test/junit-jupiter-api-5\\.9\\.3\\.jar
/myapp/lib/test/junit-jupiter-engine-5\\.9\\.3-sources\\.jar
/myapp/lib/test/junit-jupiter-engine-5\\.9\\.3\\.jar
/myapp/lib/test/junit-jupiter-params-5\\.9\\.3-sources\\.jar
/myapp/lib/test/junit-jupiter-params-5\\.9\\.3\\.jar
/myapp/lib/test/junit-platform-commons-1\\.9\\.3-sources\\.jar
/myapp/lib/test/junit-platform-commons-1\\.9\\.3\\.jar
/myapp/lib/test/junit-platform-console-standalone-1\\.9\\.3-sources\\.jar
/myapp/lib/test/junit-platform-console-standalone-1\\.9\\.3\\.jar
/myapp/lib/test/junit-platform-engine-1\\.9\\.3-sources\\.jar
/myapp/lib/test/junit-platform-engine-1\\.9\\.3\\.jar
/myapp/lib/test/opentest4j-1\\.2\\.0-sources\\.jar
/myapp/lib/test/opentest4j-1\\.2\\.0\\.jar
/myapp/lib/test/junit-jupiter-5\\.10\\.0-sources\\.jar
/myapp/lib/test/junit-jupiter-5\\.10\\.0\\.jar
/myapp/lib/test/junit-jupiter-api-5\\.10\\.0-sources\\.jar
/myapp/lib/test/junit-jupiter-api-5\\.10\\.0\\.jar
/myapp/lib/test/junit-jupiter-engine-5\\.10\\.0-sources\\.jar
/myapp/lib/test/junit-jupiter-engine-5\\.10\\.0\\.jar
/myapp/lib/test/junit-jupiter-params-5\\.10\\.0-sources\\.jar
/myapp/lib/test/junit-jupiter-params-5\\.10\\.0\\.jar
/myapp/lib/test/junit-platform-commons-1\\.10\\.0-sources\\.jar
/myapp/lib/test/junit-platform-commons-1\\.10\\.0\\.jar
/myapp/lib/test/junit-platform-console-standalone-1\\.10\\.0-sources\\.jar
/myapp/lib/test/junit-platform-console-standalone-1\\.10\\.0\\.jar
/myapp/lib/test/junit-platform-engine-1\\.10\\.0-sources\\.jar
/myapp/lib/test/junit-platform-engine-1\\.10\\.0\\.jar
/myapp/lib/test/opentest4j-1\\.3\\.0-sources\\.jar
/myapp/lib/test/opentest4j-1\\.3\\.0\\.jar
/myapp/src
/myapp/src/bld
/myapp/src/bld/java
Expand Down Expand Up @@ -374,22 +374,22 @@ void testExecuteLocalDependencies()
/myapp/lib/local
/myapp/lib/local/apiguardian-api-1\\.1\\.2-sources\\.jar
/myapp/lib/local/apiguardian-api-1\\.1\\.2\\.jar
/myapp/lib/local/junit-jupiter-5\\.9\\.3-sources\\.jar
/myapp/lib/local/junit-jupiter-5\\.9\\.3\\.jar
/myapp/lib/local/junit-jupiter-api-5\\.9\\.3-sources\\.jar
/myapp/lib/local/junit-jupiter-api-5\\.9\\.3\\.jar
/myapp/lib/local/junit-jupiter-engine-5\\.9\\.3-sources\\.jar
/myapp/lib/local/junit-jupiter-engine-5\\.9\\.3\\.jar
/myapp/lib/local/junit-jupiter-params-5\\.9\\.3-sources\\.jar
/myapp/lib/local/junit-jupiter-params-5\\.9\\.3\\.jar
/myapp/lib/local/junit-platform-commons-1\\.9\\.3-sources\\.jar
/myapp/lib/local/junit-platform-commons-1\\.9\\.3\\.jar
/myapp/lib/local/junit-platform-console-standalone-1\\.9\\.3-sources\\.jar
/myapp/lib/local/junit-platform-console-standalone-1\\.9\\.3\\.jar
/myapp/lib/local/junit-platform-engine-1\\.9\\.3-sources\\.jar
/myapp/lib/local/junit-platform-engine-1\\.9\\.3\\.jar
/myapp/lib/local/opentest4j-1\\.2\\.0-sources\\.jar
/myapp/lib/local/opentest4j-1\\.2\\.0\\.jar
/myapp/lib/local/junit-jupiter-5\\.10\\.0-sources\\.jar
/myapp/lib/local/junit-jupiter-5\\.10\\.0\\.jar
/myapp/lib/local/junit-jupiter-api-5\\.10\\.0-sources\\.jar
/myapp/lib/local/junit-jupiter-api-5\\.10\\.0\\.jar
/myapp/lib/local/junit-jupiter-engine-5\\.10\\.0-sources\\.jar
/myapp/lib/local/junit-jupiter-engine-5\\.10\\.0\\.jar
/myapp/lib/local/junit-jupiter-params-5\\.10\\.0-sources\\.jar
/myapp/lib/local/junit-jupiter-params-5\\.10\\.0\\.jar
/myapp/lib/local/junit-platform-commons-1\\.10\\.0-sources\\.jar
/myapp/lib/local/junit-platform-commons-1\\.10\\.0\\.jar
/myapp/lib/local/junit-platform-console-standalone-1\\.10\\.0-sources\\.jar
/myapp/lib/local/junit-platform-console-standalone-1\\.10\\.0\\.jar
/myapp/lib/local/junit-platform-engine-1\\.10\\.0-sources\\.jar
/myapp/lib/local/junit-platform-engine-1\\.10\\.0\\.jar
/myapp/lib/local/opentest4j-1\\.3\\.0-sources\\.jar
/myapp/lib/local/opentest4j-1\\.3\\.0\\.jar
/myapp/lib/runtime
/myapp/lib/test
/myapp/src
Expand Down Expand Up @@ -495,22 +495,22 @@ void testExecuteLocalDependenciesFolders()
/myapp/lib/local_test
/myapp/lib/local_test/apiguardian-api-1\\.1\\.2-sources\\.jar
/myapp/lib/local_test/apiguardian-api-1\\.1\\.2\\.jar
/myapp/lib/local_test/junit-jupiter-5\\.9\\.3-sources\\.jar
/myapp/lib/local_test/junit-jupiter-5\\.9\\.3\\.jar
/myapp/lib/local_test/junit-jupiter-api-5\\.9\\.3-sources\\.jar
/myapp/lib/local_test/junit-jupiter-api-5\\.9\\.3\\.jar
/myapp/lib/local_test/junit-jupiter-engine-5\\.9\\.3-sources\\.jar
/myapp/lib/local_test/junit-jupiter-engine-5\\.9\\.3\\.jar
/myapp/lib/local_test/junit-jupiter-params-5\\.9\\.3-sources\\.jar
/myapp/lib/local_test/junit-jupiter-params-5\\.9\\.3\\.jar
/myapp/lib/local_test/junit-platform-commons-1\\.9\\.3-sources\\.jar
/myapp/lib/local_test/junit-platform-commons-1\\.9\\.3\\.jar
/myapp/lib/local_test/junit-platform-console-standalone-1\\.9\\.3-sources\\.jar
/myapp/lib/local_test/junit-platform-console-standalone-1\\.9\\.3\\.jar
/myapp/lib/local_test/junit-platform-engine-1\\.9\\.3-sources\\.jar
/myapp/lib/local_test/junit-platform-engine-1\\.9\\.3\\.jar
/myapp/lib/local_test/opentest4j-1\\.2\\.0-sources\\.jar
/myapp/lib/local_test/opentest4j-1\\.2\\.0\\.jar
/myapp/lib/local_test/junit-jupiter-5\\.10\\.0-sources\\.jar
/myapp/lib/local_test/junit-jupiter-5\\.10\\.0\\.jar
/myapp/lib/local_test/junit-jupiter-api-5\\.10\\.0-sources\\.jar
/myapp/lib/local_test/junit-jupiter-api-5\\.10\\.0\\.jar
/myapp/lib/local_test/junit-jupiter-engine-5\\.10\\.0-sources\\.jar
/myapp/lib/local_test/junit-jupiter-engine-5\\.10\\.0\\.jar
/myapp/lib/local_test/junit-jupiter-params-5\\.10\\.0-sources\\.jar
/myapp/lib/local_test/junit-jupiter-params-5\\.10\\.0\\.jar
/myapp/lib/local_test/junit-platform-commons-1\\.10\\.0-sources\\.jar
/myapp/lib/local_test/junit-platform-commons-1\\.10\\.0\\.jar
/myapp/lib/local_test/junit-platform-console-standalone-1\\.10\\.0-sources\\.jar
/myapp/lib/local_test/junit-platform-console-standalone-1\\.10\\.0\\.jar
/myapp/lib/local_test/junit-platform-engine-1\\.10\\.0-sources\\.jar
/myapp/lib/local_test/junit-platform-engine-1\\.10\\.0\\.jar
/myapp/lib/local_test/opentest4j-1\\.3\\.0-sources\\.jar
/myapp/lib/local_test/opentest4j-1\\.3\\.0\\.jar
/myapp/lib/runtime
/myapp/lib/test
/myapp/src
Expand Down
Loading

0 comments on commit 84a2bb3

Please sign in to comment.