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 @Parameter(defaultValue = "${project.reporting.outputDirectory}/xref")
59 private String destDir;
60
61
62
63
64 @Parameter(defaultValue = "${project.reporting.outputDirectory}/apidocs")
65 private File javadocDir;
66
67 @Override
68 protected String getDestinationDirectory() {
69 return destDir;
70 }
71
72 @Override
73 protected List<String> getSourceRoots() {
74 if (sourcePath != null) {
75 String[] sourcePathArray = sourcePath.split(";");
76 if (sourcePathArray.length > 0) {
77 return Arrays.asList(sourcePathArray);
78 }
79 }
80
81 List<String> l = new ArrayList<>();
82
83 if (!"pom".equals(getProject().getPackaging().toLowerCase(Locale.US))) {
84 l.addAll(sourceDirs);
85 }
86
87 if (getProject().getExecutionProject() != null) {
88 if (!"pom".equals(getProject().getExecutionProject().getPackaging().toLowerCase(Locale.US))) {
89 l.addAll(getProject().getExecutionProject().getCompileSourceRoots());
90 }
91 }
92
93 return l;
94 }
95
96 @Override
97 protected List<String> getSourceRoots(MavenProject project) {
98 List<String> l = new ArrayList<>();
99
100 if (!"pom".equals(project.getPackaging().toLowerCase(Locale.US))) {
101 l.addAll(project.getCompileSourceRoots());
102 }
103
104 if (project.getExecutionProject() != null) {
105 if (!"pom".equals(project.getExecutionProject().getPackaging().toLowerCase(Locale.US))) {
106 l.addAll(project.getExecutionProject().getCompileSourceRoots());
107 }
108 }
109
110 return l;
111 }
112
113 @Override
114 public String getDescription(Locale locale) {
115 return getBundle(locale).getString("report.xref.main.description");
116 }
117
118 @Override
119 public String getName(Locale locale) {
120 return getBundle(locale).getString("report.xref.main.name");
121 }
122
123 @Override
124 public String getOutputName() {
125 return "xref/index";
126 }
127
128 @Override
129 protected File getJavadocDir() {
130 return javadocDir;
131 }
132
133 @Override
134 public void setReportOutputDirectory(File reportOutputDirectory) {
135 if ((reportOutputDirectory != null)
136 && (!reportOutputDirectory.getAbsolutePath().endsWith("xref"))) {
137 this.destDir = new File(reportOutputDirectory, "xref").getAbsolutePath();
138 } else {
139 this.destDir = reportOutputDirectory.getAbsolutePath();
140 }
141 }
142 }