2
0
Fork 0
mirror of https://github.com/ethauvin/bld.git synced 2025-04-26 00:37:10 -07:00

Improvements to create operations

This commit is contained in:
Geert Bevin 2024-12-26 16:51:46 -05:00
parent 66f7d180b9
commit 34667b5402
11 changed files with 28 additions and 32 deletions

2
core

@ -1 +1 @@
Subproject commit 3b8ac2d6e806320a9c64ff452223642862b0fe43 Subproject commit 4f780fee57ac4d171fd3db8e20bdcda7a4d27d0b

View file

@ -31,7 +31,7 @@ public class AppProjectBlueprint extends Project {
pkg = packageName; pkg = packageName;
name = projectName; name = projectName;
mainClass = packageName + "." + baseName + "Main"; mainClass = packageName + "." + baseName;
version = versionNumber; version = versionNumber;
downloadSources = true; downloadSources = true;

View file

@ -30,7 +30,7 @@ public class BaseProjectBlueprint extends Project {
pkg = packageName; pkg = packageName;
name = projectName; name = projectName;
mainClass = packageName + "." + baseName + "Main"; mainClass = packageName + "." + baseName;
version = versionNumber; version = versionNumber;
downloadSources = true; downloadSources = true;

View file

@ -31,7 +31,7 @@ public class LibProjectBlueprint extends Project {
pkg = packageName; pkg = packageName;
name = projectName; name = projectName;
mainClass = packageName + "." + baseName + "Lib"; mainClass = packageName + "." + baseName;
version = versionNumber; version = versionNumber;
downloadSources = true; downloadSources = true;

View file

@ -37,7 +37,6 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
P project_; P project_;
String projectClassName_;
String projectBuildName_; String projectBuildName_;
String projectMainName_; String projectMainName_;
String projectMainUberName_; String projectMainUberName_;
@ -99,7 +98,6 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
project_ = createProjectBlueprint(); project_ = createProjectBlueprint();
// standard names // standard names
projectClassName_ = StringUtils.capitalize(project_.name());
var base_name = baseName(); var base_name = baseName();
projectBuildName_ = projectBuildClassName(base_name); projectBuildName_ = projectBuildClassName(base_name);
projectMainName_ = projectMainClassName(base_name); projectMainName_ = projectMainClassName(base_name);
@ -135,7 +133,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
* @since 1.6 * @since 1.6
*/ */
protected String projectMainClassName(String projectClassName) { protected String projectMainClassName(String projectClassName) {
return projectClassName + "Main"; return projectClassName;
} }
/** /**
@ -145,7 +143,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
* @since 1.6 * @since 1.6
*/ */
protected String projectMainUberClassName(String projectClassName) { protected String projectMainUberClassName(String projectClassName) {
return projectClassName + "Main"; return projectClassName;
} }
/** /**
@ -202,7 +200,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
test_template.setValue("projectTest", projectTestName_); test_template.setValue("projectTest", projectTestName_);
test_template.setValue("projectMain", projectMainName_); test_template.setValue("projectMain", projectMainName_);
if (test_template.hasValueId("project")) { if (test_template.hasValueId("project")) {
test_template.setValue("project", projectClassName_); test_template.setValue("project", project_.name());
} }
var project_test_file = new File(testPackageDirectory_, projectTestName_ + ".java"); var project_test_file = new File(testPackageDirectory_, projectTestName_ + ".java");
FileUtils.writeString(test_template.getContent(), project_test_file); FileUtils.writeString(test_template.getContent(), project_test_file);
@ -214,7 +212,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
build_template.setValue("package", project_.pkg()); build_template.setValue("package", project_.pkg());
} }
if (build_template.hasValueId("project")) { if (build_template.hasValueId("project")) {
build_template.setValue("project", projectClassName_); build_template.setValue("project", project_.name());
} }
if (build_template.hasValueId("projectMain")) { if (build_template.hasValueId("projectMain")) {
build_template.setValue("projectMain", projectMainName_); build_template.setValue("projectMain", projectMainName_);
@ -551,10 +549,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
static String generateBaseName(String projectName) { static String generateBaseName(String projectName) {
if (projectName != null) { if (projectName != null) {
var base_name = projectName.trim(); return StringUtils.filterAsIdentifier(projectName.trim(), true);
base_name = StringUtils.filterAsIdentifier(base_name);
base_name = StringUtils.capitalize(base_name);
return base_name;
} }
return null; return null;

View file

@ -7,6 +7,7 @@ package rife.bld.operations;
import rife.bld.blueprints.Rife2ProjectBlueprint; import rife.bld.blueprints.Rife2ProjectBlueprint;
import rife.template.TemplateFactory; import rife.template.TemplateFactory;
import rife.tools.FileUtils; import rife.tools.FileUtils;
import rife.tools.StringUtils;
import rife.tools.exceptions.FileUtilsErrorException; import rife.tools.exceptions.FileUtilsErrorException;
import java.io.File; import java.io.File;
@ -63,7 +64,7 @@ public class CreateRife2Operation extends AbstractCreateOperation<CreateRife2Ope
// project template // project template
var template_template = TemplateFactory.HTML.get(templateBase_ + "project_template"); var template_template = TemplateFactory.HTML.get(templateBase_ + "project_template");
template_template.setValue("project", projectClassName_); template_template.setValue("project", StringUtils.capitalize(project_.name()));
var project_template_file = new File(project_.srcMainResourcesTemplatesDirectory(), "hello.html"); var project_template_file = new File(project_.srcMainResourcesTemplatesDirectory(), "hello.html");
FileUtils.writeString(template_template.getContent(), project_template_file); FileUtils.writeString(template_template.getContent(), project_template_file);

View file

@ -223,7 +223,7 @@ public class TestCompileOperation {
var compile_operation = new CompileOperation() var compile_operation = new CompileOperation()
.fromProject(create_operation.project()); .fromProject(create_operation.project());
var main_app_class = new File(new File(compile_operation.buildMainDirectory(), "tst"), "AppMain.class"); var main_app_class = new File(new File(compile_operation.buildMainDirectory(), "tst"), "App.class");
var test_app_class = new File(new File(compile_operation.buildTestDirectory(), "tst"), "AppTest.class"); var test_app_class = new File(new File(compile_operation.buildTestDirectory(), "tst"), "AppTest.class");
assertFalse(main_app_class.exists()); assertFalse(main_app_class.exists());
assertFalse(test_app_class.exists()); assertFalse(test_app_class.exists());

View file

@ -132,7 +132,7 @@ public class TestCreateAppOperation {
/my-app/src/main/java /my-app/src/main/java
/my-app/src/main/java/com /my-app/src/main/java/com
/my-app/src/main/java/com/example /my-app/src/main/java/com/example
/my-app/src/main/java/com/example/MyAppMain\\.java /my-app/src/main/java/com/example/MyApp\\.java
/my-app/src/main/resources /my-app/src/main/resources
/my-app/src/main/resources/templates /my-app/src/main/resources/templates
/my-app/src/test /my-app/src/test
@ -170,7 +170,7 @@ public class TestCreateAppOperation {
/my-app/build/main /my-app/build/main
/my-app/build/main/com /my-app/build/main/com
/my-app/build/main/com/example /my-app/build/main/com/example
/my-app/build/main/com/example/MyAppMain\\.class /my-app/build/main/com/example/MyApp\\.class
/my-app/build/test /my-app/build/test
/my-app/build/test/com /my-app/build/test/com
/my-app/build/test/com/example /my-app/build/test/com/example
@ -216,7 +216,7 @@ public class TestCreateAppOperation {
/my-app/src/main/java /my-app/src/main/java
/my-app/src/main/java/com /my-app/src/main/java/com
/my-app/src/main/java/com/example /my-app/src/main/java/com/example
/my-app/src/main/java/com/example/MyAppMain\\.java /my-app/src/main/java/com/example/MyApp\\.java
/my-app/src/main/resources /my-app/src/main/resources
/my-app/src/main/resources/templates /my-app/src/main/resources/templates
/my-app/src/test /my-app/src/test
@ -296,7 +296,7 @@ public class TestCreateAppOperation {
/your-thing/src/main/java /your-thing/src/main/java
/your-thing/src/main/java/org /your-thing/src/main/java/org
/your-thing/src/main/java/org/stuff /your-thing/src/main/java/org/stuff
/your-thing/src/main/java/org/stuff/YourThingMain.java /your-thing/src/main/java/org/stuff/YourThing.java
/your-thing/src/main/resources /your-thing/src/main/resources
/your-thing/src/main/resources/templates /your-thing/src/main/resources/templates
/your-thing/src/test /your-thing/src/test
@ -378,7 +378,7 @@ public class TestCreateAppOperation {
/my-app/build/main /my-app/build/main
/my-app/build/main/com /my-app/build/main/com
/my-app/build/main/com/example /my-app/build/main/com/example
/my-app/build/main/com/example/MyAppMain\\.class /my-app/build/main/com/example/MyApp\\.class
/my-app/build/test /my-app/build/test
/my-app/build/test/com /my-app/build/test/com
/my-app/build/test/com/example /my-app/build/test/com/example
@ -425,7 +425,7 @@ public class TestCreateAppOperation {
/my-app/src/main/java /my-app/src/main/java
/my-app/src/main/java/com /my-app/src/main/java/com
/my-app/src/main/java/com/example /my-app/src/main/java/com/example
/my-app/src/main/java/com/example/MyAppMain\\.java /my-app/src/main/java/com/example/MyApp\\.java
/my-app/src/main/resources /my-app/src/main/resources
/my-app/src/main/resources/templates /my-app/src/main/resources/templates
/my-app/src/test /my-app/src/test
@ -504,7 +504,7 @@ public class TestCreateAppOperation {
/my-app/build/main /my-app/build/main
/my-app/build/main/com /my-app/build/main/com
/my-app/build/main/com/example /my-app/build/main/com/example
/my-app/build/main/com/example/MyAppMain\\.class /my-app/build/main/com/example/MyApp\\.class
/my-app/build/test /my-app/build/test
/my-app/build/test/com /my-app/build/test/com
/my-app/build/test/com/example /my-app/build/test/com/example
@ -552,7 +552,7 @@ public class TestCreateAppOperation {
/my-app/src/main/java /my-app/src/main/java
/my-app/src/main/java/com /my-app/src/main/java/com
/my-app/src/main/java/com/example /my-app/src/main/java/com/example
/my-app/src/main/java/com/example/MyAppMain\\.java /my-app/src/main/java/com/example/MyApp\\.java
/my-app/src/main/resources /my-app/src/main/resources
/my-app/src/main/resources/templates /my-app/src/main/resources/templates
/my-app/src/test /my-app/src/test

View file

@ -107,7 +107,7 @@ public class TestCreateBaseOperation {
/my-app/src/main/java /my-app/src/main/java
/my-app/src/main/java/com /my-app/src/main/java/com
/my-app/src/main/java/com/example /my-app/src/main/java/com/example
/my-app/src/main/java/com/example/MyAppMain\\.java /my-app/src/main/java/com/example/MyApp\\.java
/my-app/src/main/resources /my-app/src/main/resources
/my-app/src/main/resources/templates /my-app/src/main/resources/templates
/my-app/src/test /my-app/src/test
@ -145,7 +145,7 @@ public class TestCreateBaseOperation {
/my-app/build/main /my-app/build/main
/my-app/build/main/com /my-app/build/main/com
/my-app/build/main/com/example /my-app/build/main/com/example
/my-app/build/main/com/example/MyAppMain\\.class /my-app/build/main/com/example/MyApp\\.class
/my-app/build/test /my-app/build/test
/my-app/build/test/com /my-app/build/test/com
/my-app/build/test/com/example /my-app/build/test/com/example
@ -173,7 +173,7 @@ public class TestCreateBaseOperation {
/my-app/src/main/java /my-app/src/main/java
/my-app/src/main/java/com /my-app/src/main/java/com
/my-app/src/main/java/com/example /my-app/src/main/java/com/example
/my-app/src/main/java/com/example/MyAppMain\\.java /my-app/src/main/java/com/example/MyApp\\.java
/my-app/src/main/resources /my-app/src/main/resources
/my-app/src/main/resources/templates /my-app/src/main/resources/templates
/my-app/src/test /my-app/src/test
@ -253,7 +253,7 @@ public class TestCreateBaseOperation {
/your-thing/src/main/java /your-thing/src/main/java
/your-thing/src/main/java/org /your-thing/src/main/java/org
/your-thing/src/main/java/org/stuff /your-thing/src/main/java/org/stuff
/your-thing/src/main/java/org/stuff/YourThingMain.java /your-thing/src/main/java/org/stuff/YourThing.java
/your-thing/src/main/resources /your-thing/src/main/resources
/your-thing/src/main/resources/templates /your-thing/src/main/resources/templates
/your-thing/src/test /your-thing/src/test
@ -292,7 +292,7 @@ public class TestCreateBaseOperation {
/your-thing/build/main /your-thing/build/main
/your-thing/build/main/org /your-thing/build/main/org
/your-thing/build/main/org/stuff /your-thing/build/main/org/stuff
/your-thing/build/main/org/stuff/YourThingMain.class /your-thing/build/main/org/stuff/YourThing.class
/your-thing/build/test /your-thing/build/test
/your-thing/build/test/org /your-thing/build/test/org
/your-thing/build/test/org/stuff /your-thing/build/test/org/stuff
@ -320,7 +320,7 @@ public class TestCreateBaseOperation {
/your-thing/src/main/java /your-thing/src/main/java
/your-thing/src/main/java/org /your-thing/src/main/java/org
/your-thing/src/main/java/org/stuff /your-thing/src/main/java/org/stuff
/your-thing/src/main/java/org/stuff/YourThingMain.java /your-thing/src/main/java/org/stuff/YourThing.java
/your-thing/src/main/resources /your-thing/src/main/resources
/your-thing/src/main/resources/templates /your-thing/src/main/resources/templates
/your-thing/src/test /your-thing/src/test

View file

@ -209,7 +209,7 @@ public class TestJarOperation {
assertEquals(""" assertEquals("""
META-INF/MANIFEST.MF META-INF/MANIFEST.MF
tst/AppMain.class tst/App.class
""", content.toString()); """, content.toString());
} finally { } finally {
FileUtils.deleteDirectory(tmp); FileUtils.deleteDirectory(tmp);

View file

@ -273,7 +273,7 @@ public class TestJavadocOperation {
var javadoc_operation = new JavadocOperation() var javadoc_operation = new JavadocOperation()
.fromProject(create_operation.project()); .fromProject(create_operation.project());
var main_app_html = new File(new File(javadoc_operation.buildDirectory(), "tst"), "AppMain.html"); var main_app_html = new File(new File(javadoc_operation.buildDirectory(), "tst"), "App.html");
var index_html = new File(javadoc_operation.buildDirectory(), "index.html"); var index_html = new File(javadoc_operation.buildDirectory(), "index.html");
var index_all_html = new File(javadoc_operation.buildDirectory(), "index-all.html"); var index_all_html = new File(javadoc_operation.buildDirectory(), "index-all.html");
assertFalse(main_app_html.exists()); assertFalse(main_app_html.exists());