Coverage Report - org.apache.maven.plugin.javadoc.TestJavadocJar
 
Classes in this File Line Coverage Branch Coverage Complexity
TestJavadocJar
0%
0/22
0%
0/8
1.5
 
 1  
 package org.apache.maven.plugin.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 java.io.File;
 23  
 import java.util.ArrayList;
 24  
 import java.util.Collections;
 25  
 import java.util.List;
 26  
 
 27  
 import org.apache.maven.artifact.Artifact;
 28  
 import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
 29  
 import org.apache.maven.plugin.javadoc.resolver.SourceResolverConfig;
 30  
 import org.apache.maven.project.MavenProject;
 31  
 import org.codehaus.plexus.util.StringUtils;
 32  
 
 33  
 /**
 34  
  * Bundles the Javadoc documentation for <code>test Java code</code> in an <b>NON aggregator</b> project into
 35  
  * a jar using the standard <a href="http://java.sun.com/j2se/javadoc/">Javadoc Tool</a>.
 36  
  *
 37  
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
 38  
  * @version $Id: org.apache.maven.plugin.javadoc.TestJavadocJar.html 829400 2012-08-19 17:42:28Z hboutemy $
 39  
  * @since 2.5
 40  
  * @goal test-jar
 41  
  * @phase package
 42  
  * @requiresDependencyResolution test
 43  
  */
 44  0
 public class TestJavadocJar
 45  
     extends JavadocJar
 46  
 {
 47  
     // ----------------------------------------------------------------------
 48  
     // Javadoc Options (should be inline with Javadoc options defined in TestJavadocReport)
 49  
     // ----------------------------------------------------------------------
 50  
 
 51  
     /**
 52  
      * Specifies the destination directory where Javadoc saves the generated HTML files.
 53  
      * <br/>
 54  
      * See <a href="http://download.oracle.com/javase/1.4.2/docs/tooldocs/windows/javadoc.html#d">d</a>.
 55  
      * <br/>
 56  
      *
 57  
      * @parameter default-value="${project.build.directory}/testapidocs"
 58  
      * @required
 59  
      */
 60  
     private File outputDirectory;
 61  
 
 62  
     /**
 63  
      * Specifies the Test title to be placed near the top of the overview summary file.
 64  
      * <br/>
 65  
      * See <a href="http://download.oracle.com/javase/1.4.2/docs/tooldocs/windows/javadoc.html#doctitle">doctitle</a>.
 66  
      * <br/>
 67  
      *
 68  
      * @parameter expression="${testDoctitle}" alias="doctitle"
 69  
      * default-value="${project.name} ${project.version} Test API"
 70  
      * @since 2.5
 71  
      */
 72  
     private String testDoctitle;
 73  
 
 74  
     /**
 75  
      * Specifies that Javadoc should retrieve the text for the Test overview documentation from the "source" file
 76  
      * specified by path/filename and place it on the Overview page (overview-summary.html).
 77  
      * <br/>
 78  
      * See <a href="http://download.oracle.com/javase/1.4.2/docs/tooldocs/windows/javadoc.html#overview">overview</a>.
 79  
      * <br/>
 80  
      *
 81  
      * @parameter expression="${testOverview}" alias="overview"
 82  
      * default-value="${basedir}/src/test/javadoc/overview.html"
 83  
      * @since 2.5
 84  
      */
 85  
     private File testOverview;
 86  
 
 87  
     /**
 88  
      * Specifies the Test title to be placed in the HTML title tag.
 89  
      * <br/>
 90  
      * See <a href="http://download.oracle.com/javase/1.4.2/docs/tooldocs/windows/javadoc.html#windowtitle">windowtitle</a>.
 91  
      * <br/>
 92  
      *
 93  
      * @parameter expression="${testWindowtitle}" alias="windowtitle"
 94  
      * default-value="${project.name} ${project.version} Test API"
 95  
      * @since 2.5
 96  
      */
 97  
     private String testWindowtitle;
 98  
 
 99  
     // ----------------------------------------------------------------------
 100  
     // Mojo Parameters (should be inline with options defined in TestJavadocReport)
 101  
     // ----------------------------------------------------------------------
 102  
 
 103  
     /**
 104  
      * Specifies the Test Javadoc resources directory to be included in the Javadoc (i.e. package.html, images...).
 105  
      *
 106  
      * @parameter expression="${basedir}/src/test/javadoc" alias="javadocDirectory"
 107  
      * @since 2.5
 108  
      */
 109  
     private File testJavadocDirectory;
 110  
 
 111  
     // ----------------------------------------------------------------------
 112  
     // Protected methods
 113  
     // ----------------------------------------------------------------------
 114  
 
 115  
     @Override
 116  
     protected String getClassifier()
 117  
     {
 118  0
         return "test-javadoc";
 119  
     }
 120  
 
 121  
     // ----------------------------------------------------------------------
 122  
     // Important Note: should be inline with methods defined in TestJavadocReport
 123  
     // ----------------------------------------------------------------------
 124  
 
 125  
     @Override
 126  
     protected String getOutputDirectory()
 127  
     {
 128  0
         return outputDirectory.getAbsoluteFile().toString();
 129  
     }
 130  
 
 131  
     @Override
 132  
     protected File getJavadocDirectory()
 133  
     {
 134  0
         return testJavadocDirectory;
 135  
     }
 136  
 
 137  
     @Override
 138  
     protected String getDoctitle()
 139  
     {
 140  0
         return testDoctitle;
 141  
     }
 142  
 
 143  
     @Override
 144  
     protected File getOverview()
 145  
     {
 146  0
         return testOverview;
 147  
     }
 148  
 
 149  
     @Override
 150  
     protected String getWindowtitle()
 151  
     {
 152  0
         return testWindowtitle;
 153  
     }
 154  
 
 155  
     @Override
 156  
     protected List<String> getProjectBuildOutputDirs( MavenProject p )
 157  
     {
 158  0
         List<String> dirs = new ArrayList<String>();
 159  0
         if ( StringUtils.isNotEmpty( p.getBuild().getOutputDirectory() ) )
 160  
         {
 161  0
             dirs.add( p.getBuild().getOutputDirectory() );
 162  
         }
 163  0
         if ( StringUtils.isNotEmpty( p.getBuild().getTestOutputDirectory() ) )
 164  
         {
 165  0
             dirs.add( p.getBuild().getTestOutputDirectory() );
 166  
         }
 167  
 
 168  0
         return dirs;
 169  
     }
 170  
 
 171  
     @Override
 172  
     protected List<String> getProjectSourceRoots( MavenProject p )
 173  
     {
 174  0
         if ( "pom".equals( p.getPackaging().toLowerCase() ) )
 175  
         {
 176  0
             return Collections.emptyList();
 177  
         }
 178  
 
 179  0
         return p.getTestCompileSourceRoots();
 180  
     }
 181  
 
 182  
     @Override
 183  
     protected List<String> getExecutionProjectSourceRoots( MavenProject p )
 184  
     {
 185  0
         if ( "pom".equals( p.getExecutionProject().getPackaging().toLowerCase() ) )
 186  
         {
 187  0
             return Collections.emptyList();
 188  
         }
 189  
 
 190  0
         return p.getExecutionProject().getTestCompileSourceRoots();
 191  
     }
 192  
 
 193  
     @Override
 194  
     protected List<Artifact> getProjectArtifacts( MavenProject p )
 195  
     {
 196  0
         return p.getTestArtifacts();
 197  
     }
 198  
 
 199  
     @Override
 200  
     protected List<Artifact> getCompileArtifacts( ArtifactResolutionResult result )
 201  
     {
 202  0
         return JavadocUtil.getCompileArtifacts( result.getArtifacts(), true );
 203  
     }
 204  
     
 205  
     /**
 206  
      * Overriden to enable the resolution of -test-sources jar files.
 207  
      * 
 208  
      * {@inheritDoc}
 209  
      */
 210  
     @Override
 211  
     protected SourceResolverConfig configureDependencySourceResolution( final SourceResolverConfig config )
 212  
     {
 213  0
         return super.configureDependencySourceResolution( config ).withoutCompileSources().withTestSources();
 214  
     }
 215  
 }