From 7ab1f2f357310135afd622b4b5ca826acc7990d3 Mon Sep 17 00:00:00 2001 From: Ryan Ashcraft Date: Fri, 1 Sep 2023 17:33:59 -0400 Subject: [PATCH 1/2] #45 :bug: update to also clean target in addition to dist --- README.md | 15 +++++++++++++++ .../habushu/CleanHabushuMojo.java | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/README.md b/README.md index a2877a1..a1121c2 100644 --- a/README.md +++ b/README.md @@ -597,6 +597,21 @@ normal circumstances. Default: `${project.basedir}/target/habushu.placeholder.txt` + +#### distDirectory #### + +Controls where the clean plugin will delete dist artifacts. + +Default: `${project.basedir}/dist` + + +#### targetirectory #### + +Controls where the clean plugin will delete target artifacts. + +Default: `${project.basedir}/target` + + ## The Habushu Build Lifecycle ## Habushu applies a [custom Maven lifecycle that binds Poetry-based DevSecOps workflow commands](https://fermenter.atlassian.net/wiki/spaces/HAB/pages/2056749057/Dependency+Management+and+Build+Automation+through+Poetry+and+Maven) to the following phases: diff --git a/habushu-maven-plugin/src/main/java/org/technologybrewery/habushu/CleanHabushuMojo.java b/habushu-maven-plugin/src/main/java/org/technologybrewery/habushu/CleanHabushuMojo.java index ded7c10..5d75ae5 100644 --- a/habushu-maven-plugin/src/main/java/org/technologybrewery/habushu/CleanHabushuMojo.java +++ b/habushu-maven-plugin/src/main/java/org/technologybrewery/habushu/CleanHabushuMojo.java @@ -39,6 +39,12 @@ public class CleanHabushuMojo extends CleanMojo { @Parameter(defaultValue = "${project.basedir}/dist", readonly = true, required = true) protected File distDirectory; + /** + * Directory in which Maven places build-time artifacts - should NOT include dist items. + */ + @Parameter(defaultValue = "${project.basedir}/target", readonly = true, required = true) + protected File targetDirectory; + /** * Enables the explicit deletion of the virtual environment that is * created/managed by Poetry. @@ -125,11 +131,15 @@ public void execute() throws MojoExecutionException { try { Fileset distArchivesFileset = createFileset(distDirectory); filesetsToDelete.add(distArchivesFileset); + + Fileset targetArchivesFileset = createFileset(targetDirectory); + filesetsToDelete.add(targetArchivesFileset); } catch (IllegalAccessException e) { throw new MojoExecutionException("Could not write to private field in Fileset class.", e); } getLog().info(String.format("Deleting distribution archives at %s", distDirectory)); + getLog().info(String.format("Deleting distribution archives at %s", targetDirectory)); setPrivateParentField("filesets", filesetsToDelete.toArray(new Fileset[0])); super.execute(); From 5316ca4cdcfe2f8a15c1967102b6a17e5a251831 Mon Sep 17 00:00:00 2001 From: Ryan Ashcraft Date: Thu, 7 Sep 2023 11:17:02 -0400 Subject: [PATCH 2/2] #45 :bug: update to also clean target in addition to dist; with PR feedback --- README.md | 2 +- .../java/org/technologybrewery/habushu/CleanHabushuMojo.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a1121c2..63ca1ab 100644 --- a/README.md +++ b/README.md @@ -605,7 +605,7 @@ Controls where the clean plugin will delete dist artifacts. Default: `${project.basedir}/dist` -#### targetirectory #### +#### targetDirectory #### Controls where the clean plugin will delete target artifacts. diff --git a/habushu-maven-plugin/src/main/java/org/technologybrewery/habushu/CleanHabushuMojo.java b/habushu-maven-plugin/src/main/java/org/technologybrewery/habushu/CleanHabushuMojo.java index 5d75ae5..27e8ddd 100644 --- a/habushu-maven-plugin/src/main/java/org/technologybrewery/habushu/CleanHabushuMojo.java +++ b/habushu-maven-plugin/src/main/java/org/technologybrewery/habushu/CleanHabushuMojo.java @@ -139,7 +139,7 @@ public void execute() throws MojoExecutionException { } getLog().info(String.format("Deleting distribution archives at %s", distDirectory)); - getLog().info(String.format("Deleting distribution archives at %s", targetDirectory)); + getLog().info(String.format("Deleting target archives at %s", targetDirectory)); setPrivateParentField("filesets", filesetsToDelete.toArray(new Fileset[0])); super.execute();