| 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 | 9 | 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 | 9 | private Set includes = new HashSet(); |
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | 9 | private Set excludes = new HashSet(); |
| 97 | |
|
| 98 | |
protected List getCompileSourceRoots() |
| 99 | |
{ |
| 100 | 27 | return compileSourceRoots; |
| 101 | |
} |
| 102 | |
|
| 103 | |
protected List getClasspathElements() |
| 104 | |
{ |
| 105 | 21 | return classpathElements; |
| 106 | |
} |
| 107 | |
|
| 108 | |
protected File getOutputDirectory() |
| 109 | |
{ |
| 110 | 34 | return outputDirectory; |
| 111 | |
} |
| 112 | |
|
| 113 | |
public void execute() |
| 114 | |
throws MojoExecutionException, CompilationFailureException |
| 115 | |
{ |
| 116 | 9 | super.execute(); |
| 117 | |
|
| 118 | 8 | projectArtifact.setFile( outputDirectory ); |
| 119 | 8 | } |
| 120 | |
|
| 121 | |
protected SourceInclusionScanner getSourceInclusionScanner( int staleMillis ) |
| 122 | |
{ |
| 123 | 8 | SourceInclusionScanner scanner = null; |
| 124 | |
|
| 125 | 8 | if ( includes.isEmpty() && excludes.isEmpty() ) |
| 126 | |
{ |
| 127 | 6 | scanner = new StaleSourceScanner( staleMillis ); |
| 128 | |
} |
| 129 | |
else |
| 130 | |
{ |
| 131 | 2 | if ( includes.isEmpty() ) |
| 132 | |
{ |
| 133 | 0 | includes.add( "**/*.java" ); |
| 134 | |
} |
| 135 | 2 | scanner = new StaleSourceScanner( staleMillis, includes, excludes ); |
| 136 | |
} |
| 137 | |
|
| 138 | 8 | return scanner; |
| 139 | |
} |
| 140 | |
|
| 141 | |
protected SourceInclusionScanner getSourceInclusionScanner( String inputFileEnding ) |
| 142 | |
{ |
| 143 | 5 | SourceInclusionScanner scanner = null; |
| 144 | |
|
| 145 | 5 | if ( includes.isEmpty() && excludes.isEmpty() ) |
| 146 | |
{ |
| 147 | 4 | includes = Collections.singleton( "**/*." + inputFileEnding ); |
| 148 | 4 | scanner = new SimpleSourceInclusionScanner( includes, Collections.EMPTY_SET ); |
| 149 | |
} |
| 150 | |
else |
| 151 | |
{ |
| 152 | 1 | if ( includes.isEmpty() ) |
| 153 | |
{ |
| 154 | 0 | includes.add( "**/*." + inputFileEnding ); |
| 155 | |
} |
| 156 | 1 | scanner = new SimpleSourceInclusionScanner( includes, excludes ); |
| 157 | |
} |
| 158 | |
|
| 159 | 5 | return scanner; |
| 160 | |
} |
| 161 | |
|
| 162 | |
protected String getSource() |
| 163 | |
{ |
| 164 | 8 | return source; |
| 165 | |
} |
| 166 | |
|
| 167 | |
protected String getTarget() |
| 168 | |
{ |
| 169 | 8 | return target; |
| 170 | |
} |
| 171 | |
|
| 172 | |
protected String getCompilerArgument() |
| 173 | |
{ |
| 174 | 8 | return compilerArgument; |
| 175 | |
} |
| 176 | |
|
| 177 | |
protected Map getCompilerArguments() |
| 178 | |
{ |
| 179 | 8 | return compilerArguments; |
| 180 | |
} |
| 181 | |
|
| 182 | |
} |