View Javadoc

1   package com.googlecode.t7mp.steps;
2   
3   import java.io.File;
4   import java.io.IOException;
5   
6   import org.apache.commons.io.FileUtils;
7   
8   import com.googlecode.t7mp.PluginLog;
9   import com.googlecode.t7mp.T7Configuration;
10  
11  /**
12   * This Step deletes the 'docs' and 'examples' directories of the
13   * Tomcat distribution.
14   * 
15   * Make sure you only use it after the extraction-step.
16   * 
17   * @author Joerg Bellmann
18   *
19   */
20  public class DeleteDocsAndExamplesStep implements Step {
21  
22      protected PluginLog logger;
23      protected T7Configuration configuration;
24  
25      @Override
26      public void execute(Context context) {
27          this.logger = context.getLog();
28          this.configuration = context.getConfiguration();
29          if (configuration.isDownloadTomcatExamples()) {
30              // now we do not support a repackaged version anymore
31              // so we only have complete tomcat-zips in maven-central
32              logger.info("Skip deletion of 'docs' and 'examples' directories.");
33              return;
34          }
35          // the user do not want docs and examples
36          try {
37              FileUtils.deleteDirectory(new File(configuration.getCatalinaBase(), "/docs"));
38          } catch (IOException e) {
39              logger.error("Could not delete the 'docs' example.", e);
40          }
41          try {
42              FileUtils.deleteDirectory(new File(configuration.getCatalinaBase(), "/examples"));
43          } catch (IOException e) {
44              logger.error("Could not delete the 'examples' directory.", e);
45          }
46      }
47  
48  }