View Javadoc

1   package com.jayway.maven.plugins.android.phase00clean;
2   
3   import org.apache.maven.plugin.AbstractMojo;
4   import org.apache.maven.plugin.MojoExecutionException;
5   import org.apache.maven.plugin.MojoFailureException;
6   import org.codehaus.plexus.util.FileUtils;
7   
8   import java.io.File;
9   import java.io.IOException;
10  
11  /**
12   * @author Johan Lindquist <johanlindquist@gmail.com>
13   * @goal clean
14   * @requiresProject true
15   * @requiresOnline false
16   * @phase clean
17   */
18  public class NdkCleanMojo extends AbstractMojo
19  {
20  
21      /**
22       * @parameter expression="${android.nativeBuildLibsOutputDirectory}" default-value="${project.basedir}/libs"
23       */
24      File ndkBuildLibsOutputDirectory;
25  
26      /**
27       * @parameter expression="${android.nativeBuildObjOutputDirectory}" default-value="${project.basedir}/obj"
28       */
29      File ndkBuildObjOutputDirectory;
30  
31      /**
32       * Forces the clean process to be skipped.
33       *
34       * @parameter expression="${android.nativeBuildSkipClean}" default-value="false"
35       */
36      boolean skipClean = false;
37  
38      /**
39       * Specifies whether the deletion of the libs/ folder structure should be skipped.  This is by default set to
40       * skip (true) to avoid unwanted deletions of libraries already present in this structure.
41       *
42       * @parameter expression="${android.nativeBuildSkipCleanLibsOutputDirectory}" default-value="true"
43       */
44      boolean skipBuildLibsOutputDirectory = true;
45  
46      /**
47       * Specifies whether the obj/ build folder structure should be deleted.
48       *
49       * @parameter expression="${android.nativeBuildSkipCleanLibsOutputDirectory}" default-value="false"
50       */
51      boolean skipBuildObjsOutputDirectory = false;
52  
53      @Override
54      public void execute() throws MojoExecutionException, MojoFailureException
55      {
56          if ( ndkBuildLibsOutputDirectory.exists() )
57          {
58              if ( ! skipBuildLibsOutputDirectory )
59              {
60                  getLog().debug( "Cleaning out native library code directory : " + ndkBuildLibsOutputDirectory
61                          .getAbsolutePath() );
62                  try
63                  {
64                      FileUtils.deleteDirectory( ndkBuildLibsOutputDirectory );
65                  }
66                  catch ( IOException e )
67                  {
68                      getLog().error( "Error deleting directory: " + e.getMessage(), e );
69                  }
70              }
71          }
72  
73          if ( ndkBuildObjOutputDirectory.exists() )
74          {
75              if ( ! skipBuildObjsOutputDirectory )
76              {
77                  getLog().debug(
78                          "Cleaning out native object code directory: " + ndkBuildObjOutputDirectory.getAbsolutePath() );
79                  try
80                  {
81                      FileUtils.deleteDirectory( ndkBuildObjOutputDirectory );
82                  }
83                  catch ( IOException e )
84                  {
85                      getLog().error( "Error deleting directory: " + e.getMessage(), e );
86                  }
87              }
88          }
89  
90      }
91  
92  }