Skip to content

Commit

Permalink
Added build clean option
Browse files Browse the repository at this point in the history
  • Loading branch information
salmonb committed Apr 1, 2024
1 parent 677fed8 commit 1827dd9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/main/java/dev/webfx/cli/commands/Build.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
@Command(name = "build", description = "Build a WebFX application.")
public final class Build extends CommonSubcommand implements Runnable {

@CommandLine.Option(names= {"-c", "--clean"}, description = "Clean the target folder before the build")
boolean clean;

@CommandLine.Option(names = {"-g", "--gwt"}, description = "Includes the GWT compilation")
private boolean gwt;

Expand Down Expand Up @@ -69,7 +72,7 @@ public void run() {
else
android = true;
}
execute(new BuildRunCommon(true, run, gwt, j2cl, fatjar, openJfxDesktop, gluonDesktop, android, ios, locate, show, appImage, deb, rpm, open), getWorkspace());
execute(new BuildRunCommon(clean, true, run, gwt, j2cl, fatjar, openJfxDesktop, gluonDesktop, android, ios, locate, show, appImage, deb, rpm, open), getWorkspace());
}

static void execute(BuildRunCommon brc, CommandWorkspace workspace) {
Expand All @@ -89,6 +92,7 @@ static void execute(BuildRunCommon brc, CommandWorkspace workspace) {
throw new CommandLine.ParameterException(new CommandLine(this), "Missing required build option");
*/
String command = "mvn " +
(brc.clean ? "clean " : "") +
(gluonModule != null ? "install " : "package ") +
(brc.fatjar ? "-P openjfx-fatjar " : "") +
(brc.openJfxDesktop ? "-P openjfx-desktop " : "") +
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/dev/webfx/cli/commands/BuildRunCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* @author Bruno Salmon
*/
final class BuildRunCommon {
final boolean clean;
final boolean build;
final boolean run;
final boolean gwt;
Expand All @@ -32,7 +33,8 @@ final class BuildRunCommon {
final boolean rpm;
final boolean open;

public BuildRunCommon(boolean build, boolean run, boolean gwt, boolean j2cl, boolean fatjar, boolean openJfxDesktop, boolean gluonDesktop, boolean android, boolean ios, boolean locate, boolean show, boolean appImage, boolean deb, boolean rpm, boolean open) {
public BuildRunCommon(boolean clean, boolean build, boolean run, boolean gwt, boolean j2cl, boolean fatjar, boolean openJfxDesktop, boolean gluonDesktop, boolean android, boolean ios, boolean locate, boolean show, boolean appImage, boolean deb, boolean rpm, boolean open) {
this.clean = clean;
this.build = build;
this.run = run;
this.gwt = gwt;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/dev/webfx/cli/commands/Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public final class Run extends CommonSubcommand implements Runnable {
@CommandLine.Option(names= {"-b", "--build"}, description = "(Re)build the application before running it")
boolean build;

@CommandLine.Option(names= {"-c", "--clean"}, description = "Clean the target folder before the build")
boolean clean;

@CommandLine.Option(names= {"--AppImage"}, description = "Takes the AppImage as executable (Linux)")
boolean appImage;

Expand All @@ -74,7 +77,7 @@ public void run() {
else
android = true;
}
execute(new BuildRunCommon(build, true, gwt, j2cl, fatjar, openJfxDesktop, gluonDesktop, android, ios, locate, show, appImage, deb, rpm, open), getWorkspace());
execute(new BuildRunCommon(clean, build, true, gwt, j2cl, fatjar, openJfxDesktop, gluonDesktop, android, ios, locate, show, appImage, deb, rpm, open), getWorkspace());
}

static void execute(BuildRunCommon brc, CommandWorkspace workspace) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/dev/webfx/cli/version/dev/version.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=0.1.0-SNAPSHOT
build.timestamp=2024-04-01 16:02
build.timestamp=2024-04-01 17:30

0 comments on commit 1827dd9

Please sign in to comment.