View Javadoc
1   package lombok.maven;
2   
3   import java.io.File;
4   
5   import org.apache.commons.lang3.StringUtils;
6   import org.apache.maven.plugins.annotations.LifecyclePhase;
7   import org.apache.maven.plugins.annotations.Mojo;
8   import org.apache.maven.plugins.annotations.Parameter;
9   import org.apache.maven.plugins.annotations.ResolutionScope;
10  
11  
12  /**
13   * Delombok java test source with lombok annotations.
14   *
15   * @author <a href="mailto:anthony@whitford.com">Anthony Whitford</a>
16   * @see <a href="http://projectlombok.org/features/delombok.html">Delombok</a>
17   */
18  @Mojo(name="testDelombok", defaultPhase=LifecyclePhase.GENERATE_TEST_SOURCES, requiresDependencyResolution=ResolutionScope.TEST, threadSafe=true)
19  public class TestDelombokMojo extends AbstractDelombokMojo {
20  
21      /**
22       * Location of the lombok annotated source files.
23       */
24      @Parameter(property="lombok.testSourceDirectory", defaultValue="${project.basedir}/src/test/lombok", required=true)
25      private File sourceDirectory;
26  
27      /**
28       * Location of the generated source files.
29       */
30      @Parameter(property="lombok.testOutputDirectory", defaultValue="${project.build.directory}/generated-test-sources/delombok", required=true)
31      private File outputDirectory;
32  
33      @Override
34      protected String getGoalDescription() {
35          return "Test Delombok";
36      }
37  
38      @Override
39      protected File getOutputDirectory() {
40          return outputDirectory;
41      }
42  
43      @Override
44      protected File getSourceDirectory() {
45          return sourceDirectory;
46      }
47  
48      @Override
49      protected String getSourcePath() {
50        return StringUtils.joinWith(File.pathSeparator,
51            StringUtils.join(this.project.getCompileSourceRoots(), File.pathSeparatorChar),
52            StringUtils.join(this.project.getTestCompileSourceRoots(), File.pathSeparatorChar)
53        );
54      }
55  
56      @Override
57      protected void addSourceRoot(final String path) {
58          project.addTestCompileSourceRoot(path);
59      }
60  }