View Javadoc
1   package org.codehaus.gmavenplus.mojo;
2   
3   import org.apache.maven.plugins.annotations.LifecyclePhase;
4   import org.apache.maven.plugins.annotations.Mojo;
5   import org.apache.maven.plugins.annotations.Parameter;
6   
7   import java.io.File;
8   
9   
10  /**
11   * This mojo removes Groovy stubs from the project's sources.
12   *
13   * @author Keegan Witt
14   * @since 1.0-beta-3
15   */
16  @Mojo(name = "removeStubs", defaultPhase = LifecyclePhase.COMPILE, threadSafe = true)
17  public class RemoveStubsMojo extends AbstractGroovyStubSourcesMojo {
18  
19      /**
20       * The location for the compiled classes.
21       */
22      @Parameter(defaultValue = "${project.build.directory}/generated-sources/groovy-stubs/main")
23      protected File stubsOutputDirectory;
24  
25      /**
26       * Executes this mojo.
27       */
28      @Override
29      public void execute() {
30          try {
31              project.getCompileSourceRoots().remove(stubsOutputDirectory.getAbsolutePath());
32          } catch (UnsupportedOperationException e) {
33              try {
34                  removeSourceRoot(project, "main", stubsOutputDirectory);
35              } catch (Throwable e2) {
36                  e.addSuppressed(e2);
37                  throw e;
38              }
39          }
40      }
41  
42  }