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 test stubs from the project's sources.
12   *
13   * @author Keegan Witt
14   * @since 1.0-beta-3
15   */
16  @Mojo(name = "removeTestStubs", defaultPhase = LifecyclePhase.TEST_COMPILE, threadSafe = true)
17  public class RemoveTestStubsMojo extends AbstractGroovyStubSourcesMojo {
18  
19      /**
20       * The location for the compiled test classes.
21       */
22      @Parameter(defaultValue = "${project.build.directory}/generated-sources/groovy-stubs/test")
23      protected File testStubsOutputDirectory;
24  
25      /**
26       * Flag to allow adding test sources to be skipped.
27       */
28      @Parameter(property = "maven.test.skip", defaultValue = "false")
29      protected boolean skipTests;
30  
31      /**
32       * Executes this mojo.
33       */
34      @Override
35      public void execute() {
36          if (!skipTests) {
37              try {
38                  project.getTestCompileSourceRoots().remove(testStubsOutputDirectory.getAbsolutePath());
39              } catch (UnsupportedOperationException e) {
40                  try {
41                      removeSourceRoot(project, "test", testStubsOutputDirectory);
42                  } catch (Throwable e2) {
43                      e.addSuppressed(e2);
44                      throw e;
45                  }
46              }
47          }
48      }
49  
50  }