View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.plugins.javadoc;
20  
21  import javax.inject.Inject;
22  
23  import java.io.File;
24  
25  import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
26  import org.apache.maven.doxia.tools.SiteTool;
27  import org.apache.maven.plugins.annotations.LifecyclePhase;
28  import org.apache.maven.plugins.annotations.Mojo;
29  import org.apache.maven.plugins.annotations.Parameter;
30  import org.apache.maven.plugins.annotations.ResolutionScope;
31  import org.apache.maven.plugins.javadoc.resolver.ResourceResolver;
32  import org.apache.maven.project.MavenProjectHelper;
33  import org.apache.maven.project.ProjectBuilder;
34  import org.apache.maven.toolchain.ToolchainManager;
35  import org.codehaus.plexus.archiver.manager.ArchiverManager;
36  import org.eclipse.aether.RepositorySystem;
37  
38  /**
39   * Bundle {@link TestJavadocJarMojo#testJavadocDirectory}, along with javadoc configuration options from
40   * {@link AbstractJavadocMojo} such as taglet, doclet, and link information into a deployable
41   * artifact. This artifact can then be consumed by the javadoc plugin mojos when used by the
42   * <code>includeDependencySources</code> option, to generate javadocs that are somewhat consistent
43   * with those generated in the original project itself.
44   *
45   * @since 2.7
46   */
47  @Mojo(
48          name = "test-resource-bundle",
49          defaultPhase = LifecyclePhase.PACKAGE,
50          requiresDependencyResolution = ResolutionScope.TEST,
51          threadSafe = true)
52  public class TestResourcesBundleMojo extends ResourcesBundleMojo {
53  
54      // CHECKSTYLE_OFF: ParameterNumber
55      @Inject
56      public TestResourcesBundleMojo(
57              MavenProjectHelper projectHelper,
58              SiteTool siteTool,
59              ArchiverManager archiverManager,
60              ResourceResolver resourceResolver,
61              RepositorySystem repoSystem,
62              ArtifactHandlerManager artifactHandlerManager,
63              ProjectBuilder mavenProjectBuilder,
64              ToolchainManager toolchainManager) {
65          super(
66                  projectHelper,
67                  siteTool,
68                  archiverManager,
69                  resourceResolver,
70                  repoSystem,
71                  artifactHandlerManager,
72                  mavenProjectBuilder,
73                  toolchainManager);
74      }
75      // CHECKSTYLE_ON: ParameterNumber
76  
77      /**
78       * Specifies the Test Javadoc resources directory to be included in the Javadoc (i.e. package.html, images...).
79       */
80      @Parameter(alias = "javadocDirectory", defaultValue = "${basedir}/src/test/javadoc")
81      private File testJavadocDirectory;
82  
83      @Override
84      protected String getAttachmentClassifier() {
85          return TEST_JAVADOC_RESOURCES_ATTACHMENT_CLASSIFIER;
86      }
87  
88      @Override
89      protected File getJavadocDirectory() {
90          return testJavadocDirectory;
91      }
92  
93      @Override
94      protected boolean isTest() {
95          return true;
96      }
97  }