View Javadoc
1   package org.apache.maven.plugins.javadoc;
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.artifact.DependencyResolutionRequiredException;
23  import org.apache.maven.plugin.MojoExecutionException;
24  import org.apache.maven.plugin.MojoFailureException;
25  import org.apache.maven.plugins.annotations.Execute;
26  import org.apache.maven.plugins.annotations.LifecyclePhase;
27  import org.apache.maven.plugins.annotations.Mojo;
28  import org.apache.maven.plugins.annotations.ResolutionScope;
29  import org.apache.maven.project.MavenProject;
30  
31  import java.util.Collections;
32  import java.util.LinkedList;
33  import java.util.List;
34  
35  /**
36   * Fix Javadoc documentation and tags for the <code>Test Java code</code> for the project.
37   * See <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#wheretags">Where Tags Can
38   * Be Used</a>.
39   *
40   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
41   * @since 2.6
42   */
43  @Mojo( name = "test-fix", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true )
44  @Execute( phase = LifecyclePhase.TEST_COMPILE )
45  public class TestFixJavadocMojo
46      extends AbstractFixJavadocMojo
47  {
48      /** {@inheritDoc} */
49      @Override
50      protected List<String> getProjectSourceRoots( MavenProject p )
51      {
52          return ( p.getTestCompileSourceRoots() == null ? Collections.<String>emptyList()
53                          : new LinkedList<>( p.getTestCompileSourceRoots() ) );
54      }
55  
56      /** {@inheritDoc} */
57      @Override
58      protected List<String> getCompileClasspathElements( MavenProject p )
59          throws DependencyResolutionRequiredException
60      {
61          return ( p.getTestClasspathElements() == null ? Collections.<String>emptyList()
62                          : new LinkedList<>( p.getTestClasspathElements() ) );
63      }
64  
65      /** {@inheritDoc} */
66      @Override
67      protected String getArtifactType( MavenProject p )
68      {
69          return "test-jar";
70      }
71  
72      /** {@inheritDoc} */
73      @Override
74      public void execute()
75          throws MojoExecutionException, MojoFailureException
76      {
77          // clirr doesn't analyze test code, so ignore it
78          ignoreClirr = true;
79  
80          super.execute();
81      }
82  }