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   * @version $Id: TestFixJavadocMojo.java 1642248 2014-11-28 00:10:50Z hboutemy $
42   * @since 2.6
43   */
44  @Mojo( name = "test-fix", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true )
45  @Execute( phase = LifecyclePhase.TEST_COMPILE )
46  public class TestFixJavadocMojo
47      extends AbstractFixJavadocMojo
48  {
49      /** {@inheritDoc} */
50      @Override
51      protected List<String> getProjectSourceRoots( MavenProject p )
52      {
53          return ( p.getTestCompileSourceRoots() == null ? Collections.<String>emptyList()
54                          : new LinkedList<>( p.getTestCompileSourceRoots() ) );
55      }
56  
57      /** {@inheritDoc} */
58      @Override
59      protected List<String> getCompileClasspathElements( MavenProject p )
60          throws DependencyResolutionRequiredException
61      {
62          return ( p.getTestClasspathElements() == null ? Collections.<String>emptyList()
63                          : new LinkedList<>( p.getTestClasspathElements() ) );
64      }
65  
66      /** {@inheritDoc} */
67      @Override
68      protected String getArtifactType( MavenProject p )
69      {
70          return "test-jar";
71      }
72  
73      /** {@inheritDoc} */
74      @Override
75      public void execute()
76          throws MojoExecutionException, MojoFailureException
77      {
78          // clirr doesn't analyze test code, so ignore it
79          ignoreClirr = true;
80  
81          super.execute();
82      }
83  }