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
52
53 @Parameter
54 private File testJavadocLocation;
55
56 @Override
57 protected List<String> getSourceRoots() {
58 List<String> l = new ArrayList<>();
59
60 if (!"pom".equals(getProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
61 l.addAll(sourceDirs);
62 }
63
64 if (getProject().getExecutionProject() != null) {
65 if (!"pom".equals(getProject().getExecutionProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
66 l.addAll(getProject().getExecutionProject().getTestCompileSourceRoots());
67 }
68 }
69
70 return l;
71 }
72
73 @Override
74 protected List<String> getSourceRoots(MavenProject project) {
75 List<String> l = new ArrayList<>();
76
77 if (project.getExecutionProject() != null) {
78 if (!"pom".equals(project.getExecutionProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
79 l.addAll(project.getExecutionProject().getTestCompileSourceRoots());
80 }
81 }
82
83 return l;
84 }
85
86 @Override
87 protected File getPluginReportOutputDirectory() {
88 return new File(getReportOutputDirectory(), "xref-test");
89 }
90
91 @Override
92 public String getDescription(Locale locale) {
93 return getBundle(locale).getString("report.xref.test.description");
94 }
95
96 @Override
97 public String getName(Locale locale) {
98 return getBundle(locale).getString("report.xref.test.name");
99 }
100
101 @Override
102 public String getOutputName() {
103 return "xref-test/index";
104 }
105
106 @Override
107 protected File getJavadocLocation() {
108 return testJavadocLocation != null ? testJavadocLocation : new File(getReportOutputDirectory(), "testapidocs");
109 }
110 }