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