mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-26 08:37:11 -07:00
Updated version to 1.9.0-SNAPSHOT.
Renamed blank project creation to app. Revised project creation descriptions. Added ability to have command aliases. Preserve compatibility with create-blank command through an alias.
This commit is contained in:
parent
86d81c9c51
commit
d8c0170dc0
38 changed files with 186 additions and 92 deletions
|
@ -157,6 +157,61 @@ public class TestProject {
|
|||
}
|
||||
}
|
||||
|
||||
static class CustomProjectRenamedCommand extends Project {
|
||||
StringBuilder result_;
|
||||
|
||||
CustomProjectRenamedCommand(File tmp, StringBuilder result) {
|
||||
result_ = result;
|
||||
workDirectory = tmp;
|
||||
pkg = "test.pkg";
|
||||
name = "my_project";
|
||||
version = new VersionNumber(0, 0, 1);
|
||||
}
|
||||
|
||||
@BuildCommand(value = "renamed", alias = "alias")
|
||||
public void newcommand() {
|
||||
assertEquals("renamed", getCurrentCommandName());
|
||||
assertNotNull(getCurrentCommandDefinition());
|
||||
result_.append("renamed");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRenamedCustomCommand()
|
||||
throws Exception {
|
||||
var tmp = Files.createTempDirectory("test").toFile();
|
||||
try {
|
||||
var result = new StringBuilder();
|
||||
var project = new CustomProjectRenamedCommand(tmp, result);
|
||||
|
||||
assertNull(project.getCurrentCommandName());
|
||||
assertNull(project.getCurrentCommandDefinition());
|
||||
|
||||
project.execute(new String[]{"renamed"});
|
||||
|
||||
assertNull(project.getCurrentCommandName());
|
||||
assertNull(project.getCurrentCommandDefinition());
|
||||
|
||||
assertEquals("renamed", result.toString());
|
||||
|
||||
// test alias
|
||||
result = new StringBuilder();
|
||||
project = new CustomProjectRenamedCommand(tmp, result);
|
||||
|
||||
assertNull(project.getCurrentCommandName());
|
||||
assertNull(project.getCurrentCommandDefinition());
|
||||
|
||||
project.execute(new String[]{"alias"});
|
||||
|
||||
assertNull(project.getCurrentCommandName());
|
||||
assertNull(project.getCurrentCommandDefinition());
|
||||
|
||||
assertEquals("renamed", result.toString());
|
||||
} finally {
|
||||
FileUtils.deleteDirectory(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
static class CustomProjectInlineHelp extends Project {
|
||||
CustomProjectInlineHelp(File tmp) {
|
||||
workDirectory = tmp;
|
||||
|
|
|
@ -11,7 +11,6 @@ import rife.tools.FileUtils;
|
|||
import javax.tools.DiagnosticCollector;
|
||||
import javax.tools.JavaFileObject;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -214,7 +213,7 @@ public class TestCompileOperation {
|
|||
throws Exception {
|
||||
var tmp = Files.createTempDirectory("test").toFile();
|
||||
try {
|
||||
var create_operation = new CreateBlankOperation()
|
||||
var create_operation = new CreateAppOperation()
|
||||
.workDirectory(tmp)
|
||||
.packageName("tst")
|
||||
.projectName("app")
|
||||
|
|
|
@ -19,10 +19,10 @@ import java.util.regex.Pattern;
|
|||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestCreateBlankOperation {
|
||||
public class TestCreateAppOperation {
|
||||
@Test
|
||||
void testInstantiation() {
|
||||
var operation = new CreateBlankOperation();
|
||||
var operation = new CreateAppOperation();
|
||||
assertNotNull(operation.workDirectory());
|
||||
assertTrue(operation.workDirectory().exists());
|
||||
assertTrue(operation.workDirectory().isDirectory());
|
||||
|
@ -41,7 +41,7 @@ public class TestCreateBlankOperation {
|
|||
var package_name = "packageName";
|
||||
var project_name = "projectName";
|
||||
|
||||
var operation = new CreateBlankOperation();
|
||||
var operation = new CreateAppOperation();
|
||||
operation
|
||||
.workDirectory(work_directory)
|
||||
.downloadDependencies(download_dependencies)
|
||||
|
@ -62,7 +62,7 @@ public class TestCreateBlankOperation {
|
|||
throws Exception {
|
||||
var tmp = Files.createTempDirectory("test").toFile();
|
||||
try {
|
||||
var create_operation = new CreateBlankOperation()
|
||||
var create_operation = new CreateAppOperation()
|
||||
.workDirectory(tmp)
|
||||
.packageName("com.example")
|
||||
.projectName("myapp")
|
||||
|
@ -236,7 +236,7 @@ public class TestCreateBlankOperation {
|
|||
throws Exception {
|
||||
var tmp = Files.createTempDirectory("test").toFile();
|
||||
try {
|
||||
var create_operation = new CreateBlankOperation()
|
||||
var create_operation = new CreateAppOperation()
|
||||
.workDirectory(tmp)
|
||||
.packageName("org.stuff")
|
||||
.projectName("yourthing");
|
||||
|
@ -312,7 +312,7 @@ public class TestCreateBlankOperation {
|
|||
throws Exception {
|
||||
var tmp = Files.createTempDirectory("test").toFile();
|
||||
try {
|
||||
var create_operation = new CreateBlankOperation()
|
||||
var create_operation = new CreateAppOperation()
|
||||
.workDirectory(tmp)
|
||||
.packageName("com.example")
|
||||
.projectName("myapp")
|
||||
|
@ -436,7 +436,7 @@ public class TestCreateBlankOperation {
|
|||
throws Exception {
|
||||
var tmp = Files.createTempDirectory("test").toFile();
|
||||
try {
|
||||
var create_operation = new CreateBlankOperation()
|
||||
var create_operation = new CreateAppOperation()
|
||||
.workDirectory(tmp)
|
||||
.packageName("com.example")
|
||||
.projectName("myapp")
|
|
@ -16,7 +16,6 @@ import java.util.List;
|
|||
import java.util.function.Function;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static rife.bld.dependencies.Scope.test;
|
||||
|
||||
public class TestJUnitOperation {
|
||||
@Test
|
||||
|
@ -176,7 +175,7 @@ public class TestJUnitOperation {
|
|||
throws Exception {
|
||||
var tmp = Files.createTempDirectory("test").toFile();
|
||||
try {
|
||||
var create_operation = new CreateBlankOperation()
|
||||
var create_operation = new CreateAppOperation()
|
||||
.workDirectory(tmp)
|
||||
.packageName("com.example")
|
||||
.projectName("myapp")
|
||||
|
@ -219,7 +218,7 @@ public class TestJUnitOperation {
|
|||
throws Exception {
|
||||
var tmp = Files.createTempDirectory("test").toFile();
|
||||
try {
|
||||
var create_operation = new CreateBlankOperation() {
|
||||
var create_operation = new CreateAppOperation() {
|
||||
@Override
|
||||
protected Project createProjectBlueprint() {
|
||||
var project = super.createProjectBlueprint();
|
||||
|
|
|
@ -182,7 +182,7 @@ public class TestJarOperation {
|
|||
throws Exception {
|
||||
var tmp = Files.createTempDirectory("test").toFile();
|
||||
try {
|
||||
var create_operation = new CreateBlankOperation()
|
||||
var create_operation = new CreateAppOperation()
|
||||
.workDirectory(tmp)
|
||||
.packageName("tst")
|
||||
.projectName("app")
|
||||
|
|
|
@ -263,7 +263,7 @@ public class TestJavadocOperation {
|
|||
throws Exception {
|
||||
var tmp = Files.createTempDirectory("test").toFile();
|
||||
try {
|
||||
var create_operation = new CreateBlankOperation()
|
||||
var create_operation = new CreateAppOperation()
|
||||
.workDirectory(tmp)
|
||||
.packageName("tst")
|
||||
.projectName("app")
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test;
|
|||
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||
import org.junit.jupiter.api.condition.OS;
|
||||
import rife.bld.Project;
|
||||
import rife.bld.blueprints.BlankProjectBlueprint;
|
||||
import rife.bld.blueprints.AppProjectBlueprint;
|
||||
import rife.bld.dependencies.*;
|
||||
import rife.bld.publish.PublishArtifact;
|
||||
import rife.tools.FileUtils;
|
||||
|
@ -136,7 +136,7 @@ public class TestPublishOperation {
|
|||
assertThrows(FileUtilsErrorException.class, () -> FileUtils.readString(new URL("http://localhost:8081/api/maven/details/releases/test/pkg/myapp/0.0.1")));
|
||||
|
||||
// create a first publication
|
||||
var create_operation1 = new CreateBlankOperation()
|
||||
var create_operation1 = new CreateAppOperation()
|
||||
.workDirectory(tmp1)
|
||||
.packageName("test.pkg")
|
||||
.projectName("myapp")
|
||||
|
@ -193,9 +193,9 @@ public class TestPublishOperation {
|
|||
assertEquals("myapp-0.0.1.pom", version_files_json1.getJSONObject(9).get("name"));
|
||||
|
||||
// created an updated publication
|
||||
var create_operation2 = new CreateBlankOperation() {
|
||||
var create_operation2 = new CreateAppOperation() {
|
||||
protected Project createProjectBlueprint() {
|
||||
return new BlankProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 0, 0));
|
||||
return new AppProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 0, 0));
|
||||
}
|
||||
}
|
||||
.workDirectory(tmp2)
|
||||
|
@ -286,7 +286,7 @@ public class TestPublishOperation {
|
|||
var tmp_local = Files.createTempDirectory("test").toFile();
|
||||
try {
|
||||
// create a first publication
|
||||
var create_operation1 = new CreateBlankOperation()
|
||||
var create_operation1 = new CreateAppOperation()
|
||||
.workDirectory(tmp1)
|
||||
.packageName("test.pkg")
|
||||
.projectName("myapp")
|
||||
|
@ -326,9 +326,9 @@ public class TestPublishOperation {
|
|||
assertTrue(maven_metadata1.getVersions().contains(create_operation1.project().version()));
|
||||
|
||||
// created an updated publication
|
||||
var create_operation2 = new CreateBlankOperation() {
|
||||
var create_operation2 = new CreateAppOperation() {
|
||||
protected Project createProjectBlueprint() {
|
||||
return new BlankProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 0, 0));
|
||||
return new AppProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 0, 0));
|
||||
}
|
||||
}
|
||||
.workDirectory(tmp2)
|
||||
|
@ -403,9 +403,9 @@ public class TestPublishOperation {
|
|||
assertThrows(FileUtilsErrorException.class, () -> FileUtils.readString(new URL("http://localhost:8081/api/maven/details/releases/test/pkg/myapp/1.2.3-SNAPSHOT")));
|
||||
|
||||
// create a first publication
|
||||
var create_operation1 = new CreateBlankOperation() {
|
||||
var create_operation1 = new CreateAppOperation() {
|
||||
protected Project createProjectBlueprint() {
|
||||
return new BlankProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 2, 3, "SNAPSHOT"));
|
||||
return new AppProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 2, 3, "SNAPSHOT"));
|
||||
}
|
||||
}
|
||||
.workDirectory(tmp1)
|
||||
|
@ -480,9 +480,9 @@ public class TestPublishOperation {
|
|||
assertTrue(maven_snapshot_metadata1.getVersions().contains(create_operation1.project().version()));
|
||||
|
||||
// created an updated publication
|
||||
var create_operation2 = new CreateBlankOperation() {
|
||||
var create_operation2 = new CreateAppOperation() {
|
||||
protected Project createProjectBlueprint() {
|
||||
return new BlankProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 2, 3, "SNAPSHOT"));
|
||||
return new AppProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 2, 3, "SNAPSHOT"));
|
||||
}
|
||||
}
|
||||
.workDirectory(tmp2)
|
||||
|
@ -573,9 +573,9 @@ public class TestPublishOperation {
|
|||
var tmp_local = Files.createTempDirectory("test").toFile();
|
||||
try {
|
||||
// create a first publication
|
||||
var create_operation1 = new CreateBlankOperation() {
|
||||
var create_operation1 = new CreateAppOperation() {
|
||||
protected Project createProjectBlueprint() {
|
||||
return new BlankProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 2, 3, "SNAPSHOT"));
|
||||
return new AppProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 2, 3, "SNAPSHOT"));
|
||||
}
|
||||
}
|
||||
.workDirectory(tmp1)
|
||||
|
@ -629,9 +629,9 @@ public class TestPublishOperation {
|
|||
assertTrue(maven_snapshot_metadata1.getVersions().contains(create_operation1.project().version()));
|
||||
|
||||
// created an updated publication
|
||||
var create_operation2 = new CreateBlankOperation() {
|
||||
var create_operation2 = new CreateAppOperation() {
|
||||
protected Project createProjectBlueprint() {
|
||||
return new BlankProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 2, 3, "SNAPSHOT"));
|
||||
return new AppProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 2, 3, "SNAPSHOT"));
|
||||
}
|
||||
}
|
||||
.workDirectory(tmp2)
|
||||
|
|
|
@ -160,7 +160,7 @@ public class TestRunOperation {
|
|||
throws Exception {
|
||||
var tmp = Files.createTempDirectory("test").toFile();
|
||||
try {
|
||||
var create_operation = new CreateBlankOperation()
|
||||
var create_operation = new CreateAppOperation()
|
||||
.workDirectory(tmp)
|
||||
.packageName("com.example")
|
||||
.projectName("myapp")
|
||||
|
|
|
@ -90,11 +90,11 @@ public class TestUberJarOperation {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testFromProjectBlank()
|
||||
void testFromProjectApp()
|
||||
throws Exception {
|
||||
var tmp = Files.createTempDirectory("test").toFile();
|
||||
try {
|
||||
var create_operation = new CreateBlankOperation()
|
||||
var create_operation = new CreateAppOperation()
|
||||
.workDirectory(tmp)
|
||||
.packageName("tst")
|
||||
.projectName("app")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue