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