2
0
Fork 0
mirror of https://github.com/ethauvin/bld.git synced 2025-04-25 16:27:11 -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

View file

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

View file

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

View file

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

View file

@ -37,7 +37,6 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
P project_;
String projectClassName_;
String projectBuildName_;
String projectMainName_;
String projectMainUberName_;
@ -99,7 +98,6 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
project_ = createProjectBlueprint();
// standard names
projectClassName_ = StringUtils.capitalize(project_.name());
var base_name = baseName();
projectBuildName_ = projectBuildClassName(base_name);
projectMainName_ = projectMainClassName(base_name);
@ -135,7 +133,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
* @since 1.6
*/
protected String projectMainClassName(String projectClassName) {
return projectClassName + "Main";
return projectClassName;
}
/**
@ -145,7 +143,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
* @since 1.6
*/
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("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);
@ -214,7 +212,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
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_);
@ -551,10 +549,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
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;

View file

@ -7,6 +7,7 @@ package rife.bld.operations;
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;
@ -63,7 +64,7 @@ public class CreateRife2Operation extends AbstractCreateOperation<CreateRife2Ope
// 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);