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.Arrays;
24 import java.util.List;
25 import java.util.Locale;
26
27 import org.apache.maven.plugins.annotations.Execute;
28 import org.apache.maven.plugins.annotations.LifecyclePhase;
29 import org.apache.maven.plugins.annotations.Mojo;
30 import org.apache.maven.plugins.annotations.Parameter;
31 import org.apache.maven.project.MavenProject;
32
33
34
35
36
37
38
39 @Mojo(name = "jxr")
40 @Execute(phase = LifecyclePhase.GENERATE_SOURCES)
41 public class JxrReport extends AbstractJxrReport {
42
43
44
45 @Parameter(defaultValue = "${project.compileSourceRoots}", required = true, readonly = true)
46 private List<String> sourceDirs;
47
48
49
50
51
52 @Parameter
53 private String sourcePath;
54
55
56
57
58
59
60 @Parameter
61 private File javadocLocation;
62
63 @Override
64 protected File getPluginReportOutputDirectory() {
65 return new File(getReportOutputDirectory(), "xref");
66 }
67
68 @Override
69 protected List<String> getSourceRoots() {
70 if (sourcePath != null) {
71 String[] sourcePathArray = sourcePath.split(";");
72 if (sourcePathArray.length > 0) {
73 return Arrays.asList(sourcePathArray);
74 }
75 }
76
77 List<String> l = new ArrayList<>();
78
79 if (!"pom".equals(getProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
80 l.addAll(sourceDirs);
81 }
82
83 if (getProject().getExecutionProject() != null) {
84 if (!"pom".equals(getProject().getExecutionProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
85 l.addAll(getProject().getExecutionProject().getCompileSourceRoots());
86 }
87 }
88
89 return l;
90 }
91
92 @Override
93 protected List<String> getSourceRoots(MavenProject project) {
94 List<String> l = new ArrayList<>();
95
96 if (!"pom".equals(project.getPackaging().toLowerCase(Locale.ENGLISH))) {
97 l.addAll(project.getCompileSourceRoots());
98 }
99
100 if (project.getExecutionProject() != null) {
101 if (!"pom".equals(project.getExecutionProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
102 l.addAll(project.getExecutionProject().getCompileSourceRoots());
103 }
104 }
105
106 return l;
107 }
108
109 @Override
110 public String getDescription(Locale locale) {
111 return getBundle(locale).getString("report.xref.main.description");
112 }
113
114 @Override
115 public String getName(Locale locale) {
116 return getBundle(locale).getString("report.xref.main.name");
117 }
118
119 @Override
120 public String getOutputName() {
121 return "xref/index";
122 }
123
124 @Override
125 protected File getJavadocLocation() {
126 return javadocLocation != null ? javadocLocation : new File(getReportOutputDirectory(), "apidocs");
127 }
128 }