mirror of
https://github.com/rife2/bld
synced 2026-08-05 15:17:49 +02:00
Compare commits
No commits in common. "bd10018aa87467aac05aeb12f4b7cf6c629f8aa4" and "10a8e6133b4f8df20dcbc74db33e4f6d762f5f43" have entirely different histories.
bd10018aa8
...
10a8e6133b
3
.github/workflows/bld.yml
vendored
3
.github/workflows/bld.yml
vendored
|
|
@ -109,10 +109,11 @@ jobs:
|
||||||
|
|
||||||
- name: Cache bld dependencies
|
- name: Cache bld dependencies
|
||||||
id: cache-bld
|
id: cache-bld
|
||||||
uses: actions/cache@v6
|
uses: actions/cache@v5
|
||||||
with:
|
with:
|
||||||
path: lib
|
path: lib
|
||||||
key: ${{ runner.os }}-bld-java${{ matrix.java-version}}-lib
|
key: ${{ runner.os }}-bld-java${{ matrix.java-version}}-lib
|
||||||
|
restore-keys: ${{ runner.os }}-bld-java${{ matrix.java-version}}-lib
|
||||||
|
|
||||||
- name: Compile source
|
- name: Compile source
|
||||||
run: ./bld clean compile
|
run: ./bld clean compile
|
||||||
|
|
|
||||||
3
.github/workflows/pages.yml
vendored
3
.github/workflows/pages.yml
vendored
|
|
@ -45,10 +45,11 @@ jobs:
|
||||||
|
|
||||||
- name: Cache bld dependencies
|
- name: Cache bld dependencies
|
||||||
id: cache-bld
|
id: cache-bld
|
||||||
uses: actions/cache@v6
|
uses: actions/cache@v5
|
||||||
with:
|
with:
|
||||||
path: lib
|
path: lib
|
||||||
key: ${{ runner.os }}-bld-pages-lib
|
key: ${{ runner.os }}-bld-pages-lib
|
||||||
|
restore-keys: ${{ runner.os }}-bld-pages-lib
|
||||||
|
|
||||||
- name: Build Javadocs
|
- name: Build Javadocs
|
||||||
run: ./bld clean compile javadoc
|
run: ./bld clean compile javadoc
|
||||||
|
|
|
||||||
2
.github/workflows/publish.yml
vendored
2
.github/workflows/publish.yml
vendored
|
|
@ -11,8 +11,6 @@ jobs:
|
||||||
- name: Checkout source repository
|
- name: Checkout source repository
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v7
|
||||||
with:
|
with:
|
||||||
clean: true
|
|
||||||
submodules: 'true'
|
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Check version is SNAPSHOT
|
- name: Check version is SNAPSHOT
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,10 @@ public class BuildExecutor {
|
||||||
private static final String ARG_HELP3 = "-?";
|
private static final String ARG_HELP3 = "-?";
|
||||||
private static final String ARG_STACKTRACE1 = "--stacktrace";
|
private static final String ARG_STACKTRACE1 = "--stacktrace";
|
||||||
private static final String ARG_STACKTRACE2 = "-s";
|
private static final String ARG_STACKTRACE2 = "-s";
|
||||||
private static final String ARG_VERBOSE1 = "--verbose";
|
|
||||||
private static final String ARG_VERBOSE2 = "-v";
|
|
||||||
|
|
||||||
private final HierarchicalProperties properties_;
|
private final HierarchicalProperties properties_;
|
||||||
private List<String> arguments_ = Collections.emptyList();
|
private List<String> arguments_ = Collections.emptyList();
|
||||||
private boolean offline_ = false;
|
private boolean offline_ = false;
|
||||||
private boolean verbose_ = false;
|
|
||||||
private Map<String, CommandDefinition> buildCommands_ = null;
|
private Map<String, CommandDefinition> buildCommands_ = null;
|
||||||
private Map<String, String> buildAliases_ = null;
|
private Map<String, String> buildAliases_ = null;
|
||||||
private final AtomicReference<String> currentCommandName_ = new AtomicReference<>();
|
private final AtomicReference<String> currentCommandName_ = new AtomicReference<>();
|
||||||
|
|
@ -138,18 +135,6 @@ public class BuildExecutor {
|
||||||
return offline_;
|
return offline_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether the bld execution should output detailed information
|
|
||||||
* about the operations it performs.
|
|
||||||
*
|
|
||||||
* @return {@code true} if the execution is verbose;
|
|
||||||
* or {@code false} otherwise
|
|
||||||
* @since 2.3.1
|
|
||||||
*/
|
|
||||||
public boolean verbose() {
|
|
||||||
return verbose_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the properties uses for bld execution.
|
* Returns the properties uses for bld execution.
|
||||||
*
|
*
|
||||||
|
|
@ -242,7 +227,6 @@ public class BuildExecutor {
|
||||||
var show_help = false;
|
var show_help = false;
|
||||||
show_help |= arguments_.removeAll(List.of(ARG_HELP1, ARG_HELP2, ARG_HELP3));
|
show_help |= arguments_.removeAll(List.of(ARG_HELP1, ARG_HELP2, ARG_HELP3));
|
||||||
showStacktrace = arguments_.removeAll(List.of(ARG_STACKTRACE1, ARG_STACKTRACE2));
|
showStacktrace = arguments_.removeAll(List.of(ARG_STACKTRACE1, ARG_STACKTRACE2));
|
||||||
verbose_ = arguments_.removeAll(List.of(ARG_VERBOSE1, ARG_VERBOSE2));
|
|
||||||
|
|
||||||
if (show_help) {
|
if (show_help) {
|
||||||
new HelpOperation(this, Collections.emptyList()).execute();
|
new HelpOperation(this, Collections.emptyList()).execute();
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ public class Cli extends BuildExecutor {
|
||||||
@BuildCommand(help = CreateHelp.class)
|
@BuildCommand(help = CreateHelp.class)
|
||||||
public void create()
|
public void create()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
createOperation_.fromArguments(arguments()).verbose(verbose()).execute();
|
createOperation_.fromArguments(arguments()).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -44,7 +44,7 @@ public class Cli extends BuildExecutor {
|
||||||
@BuildCommand(value = "create-app", alias = "create-blank", help = CreateAppHelp.class)
|
@BuildCommand(value = "create-app", alias = "create-blank", help = CreateAppHelp.class)
|
||||||
public void createApp()
|
public void createApp()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
createAppOperation_.executeOnce(() -> createAppOperation_.verbose(verbose()).fromArguments(arguments()));
|
createAppOperation_.executeOnce(() -> createAppOperation_.fromArguments(arguments()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -56,7 +56,7 @@ public class Cli extends BuildExecutor {
|
||||||
@BuildCommand(value = "create-base", help = CreateBaseHelp.class)
|
@BuildCommand(value = "create-base", help = CreateBaseHelp.class)
|
||||||
public void createBase()
|
public void createBase()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
createBaseOperation_.executeOnce(() -> createBaseOperation_.verbose(verbose()).fromArguments(arguments()));
|
createBaseOperation_.executeOnce(() -> createBaseOperation_.fromArguments(arguments()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -68,7 +68,7 @@ public class Cli extends BuildExecutor {
|
||||||
@BuildCommand(value = "create-lib", help = CreateLibHelp.class)
|
@BuildCommand(value = "create-lib", help = CreateLibHelp.class)
|
||||||
public void createLib()
|
public void createLib()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
createLibOperation_.executeOnce(() -> createLibOperation_.verbose(verbose()).fromArguments(arguments()));
|
createLibOperation_.executeOnce(() -> createLibOperation_.fromArguments(arguments()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -80,7 +80,7 @@ public class Cli extends BuildExecutor {
|
||||||
@BuildCommand(value = "create-rife2", help = CreateRife2Help.class)
|
@BuildCommand(value = "create-rife2", help = CreateRife2Help.class)
|
||||||
public void createRife2()
|
public void createRife2()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
createRife2Operation_.executeOnce(() -> createRife2Operation_.verbose(verbose()).fromArguments(arguments()));
|
createRife2Operation_.executeOnce(() -> createRife2Operation_.fromArguments(arguments()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,6 @@ public class Project extends BaseProject {
|
||||||
public void jarSources()
|
public void jarSources()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
jarSourcesOperation().executeOnce(() -> jarSourcesOperation()
|
jarSourcesOperation().executeOnce(() -> jarSourcesOperation()
|
||||||
.verbose(verbose())
|
|
||||||
.manifestAttributes(Map.of(Attributes.Name.MANIFEST_VERSION, "1.0"))
|
.manifestAttributes(Map.of(Attributes.Name.MANIFEST_VERSION, "1.0"))
|
||||||
.sourceDirectories(List.of(srcMainJavaDirectory()))
|
.sourceDirectories(List.of(srcMainJavaDirectory()))
|
||||||
.destinationDirectory(buildDistDirectory())
|
.destinationDirectory(buildDistDirectory())
|
||||||
|
|
@ -164,9 +163,7 @@ public class Project extends BaseProject {
|
||||||
throws Exception {
|
throws Exception {
|
||||||
compile();
|
compile();
|
||||||
javadoc();
|
javadoc();
|
||||||
jarJavadocOperation().executeOnce(() -> jarJavadocOperation()
|
jarJavadocOperation().executeOnce(() -> jarJavadocOperation().manifestAttributes(Map.of(Attributes.Name.MANIFEST_VERSION, "1.0"))
|
||||||
.verbose(verbose())
|
|
||||||
.manifestAttributes(Map.of(Attributes.Name.MANIFEST_VERSION, "1.0"))
|
|
||||||
.sourceDirectories(List.of(buildJavadocDirectory()))
|
.sourceDirectories(List.of(buildJavadocDirectory()))
|
||||||
.destinationDirectory(buildDistDirectory())
|
.destinationDirectory(buildDistDirectory())
|
||||||
.destinationFileName(javadocJarFileName()));
|
.destinationFileName(javadocJarFileName()));
|
||||||
|
|
|
||||||
|
|
@ -164,44 +164,14 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
|
||||||
protected void executeCreateProjectStructure() {
|
protected void executeCreateProjectStructure() {
|
||||||
project_.createProjectStructure();
|
project_.createProjectStructure();
|
||||||
|
|
||||||
executeCreateDirectory(bldPackageDirectory_);
|
bldPackageDirectory_.mkdirs();
|
||||||
executeCreateDirectory(mainPackageDirectory_);
|
mainPackageDirectory_.mkdirs();
|
||||||
executeCreateDirectory(testPackageDirectory_);
|
testPackageDirectory_.mkdirs();
|
||||||
|
|
||||||
executeCreateDirectory(ideaDirectory_);
|
ideaDirectory_.mkdirs();
|
||||||
executeCreateDirectory(ideaLibrariesDirectory_);
|
ideaLibrariesDirectory_.mkdirs();
|
||||||
executeCreateDirectory(ideaRunConfigurationsDirectory_);
|
ideaRunConfigurationsDirectory_.mkdirs();
|
||||||
executeCreateDirectory(vscodeDirectory_);
|
vscodeDirectory_.mkdirs();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Part of the {@link #execute} operation, creates a directory and all its
|
|
||||||
* parents, outputting the location when the operation is {@link #verbose()}.
|
|
||||||
*
|
|
||||||
* @param directory the directory to create
|
|
||||||
* @since 2.3.1
|
|
||||||
*/
|
|
||||||
protected void executeCreateDirectory(File directory) {
|
|
||||||
if (verbose()) {
|
|
||||||
System.out.println("Creating directory '" + directory.getAbsolutePath() + "'");
|
|
||||||
}
|
|
||||||
directory.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Part of the {@link #execute} operation, writes the content of a project
|
|
||||||
* file, outputting the location when the operation is {@link #verbose()}.
|
|
||||||
*
|
|
||||||
* @param content the content to write
|
|
||||||
* @param file the file to write the content into
|
|
||||||
* @since 2.3.1
|
|
||||||
*/
|
|
||||||
protected void executeWriteProjectFile(String content, File file)
|
|
||||||
throws FileUtilsErrorException {
|
|
||||||
if (verbose()) {
|
|
||||||
System.out.println("Creating file '" + file.getAbsolutePath() + "'");
|
|
||||||
}
|
|
||||||
FileUtils.writeString(content, file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -213,7 +183,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
|
||||||
protected void executePopulateProjectStructure()
|
protected void executePopulateProjectStructure()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
// project gitignore
|
// project gitignore
|
||||||
executeWriteProjectFile(
|
FileUtils.writeString(
|
||||||
TemplateFactory.TXT.get(templateBase_ + "project_gitignore").getContent(),
|
TemplateFactory.TXT.get(templateBase_ + "project_gitignore").getContent(),
|
||||||
new File(project_.workDirectory(), ".gitignore"));
|
new File(project_.workDirectory(), ".gitignore"));
|
||||||
|
|
||||||
|
|
@ -222,7 +192,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
|
||||||
site_template.setValue("package", project_.pkg());
|
site_template.setValue("package", project_.pkg());
|
||||||
site_template.setValue("projectMain", projectMainName_);
|
site_template.setValue("projectMain", projectMainName_);
|
||||||
var project_main_file = new File(mainPackageDirectory_, projectMainName_ + ".java");
|
var project_main_file = new File(mainPackageDirectory_, projectMainName_ + ".java");
|
||||||
executeWriteProjectFile(site_template.getContent(), project_main_file);
|
FileUtils.writeString(site_template.getContent(), project_main_file);
|
||||||
|
|
||||||
// project test
|
// project test
|
||||||
var test_template = TemplateFactory.TXT.get(templateBase_ + "project_test");
|
var test_template = TemplateFactory.TXT.get(templateBase_ + "project_test");
|
||||||
|
|
@ -233,7 +203,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
|
||||||
test_template.setValue("project", project_.name());
|
test_template.setValue("project", project_.name());
|
||||||
}
|
}
|
||||||
var project_test_file = new File(testPackageDirectory_, projectTestName_ + ".java");
|
var project_test_file = new File(testPackageDirectory_, projectTestName_ + ".java");
|
||||||
executeWriteProjectFile(test_template.getContent(), project_test_file);
|
FileUtils.writeString(test_template.getContent(), project_test_file);
|
||||||
|
|
||||||
// project build
|
// project build
|
||||||
var build_template = TemplateFactory.TXT.get(templateBase_ + "project_build");
|
var build_template = TemplateFactory.TXT.get(templateBase_ + "project_build");
|
||||||
|
|
@ -277,26 +247,23 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
|
||||||
build_template.appendBlock("scopes", "scope");
|
build_template.appendBlock("scopes", "scope");
|
||||||
}
|
}
|
||||||
var project_build_file = new File(bldPackageDirectory_, projectBuildName_ + ".java");
|
var project_build_file = new File(bldPackageDirectory_, projectBuildName_ + ".java");
|
||||||
executeWriteProjectFile(build_template.getContent(), project_build_file);
|
FileUtils.writeString(build_template.getContent(), project_build_file);
|
||||||
|
|
||||||
// build shell scripts
|
// build shell scripts
|
||||||
var build_sh_template = TemplateFactory.TXT.get("bld.bld");
|
var build_sh_template = TemplateFactory.TXT.get("bld.bld");
|
||||||
build_sh_template.setValue("projectBuild", projectBuildName_);
|
build_sh_template.setValue("projectBuild", projectBuildName_);
|
||||||
build_sh_template.setValue("package", project_.pkg());
|
build_sh_template.setValue("package", project_.pkg());
|
||||||
var build_sh_file = new File(project_.workDirectory(), "bld");
|
var build_sh_file = new File(project_.workDirectory(), "bld");
|
||||||
executeWriteProjectFile(build_sh_template.getContent(), build_sh_file);
|
FileUtils.writeString(build_sh_template.getContent(), build_sh_file);
|
||||||
build_sh_file.setExecutable(true);
|
build_sh_file.setExecutable(true);
|
||||||
|
|
||||||
var build_bat_template = TemplateFactory.TXT.get("bld.bld_bat");
|
var build_bat_template = TemplateFactory.TXT.get("bld.bld_bat");
|
||||||
build_bat_template.setValue("projectBuild", projectBuildName_);
|
build_bat_template.setValue("projectBuild", projectBuildName_);
|
||||||
build_bat_template.setValue("package", project_.pkg());
|
build_bat_template.setValue("package", project_.pkg());
|
||||||
var build_bat_file = new File(project_.workDirectory(), "bld.bat");
|
var build_bat_file = new File(project_.workDirectory(), "bld.bat");
|
||||||
executeWriteProjectFile(build_bat_template.getContent(), build_bat_file);
|
FileUtils.writeString(build_bat_template.getContent(), build_bat_file);
|
||||||
|
|
||||||
// create the wrapper files
|
// create the wrapper files
|
||||||
if (verbose()) {
|
|
||||||
System.out.println("Creating wrapper files in '" + project_.libBldDirectory().getAbsolutePath() + "'");
|
|
||||||
}
|
|
||||||
new Wrapper().createWrapperFiles(project_.libBldDirectory(), BldVersion.getVersion());
|
new Wrapper().createWrapperFiles(project_.libBldDirectory(), BldVersion.getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -308,31 +275,31 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
|
||||||
protected void executePopulateIdeaProject()
|
protected void executePopulateIdeaProject()
|
||||||
throws FileUtilsErrorException {
|
throws FileUtilsErrorException {
|
||||||
// IDEA project files
|
// IDEA project files
|
||||||
executeWriteProjectFile(
|
FileUtils.writeString(
|
||||||
TemplateFactory.XML.get(templateBase_ + "idea.app_iml").getContent(),
|
TemplateFactory.XML.get(templateBase_ + "idea.app_iml").getContent(),
|
||||||
new File(ideaDirectory_, "app.iml"));
|
new File(ideaDirectory_, "app.iml"));
|
||||||
executeWriteProjectFile(
|
FileUtils.writeString(
|
||||||
TemplateFactory.XML.get(templateBase_ + "idea.bld_iml").getContent(),
|
TemplateFactory.XML.get(templateBase_ + "idea.bld_iml").getContent(),
|
||||||
new File(ideaDirectory_, "bld.iml"));
|
new File(ideaDirectory_, "bld.iml"));
|
||||||
executeWriteProjectFile(
|
FileUtils.writeString(
|
||||||
TemplateFactory.XML.get(templateBase_ + "idea.misc").getContent(),
|
TemplateFactory.XML.get(templateBase_ + "idea.misc").getContent(),
|
||||||
new File(ideaDirectory_, "misc.xml"));
|
new File(ideaDirectory_, "misc.xml"));
|
||||||
executeWriteProjectFile(
|
FileUtils.writeString(
|
||||||
TemplateFactory.XML.get(templateBase_ + "idea.modules").getContent(),
|
TemplateFactory.XML.get(templateBase_ + "idea.modules").getContent(),
|
||||||
new File(ideaDirectory_, "modules.xml"));
|
new File(ideaDirectory_, "modules.xml"));
|
||||||
|
|
||||||
var bld_xml_template = TemplateFactory.XML.get(templateBase_ + "idea.libraries.bld");
|
var bld_xml_template = TemplateFactory.XML.get(templateBase_ + "idea.libraries.bld");
|
||||||
bld_xml_template.setValue("version", BldVersion.getVersion());
|
bld_xml_template.setValue("version", BldVersion.getVersion());
|
||||||
var bld_xml_file = new File(ideaLibrariesDirectory_, "bld.xml");
|
var bld_xml_file = new File(ideaLibrariesDirectory_, "bld.xml");
|
||||||
executeWriteProjectFile(bld_xml_template.getContent(), bld_xml_file);
|
FileUtils.writeString(bld_xml_template.getContent(), bld_xml_file);
|
||||||
|
|
||||||
executeWriteProjectFile(
|
FileUtils.writeString(
|
||||||
TemplateFactory.XML.get(templateBase_ + "idea.libraries.compile").getContent(),
|
TemplateFactory.XML.get(templateBase_ + "idea.libraries.compile").getContent(),
|
||||||
new File(ideaLibrariesDirectory_, "compile.xml"));
|
new File(ideaLibrariesDirectory_, "compile.xml"));
|
||||||
executeWriteProjectFile(
|
FileUtils.writeString(
|
||||||
TemplateFactory.XML.get(templateBase_ + "idea.libraries.runtime").getContent(),
|
TemplateFactory.XML.get(templateBase_ + "idea.libraries.runtime").getContent(),
|
||||||
new File(ideaLibrariesDirectory_, "runtime.xml"));
|
new File(ideaLibrariesDirectory_, "runtime.xml"));
|
||||||
executeWriteProjectFile(
|
FileUtils.writeString(
|
||||||
TemplateFactory.XML.get(templateBase_ + "idea.libraries.test").getContent(),
|
TemplateFactory.XML.get(templateBase_ + "idea.libraries.test").getContent(),
|
||||||
new File(ideaLibrariesDirectory_, "test.xml"));
|
new File(ideaLibrariesDirectory_, "test.xml"));
|
||||||
|
|
||||||
|
|
@ -342,7 +309,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
|
||||||
run_site_template.setValue("package", project_.pkg());
|
run_site_template.setValue("package", project_.pkg());
|
||||||
run_site_template.setValue("projectMain", projectMainName_);
|
run_site_template.setValue("projectMain", projectMainName_);
|
||||||
var run_site_file = new File(ideaRunConfigurationsDirectory_, "Run Main.xml");
|
var run_site_file = new File(ideaRunConfigurationsDirectory_, "Run Main.xml");
|
||||||
executeWriteProjectFile(run_site_template.getContent(), run_site_file);
|
FileUtils.writeString(run_site_template.getContent(), run_site_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IDEA run tests
|
// IDEA run tests
|
||||||
|
|
@ -352,7 +319,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
|
||||||
run_tests_template.setValue("projectTest", projectTestName_);
|
run_tests_template.setValue("projectTest", projectTestName_);
|
||||||
}
|
}
|
||||||
var run_tests_file = new File(ideaRunConfigurationsDirectory_, "Run Tests.xml");
|
var run_tests_file = new File(ideaRunConfigurationsDirectory_, "Run Tests.xml");
|
||||||
executeWriteProjectFile(run_tests_template.getContent(), run_tests_file);
|
FileUtils.writeString(run_tests_template.getContent(), run_tests_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -380,14 +347,14 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
|
||||||
launch_template.setValue("projectTest", projectTestName_);
|
launch_template.setValue("projectTest", projectTestName_);
|
||||||
}
|
}
|
||||||
var launch_file = new File(vscodeDirectory_, "launch.json");
|
var launch_file = new File(vscodeDirectory_, "launch.json");
|
||||||
executeWriteProjectFile(launch_template.getContent(), launch_file);
|
FileUtils.writeString(launch_template.getContent(), launch_file);
|
||||||
|
|
||||||
var settings_template = TemplateFactory.JSON.get(templateBase_ + "vscode.settings");
|
var settings_template = TemplateFactory.JSON.get(templateBase_ + "vscode.settings");
|
||||||
if (settings_template.hasValueId("version")) {
|
if (settings_template.hasValueId("version")) {
|
||||||
settings_template.setValue("version", BldVersion.getVersion());
|
settings_template.setValue("version", BldVersion.getVersion());
|
||||||
}
|
}
|
||||||
var settings_file = new File(vscodeDirectory_, "settings.json");
|
var settings_file = new File(vscodeDirectory_, "settings.json");
|
||||||
executeWriteProjectFile(settings_template.getContent(), settings_file);
|
FileUtils.writeString(settings_template.getContent(), settings_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ package rife.bld.operations;
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractOperation<T extends AbstractOperation<T>> {
|
public abstract class AbstractOperation<T extends AbstractOperation<T>> {
|
||||||
private boolean silent_ = false;
|
private boolean silent_ = false;
|
||||||
private boolean verbose_ = false;
|
|
||||||
private boolean executed_ = false;
|
private boolean executed_ = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -41,39 +40,6 @@ public abstract class AbstractOperation<T extends AbstractOperation<T>> {
|
||||||
return silent_;
|
return silent_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Changes whether the operation should output detailed information about
|
|
||||||
* what it's doing.
|
|
||||||
* <p>
|
|
||||||
* Defaults to not verbose.
|
|
||||||
* <p>
|
|
||||||
* Verbosity is independent from silence: the {@code silent} setting
|
|
||||||
* suppresses an operation's regular output, while the {@code verbose}
|
|
||||||
* setting adds detailed output about the individual steps an operation
|
|
||||||
* performs.
|
|
||||||
*
|
|
||||||
* @param verbose {@code true} if the operation should be verbose;
|
|
||||||
* {@code false} otherwise
|
|
||||||
* @return this operation instance
|
|
||||||
* @since 2.3.1
|
|
||||||
*/
|
|
||||||
public T verbose(boolean verbose) {
|
|
||||||
verbose_ = verbose;
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates whether the operation should output detailed information about
|
|
||||||
* what it's doing.
|
|
||||||
*
|
|
||||||
* @return {@code true} if the operation should be verbose;
|
|
||||||
* {@code false} otherwise
|
|
||||||
* @since 2.3.1
|
|
||||||
*/
|
|
||||||
public boolean verbose() {
|
|
||||||
return verbose_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that this operation instance is executed once and only once.
|
* Ensures that this operation instance is executed once and only once.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -84,13 +84,7 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
|
||||||
*/
|
*/
|
||||||
protected Process executeStartProcess()
|
protected Process executeStartProcess()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
var command = executeConstructProcessCommandList();
|
var builder = new ProcessBuilder(executeConstructProcessCommandList());
|
||||||
|
|
||||||
if (verbose()) {
|
|
||||||
System.out.println("Executing command: " + String.join(" ", command));
|
|
||||||
}
|
|
||||||
|
|
||||||
var builder = new ProcessBuilder(command);
|
|
||||||
builder.directory(workDirectory());
|
builder.directory(workDirectory());
|
||||||
|
|
||||||
if (!environment_.isEmpty()) {
|
if (!environment_.isEmpty()) {
|
||||||
|
|
|
||||||
|
|
@ -130,10 +130,6 @@ public abstract class AbstractToolProviderOperation<T extends AbstractToolProvid
|
||||||
var tool = ToolProvider.findFirst(toolName_).orElseThrow(() ->
|
var tool = ToolProvider.findFirst(toolName_).orElseThrow(() ->
|
||||||
new IllegalStateException("No " + toolName_ + " tool found."));
|
new IllegalStateException("No " + toolName_ + " tool found."));
|
||||||
|
|
||||||
if (verbose()) {
|
|
||||||
System.out.println("Executing command: " + tool.name() + ' ' + String.join(" ", toolArgs_));
|
|
||||||
}
|
|
||||||
|
|
||||||
var status = tool.run(System.out, System.err, toolArgs_.toArray(new String[0]));
|
var status = tool.run(System.out, System.err, toolArgs_.toArray(new String[0]));
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
System.out.println(tool.name() + ' ' + String.join(" ", toolArgs_));
|
System.out.println(tool.name() + ' ' + String.join(" ", toolArgs_));
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,6 @@ public class CleanOperation extends AbstractOperation<CleanOperation> {
|
||||||
*/
|
*/
|
||||||
protected void executeCleanDirectory(File directory) {
|
protected void executeCleanDirectory(File directory) {
|
||||||
try {
|
try {
|
||||||
if (verbose() && directory.exists()) {
|
|
||||||
System.out.println("Deleting directory '" + directory.getAbsolutePath() + "'");
|
|
||||||
}
|
|
||||||
FileUtils.deleteDirectory(directory);
|
FileUtils.deleteDirectory(directory);
|
||||||
} catch (FileUtilsErrorException e) {
|
} catch (FileUtilsErrorException e) {
|
||||||
// no-op
|
// no-op
|
||||||
|
|
@ -59,8 +56,7 @@ public class CleanOperation extends AbstractOperation<CleanOperation> {
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public CleanOperation fromProject(BaseProject project) {
|
public CleanOperation fromProject(BaseProject project) {
|
||||||
return verbose(project.verbose())
|
return directories(project.buildDirectory()
|
||||||
.directories(project.buildDirectory()
|
|
||||||
.listFiles(f -> !f.equals(project.buildBldDirectory())));
|
.listFiles(f -> !f.equals(project.buildBldDirectory())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,14 +85,7 @@ public class CompileOperation extends AbstractOperation<CompileOperation> {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
var sources = new ArrayList<>(mainSourceFiles());
|
var sources = new ArrayList<>(mainSourceFiles());
|
||||||
for (var directory : mainSourceDirectories()) {
|
for (var directory : mainSourceDirectories()) {
|
||||||
var found = FileUtils.getJavaFileList(directory);
|
sources.addAll(FileUtils.getJavaFileList(directory));
|
||||||
if (verbose()) {
|
|
||||||
var dir_abs = directory.getAbsoluteFile();
|
|
||||||
for (var source : found) {
|
|
||||||
System.out.println("Found main source file '" + dir_abs.toPath().relativize(source.toPath()) + "' in '" + dir_abs + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sources.addAll(found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sources.isEmpty()) {
|
if (sources.isEmpty()) {
|
||||||
|
|
@ -117,14 +110,7 @@ public class CompileOperation extends AbstractOperation<CompileOperation> {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
var sources = new ArrayList<>(testSourceFiles());
|
var sources = new ArrayList<>(testSourceFiles());
|
||||||
for (var directory : testSourceDirectories()) {
|
for (var directory : testSourceDirectories()) {
|
||||||
var found = FileUtils.getJavaFileList(directory);
|
sources.addAll(FileUtils.getJavaFileList(directory));
|
||||||
if (verbose()) {
|
|
||||||
var dir_abs = directory.getAbsoluteFile();
|
|
||||||
for (var source : found) {
|
|
||||||
System.out.println("Found test source file '" + dir_abs.toPath().relativize(source.toPath()) + "' in '" + dir_abs + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sources.addAll(found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sources.isEmpty()) {
|
if (sources.isEmpty()) {
|
||||||
|
|
@ -155,12 +141,6 @@ public class CompileOperation extends AbstractOperation<CompileOperation> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose()) {
|
|
||||||
for (var source : sources) {
|
|
||||||
System.out.println("Compiling source '" + source.getAbsolutePath() + "' into '" + destination.getAbsolutePath() + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var compiler = ToolProvider.getSystemJavaCompiler();
|
var compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
try (var file_manager = compiler.getStandardFileManager(null, null, null)) {
|
try (var file_manager = compiler.getStandardFileManager(null, null, null)) {
|
||||||
var compilation_units = file_manager.getJavaFileObjectsFromFiles(sources);
|
var compilation_units = file_manager.getJavaFileObjectsFromFiles(sources);
|
||||||
|
|
@ -241,8 +221,7 @@ public class CompileOperation extends AbstractOperation<CompileOperation> {
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public CompileOperation fromProject(BaseProject project) {
|
public CompileOperation fromProject(BaseProject project) {
|
||||||
var operation = verbose(project.verbose())
|
var operation = buildMainDirectory(project.buildMainDirectory())
|
||||||
.buildMainDirectory(project.buildMainDirectory())
|
|
||||||
.buildTestDirectory(project.buildTestDirectory())
|
.buildTestDirectory(project.buildTestDirectory())
|
||||||
.compileMainClasspath(project.compileMainClasspath())
|
.compileMainClasspath(project.compileMainClasspath())
|
||||||
.compileTestClasspath(project.compileTestClasspath())
|
.compileTestClasspath(project.compileTestClasspath())
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,6 @@ public class HelpOperation {
|
||||||
-?, -h, --help Shows the help
|
-?, -h, --help Shows the help
|
||||||
-D<name>=<value> Sets a JVM system property
|
-D<name>=<value> Sets a JVM system property
|
||||||
-s, --stacktrace Prints out the stacktrace for exceptions
|
-s, --stacktrace Prints out the stacktrace for exceptions
|
||||||
-v, --verbose Prints out detailed information about the operations
|
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -108,10 +108,6 @@ public class JarOperation extends AbstractOperation<JarOperation> {
|
||||||
*/
|
*/
|
||||||
protected void executeAddFileToJar(JarOutputStream jar, NamedFile file)
|
protected void executeAddFileToJar(JarOutputStream jar, NamedFile file)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (verbose()) {
|
|
||||||
System.out.println("Adding '" + file.file().getAbsolutePath() + "' to jar as '" + file.name().replace('\\', '/') + "'");
|
|
||||||
}
|
|
||||||
|
|
||||||
var entry = new JarEntry(file.name().replace('\\', '/'));
|
var entry = new JarEntry(file.name().replace('\\', '/'));
|
||||||
entry.setTime(file.file().lastModified());
|
entry.setTime(file.file().lastModified());
|
||||||
jar.putNextEntry(entry);
|
jar.putNextEntry(entry);
|
||||||
|
|
@ -132,8 +128,7 @@ public class JarOperation extends AbstractOperation<JarOperation> {
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public JarOperation fromProject(BaseProject project) {
|
public JarOperation fromProject(BaseProject project) {
|
||||||
return verbose(project.verbose())
|
return manifestAttributes(Map.of(Attributes.Name.MANIFEST_VERSION, "1.0"))
|
||||||
.manifestAttributes(Map.of(Attributes.Name.MANIFEST_VERSION, "1.0"))
|
|
||||||
.sourceDirectories(project.buildMainDirectory(), project.srcMainResourcesDirectory())
|
.sourceDirectories(project.buildMainDirectory(), project.srcMainResourcesDirectory())
|
||||||
.destinationDirectory(project.buildDistDirectory())
|
.destinationDirectory(project.buildDistDirectory())
|
||||||
.destinationFileName(project.jarFileName())
|
.destinationFileName(project.jarFileName())
|
||||||
|
|
|
||||||
|
|
@ -102,12 +102,6 @@ public class JavadocOperation extends AbstractOperation<JavadocOperation> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose()) {
|
|
||||||
for (var source : filtered_sources) {
|
|
||||||
System.out.println("Documenting source '" + source.getAbsolutePath() + "' into '" + destination.getAbsolutePath() + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var documentation = ToolProvider.getSystemDocumentationTool();
|
var documentation = ToolProvider.getSystemDocumentationTool();
|
||||||
try (var file_manager = documentation.getStandardFileManager(null, null, null)) {
|
try (var file_manager = documentation.getStandardFileManager(null, null, null)) {
|
||||||
var compilation_units = file_manager.getJavaFileObjectsFromFiles(filtered_sources);
|
var compilation_units = file_manager.getJavaFileObjectsFromFiles(filtered_sources);
|
||||||
|
|
@ -158,8 +152,7 @@ public class JavadocOperation extends AbstractOperation<JavadocOperation> {
|
||||||
* @since 1.5.10
|
* @since 1.5.10
|
||||||
*/
|
*/
|
||||||
public JavadocOperation fromProject(BaseProject project) {
|
public JavadocOperation fromProject(BaseProject project) {
|
||||||
var operation = verbose(project.verbose())
|
var operation = buildDirectory(project.buildJavadocDirectory())
|
||||||
.buildDirectory(project.buildJavadocDirectory())
|
|
||||||
.classpath(project.compileMainClasspath())
|
.classpath(project.compileMainClasspath())
|
||||||
.classpath(project.buildMainDirectory().getAbsolutePath())
|
.classpath(project.buildMainDirectory().getAbsolutePath())
|
||||||
.modulePath(project.compileMainModulePath())
|
.modulePath(project.compileMainModulePath())
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,7 @@ public class RunOperation extends AbstractProcessOperation<RunOperation> {
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public RunOperation fromProject(BaseProject project) {
|
public RunOperation fromProject(BaseProject project) {
|
||||||
var operation = verbose(project.verbose())
|
var operation = workDirectory(project.workDirectory())
|
||||||
.workDirectory(project.workDirectory())
|
|
||||||
.javaTool(project.javaTool())
|
.javaTool(project.javaTool())
|
||||||
.classpath(project.runClasspath())
|
.classpath(project.runClasspath())
|
||||||
.modulePath(project.runModulePath())
|
.modulePath(project.runModulePath())
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,7 @@ public class TestOperation<T extends TestOperation<T, O>, O extends List<String>
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public T fromProject(BaseProject project) {
|
public T fromProject(BaseProject project) {
|
||||||
var operation = verbose(project.verbose())
|
var operation = workDirectory(project.workDirectory())
|
||||||
.workDirectory(project.workDirectory())
|
|
||||||
.javaTool(project.javaTool())
|
.javaTool(project.javaTool())
|
||||||
.classpath(project.testClasspath())
|
.classpath(project.testClasspath())
|
||||||
.modulePath(project.testModulePath());
|
.modulePath(project.testModulePath());
|
||||||
|
|
|
||||||
|
|
@ -60,9 +60,6 @@ public class UberJarOperation extends AbstractOperation<UberJarOperation> {
|
||||||
protected void executeCollectSourceJarContents(File stagingDirectory)
|
protected void executeCollectSourceJarContents(File stagingDirectory)
|
||||||
throws FileUtilsErrorException {
|
throws FileUtilsErrorException {
|
||||||
for (var jar : jarSourceFiles()) {
|
for (var jar : jarSourceFiles()) {
|
||||||
if (verbose()) {
|
|
||||||
System.out.println("Unpacking jar '" + jar.getAbsolutePath() + "'");
|
|
||||||
}
|
|
||||||
FileUtils.unzipFile(jar, stagingDirectory);
|
FileUtils.unzipFile(jar, stagingDirectory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -76,9 +73,6 @@ public class UberJarOperation extends AbstractOperation<UberJarOperation> {
|
||||||
throws FileUtilsErrorException {
|
throws FileUtilsErrorException {
|
||||||
for (var named_file : sourceDirectories()) {
|
for (var named_file : sourceDirectories()) {
|
||||||
if (named_file.file().exists()) {
|
if (named_file.file().exists()) {
|
||||||
if (verbose()) {
|
|
||||||
System.out.println("Collecting resources from '" + named_file.file().getAbsolutePath() + "'");
|
|
||||||
}
|
|
||||||
var destination_file = new File(stagingDirectory, named_file.name());
|
var destination_file = new File(stagingDirectory, named_file.name());
|
||||||
destination_file.mkdirs();
|
destination_file.mkdirs();
|
||||||
FileUtils.copyDirectory(named_file.file(), destination_file);
|
FileUtils.copyDirectory(named_file.file(), destination_file);
|
||||||
|
|
@ -97,7 +91,6 @@ public class UberJarOperation extends AbstractOperation<UberJarOperation> {
|
||||||
existing_manifest.delete();
|
existing_manifest.delete();
|
||||||
|
|
||||||
new JarOperation()
|
new JarOperation()
|
||||||
.verbose(verbose())
|
|
||||||
.manifestAttributes(Map.of(
|
.manifestAttributes(Map.of(
|
||||||
Attributes.Name.MANIFEST_VERSION, "1.0",
|
Attributes.Name.MANIFEST_VERSION, "1.0",
|
||||||
Attributes.Name.MAIN_CLASS, mainClass()))
|
Attributes.Name.MAIN_CLASS, mainClass()))
|
||||||
|
|
@ -122,8 +115,7 @@ public class UberJarOperation extends AbstractOperation<UberJarOperation> {
|
||||||
jars.addAll(project.runtimeClasspathJars());
|
jars.addAll(project.runtimeClasspathJars());
|
||||||
jars.add(new File(project.buildDistDirectory(), project.jarFileName()));
|
jars.add(new File(project.buildDistDirectory(), project.jarFileName()));
|
||||||
|
|
||||||
return verbose(project.verbose())
|
return jarSourceFiles(jars)
|
||||||
.jarSourceFiles(jars)
|
|
||||||
.destinationDirectory(project.buildDistDirectory())
|
.destinationDirectory(project.buildDistDirectory())
|
||||||
.destinationFileName(project.uberJarFileName())
|
.destinationFileName(project.uberJarFileName())
|
||||||
.mainClass(project.uberJarMainClass());
|
.mainClass(project.uberJarMainClass());
|
||||||
|
|
|
||||||
|
|
@ -23,25 +23,9 @@ public class UpgradeOperation extends AbstractOperation<UpgradeOperation> {
|
||||||
*/
|
*/
|
||||||
public void execute()
|
public void execute()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
var bld_dir = Path.of("lib", "bld").toFile();
|
new Wrapper().createWrapperFiles(Path.of("lib", "bld").toFile(), BldVersion.getVersion());
|
||||||
var idea_dir = new File(".idea");
|
new Wrapper().upgradeIdeaBldLibrary(new File(".idea"), BldVersion.getVersion());
|
||||||
var vscode_dir = new File(".vscode");
|
new Wrapper().upgradeVscodeSettings(new File(".vscode"), BldVersion.getVersion());
|
||||||
|
|
||||||
if (verbose()) {
|
|
||||||
System.out.println("Creating wrapper files in '" + bld_dir.getAbsolutePath() + "'");
|
|
||||||
}
|
|
||||||
new Wrapper().createWrapperFiles(bld_dir, BldVersion.getVersion());
|
|
||||||
|
|
||||||
if (verbose()) {
|
|
||||||
System.out.println("Upgrading IDEA bld library in '" + idea_dir.getAbsolutePath() + "'");
|
|
||||||
}
|
|
||||||
new Wrapper().upgradeIdeaBldLibrary(idea_dir, BldVersion.getVersion());
|
|
||||||
|
|
||||||
if (verbose()) {
|
|
||||||
System.out.println("Upgrading VSCode settings in '" + vscode_dir.getAbsolutePath() + "'");
|
|
||||||
}
|
|
||||||
new Wrapper().upgradeVscodeSettings(vscode_dir, BldVersion.getVersion());
|
|
||||||
|
|
||||||
if (!silent()) {
|
if (!silent()) {
|
||||||
System.out.println("The wrapper was successfully upgraded to " + BldVersion.getVersion() + ".");
|
System.out.println("The wrapper was successfully upgraded to " + BldVersion.getVersion() + ".");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,9 +77,6 @@ public class WarOperation extends AbstractOperation<WarOperation> {
|
||||||
protected void executeCopyWebappDirectory(File stagingDirectory)
|
protected void executeCopyWebappDirectory(File stagingDirectory)
|
||||||
throws FileUtilsErrorException {
|
throws FileUtilsErrorException {
|
||||||
if (webappDirectory() != null) {
|
if (webappDirectory() != null) {
|
||||||
if (verbose()) {
|
|
||||||
System.out.println("Copying webapp directory '" + webappDirectory().getAbsolutePath() + "'");
|
|
||||||
}
|
|
||||||
FileUtils.copyDirectory(webappDirectory(), stagingDirectory);
|
FileUtils.copyDirectory(webappDirectory(), stagingDirectory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -95,9 +92,6 @@ public class WarOperation extends AbstractOperation<WarOperation> {
|
||||||
if (!libSourceDirectories().isEmpty()) {
|
if (!libSourceDirectories().isEmpty()) {
|
||||||
web_inf_lib_dir.mkdirs();
|
web_inf_lib_dir.mkdirs();
|
||||||
for (var dir : libSourceDirectories()) {
|
for (var dir : libSourceDirectories()) {
|
||||||
if (verbose()) {
|
|
||||||
System.out.println("Copying lib directory '" + dir.getAbsolutePath() + "' into 'WEB-INF/lib'");
|
|
||||||
}
|
|
||||||
FileUtils.copyDirectory(dir, web_inf_lib_dir);
|
FileUtils.copyDirectory(dir, web_inf_lib_dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -105,9 +99,6 @@ public class WarOperation extends AbstractOperation<WarOperation> {
|
||||||
if (!jarSourceFiles().isEmpty()) {
|
if (!jarSourceFiles().isEmpty()) {
|
||||||
web_inf_lib_dir.mkdirs();
|
web_inf_lib_dir.mkdirs();
|
||||||
for (var file : jarSourceFiles()) {
|
for (var file : jarSourceFiles()) {
|
||||||
if (verbose()) {
|
|
||||||
System.out.println("Copying jar '" + file.file().getAbsolutePath() + "' into 'WEB-INF/lib' as '" + file.name() + "'");
|
|
||||||
}
|
|
||||||
FileUtils.copy(file.file(), new File(web_inf_lib_dir, file.name()));
|
FileUtils.copy(file.file(), new File(web_inf_lib_dir, file.name()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -124,9 +115,6 @@ public class WarOperation extends AbstractOperation<WarOperation> {
|
||||||
if (!classesSourceDirectories().isEmpty()) {
|
if (!classesSourceDirectories().isEmpty()) {
|
||||||
web_inf_classes_dir.mkdirs();
|
web_inf_classes_dir.mkdirs();
|
||||||
for (var dir : classesSourceDirectories()) {
|
for (var dir : classesSourceDirectories()) {
|
||||||
if (verbose()) {
|
|
||||||
System.out.println("Copying classes directory '" + dir.getAbsolutePath() + "' into 'WEB-INF/classes'");
|
|
||||||
}
|
|
||||||
FileUtils.copyDirectory(dir, web_inf_classes_dir);
|
FileUtils.copyDirectory(dir, web_inf_classes_dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -140,9 +128,6 @@ public class WarOperation extends AbstractOperation<WarOperation> {
|
||||||
protected void executeCopyWebXmlFile(File stagingWebInfDirectory)
|
protected void executeCopyWebXmlFile(File stagingWebInfDirectory)
|
||||||
throws FileUtilsErrorException {
|
throws FileUtilsErrorException {
|
||||||
if (webXmlFile() != null) {
|
if (webXmlFile() != null) {
|
||||||
if (verbose()) {
|
|
||||||
System.out.println("Copying web.xml file '" + webXmlFile().getAbsolutePath() + "' into 'WEB-INF'");
|
|
||||||
}
|
|
||||||
FileUtils.copy(webXmlFile(), new File(stagingWebInfDirectory, "web.xml"));
|
FileUtils.copy(webXmlFile(), new File(stagingWebInfDirectory, "web.xml"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -155,7 +140,6 @@ public class WarOperation extends AbstractOperation<WarOperation> {
|
||||||
protected void executeCreateWarArchive(File stagingDirectory)
|
protected void executeCreateWarArchive(File stagingDirectory)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
new JarOperation()
|
new JarOperation()
|
||||||
.verbose(verbose())
|
|
||||||
.sourceDirectories(stagingDirectory)
|
.sourceDirectories(stagingDirectory)
|
||||||
.destinationDirectory(destinationDirectory())
|
.destinationDirectory(destinationDirectory())
|
||||||
.destinationFileName(destinationFileName())
|
.destinationFileName(destinationFileName())
|
||||||
|
|
@ -181,8 +165,7 @@ public class WarOperation extends AbstractOperation<WarOperation> {
|
||||||
jar_source_files.add(new NamedFile(jar_file.getName(), jar_file));
|
jar_source_files.add(new NamedFile(jar_file.getName(), jar_file));
|
||||||
}
|
}
|
||||||
|
|
||||||
return verbose(project.verbose())
|
return jarSourceFiles(jar_source_files)
|
||||||
.jarSourceFiles(jar_source_files)
|
|
||||||
.webappDirectory(project.srcMainWebappDirectory())
|
.webappDirectory(project.srcMainWebappDirectory())
|
||||||
.destinationDirectory(project.buildDistDirectory())
|
.destinationDirectory(project.buildDistDirectory())
|
||||||
.destinationFileName(project.warFileName());
|
.destinationFileName(project.warFileName());
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,7 @@ import org.junit.jupiter.api.Test;
|
||||||
import rife.bld.WebProject;
|
import rife.bld.WebProject;
|
||||||
import rife.tools.FileUtils;
|
import rife.tools.FileUtils;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -92,37 +90,6 @@ public class TestCleanOperation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void testVerbose()
|
|
||||||
throws Exception {
|
|
||||||
var tmp = Files.createTempDirectory("test").toFile();
|
|
||||||
try {
|
|
||||||
var dir1 = new File(tmp, "dir1");
|
|
||||||
var dir2 = new File(tmp, "dir2");
|
|
||||||
dir1.mkdirs();
|
|
||||||
dir2.mkdirs();
|
|
||||||
|
|
||||||
var orig_out = System.out;
|
|
||||||
var captured = new ByteArrayOutputStream();
|
|
||||||
try {
|
|
||||||
System.setOut(new PrintStream(captured, true));
|
|
||||||
|
|
||||||
new CleanOperation()
|
|
||||||
.verbose(true)
|
|
||||||
.directories(List.of(dir1, dir2))
|
|
||||||
.execute();
|
|
||||||
} finally {
|
|
||||||
System.setOut(orig_out);
|
|
||||||
}
|
|
||||||
|
|
||||||
var output = captured.toString();
|
|
||||||
assertTrue(output.contains("Deleting directory '" + dir1.getAbsolutePath() + "'"), output);
|
|
||||||
assertTrue(output.contains("Deleting directory '" + dir2.getAbsolutePath() + "'"), output);
|
|
||||||
} finally {
|
|
||||||
FileUtils.deleteDirectory(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static class TestProject extends WebProject {
|
static class TestProject extends WebProject {
|
||||||
public TestProject(File tmp) {
|
public TestProject(File tmp) {
|
||||||
workDirectory = tmp;
|
workDirectory = tmp;
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,7 @@ import rife.tools.FileUtils;
|
||||||
|
|
||||||
import javax.tools.DiagnosticCollector;
|
import javax.tools.DiagnosticCollector;
|
||||||
import javax.tools.JavaFileObject;
|
import javax.tools.JavaFileObject;
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -210,83 +208,6 @@ public class TestCompileOperation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void testVerbose()
|
|
||||||
throws Exception {
|
|
||||||
var tmp = Files.createTempDirectory("test").toFile();
|
|
||||||
try {
|
|
||||||
var main_dir = new File(tmp, "main");
|
|
||||||
var package_dir = new File(main_dir, "tst");
|
|
||||||
package_dir.mkdirs();
|
|
||||||
var source_file = new File(package_dir, "Source.java");
|
|
||||||
FileUtils.writeString("""
|
|
||||||
package tst;
|
|
||||||
public class Source {
|
|
||||||
}
|
|
||||||
""", source_file);
|
|
||||||
|
|
||||||
var build_main = new File(tmp, "buildMain");
|
|
||||||
|
|
||||||
var orig_out = System.out;
|
|
||||||
var captured = new ByteArrayOutputStream();
|
|
||||||
try {
|
|
||||||
System.setOut(new PrintStream(captured, true));
|
|
||||||
|
|
||||||
new CompileOperation()
|
|
||||||
.verbose(true)
|
|
||||||
.buildMainDirectory(build_main)
|
|
||||||
.mainSourceDirectories(List.of(main_dir))
|
|
||||||
.execute();
|
|
||||||
} finally {
|
|
||||||
System.setOut(orig_out);
|
|
||||||
}
|
|
||||||
|
|
||||||
var output = captured.toString();
|
|
||||||
assertTrue(output.contains("Found main source file '" + new File("tst", "Source.java") + "' in '" + main_dir.getAbsoluteFile() + "'"), output);
|
|
||||||
assertTrue(output.contains("Compiling source '" + source_file.getAbsolutePath() + "' into '" + build_main.getAbsolutePath() + "'"), output);
|
|
||||||
} finally {
|
|
||||||
FileUtils.deleteDirectory(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testNotVerbose()
|
|
||||||
throws Exception {
|
|
||||||
var tmp = Files.createTempDirectory("test").toFile();
|
|
||||||
try {
|
|
||||||
var main_dir = new File(tmp, "main");
|
|
||||||
var package_dir = new File(main_dir, "tst");
|
|
||||||
package_dir.mkdirs();
|
|
||||||
var source_file = new File(package_dir, "Source.java");
|
|
||||||
FileUtils.writeString("""
|
|
||||||
package tst;
|
|
||||||
public class Source {
|
|
||||||
}
|
|
||||||
""", source_file);
|
|
||||||
|
|
||||||
var build_main = new File(tmp, "buildMain");
|
|
||||||
|
|
||||||
var orig_out = System.out;
|
|
||||||
var captured = new ByteArrayOutputStream();
|
|
||||||
try {
|
|
||||||
System.setOut(new PrintStream(captured, true));
|
|
||||||
|
|
||||||
new CompileOperation()
|
|
||||||
.buildMainDirectory(build_main)
|
|
||||||
.mainSourceDirectories(List.of(main_dir))
|
|
||||||
.execute();
|
|
||||||
} finally {
|
|
||||||
System.setOut(orig_out);
|
|
||||||
}
|
|
||||||
|
|
||||||
var output = captured.toString();
|
|
||||||
assertFalse(output.contains("Found main source file"), output);
|
|
||||||
assertFalse(output.contains("Compiling source"), output);
|
|
||||||
} finally {
|
|
||||||
FileUtils.deleteDirectory(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testFromProject()
|
void testFromProject()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,6 @@ package rife.bld.operations;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import rife.tools.FileUtils;
|
import rife.tools.FileUtils;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
@ -347,35 +344,4 @@ public class TestCreateBaseOperation {
|
||||||
FileUtils.deleteDirectory(tmp);
|
FileUtils.deleteDirectory(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void testVerbose()
|
|
||||||
throws Exception {
|
|
||||||
var tmp = Files.createTempDirectory("test").toFile();
|
|
||||||
try {
|
|
||||||
var orig_out = System.out;
|
|
||||||
var captured = new ByteArrayOutputStream();
|
|
||||||
try {
|
|
||||||
System.setOut(new PrintStream(captured, true));
|
|
||||||
|
|
||||||
new CreateBaseOperation()
|
|
||||||
.verbose(true)
|
|
||||||
.workDirectory(tmp)
|
|
||||||
.packageName("org.stuff")
|
|
||||||
.projectName("your-thing")
|
|
||||||
.baseName("YourThing")
|
|
||||||
.execute();
|
|
||||||
} finally {
|
|
||||||
System.setOut(orig_out);
|
|
||||||
}
|
|
||||||
|
|
||||||
var output = captured.toString();
|
|
||||||
var bld_file = new File(tmp, "your-thing/src/bld/java/org/stuff/YourThingBuild.java");
|
|
||||||
var main_package_dir = new File(tmp, "your-thing/src/main/java/org/stuff");
|
|
||||||
assertTrue(output.contains("Creating directory '" + main_package_dir.getAbsolutePath() + "'"), output);
|
|
||||||
assertTrue(output.contains("Creating file '" + bld_file.getAbsolutePath() + "'"), output);
|
|
||||||
} finally {
|
|
||||||
FileUtils.deleteDirectory(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,7 @@ import org.junit.jupiter.api.Test;
|
||||||
import rife.bld.NamedFile;
|
import rife.bld.NamedFile;
|
||||||
import rife.tools.FileUtils;
|
import rife.tools.FileUtils;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -179,41 +177,6 @@ public class TestJarOperation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void testVerbose()
|
|
||||||
throws Exception {
|
|
||||||
var tmp = Files.createTempDirectory("test").toFile();
|
|
||||||
try {
|
|
||||||
var source_dir = new File(tmp, "source");
|
|
||||||
var destination_dir = new File(tmp, "destination");
|
|
||||||
var destination_name = "archive.jar";
|
|
||||||
|
|
||||||
source_dir.mkdirs();
|
|
||||||
var source1 = new File(source_dir, "source1.text");
|
|
||||||
FileUtils.writeString("source1", source1);
|
|
||||||
|
|
||||||
var orig_out = System.out;
|
|
||||||
var captured = new ByteArrayOutputStream();
|
|
||||||
try {
|
|
||||||
System.setOut(new PrintStream(captured, true));
|
|
||||||
|
|
||||||
new JarOperation()
|
|
||||||
.verbose(true)
|
|
||||||
.sourceDirectories(List.of(source_dir))
|
|
||||||
.destinationDirectory(destination_dir)
|
|
||||||
.destinationFileName(destination_name)
|
|
||||||
.execute();
|
|
||||||
} finally {
|
|
||||||
System.setOut(orig_out);
|
|
||||||
}
|
|
||||||
|
|
||||||
var output = captured.toString();
|
|
||||||
assertTrue(output.contains("Adding '" + source1.getAbsolutePath() + "' to jar as 'source1.text'"), output);
|
|
||||||
} finally {
|
|
||||||
FileUtils.deleteDirectory(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testFromProject()
|
void testFromProject()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,7 @@ import org.junit.jupiter.api.Test;
|
||||||
import rife.bld.NamedFile;
|
import rife.bld.NamedFile;
|
||||||
import rife.tools.FileUtils;
|
import rife.tools.FileUtils;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
|
|
@ -108,51 +106,6 @@ public class TestWarOperation {
|
||||||
assertEquals(destination_fileName, operation3.destinationFileName());
|
assertEquals(destination_fileName, operation3.destinationFileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void testVerbose()
|
|
||||||
throws Exception {
|
|
||||||
var tmp = Files.createTempDirectory("test").toFile();
|
|
||||||
try {
|
|
||||||
var webapp_dir = new File(tmp, "webapp");
|
|
||||||
webapp_dir.mkdirs();
|
|
||||||
FileUtils.writeString("body { }", new File(webapp_dir, "style.css"));
|
|
||||||
|
|
||||||
var jar_file = new File(tmp, "lib.jar");
|
|
||||||
FileUtils.writeString("not really a jar", jar_file);
|
|
||||||
|
|
||||||
var web_xml_file = new File(tmp, "web.xml");
|
|
||||||
FileUtils.writeString("<web-app/>", web_xml_file);
|
|
||||||
|
|
||||||
var destination_dir = new File(tmp, "destination");
|
|
||||||
|
|
||||||
var orig_out = System.out;
|
|
||||||
var captured = new ByteArrayOutputStream();
|
|
||||||
try {
|
|
||||||
System.setOut(new PrintStream(captured, true));
|
|
||||||
|
|
||||||
new WarOperation()
|
|
||||||
.verbose(true)
|
|
||||||
.webappDirectory(webapp_dir)
|
|
||||||
.jarSourceFiles(new NamedFile("lib.jar", jar_file))
|
|
||||||
.webXmlFile(web_xml_file)
|
|
||||||
.destinationDirectory(destination_dir)
|
|
||||||
.destinationFileName("archive.war")
|
|
||||||
.execute();
|
|
||||||
} finally {
|
|
||||||
System.setOut(orig_out);
|
|
||||||
}
|
|
||||||
|
|
||||||
var output = captured.toString();
|
|
||||||
assertTrue(output.contains("Copying webapp directory '" + webapp_dir.getAbsolutePath() + "'"), output);
|
|
||||||
assertTrue(output.contains("Copying jar '" + jar_file.getAbsolutePath() + "' into 'WEB-INF/lib' as 'lib.jar'"), output);
|
|
||||||
assertTrue(output.contains("Copying web.xml file '" + web_xml_file.getAbsolutePath() + "' into 'WEB-INF'"), output);
|
|
||||||
// the internal jar operation also runs verbosely
|
|
||||||
assertTrue(output.contains("' to jar as '"), output);
|
|
||||||
} finally {
|
|
||||||
FileUtils.deleteDirectory(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testFromProject()
|
void testFromProject()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue