Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
HelpGeneratorMojo |
|
| 1.6666666666666667;1,667 |
1 | package org.apache.maven.plugin.plugin; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | import org.apache.maven.plugin.MojoExecutionException; | |
23 | import org.apache.maven.tools.plugin.generator.Generator; | |
24 | import org.apache.maven.tools.plugin.generator.PluginHelpGenerator; | |
25 | import org.codehaus.plexus.velocity.VelocityComponent; | |
26 | ||
27 | import java.io.File; | |
28 | ||
29 | /** | |
30 | * Generates a <code>HelpMojo</code> class. | |
31 | * | |
32 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> | |
33 | * @version $Id: HelpGeneratorMojo.java 1337712 2012-05-12 22:41:56Z hboutemy $ | |
34 | * @goal helpmojo | |
35 | * @phase generate-sources | |
36 | * @since 2.4 | |
37 | */ | |
38 | 0 | public class HelpGeneratorMojo |
39 | extends AbstractGeneratorMojo | |
40 | { | |
41 | /** | |
42 | * The directory where the generated <code>HelpMojo</code> file will be put. | |
43 | * | |
44 | * @parameter default-value="${project.build.directory}/generated-sources/plugin" | |
45 | */ | |
46 | protected File outputDirectory; | |
47 | ||
48 | /** | |
49 | * The name of the package for the generated <code>HelpMojo</code>. By default, the package will be calculated based | |
50 | * on the packages of the other plugin goals. | |
51 | * | |
52 | * @parameter | |
53 | * @since 2.6 | |
54 | */ | |
55 | private String helpPackageName; | |
56 | ||
57 | /** | |
58 | * Velocity component. | |
59 | * | |
60 | * @component | |
61 | * @readonly | |
62 | * @required | |
63 | */ | |
64 | private VelocityComponent velocity; | |
65 | ||
66 | /** | |
67 | * {@inheritDoc} | |
68 | */ | |
69 | protected File getOutputDirectory() | |
70 | { | |
71 | 0 | return outputDirectory; |
72 | } | |
73 | ||
74 | /** | |
75 | * {@inheritDoc} | |
76 | */ | |
77 | protected Generator createGenerator() | |
78 | { | |
79 | 0 | return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setVelocityComponent( this.velocity ); |
80 | } | |
81 | ||
82 | /** | |
83 | * {@inheritDoc} | |
84 | */ | |
85 | public void execute() | |
86 | throws MojoExecutionException | |
87 | { | |
88 | 0 | super.execute(); |
89 | ||
90 | 0 | if ( !project.getCompileSourceRoots().contains( outputDirectory.getAbsolutePath() ) && !skip ) |
91 | { | |
92 | 0 | project.addCompileSourceRoot( outputDirectory.getAbsolutePath() ); |
93 | } | |
94 | ||
95 | 0 | } |
96 | ||
97 | } |