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