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.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
40
41 @Mojo( name = "test-jxr" )
42 @Execute( phase = LifecyclePhase.GENERATE_TEST_SOURCES )
43 public class JxrTestReport
44 extends AbstractJxrReport
45 {
46
47
48
49 @Parameter( defaultValue = "${project.testCompileSourceRoots}", required = true, readonly = true )
50 private List<String> sourceDirs;
51
52
53
54
55 @Parameter( defaultValue = "${project.reporting.outputDirectory}/xref-test" )
56 private String destDir;
57
58
59
60
61 @Parameter( defaultValue = "${project.reporting.outputDirectory}/testapidocs" )
62 private File testJavadocDir;
63
64 @Override
65 protected List<String> getSourceRoots()
66 {
67 List<String> l = new ArrayList<>();
68
69 if ( !"pom".equals( getProject().getPackaging().toLowerCase( Locale.US ) ) )
70 {
71 l.addAll( sourceDirs );
72 }
73
74 if ( getProject().getExecutionProject() != null )
75 {
76 if ( !"pom".equals( getProject().getExecutionProject().getPackaging().toLowerCase( Locale.US ) ) )
77 {
78 l.addAll( getProject().getExecutionProject().getTestCompileSourceRoots() );
79 }
80 }
81
82 return l;
83 }
84
85 @Override
86 protected List<String> getSourceRoots( MavenProject project )
87 {
88 List<String> l = new ArrayList<>();
89
90 if ( project.getExecutionProject() != null )
91 {
92 if ( !"pom".equals( project.getExecutionProject().getPackaging().toLowerCase( Locale.US ) ) )
93 {
94 l.addAll( project.getExecutionProject().getTestCompileSourceRoots() );
95 }
96 }
97
98 return l;
99 }
100
101 @Override
102 protected String getDestinationDirectory()
103 {
104 return destDir;
105 }
106
107 @Override
108 public String getDescription( Locale locale )
109 {
110 return getBundle( locale ).getString( "report.xref.test.description" );
111 }
112
113 @Override
114 public String getName( Locale locale )
115 {
116 return getBundle( locale ).getString( "report.xref.test.name" );
117 }
118
119 @Override
120 public String getOutputName()
121 {
122 return "xref-test/index";
123 }
124
125 @Override
126 protected File getJavadocDir()
127 {
128 return testJavadocDir;
129 }
130
131 @Override
132 public void setReportOutputDirectory( File reportOutputDirectory )
133 {
134 if ( ( reportOutputDirectory != null ) && ( !reportOutputDirectory.getAbsolutePath().endsWith( "xref-test" ) ) )
135 {
136 this.destDir = new File( reportOutputDirectory, "xref-test" ).getAbsolutePath();
137 }
138 else
139 {
140 this.destDir = reportOutputDirectory.getAbsolutePath();
141 }
142 }
143 }