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