1 package org.apache.maven.plugin.plugin;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.plugin.MojoExecutionException;
23 import org.apache.maven.plugins.annotations.Component;
24 import org.apache.maven.plugins.annotations.LifecyclePhase;
25 import org.apache.maven.plugins.annotations.Mojo;
26 import org.apache.maven.plugins.annotations.Parameter;
27 import org.apache.maven.tools.plugin.generator.Generator;
28 import org.apache.maven.tools.plugin.generator.PluginHelpGenerator;
29 import org.codehaus.plexus.velocity.VelocityComponent;
30
31 import java.io.File;
32
33
34
35
36
37
38
39
40 @Mojo( name = "helpmojo", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true )
41 public class HelpGeneratorMojo
42 extends AbstractGeneratorMojo
43 {
44
45
46
47 @Parameter( defaultValue = "${project.build.directory}/generated-sources/plugin" )
48 protected File outputDirectory;
49
50
51
52
53
54
55
56 @Parameter
57 private String helpPackageName;
58
59
60
61
62 @Component
63 private VelocityComponent velocity;
64
65
66
67
68 protected File getOutputDirectory()
69 {
70 return outputDirectory;
71 }
72
73
74
75
76 protected Generator createGenerator()
77 {
78 return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setVelocityComponent( this.velocity );
79 }
80
81
82
83
84 public void execute()
85 throws MojoExecutionException
86 {
87 super.execute();
88
89 if ( !project.getCompileSourceRoots().contains( outputDirectory.getAbsolutePath() ) && !skip )
90 {
91 project.addCompileSourceRoot( outputDirectory.getAbsolutePath() );
92 }
93
94 }
95
96 }