1 package org.apache.maven.plugin.jxr;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.plugins.annotations.Mojo;
23 import org.apache.maven.plugins.annotations.Parameter;
24 import org.apache.maven.project.MavenProject;
25
26 import java.io.File;
27 import java.util.ArrayList;
28 import java.util.List;
29 import java.util.Locale;
30
31
32
33
34
35
36
37
38
39 @Mojo( name = "test-jxr" )
40 public class JxrTestReport
41 extends AbstractJxrReport
42 {
43
44
45
46 @Parameter( defaultValue = "${project.testCompileSourceRoots}", required = true, readonly = true )
47 private List<String> sourceDirs;
48
49
50
51
52 @Parameter( defaultValue = "${project.reporting.outputDirectory}/xref-test" )
53 private String destDir;
54
55
56
57
58 @Parameter( defaultValue = "${project.reporting.outputDirectory}/testapidocs" )
59 private File testJavadocDir;
60
61
62
63
64 protected List<String> getSourceRoots()
65 {
66 List<String> l = new ArrayList<String>();
67
68 if ( !"pom".equals( getProject().getPackaging().toLowerCase() ) )
69 {
70 l.addAll( sourceDirs );
71 }
72
73 if ( getProject().getExecutionProject() != null )
74 {
75 if ( !"pom".equals( getProject().getExecutionProject().getPackaging().toLowerCase() ) )
76 {
77 l.addAll( getProject().getExecutionProject().getTestCompileSourceRoots() );
78 }
79 }
80
81 return l;
82 }
83
84
85
86
87 protected List<String> getSourceRoots( MavenProject project )
88 {
89 List<String> l = new ArrayList<String>();
90
91 if ( project.getExecutionProject() != null )
92 {
93 if ( !"pom".equals( project.getExecutionProject().getPackaging().toLowerCase() ) )
94 {
95 l.addAll( project.getExecutionProject().getTestCompileSourceRoots() );
96 }
97 }
98
99 return l;
100 }
101
102
103
104
105 protected String getDestinationDirectory()
106 {
107 return destDir;
108 }
109
110
111
112
113 public String getDescription( Locale locale )
114 {
115 return getBundle( locale ).getString( "report.xref.test.description" );
116 }
117
118
119
120
121 public String getName( Locale locale )
122 {
123 return getBundle( locale ).getString( "report.xref.test.name" );
124 }
125
126
127
128
129 public String getOutputName()
130 {
131 return "xref-test/index";
132 }
133
134
135
136
137 protected File getJavadocDir()
138 {
139 return testJavadocDir;
140 }
141
142
143
144
145 public void setReportOutputDirectory( File reportOutputDirectory )
146 {
147 if ( ( reportOutputDirectory != null ) && ( !reportOutputDirectory.getAbsolutePath().endsWith( "xref-test" ) ) )
148 {
149 this.destDir = new File( reportOutputDirectory, "xref-test" ).getAbsolutePath();
150 }
151 else
152 {
153 this.destDir = reportOutputDirectory.getAbsolutePath();
154 }
155 }
156 }