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 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="delombok", defaultPhase=LifecyclePhase.GENERATE_SOURCES, requiresDependencyResolution=ResolutionScope.COMPILE, threadSafe=true)
19  public class DelombokMojo extends AbstractDelombokMojo {
20  
21      /**
22       * Location of the lombok annotated source files.
23       */
24      @Parameter(property="lombok.sourceDirectory", defaultValue="${project.basedir}/src/main/lombok", required=true)
25      private File sourceDirectory;
26  
27      /**
28       * Location of the generated source files.
29       */
30      @Parameter(property="lombok.outputDirectory", defaultValue="${project.build.directory}/generated-sources/delombok", required=true)
31      private File outputDirectory;
32  
33      @Override
34      protected String getGoalDescription() {
35          return "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.join(this.project.getCompileSourceRoots(), File.pathSeparatorChar);
51      }
52  
53      @Override
54      protected void addSourceRoot(final String path) {
55          project.addCompileSourceRoot(path);
56      }
57  }