Skip to content

Commit

Permalink
Improvements to create operations
Browse files Browse the repository at this point in the history
  • Loading branch information
gbevin committed Dec 26, 2024
1 parent 66f7d18 commit 34667b5
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 32 deletions.
2 changes: 1 addition & 1 deletion core
2 changes: 1 addition & 1 deletion src/main/java/rife/bld/blueprints/AppProjectBlueprint.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public AppProjectBlueprint(File work, String packageName, String projectName, St

pkg = packageName;
name = projectName;
mainClass = packageName + "." + baseName + "Main";
mainClass = packageName + "." + baseName;
version = versionNumber;

downloadSources = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public BaseProjectBlueprint(File work, String packageName, String projectName, S

pkg = packageName;
name = projectName;
mainClass = packageName + "." + baseName + "Main";
mainClass = packageName + "." + baseName;
version = versionNumber;

downloadSources = true;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rife/bld/blueprints/LibProjectBlueprint.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public LibProjectBlueprint(File work, String packageName, String projectName, St

pkg = packageName;
name = projectName;
mainClass = packageName + "." + baseName + "Lib";
mainClass = packageName + "." + baseName;
version = versionNumber;

downloadSources = true;
Expand Down
15 changes: 5 additions & 10 deletions src/main/java/rife/bld/operations/AbstractCreateOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<

P project_;

String projectClassName_;
String projectBuildName_;
String projectMainName_;
String projectMainUberName_;
Expand Down Expand Up @@ -99,7 +98,6 @@ protected void executeConfigure() {
project_ = createProjectBlueprint();

// standard names
projectClassName_ = StringUtils.capitalize(project_.name());
var base_name = baseName();
projectBuildName_ = projectBuildClassName(base_name);
projectMainName_ = projectMainClassName(base_name);
Expand Down Expand Up @@ -135,7 +133,7 @@ protected String projectBuildClassName(String projectClassName) {
* @since 1.6
*/
protected String projectMainClassName(String projectClassName) {
return projectClassName + "Main";
return projectClassName;
}

/**
Expand All @@ -145,7 +143,7 @@ protected String projectMainClassName(String projectClassName) {
* @since 1.6
*/
protected String projectMainUberClassName(String projectClassName) {
return projectClassName + "Main";
return projectClassName;
}

/**
Expand Down Expand Up @@ -202,7 +200,7 @@ protected void executePopulateProjectStructure()
test_template.setValue("projectTest", projectTestName_);
test_template.setValue("projectMain", projectMainName_);
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");
FileUtils.writeString(test_template.getContent(), project_test_file);
Expand All @@ -214,7 +212,7 @@ protected void executePopulateProjectStructure()
build_template.setValue("package", project_.pkg());
}
if (build_template.hasValueId("project")) {
build_template.setValue("project", projectClassName_);
build_template.setValue("project", project_.name());
}
if (build_template.hasValueId("projectMain")) {
build_template.setValue("projectMain", projectMainName_);
Expand Down Expand Up @@ -551,10 +549,7 @@ public String projectName() {

static String generateBaseName(String projectName) {
if (projectName != null) {
var base_name = projectName.trim();
base_name = StringUtils.filterAsIdentifier(base_name);
base_name = StringUtils.capitalize(base_name);
return base_name;
return StringUtils.filterAsIdentifier(projectName.trim(), true);
}

return null;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/rife/bld/operations/CreateRife2Operation.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import rife.bld.blueprints.Rife2ProjectBlueprint;
import rife.template.TemplateFactory;
import rife.tools.FileUtils;
import rife.tools.StringUtils;
import rife.tools.exceptions.FileUtilsErrorException;

import java.io.File;
Expand Down Expand Up @@ -63,7 +64,7 @@ protected void executePopulateProjectStructure()

// 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");
FileUtils.writeString(template_template.getContent(), project_template_file);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void testFromProject()
var compile_operation = new CompileOperation()
.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");
assertFalse(main_app_class.exists());
assertFalse(test_app_class.exists());
Expand Down
16 changes: 8 additions & 8 deletions src/test/java/rife/bld/operations/TestCreateAppOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void testExecute()
/my-app/src/main/java
/my-app/src/main/java/com
/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/templates
/my-app/src/test
Expand Down Expand Up @@ -170,7 +170,7 @@ void testExecute()
/my-app/build/main
/my-app/build/main/com
/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/com
/my-app/build/test/com/example
Expand Down Expand Up @@ -216,7 +216,7 @@ void testExecute()
/my-app/src/main/java
/my-app/src/main/java/com
/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/templates
/my-app/src/test
Expand Down Expand Up @@ -296,7 +296,7 @@ void testExecuteNoDownload()
/your-thing/src/main/java
/your-thing/src/main/java/org
/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/templates
/your-thing/src/test
Expand Down Expand Up @@ -378,7 +378,7 @@ void testExecuteLocalDependencies()
/my-app/build/main
/my-app/build/main/com
/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/com
/my-app/build/test/com/example
Expand Down Expand Up @@ -425,7 +425,7 @@ void testExecuteLocalDependencies()
/my-app/src/main/java
/my-app/src/main/java/com
/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/templates
/my-app/src/test
Expand Down Expand Up @@ -504,7 +504,7 @@ void testExecuteLocalDependenciesFolders()
/my-app/build/main
/my-app/build/main/com
/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/com
/my-app/build/test/com/example
Expand Down Expand Up @@ -552,7 +552,7 @@ void testExecuteLocalDependenciesFolders()
/my-app/src/main/java
/my-app/src/main/java/com
/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/templates
/my-app/src/test
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/rife/bld/operations/TestCreateBaseOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void testExecute()
/my-app/src/main/java
/my-app/src/main/java/com
/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/templates
/my-app/src/test
Expand Down Expand Up @@ -145,7 +145,7 @@ void testExecute()
/my-app/build/main
/my-app/build/main/com
/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/com
/my-app/build/test/com/example
Expand Down Expand Up @@ -173,7 +173,7 @@ void testExecute()
/my-app/src/main/java
/my-app/src/main/java/com
/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/templates
/my-app/src/test
Expand Down Expand Up @@ -253,7 +253,7 @@ void testExecuteNoDownload()
/your-thing/src/main/java
/your-thing/src/main/java/org
/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/templates
/your-thing/src/test
Expand Down Expand Up @@ -292,7 +292,7 @@ void testExecuteNoDownload()
/your-thing/build/main
/your-thing/build/main/org
/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/org
/your-thing/build/test/org/stuff
Expand Down Expand Up @@ -320,7 +320,7 @@ void testExecuteNoDownload()
/your-thing/src/main/java
/your-thing/src/main/java/org
/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/templates
/your-thing/src/test
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/rife/bld/operations/TestJarOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void testFromProject()

assertEquals("""
META-INF/MANIFEST.MF
tst/AppMain.class
tst/App.class
""", content.toString());
} finally {
FileUtils.deleteDirectory(tmp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void testFromProject()
var javadoc_operation = new JavadocOperation()
.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_all_html = new File(javadoc_operation.buildDirectory(), "index-all.html");
assertFalse(main_app_html.exists());
Expand Down

0 comments on commit 34667b5

Please sign in to comment.