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 543883 2007-06-03 11:56:01Z vsiveton $
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 ( !"pom".equals( project.getPackaging().toLowerCase() ) )
95 {
96 l.addAll( project.getExecutionProject().getTestCompileSourceRoots() );
97 }
98
99 if ( project.getExecutionProject() != null )
100 {
101 if ( !"pom".equals( project.getExecutionProject().getPackaging().toLowerCase() ) )
102 {
103 l.addAll( project.getExecutionProject().getTestCompileSourceRoots() );
104 }
105 }
106
107 return l;
108 }
109
110 /**
111 * @see org.apache.maven.plugin.jxr.AbstractJxrReport#getDestinationDirectory()
112 */
113 protected String getDestinationDirectory()
114 {
115 return destDir;
116 }
117
118 /**
119 * @see org.apache.maven.reporting.MavenReport#getDescription(java.util.Locale)
120 */
121 public String getDescription( Locale locale )
122 {
123 return getBundle( locale ).getString( "report.xref.test.description" );
124 }
125
126 /**
127 * @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale)
128 */
129 public String getName( Locale locale )
130 {
131 return getBundle( locale ).getString( "report.xref.test.name" );
132 }
133
134 /**
135 * @see org.apache.maven.reporting.MavenReport#getOutputName()
136 */
137 public String getOutputName()
138 {
139 return "xref-test/index";
140 }
141
142 /**
143 * @see org.apache.maven.plugin.jxr.AbstractJxrReport#getJavadocDir()
144 */
145 protected File getJavadocDir()
146 {
147 return testJavadocDir;
148 }
149
150 /**
151 * @see org.apache.maven.reporting.AbstractMavenReport#setReportOutputDirectory(java.io.File)
152 */
153 public void setReportOutputDirectory( File reportOutputDirectory )
154 {
155 if ( ( reportOutputDirectory != null ) && ( !reportOutputDirectory.getAbsolutePath().endsWith( "xref-test" ) ) )
156 {
157 this.destDir = new File( reportOutputDirectory, "xref-test" ).getAbsolutePath();
158 }
159 else
160 {
161 this.destDir = reportOutputDirectory.getAbsolutePath();
162 }
163 }
164 }