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 java.io.File;
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.List;
26 import java.util.Locale;
27
28 import org.apache.maven.plugins.annotations.Execute;
29 import org.apache.maven.plugins.annotations.LifecyclePhase;
30 import org.apache.maven.plugins.annotations.Mojo;
31 import org.apache.maven.plugins.annotations.Parameter;
32 import org.apache.maven.project.MavenProject;
33
34
35
36
37
38
39
40
41 @Mojo( name = "jxr" )
42 @Execute( phase = LifecyclePhase.GENERATE_SOURCES )
43 public class JxrReport
44 extends AbstractJxrReport
45 {
46
47
48
49 @Parameter( defaultValue = "${project.compileSourceRoots}", required = true, readonly = true )
50 private List<String> sourceDirs;
51
52
53
54
55
56 @Parameter
57 private String sourcePath;
58
59
60
61
62 @Parameter( defaultValue = "${project.reporting.outputDirectory}/xref" )
63 private String destDir;
64
65
66
67
68 @Parameter( defaultValue = "${project.reporting.outputDirectory}/apidocs" )
69 private File javadocDir;
70
71 @Override
72 protected String getDestinationDirectory()
73 {
74 return destDir;
75 }
76
77 @Override
78 protected List<String> getSourceRoots()
79 {
80 if ( sourcePath != null )
81 {
82 String[] sourcePathArray = sourcePath.split( ";" );
83 if ( sourcePathArray.length > 0 )
84 {
85 return Arrays.asList( sourcePathArray );
86 }
87 }
88
89 List<String> l = new ArrayList<>();
90
91 if ( !"pom".equals( getProject().getPackaging().toLowerCase( Locale.US ) ) )
92 {
93 l.addAll( sourceDirs );
94 }
95
96 if ( getProject().getExecutionProject() != null )
97 {
98 if ( !"pom".equals( getProject().getExecutionProject().getPackaging().toLowerCase( Locale.US ) ) )
99 {
100 l.addAll( getProject().getExecutionProject().getCompileSourceRoots() );
101 }
102 }
103
104 return l;
105 }
106
107 @Override
108 protected List<String> getSourceRoots( MavenProject project )
109 {
110 List<String> l = new ArrayList<>();
111
112 if ( !"pom".equals( project.getPackaging().toLowerCase( Locale.US ) ) )
113 {
114 l.addAll( project.getCompileSourceRoots() );
115 }
116
117 if ( project.getExecutionProject() != null )
118 {
119 if ( !"pom".equals( project.getExecutionProject().getPackaging().toLowerCase( Locale.US ) ) )
120 {
121 l.addAll( project.getExecutionProject().getCompileSourceRoots() );
122 }
123 }
124
125 return l;
126 }
127
128 @Override
129 public String getDescription( Locale locale )
130 {
131 return getBundle( locale ).getString( "report.xref.main.description" );
132 }
133
134 @Override
135 public String getName( Locale locale )
136 {
137 return getBundle( locale ).getString( "report.xref.main.name" );
138 }
139
140 @Override
141 public String getOutputName()
142 {
143 return "xref/index";
144 }
145
146 @Override
147 protected File getJavadocDir()
148 {
149 return javadocDir;
150 }
151
152 @Override
153 public void setReportOutputDirectory( File reportOutputDirectory )
154 {
155 if ( ( reportOutputDirectory != null ) && ( !reportOutputDirectory.getAbsolutePath().endsWith( "xref" ) ) )
156 {
157 this.destDir = new File( reportOutputDirectory, "xref" ).getAbsolutePath();
158 }
159 else
160 {
161 this.destDir = reportOutputDirectory.getAbsolutePath();
162 }
163 }
164 }