1 package org.apache.maven.plugin;
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.artifact.Artifact;
23 import org.codehaus.plexus.compiler.util.scan.SimpleSourceInclusionScanner;
24 import org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner;
25 import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner;
26
27 import java.io.File;
28 import java.util.Collections;
29 import java.util.HashSet;
30 import java.util.List;
31 import java.util.Map;
32 import java.util.Set;
33
34
35
36
37
38
39
40
41
42
43
44 public class CompilerMojo
45 extends AbstractCompilerMojo
46 {
47
48
49
50
51
52
53
54 private List compileSourceRoots;
55
56
57
58
59
60
61
62
63 private List classpathElements;
64
65
66
67
68
69
70
71
72 private File outputDirectory;
73
74
75
76
77
78
79
80
81
82 private Artifact projectArtifact;
83
84
85
86
87
88
89 private Set includes = new HashSet();
90
91
92
93
94
95
96 private Set excludes = new HashSet();
97
98 protected List getCompileSourceRoots()
99 {
100 return compileSourceRoots;
101 }
102
103 protected List getClasspathElements()
104 {
105 return classpathElements;
106 }
107
108 protected File getOutputDirectory()
109 {
110 return outputDirectory;
111 }
112
113 public void execute()
114 throws MojoExecutionException, CompilationFailureException
115 {
116 super.execute();
117
118 projectArtifact.setFile( outputDirectory );
119 }
120
121 protected SourceInclusionScanner getSourceInclusionScanner( int staleMillis )
122 {
123 SourceInclusionScanner scanner = null;
124
125 if ( includes.isEmpty() && excludes.isEmpty() )
126 {
127 scanner = new StaleSourceScanner( staleMillis );
128 }
129 else
130 {
131 if ( includes.isEmpty() )
132 {
133 includes.add( "**/*.java" );
134 }
135 scanner = new StaleSourceScanner( staleMillis, includes, excludes );
136 }
137
138 return scanner;
139 }
140
141 protected SourceInclusionScanner getSourceInclusionScanner( String inputFileEnding )
142 {
143 SourceInclusionScanner scanner = null;
144
145 if ( includes.isEmpty() && excludes.isEmpty() )
146 {
147 includes = Collections.singleton( "**/*." + inputFileEnding );
148 scanner = new SimpleSourceInclusionScanner( includes, Collections.EMPTY_SET );
149 }
150 else
151 {
152 if ( includes.isEmpty() )
153 {
154 includes.add( "**/*." + inputFileEnding );
155 }
156 scanner = new SimpleSourceInclusionScanner( includes, excludes );
157 }
158
159 return scanner;
160 }
161
162 protected String getSource()
163 {
164 return source;
165 }
166
167 protected String getTarget()
168 {
169 return target;
170 }
171
172 protected String getCompilerArgument()
173 {
174 return compilerArgument;
175 }
176
177 protected Map getCompilerArguments()
178 {
179 return compilerArguments;
180 }
181
182 }