mirror of
https://github.com/rife2/bld
synced 2026-08-04 23:07:46 +02:00
Compare commits
2 commits
10a8e6133b
...
bd10018aa8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd10018aa8 | ||
|
|
7ee353ede0 |
3
.github/workflows/bld.yml
vendored
3
.github/workflows/bld.yml
vendored
|
|
@ -109,11 +109,10 @@ jobs:
|
||||||
|
|
||||||
- name: Cache bld dependencies
|
- name: Cache bld dependencies
|
||||||
id: cache-bld
|
id: cache-bld
|
||||||
uses: actions/cache@v5
|
uses: actions/cache@v6
|
||||||
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,11 +45,10 @@ jobs:
|
||||||
|
|
||||||
- name: Cache bld dependencies
|
- name: Cache bld dependencies
|
||||||
id: cache-bld
|
id: cache-bld
|
||||||
uses: actions/cache@v5
|
uses: actions/cache@v6
|
||||||
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,6 +11,8 @@ 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,10 +37,13 @@ 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<>();
|
||||||
|
|
@ -135,6 +138,18 @@ 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.
|
||||||
*
|
*
|
||||||
|
|
@ -227,6 +242,7 @@ 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()).execute();
|
createOperation_.fromArguments(arguments()).verbose(verbose()).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_.fromArguments(arguments()));
|
createAppOperation_.executeOnce(() -> createAppOperation_.verbose(verbose()).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_.fromArguments(arguments()));
|
createBaseOperation_.executeOnce(() -> createBaseOperation_.verbose(verbose()).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_.fromArguments(arguments()));
|
createLibOperation_.executeOnce(() -> createLibOperation_.verbose(verbose()).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_.fromArguments(arguments()));
|
createRife2Operation_.executeOnce(() -> createRife2Operation_.verbose(verbose()).fromArguments(arguments()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,7 @@ 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())
|
||||||
|
|
@ -163,7 +164,9 @@ public class Project extends BaseProject {
|
||||||
throws Exception {
|
throws Exception {
|
||||||
compile();
|
compile();
|
||||||
javadoc();
|
javadoc();
|
||||||
jarJavadocOperation().executeOnce(() -> jarJavadocOperation().manifestAttributes(Map.of(Attributes.Name.MANIFEST_VERSION, "1.0"))
|
jarJavadocOperation().executeOnce(() -> jarJavadocOperation()
|
||||||
|
.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,14 +164,44 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
|
||||||
protected void executeCreateProjectStructure() {
|
protected void executeCreateProjectStructure() {
|
||||||
project_.createProjectStructure();
|
project_.createProjectStructure();
|
||||||
|
|
||||||
bldPackageDirectory_.mkdirs();
|
executeCreateDirectory(bldPackageDirectory_);
|
||||||
mainPackageDirectory_.mkdirs();
|
executeCreateDirectory(mainPackageDirectory_);
|
||||||
testPackageDirectory_.mkdirs();
|
executeCreateDirectory(testPackageDirectory_);
|
||||||
|
|
||||||
ideaDirectory_.mkdirs();
|
executeCreateDirectory(ideaDirectory_);
|
||||||
ideaLibrariesDirectory_.mkdirs();
|
executeCreateDirectory(ideaLibrariesDirectory_);
|
||||||
ideaRunConfigurationsDirectory_.mkdirs();
|
executeCreateDirectory(ideaRunConfigurationsDirectory_);
|
||||||
vscodeDirectory_.mkdirs();
|
executeCreateDirectory(vscodeDirectory_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -183,7 +213,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
|
||||||
protected void executePopulateProjectStructure()
|
protected void executePopulateProjectStructure()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
// project gitignore
|
// project gitignore
|
||||||
FileUtils.writeString(
|
executeWriteProjectFile(
|
||||||
TemplateFactory.TXT.get(templateBase_ + "project_gitignore").getContent(),
|
TemplateFactory.TXT.get(templateBase_ + "project_gitignore").getContent(),
|
||||||
new File(project_.workDirectory(), ".gitignore"));
|
new File(project_.workDirectory(), ".gitignore"));
|
||||||
|
|
||||||
|
|
@ -192,7 +222,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");
|
||||||
FileUtils.writeString(site_template.getContent(), project_main_file);
|
executeWriteProjectFile(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");
|
||||||
|
|
@ -203,7 +233,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");
|
||||||
FileUtils.writeString(test_template.getContent(), project_test_file);
|
executeWriteProjectFile(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");
|
||||||
|
|
@ -247,23 +277,26 @@ 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");
|
||||||
FileUtils.writeString(build_template.getContent(), project_build_file);
|
executeWriteProjectFile(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");
|
||||||
FileUtils.writeString(build_sh_template.getContent(), build_sh_file);
|
executeWriteProjectFile(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");
|
||||||
FileUtils.writeString(build_bat_template.getContent(), build_bat_file);
|
executeWriteProjectFile(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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -275,31 +308,31 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
|
||||||
protected void executePopulateIdeaProject()
|
protected void executePopulateIdeaProject()
|
||||||
throws FileUtilsErrorException {
|
throws FileUtilsErrorException {
|
||||||
// IDEA project files
|
// IDEA project files
|
||||||
FileUtils.writeString(
|
executeWriteProjectFile(
|
||||||
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"));
|
||||||
FileUtils.writeString(
|
executeWriteProjectFile(
|
||||||
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"));
|
||||||
FileUtils.writeString(
|
executeWriteProjectFile(
|
||||||
TemplateFactory.XML.get(templateBase_ + "idea.misc").getContent(),
|
TemplateFactory.XML.get(templateBase_ + "idea.misc").getContent(),
|
||||||
new File(ideaDirectory_, "misc.xml"));
|
new File(ideaDirectory_, "misc.xml"));
|
||||||
FileUtils.writeString(
|
executeWriteProjectFile(
|
||||||
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");
|
||||||
FileUtils.writeString(bld_xml_template.getContent(), bld_xml_file);
|
executeWriteProjectFile(bld_xml_template.getContent(), bld_xml_file);
|
||||||
|
|
||||||
FileUtils.writeString(
|
executeWriteProjectFile(
|
||||||
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"));
|
||||||
FileUtils.writeString(
|
executeWriteProjectFile(
|
||||||
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"));
|
||||||
FileUtils.writeString(
|
executeWriteProjectFile(
|
||||||
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"));
|
||||||
|
|
||||||
|
|
@ -309,7 +342,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");
|
||||||
FileUtils.writeString(run_site_template.getContent(), run_site_file);
|
executeWriteProjectFile(run_site_template.getContent(), run_site_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IDEA run tests
|
// IDEA run tests
|
||||||
|
|
@ -319,7 +352,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");
|
||||||
FileUtils.writeString(run_tests_template.getContent(), run_tests_file);
|
executeWriteProjectFile(run_tests_template.getContent(), run_tests_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -347,14 +380,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");
|
||||||
FileUtils.writeString(launch_template.getContent(), launch_file);
|
executeWriteProjectFile(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");
|
||||||
FileUtils.writeString(settings_template.getContent(), settings_file);
|
executeWriteProjectFile(settings_template.getContent(), settings_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -40,6 +41,39 @@ 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,7 +84,13 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
|
||||||
*/
|
*/
|
||||||
protected Process executeStartProcess()
|
protected Process executeStartProcess()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
var builder = new ProcessBuilder(executeConstructProcessCommandList());
|
var command = 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,6 +130,10 @@ 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,6 +43,9 @@ 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
|
||||||
|
|
@ -56,8 +59,9 @@ public class CleanOperation extends AbstractOperation<CleanOperation> {
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public CleanOperation fromProject(BaseProject project) {
|
public CleanOperation fromProject(BaseProject project) {
|
||||||
return directories(project.buildDirectory()
|
return verbose(project.verbose())
|
||||||
.listFiles(f -> !f.equals(project.buildBldDirectory())));
|
.directories(project.buildDirectory()
|
||||||
|
.listFiles(f -> !f.equals(project.buildBldDirectory())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,14 @@ 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()) {
|
||||||
sources.addAll(FileUtils.getJavaFileList(directory));
|
var found = 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()) {
|
||||||
|
|
@ -110,7 +117,14 @@ 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()) {
|
||||||
sources.addAll(FileUtils.getJavaFileList(directory));
|
var found = 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()) {
|
||||||
|
|
@ -141,6 +155,12 @@ 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);
|
||||||
|
|
@ -221,7 +241,8 @@ public class CompileOperation extends AbstractOperation<CompileOperation> {
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public CompileOperation fromProject(BaseProject project) {
|
public CompileOperation fromProject(BaseProject project) {
|
||||||
var operation = buildMainDirectory(project.buildMainDirectory())
|
var operation = verbose(project.verbose())
|
||||||
|
.buildMainDirectory(project.buildMainDirectory())
|
||||||
.buildTestDirectory(project.buildTestDirectory())
|
.buildTestDirectory(project.buildTestDirectory())
|
||||||
.compileMainClasspath(project.compileMainClasspath())
|
.compileMainClasspath(project.compileMainClasspath())
|
||||||
.compileTestClasspath(project.compileTestClasspath())
|
.compileTestClasspath(project.compileTestClasspath())
|
||||||
|
|
|
||||||
|
|
@ -193,6 +193,7 @@ 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,6 +108,10 @@ 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);
|
||||||
|
|
@ -128,7 +132,8 @@ public class JarOperation extends AbstractOperation<JarOperation> {
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public JarOperation fromProject(BaseProject project) {
|
public JarOperation fromProject(BaseProject project) {
|
||||||
return manifestAttributes(Map.of(Attributes.Name.MANIFEST_VERSION, "1.0"))
|
return verbose(project.verbose())
|
||||||
|
.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,6 +102,12 @@ 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);
|
||||||
|
|
@ -152,7 +158,8 @@ 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 = buildDirectory(project.buildJavadocDirectory())
|
var operation = verbose(project.verbose())
|
||||||
|
.buildDirectory(project.buildJavadocDirectory())
|
||||||
.classpath(project.compileMainClasspath())
|
.classpath(project.compileMainClasspath())
|
||||||
.classpath(project.buildMainDirectory().getAbsolutePath())
|
.classpath(project.buildMainDirectory().getAbsolutePath())
|
||||||
.modulePath(project.compileMainModulePath())
|
.modulePath(project.compileMainModulePath())
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,8 @@ public class RunOperation extends AbstractProcessOperation<RunOperation> {
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public RunOperation fromProject(BaseProject project) {
|
public RunOperation fromProject(BaseProject project) {
|
||||||
var operation = workDirectory(project.workDirectory())
|
var operation = verbose(project.verbose())
|
||||||
|
.workDirectory(project.workDirectory())
|
||||||
.javaTool(project.javaTool())
|
.javaTool(project.javaTool())
|
||||||
.classpath(project.runClasspath())
|
.classpath(project.runClasspath())
|
||||||
.modulePath(project.runModulePath())
|
.modulePath(project.runModulePath())
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,8 @@ 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 = workDirectory(project.workDirectory())
|
var operation = verbose(project.verbose())
|
||||||
|
.workDirectory(project.workDirectory())
|
||||||
.javaTool(project.javaTool())
|
.javaTool(project.javaTool())
|
||||||
.classpath(project.testClasspath())
|
.classpath(project.testClasspath())
|
||||||
.modulePath(project.testModulePath());
|
.modulePath(project.testModulePath());
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,9 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -73,6 +76,9 @@ 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);
|
||||||
|
|
@ -91,6 +97,7 @@ 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()))
|
||||||
|
|
@ -115,7 +122,8 @@ 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 jarSourceFiles(jars)
|
return verbose(project.verbose())
|
||||||
|
.jarSourceFiles(jars)
|
||||||
.destinationDirectory(project.buildDistDirectory())
|
.destinationDirectory(project.buildDistDirectory())
|
||||||
.destinationFileName(project.uberJarFileName())
|
.destinationFileName(project.uberJarFileName())
|
||||||
.mainClass(project.uberJarMainClass());
|
.mainClass(project.uberJarMainClass());
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,25 @@ public class UpgradeOperation extends AbstractOperation<UpgradeOperation> {
|
||||||
*/
|
*/
|
||||||
public void execute()
|
public void execute()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
new Wrapper().createWrapperFiles(Path.of("lib", "bld").toFile(), BldVersion.getVersion());
|
var bld_dir = Path.of("lib", "bld").toFile();
|
||||||
new Wrapper().upgradeIdeaBldLibrary(new File(".idea"), BldVersion.getVersion());
|
var idea_dir = new File(".idea");
|
||||||
new Wrapper().upgradeVscodeSettings(new File(".vscode"), BldVersion.getVersion());
|
var vscode_dir = new File(".vscode");
|
||||||
|
|
||||||
|
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,6 +77,9 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -92,6 +95,9 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -99,6 +105,9 @@ 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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -115,6 +124,9 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -128,6 +140,9 @@ 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"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -140,6 +155,7 @@ 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())
|
||||||
|
|
@ -165,7 +181,8 @@ 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 jarSourceFiles(jar_source_files)
|
return verbose(project.verbose())
|
||||||
|
.jarSourceFiles(jar_source_files)
|
||||||
.webappDirectory(project.srcMainWebappDirectory())
|
.webappDirectory(project.srcMainWebappDirectory())
|
||||||
.destinationDirectory(project.buildDistDirectory())
|
.destinationDirectory(project.buildDistDirectory())
|
||||||
.destinationFileName(project.warFileName());
|
.destinationFileName(project.warFileName());
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,9 @@ 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;
|
||||||
|
|
||||||
|
|
@ -90,6 +92,37 @@ 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,7 +10,9 @@ 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;
|
||||||
|
|
||||||
|
|
@ -208,6 +210,83 @@ 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,6 +7,9 @@ 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;
|
||||||
|
|
||||||
|
|
@ -344,4 +347,35 @@ 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,7 +8,9 @@ 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;
|
||||||
|
|
@ -177,6 +179,41 @@ 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,7 +8,9 @@ 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;
|
||||||
|
|
@ -106,6 +108,51 @@ 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