22
33import com .igormaznitsa .jbbp .plugin .common .converters .JBBPScriptTranslator ;
44import com .igormaznitsa .jbbp .plugin .common .converters .Target ;
5+ import org .apache .commons .io .FileUtils ;
56import org .apache .maven .plugin .MojoExecutionException ;
67import org .apache .maven .plugin .MojoFailureException ;
78import org .apache .maven .plugins .annotations .LifecyclePhase ;
89import org .apache .maven .plugins .annotations .Mojo ;
10+ import org .apache .maven .plugins .annotations .Parameter ;
911
1012import java .io .File ;
1113import java .io .IOException ;
1921@ Mojo (name = "clean" , defaultPhase = LifecyclePhase .CLEAN , threadSafe = true )
2022public class JBBPCleanMojo extends AbstractJBBPMojo {
2123
24+ /**
25+ * Clean whole target folder.
26+ */
27+ @ Parameter (alias = "cleanAll" , defaultValue = "false" )
28+ private boolean cleanAll ;
29+
30+
2231 @ Override
2332 public void executeMojo () throws MojoExecutionException , MojoFailureException {
33+ if (this .cleanAll ) {
34+ getLog ().debug ("Clean whole folder : " + this .output );
35+ if (this .output .isDirectory ()) {
36+ try {
37+ FileUtils .cleanDirectory (this .output );
38+ } catch (IOException ex ) {
39+ throw new MojoExecutionException ("Can't clean folder : " + this .output , ex );
40+ }
41+ } else {
42+ getLog ().info ("Can't find output folder : " + this .output );
43+ }
44+ return ;
45+ }
46+
2447 final Set <File > scripts = findSources (this .output );
2548 if (checkSetNonEmptyWithLogging (scripts )) {
2649 int counter = 0 ;
@@ -36,8 +59,8 @@ public void executeMojo() throws MojoExecutionException, MojoFailureException {
3659 final Set <File > files ;
3760 try {
3861 files = target .getTranslator ().translate (parameters , true );
39- }catch (IOException ex ){
40- throw new MojoExecutionException ("Error during form file set" ,ex );
62+ } catch (IOException ex ) {
63+ throw new MojoExecutionException ("Error during form file set" , ex );
4164 }
4265
4366 for (final File f : files ) {
0 commit comments