1 package org.apache.maven.plugin.jxr;
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.project.MavenProject;
23
24 import java.io.File;
25 import java.util.ArrayList;
26 import java.util.List;
27 import java.util.Locale;
28
29 /**
30 * Creates an html-based, cross referenced version of Java source code
31 * for a project's test sources.
32 *
33 * @author <a href="mailto:bellingard.NO-SPAM@gmail.com">Fabrice Bellingard</a>
34 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
35 * @version $Id: JxrTestReport.java 1145180 2011-07-11 14:02:55Z bimargulies $
36 * @goal test-jxr
37 */
38 public class JxrTestReport
39 extends AbstractJxrReport
40 {
41 /**
42 * Test directories of the project.
43 *
44 * @parameter expression="${project.testCompileSourceRoots}"
45 * @required
46 * @readonly
47 */
48 private List sourceDirs;
49
50 /**
51 * Folder where the Xref files will be copied to.
52 *
53 * @parameter expression="${project.reporting.outputDirectory}/xref-test"
54 */
55 private String destDir;
56
57 /**
58 * Folder where Test Javadoc is generated for this project.
59 *
60 * @parameter expression="${project.reporting.outputDirectory}/testapidocs"
61 */
62 private File testJavadocDir;
63
64 /**
65 * @see org.apache.maven.plugin.jxr.AbstractJxrReport#getSourceRoots()
66 */
67 protected List getSourceRoots()
68 {
69 List l = new ArrayList();
70
71 if ( !"pom".equals( getProject().getPackaging().toLowerCase() ) )
72 {
73 l.addAll( sourceDirs );
74 }
75
76 if ( getProject().getExecutionProject() != null )
77 {
78 if ( !"pom".equals( getProject().getExecutionProject().getPackaging().toLowerCase() ) )
79 {
80 l.addAll( getProject().getExecutionProject().getTestCompileSourceRoots() );
81 }
82 }
83
84 return l;
85 }
86
87 /**
88 * @see org.apache.maven.plugin.jxr.AbstractJxrReport#getSourceRoots(org.apache.maven.project.MavenProject)
89 */
90 protected List getSourceRoots( MavenProject project )
91 {
92 List l = new ArrayList();
93
94 if ( project.getExecutionProject() != null )
95 {
96 if ( !"pom".equals( project.getExecutionProject().getPackaging().toLowerCase() ) )
97 {
98 l.addAll( project.getExecutionProject().getTestCompileSourceRoots() );
99 }
100 }
101
102 return l;
103 }
104
105 /**
106 * @see org.apache.maven.plugin.jxr.AbstractJxrReport#getDestinationDirectory()
107 */
108 protected String getDestinationDirectory()
109 {
110 return destDir;
111 }
112
113 /**
114 * @see org.apache.maven.reporting.MavenReport#getDescription(java.util.Locale)
115 */
116 public String getDescription( Locale locale )
117 {
118 return getBundle( locale ).getString( "report.xref.test.description" );
119 }
120
121 /**
122 * @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale)
123 */
124 public String getName( Locale locale )
125 {
126 return getBundle( locale ).getString( "report.xref.test.name" );
127 }
128
129 /**
130 * @see org.apache.maven.reporting.MavenReport#getOutputName()
131 */
132 public String getOutputName()
133 {
134 return "xref-test/index";
135 }
136
137 /**
138 * @see org.apache.maven.plugin.jxr.AbstractJxrReport#getJavadocDir()
139 */
140 protected File getJavadocDir()
141 {
142 return testJavadocDir;
143 }
144
145 /**
146 * @see org.apache.maven.reporting.AbstractMavenReport#setReportOutputDirectory(java.io.File)
147 */
148 public void setReportOutputDirectory( File reportOutputDirectory )
149 {
150 if ( ( reportOutputDirectory != null ) && ( !reportOutputDirectory.getAbsolutePath().endsWith( "xref-test" ) ) )
151 {
152 this.destDir = new File( reportOutputDirectory, "xref-test" ).getAbsolutePath();
153 }
154 else
155 {
156 this.destDir = reportOutputDirectory.getAbsolutePath();
157 }
158 }
159 }