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 java.io.File; | |
23 | ||
24 | import org.apache.maven.plugin.MojoExecutionException; | |
25 | import org.apache.maven.tools.plugin.generator.Generator; | |
26 | import org.apache.maven.tools.plugin.generator.PluginHelpGenerator; | |
27 | ||
28 | /** | |
29 | * Generates a <code>HelpMojo</code> class. | |
30 | * | |
31 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> | |
32 | * @version $Id: HelpGeneratorMojo.java 1133737 2011-06-09 09:20:50Z stephenc $ | |
33 | * @since 2.4 | |
34 | * @goal helpmojo | |
35 | * @phase generate-sources | |
36 | */ | |
37 | 0 | public class HelpGeneratorMojo |
38 | extends AbstractGeneratorMojo | |
39 | { | |
40 | /** | |
41 | * The directory where the generated <code>HelpMojo</code> file will be put. | |
42 | * | |
43 | * @parameter default-value="${project.build.directory}/generated-sources/plugin" | |
44 | */ | |
45 | protected File outputDirectory; | |
46 | ||
47 | /** | |
48 | * The name of the package for the generated <code>HelpMojo</code>. By default, the package will be calculated based | |
49 | * on the packages of the other plugin goals. | |
50 | * | |
51 | * @parameter | |
52 | * @since 2.6 | |
53 | */ | |
54 | private String helpPackageName; | |
55 | ||
56 | /** | |
57 | * Generate Java 5 sources. | |
58 | * | |
59 | * @parameter expression="${useJava5}" default-value="false" | |
60 | * @since 2.7 | |
61 | */ | |
62 | private boolean useJava5; | |
63 | ||
64 | /** {@inheritDoc} */ | |
65 | protected File getOutputDirectory() | |
66 | { | |
67 | 0 | return outputDirectory; |
68 | } | |
69 | ||
70 | /** {@inheritDoc} */ | |
71 | protected Generator createGenerator() | |
72 | { | |
73 | 0 | return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setUseJava5( useJava5 ); |
74 | } | |
75 | ||
76 | /** {@inheritDoc} */ | |
77 | public void execute() | |
78 | throws MojoExecutionException | |
79 | { | |
80 | 0 | super.execute(); |
81 | ||
82 | 0 | if ( !project.getCompileSourceRoots().contains( outputDirectory.getAbsolutePath() ) && !skip ) |
83 | { | |
84 | 0 | project.addCompileSourceRoot( outputDirectory.getAbsolutePath() ); |
85 | } | |
86 | 0 | } |
87 | } |