2
0
Fork 0
mirror of https://github.com/ethauvin/bld.git synced 2025-04-27 00:38:12 -07:00

Test fixes for changed dependency versions.

Tweaked vscode project structures.
Changed lib project to use JUnit and extend Project instead of BaseProject
This commit is contained in:
Geert Bevin 2024-02-25 12:42:24 -05:00
parent 183097c4f9
commit 30101af0ab
18 changed files with 240 additions and 424 deletions

View file

@ -13,6 +13,7 @@ import java.util.List;
import static rife.bld.dependencies.Repository.MAVEN_CENTRAL;
import static rife.bld.dependencies.Repository.SONATYPE_SNAPSHOTS;
import static rife.bld.dependencies.Scope.test;
/**
* Provides the dependency information required to create a new lib project.
@ -35,5 +36,8 @@ public class LibProjectBlueprint extends Project {
downloadSources = true;
repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS);
scope(test)
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5,10,2)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,10,2)));
}
}

View file

@ -40,7 +40,7 @@ public class Rife2ProjectBlueprint extends WebProject {
scope(compile)
.include(dependency("com.uwyn.rife2", "rife2", version(1,7,3)));
scope(test)
.include(dependency("org.jsoup", "jsoup", version(1,17,3)))
.include(dependency("org.jsoup", "jsoup", version(1,17,2)))
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5,10,2)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,10,2)));
scope(standalone)

View file

@ -206,8 +206,12 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
// project build
var build_template = TemplateFactory.TXT.get(templateBase_ + "project_build");
build_template.setValue("projectBuild", projectBuildName_);
build_template.setValue("package", project_.pkg());
build_template.setValue("project", projectClassName_);
if (build_template.hasValueId("package")) {
build_template.setValue("package", project_.pkg());
}
if (build_template.hasValueId("project")) {
build_template.setValue("project", projectClassName_);
}
if (build_template.hasValueId("projectMain")) {
build_template.setValue("projectMain", projectMainName_);
}
@ -326,17 +330,6 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
*/
protected void executePopulateVscodeProject()
throws FileUtilsErrorException {
var launch_template = TemplateFactory.JSON.get(templateBase_ + "vscode.launch");
launch_template.setValue("package", project_.pkg());
if (launch_template.hasValueId("projectMain")) {
launch_template.setValue("projectMain", projectMainName_);
}
if (launch_template.hasValueId("projectTest")) {
launch_template.setValue("projectTest", projectTestName_);
}
var launch_file = new File(vscodeDirectory_, "launch.json");
FileUtils.writeString(launch_template.getContent(), launch_file);
var settings_template = TemplateFactory.JSON.get(templateBase_ + "vscode.settings");
if (settings_template.hasValueId("version")) {
settings_template.setValue("version", BldVersion.getVersion());

View file

@ -1,24 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Run Main",
"request": "launch",
"mainClass": "{{v package/}}.{{v projectMain/}}"
},
{
"type": "java",
"name": "Run Tests",
"request": "launch",
"mainClass": "org.junit.platform.console.ConsoleLauncher",
"args": [
"--details=verbose",
"--scan-classpath",
"--disable-banner",
"--disable-ansi-colors",
"--exclude-engine=junit-platform-suite",
"--exclude-engine=junit-vintage"]
}
]
}

View file

@ -8,6 +8,7 @@
"java.configuration.updateBuildConfiguration": "automatic",
"java.project.referencedLibraries": [
"${HOME}/.bld/dist/bld-{{v version/}}.jar",
"lib/bld/*.jar",
"lib/compile/*.jar",
"lib/provided/*.jar",
"lib/runtime/*.jar",

View file

@ -1,17 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Run Main",
"request": "launch",
"mainClass": "{{v package/}}.{{v projectMain/}}"
},
{
"type": "java",
"name": "Run Tests",
"request": "launch",
"mainClass": "{{v package/}}.{{v projectTest/}}"
}
]
}

View file

@ -8,6 +8,7 @@
"java.configuration.updateBuildConfiguration": "automatic",
"java.project.referencedLibraries": [
"${HOME}/.bld/dist/bld-{{v version/}}.jar",
"lib/bld/*.jar",
"lib/compile/*.jar",
"lib/provided/*.jar",
"lib/runtime/*.jar",

View file

@ -1,7 +1,11 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Tests" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="{{v package/}}.{{v projectTest/}}" />
<configuration default="false" name="Run Tests" type="JUnit" factoryName="JUnit">
<module name="app" />
<option name="PACKAGE_NAME" value="moog" />
<option name="MAIN_CLASS_NAME" value="{{v package/}}" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="directory" />
<dir value="$PROJECT_DIR$/src/test/java" />
<method v="2">
<option name="Make" enabled="true" />
</method>

View file

@ -1,17 +1,23 @@
package {{v package/}};
import rife.bld.BaseProject;
import rife.bld.Project;
import java.util.List;
public class {{v projectBuild/}} extends BaseProject {
import static rife.bld.dependencies.Repository.*;
import static rife.bld.dependencies.Scope.*;
public class {{v projectBuild/}} extends Project {
public {{v projectBuild/}}() {
pkg = "{{v package/}}";
name = "{{v project/}}";
version = version(0,1,0);
testOperation().mainClass("{{v package/}}.{{v projectTest/}}");
}
downloadSources = true;
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
{{v scopes}}{{/v}}{{b scope}} scope({{v name/}}){{v dependencies}}{{/v}};
{{b dependency}}
.include(dependency("{{v groupId/}}", "{{v artifactId/}}", version({{v version/}}))){{/b}}{{/b}} }
public static void main(String[] args) {
new {{v projectBuild/}}().start(args);

View file

@ -1,15 +1,12 @@
package {{v package/}};
public class {{v projectTest/}} {
void verifyHello() {
if (!"Hello World!".equals(new {{v projectMain/}}().getMessage())) {
throw new AssertionError();
} else {
System.out.println("Succeeded");
}
}
import org.junit.jupiter.api.Test;
public static void main(String[] args) {
new {{v projectTest/}}().verifyHello();
import static org.junit.jupiter.api.Assertions.*;
public class {{v projectTest/}} {
@Test
void verifyHello() {
assertEquals("Hello World!", new {{v projectMain/}}().getMessage());
}
}
}

View file

@ -1,11 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Run Tests",
"request": "launch",
"mainClass": "{{v package/}}.{{v projectTest/}}"
}
]
}

View file

@ -8,6 +8,7 @@
"java.configuration.updateBuildConfiguration": "automatic",
"java.project.referencedLibraries": [
"${HOME}/.bld/dist/bld-{{v version/}}.jar",
"lib/bld/*.jar",
"lib/compile/*.jar",
"lib/provided/*.jar",
"lib/runtime/*.jar",

View file

@ -1,24 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Run Main",
"request": "launch",
"mainClass": "{{v package/}}.{{v projectMain/}}"
},
{
"type": "java",
"name": "Run Tests",
"request": "launch",
"mainClass": "org.junit.platform.console.ConsoleLauncher",
"args": [
"--details=verbose",
"--scan-classpath",
"--disable-banner",
"--disable-ansi-colors",
"--exclude-engine=junit-platform-suite",
"--exclude-engine=junit-vintage"]
}
]
}

View file

@ -9,6 +9,7 @@
"java.configuration.updateBuildConfiguration": "automatic",
"java.project.referencedLibraries": [
"${HOME}/.bld/dist/bld-{{v version/}}.jar",
"lib/bld/*.jar",
"lib/compile/*.jar",
"lib/provided/*.jar",
"lib/runtime/*.jar",