diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/AbstractCompiler.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/AbstractCompiler.java index 7565f365..40e6a8e0 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/AbstractCompiler.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/AbstractCompiler.java @@ -23,29 +23,26 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - -import org.codehaus.plexus.util.DirectoryScanner; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.File; import java.io.IOException; import java.util.HashSet; import java.util.List; import java.util.Set; +import org.codehaus.plexus.util.DirectoryScanner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * @author Jason van Zyl * @author Michal Maczka * @author Trygve Laugstøl */ -public abstract class AbstractCompiler - implements Compiler -{ - protected Logger log = LoggerFactory.getLogger ( getClass() ); +public abstract class AbstractCompiler implements Compiler { + protected Logger log = LoggerFactory.getLogger(getClass()); protected static final String EOL = System.lineSeparator(); - protected static final String PS = System.getProperty( "path.separator" ); + protected static final String PS = System.getProperty("path.separator"); private final CompilerOutputStyle compilerOutputStyle; @@ -59,9 +56,11 @@ public abstract class AbstractCompiler // // ---------------------------------------------------------------------- - protected AbstractCompiler( CompilerOutputStyle compilerOutputStyle, String inputFileEnding, - String outputFileEnding, String outputFile ) - { + protected AbstractCompiler( + CompilerOutputStyle compilerOutputStyle, + String inputFileEnding, + String outputFileEnding, + String outputFile) { this.compilerOutputStyle = compilerOutputStyle; this.inputFileEnding = inputFileEnding; @@ -77,48 +76,35 @@ protected AbstractCompiler( CompilerOutputStyle compilerOutputStyle, String inpu public abstract String getCompilerId(); - public CompilerResult performCompile(CompilerConfiguration configuration) - throws CompilerException - { + public CompilerResult performCompile(CompilerConfiguration configuration) throws CompilerException { throw new CompilerNotImplementedException("The performCompile method has not been implemented."); } - public CompilerOutputStyle getCompilerOutputStyle() - { + public CompilerOutputStyle getCompilerOutputStyle() { return compilerOutputStyle; } - public String getInputFileEnding( CompilerConfiguration configuration ) - throws CompilerException - { + public String getInputFileEnding(CompilerConfiguration configuration) throws CompilerException { return inputFileEnding; } - public String getOutputFileEnding( CompilerConfiguration configuration ) - throws CompilerException - { - if ( compilerOutputStyle != CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE ) - { - throw new RuntimeException( "This compiler implementation doesn't have one output file per input file." ); + public String getOutputFileEnding(CompilerConfiguration configuration) throws CompilerException { + if (compilerOutputStyle != CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE) { + throw new RuntimeException("This compiler implementation doesn't have one output file per input file."); } return outputFileEnding; } - public String getOutputFile( CompilerConfiguration configuration ) - throws CompilerException - { - if ( compilerOutputStyle != CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES ) - { - throw new RuntimeException( "This compiler implementation doesn't have one output file for all files." ); + public String getOutputFile(CompilerConfiguration configuration) throws CompilerException { + if (compilerOutputStyle != CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES) { + throw new RuntimeException("This compiler implementation doesn't have one output file for all files."); } return outputFile; } - public boolean canUpdateTarget( CompilerConfiguration configuration ) - throws CompilerException - { + public boolean canUpdateTarget(CompilerConfiguration configuration) throws CompilerException { return true; } @@ -126,42 +112,35 @@ public boolean canUpdateTarget( CompilerConfiguration configuration ) // Utility Methods // ---------------------------------------------------------------------- - public static String getPathString( List pathElements ) - { + public static String getPathString(List pathElements) { StringBuilder sb = new StringBuilder(); - for ( String pathElement : pathElements ) - { - sb.append( pathElement ).append( File.pathSeparator ); + for (String pathElement : pathElements) { + sb.append(pathElement).append(File.pathSeparator); } return sb.toString(); } - protected static Set getSourceFilesForSourceRoot( CompilerConfiguration config, String sourceLocation ) - { + protected static Set getSourceFilesForSourceRoot(CompilerConfiguration config, String sourceLocation) { DirectoryScanner scanner = new DirectoryScanner(); - scanner.setBasedir( sourceLocation ); + scanner.setBasedir(sourceLocation); Set includes = config.getIncludes(); - if ( includes != null && !includes.isEmpty() ) - { - String[] inclStrs = includes.toArray( new String[0] ); - scanner.setIncludes( inclStrs ); - } - else - { - scanner.setIncludes( new String[]{ "**/*.java" } ); + if (includes != null && !includes.isEmpty()) { + String[] inclStrs = includes.toArray(new String[0]); + scanner.setIncludes(inclStrs); + } else { + scanner.setIncludes(new String[] {"**/*.java"}); } Set excludes = config.getExcludes(); - if ( excludes != null && !excludes.isEmpty() ) - { - String[] exclStrs = excludes.toArray( new String[0] ); - scanner.setExcludes( exclStrs ); + if (excludes != null && !excludes.isEmpty()) { + String[] exclStrs = excludes.toArray(new String[0]); + scanner.setExcludes(exclStrs); } scanner.scan(); @@ -170,125 +149,105 @@ protected static Set getSourceFilesForSourceRoot( CompilerConfiguration Set sources = new HashSet<>(); - for ( String sourceDirectorySource : sourceDirectorySources ) - { - File f = new File( sourceLocation, sourceDirectorySource ); + for (String sourceDirectorySource : sourceDirectorySources) { + File f = new File(sourceLocation, sourceDirectorySource); - sources.add( f.getPath() ); + sources.add(f.getPath()); } return sources; } - protected static String[] getSourceFiles( CompilerConfiguration config ) - { + protected static String[] getSourceFiles(CompilerConfiguration config) { Set sources = new HashSet<>(); Set sourceFiles = config.getSourceFiles(); - if ( sourceFiles != null && !sourceFiles.isEmpty() ) - { - for ( File sourceFile : sourceFiles ) - { - sources.add( sourceFile.getAbsolutePath() ); + if (sourceFiles != null && !sourceFiles.isEmpty()) { + for (File sourceFile : sourceFiles) { + sources.add(sourceFile.getAbsolutePath()); } - } - else - { - for ( String sourceLocation : config.getSourceLocations() ) - { - sources.addAll( getSourceFilesForSourceRoot( config, sourceLocation ) ); + } else { + for (String sourceLocation : config.getSourceLocations()) { + sources.addAll(getSourceFilesForSourceRoot(config, sourceLocation)); } } String[] result; - if ( sources.isEmpty() ) - { + if (sources.isEmpty()) { result = new String[0]; - } - else - { - result = sources.toArray( new String[0] ); + } else { + result = sources.toArray(new String[0]); } return result; } - protected static String makeClassName( String fileName, String sourceDir ) - throws CompilerException - { - File origFile = new File( fileName ); + protected static String makeClassName(String fileName, String sourceDir) throws CompilerException { + File origFile = new File(fileName); String canonical = null; - if ( origFile.exists() ) - { - canonical = getCanonicalPath( origFile ).replace( '\\', '/' ); + if (origFile.exists()) { + canonical = getCanonicalPath(origFile).replace('\\', '/'); } - if ( sourceDir != null ) - { - String prefix = getCanonicalPath( new File( sourceDir ) ).replace( '\\', '/' ); + if (sourceDir != null) { + String prefix = getCanonicalPath(new File(sourceDir)).replace('\\', '/'); - if ( canonical != null ) - { - if ( canonical.startsWith( prefix ) ) - { - String result = canonical.substring( prefix.length() + 1, canonical.length() - 5 ); + if (canonical != null) { + if (canonical.startsWith(prefix)) { + String result = canonical.substring(prefix.length() + 1, canonical.length() - 5); - result = result.replace( '/', '.' ); + result = result.replace('/', '.'); return result; } - } - else - { - File t = new File( sourceDir, fileName ); + } else { + File t = new File(sourceDir, fileName); - if ( t.exists() ) - { - String str = getCanonicalPath( t ).replace( '\\', '/' ); + if (t.exists()) { + String str = getCanonicalPath(t).replace('\\', '/'); - return str.substring( prefix.length() + 1, str.length() - 5 ).replace( '/', '.' ); + return str.substring(prefix.length() + 1, str.length() - 5).replace('/', '.'); } } } - if ( fileName.endsWith( ".java" ) ) - { - fileName = fileName.substring( 0, fileName.length() - 5 ); + if (fileName.endsWith(".java")) { + fileName = fileName.substring(0, fileName.length() - 5); } - fileName = fileName.replace( '\\', '.' ); + fileName = fileName.replace('\\', '.'); - return fileName.replace( '/', '.' ); + return fileName.replace('/', '.'); } - private static String getCanonicalPath( File origFile ) - throws CompilerException - { - try - { + private static String getCanonicalPath(File origFile) throws CompilerException { + try { return origFile.getCanonicalPath(); - } - catch ( IOException e ) - { + } catch (IOException e) { throw new CompilerException( - "Error while getting the canonical path of '" + origFile.getAbsolutePath() + "'.", e ); + "Error while getting the canonical path of '" + origFile.getAbsolutePath() + "'.", e); } } - protected void logCompiling( String[] sourceFiles, CompilerConfiguration config ) - { - if ( log.isInfoEnabled() ) - { - String to = ( config.getWorkingDirectory() == null ) ? config.getOutputLocation() : - config.getWorkingDirectory().toPath().relativize( new File( config.getOutputLocation() ).toPath() ).toString(); - log.info( "Compiling " + - ( sourceFiles == null ? "" : ( sourceFiles.length + " source file" + ( sourceFiles.length == 1 ? " " : "s " ) ) ) + - "with " + getCompilerId() + " [" + config.describe() + "]" + - " to " + to ); + protected void logCompiling(String[] sourceFiles, CompilerConfiguration config) { + if (log.isInfoEnabled()) { + String to = (config.getWorkingDirectory() == null) + ? config.getOutputLocation() + : config.getWorkingDirectory() + .toPath() + .relativize(new File(config.getOutputLocation()).toPath()) + .toString(); + log.info("Compiling " + + (sourceFiles == null + ? "" + : (sourceFiles.length + " source file" + (sourceFiles.length == 1 ? " " : "s "))) + + "with " + + getCompilerId() + " [" + config.describe() + "]" + " to " + + to); } - } + } } diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/Compiler.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/Compiler.java index e576313f..e1579d27 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/Compiler.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/Compiler.java @@ -24,44 +24,36 @@ * SOFTWARE. */ -import java.util.List; - /** * The interface of an compiling language processor (aka compiler). - * + * * @author Jason van Zyl * @author Trygve Laugstøl * @author Matthew Pocock */ -public interface Compiler -{ +public interface Compiler { String ROLE = Compiler.class.getName(); CompilerOutputStyle getCompilerOutputStyle(); - String getInputFileEnding( CompilerConfiguration configuration ) - throws CompilerException; + String getInputFileEnding(CompilerConfiguration configuration) throws CompilerException; - String getOutputFileEnding( CompilerConfiguration configuration ) - throws CompilerException; + String getOutputFileEnding(CompilerConfiguration configuration) throws CompilerException; - String getOutputFile( CompilerConfiguration configuration ) - throws CompilerException; + String getOutputFile(CompilerConfiguration configuration) throws CompilerException; - boolean canUpdateTarget( CompilerConfiguration configuration ) - throws CompilerException; + boolean canUpdateTarget(CompilerConfiguration configuration) throws CompilerException; /** * Performs the compilation of the project. Clients must implement this * method. - * + * * @param configuration the configuration description of the compilation * to perform * @return the result of the compilation returned by the language processor * @throws CompilerException */ - CompilerResult performCompile( CompilerConfiguration configuration ) - throws CompilerException; + CompilerResult performCompile(CompilerConfiguration configuration) throws CompilerException; /** * Create the command line that would be executed using this configuration. @@ -74,15 +66,13 @@ CompilerResult performCompile( CompilerConfiguration configuration ) * @throws CompilerException if there was an error generating the command * line */ - String[] createCommandLine( CompilerConfiguration config ) - throws CompilerException; - + String[] createCommandLine(CompilerConfiguration config) throws CompilerException; /** * Based on this flag the caller can decide the strategy how to compile. E.g. is incrementCompilation is not supported, * it could decide to clear to outputDirectory to enforce a complete recompilation. - * - * @return {@code true} if incrementalCompilation is supported, otherwise {@code false} + * + * @return {@code true} if incrementalCompilation is supported, otherwise {@code false} */ default boolean supportsIncrementalCompilation() { return false; diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerConfiguration.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerConfiguration.java index 3089cbb5..9ff586b7 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerConfiguration.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerConfiguration.java @@ -23,9 +23,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - -import org.codehaus.plexus.util.StringUtils; - import java.io.File; import java.util.AbstractMap; import java.util.ArrayList; @@ -38,11 +35,12 @@ import java.util.Map; import java.util.Set; +import org.codehaus.plexus.util.StringUtils; + /** * @author jdcasey */ -public class CompilerConfiguration -{ +public class CompilerConfiguration { private String outputLocation; private List classpathEntries = new LinkedList<>(); @@ -72,7 +70,7 @@ public class CompilerConfiguration private boolean showWarnings = true; private String warnings; - + private boolean showLint; /** @@ -98,7 +96,7 @@ public class CompilerConfiguration */ private String moduleVersion; - private Collection> customCompilerArguments = new ArrayList<>(); + private Collection> customCompilerArguments = new ArrayList<>(); private boolean fork; @@ -172,7 +170,7 @@ public class CompilerConfiguration * force usage of old JavacCompiler even if javax.tools is detected * @since 2.0 */ - private boolean forceJavacCompilerUse=false; + private boolean forceJavacCompilerUse = false; /** * force a different of the debug file containing the forked command run (such javac.sh) @@ -192,13 +190,11 @@ public class CompilerConfiguration // // ---------------------------------------------------------------------- - public void setOutputLocation( String outputLocation ) - { + public void setOutputLocation(String outputLocation) { this.outputLocation = outputLocation; } - public String getOutputLocation() - { + public String getOutputLocation() { return outputLocation; } @@ -206,270 +202,208 @@ public String getOutputLocation() // Class path // ---------------------------------------------------------------------- - public void addClasspathEntry( String classpathEntry ) - { - classpathEntries.add( classpathEntry ); + public void addClasspathEntry(String classpathEntry) { + classpathEntries.add(classpathEntry); } - public void setClasspathEntries( List classpathEntries ) - { - if ( classpathEntries == null ) - { + public void setClasspathEntries(List classpathEntries) { + if (classpathEntries == null) { this.classpathEntries = Collections.emptyList(); - } - else - { - this.classpathEntries = new LinkedList<>( classpathEntries ); + } else { + this.classpathEntries = new LinkedList<>(classpathEntries); } } - public List getClasspathEntries() - { - return Collections.unmodifiableList( classpathEntries ); + public List getClasspathEntries() { + return Collections.unmodifiableList(classpathEntries); } // ---------------------------------------------------------------------- // Module path // ---------------------------------------------------------------------- - public void addModulepathEntry( String modulepathEntry ) - { - modulepathEntries.add( modulepathEntry ); + public void addModulepathEntry(String modulepathEntry) { + modulepathEntries.add(modulepathEntry); } - public void setModulepathEntries( List modulepathEntries ) - { - if ( modulepathEntries == null ) - { + public void setModulepathEntries(List modulepathEntries) { + if (modulepathEntries == null) { this.modulepathEntries = Collections.emptyList(); - } - else - { - this.modulepathEntries = new LinkedList<>( modulepathEntries ); + } else { + this.modulepathEntries = new LinkedList<>(modulepathEntries); } } - public List getModulepathEntries() - { - return Collections.unmodifiableList( modulepathEntries ); + public List getModulepathEntries() { + return Collections.unmodifiableList(modulepathEntries); } // ---------------------------------------------------------------------- // Source files // ---------------------------------------------------------------------- - public void setSourceFiles( Set sourceFiles ) - { - if ( sourceFiles == null ) - { + public void setSourceFiles(Set sourceFiles) { + if (sourceFiles == null) { this.sourceFiles = Collections.emptySet(); - } - else - { - this.sourceFiles = new HashSet<>( sourceFiles ); + } else { + this.sourceFiles = new HashSet<>(sourceFiles); } } - public Set getSourceFiles() - { + public Set getSourceFiles() { return sourceFiles; } - public void addSourceLocation( String sourceLocation ) - { - sourceLocations.add( sourceLocation ); + public void addSourceLocation(String sourceLocation) { + sourceLocations.add(sourceLocation); } - public void setSourceLocations( List sourceLocations ) - { - if ( sourceLocations == null ) - { + public void setSourceLocations(List sourceLocations) { + if (sourceLocations == null) { this.sourceLocations = Collections.emptyList(); - } - else - { - this.sourceLocations = new LinkedList<>( sourceLocations ); + } else { + this.sourceLocations = new LinkedList<>(sourceLocations); } } - public List getSourceLocations() - { - return Collections.unmodifiableList( sourceLocations ); + public List getSourceLocations() { + return Collections.unmodifiableList(sourceLocations); } - public void addInclude( String include ) - { - includes.add( include ); + public void addInclude(String include) { + includes.add(include); } - public void setIncludes( Set includes ) - { - if ( includes == null ) - { + public void setIncludes(Set includes) { + if (includes == null) { this.includes = Collections.emptySet(); - } - else - { - this.includes = new HashSet<>( includes ); + } else { + this.includes = new HashSet<>(includes); } } - public Set getIncludes() - { - return Collections.unmodifiableSet( includes ); + public Set getIncludes() { + return Collections.unmodifiableSet(includes); } - public void addExclude( String exclude ) - { - excludes.add( exclude ); + public void addExclude(String exclude) { + excludes.add(exclude); } - public void setExcludes( Set excludes ) - { - if ( excludes == null ) - { + public void setExcludes(Set excludes) { + if (excludes == null) { this.excludes = Collections.emptySet(); - } - else - { - this.excludes = new HashSet<>( excludes ); + } else { + this.excludes = new HashSet<>(excludes); } } - public Set getExcludes() - { - return Collections.unmodifiableSet( excludes ); + public Set getExcludes() { + return Collections.unmodifiableSet(excludes); } // ---------------------------------------------------------------------- // Compiler Settings // ---------------------------------------------------------------------- - public void setDebug( boolean debug ) - { + public void setDebug(boolean debug) { this.debug = debug; } - public boolean isDebug() - { + public boolean isDebug() { return debug; } - public void setDebugLevel( String debugLevel ) - { + public void setDebugLevel(String debugLevel) { this.debugLevel = debugLevel; } - public String getDebugLevel() - { + public String getDebugLevel() { return debugLevel; } - public void setWarnings( String warnings ) - { + public void setWarnings(String warnings) { this.warnings = warnings; } - public boolean isShowWarnings() - { + public boolean isShowWarnings() { return showWarnings; } - public void setShowWarnings( boolean showWarnings ) - { + public void setShowWarnings(boolean showWarnings) { this.showWarnings = showWarnings; } - public boolean isShowDeprecation() - { + public boolean isShowDeprecation() { return showDeprecation; } - public String getWarnings() - { + public String getWarnings() { return warnings; } - - - public void setShowLint( boolean showLint ) - { + public void setShowLint(boolean showLint) { this.showLint = showLint; } - public boolean isShowLint() - { + public boolean isShowLint() { return this.showLint; } - public void setShowDeprecation( boolean showDeprecation ) - { + public void setShowDeprecation(boolean showDeprecation) { this.showDeprecation = showDeprecation; } - public boolean isFailOnWarning() - { + public boolean isFailOnWarning() { return failOnWarning; } - public void setFailOnWarning( boolean failOnWarnings ) - { + public void setFailOnWarning(boolean failOnWarnings) { this.failOnWarning = failOnWarnings; } - public String getSourceVersion() - { + public String getSourceVersion() { return sourceVersion; } - public void setSourceVersion( String sourceVersion ) - { + public void setSourceVersion(String sourceVersion) { this.sourceVersion = sourceVersion; } - public String getTargetVersion() - { + public String getTargetVersion() { return targetVersion; } - public void setTargetVersion( String targetVersion ) - { + public void setTargetVersion(String targetVersion) { this.targetVersion = targetVersion; } - public String getReleaseVersion() - { + public String getReleaseVersion() { return releaseVersion; } - public void setReleaseVersion( String releaseVersion ) - { + public void setReleaseVersion(String releaseVersion) { this.releaseVersion = releaseVersion; } - public String getSourceEncoding() - { + public String getSourceEncoding() { return sourceEncoding; } - public void setSourceEncoding( String sourceEncoding ) - { + public void setSourceEncoding(String sourceEncoding) { this.sourceEncoding = sourceEncoding; } - public String getModuleVersion() - { + public String getModuleVersion() { return moduleVersion; } - public void setModuleVersion( String moduleVersion ) - { + public void setModuleVersion(String moduleVersion) { this.moduleVersion = moduleVersion; } - public void addCompilerCustomArgument( String customArgument, String value ) - { - customCompilerArguments.add( new AbstractMap.SimpleImmutableEntry<>( customArgument, value ) ); + public void addCompilerCustomArgument(String customArgument, String value) { + customCompilerArguments.add(new AbstractMap.SimpleImmutableEntry<>(customArgument, value)); } /** @@ -478,22 +412,18 @@ public void addCompilerCustomArgument( String customArgument, String value ) * @return * @see CompilerConfiguration#getCustomCompilerArgumentsEntries() */ - public Map getCustomCompilerArgumentsAsMap() - { - LinkedHashMap arguments = new LinkedHashMap<>( customCompilerArguments.size() ); - for ( Map.Entry entry : customCompilerArguments ) - { - arguments.put( entry.getKey(), entry.getValue() ); + public Map getCustomCompilerArgumentsAsMap() { + LinkedHashMap arguments = new LinkedHashMap<>(customCompilerArguments.size()); + for (Map.Entry entry : customCompilerArguments) { + arguments.put(entry.getKey(), entry.getValue()); } return arguments; } - public void setCustomCompilerArgumentsAsMap( Map customCompilerArguments ) - { + public void setCustomCompilerArgumentsAsMap(Map customCompilerArguments) { this.customCompilerArguments = new ArrayList<>(); - if ( customCompilerArguments != null ) - { - this.customCompilerArguments.addAll( customCompilerArguments.entrySet() ); + if (customCompilerArguments != null) { + this.customCompilerArguments.addAll(customCompilerArguments.entrySet()); } } @@ -502,158 +432,127 @@ public void setCustomCompilerArgumentsAsMap( Map customCompilerA * * @return */ - public Collection> getCustomCompilerArgumentsEntries() - { + public Collection> getCustomCompilerArgumentsEntries() { return customCompilerArguments; } - public boolean isFork() - { + public boolean isFork() { return fork; } - public void setFork( boolean fork ) - { + public void setFork(boolean fork) { this.fork = fork; } - public String getMeminitial() - { + public String getMeminitial() { return meminitial; } - public void setMeminitial( String meminitial ) - { + public void setMeminitial(String meminitial) { this.meminitial = meminitial; } - public String getMaxmem() - { + public String getMaxmem() { return maxmem; } - public void setMaxmem( String maxmem ) - { + public void setMaxmem(String maxmem) { this.maxmem = maxmem; } - public String getExecutable() - { + public String getExecutable() { return executable; } - public void setExecutable( String executable ) - { + public void setExecutable(String executable) { this.executable = executable; } - public File getWorkingDirectory() - { + public File getWorkingDirectory() { return workingDirectory; } - public void setWorkingDirectory( File workingDirectory ) - { + public void setWorkingDirectory(File workingDirectory) { this.workingDirectory = workingDirectory; } - public File getBuildDirectory() - { + public File getBuildDirectory() { return buildDirectory; } - public void setBuildDirectory( File buildDirectory ) - { + public void setBuildDirectory(File buildDirectory) { this.buildDirectory = buildDirectory; } - public String getOutputFileName() - { + public String getOutputFileName() { return outputFileName; } - public void setOutputFileName( String outputFileName ) - { + public void setOutputFileName(String outputFileName) { this.outputFileName = outputFileName; } - public boolean isOptimize() - { + public boolean isOptimize() { return optimize; } - public void setOptimize( boolean optimize ) - { + public void setOptimize(boolean optimize) { this.optimize = optimize; } - public String getCompilerVersion() - { + public String getCompilerVersion() { return compilerVersion; } - public void setCompilerVersion( String compilerVersion ) - { + public void setCompilerVersion(String compilerVersion) { this.compilerVersion = compilerVersion; } - public boolean isVerbose() - { + public boolean isVerbose() { return verbose; } - public void setVerbose( boolean verbose ) - { + public void setVerbose(boolean verbose) { this.verbose = verbose; } - public boolean isParameters() - { + public boolean isParameters() { return parameters; } - public void setParameters(boolean parameters) - { + public void setParameters(boolean parameters) { this.parameters = parameters; } - public boolean isEnablePreview() - { + public boolean isEnablePreview() { return enablePreview; } - public void setEnablePreview(boolean enablePreview) - { + public void setEnablePreview(boolean enablePreview) { this.enablePreview = enablePreview; } - public void setProc(String proc ) - { + public void setProc(String proc) { this.proc = proc; } - public void setGeneratedSourcesDirectory( File generatedSourcesDirectory ) - { + public void setGeneratedSourcesDirectory(File generatedSourcesDirectory) { this.generatedSourcesDirectory = generatedSourcesDirectory; } - public File getGeneratedSourcesDirectory() - { + public File getGeneratedSourcesDirectory() { return generatedSourcesDirectory; } - public String getProc() - { + public String getProc() { return proc; } - public void setAnnotationProcessors( String[] annotationProcessors ) - { + public void setAnnotationProcessors(String[] annotationProcessors) { this.annotationProcessors = annotationProcessors; } - public String[] getAnnotationProcessors() - { + public String[] getAnnotationProcessors() { return annotationProcessors; } @@ -664,11 +563,11 @@ public String[] getAnnotationProcessors() * @param entry processor path entry to add */ public void addProcessorPathEntry(String entry) { - if ( processorPathEntries == null ) { + if (processorPathEntries == null) { processorPathEntries = new LinkedList<>(); } - processorPathEntries.add( entry ); + processorPathEntries.add(entry); } /** @@ -691,152 +590,123 @@ public void setProcessorPathEntries(List processorPathEntries) { this.processorPathEntries = processorPathEntries; } - public void addProcessorModulePathEntry(String entry) { - if ( processorModulePathEntries == null ) { + if (processorModulePathEntries == null) { processorModulePathEntries = new LinkedList<>(); } - processorModulePathEntries.add( entry ); + processorModulePathEntries.add(entry); } - - public List getProcessorModulePathEntries() - { + + public List getProcessorModulePathEntries() { return processorModulePathEntries; } - - public void setProcessorModulePathEntries( List processorModulePathEntries ) - { + + public void setProcessorModulePathEntries(List processorModulePathEntries) { this.processorModulePathEntries = processorModulePathEntries; } - - - public CompilerReuseStrategy getCompilerReuseStrategy() - { + + public CompilerReuseStrategy getCompilerReuseStrategy() { return compilerReuseStrategy; } - public void setCompilerReuseStrategy( CompilerReuseStrategy compilerReuseStrategy ) - { + public void setCompilerReuseStrategy(CompilerReuseStrategy compilerReuseStrategy) { this.compilerReuseStrategy = compilerReuseStrategy; } - public String getDebugFileName() - { + public String getDebugFileName() { return debugFileName; } - public void setDebugFileName(String debugFileName) - { + public void setDebugFileName(String debugFileName) { this.debugFileName = debugFileName; } /** * Re-use strategy of the compiler (implement for java only). */ - public enum CompilerReuseStrategy - { + public enum CompilerReuseStrategy { /** * Always reuse the same. * Default strategy. */ - ReuseSame( "reuseSame" ), + ReuseSame("reuseSame"), /** * Re-create a new compiler for each use. */ - AlwaysNew( "alwaysNew" ), + AlwaysNew("alwaysNew"), /** * Re-use already created compiler, create new one if non already exists. * Will mimic a kind of pool to prevent different threads use the same. */ - ReuseCreated( "reuseCreated" ); + ReuseCreated("reuseCreated"); private String strategy; - CompilerReuseStrategy( String strategy ) - { + CompilerReuseStrategy(String strategy) { this.strategy = strategy; } - public String getStrategy() - { + public String getStrategy() { return strategy; } @Override - public String toString() - { + public String toString() { return "CompilerReuseStrategy:" + this.strategy; } } - public boolean isForceJavacCompilerUse() - { + public boolean isForceJavacCompilerUse() { return forceJavacCompilerUse; } - public void setForceJavacCompilerUse( boolean forceJavacCompilerUse ) - { + public void setForceJavacCompilerUse(boolean forceJavacCompilerUse) { this.forceJavacCompilerUse = forceJavacCompilerUse; } - public String getImplicitOption() - { + public String getImplicitOption() { return implicitOption; } - public void setImplicitOption( String implicitOption ) - { + public void setImplicitOption(String implicitOption) { this.implicitOption = implicitOption; } - public String describe() - { + public String describe() { List params = new ArrayList<>(); - if ( isFork() ) - { - params.add( "forked" ); + if (isFork()) { + params.add("forked"); } // base options: debug, optimize, verbose, deprecation - if ( isDebug() ) - { - if ( StringUtils.isNotEmpty( getDebugLevel() ) ) - { - params.add( "debug:" + getDebugLevel() ); - } - else - { - params.add( "debug" ); + if (isDebug()) { + if (StringUtils.isNotEmpty(getDebugLevel())) { + params.add("debug:" + getDebugLevel()); + } else { + params.add("debug"); } } - if ( isOptimize() ) - { - params.add( "optimize" ); + if (isOptimize()) { + params.add("optimize"); } - if ( isVerbose() ) - { - params.add( "verbose" ); + if (isVerbose()) { + params.add("verbose"); } - if ( isShowDeprecation() ) - { - params.add( "deprecation" ); + if (isShowDeprecation()) { + params.add("deprecation"); } // target bytecode options: release or target, module-path - if ( !StringUtils.isEmpty( getReleaseVersion() ) ) - { - params.add( "release " + getReleaseVersion() ); - } - else if ( !StringUtils.isEmpty( getTargetVersion() ) ) - { - params.add( "target " + getTargetVersion() ); + if (!StringUtils.isEmpty(getReleaseVersion())) { + params.add("release " + getReleaseVersion()); + } else if (!StringUtils.isEmpty(getTargetVersion())) { + params.add("target " + getTargetVersion()); } - if ( getModulepathEntries() != null && !getModulepathEntries().isEmpty() ) - { - params.add( "module-path" ); + if (getModulepathEntries() != null && !getModulepathEntries().isEmpty()) { + params.add("module-path"); } - return String.join( " ", params ); + return String.join(" ", params); } } diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerException.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerException.java index a8a9899c..abd77528 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerException.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerException.java @@ -27,16 +27,12 @@ /** * @author Trygve Laugstøl */ -public class CompilerException - extends Exception -{ - public CompilerException( String message ) - { - super( message ); +public class CompilerException extends Exception { + public CompilerException(String message) { + super(message); } - public CompilerException( String message, Throwable cause ) - { - super( message, cause ); + public CompilerException(String message, Throwable cause) { + super(message, cause); } } diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerMessage.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerMessage.java index 5ca5a659..e2c88080 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerMessage.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerMessage.java @@ -48,8 +48,7 @@ * @author Stefano Mazzocchi * @since 2.0 */ -public class CompilerMessage -{ +public class CompilerMessage { private static final String JDK_6_NOTE_PREFIX = "note: "; private static final String JDK_6_WARNING_PREFIX = "warning: "; @@ -89,7 +88,6 @@ public class CompilerMessage */ private final String message; - /** * Constructs a compiler message. * @@ -104,9 +102,14 @@ public class CompilerMessage * @deprecated Use {@link #CompilerMessage(String, Kind, int, int, int, int, String)} instead */ @Deprecated - public CompilerMessage( final String file, final boolean error, final int startline, final int startcolumn, final int endline, final int endcolumn, - final String message ) - { + public CompilerMessage( + final String file, + final boolean error, + final int startline, + final int startcolumn, + final int endline, + final int endcolumn, + final String message) { this.file = file; this.kind = error ? Kind.ERROR : Kind.WARNING; this.startline = startline; @@ -114,7 +117,7 @@ public CompilerMessage( final String file, final boolean error, final int startl this.endline = endline; this.endcolumn = endcolumn; - this.message = cleanupMessage( message ); + this.message = cleanupMessage(message); } /** @@ -128,16 +131,21 @@ public CompilerMessage( final String file, final boolean error, final int startl * @param endcolumn The end column number of the offending program text * @param message The actual message text produced by the language processor */ - public CompilerMessage( final String file, final Kind kind, final int startline, final int startcolumn, final int endline, final int endcolumn, - final String message ) - { + public CompilerMessage( + final String file, + final Kind kind, + final int startline, + final int startcolumn, + final int endline, + final int endcolumn, + final String message) { this.file = file; this.kind = kind; this.startline = startline; this.startcolumn = startcolumn; this.endline = endline; this.endcolumn = endcolumn; - this.message = cleanupMessage( message ); + this.message = cleanupMessage(message); } /** @@ -147,10 +155,9 @@ public CompilerMessage( final String file, final Kind kind, final int startline, * @deprecated Use {@link #CompilerMessage(String, Kind)} instead */ @Deprecated - public CompilerMessage( final String message ) - { + public CompilerMessage(final String message) { this.kind = Kind.WARNING; - this.message = cleanupMessage( message ); + this.message = cleanupMessage(message); } /** @@ -162,10 +169,9 @@ public CompilerMessage( final String message ) * @deprecated Use {@link #CompilerMessage(String, Kind)} instead */ @Deprecated - public CompilerMessage( final String message, final boolean error ) - { + public CompilerMessage(final String message, final boolean error) { this.kind = error ? Kind.ERROR : Kind.WARNING; - this.message = cleanupMessage( message ); + this.message = cleanupMessage(message); } /** @@ -175,10 +181,9 @@ public CompilerMessage( final String message, final boolean error ) * @param kind The kind of message * @since 2.0 */ - public CompilerMessage( final String message, final Kind kind ) - { + public CompilerMessage(final String message, final Kind kind) { this.kind = kind; - this.message = cleanupMessage( message ); + this.message = cleanupMessage(message); } /** @@ -186,8 +191,7 @@ public CompilerMessage( final String message, final Kind kind ) * * @return The filename associated with this compiler message */ - public String getFile() - { + public String getFile() { return file; } @@ -196,8 +200,7 @@ public String getFile() * * @return Whether the message is an error message */ - public boolean isError() - { + public boolean isError() { return kind == Kind.ERROR; } @@ -207,8 +210,7 @@ public boolean isError() * * @return The starting line number of the program text originating this message */ - public int getStartLine() - { + public int getStartLine() { return startline; } @@ -219,8 +221,7 @@ public int getStartLine() * @return The starting column number of the program text originating this * message */ - public int getStartColumn() - { + public int getStartColumn() { return startcolumn; } @@ -230,8 +231,7 @@ public int getStartColumn() * * @return The ending line number of the program text originating this message */ - public int getEndLine() - { + public int getEndLine() { return endline; } @@ -242,8 +242,7 @@ public int getEndLine() * @return The ending column number of the program text originating this * message */ - public int getEndColumn() - { + public int getEndColumn() { return endcolumn; } @@ -252,8 +251,7 @@ public int getEndColumn() * * @return The message produced by the language processor */ - public String getMessage() - { + public String getMessage() { return message; } @@ -263,49 +261,33 @@ public String getMessage() * @return the kind of the message * @since 2.0 */ - public Kind getKind() - { + public Kind getKind() { return kind; } @Override - public String toString() - { - if ( file != null ) - { - if ( startline != 0 ) - { - if ( startcolumn != 0 ) - { + public String toString() { + if (file != null) { + if (startline != 0) { + if (startcolumn != 0) { return file + ":" + "[" + startline + "," + startcolumn + "] " + message; - } - else - { + } else { return file + ":" + "[" + startline + "] " + message; } - } - else - { + } else { return file + ": " + message; } - } - else - { + } else { return message; } } - private String cleanupMessage( String msg ) - { - if ( kind == Kind.NOTE && msg.toLowerCase() - .startsWith( JDK_6_NOTE_PREFIX ) ) - { - msg = msg.substring( JDK_6_NOTE_PREFIX.length() ); - } - else if ( ( kind == Kind.WARNING || kind == Kind.MANDATORY_WARNING ) && msg.toLowerCase() - .startsWith( JDK_6_WARNING_PREFIX ) ) - { - msg = msg.substring( JDK_6_WARNING_PREFIX.length() ); + private String cleanupMessage(String msg) { + if (kind == Kind.NOTE && msg.toLowerCase().startsWith(JDK_6_NOTE_PREFIX)) { + msg = msg.substring(JDK_6_NOTE_PREFIX.length()); + } else if ((kind == Kind.WARNING || kind == Kind.MANDATORY_WARNING) + && msg.toLowerCase().startsWith(JDK_6_WARNING_PREFIX)) { + msg = msg.substring(JDK_6_WARNING_PREFIX.length()); } return msg; @@ -316,31 +298,28 @@ else if ( ( kind == Kind.WARNING || kind == Kind.MANDATORY_WARNING ) && msg.toLo * * @since 2.0 */ - public enum Kind - { + public enum Kind { /** * Problem which prevents the tool's normal completion. */ - ERROR( "error" ), + ERROR("error"), /** * Problem similar to a warning, but is mandated by the tool's specification. */ - MANDATORY_WARNING( "mandatory_warning" ), + MANDATORY_WARNING("mandatory_warning"), /** * Informative message from the tool. */ - NOTE( "note" ), + NOTE("note"), /** * Diagnostic which does not fit within the other kinds. */ - OTHER( "other" ), + OTHER("other"), /** * Problem which does not usually prevent the tool from completing normally. */ - WARNING( "warning" ); + WARNING("warning"); - Kind( String type ) - { - } + Kind(String type) {} } } diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerNotImplementedException.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerNotImplementedException.java index b74e233e..571cb6bc 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerNotImplementedException.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerNotImplementedException.java @@ -27,16 +27,12 @@ /** * @author Andrew Eisenberg */ -public class CompilerNotImplementedException - extends CompilerException -{ - public CompilerNotImplementedException( String message ) - { - super( message ); +public class CompilerNotImplementedException extends CompilerException { + public CompilerNotImplementedException(String message) { + super(message); } - public CompilerNotImplementedException( String message, Throwable cause ) - { - super( message, cause ); + public CompilerNotImplementedException(String message, Throwable cause) { + super(message, cause); } } diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerOutputStyle.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerOutputStyle.java index f7e0a280..f9080b21 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerOutputStyle.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerOutputStyle.java @@ -27,13 +27,12 @@ /** * @author Trygve Laugstøl */ -public final class CompilerOutputStyle -{ - public final static CompilerOutputStyle ONE_OUTPUT_FILE_PER_INPUT_FILE = - new CompilerOutputStyle( "one-output-file-per-input-file" ); +public final class CompilerOutputStyle { + public static final CompilerOutputStyle ONE_OUTPUT_FILE_PER_INPUT_FILE = + new CompilerOutputStyle("one-output-file-per-input-file"); - public final static CompilerOutputStyle ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES = - new CompilerOutputStyle( "one-output-file" ); + public static final CompilerOutputStyle ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES = + new CompilerOutputStyle("one-output-file"); // ---------------------------------------------------------------------- // @@ -41,8 +40,7 @@ public final class CompilerOutputStyle private String id; - private CompilerOutputStyle( String id ) - { + private CompilerOutputStyle(String id) { this.id = id; } @@ -50,23 +48,19 @@ private CompilerOutputStyle( String id ) // // ---------------------------------------------------------------------- - public String toString() - { + public String toString() { return id; } - public boolean equals( Object other ) - { - if ( !( other instanceof CompilerOutputStyle ) ) - { + public boolean equals(Object other) { + if (!(other instanceof CompilerOutputStyle)) { return false; } - return id.equals( ( (CompilerOutputStyle) other ).id ); + return id.equals(((CompilerOutputStyle) other).id); } - public int hashCode() - { + public int hashCode() { return id.hashCode(); } } diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerResult.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerResult.java index 97236b09..d559ae5c 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerResult.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerResult.java @@ -24,12 +24,11 @@ /** * The result returned from a compiling language processor (aka compiler), possibly including * some messages. - * + * * @author Olivier Lamy * @since 2.0 */ -public class CompilerResult -{ +public class CompilerResult { private boolean success; private List compilerMessages; @@ -37,56 +36,47 @@ public class CompilerResult /** * Constructs a successful compiler result with no messages. */ - public CompilerResult() - { + public CompilerResult() { this.success = true; } /** * Constructs a compiler result. - * + * * @param success if the compiler process was successful or not * @param compilerMessages a list of messages from the compiler process */ - public CompilerResult( boolean success, List compilerMessages ) - { + public CompilerResult(boolean success, List compilerMessages) { this.success = success; this.compilerMessages = compilerMessages; } - public boolean isSuccess() - { + public boolean isSuccess() { return success; } - public void setSuccess( boolean success ) - { + public void setSuccess(boolean success) { this.success = success; } - public CompilerResult success( boolean success ) - { - this.setSuccess( success ); + public CompilerResult success(boolean success) { + this.setSuccess(success); return this; } - public List getCompilerMessages() - { - if ( compilerMessages == null ) - { + public List getCompilerMessages() { + if (compilerMessages == null) { this.compilerMessages = new ArrayList<>(); } return compilerMessages; } - public void setCompilerMessages( List compilerMessages ) - { + public void setCompilerMessages(List compilerMessages) { this.compilerMessages = compilerMessages; } - public CompilerResult compilerMessages( List compilerMessages ) - { - this.setCompilerMessages( compilerMessages ); + public CompilerResult compilerMessages(List compilerMessages) { + this.setCompilerMessages(compilerMessages); return this; } } diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/StreamPumper.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/StreamPumper.java index fc13661d..4b968d40 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/StreamPumper.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/StreamPumper.java @@ -23,7 +23,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - import java.io.BufferedInputStream; import java.io.IOException; import java.io.OutputStream; @@ -31,9 +30,7 @@ /** * @author Jason van Zyl */ -public class StreamPumper - extends Thread -{ +public class StreamPumper extends Thread { private static final int BUFFER_SIZE = 512; private final BufferedInputStream stream; @@ -44,43 +41,31 @@ public class StreamPumper private final OutputStream out; - public StreamPumper( BufferedInputStream is, OutputStream out ) - { + public StreamPumper(BufferedInputStream is, OutputStream out) { this.stream = is; this.out = out; } - public void pumpStream() - throws IOException - { + public void pumpStream() throws IOException { byte[] buf = new byte[BUFFER_SIZE]; - if ( !endOfStream ) - { - int bytesRead = stream.read( buf, 0, BUFFER_SIZE ); + if (!endOfStream) { + int bytesRead = stream.read(buf, 0, BUFFER_SIZE); - if ( bytesRead > 0 ) - { - out.write( buf, 0, bytesRead ); - } - else if ( bytesRead == -1 ) - { + if (bytesRead > 0) { + out.write(buf, 0, bytesRead); + } else if (bytesRead == -1) { endOfStream = true; } } } - public void run() - { - try - { - while ( !endOfStream ) - { + public void run() { + try { + while (!endOfStream) { pumpStream(); - sleep( SLEEP_TIME ); + sleep(SLEEP_TIME); } - } - catch ( Exception e ) - { + } catch (Exception e) { // getLogger().warn("Jikes.run()", e); } } diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/AbstractSourceInclusionScanner.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/AbstractSourceInclusionScanner.java index 44af00a8..b9f89a41 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/AbstractSourceInclusionScanner.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/AbstractSourceInclusionScanner.java @@ -16,62 +16,51 @@ * limitations under the License. */ -import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping; -import org.codehaus.plexus.util.DirectoryScanner; - import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; +import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping; +import org.codehaus.plexus.util.DirectoryScanner; + /** * @author jdcasey */ -public abstract class AbstractSourceInclusionScanner - implements SourceInclusionScanner -{ +public abstract class AbstractSourceInclusionScanner implements SourceInclusionScanner { private final List sourceMappings = new ArrayList<>(); - public final void addSourceMapping( SourceMapping sourceMapping ) - { - sourceMappings.add( sourceMapping ); + public final void addSourceMapping(SourceMapping sourceMapping) { + sourceMappings.add(sourceMapping); } - protected final List getSourceMappings() - { - return Collections.unmodifiableList( sourceMappings ); + protected final List getSourceMappings() { + return Collections.unmodifiableList(sourceMappings); } - protected String[] scanForSources( File sourceDir, Set sourceIncludes, Set sourceExcludes ) - { + protected String[] scanForSources(File sourceDir, Set sourceIncludes, Set sourceExcludes) { DirectoryScanner ds = new DirectoryScanner(); - ds.setFollowSymlinks( true ); - ds.setBasedir( sourceDir ); + ds.setFollowSymlinks(true); + ds.setBasedir(sourceDir); String[] includes; - if ( sourceIncludes.isEmpty() ) - { + if (sourceIncludes.isEmpty()) { includes = new String[0]; - } - else - { - includes = sourceIncludes.toArray( new String[0] ); + } else { + includes = sourceIncludes.toArray(new String[0]); } - ds.setIncludes( includes ); + ds.setIncludes(includes); String[] excludes; - if ( sourceExcludes.isEmpty() ) - { + if (sourceExcludes.isEmpty()) { excludes = new String[0]; - } - else - { - excludes = sourceExcludes.toArray( new String[0] ); + } else { + excludes = sourceExcludes.toArray(new String[0]); } - ds.setExcludes( excludes ); + ds.setExcludes(excludes); ds.addDefaultExcludes(); ds.scan(); diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/InclusionScanException.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/InclusionScanException.java index 6b8c3a55..0e888b2d 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/InclusionScanException.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/InclusionScanException.java @@ -19,16 +19,12 @@ /** * @author jdcasey */ -public class InclusionScanException - extends Exception -{ - public InclusionScanException( String message ) - { - super( message ); +public class InclusionScanException extends Exception { + public InclusionScanException(String message) { + super(message); } - public InclusionScanException( String message, Throwable cause ) - { - super( message, cause ); + public InclusionScanException(String message, Throwable cause) { + super(message, cause); } } diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/SimpleSourceInclusionScanner.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/SimpleSourceInclusionScanner.java index a420a3a6..59d34aa1 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/SimpleSourceInclusionScanner.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/SimpleSourceInclusionScanner.java @@ -23,51 +23,42 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - -import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping; - import java.io.File; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; +import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping; + /** * @author Trygve Laugstøl */ -public class SimpleSourceInclusionScanner - extends AbstractSourceInclusionScanner -{ +public class SimpleSourceInclusionScanner extends AbstractSourceInclusionScanner { private final Set sourceIncludes; private final Set sourceExcludes; - public SimpleSourceInclusionScanner( Set sourceIncludes, Set sourceExcludes ) - { + public SimpleSourceInclusionScanner(Set sourceIncludes, Set sourceExcludes) { this.sourceIncludes = sourceIncludes; this.sourceExcludes = sourceExcludes; } - public Set getIncludedSources( File sourceDir, File targetDir ) - throws InclusionScanException - { + public Set getIncludedSources(File sourceDir, File targetDir) throws InclusionScanException { List srcMappings = getSourceMappings(); - if ( srcMappings.isEmpty() ) - { + if (srcMappings.isEmpty()) { return Collections.emptySet(); } - String[] potentialSources = scanForSources( sourceDir, sourceIncludes, sourceExcludes ); + String[] potentialSources = scanForSources(sourceDir, sourceIncludes, sourceExcludes); - Set matchingSources = new HashSet<>( potentialSources != null ? potentialSources.length : 0 ); + Set matchingSources = new HashSet<>(potentialSources != null ? potentialSources.length : 0); - if ( potentialSources != null ) - { - for ( String potentialSource : potentialSources ) - { - matchingSources.add( new File( sourceDir, potentialSource ) ); + if (potentialSources != null) { + for (String potentialSource : potentialSources) { + matchingSources.add(new File(sourceDir, potentialSource)); } } diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/SourceInclusionScanner.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/SourceInclusionScanner.java index c47b4c99..6d1c8f86 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/SourceInclusionScanner.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/SourceInclusionScanner.java @@ -14,17 +14,16 @@ * the License. */ -import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping; - import java.io.File; import java.util.Set; +import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping; + /** * @author jdcasey */ -public interface SourceInclusionScanner -{ - void addSourceMapping( SourceMapping sourceMapping ); +public interface SourceInclusionScanner { + void addSourceMapping(SourceMapping sourceMapping); /** * @param sourceDir @@ -32,6 +31,5 @@ public interface SourceInclusionScanner * @return Set of File objects * @throws InclusionScanException */ - Set getIncludedSources( File sourceDir, File targetDir ) - throws InclusionScanException; + Set getIncludedSources(File sourceDir, File targetDir) throws InclusionScanException; } diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/StaleSourceScanner.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/StaleSourceScanner.java index d255be5d..0d7a7985 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/StaleSourceScanner.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/StaleSourceScanner.java @@ -16,20 +16,18 @@ * limitations under the License. */ -import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping; - import java.io.File; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; +import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping; + /** * @author jdcasey */ -public class StaleSourceScanner - extends AbstractSourceInclusionScanner -{ +public class StaleSourceScanner extends AbstractSourceInclusionScanner { private final long lastUpdatedWithinMsecs; private final Set sourceIncludes; @@ -40,18 +38,15 @@ public class StaleSourceScanner // // ---------------------------------------------------------------------- - public StaleSourceScanner() - { - this( 0, Collections.singleton( "**/*" ), Collections.emptySet() ); + public StaleSourceScanner() { + this(0, Collections.singleton("**/*"), Collections.emptySet()); } - public StaleSourceScanner( long lastUpdatedWithinMsecs ) - { - this( lastUpdatedWithinMsecs, Collections.singleton( "**/*" ), Collections.emptySet() ); + public StaleSourceScanner(long lastUpdatedWithinMsecs) { + this(lastUpdatedWithinMsecs, Collections.singleton("**/*"), Collections.emptySet()); } - public StaleSourceScanner( long lastUpdatedWithinMsecs, Set sourceIncludes, Set sourceExcludes ) - { + public StaleSourceScanner(long lastUpdatedWithinMsecs, Set sourceIncludes, Set sourceExcludes) { this.lastUpdatedWithinMsecs = lastUpdatedWithinMsecs; this.sourceIncludes = sourceIncludes; @@ -63,38 +58,31 @@ public StaleSourceScanner( long lastUpdatedWithinMsecs, Set sourceInclud // SourceInclusionScanner Implementation // ---------------------------------------------------------------------- - public Set getIncludedSources( File sourceDir, File targetDir ) - throws InclusionScanException - { + public Set getIncludedSources(File sourceDir, File targetDir) throws InclusionScanException { List srcMappings = getSourceMappings(); - if ( srcMappings.isEmpty() ) - { + if (srcMappings.isEmpty()) { return Collections.emptySet(); } - String[] potentialIncludes = scanForSources( sourceDir, sourceIncludes, sourceExcludes ); + String[] potentialIncludes = scanForSources(sourceDir, sourceIncludes, sourceExcludes); Set matchingSources = new HashSet<>(); - for ( String path : potentialIncludes ) - { - File sourceFile = new File( sourceDir, path ); + for (String path : potentialIncludes) { + File sourceFile = new File(sourceDir, path); staleSourceFileTesting: - for ( SourceMapping mapping : srcMappings ) - { - Set targetFiles = mapping.getTargetFiles( targetDir, path ); + for (SourceMapping mapping : srcMappings) { + Set targetFiles = mapping.getTargetFiles(targetDir, path); // never include files that don't have corresponding target mappings. // the targets don't have to exist on the filesystem, but the // mappers must tell us to look for them. - for ( File targetFile : targetFiles ) - { - if ( !targetFile.exists() || ( targetFile.lastModified() + lastUpdatedWithinMsecs - < sourceFile.lastModified() ) ) - { - matchingSources.add( sourceFile ); + for (File targetFile : targetFiles) { + if (!targetFile.exists() + || (targetFile.lastModified() + lastUpdatedWithinMsecs < sourceFile.lastModified())) { + matchingSources.add(sourceFile); break staleSourceFileTesting; } } diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mapping/SingleTargetSourceMapping.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mapping/SingleTargetSourceMapping.java index c68ca279..d1d3dc1e 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mapping/SingleTargetSourceMapping.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mapping/SingleTargetSourceMapping.java @@ -23,40 +23,33 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +import java.io.File; +import java.util.Collections; +import java.util.Set; import org.codehaus.plexus.compiler.util.scan.InclusionScanException; -import java.util.Set; -import java.util.Collections; -import java.io.File; - /** * Maps a set of input files to a single output file. * * @author Trygve Laugstøl */ -public class SingleTargetSourceMapping - implements SourceMapping -{ +public class SingleTargetSourceMapping implements SourceMapping { private final String sourceSuffix; private final String outputFile; - public SingleTargetSourceMapping( String sourceSuffix, String outputFile ) - { + public SingleTargetSourceMapping(String sourceSuffix, String outputFile) { this.sourceSuffix = sourceSuffix; this.outputFile = outputFile; } - public Set getTargetFiles( File targetDir, String source ) - throws InclusionScanException - { - if ( !source.endsWith( sourceSuffix ) ) - { + public Set getTargetFiles(File targetDir, String source) throws InclusionScanException { + if (!source.endsWith(sourceSuffix)) { return Collections.emptySet(); } - return Collections.singleton( new File( targetDir, outputFile ) ); + return Collections.singleton(new File(targetDir, outputFile)); } } diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mapping/SourceMapping.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mapping/SourceMapping.java index 40d77ec4..1e91c61d 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mapping/SourceMapping.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mapping/SourceMapping.java @@ -16,16 +16,14 @@ * limitations under the License. */ -import org.codehaus.plexus.compiler.util.scan.InclusionScanException; - import java.io.File; import java.util.Set; +import org.codehaus.plexus.compiler.util.scan.InclusionScanException; + /** * @author jdcasey */ -public interface SourceMapping -{ - Set getTargetFiles( File targetDir, String source ) - throws InclusionScanException; +public interface SourceMapping { + Set getTargetFiles(File targetDir, String source) throws InclusionScanException; } diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mapping/SuffixMapping.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mapping/SuffixMapping.java index c744cf68..e11e53c2 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mapping/SuffixMapping.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mapping/SuffixMapping.java @@ -24,38 +24,31 @@ /** * @author jdcasey */ -public final class SuffixMapping - implements SourceMapping -{ +public final class SuffixMapping implements SourceMapping { private final String sourceSuffix; private final Set targetSuffixes; - public SuffixMapping( String sourceSuffix, String targetSuffix ) - { + public SuffixMapping(String sourceSuffix, String targetSuffix) { this.sourceSuffix = sourceSuffix; - this.targetSuffixes = Collections.singleton( targetSuffix ); + this.targetSuffixes = Collections.singleton(targetSuffix); } - public SuffixMapping( String sourceSuffix, Set targetSuffixes ) - { + public SuffixMapping(String sourceSuffix, Set targetSuffixes) { this.sourceSuffix = sourceSuffix; - this.targetSuffixes = Collections.unmodifiableSet( targetSuffixes ); + this.targetSuffixes = Collections.unmodifiableSet(targetSuffixes); } - public Set getTargetFiles( File targetDir, String source ) - { + public Set getTargetFiles(File targetDir, String source) { Set targetFiles = new HashSet<>(); - if ( source.endsWith( sourceSuffix ) ) - { - String base = source.substring( 0, source.length() - sourceSuffix.length() ); + if (source.endsWith(sourceSuffix)) { + String base = source.substring(0, source.length() - sourceSuffix.length()); - for ( String suffix : targetSuffixes ) - { - targetFiles.add( new File( targetDir, base + suffix ) ); + for (String suffix : targetSuffixes) { + targetFiles.add(new File(targetDir, base + suffix)); } } diff --git a/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/CompilerConfigurationTest.java b/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/CompilerConfigurationTest.java index d295b69b..53e0a9f8 100644 --- a/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/CompilerConfigurationTest.java +++ b/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/CompilerConfigurationTest.java @@ -1,44 +1,42 @@ package org.codehaus.plexus.compiler; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - import java.util.Iterator; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -public class CompilerConfigurationTest -{ +public class CompilerConfigurationTest { private CompilerConfiguration configuration; - @BeforeEach - protected void setUp() - throws Exception - { + protected void setUp() throws Exception { configuration = new CompilerConfiguration(); } @Test - public void testCustomArguments() - { - configuration.addCompilerCustomArgument( "--add-exports", "FROM-MOD/package1=OTHER-MOD" ); - configuration.addCompilerCustomArgument( "--add-exports", "FROM-MOD/package2=OTHER-MOD" ); - - assertThat(configuration.getCustomCompilerArgumentsAsMap().size(), is( 1 )); - assertThat( configuration.getCustomCompilerArgumentsAsMap().get( "--add-exports" ), is( "FROM-MOD/package2=OTHER-MOD" ) ); - - assertThat( configuration.getCustomCompilerArgumentsEntries().size(), is( 2 ) ); - Iterator> entries = configuration.getCustomCompilerArgumentsEntries().iterator(); - Map.Entry entry; - + public void testCustomArguments() { + configuration.addCompilerCustomArgument("--add-exports", "FROM-MOD/package1=OTHER-MOD"); + configuration.addCompilerCustomArgument("--add-exports", "FROM-MOD/package2=OTHER-MOD"); + + assertThat(configuration.getCustomCompilerArgumentsAsMap().size(), is(1)); + assertThat( + configuration.getCustomCompilerArgumentsAsMap().get("--add-exports"), + is("FROM-MOD/package2=OTHER-MOD")); + + assertThat(configuration.getCustomCompilerArgumentsEntries().size(), is(2)); + Iterator> entries = + configuration.getCustomCompilerArgumentsEntries().iterator(); + Map.Entry entry; + entry = entries.next(); - assertThat( entry.getKey(), is( "--add-exports" ) ); - assertThat( entry.getValue(), is( "FROM-MOD/package1=OTHER-MOD" ) ); + assertThat(entry.getKey(), is("--add-exports")); + assertThat(entry.getValue(), is("FROM-MOD/package1=OTHER-MOD")); entry = entries.next(); - assertThat( entry.getKey(), is( "--add-exports" )); - assertThat( entry.getValue(), is( "FROM-MOD/package2=OTHER-MOD") ); + assertThat(entry.getKey(), is("--add-exports")); + assertThat(entry.getValue(), is("FROM-MOD/package2=OTHER-MOD")); } } diff --git a/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/AbstractSourceInclusionScannerTest.java b/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/AbstractSourceInclusionScannerTest.java index 1ddd35a0..bac63c56 100644 --- a/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/AbstractSourceInclusionScannerTest.java +++ b/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/AbstractSourceInclusionScannerTest.java @@ -36,37 +36,33 @@ * * @author Carlos Sanchez */ -public abstract class AbstractSourceInclusionScannerTest -{ +public abstract class AbstractSourceInclusionScannerTest { private static final String TESTFILE_DEST_MARKER_FILE = - SourceInclusionScanner.class.getName().replace( '.', '/' ) + "-testMarker.txt"; + SourceInclusionScanner.class.getName().replace('.', '/') + "-testMarker.txt"; protected SourceInclusionScanner scanner; @Test - public void testGetIncludedSources() - throws Exception - { - File base = new File( getTestBaseDir(), "testGetIncludedSources" ); + public void testGetIncludedSources() throws Exception { + File base = new File(getTestBaseDir(), "testGetIncludedSources"); - File sourceFile = new File( base, "file.java" ); + File sourceFile = new File(base, "file.java"); - writeFile( sourceFile ); + writeFile(sourceFile); - sourceFile.setLastModified( System.currentTimeMillis() ); + sourceFile.setLastModified(System.currentTimeMillis()); - SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); + SuffixMapping mapping = new SuffixMapping(".java", ".xml"); - scanner.addSourceMapping( mapping ); + scanner.addSourceMapping(mapping); - Set includedSources = scanner.getIncludedSources( base, base ); + Set includedSources = scanner.getIncludedSources(base, base); - assertThat( "no sources were included", includedSources, not( empty() ) ); + assertThat("no sources were included", includedSources, not(empty())); - for ( File file : includedSources ) - { - assertThat( "file included does not exist", file, anExistingFile() ); + for (File file : includedSources) { + assertThat("file included does not exist", file, anExistingFile()); } } @@ -74,48 +70,38 @@ public void testGetIncludedSources() // Utilities // ---------------------------------------------------------------------- - protected File getTestBaseDir() - throws URISyntaxException - { + protected File getTestBaseDir() throws URISyntaxException { ClassLoader cl = Thread.currentThread().getContextClassLoader(); - URL markerResource = cl.getResource( TESTFILE_DEST_MARKER_FILE ); + URL markerResource = cl.getResource(TESTFILE_DEST_MARKER_FILE); File basedir; - if ( markerResource != null ) - { - File marker = new File( markerResource.toURI() ); + if (markerResource != null) { + File marker = new File(markerResource.toURI()); basedir = marker.getParentFile().getAbsoluteFile(); - } - else - { + } else { // punt. - System.out.println( "Cannot find marker file: \'" + TESTFILE_DEST_MARKER_FILE + "\' in classpath. " + - "Using '.' for basedir." ); + System.out.println("Cannot find marker file: \'" + TESTFILE_DEST_MARKER_FILE + "\' in classpath. " + + "Using '.' for basedir."); - basedir = new File( "." ).getAbsoluteFile(); + basedir = new File(".").getAbsoluteFile(); } return basedir; } - protected void writeFile( File file ) - throws IOException - { + protected void writeFile(File file) throws IOException { File parent = file.getParentFile(); - if ( !parent.exists() ) - { + if (!parent.exists()) { parent.mkdirs(); } file.deleteOnExit(); - try (FileWriter fWriter = new FileWriter( file )) - { - fWriter.write( "This is just a test file." ); + try (FileWriter fWriter = new FileWriter(file)) { + fWriter.write("This is just a test file."); } } - } diff --git a/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/SimpleSourceInclusionScannerTest.java b/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/SimpleSourceInclusionScannerTest.java index a8783501..788872d6 100644 --- a/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/SimpleSourceInclusionScannerTest.java +++ b/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/SimpleSourceInclusionScannerTest.java @@ -16,31 +16,25 @@ * limitations under the License. */ -import org.junit.jupiter.api.BeforeEach; - import java.util.Collections; import java.util.HashSet; import java.util.Set; +import org.junit.jupiter.api.BeforeEach; /** * Test for * * @author Carlos Sanchez */ -public class SimpleSourceInclusionScannerTest - extends AbstractSourceInclusionScannerTest -{ +public class SimpleSourceInclusionScannerTest extends AbstractSourceInclusionScannerTest { private Set includes, excludes; @BeforeEach - public void setUp() - throws Exception - { - includes = Collections.singleton( "*.java" ); + public void setUp() throws Exception { + includes = Collections.singleton("*.java"); excludes = new HashSet<>(); - scanner = new SimpleSourceInclusionScanner( includes, excludes ); + scanner = new SimpleSourceInclusionScanner(includes, excludes); } - } diff --git a/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/StaleSourceScannerTest.java b/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/StaleSourceScannerTest.java index 6679bb97..3cd1c475 100644 --- a/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/StaleSourceScannerTest.java +++ b/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/StaleSourceScannerTest.java @@ -37,141 +37,129 @@ * @author jdcasey * @author Trygve Laugstøl */ -public class StaleSourceScannerTest - extends AbstractSourceInclusionScannerTest -{ +public class StaleSourceScannerTest extends AbstractSourceInclusionScannerTest { @BeforeEach - public void setUp() - throws Exception - { + public void setUp() throws Exception { scanner = new StaleSourceScanner(); } @Test - public void testWithDefaultConstructorShouldFindOneStaleSource() - throws Exception - { - File base = new File( getTestBaseDir(), "test1" ); + public void testWithDefaultConstructorShouldFindOneStaleSource() throws Exception { + File base = new File(getTestBaseDir(), "test1"); long now = System.currentTimeMillis(); - File targetFile = new File( base, "file.xml" ); + File targetFile = new File(base, "file.xml"); - writeFile( targetFile ); + writeFile(targetFile); - targetFile.setLastModified( now - 60000 ); + targetFile.setLastModified(now - 60000); - File sourceFile = new File( base, "file.java" ); + File sourceFile = new File(base, "file.java"); - writeFile( sourceFile ); + writeFile(sourceFile); - sourceFile.setLastModified( now ); + sourceFile.setLastModified(now); - SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); + SuffixMapping mapping = new SuffixMapping(".java", ".xml"); - scanner.addSourceMapping( mapping ); + scanner.addSourceMapping(mapping); - Set result = scanner.getIncludedSources( base, base ); + Set result = scanner.getIncludedSources(base, base); - assertThat( "wrong number of stale sources returned.", result.size(), is( 1) ); + assertThat("wrong number of stale sources returned.", result.size(), is(1)); - assertThat( "expected stale source file not found in result", result, Matchers.contains( sourceFile ) ); + assertThat("expected stale source file not found in result", result, Matchers.contains(sourceFile)); } @Test - public void testWithDefaultConstructorShouldNotFindStaleSources() - throws Exception - { - File base = new File( getTestBaseDir(), "test2" ); + public void testWithDefaultConstructorShouldNotFindStaleSources() throws Exception { + File base = new File(getTestBaseDir(), "test2"); long now = System.currentTimeMillis(); - File sourceFile = new File( base, "file.java" ); + File sourceFile = new File(base, "file.java"); - writeFile( sourceFile ); + writeFile(sourceFile); - sourceFile.setLastModified( now - 60000 ); + sourceFile.setLastModified(now - 60000); - File targetFile = new File( base, "file.xml" ); + File targetFile = new File(base, "file.xml"); - writeFile( targetFile ); + writeFile(targetFile); - targetFile.setLastModified( now ); + targetFile.setLastModified(now); - SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); + SuffixMapping mapping = new SuffixMapping(".java", ".xml"); - scanner.addSourceMapping( mapping ); + scanner.addSourceMapping(mapping); - Set result = scanner.getIncludedSources( base, base ); + Set result = scanner.getIncludedSources(base, base); - assertThat( "wrong number of stale sources returned.", result.size(), is( 0 ) ); + assertThat("wrong number of stale sources returned.", result.size(), is(0)); - assertThat( "expected stale source file not found in result", result, empty( ) ); + assertThat("expected stale source file not found in result", result, empty()); } @Test - public void testWithDefaultConstructorShouldFindStaleSourcesBecauseOfMissingTargetFile() - throws Exception - { - File base = new File( getTestBaseDir(), "test3" ); + public void testWithDefaultConstructorShouldFindStaleSourcesBecauseOfMissingTargetFile() throws Exception { + File base = new File(getTestBaseDir(), "test3"); - File sourceFile = new File( base, "file.java" ); + File sourceFile = new File(base, "file.java"); - writeFile( sourceFile ); + writeFile(sourceFile); - SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); + SuffixMapping mapping = new SuffixMapping(".java", ".xml"); - scanner.addSourceMapping( mapping ); + scanner.addSourceMapping(mapping); - Set result = scanner.getIncludedSources( base, base ); + Set result = scanner.getIncludedSources(base, base); - assertThat( "wrong number of stale sources returned.", result.size(), is( 1) ); + assertThat("wrong number of stale sources returned.", result.size(), is(1)); - assertThat( "expected stale source file not found in result", result, contains( sourceFile ) ); + assertThat("expected stale source file not found in result", result, contains(sourceFile)); } @Test public void testWithDefaultConstructorShouldFindStaleSourcesOneBecauseOfMissingTargetAndOneBecauseOfStaleTarget() - throws Exception - { - File base = new File( getTestBaseDir(), "test4" ); + throws Exception { + File base = new File(getTestBaseDir(), "test4"); long now = System.currentTimeMillis(); - File targetFile = new File( base, "file2.xml" ); + File targetFile = new File(base, "file2.xml"); - writeFile( targetFile ); + writeFile(targetFile); - targetFile.setLastModified( now - 60000 ); + targetFile.setLastModified(now - 60000); - File sourceFile = new File( base, "file.java" ); + File sourceFile = new File(base, "file.java"); - writeFile( sourceFile ); + writeFile(sourceFile); - File sourceFile2 = new File( base, "file2.java" ); + File sourceFile2 = new File(base, "file2.java"); - writeFile( sourceFile2 ); + writeFile(sourceFile2); - sourceFile2.setLastModified( now ); + sourceFile2.setLastModified(now); - SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); + SuffixMapping mapping = new SuffixMapping(".java", ".xml"); - scanner.addSourceMapping( mapping ); + scanner.addSourceMapping(mapping); - Set result = scanner.getIncludedSources( base, base ); + Set result = scanner.getIncludedSources(base, base); - assertThat( "wrong number of stale sources returned.", result.size(), is( 2) ); - - assertThat( "expected stale source file not found in result", result, containsInAnyOrder( sourceFile, sourceFile2 ) ); + assertThat("wrong number of stale sources returned.", result.size(), is(2)); + assertThat( + "expected stale source file not found in result", result, containsInAnyOrder(sourceFile, sourceFile2)); } @Test public void testWithDefaultConstructorShouldFindOneStaleSourcesWithStaleTargetAndOmitUpToDateSource() - throws Exception - { - File base = new File( getTestBaseDir(), "test5" ); + throws Exception { + File base = new File(getTestBaseDir(), "test5"); long now = System.currentTimeMillis(); @@ -179,225 +167,219 @@ public void testWithDefaultConstructorShouldFindOneStaleSourcesWithStaleTargetAn // write the target file first, and set the lastmod to some time in the // past to ensure this. - File targetFile = new File( base, "file.xml" ); + File targetFile = new File(base, "file.xml"); - writeFile( targetFile ); + writeFile(targetFile); - targetFile.setLastModified( now - 60000 ); + targetFile.setLastModified(now - 60000); // now write the source file, and set the lastmod to now. - File sourceFile = new File( base, "file.java" ); + File sourceFile = new File(base, "file.java"); - writeFile( sourceFile ); + writeFile(sourceFile); - sourceFile.setLastModified( now ); + sourceFile.setLastModified(now); // target/source (2) should result in source being omitted. // write the source file first, and set the lastmod to some time in the // past to ensure this. - File sourceFile2 = new File( base, "file2.java" ); + File sourceFile2 = new File(base, "file2.java"); - writeFile( sourceFile2 ); + writeFile(sourceFile2); - sourceFile2.setLastModified( now - 60000 ); + sourceFile2.setLastModified(now - 60000); // now write the target file, with lastmod of now. - File targetFile2 = new File( base, "file2.xml" ); + File targetFile2 = new File(base, "file2.xml"); - writeFile( targetFile2 ); + writeFile(targetFile2); - targetFile2.setLastModified( now ); + targetFile2.setLastModified(now); - SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); + SuffixMapping mapping = new SuffixMapping(".java", ".xml"); - scanner.addSourceMapping( mapping ); + scanner.addSourceMapping(mapping); - Set result = scanner.getIncludedSources( base, base ); + Set result = scanner.getIncludedSources(base, base); - assertThat( "wrong number of stale sources returned.", result.size(), is( 1 ) ); + assertThat("wrong number of stale sources returned.", result.size(), is(1)); - assertThat( "expected stale source file not found in result", result, contains( sourceFile ) ); + assertThat("expected stale source file not found in result", result, contains(sourceFile)); } @Test - public void testConstructedWithMsecsShouldReturnOneSourceFileOfTwoDueToLastMod() - throws Exception - { - File base = new File( getTestBaseDir(), "test6" ); + public void testConstructedWithMsecsShouldReturnOneSourceFileOfTwoDueToLastMod() throws Exception { + File base = new File(getTestBaseDir(), "test6"); long now = System.currentTimeMillis(); - File targetFile = new File( base, "file.xml" ); + File targetFile = new File(base, "file.xml"); - writeFile( targetFile ); + writeFile(targetFile); // should be within the threshold of lastMod for stale sources. - targetFile.setLastModified( now - 8000 ); + targetFile.setLastModified(now - 8000); - File sourceFile = new File( base, "file.java" ); + File sourceFile = new File(base, "file.java"); - writeFile( sourceFile ); + writeFile(sourceFile); // modified 'now' for comparison with the above target file. - sourceFile.setLastModified( now ); + sourceFile.setLastModified(now); - File targetFile2 = new File( base, "file2.xml" ); + File targetFile2 = new File(base, "file2.xml"); - writeFile( targetFile2 ); + writeFile(targetFile2); - targetFile2.setLastModified( now - 12000 ); + targetFile2.setLastModified(now - 12000); - File sourceFile2 = new File( base, "file2.java" ); + File sourceFile2 = new File(base, "file2.java"); - writeFile( sourceFile2 ); + writeFile(sourceFile2); // modified 'now' for comparison to above target file. - sourceFile2.setLastModified( now ); + sourceFile2.setLastModified(now); - SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); + SuffixMapping mapping = new SuffixMapping(".java", ".xml"); - scanner = new StaleSourceScanner( 10000 ); + scanner = new StaleSourceScanner(10000); - scanner.addSourceMapping( mapping ); + scanner.addSourceMapping(mapping); - Set result = scanner.getIncludedSources( base, base ); + Set result = scanner.getIncludedSources(base, base); - assertThat( "wrong number of stale sources returned.", result.size(), is( 1 ) ); + assertThat("wrong number of stale sources returned.", result.size(), is(1)); - assertThat( "expected stale source file not found in result", result, contains( sourceFile2 ) ); + assertThat("expected stale source file not found in result", result, contains(sourceFile2)); } @Test public void testConstructedWithMsecsIncludesAndExcludesShouldReturnOneSourceFileOfThreeDueToIncludePattern() - throws Exception - { - File base = new File( getTestBaseDir(), "test7" ); + throws Exception { + File base = new File(getTestBaseDir(), "test7"); long now = System.currentTimeMillis(); - File targetFile = new File( base, "file.xml" ); + File targetFile = new File(base, "file.xml"); - writeFile( targetFile ); + writeFile(targetFile); // should be within the threshold of lastMod for stale sources. - targetFile.setLastModified( now - 12000 ); + targetFile.setLastModified(now - 12000); - File sourceFile = new File( base, "file.java" ); + File sourceFile = new File(base, "file.java"); - writeFile( sourceFile ); + writeFile(sourceFile); // modified 'now' for comparison with the above target file. - sourceFile.setLastModified( now ); + sourceFile.setLastModified(now); - File targetFile2 = new File( base, "file2.xml" ); + File targetFile2 = new File(base, "file2.xml"); - writeFile( targetFile2 ); + writeFile(targetFile2); - targetFile2.setLastModified( now - 12000 ); + targetFile2.setLastModified(now - 12000); - File sourceFile2 = new File( base, "file2.java" ); + File sourceFile2 = new File(base, "file2.java"); - writeFile( sourceFile2 ); + writeFile(sourceFile2); // modified 'now' for comparison to above target file. - sourceFile2.setLastModified( now ); + sourceFile2.setLastModified(now); - File targetFile3 = new File( base, "file3.xml" ); + File targetFile3 = new File(base, "file3.xml"); - writeFile( targetFile3 ); + writeFile(targetFile3); - targetFile3.setLastModified( now - 12000 ); + targetFile3.setLastModified(now - 12000); - File sourceFile3 = new File( base, "file3.java" ); + File sourceFile3 = new File(base, "file3.java"); - writeFile( sourceFile3 ); + writeFile(sourceFile3); // modified 'now' for comparison to above target file. - sourceFile3.setLastModified( now ); + sourceFile3.setLastModified(now); - SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); + SuffixMapping mapping = new SuffixMapping(".java", ".xml"); - scanner = new StaleSourceScanner( 0, Collections.singleton( "*3.java" ), Collections.emptySet() ); + scanner = new StaleSourceScanner(0, Collections.singleton("*3.java"), Collections.emptySet()); - scanner.addSourceMapping( mapping ); + scanner.addSourceMapping(mapping); - Set result = scanner.getIncludedSources( base, base ); + Set result = scanner.getIncludedSources(base, base); - assertThat( "wrong number of stale sources returned.", result.size(), is( 1 ) ); + assertThat("wrong number of stale sources returned.", result.size(), is(1)); - assertThat( "expected stale source file not found in result", result, contains( sourceFile3 ) ); + assertThat("expected stale source file not found in result", result, contains(sourceFile3)); } @Test public void testConstructedWithMsecsIncludesAndExcludesShouldReturnTwoSourceFilesOfThreeDueToExcludePattern() - throws Exception - { - File base = new File( getTestBaseDir(), "test8" ); + throws Exception { + File base = new File(getTestBaseDir(), "test8"); long now = System.currentTimeMillis(); - File targetFile = new File( base, "fileX.xml" ); + File targetFile = new File(base, "fileX.xml"); - writeFile( targetFile ); + writeFile(targetFile); // should be within the threshold of lastMod for stale sources. - targetFile.setLastModified( now - 12000 ); + targetFile.setLastModified(now - 12000); - File sourceFile = new File( base, "fileX.java" ); + File sourceFile = new File(base, "fileX.java"); - writeFile( sourceFile ); + writeFile(sourceFile); // modified 'now' for comparison with the above target file. - sourceFile.setLastModified( now ); + sourceFile.setLastModified(now); - File targetFile2 = new File( base, "file2.xml" ); + File targetFile2 = new File(base, "file2.xml"); - writeFile( targetFile2 ); + writeFile(targetFile2); - targetFile2.setLastModified( now - 12000 ); + targetFile2.setLastModified(now - 12000); - File sourceFile2 = new File( base, "file2.java" ); + File sourceFile2 = new File(base, "file2.java"); - writeFile( sourceFile2 ); + writeFile(sourceFile2); // modified 'now' for comparison to above target file. - sourceFile2.setLastModified( now ); + sourceFile2.setLastModified(now); - File targetFile3 = new File( base, "file3.xml" ); + File targetFile3 = new File(base, "file3.xml"); - writeFile( targetFile3 ); + writeFile(targetFile3); - targetFile3.setLastModified( now - 12000 ); + targetFile3.setLastModified(now - 12000); - File sourceFile3 = new File( base, "file3.java" ); + File sourceFile3 = new File(base, "file3.java"); - writeFile( sourceFile3 ); + writeFile(sourceFile3); // modified 'now' for comparison to above target file. - sourceFile3.setLastModified( now ); - - SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); + sourceFile3.setLastModified(now); - scanner = new StaleSourceScanner( 0, Collections.singleton( "**/*" ), Collections.singleton( "*X.*" ) ); + SuffixMapping mapping = new SuffixMapping(".java", ".xml"); - scanner.addSourceMapping( mapping ); + scanner = new StaleSourceScanner(0, Collections.singleton("**/*"), Collections.singleton("*X.*")); - Set result = scanner.getIncludedSources( base, base ); + scanner.addSourceMapping(mapping); - assertThat( "wrong number of stale sources returned.", result.size(), is( 2 ) ); + Set result = scanner.getIncludedSources(base, base); - assertThat( "expected stale source file not found in result", result, containsInAnyOrder( sourceFile2, sourceFile3 ) ); + assertThat("wrong number of stale sources returned.", result.size(), is(2)); + assertThat( + "expected stale source file not found in result", result, containsInAnyOrder(sourceFile2, sourceFile3)); } @Test - public void testSingleFileSourceMapping() - throws Exception - { - File src = new File( getTestBaseDir(), "test9-src" ); + public void testSingleFileSourceMapping() throws Exception { + File src = new File(getTestBaseDir(), "test9-src"); - File target = new File( getTestBaseDir(), "test9-target" ); + File target = new File(getTestBaseDir(), "test9-target"); long now = System.currentTimeMillis(); @@ -405,68 +387,64 @@ public void testSingleFileSourceMapping() // The output file is missing // ---------------------------------------------------------------------- - File fooCs = new File( src, "Foo.cs" ); + File fooCs = new File(src, "Foo.cs"); - writeFile( fooCs ); + writeFile(fooCs); - fooCs.setLastModified( now - 10000 ); + fooCs.setLastModified(now - 10000); - SourceMapping mapping = new SingleTargetSourceMapping( ".cs", "Application.exe" ); + SourceMapping mapping = new SingleTargetSourceMapping(".cs", "Application.exe"); - scanner = new StaleSourceScanner( 0 ); + scanner = new StaleSourceScanner(0); - scanner.addSourceMapping( mapping ); + scanner.addSourceMapping(mapping); - Set result = scanner.getIncludedSources( src, target ); + Set result = scanner.getIncludedSources(src, target); - assertThat( result.size(), is( 1 ) ); + assertThat(result.size(), is(1)); - assertThat( result, contains( fooCs ) ); + assertThat(result, contains(fooCs)); // ---------------------------------------------------------------------- // Add another source file // ---------------------------------------------------------------------- - File barCs = new File( src, "Bar.cs" ); - - writeFile( barCs ); + File barCs = new File(src, "Bar.cs"); - barCs.setLastModified( now - 20000 ); + writeFile(barCs); - result = scanner.getIncludedSources( src, target ); + barCs.setLastModified(now - 20000); - assertThat( result.size(), is( 2 ) ); - - assertThat( result, containsInAnyOrder( fooCs, barCs ) ); + result = scanner.getIncludedSources(src, target); + assertThat(result.size(), is(2)); + assertThat(result, containsInAnyOrder(fooCs, barCs)); // ---------------------------------------------------------------------- // Now add the result file // ---------------------------------------------------------------------- - File applicationExe = new File( target, "Application.exe" ); - - writeFile( applicationExe ); + File applicationExe = new File(target, "Application.exe"); - applicationExe.setLastModified( now ); + writeFile(applicationExe); - result = scanner.getIncludedSources( src, target ); + applicationExe.setLastModified(now); - assertThat( result, empty() ); + result = scanner.getIncludedSources(src, target); + assertThat(result, empty()); // ---------------------------------------------------------------------- // Make Application.exe older than the Foo.cs // ---------------------------------------------------------------------- - applicationExe.setLastModified( now - 15000 ); + applicationExe.setLastModified(now - 15000); - result = scanner.getIncludedSources( src, target ); + result = scanner.getIncludedSources(src, target); - assertThat( result.size(), is( 1 ) ); + assertThat(result.size(), is(1)); - assertThat( result, contains( fooCs ) ); + assertThat(result, contains(fooCs)); } - } diff --git a/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/mapping/SuffixMappingTest.java b/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/mapping/SuffixMappingTest.java index 72a5d494..028b3e1c 100644 --- a/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/mapping/SuffixMappingTest.java +++ b/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/mapping/SuffixMappingTest.java @@ -16,12 +16,12 @@ * limitations under the License. */ -import org.junit.jupiter.api.Test; - import java.io.File; import java.util.HashSet; import java.util.Set; +import org.junit.jupiter.api.Test; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.empty; @@ -30,95 +30,89 @@ /** * @author jdcasey */ -public class SuffixMappingTest -{ +public class SuffixMappingTest { @Test - public void testShouldReturnSingleClassFileForSingleJavaFile() - { + public void testShouldReturnSingleClassFileForSingleJavaFile() { String base = "path/to/file"; - File basedir = new File( "." ); + File basedir = new File("."); - SuffixMapping mapping = new SuffixMapping( ".java", ".class" ); + SuffixMapping mapping = new SuffixMapping(".java", ".class"); - Set results = mapping.getTargetFiles( basedir, base + ".java" ); + Set results = mapping.getTargetFiles(basedir, base + ".java"); - assertThat( "Returned wrong number of target files.", results.size(), is( 1 ) ); + assertThat("Returned wrong number of target files.", results.size(), is(1)); - assertThat( "Target file is wrong.", results.iterator().next(), is( new File( basedir, base + ".class" ) ) ); + assertThat("Target file is wrong.", results.iterator().next(), is(new File(basedir, base + ".class"))); } @Test - public void testShouldNotReturnClassFileWhenSourceFileHasWrongSuffix() - { + public void testShouldNotReturnClassFileWhenSourceFileHasWrongSuffix() { String base = "path/to/file"; - File basedir = new File( "." ); + File basedir = new File("."); - SuffixMapping mapping = new SuffixMapping( ".java", ".class" ); + SuffixMapping mapping = new SuffixMapping(".java", ".class"); - Set results = mapping.getTargetFiles( basedir, base + ".xml" ); + Set results = mapping.getTargetFiles(basedir, base + ".xml"); - assertThat( "Returned wrong number of target files.", results, empty() ); + assertThat("Returned wrong number of target files.", results, empty()); } @Test - public void testShouldReturnOneClassFileAndOneXmlFileForSingleJavaFile() - { + public void testShouldReturnOneClassFileAndOneXmlFileForSingleJavaFile() { String base = "path/to/file"; - File basedir = new File( "." ); + File basedir = new File("."); Set targets = new HashSet<>(); - targets.add( ".class" ); - targets.add( ".xml" ); - - SuffixMapping mapping = new SuffixMapping( ".java", targets ); + targets.add(".class"); + targets.add(".xml"); - Set results = mapping.getTargetFiles( basedir, base + ".java" ); + SuffixMapping mapping = new SuffixMapping(".java", targets); - assertThat( "Returned wrong number of target files.", results.size(), is( 2 ) ); + Set results = mapping.getTargetFiles(basedir, base + ".java"); - assertThat( "Targets do not contain class target.", results, - containsInAnyOrder( new File( basedir, base + ".class" ), new File( basedir, base + ".xml" ) ) ); + assertThat("Returned wrong number of target files.", results.size(), is(2)); + assertThat( + "Targets do not contain class target.", + results, + containsInAnyOrder(new File(basedir, base + ".class"), new File(basedir, base + ".xml"))); } @Test - public void testShouldReturnNoTargetFilesWhenSourceFileHasWrongSuffix() - { + public void testShouldReturnNoTargetFilesWhenSourceFileHasWrongSuffix() { String base = "path/to/file"; - File basedir = new File( "." ); + File basedir = new File("."); Set targets = new HashSet<>(); - targets.add( ".class" ); - targets.add( ".xml" ); + targets.add(".class"); + targets.add(".xml"); - SuffixMapping mapping = new SuffixMapping( ".java", targets ); + SuffixMapping mapping = new SuffixMapping(".java", targets); - Set results = mapping.getTargetFiles( basedir, base + ".apt" ); + Set results = mapping.getTargetFiles(basedir, base + ".apt"); - assertThat( "Returned wrong number of target files.", results, empty() ); + assertThat("Returned wrong number of target files.", results, empty()); } @Test - public void testSingleTargetMapper() - throws Exception - { + public void testSingleTargetMapper() throws Exception { String base = "path/to/file"; - File basedir = new File( "target/" ); + File basedir = new File("target/"); - SingleTargetSourceMapping mapping = new SingleTargetSourceMapping( ".cs", "/foo" ); + SingleTargetSourceMapping mapping = new SingleTargetSourceMapping(".cs", "/foo"); - Set results = mapping.getTargetFiles( basedir, base + ".apt" ); + Set results = mapping.getTargetFiles(basedir, base + ".apt"); - assertThat( results, empty() ); + assertThat(results, empty()); - results = mapping.getTargetFiles( basedir, base + ".cs" ); + results = mapping.getTargetFiles(basedir, base + ".cs"); - assertThat( results.size(), is( 1 ) ); + assertThat(results.size(), is(1)); } } diff --git a/plexus-compiler-its/pom.xml b/plexus-compiler-its/pom.xml index 768915e8..e13f29e9 100644 --- a/plexus-compiler-its/pom.xml +++ b/plexus-compiler-its/pom.xml @@ -42,12 +42,12 @@ integration-tests - verify install run verify + verify false true diff --git a/plexus-compiler-manager/pom.xml b/plexus-compiler-manager/pom.xml index 243a6f0c..84be7263 100644 --- a/plexus-compiler-manager/pom.xml +++ b/plexus-compiler-manager/pom.xml @@ -21,6 +21,10 @@ javax.inject javax.inject + + org.codehaus.plexus + plexus-xml + org.junit.jupiter junit-jupiter-api diff --git a/plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/manager/CompilerManager.java b/plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/manager/CompilerManager.java index 4233e3c4..44b06601 100644 --- a/plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/manager/CompilerManager.java +++ b/plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/manager/CompilerManager.java @@ -23,16 +23,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - import org.codehaus.plexus.compiler.Compiler; /** * @author Trygve Laugstøl */ -public interface CompilerManager -{ +public interface CompilerManager { String ROLE = CompilerManager.class.getName(); - Compiler getCompiler( String compilerId ) - throws NoSuchCompilerException; + Compiler getCompiler(String compilerId) throws NoSuchCompilerException; } diff --git a/plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/manager/DefaultCompilerManager.java b/plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/manager/DefaultCompilerManager.java index 3b303add..29af62f7 100644 --- a/plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/manager/DefaultCompilerManager.java +++ b/plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/manager/DefaultCompilerManager.java @@ -23,20 +23,18 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - -import org.codehaus.plexus.compiler.Compiler; - import javax.inject.Inject; import javax.inject.Named; + import java.util.Map; +import org.codehaus.plexus.compiler.Compiler; + /** * @author Trygve Laugstøl */ @Named -public class DefaultCompilerManager - implements CompilerManager -{ +public class DefaultCompilerManager implements CompilerManager { @Inject private Map compilers; @@ -44,14 +42,11 @@ public class DefaultCompilerManager // CompilerManager Implementation // ---------------------------------------------------------------------- - public Compiler getCompiler( String compilerId ) - throws NoSuchCompilerException - { - Compiler compiler = compilers.get( compilerId ); + public Compiler getCompiler(String compilerId) throws NoSuchCompilerException { + Compiler compiler = compilers.get(compilerId); - if ( compiler == null ) - { - throw new NoSuchCompilerException( compilerId ); + if (compiler == null) { + throw new NoSuchCompilerException(compilerId); } return compiler; diff --git a/plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/manager/NoSuchCompilerException.java b/plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/manager/NoSuchCompilerException.java index fb296035..e40c6462 100644 --- a/plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/manager/NoSuchCompilerException.java +++ b/plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/manager/NoSuchCompilerException.java @@ -27,20 +27,16 @@ /** * @author Trygve Laugstøl */ -public class NoSuchCompilerException - extends Exception -{ +public class NoSuchCompilerException extends Exception { private final String compilerId; - public NoSuchCompilerException( String compilerId ) - { - super( "No such compiler '" + compilerId + "'." ); + public NoSuchCompilerException(String compilerId) { + super("No such compiler '" + compilerId + "'."); this.compilerId = compilerId; } - public String getCompilerId() - { + public String getCompilerId() { return compilerId; } } diff --git a/plexus-compiler-manager/src/test/java/org/codehaus/plexus/compiler/manager/CompilerManagerTest.java b/plexus-compiler-manager/src/test/java/org/codehaus/plexus/compiler/manager/CompilerManagerTest.java index 0eede05c..8a13c541 100644 --- a/plexus-compiler-manager/src/test/java/org/codehaus/plexus/compiler/manager/CompilerManagerTest.java +++ b/plexus-compiler-manager/src/test/java/org/codehaus/plexus/compiler/manager/CompilerManagerTest.java @@ -23,26 +23,22 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +import javax.inject.Inject; import org.codehaus.plexus.testing.PlexusTest; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import javax.inject.Inject; - /** * @author Trygve Laugstøl */ @PlexusTest -public class CompilerManagerTest -{ +public class CompilerManagerTest { @Inject private CompilerManager compilerManager; @Test - public void testBasic() - throws Exception - { - Assertions.assertThrows(NoSuchCompilerException.class, () -> compilerManager.getCompiler( "foo" )); + public void testBasic() throws Exception { + Assertions.assertThrows(NoSuchCompilerException.class, () -> compilerManager.getCompiler("foo")); } } diff --git a/plexus-compiler-test/pom.xml b/plexus-compiler-test/pom.xml index f6670a76..9ba37b39 100644 --- a/plexus-compiler-test/pom.xml +++ b/plexus-compiler-test/pom.xml @@ -20,7 +20,8 @@ org.junit.jupiter junit-jupiter-api - compile + compile + org.codehaus.plexus @@ -56,6 +57,10 @@ org.codehaus.plexus plexus-utils + + org.codehaus.plexus + plexus-xml + commons-lang diff --git a/plexus-compiler-test/src/main/java/org/codehaus/plexus/compiler/AbstractCompilerTckTest.java b/plexus-compiler-test/src/main/java/org/codehaus/plexus/compiler/AbstractCompilerTckTest.java index 2a6c8106..4c03e35b 100644 --- a/plexus-compiler-test/src/main/java/org/codehaus/plexus/compiler/AbstractCompilerTckTest.java +++ b/plexus-compiler-test/src/main/java/org/codehaus/plexus/compiler/AbstractCompilerTckTest.java @@ -23,6 +23,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +import javax.inject.Inject; import java.io.File; import java.io.IOException; @@ -30,8 +31,6 @@ import java.util.List; import java.util.Map; -import javax.inject.Inject; - import org.codehaus.plexus.testing.PlexusTest; import org.codehaus.plexus.util.FileUtils; import org.junit.jupiter.api.BeforeEach; @@ -47,30 +46,26 @@ * @author Trygve Laugstøl */ @PlexusTest -public abstract class AbstractCompilerTckTest -{ +public abstract class AbstractCompilerTckTest { private static final String EOL = System.lineSeparator(); protected String roleHint; - + private TestInfo testInfo; - + @Inject private Map compilers; @BeforeEach - final void setup( TestInfo testInfo ) - { + final void setup(TestInfo testInfo) { this.testInfo = testInfo; } @Test - public void testDeprecation() - throws Exception - { - File foo = new File( getSrc(), "Foo.java" ); + public void testDeprecation() throws Exception { + File foo = new File(getSrc(), "Foo.java"); - writeFileWithDeprecatedApi( foo, "Foo" ); + writeFileWithDeprecatedApi(foo, "Foo"); // ---------------------------------------------------------------------- // @@ -78,34 +73,32 @@ public void testDeprecation() CompilerConfiguration configuration = new CompilerConfiguration(); - configuration.setShowDeprecation( true ); + configuration.setShowDeprecation(true); - configuration.addSourceLocation( getSrc().getAbsolutePath() ); + configuration.addSourceLocation(getSrc().getAbsolutePath()); - List result = compile( configuration ); + List result = compile(configuration); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - assertThat( result.size(), is( 1 ) ); + assertThat(result.size(), is(1)); - CompilerMessage error = result.get( 0 ); + CompilerMessage error = result.get(0); - assertThat( error.isError(), is( false ) ); + assertThat(error.isError(), is(false)); - assertThat( error.getMessage(), containsString( "Date" ) ); + assertThat(error.getMessage(), containsString("Date")); - assertThat( error.getMessage(), containsString( "deprecated" ) ); + assertThat(error.getMessage(), containsString("deprecated")); } @Test - public void testWarning() - throws Exception - { - File foo = new File( getSrc(), "Foo.java" ); + public void testWarning() throws Exception { + File foo = new File(getSrc(), "Foo.java"); - writeFileWithWarning( foo, "Foo" ); + writeFileWithWarning(foo, "Foo"); // ---------------------------------------------------------------------- // @@ -113,111 +106,101 @@ public void testWarning() CompilerConfiguration configuration = new CompilerConfiguration(); - configuration.setShowWarnings( true ); + configuration.setShowWarnings(true); - configuration.addSourceLocation( getSrc().getAbsolutePath() ); + configuration.addSourceLocation(getSrc().getAbsolutePath()); - List result = compile( configuration ); + List result = compile(configuration); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - assertThat( result.size(), is( 1 ) ); + assertThat(result.size(), is(1)); - CompilerMessage error = result.get( 0 ); + CompilerMessage error = result.get(0); - assertThat( error.isError(), is( false ) ); + assertThat(error.isError(), is(false)); - assertThat( error.getMessage(), containsString( "finally block does not complete normally" ) ); + assertThat(error.getMessage(), containsString("finally block does not complete normally")); } - - protected List compile( CompilerConfiguration configuration ) - throws Exception - { + + protected List compile(CompilerConfiguration configuration) throws Exception { // ---------------------------------------------------------------------- // Set up configuration // ---------------------------------------------------------------------- File compilerOutput = getCompilerOutput(); - if ( compilerOutput.exists() ) - { - FileUtils.deleteDirectory( compilerOutput ); + if (compilerOutput.exists()) { + FileUtils.deleteDirectory(compilerOutput); } - configuration.setOutputLocation( compilerOutput.getAbsolutePath() ); + configuration.setOutputLocation(compilerOutput.getAbsolutePath()); // ---------------------------------------------------------------------- // Compile! // ---------------------------------------------------------------------- - List result = getCompiler().performCompile( configuration ).getCompilerMessages(); + List result = + getCompiler().performCompile(configuration).getCompilerMessages(); - assertThat( result, notNullValue() ); + assertThat(result, notNullValue()); return result; } private Compiler getCompiler() { - return compilers.get( roleHint ); + return compilers.get(roleHint); } - - private File getCompilerOutput() - { - return new File( "target/compiler-output/" + testInfo.getTestMethod().map( Method::getName ).orElseThrow( null ) ); + + private File getCompilerOutput() { + return new File("target/compiler-output/" + + testInfo.getTestMethod().map(Method::getName).orElseThrow(null)); } - private File getSrc() - { - return new File( "target/compiler-src/" + testInfo.getTestMethod().map( Method::getName ).orElseThrow( null ) ); + private File getSrc() { + return new File("target/compiler-src/" + + testInfo.getTestMethod().map(Method::getName).orElseThrow(null)); } - protected void writeFileWithDeprecatedApi( File path, String className ) - throws IOException - { + protected void writeFileWithDeprecatedApi(File path, String className) throws IOException { File parent = path.getParentFile(); - if ( !parent.exists() ) - { - assertThat( parent.mkdirs(), is( true ) ); + if (!parent.exists()) { + assertThat(parent.mkdirs(), is(true)); } - String source = "import java.util.Date;" + EOL + - "" + EOL + - "public class " + className + "" + EOL + - "{" + EOL + - " private static Date date = new Date( \"foo\" );" + EOL + - " static " + EOL + - " { " + EOL + - " Date date = " + className + ".date; " + EOL + - " Date date2 = date; " + EOL + - " date = date2; " + EOL + - " }" + EOL + - "}"; - - FileUtils.fileWrite( path.getAbsolutePath(), source ); + String source = "import java.util.Date;" + EOL + "" + + EOL + "public class " + + className + "" + EOL + "{" + + EOL + " private static Date date = new Date( \"foo\" );" + + EOL + " static " + + EOL + " { " + + EOL + " Date date = " + + className + ".date; " + EOL + " Date date2 = date; " + + EOL + " date = date2; " + + EOL + " }" + + EOL + "}"; + + FileUtils.fileWrite(path.getAbsolutePath(), source); } - protected void writeFileWithWarning( File path, String className ) - throws IOException - { + protected void writeFileWithWarning(File path, String className) throws IOException { File parent = path.getParentFile(); - if ( !parent.exists() ) - { - assertThat( parent.mkdirs(), is( true ) ); + if (!parent.exists()) { + assertThat(parent.mkdirs(), is(true)); } - String source = "public class " + className + "" + EOL + - "{" + EOL + - " public void foo()" + EOL + - " {" + EOL + - " try{ throw new java.io.IOException(); }" + EOL + - " finally { return; }" + EOL + - " }" + EOL + - "}"; + String source = "public class " + className + "" + EOL + "{" + + EOL + " public void foo()" + + EOL + " {" + + EOL + " try{ throw new java.io.IOException(); }" + + EOL + " finally { return; }" + + EOL + " }" + + EOL + "}"; - FileUtils.fileWrite( path.getAbsolutePath(), source ); + FileUtils.fileWrite(path.getAbsolutePath(), source); } } diff --git a/plexus-compiler-test/src/main/java/org/codehaus/plexus/compiler/AbstractCompilerTest.java b/plexus-compiler-test/src/main/java/org/codehaus/plexus/compiler/AbstractCompilerTest.java index b9687038..977ffbd1 100644 --- a/plexus-compiler-test/src/main/java/org/codehaus/plexus/compiler/AbstractCompilerTest.java +++ b/plexus-compiler-test/src/main/java/org/codehaus/plexus/compiler/AbstractCompilerTest.java @@ -23,6 +23,16 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +import javax.inject.Inject; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; @@ -37,23 +47,10 @@ import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.StringUtils; -import org.hamcrest.MatcherAssert; -import org.hamcrest.Matchers; import org.hamcrest.io.FileMatchers; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import javax.inject.Inject; - import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.is; @@ -62,311 +59,277 @@ * */ @PlexusTest -public abstract class AbstractCompilerTest -{ +public abstract class AbstractCompilerTest { private boolean compilerDebug = false; private boolean compilerDeprecationWarnings = false; private boolean forceJavacCompilerUse = false; - + @Inject private Map compilers; @Inject private ArtifactRepositoryLayout repositoryLayout; - + private ArtifactRepository localRepository; - + protected abstract String getRoleHint(); @BeforeEach - final void setUpLocalRepo() - throws Exception - { - String localRepo = System.getProperty( "maven.repo.local" ); - - if ( localRepo == null ) - { - File settingsFile = new File( System.getProperty( "user.home" ), ".m2/settings.xml" ); - if ( settingsFile.exists() ) - { - Settings settings = new SettingsXpp3Reader().read( ReaderFactory.newXmlReader( settingsFile ) ); + final void setUpLocalRepo() throws Exception { + String localRepo = System.getProperty("maven.repo.local"); + + if (localRepo == null) { + File settingsFile = new File(System.getProperty("user.home"), ".m2/settings.xml"); + if (settingsFile.exists()) { + Settings settings = new SettingsXpp3Reader().read(ReaderFactory.newXmlReader(settingsFile)); localRepo = settings.getLocalRepository(); } } - if ( localRepo == null ) - { - localRepo = System.getProperty( "user.home" ) + "/.m2/repository"; + if (localRepo == null) { + localRepo = System.getProperty("user.home") + "/.m2/repository"; } - localRepository = new DefaultArtifactRepository( "local", "file://" + localRepo, repositoryLayout ); + localRepository = new DefaultArtifactRepository("local", "file://" + localRepo, repositoryLayout); } - protected void setCompilerDebug( boolean flag ) - { + protected void setCompilerDebug(boolean flag) { compilerDebug = flag; } - protected void setCompilerDeprecationWarnings( boolean flag ) - { + protected void setCompilerDeprecationWarnings(boolean flag) { compilerDeprecationWarnings = flag; } - public void setForceJavacCompilerUse( boolean forceJavacCompilerUse ) - { + public void setForceJavacCompilerUse(boolean forceJavacCompilerUse) { this.forceJavacCompilerUse = forceJavacCompilerUse; } - - protected final Compiler getCompiler() - { - return compilers.get( getRoleHint() ); + + protected final Compiler getCompiler() { + return compilers.get(getRoleHint()); } - protected List getClasspath() - throws Exception - { + protected List getClasspath() throws Exception { List cp = new ArrayList<>(); - File file = getLocalArtifactPath( "commons-lang", "commons-lang", "2.0", "jar" ); + File file = getLocalArtifactPath("commons-lang", "commons-lang", "2.0", "jar"); - assertThat("test prerequisite: commons-lang library must be available in local repository, expected ", - file, FileMatchers.aReadableFile()); + assertThat( + "test prerequisite: commons-lang library must be available in local repository, expected ", + file, + FileMatchers.aReadableFile()); - cp.add( file.getAbsolutePath() ); + cp.add(file.getAbsolutePath()); return cp; } - protected void configureCompilerConfig( CompilerConfiguration compilerConfig ) - { - - } + protected void configureCompilerConfig(CompilerConfiguration compilerConfig) {} @Test - public void testCompilingSources() - throws Exception - { + public void testCompilingSources() throws Exception { List messages = new ArrayList<>(); Collection files = new ArrayList<>(); - for ( CompilerConfiguration compilerConfig : getCompilerConfigurations() ) - { - File outputDir = new File( compilerConfig.getOutputLocation() ); + for (CompilerConfiguration compilerConfig : getCompilerConfigurations()) { + File outputDir = new File(compilerConfig.getOutputLocation()); - messages.addAll( getCompiler().performCompile( compilerConfig ).getCompilerMessages() ); + messages.addAll(getCompiler().performCompile(compilerConfig).getCompilerMessages()); - if ( outputDir.isDirectory() ) - { - files.addAll( normalizePaths( FileUtils.getFileNames( outputDir, null, null, false ) ) ); + if (outputDir.isDirectory()) { + files.addAll(normalizePaths(FileUtils.getFileNames(outputDir, null, null, false))); } } - int numCompilerErrors = compilerErrorCount( messages ); + int numCompilerErrors = compilerErrorCount(messages); int numCompilerWarnings = messages.size() - numCompilerErrors; int expectedErrors = expectedErrors(); - if ( expectedErrors != numCompilerErrors ) - { - System.out.println( numCompilerErrors + " error(s) found:" ); + if (expectedErrors != numCompilerErrors) { + System.out.println(numCompilerErrors + " error(s) found:"); List errors = new ArrayList<>(); - for ( CompilerMessage error : messages ) - { - if ( !error.isError() ) - { + for (CompilerMessage error : messages) { + if (!error.isError()) { continue; } - System.out.println( "----" ); - System.out.println( error.getFile() ); - System.out.println( error.getMessage() ); - System.out.println( "----" ); - errors.add( error.getMessage() ); + System.out.println("----"); + System.out.println(error.getFile()); + System.out.println(error.getMessage()); + System.out.println("----"); + errors.add(error.getMessage()); } - assertThat("Wrong number of compilation errors (" + numCompilerErrors + "/" + expectedErrors // - + ") : " + displayLines( errors ), - numCompilerErrors, is( expectedErrors ) ); + assertThat( + "Wrong number of compilation errors (" + numCompilerErrors + "/" + expectedErrors // + + ") : " + displayLines(errors), + numCompilerErrors, + is(expectedErrors)); } int expectedWarnings = expectedWarnings(); - if ( expectedWarnings != numCompilerWarnings ) - { + if (expectedWarnings != numCompilerWarnings) { List warnings = new ArrayList<>(); - System.out.println( numCompilerWarnings + " warning(s) found:" ); - for ( CompilerMessage error : messages ) - { - if ( error.isError() ) - { + System.out.println(numCompilerWarnings + " warning(s) found:"); + for (CompilerMessage error : messages) { + if (error.isError()) { continue; } - System.out.println( "----" ); - System.out.println( error.getFile() ); - System.out.println( error.getMessage() ); - System.out.println( "----" ); - warnings.add( error.getMessage() ); + System.out.println("----"); + System.out.println(error.getFile()); + System.out.println(error.getMessage()); + System.out.println("----"); + warnings.add(error.getMessage()); } - assertThat( "Wrong number (" - + numCompilerWarnings + "/" + expectedWarnings + ") of compilation warnings: " - + displayLines( warnings ), numCompilerWarnings, is( expectedWarnings ) ); + assertThat( + "Wrong number (" + + numCompilerWarnings + "/" + expectedWarnings + ") of compilation warnings: " + + displayLines(warnings), + numCompilerWarnings, + is(expectedWarnings)); } - assertThat( files, containsInAnyOrder(normalizePaths(expectedOutputFiles()).toArray(new String[0]))); + assertThat( + files, containsInAnyOrder(normalizePaths(expectedOutputFiles()).toArray(new String[0]))); } - protected String displayLines( List warnings) - { + protected String displayLines(List warnings) { // with java8 could be as simple as String.join(System.lineSeparator(), warnings) - StringBuilder sb = new StringBuilder( System.lineSeparator() ); - for ( String warning : warnings ) - { - sb.append( '-' ).append( warning ).append( System.lineSeparator() ); + StringBuilder sb = new StringBuilder(System.lineSeparator()); + for (String warning : warnings) { + sb.append('-').append(warning).append(System.lineSeparator()); } return sb.toString(); } - private List getCompilerConfigurations() - throws Exception - { + private List getCompilerConfigurations() throws Exception { String sourceDir = "src/test-input/src/main"; - List filenames = - FileUtils.getFileNames( new File( sourceDir ), "**/*.java", null, false, true ); - Collections.sort( filenames ); + List filenames = FileUtils.getFileNames(new File(sourceDir), "**/*.java", null, false, true); + Collections.sort(filenames); List compilerConfigurations = new ArrayList<>(); int index = 0; - for ( Iterator it = filenames.iterator(); it.hasNext(); index++ ) - { + for (Iterator it = filenames.iterator(); it.hasNext(); index++) { String filename = it.next(); CompilerConfiguration compilerConfig = new CompilerConfiguration(); - compilerConfig.setDebug( compilerDebug ); + compilerConfig.setDebug(compilerDebug); - compilerConfig.setShowDeprecation( compilerDeprecationWarnings ); + compilerConfig.setShowDeprecation(compilerDeprecationWarnings); - compilerConfig.setClasspathEntries( getClasspath() ); + compilerConfig.setClasspathEntries(getClasspath()); - compilerConfig.addSourceLocation( sourceDir ); + compilerConfig.addSourceLocation(sourceDir); - compilerConfig.setOutputLocation( "target/" + getRoleHint() + "/classes-" + index ); + compilerConfig.setOutputLocation("target/" + getRoleHint() + "/classes-" + index); - FileUtils.deleteDirectory( compilerConfig.getOutputLocation() ); + FileUtils.deleteDirectory(compilerConfig.getOutputLocation()); - compilerConfig.addInclude( filename ); + compilerConfig.addInclude(filename); - compilerConfig.setForceJavacCompilerUse( this.forceJavacCompilerUse ); + compilerConfig.setForceJavacCompilerUse(this.forceJavacCompilerUse); - configureCompilerConfig( compilerConfig ); + configureCompilerConfig(compilerConfig); String target = getTargetVersion(); - if( StringUtils.isNotEmpty( target) ) - { - compilerConfig.setTargetVersion( target ); + if (StringUtils.isNotEmpty(target)) { + compilerConfig.setTargetVersion(target); } String source = getSourceVersion(); - if( StringUtils.isNotEmpty( source) ) - { - compilerConfig.setSourceVersion( source ); + if (StringUtils.isNotEmpty(source)) { + compilerConfig.setSourceVersion(source); } - compilerConfigurations.add( compilerConfig ); - + compilerConfigurations.add(compilerConfig); } return compilerConfigurations; } - public String getTargetVersion() - { + public String getTargetVersion() { return null; } - public String getSourceVersion() - { + public String getSourceVersion() { return null; } - - private List normalizePaths( Collection relativePaths ) - { + private List normalizePaths(Collection relativePaths) { return relativePaths.stream() - .map( s -> s.replace( File.separatorChar, '/' ) ) + .map(s -> s.replace(File.separatorChar, '/')) .collect(Collectors.toList()); } - protected int compilerErrorCount( List messages ) - { + protected int compilerErrorCount(List messages) { int count = 0; - for ( CompilerMessage message : messages ) - { + for (CompilerMessage message : messages) { count += message.isError() ? 1 : 0; } return count; } - protected int expectedErrors() - { + protected int expectedErrors() { return 1; } - protected int expectedWarnings() - { + protected int expectedWarnings() { return 0; } - protected Collection expectedOutputFiles() - { + protected Collection expectedOutputFiles() { return Collections.emptyList(); } - protected File getLocalArtifactPath( String groupId, String artifactId, String version, String type ) - { - VersionRange versionRange = VersionRange.createFromVersion( version ); + protected File getLocalArtifactPath(String groupId, String artifactId, String version, String type) { + VersionRange versionRange = VersionRange.createFromVersion(version); - Artifact artifact = new DefaultArtifact( groupId, artifactId, versionRange, Artifact.SCOPE_COMPILE, type, null, - new DefaultArtifactHandler( type ) ); + Artifact artifact = new DefaultArtifact( + groupId, + artifactId, + versionRange, + Artifact.SCOPE_COMPILE, + type, + null, + new DefaultArtifactHandler(type)); - return getLocalArtifactPath( artifact ); + return getLocalArtifactPath(artifact); } - protected String getJavaVersion() - { + protected String getJavaVersion() { - String javaVersion = System.getProperty( "java.version" ); + String javaVersion = System.getProperty("java.version"); String realJavaVersion = javaVersion; - int dotIdx = javaVersion.indexOf( "." ); - if ( dotIdx > -1 ) - { + int dotIdx = javaVersion.indexOf("."); + if (dotIdx > -1) { int lastDot = dotIdx; // find the next dot, so we can trim up to this point. - dotIdx = javaVersion.indexOf( ".", lastDot + 1 ); - if ( dotIdx > lastDot ) - { - javaVersion = javaVersion.substring( 0, dotIdx ); + dotIdx = javaVersion.indexOf(".", lastDot + 1); + if (dotIdx > lastDot) { + javaVersion = javaVersion.substring(0, dotIdx); } } - System.out.println( "java.version is: " + realJavaVersion + "\ntrimmed java version is: " + javaVersion - + "\ncomparison: \"1.5\".compareTo( \"" + javaVersion + "\" ) == " + ( "1.5".compareTo( - javaVersion ) ) + "\n" ); + System.out.println("java.version is: " + realJavaVersion + "\ntrimmed java version is: " + javaVersion + + "\ncomparison: \"1.5\".compareTo( \"" + javaVersion + "\" ) == " + ("1.5".compareTo(javaVersion)) + + "\n"); return javaVersion; } - protected File getLocalArtifactPath( Artifact artifact ) - { - return new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) ); + protected File getLocalArtifactPath(Artifact artifact) { + return new File(localRepository.getBasedir(), localRepository.pathOf(artifact)); } } diff --git a/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajc/AspectJCompiler.java b/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajc/AspectJCompiler.java index b403f32a..d3503d8b 100644 --- a/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajc/AspectJCompiler.java +++ b/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajc/AspectJCompiler.java @@ -1,5 +1,20 @@ package org.codehaus.plexus.compiler.ajc; +import javax.inject.Named; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.aspectj.ajdt.ajc.BuildArgParser; import org.aspectj.ajdt.internal.core.builder.AjBuildConfig; import org.aspectj.ajdt.internal.core.builder.AjBuildManager; @@ -17,21 +32,6 @@ import org.codehaus.plexus.compiler.CompilerResult; import org.codehaus.plexus.util.DirectoryScanner; -import javax.inject.Named; -import javax.inject.Singleton; -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - /** *

* Options @@ -288,201 +288,164 @@ * @author Jason van Zyl */ @Named("aspectj") -public class AspectJCompiler - extends AbstractCompiler -{ +public class AspectJCompiler extends AbstractCompiler { // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public AspectJCompiler() - { + public AspectJCompiler() { // Input file ending "" means: Give me all files, I am going to filter them myself later. We are doing this, // because in method 'getSourceFiles' we need to search for both ".java" and ".aj" files. - super( CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE, "", ".class", null ); + super(CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE, "", ".class", null); } @Override - public String getCompilerId() - { + public String getCompilerId() { return "aspectj"; } - public CompilerResult performCompile( CompilerConfiguration config ) - throws CompilerException - { - File destinationDir = new File( config.getOutputLocation() ); + public CompilerResult performCompile(CompilerConfiguration config) throws CompilerException { + File destinationDir = new File(config.getOutputLocation()); - if ( !destinationDir.exists() ) - { + if (!destinationDir.exists()) { destinationDir.mkdirs(); } - String[] sourceFiles = getSourceFiles( config ); + String[] sourceFiles = getSourceFiles(config); - if ( sourceFiles.length == 0 ) - { + if (sourceFiles.length == 0) { return new CompilerResult(); } - logCompiling( sourceFiles, config ); + logCompiling(sourceFiles, config); // String[] args = buildCompilerArguments( config, sourceFiles ); - AjBuildConfig buildConfig = buildCompilerConfig( config ); - return new CompilerResult().compilerMessages( compileInProcess( buildConfig ) ); + AjBuildConfig buildConfig = buildCompilerConfig(config); + return new CompilerResult().compilerMessages(compileInProcess(buildConfig)); } - private static class AspectJMessagePrinter extends Main.MessagePrinter - { - public AspectJMessagePrinter( boolean verbose ) - { - super( verbose ); + private static class AspectJMessagePrinter extends Main.MessagePrinter { + public AspectJMessagePrinter(boolean verbose) { + super(verbose); } } - private AjBuildConfig buildCompilerConfig( CompilerConfiguration config ) - throws CompilerException - { + private AjBuildConfig buildCompilerConfig(CompilerConfiguration config) throws CompilerException { BuildArgParser buildArgParser = new BuildArgParser(new AspectJMessagePrinter(config.isVerbose())); AjBuildConfig buildConfig = new AjBuildConfig(buildArgParser); // Avoid NPE when AjBuildConfig.getCheckedClasspaths() is called later during compilation buildArgParser.populateBuildConfig(buildConfig, new String[0], true, null); - buildConfig.setIncrementalMode( false ); + buildConfig.setIncrementalMode(false); - String[] files = getSourceFiles( config ); - if ( files != null ) - { - buildConfig.setFiles( buildFileList( Arrays.asList( files ) ) ); + String[] files = getSourceFiles(config); + if (files != null) { + buildConfig.setFiles(buildFileList(Arrays.asList(files))); } String releaseVersion = config.getReleaseVersion(); - setSourceVersion( buildConfig, releaseVersion == null ? config.getSourceVersion() : releaseVersion ); - setTargetVersion( buildConfig, releaseVersion == null ? config.getTargetVersion() : releaseVersion ); + setSourceVersion(buildConfig, releaseVersion == null ? config.getSourceVersion() : releaseVersion); + setTargetVersion(buildConfig, releaseVersion == null ? config.getTargetVersion() : releaseVersion); - if ( config.isDebug() ) - { + if (config.isDebug()) { buildConfig.getOptions().produceDebugAttributes = - ClassFileConstants.ATTR_SOURCE + ClassFileConstants.ATTR_LINES + ClassFileConstants.ATTR_VARS; + ClassFileConstants.ATTR_SOURCE + ClassFileConstants.ATTR_LINES + ClassFileConstants.ATTR_VARS; } Map javaOpts = config.getCustomCompilerArgumentsAsMap(); - if ( javaOpts != null && !javaOpts.isEmpty() ) - { + if (javaOpts != null && !javaOpts.isEmpty()) { // TODO support customCompilerArguments // buildConfig.setJavaOptions( javaOpts ); } - List cp = new LinkedList<>( config.getClasspathEntries() ); - - File javaHomeDir = new File( System.getProperty( "java.home" ) ); - File[] jars = new File( javaHomeDir, "lib" ).listFiles(); - if ( jars != null ) - { - for ( File jar : jars ) - { - if ( jar.getName().endsWith( ".jar" ) || jar.getName().endsWith( ".zip" ) ) - { - cp.add( 0, jar.getAbsolutePath() ); + List cp = new LinkedList<>(config.getClasspathEntries()); + + File javaHomeDir = new File(System.getProperty("java.home")); + File[] jars = new File(javaHomeDir, "lib").listFiles(); + if (jars != null) { + for (File jar : jars) { + if (jar.getName().endsWith(".jar") || jar.getName().endsWith(".zip")) { + cp.add(0, jar.getAbsolutePath()); } } } - jars = new File( javaHomeDir, "../Classes" ).listFiles(); - if ( jars != null ) - { - for ( File jar : jars ) - { - if ( jar.getName().endsWith( ".jar" ) || jar.getName().endsWith( ".zip" ) ) - { - cp.add( 0, jar.getAbsolutePath() ); + jars = new File(javaHomeDir, "../Classes").listFiles(); + if (jars != null) { + for (File jar : jars) { + if (jar.getName().endsWith(".jar") || jar.getName().endsWith(".zip")) { + cp.add(0, jar.getAbsolutePath()); } } } - checkForAspectJRT( cp ); - if ( cp != null && !cp.isEmpty() ) - { - List elements = new ArrayList<>( cp.size() ); - for ( String path : cp ) - { - elements.add( ( new File( path ) ).getAbsolutePath() ); + checkForAspectJRT(cp); + if (cp != null && !cp.isEmpty()) { + List elements = new ArrayList<>(cp.size()); + for (String path : cp) { + elements.add((new File(path)).getAbsolutePath()); } - buildConfig.setClasspath( elements ); + buildConfig.setClasspath(elements); } String outputLocation = config.getOutputLocation(); - if ( outputLocation != null ) - { - File outDir = new File( outputLocation ); - if ( !outDir.exists() ) - { + if (outputLocation != null) { + File outDir = new File(outputLocation); + if (!outDir.exists()) { outDir.mkdirs(); } - buildConfig.setOutputDir( outDir ); + buildConfig.setOutputDir(outDir); } - if ( config instanceof AspectJCompilerConfiguration ) - { + if (config instanceof AspectJCompilerConfiguration) { AspectJCompilerConfiguration ajCfg = (AspectJCompilerConfiguration) config; Map sourcePathResources = ajCfg.getSourcePathResources(); - if ( sourcePathResources != null && !sourcePathResources.isEmpty() ) - { - buildConfig.setSourcePathResources( sourcePathResources ); + if (sourcePathResources != null && !sourcePathResources.isEmpty()) { + buildConfig.setSourcePathResources(sourcePathResources); } Map ajOptions = ajCfg.getAJOptions(); - if ( ajOptions != null && !ajOptions.isEmpty() ) - { + if (ajOptions != null && !ajOptions.isEmpty()) { // TODO not supported - //buildConfig.setAjOptions( ajCfg.getAJOptions() ); + // buildConfig.setAjOptions( ajCfg.getAJOptions() ); } - List aspectPath = buildFileList( ajCfg.getAspectPath() ); - if ( aspectPath != null && !aspectPath.isEmpty() ) - { - buildConfig.setAspectpath( buildFileList( ajCfg.getAspectPath() ) ); + List aspectPath = buildFileList(ajCfg.getAspectPath()); + if (aspectPath != null && !aspectPath.isEmpty()) { + buildConfig.setAspectpath(buildFileList(ajCfg.getAspectPath())); } - List inJars = buildFileList( ajCfg.getInJars() ); - if ( inJars != null && !inJars.isEmpty() ) - { - buildConfig.setInJars( buildFileList( ajCfg.getInJars() ) ); + List inJars = buildFileList(ajCfg.getInJars()); + if (inJars != null && !inJars.isEmpty()) { + buildConfig.setInJars(buildFileList(ajCfg.getInJars())); } - List inPaths = buildFileList( ajCfg.getInPath() ); - if ( inPaths != null && !inPaths.isEmpty() ) - { - buildConfig.setInPath( buildFileList( ajCfg.getInPath() ) ); + List inPaths = buildFileList(ajCfg.getInPath()); + if (inPaths != null && !inPaths.isEmpty()) { + buildConfig.setInPath(buildFileList(ajCfg.getInPath())); } String outJar = ajCfg.getOutputJar(); - if ( outJar != null ) - { - buildConfig.setOutputJar( new File( ajCfg.getOutputJar() ) ); + if (outJar != null) { + buildConfig.setOutputJar(new File(ajCfg.getOutputJar())); } } return buildConfig; } - private List compileInProcess( AjBuildConfig buildConfig ) - throws CompilerException - { + private List compileInProcess(AjBuildConfig buildConfig) throws CompilerException { MessageHandler messageHandler = new MessageHandler(); - AjBuildManager manager = new AjBuildManager( messageHandler ); + AjBuildManager manager = new AjBuildManager(messageHandler); - try - { - manager.batchBuild( buildConfig, messageHandler ); - } - catch ( AbortException | IOException e ) - { - throw new CompilerException( "Unknown error while compiling", e ); + try { + manager.batchBuild(buildConfig, messageHandler); + } catch (AbortException | IOException e) { + throw new CompilerException("Unknown error while compiling", e); } // We need the location of the maven so we have a couple of options @@ -494,73 +457,60 @@ private List compileInProcess( AjBuildConfig buildConfig ) // property or we // could pass in a set of parameters in a Map. - boolean errors = messageHandler.hasAnyMessage( IMessage.ERROR, true ); + boolean errors = messageHandler.hasAnyMessage(IMessage.ERROR, true); List messages = new ArrayList<>(); - if ( errors ) - { - IMessage[] errorMessages = messageHandler.getMessages( IMessage.ERROR, true ); + if (errors) { + IMessage[] errorMessages = messageHandler.getMessages(IMessage.ERROR, true); - for ( IMessage m : errorMessages ) - { + for (IMessage m : errorMessages) { ISourceLocation sourceLocation = m.getSourceLocation(); CompilerMessage error; - if ( sourceLocation == null ) - { - error = new CompilerMessage( m.getMessage(), true ); - } - else - { - error = - new CompilerMessage( sourceLocation.getSourceFile().getPath(), true, sourceLocation.getLine(), - sourceLocation.getColumn(), sourceLocation.getEndLine(), - sourceLocation.getColumn(), m.getMessage() ); + if (sourceLocation == null) { + error = new CompilerMessage(m.getMessage(), true); + } else { + error = new CompilerMessage( + sourceLocation.getSourceFile().getPath(), + true, + sourceLocation.getLine(), + sourceLocation.getColumn(), + sourceLocation.getEndLine(), + sourceLocation.getColumn(), + m.getMessage()); } - messages.add( error ); + messages.add(error); } } return messages; } - private void checkForAspectJRT( List cp ) - { - if ( cp == null || cp.isEmpty() ) - { - throw new IllegalStateException( "AspectJ Runtime not found in supplied classpath" ); - } - else - { - try - { + private void checkForAspectJRT(List cp) { + if (cp == null || cp.isEmpty()) { + throw new IllegalStateException("AspectJ Runtime not found in supplied classpath"); + } else { + try { URL[] urls = new URL[cp.size()]; - for ( int i = 0; i < urls.length; i++ ) - { - urls[i] = ( new File( cp.get( i ) ) ).toURL(); + for (int i = 0; i < urls.length; i++) { + urls[i] = (new File(cp.get(i))).toURL(); } - URLClassLoader cloader = new URLClassLoader( urls ); + URLClassLoader cloader = new URLClassLoader(urls); - cloader.loadClass( "org.aspectj.lang.JoinPoint" ); - } - catch ( MalformedURLException e ) - { - throw new IllegalArgumentException( "Invalid classpath entry" ); - } - catch ( ClassNotFoundException e ) - { - throw new IllegalStateException( "AspectJ Runtime not found in supplied classpath" ); + cloader.loadClass("org.aspectj.lang.JoinPoint"); + } catch (MalformedURLException e) { + throw new IllegalArgumentException("Invalid classpath entry"); + } catch (ClassNotFoundException e) { + throw new IllegalStateException("AspectJ Runtime not found in supplied classpath"); } } } - private List buildFileList( List locations ) - { + private List buildFileList(List locations) { List fileList = new LinkedList<>(); - for ( String location : locations ) - { - fileList.add( new File( location ) ); + for (String location : locations) { + fileList.add(new File(location)); } return fileList; @@ -572,10 +522,8 @@ private List buildFileList( List locations ) * @param buildConfig * @param sourceVersion */ - private void setSourceVersion( AjBuildConfig buildConfig, String sourceVersion ) - throws CompilerException - { - buildConfig.getOptions().sourceLevel = versionStringToMajorMinor( sourceVersion ); + private void setSourceVersion(AjBuildConfig buildConfig, String sourceVersion) throws CompilerException { + buildConfig.getOptions().sourceLevel = versionStringToMajorMinor(sourceVersion); } /** @@ -584,124 +532,120 @@ private void setSourceVersion( AjBuildConfig buildConfig, String sourceVersion ) * @param buildConfig * @param targetVersion */ - private void setTargetVersion( AjBuildConfig buildConfig, String targetVersion ) - throws CompilerException - { - buildConfig.getOptions().targetJDK = versionStringToMajorMinor( targetVersion ); + private void setTargetVersion(AjBuildConfig buildConfig, String targetVersion) throws CompilerException { + buildConfig.getOptions().targetJDK = versionStringToMajorMinor(targetVersion); } - private static long versionStringToMajorMinor(String version) throws CompilerException - { - if ( version == null ) - { + private static long versionStringToMajorMinor(String version) throws CompilerException { + if (version == null) { version = ""; } // Note: We avoid using org.codehaus.plexus:plexus-java here on purpose, because Maven Compiler might depend on // a different (older) versionm, e.g. not having the 'asMajor' method yet. This can cause problems for users // trying to compile their AspectJ code using Plexus. - + version = version.trim() - // Cut off leading "1.", focusing on the Java major - .replaceFirst( "^1[.]", "" ) - // Accept, but cut off trailing ".0", as ECJ/ACJ explicitly support versions like 5.0, 8.0, 11.0 - .replaceFirst("[.]0$", ""); - - switch ( version ) - { - // Java 1.6 as a default source/target seems to make sense. Maven Compiler should set its own default - // anyway, so this probably never needs to be used. But not having a default feels bad, too. - case "" : return ClassFileConstants.JDK1_6; - case "1" : return ClassFileConstants.JDK1_1; - case "2" : return ClassFileConstants.JDK1_2; - case "3" : return ClassFileConstants.JDK1_3; - case "4" : return ClassFileConstants.JDK1_4; - case "5" : return ClassFileConstants.JDK1_5; - case "6" : return ClassFileConstants.JDK1_6; - case "7" : return ClassFileConstants.JDK1_7; - case "8" : return ClassFileConstants.JDK1_8; - case "9" : return ClassFileConstants.JDK9; - case "10" : return ClassFileConstants.JDK10; - case "11" : return ClassFileConstants.JDK11; - case "12" : return ClassFileConstants.JDK12; - case "13" : return ClassFileConstants.JDK13; - case "14" : return ClassFileConstants.JDK14; - case "15" : return ClassFileConstants.JDK15; - case "16" : return ClassFileConstants.JDK16; + // Cut off leading "1.", focusing on the Java major + .replaceFirst("^1[.]", "") + // Accept, but cut off trailing ".0", as ECJ/ACJ explicitly support versions like 5.0, 8.0, 11.0 + .replaceFirst("[.]0$", ""); + + switch (version) { + // Java 1.6 as a default source/target seems to make sense. Maven Compiler should set its own default + // anyway, so this probably never needs to be used. But not having a default feels bad, too. + case "": + return ClassFileConstants.JDK1_6; + case "1": + return ClassFileConstants.JDK1_1; + case "2": + return ClassFileConstants.JDK1_2; + case "3": + return ClassFileConstants.JDK1_3; + case "4": + return ClassFileConstants.JDK1_4; + case "5": + return ClassFileConstants.JDK1_5; + case "6": + return ClassFileConstants.JDK1_6; + case "7": + return ClassFileConstants.JDK1_7; + case "8": + return ClassFileConstants.JDK1_8; + case "9": + return ClassFileConstants.JDK9; + case "10": + return ClassFileConstants.JDK10; + case "11": + return ClassFileConstants.JDK11; + case "12": + return ClassFileConstants.JDK12; + case "13": + return ClassFileConstants.JDK13; + case "14": + return ClassFileConstants.JDK14; + case "15": + return ClassFileConstants.JDK15; + case "16": + return ClassFileConstants.JDK16; } - throw new CompilerException( "Unknown Java source/target version number: " + version ); + throw new CompilerException("Unknown Java source/target version number: " + version); } /** * @return null */ - public String[] createCommandLine( CompilerConfiguration config ) - throws CompilerException - { + public String[] createCommandLine(CompilerConfiguration config) throws CompilerException { return null; } - protected static String[] getSourceFiles( CompilerConfiguration config ) - { + protected static String[] getSourceFiles(CompilerConfiguration config) { Set sources = new HashSet<>(); Set sourceFiles = config.getSourceFiles(); - if ( sourceFiles != null && !sourceFiles.isEmpty() ) - { - for ( File sourceFile : sourceFiles ) - { - if ( sourceFile.getName().endsWith( ".java" ) || sourceFile.getName().endsWith( ".aj" ) ) - { - sources.add( sourceFile.getAbsolutePath() ); + if (sourceFiles != null && !sourceFiles.isEmpty()) { + for (File sourceFile : sourceFiles) { + if (sourceFile.getName().endsWith(".java") + || sourceFile.getName().endsWith(".aj")) { + sources.add(sourceFile.getAbsolutePath()); } } - } - else - { - for ( String sourceLocation : config.getSourceLocations() ) - { - sources.addAll( getSourceFilesForSourceRoot( config, sourceLocation ) ); + } else { + for (String sourceLocation : config.getSourceLocations()) { + sources.addAll(getSourceFilesForSourceRoot(config, sourceLocation)); } } String[] result; - if ( sources.isEmpty() ) - { + if (sources.isEmpty()) { result = new String[0]; - } - else - { - result = sources.toArray( new String[sources.size()] ); + } else { + result = sources.toArray(new String[sources.size()]); } return result; } - protected static Set getSourceFilesForSourceRoot( CompilerConfiguration config, String sourceLocation ) - { + protected static Set getSourceFilesForSourceRoot(CompilerConfiguration config, String sourceLocation) { DirectoryScanner scanner = new DirectoryScanner(); - scanner.setBasedir( sourceLocation ); + scanner.setBasedir(sourceLocation); Set includes = config.getIncludes(); - if ( includes != null && !includes.isEmpty() ) - { - String[] inclStrs = includes.toArray( new String[includes.size()] ); - scanner.setIncludes( inclStrs ); - } - else - { - scanner.setIncludes( new String[] {"**/*.java", "**/*.aj"} ); + if (includes != null && !includes.isEmpty()) { + String[] inclStrs = includes.toArray(new String[includes.size()]); + scanner.setIncludes(inclStrs); + } else { + scanner.setIncludes(new String[] {"**/*.java", "**/*.aj"}); } Set excludes = config.getExcludes(); - if ( excludes != null && !excludes.isEmpty() ) - { - String[] exclStrs = excludes.toArray( new String[excludes.size()] ); - scanner.setExcludes( exclStrs ); + if (excludes != null && !excludes.isEmpty()) { + String[] exclStrs = excludes.toArray(new String[excludes.size()]); + scanner.setExcludes(exclStrs); } scanner.scan(); @@ -710,14 +654,12 @@ protected static Set getSourceFilesForSourceRoot( CompilerConfiguration Set sources = new HashSet<>(); - for ( String sourceDirectorySource : sourceDirectorySources ) - { - File f = new File( sourceLocation, sourceDirectorySource ); + for (String sourceDirectorySource : sourceDirectorySources) { + File f = new File(sourceLocation, sourceDirectorySource); - sources.add( f.getPath() ); + sources.add(f.getPath()); } return sources; } - } diff --git a/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajc/AspectJCompilerConfiguration.java b/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajc/AspectJCompilerConfiguration.java index 8ef8aefb..6afcc3c8 100644 --- a/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajc/AspectJCompilerConfiguration.java +++ b/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajc/AspectJCompilerConfiguration.java @@ -13,9 +13,7 @@ /** * @author jdcasey */ -public class AspectJCompilerConfiguration - extends CompilerConfiguration -{ +public class AspectJCompilerConfiguration extends CompilerConfiguration { private List aspectPath = new LinkedList<>(); @@ -29,92 +27,75 @@ public class AspectJCompilerConfiguration private Map sourcePathResources; - public void setAspectPath( List aspectPath ) - { - this.aspectPath = new LinkedList<>( aspectPath ); + public void setAspectPath(List aspectPath) { + this.aspectPath = new LinkedList<>(aspectPath); } - public void addAspectPath( String aspectPath ) - { - this.aspectPath.add( aspectPath ); + public void addAspectPath(String aspectPath) { + this.aspectPath.add(aspectPath); } - public List getAspectPath() - { - return Collections.unmodifiableList( aspectPath ); + public List getAspectPath() { + return Collections.unmodifiableList(aspectPath); } - public void setInJars( List inJars ) - { - this.inJars = new LinkedList<>( inJars ); + public void setInJars(List inJars) { + this.inJars = new LinkedList<>(inJars); } - public void addInJar( String inJar ) - { - this.inJars.add( inJar ); + public void addInJar(String inJar) { + this.inJars.add(inJar); } - public List getInJars() - { - return Collections.unmodifiableList( inJars ); + public List getInJars() { + return Collections.unmodifiableList(inJars); } - public void setInPath( List inPath ) - { - this.inPath = new LinkedList<>( inPath ); + public void setInPath(List inPath) { + this.inPath = new LinkedList<>(inPath); } - public void addInPath( String inPath ) - { - this.inPath.add( inPath ); + public void addInPath(String inPath) { + this.inPath.add(inPath); } - public List getInPath() - { - return Collections.unmodifiableList( inPath ); + public List getInPath() { + return Collections.unmodifiableList(inPath); } - public void setOutputJar( String outputJar ) - { + public void setOutputJar(String outputJar) { this.outputJar = outputJar; } - public String getOutputJar() - { + public String getOutputJar() { return outputJar; } /** * Ignored, not supported yet */ - public void setAJOptions( Map ajOptions ) - { - //TODO - //this.ajOptions = new TreeMap( ajOptions ); + public void setAJOptions(Map ajOptions) { + // TODO + // this.ajOptions = new TreeMap( ajOptions ); } - public void setAJOption( String optionName, String optionValue ) - { - this.ajOptions.put( optionName, optionValue ); + public void setAJOption(String optionName, String optionValue) { + this.ajOptions.put(optionName, optionValue); } /** * Ignored, not supported yet * @return empty Map */ - public Map getAJOptions() - { - return Collections.unmodifiableMap( ajOptions ); + public Map getAJOptions() { + return Collections.unmodifiableMap(ajOptions); } - public void setSourcePathResources( Map sourcePathResources ) - { - this.sourcePathResources = new TreeMap<>( sourcePathResources ); + public void setSourcePathResources(Map sourcePathResources) { + this.sourcePathResources = new TreeMap<>(sourcePathResources); } - public Map getSourcePathResources() - { + public Map getSourcePathResources() { return sourcePathResources; } - } diff --git a/plexus-compilers/plexus-compiler-aspectj/src/test/java/org/codehaus/plexus/compiler/ajc/AspectJCompilerTest.java b/plexus-compilers/plexus-compiler-aspectj/src/test/java/org/codehaus/plexus/compiler/ajc/AspectJCompilerTest.java index 6c20e598..c73cd139 100644 --- a/plexus-compilers/plexus-compiler-aspectj/src/test/java/org/codehaus/plexus/compiler/ajc/AspectJCompilerTest.java +++ b/plexus-compilers/plexus-compiler-aspectj/src/test/java/org/codehaus/plexus/compiler/ajc/AspectJCompilerTest.java @@ -10,35 +10,27 @@ /** * @author Jason van Zyl */ -public class AspectJCompilerTest - extends AbstractCompilerTest -{ - public AspectJCompilerTest() - { +public class AspectJCompilerTest extends AbstractCompilerTest { + public AspectJCompilerTest() { super(); } @Override - protected String getRoleHint() - { + protected String getRoleHint() { return "aspectj"; } @Override - protected Collection expectedOutputFiles() - { - return Arrays.asList( "org/codehaus/foo/ExternalDeps.class", "org/codehaus/foo/Person.class" ); + protected Collection expectedOutputFiles() { + return Arrays.asList("org/codehaus/foo/ExternalDeps.class", "org/codehaus/foo/Person.class"); } @Override - protected List getClasspath() - throws Exception - { + protected List getClasspath() throws Exception { List classpath = super.getClasspath(); - String aspectjVersion = System.getProperty( "aspectj.version" ); - File aspectjRuntime = getLocalArtifactPath( "org.aspectj", "aspectjrt", aspectjVersion, "jar" ); - classpath.add( aspectjRuntime.getAbsolutePath() ); + String aspectjVersion = System.getProperty("aspectj.version"); + File aspectjRuntime = getLocalArtifactPath("org.aspectj", "aspectjrt", aspectjVersion, "jar"); + classpath.add(aspectjRuntime.getAbsolutePath()); return classpath; } - } diff --git a/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler/csharp/CSharpCompiler.java b/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler/csharp/CSharpCompiler.java index 9a232bd2..c2b0bd9c 100644 --- a/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler/csharp/CSharpCompiler.java +++ b/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler/csharp/CSharpCompiler.java @@ -16,23 +16,8 @@ * limitations under the License. */ -import org.codehaus.plexus.compiler.AbstractCompiler; -import org.codehaus.plexus.compiler.CompilerConfiguration; -import org.codehaus.plexus.compiler.CompilerException; -import org.codehaus.plexus.compiler.CompilerMessage; -import org.codehaus.plexus.compiler.CompilerOutputStyle; -import org.codehaus.plexus.compiler.CompilerResult; -import org.codehaus.plexus.util.DirectoryScanner; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.Os; -import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.cli.CommandLineException; -import org.codehaus.plexus.util.cli.CommandLineUtils; -import org.codehaus.plexus.util.cli.Commandline; -import org.codehaus.plexus.util.cli.StreamConsumer; -import org.codehaus.plexus.util.cli.WriterStreamConsumer; - import javax.inject.Named; + import java.io.BufferedReader; import java.io.File; import java.io.FileWriter; @@ -50,33 +35,46 @@ import java.util.Map; import java.util.Set; +import org.codehaus.plexus.compiler.AbstractCompiler; +import org.codehaus.plexus.compiler.CompilerConfiguration; +import org.codehaus.plexus.compiler.CompilerException; +import org.codehaus.plexus.compiler.CompilerMessage; +import org.codehaus.plexus.compiler.CompilerOutputStyle; +import org.codehaus.plexus.compiler.CompilerResult; +import org.codehaus.plexus.util.DirectoryScanner; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.Os; +import org.codehaus.plexus.util.StringUtils; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; +import org.codehaus.plexus.util.cli.StreamConsumer; +import org.codehaus.plexus.util.cli.WriterStreamConsumer; + /** * @author Gilles Dodinet * @author Trygve Laugstøl * @author Matthew Pocock * @author Chris Stevenson */ -@Named( "csharp" ) -public class CSharpCompiler - extends AbstractCompiler -{ +@Named("csharp") +public class CSharpCompiler extends AbstractCompiler { private static final String JAR_SUFFIX = ".jar"; private static final String DLL_SUFFIX = ".dll"; private static final String NET_SUFFIX = ".net"; - + private static final String ARGUMENTS_FILE_NAME = "csharp-arguments"; - private static final String[] DEFAULT_INCLUDES = { "**/**" }; - + private static final String[] DEFAULT_INCLUDES = {"**/**"}; + private Map compilerArguments; // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public CSharpCompiler() - { - super( CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES, ".cs", null, null ); + public CSharpCompiler() { + super(CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES, ".cs", null, null); } // ---------------------------------------------------------------------- @@ -84,117 +82,94 @@ public CSharpCompiler() // ---------------------------------------------------------------------- @Override - public String getCompilerId() - { + public String getCompilerId() { return "csharp"; } - public boolean canUpdateTarget( CompilerConfiguration configuration ) - throws CompilerException - { + public boolean canUpdateTarget(CompilerConfiguration configuration) throws CompilerException { return false; } - public String getOutputFile( CompilerConfiguration configuration ) - throws CompilerException - { - return configuration.getOutputFileName() + "." + getTypeExtension( configuration ); + public String getOutputFile(CompilerConfiguration configuration) throws CompilerException { + return configuration.getOutputFileName() + "." + getTypeExtension(configuration); } - public CompilerResult performCompile( CompilerConfiguration config ) - throws CompilerException - { - File destinationDir = new File( config.getOutputLocation() ); + public CompilerResult performCompile(CompilerConfiguration config) throws CompilerException { + File destinationDir = new File(config.getOutputLocation()); - if ( !destinationDir.exists() ) - { + if (!destinationDir.exists()) { destinationDir.mkdirs(); } - config.setSourceFiles( null ); + config.setSourceFiles(null); - String[] sourceFiles = CSharpCompiler.getSourceFiles( config ); + String[] sourceFiles = CSharpCompiler.getSourceFiles(config); - if ( sourceFiles.length == 0 ) - { - return new CompilerResult().success( true ); + if (sourceFiles.length == 0) { + return new CompilerResult().success(true); } - logCompiling( sourceFiles, config ); + logCompiling(sourceFiles, config); - String[] args = buildCompilerArguments( config, sourceFiles ); + String[] args = buildCompilerArguments(config, sourceFiles); List messages; - if ( config.isFork() ) - { - messages = - compileOutOfProcess( config.getWorkingDirectory(), config.getBuildDirectory(), findExecutable( config ), - args ); - } - else - { - throw new CompilerException( "This compiler doesn't support in-process compilation." ); + if (config.isFork()) { + messages = compileOutOfProcess( + config.getWorkingDirectory(), config.getBuildDirectory(), findExecutable(config), args); + } else { + throw new CompilerException("This compiler doesn't support in-process compilation."); } - return new CompilerResult().compilerMessages( messages ); + return new CompilerResult().compilerMessages(messages); } - public String[] createCommandLine( CompilerConfiguration config ) - throws CompilerException - { - return buildCompilerArguments( config, CSharpCompiler.getSourceFiles( config ) ); + public String[] createCommandLine(CompilerConfiguration config) throws CompilerException { + return buildCompilerArguments(config, CSharpCompiler.getSourceFiles(config)); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - private Map getCompilerArguments( CompilerConfiguration config ) - { - if (compilerArguments != null) - { + private Map getCompilerArguments(CompilerConfiguration config) { + if (compilerArguments != null) { return compilerArguments; } - + compilerArguments = config.getCustomCompilerArgumentsAsMap(); - + Iterator i = compilerArguments.keySet().iterator(); - - while ( i.hasNext() ) - { + + while (i.hasNext()) { String orig = i.next(); - String v = compilerArguments.get( orig ); - if ( orig.contains( ":" ) && v == null ) - { - String[] arr = orig.split( ":" ); + String v = compilerArguments.get(orig); + if (orig.contains(":") && v == null) { + String[] arr = orig.split(":"); i.remove(); String k = arr[0]; v = arr[1]; - compilerArguments.put( k, v ); - if ( config.isDebug() ) - { - System.out.println( "transforming argument from " + orig + " to " + k + " = [" + v + "]" ); + compilerArguments.put(k, v); + if (config.isDebug()) { + System.out.println("transforming argument from " + orig + " to " + k + " = [" + v + "]"); } } } - - config.setCustomCompilerArgumentsAsMap( compilerArguments ); - + + config.setCustomCompilerArgumentsAsMap(compilerArguments); + return compilerArguments; } - private String findExecutable( CompilerConfiguration config ) - { + private String findExecutable(CompilerConfiguration config) { String executable = config.getExecutable(); - if ( !StringUtils.isEmpty( executable ) ) - { + if (!StringUtils.isEmpty(executable)) { return executable; } - if ( Os.isFamily( "windows" ) ) - { + if (Os.isFamily("windows")) { return "csc"; } @@ -202,60 +177,56 @@ private String findExecutable( CompilerConfiguration config ) } /* -$ mcs --help -Mono C# compiler, (C) 2001 - 2003 Ximian, Inc. -mcs [options] source-files - --about About the Mono C# compiler - -addmodule:MODULE Adds the module to the generated assembly - -checked[+|-] Set default context to checked - -codepage:ID Sets code page to the one in ID (number, utf8, reset) - -clscheck[+|-] Disables CLS Compliance verifications - -define:S1[;S2] Defines one or more symbols (short: /d:) - -debug[+|-], -g Generate debugging information - -delaysign[+|-] Only insert the public key into the assembly (no signing) - -doc:FILE XML Documentation file to generate - -keycontainer:NAME The key pair container used to strongname the assembly - -keyfile:FILE The strongname key file used to strongname the assembly - -langversion:TEXT Specifies language version modes: ISO-1 or Default - -lib:PATH1,PATH2 Adds the paths to the assembly link path - -main:class Specified the class that contains the entry point - -noconfig[+|-] Disables implicit references to assemblies - -nostdlib[+|-] Does not load core libraries - -nowarn:W1[,W2] Disables one or more warnings - -optimize[+|-] Enables code optimalizations - -out:FNAME Specifies output file - -pkg:P1[,Pn] References packages P1..Pn - -recurse:SPEC Recursively compiles the files in SPEC ([dir]/file) - -reference:ASS References the specified assembly (-r:ASS) - -target:KIND Specifies the target (KIND is one of: exe, winexe, - library, module), (short: /t:) - -unsafe[+|-] Allows unsafe code - -warnaserror[+|-] Treat warnings as errors - -warn:LEVEL Sets warning level (the highest is 4, the default is 2) - -help2 Show other help flags - -Resources: - -linkresource:FILE[,ID] Links FILE as a resource - -resource:FILE[,ID] Embed FILE as a resource - -win32res:FILE Specifies Win32 resource file (.res) - -win32icon:FILE Use this icon for the output - @file Read response file for more options - -Options can be of the form -option or /option - */ - - private String[] buildCompilerArguments( CompilerConfiguration config, String[] sourceFiles ) - throws CompilerException - { + $ mcs --help + Mono C# compiler, (C) 2001 - 2003 Ximian, Inc. + mcs [options] source-files + --about About the Mono C# compiler + -addmodule:MODULE Adds the module to the generated assembly + -checked[+|-] Set default context to checked + -codepage:ID Sets code page to the one in ID (number, utf8, reset) + -clscheck[+|-] Disables CLS Compliance verifications + -define:S1[;S2] Defines one or more symbols (short: /d:) + -debug[+|-], -g Generate debugging information + -delaysign[+|-] Only insert the public key into the assembly (no signing) + -doc:FILE XML Documentation file to generate + -keycontainer:NAME The key pair container used to strongname the assembly + -keyfile:FILE The strongname key file used to strongname the assembly + -langversion:TEXT Specifies language version modes: ISO-1 or Default + -lib:PATH1,PATH2 Adds the paths to the assembly link path + -main:class Specified the class that contains the entry point + -noconfig[+|-] Disables implicit references to assemblies + -nostdlib[+|-] Does not load core libraries + -nowarn:W1[,W2] Disables one or more warnings + -optimize[+|-] Enables code optimalizations + -out:FNAME Specifies output file + -pkg:P1[,Pn] References packages P1..Pn + -recurse:SPEC Recursively compiles the files in SPEC ([dir]/file) + -reference:ASS References the specified assembly (-r:ASS) + -target:KIND Specifies the target (KIND is one of: exe, winexe, + library, module), (short: /t:) + -unsafe[+|-] Allows unsafe code + -warnaserror[+|-] Treat warnings as errors + -warn:LEVEL Sets warning level (the highest is 4, the default is 2) + -help2 Show other help flags + + Resources: + -linkresource:FILE[,ID] Links FILE as a resource + -resource:FILE[,ID] Embed FILE as a resource + -win32res:FILE Specifies Win32 resource file (.res) + -win32icon:FILE Use this icon for the output + @file Read response file for more options + + Options can be of the form -option or /option + */ + + private String[] buildCompilerArguments(CompilerConfiguration config, String[] sourceFiles) + throws CompilerException { List args = new ArrayList<>(); - if ( config.isDebug() ) - { - args.add( "/debug+" ); - } - else - { - args.add( "/debug-" ); + if (config.isDebug()) { + args.add("/debug+"); + } else { + args.add("/debug-"); } // config.isShowWarnings() @@ -267,41 +238,32 @@ private String[] buildCompilerArguments( CompilerConfiguration config, String[] // // ---------------------------------------------------------------------- - for ( String element : config.getClasspathEntries() ) - { - File f = new File( element ); + for (String element : config.getClasspathEntries()) { + File f = new File(element); - if ( !f.isFile() ) - { + if (!f.isFile()) { continue; } - + if (element.endsWith(JAR_SUFFIX)) { - try - { + try { File dllDir = new File(element + NET_SUFFIX); - if (!dllDir.exists()) - { + if (!dllDir.exists()) { dllDir.mkdir(); } JarUtil.extract(dllDir.toPath(), new File(element)); - for (String tmpfile : dllDir.list()) - { - if ( tmpfile.endsWith(DLL_SUFFIX) ) - { - String dll = Paths.get(dllDir.getAbsolutePath(), tmpfile).toString(); - args.add( "/reference:\"" + dll + "\"" ); + for (String tmpfile : dllDir.list()) { + if (tmpfile.endsWith(DLL_SUFFIX)) { + String dll = + Paths.get(dllDir.getAbsolutePath(), tmpfile).toString(); + args.add("/reference:\"" + dll + "\""); } } + } catch (IOException e) { + throw new CompilerException(e.toString(), e); } - catch ( IOException e ) - { - throw new CompilerException( e.toString(), e ); - } - } - else - { - args.add( "/reference:\"" + element + "\"" ); + } else { + args.add("/reference:\"" + element + "\""); } } @@ -309,171 +271,144 @@ private String[] buildCompilerArguments( CompilerConfiguration config, String[] // Main class // ---------------------------------------------------------------------- - Map compilerArguments = getCompilerArguments( config ); + Map compilerArguments = getCompilerArguments(config); - String mainClass = compilerArguments.get( "-main" ); + String mainClass = compilerArguments.get("-main"); - if ( !StringUtils.isEmpty( mainClass ) ) - { - args.add( "/main:" + mainClass ); + if (!StringUtils.isEmpty(mainClass)) { + args.add("/main:" + mainClass); } // ---------------------------------------------------------------------- // Xml Doc output // ---------------------------------------------------------------------- - String doc = compilerArguments.get( "-doc" ); + String doc = compilerArguments.get("-doc"); - if ( !StringUtils.isEmpty( doc ) ) - { - args.add( "/doc:" + new File( config.getOutputLocation(), - config.getOutputFileName() + ".xml" ).getAbsolutePath() ); + if (!StringUtils.isEmpty(doc)) { + args.add("/doc:" + + new File(config.getOutputLocation(), config.getOutputFileName() + ".xml").getAbsolutePath()); } // ---------------------------------------------------------------------- // Xml Doc output // ---------------------------------------------------------------------- - String nowarn = compilerArguments.get( "-nowarn" ); + String nowarn = compilerArguments.get("-nowarn"); - if ( !StringUtils.isEmpty( nowarn ) ) - { - args.add( "/nowarn:" + nowarn ); + if (!StringUtils.isEmpty(nowarn)) { + args.add("/nowarn:" + nowarn); } // ---------------------------------------------------------------------- // Out - Override output name, this is required for generating the unit test dll // ---------------------------------------------------------------------- - String out = compilerArguments.get( "-out" ); + String out = compilerArguments.get("-out"); - if ( !StringUtils.isEmpty( out ) ) - { - args.add( "/out:" + new File( config.getOutputLocation(), out ).getAbsolutePath() ); - } - else - { - args.add( "/out:" + new File( config.getOutputLocation(), getOutputFile( config ) ).getAbsolutePath() ); + if (!StringUtils.isEmpty(out)) { + args.add("/out:" + new File(config.getOutputLocation(), out).getAbsolutePath()); + } else { + args.add("/out:" + new File(config.getOutputLocation(), getOutputFile(config)).getAbsolutePath()); } // ---------------------------------------------------------------------- // Resource File - compile in a resource file into the assembly being created // ---------------------------------------------------------------------- - String resourcefile = compilerArguments.get( "-resourcefile" ); + String resourcefile = compilerArguments.get("-resourcefile"); - if ( !StringUtils.isEmpty( resourcefile ) ) - { - String resourceTarget = compilerArguments.get( "-resourcetarget" ); - args.add( "/res:" + new File( resourcefile ).getAbsolutePath() + "," + resourceTarget ); + if (!StringUtils.isEmpty(resourcefile)) { + String resourceTarget = compilerArguments.get("-resourcetarget"); + args.add("/res:" + new File(resourcefile).getAbsolutePath() + "," + resourceTarget); } // ---------------------------------------------------------------------- - // Target - type of assembly to produce, lib,exe,winexe etc... + // Target - type of assembly to produce, lib,exe,winexe etc... // ---------------------------------------------------------------------- - String target = compilerArguments.get( "-target" ); + String target = compilerArguments.get("-target"); - if ( StringUtils.isEmpty( target ) ) - { - args.add( "/target:library" ); - } - else - { - args.add( "/target:" + target ); + if (StringUtils.isEmpty(target)) { + args.add("/target:library"); + } else { + args.add("/target:" + target); } // ---------------------------------------------------------------------- // remove MS logo from output (not applicable for mono) // ---------------------------------------------------------------------- - String nologo = compilerArguments.get( "-nologo" ); + String nologo = compilerArguments.get("-nologo"); - if ( !StringUtils.isEmpty( nologo ) ) - { - args.add( "/nologo" ); + if (!StringUtils.isEmpty(nologo)) { + args.add("/nologo"); } // ---------------------------------------------------------------------- // add any resource files // ---------------------------------------------------------------------- - this.addResourceArgs( config, args ); + this.addResourceArgs(config, args); // ---------------------------------------------------------------------- // add source files // ---------------------------------------------------------------------- - for ( String sourceFile : sourceFiles ) - { - args.add( sourceFile ); + for (String sourceFile : sourceFiles) { + args.add(sourceFile); } - return args.toArray( new String[args.size()] ); + return args.toArray(new String[args.size()]); } - private void addResourceArgs( CompilerConfiguration config, List args ) - { - File filteredResourceDir = this.findResourceDir( config ); - if ( ( filteredResourceDir != null ) && filteredResourceDir.exists() ) - { + private void addResourceArgs(CompilerConfiguration config, List args) { + File filteredResourceDir = this.findResourceDir(config); + if ((filteredResourceDir != null) && filteredResourceDir.exists()) { DirectoryScanner scanner = new DirectoryScanner(); - scanner.setBasedir( filteredResourceDir ); - scanner.setIncludes( DEFAULT_INCLUDES ); + scanner.setBasedir(filteredResourceDir); + scanner.setIncludes(DEFAULT_INCLUDES); scanner.addDefaultExcludes(); scanner.scan(); - List includedFiles = Arrays.asList( scanner.getIncludedFiles() ); - for ( String name : includedFiles ) - { - File filteredResource = new File( filteredResourceDir, name ); - String assemblyResourceName = this.convertNameToAssemblyResourceName( name ); + List includedFiles = Arrays.asList(scanner.getIncludedFiles()); + for (String name : includedFiles) { + File filteredResource = new File(filteredResourceDir, name); + String assemblyResourceName = this.convertNameToAssemblyResourceName(name); String argLine = "/resource:\"" + filteredResource + "\",\"" + assemblyResourceName + "\""; - if ( config.isDebug() ) - { - System.out.println( "adding resource arg line:" + argLine ); + if (config.isDebug()) { + System.out.println("adding resource arg line:" + argLine); } - args.add( argLine ); - + args.add(argLine); } } } - private File findResourceDir( CompilerConfiguration config ) - { - if ( config.isDebug() ) - { - System.out.println( "Looking for resourcesDir" ); + private File findResourceDir(CompilerConfiguration config) { + if (config.isDebug()) { + System.out.println("Looking for resourcesDir"); } - - Map compilerArguments = getCompilerArguments( config ); - - String tempResourcesDirAsString = compilerArguments.get( "-resourceDir" ); + + Map compilerArguments = getCompilerArguments(config); + + String tempResourcesDirAsString = compilerArguments.get("-resourceDir"); File filteredResourceDir = null; - if ( tempResourcesDirAsString != null ) - { - filteredResourceDir = new File( tempResourcesDirAsString ); - if ( config.isDebug() ) - { - System.out.println( "Found resourceDir at: " + filteredResourceDir.toString() ); + if (tempResourcesDirAsString != null) { + filteredResourceDir = new File(tempResourcesDirAsString); + if (config.isDebug()) { + System.out.println("Found resourceDir at: " + filteredResourceDir.toString()); } - } - else - { - if ( config.isDebug() ) - { - System.out.println( "No resourceDir was available." ); + } else { + if (config.isDebug()) { + System.out.println("No resourceDir was available."); } } return filteredResourceDir; } - private String convertNameToAssemblyResourceName( String name ) - { - return name.replace( File.separatorChar, '.' ); + private String convertNameToAssemblyResourceName(String name) { + return name.replace(File.separatorChar, '.'); } - @SuppressWarnings( "deprecation" ) - private List compileOutOfProcess( File workingDirectory, File target, String executable, - String[] args ) - throws CompilerException - { + @SuppressWarnings("deprecation") + private List compileOutOfProcess( + File workingDirectory, File target, String executable, String[] args) throws CompilerException { // ---------------------------------------------------------------------- // Build the @arguments file // ---------------------------------------------------------------------- @@ -482,24 +417,18 @@ private List compileOutOfProcess( File workingDirectory, File t PrintWriter output = null; - try - { - file = new File( target, ARGUMENTS_FILE_NAME ); + try { + file = new File(target, ARGUMENTS_FILE_NAME); - output = new PrintWriter( new FileWriter( file ) ); + output = new PrintWriter(new FileWriter(file)); - for ( String arg : args ) - { - output.println( arg ); + for (String arg : args) { + output.println(arg); } - } - catch ( IOException e ) - { - throw new CompilerException( "Error writing arguments file.", e ); - } - finally - { - IOUtil.close( output ); + } catch (IOException e) { + throw new CompilerException("Error writing arguments file.", e); + } finally { + IOUtil.close(output); } // ---------------------------------------------------------------------- @@ -508,58 +437,50 @@ private List compileOutOfProcess( File workingDirectory, File t Commandline cli = new Commandline(); - cli.setWorkingDirectory( workingDirectory.getAbsolutePath() ); + cli.setWorkingDirectory(workingDirectory.getAbsolutePath()); - cli.setExecutable( executable ); + cli.setExecutable(executable); - cli.createArgument().setValue( "@" + file.getAbsolutePath() ); + cli.createArgument().setValue("@" + file.getAbsolutePath()); Writer stringWriter = new StringWriter(); - StreamConsumer out = new WriterStreamConsumer( stringWriter ); + StreamConsumer out = new WriterStreamConsumer(stringWriter); - StreamConsumer err = new WriterStreamConsumer( stringWriter ); + StreamConsumer err = new WriterStreamConsumer(stringWriter); int returnCode; List messages; - try - { - returnCode = CommandLineUtils.executeCommandLine( cli, out, err ); + try { + returnCode = CommandLineUtils.executeCommandLine(cli, out, err); - messages = parseCompilerOutput( new BufferedReader( new StringReader( stringWriter.toString() ) ) ); - } - catch ( CommandLineException | IOException e ) - { - throw new CompilerException( "Error while executing the external compiler.", e ); + messages = parseCompilerOutput(new BufferedReader(new StringReader(stringWriter.toString()))); + } catch (CommandLineException | IOException e) { + throw new CompilerException("Error while executing the external compiler.", e); } - if ( returnCode != 0 && messages.isEmpty() ) - { + if (returnCode != 0 && messages.isEmpty()) { // TODO: exception? - messages.add( new CompilerMessage( - "Failure executing the compiler, but could not parse the error:" + EOL + stringWriter.toString(), - true ) ); + messages.add(new CompilerMessage( + "Failure executing the compiler, but could not parse the error:" + EOL + stringWriter.toString(), + true)); } return messages; } - public static List parseCompilerOutput( BufferedReader bufferedReader ) - throws IOException - { + public static List parseCompilerOutput(BufferedReader bufferedReader) throws IOException { List messages = new ArrayList<>(); String line = bufferedReader.readLine(); - while ( line != null ) - { - CompilerMessage compilerError = DefaultCSharpCompilerParser.parseLine( line ); + while (line != null) { + CompilerMessage compilerError = DefaultCSharpCompilerParser.parseLine(line); - if ( compilerError != null ) - { - messages.add( compilerError ); + if (compilerError != null) { + messages.add(compilerError); } line = bufferedReader.readLine(); @@ -568,106 +489,84 @@ public static List parseCompilerOutput( BufferedReader buffered return messages; } - private String getType( Map compilerArguments ) - { - String type = compilerArguments.get( "-target" ); + private String getType(Map compilerArguments) { + String type = compilerArguments.get("-target"); - if ( StringUtils.isEmpty( type ) ) - { + if (StringUtils.isEmpty(type)) { return "library"; } return type; } - private String getTypeExtension( CompilerConfiguration configuration ) - throws CompilerException - { - String type = getType( configuration.getCustomCompilerArgumentsAsMap() ); + private String getTypeExtension(CompilerConfiguration configuration) throws CompilerException { + String type = getType(configuration.getCustomCompilerArgumentsAsMap()); - if ( "exe".equals( type ) || "winexe".equals( type ) ) - { + if ("exe".equals(type) || "winexe".equals(type)) { return "exe"; } - if ( "library".equals( type ) || "module".equals( type ) ) - { + if ("library".equals(type) || "module".equals(type)) { return "dll"; } - throw new CompilerException( "Unrecognized type '" + type + "'." ); + throw new CompilerException("Unrecognized type '" + type + "'."); } - // added for debug purposes.... - protected static String[] getSourceFiles( CompilerConfiguration config ) - { + // added for debug purposes.... + protected static String[] getSourceFiles(CompilerConfiguration config) { Set sources = new HashSet<>(); - //Set sourceFiles = null; - //was: + // Set sourceFiles = null; + // was: Set sourceFiles = config.getSourceFiles(); - if ( sourceFiles != null && !sourceFiles.isEmpty() ) - { - for ( File sourceFile : sourceFiles ) - { - sources.add( sourceFile.getAbsolutePath() ); + if (sourceFiles != null && !sourceFiles.isEmpty()) { + for (File sourceFile : sourceFiles) { + sources.add(sourceFile.getAbsolutePath()); } - } - else - { - for ( String sourceLocation : config.getSourceLocations() ) - { - if (!new File(sourceLocation).exists()) - { - if ( config.isDebug() ) - { - System.out.println( "Ignoring not found sourceLocation at: " + sourceLocation ); + } else { + for (String sourceLocation : config.getSourceLocations()) { + if (!new File(sourceLocation).exists()) { + if (config.isDebug()) { + System.out.println("Ignoring not found sourceLocation at: " + sourceLocation); } continue; } - sources.addAll( getSourceFilesForSourceRoot( config, sourceLocation ) ); + sources.addAll(getSourceFilesForSourceRoot(config, sourceLocation)); } } String[] result; - if ( sources.isEmpty() ) - { + if (sources.isEmpty()) { result = new String[0]; - } - else - { - result = sources.toArray( new String[sources.size()] ); + } else { + result = sources.toArray(new String[sources.size()]); } return result; } - protected static Set getSourceFilesForSourceRoot( CompilerConfiguration config, String sourceLocation ) - { + protected static Set getSourceFilesForSourceRoot(CompilerConfiguration config, String sourceLocation) { DirectoryScanner scanner = new DirectoryScanner(); - scanner.setBasedir( sourceLocation ); + scanner.setBasedir(sourceLocation); Set includes = config.getIncludes(); - if ( includes != null && !includes.isEmpty() ) - { - String[] inclStrs = includes.toArray( new String[includes.size()] ); - scanner.setIncludes( inclStrs ); - } - else - { - scanner.setIncludes( new String[]{ "**/*.cs" } ); + if (includes != null && !includes.isEmpty()) { + String[] inclStrs = includes.toArray(new String[includes.size()]); + scanner.setIncludes(inclStrs); + } else { + scanner.setIncludes(new String[] {"**/*.cs"}); } Set excludes = config.getExcludes(); - if ( excludes != null && !excludes.isEmpty() ) - { - String[] exclStrs = excludes.toArray( new String[excludes.size()] ); - scanner.setIncludes( exclStrs ); + if (excludes != null && !excludes.isEmpty()) { + String[] exclStrs = excludes.toArray(new String[excludes.size()]); + scanner.setIncludes(exclStrs); } scanner.scan(); @@ -676,11 +575,10 @@ protected static Set getSourceFilesForSourceRoot( CompilerConfiguration Set sources = new HashSet<>(); - for ( String source : sourceDirectorySources ) - { - File f = new File( sourceLocation, source ); + for (String source : sourceDirectorySources) { + File f = new File(sourceLocation, source); - sources.add( f.getPath() ); + sources.add(f.getPath()); } return sources; diff --git a/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler/csharp/DefaultCSharpCompilerParser.java b/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler/csharp/DefaultCSharpCompilerParser.java index 54643673..6ef8188a 100644 --- a/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler/csharp/DefaultCSharpCompilerParser.java +++ b/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler/csharp/DefaultCSharpCompilerParser.java @@ -18,8 +18,7 @@ * @author Matthew Pocock * @author Chris Stevenson */ -public class DefaultCSharpCompilerParser -{ +public class DefaultCSharpCompilerParser { private static String ERROR_PREFIX = "error "; @@ -29,44 +28,36 @@ public class DefaultCSharpCompilerParser private static String MAGIC_LINE_MARKER_2 = ")"; - - public static CompilerMessage parseLine( String line ) - { + public static CompilerMessage parseLine(String line) { CompilerMessage ce = null; - if ( isOutputWithNoColumnNumber( line ) ) - { - ce = parseLineWithNoColumnNumber( line ); - } - else - { - ce = parseLineWithColumnNumberAndLineNumber( line ); + if (isOutputWithNoColumnNumber(line)) { + ce = parseLineWithNoColumnNumber(line); + } else { + ce = parseLineWithColumnNumberAndLineNumber(line); } return ce; } - private static boolean isOutputWithNoColumnNumber( String line ) - { + private static boolean isOutputWithNoColumnNumber(String line) { - int i = line.indexOf( MAGIC_LINE_MARKER ); + int i = line.indexOf(MAGIC_LINE_MARKER); - if ( i == -1 ) - { + if (i == -1) { return true; } - String chunk1 = line.substring( i + MAGIC_LINE_MARKER.length() ); + String chunk1 = line.substring(i + MAGIC_LINE_MARKER.length()); - int j = chunk1.indexOf( MAGIC_LINE_MARKER_2 ); + int j = chunk1.indexOf(MAGIC_LINE_MARKER_2); - String chunk2 = chunk1.substring( 0, j ); + String chunk2 = chunk1.substring(0, j); - return !chunk2.contains( "," ); + return !chunk2.contains(","); } - private static CompilerMessage parseLineWithNoColumnNumber( String line ) - { + private static CompilerMessage parseLineWithNoColumnNumber(String line) { String file = null; boolean error = true; @@ -76,47 +67,38 @@ private static CompilerMessage parseLineWithNoColumnNumber( String line ) int endcolumn = -1; String message; - if ( line.startsWith( ERROR_PREFIX ) ) - { - message = line.substring( ERROR_PREFIX.length() ); - } - else if ( line.startsWith( COMPILATION_PREFIX ) ) - { + if (line.startsWith(ERROR_PREFIX)) { + message = line.substring(ERROR_PREFIX.length()); + } else if (line.startsWith(COMPILATION_PREFIX)) { // ignore return null; - } - else if ( line.contains( MAGIC_LINE_MARKER ) ) - { - int i = line.indexOf( MAGIC_LINE_MARKER ); + } else if (line.contains(MAGIC_LINE_MARKER)) { + int i = line.indexOf(MAGIC_LINE_MARKER); - int j = line.indexOf( ' ', i ); + int j = line.indexOf(' ', i); - file = line.substring( 0, i + 3 ); + file = line.substring(0, i + 3); - String num = line.substring( i + MAGIC_LINE_MARKER.length(), j - 1 ); + String num = line.substring(i + MAGIC_LINE_MARKER.length(), j - 1); - startline = Integer.parseInt( num ); + startline = Integer.parseInt(num); endline = startline; - message = line.substring( j + 1 + ERROR_PREFIX.length() ); + message = line.substring(j + 1 + ERROR_PREFIX.length()); - error = line.contains( ") error" ); - } - else - { - System.err.println( "Unknown output: " + line ); + error = line.contains(") error"); + } else { + System.err.println("Unknown output: " + line); return null; } - return new CompilerMessage( file, error, startline, startcolumn, endline, endcolumn, message ); - + return new CompilerMessage(file, error, startline, startcolumn, endline, endcolumn, message); } - private static CompilerMessage parseLineWithColumnNumberAndLineNumber( String line ) - { + private static CompilerMessage parseLineWithColumnNumberAndLineNumber(String line) { String file = null; boolean error = true; @@ -126,63 +108,50 @@ private static CompilerMessage parseLineWithColumnNumberAndLineNumber( String li int endcolumn = -1; String message; - if ( line.startsWith( ERROR_PREFIX ) ) - { - message = line.substring( ERROR_PREFIX.length() ); - } - else if ( line.startsWith( COMPILATION_PREFIX ) ) - { + if (line.startsWith(ERROR_PREFIX)) { + message = line.substring(ERROR_PREFIX.length()); + } else if (line.startsWith(COMPILATION_PREFIX)) { return null; - } - else if ( line.contains( MAGIC_LINE_MARKER ) ) - { - int i = line.indexOf( MAGIC_LINE_MARKER ); + } else if (line.contains(MAGIC_LINE_MARKER)) { + int i = line.indexOf(MAGIC_LINE_MARKER); - int j = line.indexOf( ' ', i ); + int j = line.indexOf(' ', i); - file = line.substring( 0, i + 3 ); + file = line.substring(0, i + 3); - String linecol = line.substring( i + MAGIC_LINE_MARKER.length(), j - 2 ); + String linecol = line.substring(i + MAGIC_LINE_MARKER.length(), j - 2); String linenum = null; String colnum = null; - if ( linecol.contains( "," ) && linecol.split( "," ).length == 2 ) - { - linenum = linecol.split( "," )[0]; - colnum = linecol.split( "," )[1]; - } - else if ( linecol.split( "," ).length == 1 ) - { - linenum = linecol.split( "," )[0]; + if (linecol.contains(",") && linecol.split(",").length == 2) { + linenum = linecol.split(",")[0]; + colnum = linecol.split(",")[1]; + } else if (linecol.split(",").length == 1) { + linenum = linecol.split(",")[0]; colnum = "-1"; - } - else - { + } else { linenum = linecol.trim(); colnum = "-1"; } - startline = StringUtils.isEmpty( linenum ) ? -1 : Integer.parseInt( linenum ); + startline = StringUtils.isEmpty(linenum) ? -1 : Integer.parseInt(linenum); - startcolumn = StringUtils.isEmpty( colnum ) ? -1 : Integer.parseInt( colnum ); + startcolumn = StringUtils.isEmpty(colnum) ? -1 : Integer.parseInt(colnum); endline = startline; endcolumn = startcolumn; - message = line.substring( j + 1 + ERROR_PREFIX.length() ); + message = line.substring(j + 1 + ERROR_PREFIX.length()); - error = line.contains( "): error" ); - } - else - { - System.err.println( "Unknown output: " + line ); + error = line.contains("): error"); + } else { + System.err.println("Unknown output: " + line); return null; } - return new CompilerMessage( file, error, startline, startcolumn, endline, endcolumn, message ); + return new CompilerMessage(file, error, startline, startcolumn, endline, endcolumn, message); } - } diff --git a/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler/csharp/JarUtil.java b/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler/csharp/JarUtil.java index 2d5689b7..37edda5e 100644 --- a/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler/csharp/JarUtil.java +++ b/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler/csharp/JarUtil.java @@ -26,7 +26,7 @@ public static void extract(Path destDir, File jarFile) throws IOException { continue; } try (InputStream is = jar.getInputStream(file); - OutputStream fos = Files.newOutputStream(f)) { + OutputStream fos = Files.newOutputStream(f)) { while (is.available() > 0) { fos.write(is.read()); } diff --git a/plexus-compilers/plexus-compiler-csharp/src/test/java/org/codehaus/plexus/compiler/csharp/CSharpCompilerTest.java b/plexus-compilers/plexus-compiler-csharp/src/test/java/org/codehaus/plexus/compiler/csharp/CSharpCompilerTest.java index 8c9acfca..60c5f362 100644 --- a/plexus-compilers/plexus-compiler-csharp/src/test/java/org/codehaus/plexus/compiler/csharp/CSharpCompilerTest.java +++ b/plexus-compilers/plexus-compiler-csharp/src/test/java/org/codehaus/plexus/compiler/csharp/CSharpCompilerTest.java @@ -23,15 +23,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - -import org.codehaus.plexus.compiler.CompilerMessage; -import org.junit.jupiter.api.Test; - import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; import java.util.List; +import org.codehaus.plexus.compiler.CompilerMessage; +import org.junit.jupiter.api.Test; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; @@ -41,189 +40,135 @@ /** * @author Trygve Laugstøl */ -public class CSharpCompilerTest -{ +public class CSharpCompilerTest { @Test - public void testParser() - throws IOException - { + public void testParser() throws IOException { CompilerMessage error; // ---------------------------------------------------------------------- // Test a few concrete lines // ---------------------------------------------------------------------- - error = DefaultCSharpCompilerParser.parseLine( "error CS2008: No files to compile were specified" ); + error = DefaultCSharpCompilerParser.parseLine("error CS2008: No files to compile were specified"); assertThat(error, notNullValue()); + assertThat(error.getMessage(), is("CS2008: No files to compile were specified")); - assertThat( error.getMessage(), is("CS2008: No files to compile were specified")); - - error = DefaultCSharpCompilerParser.parseLine( "Compilation failed: 1 error(s), 0 warnings" ); + error = DefaultCSharpCompilerParser.parseLine("Compilation failed: 1 error(s), 0 warnings"); - assertThat( error, nullValue() ); + assertThat(error, nullValue()); - error = DefaultCSharpCompilerParser.parseLine( "Compilation succeeded - 2 warning(s)" ); + error = DefaultCSharpCompilerParser.parseLine("Compilation succeeded - 2 warning(s)"); - assertThat( error, nullValue() ); + assertThat(error, nullValue()); error = DefaultCSharpCompilerParser.parseLine( - "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./TestRunnerThread.cs(29) error CS0246: Cannot find type 'NameValueCollection'" ); + "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./TestRunnerThread.cs(29) error CS0246: Cannot find type 'NameValueCollection'"); - assertThat( error, notNullValue() ); + assertThat(error, notNullValue()); - assertThat( error.getStartLine(), is(29)); + assertThat(error.getStartLine(), is(29)); - assertThat( error.getStartColumn(), is(-1) ); + assertThat(error.getStartColumn(), is(-1)); - assertThat( error.getEndLine(), is(29) ); + assertThat(error.getEndLine(), is(29)); - assertThat( error.getEndColumn(), is(-1) ); + assertThat(error.getEndColumn(), is(-1)); - assertThat( error.getMessage(), is( "CS0246: Cannot find type 'NameValueCollection'" ) ); + assertThat(error.getMessage(), is("CS0246: Cannot find type 'NameValueCollection'")); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- String input = - "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./TestRunnerThread.cs(5) error CS0234: The type or namespace name `Specialized' could not be found in namespace `System.Collections'\n" - + - "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./TestRunnerThread.cs(29) error CS0246: Cannot find type 'NameValueCollection'\n" - + - "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./Reflect.cs(4) error CS0234: The type or namespace name `Framework' could not be found in namespace `NUnit'\n" - + - "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./Reflect.cs(123) error CS0246: Cannot find type 'TestFixtureAttribute'\n" - + - "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./Reflect.cs(129) error CS0246: Cannot find type 'TestAttribute'\n" - + - "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./Reflect.cs(135) error CS0246: Cannot find type 'IgnoreAttribute'\n" - + - "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./Reflect.cs(141) error CS0246: Cannot find type 'ExpectedExceptionAttribute'\n" - + - "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./WarningSuite.cs(49) error CS0506: `NUnit.Core.WarningSuite.Add': cannot override inherited member `TestSuite.Add' because it is not virtual, abstract or override\n" - + - "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./WarningSuite.cs(49) error CS0507: `NUnit.Core.WarningSuite.Add': can't change the access modifiers when overriding inherited member `TestSuite.Add'\n" - + - "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./WarningSuite.cs(56) error CS0115: 'NUnit.Core.WarningSuite.CreateNewSuite(System.Type)': no suitable methods found to override\n" - + "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./TestRunnerThread.cs(5) error CS0234: The type or namespace name `Specialized' could not be found in namespace `System.Collections'\n" - + - "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./TestRunnerThread.cs(5) error CS0246: The namespace `System.Collections.Specialized' can not be found (missing assembly reference?)\n" - + - "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./Reflect.cs(4) error CS0234: The type or namespace name `Framework' could not be found in namespace `NUnit'\n" - + - "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./Reflect.cs(4) error CS0246: The namespace `NUnit.Framework' can not be found (missing assembly reference?)\n" - + - "Compilation failed: 14 error(s), 0 warnings"; + + "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./TestRunnerThread.cs(29) error CS0246: Cannot find type 'NameValueCollection'\n" + + "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./Reflect.cs(4) error CS0234: The type or namespace name `Framework' could not be found in namespace `NUnit'\n" + + "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./Reflect.cs(123) error CS0246: Cannot find type 'TestFixtureAttribute'\n" + + "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./Reflect.cs(129) error CS0246: Cannot find type 'TestAttribute'\n" + + "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./Reflect.cs(135) error CS0246: Cannot find type 'IgnoreAttribute'\n" + + "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./Reflect.cs(141) error CS0246: Cannot find type 'ExpectedExceptionAttribute'\n" + + "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./WarningSuite.cs(49) error CS0506: `NUnit.Core.WarningSuite.Add': cannot override inherited member `TestSuite.Add' because it is not virtual, abstract or override\n" + + "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./WarningSuite.cs(49) error CS0507: `NUnit.Core.WarningSuite.Add': can't change the access modifiers when overriding inherited member `TestSuite.Add'\n" + + "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./WarningSuite.cs(56) error CS0115: 'NUnit.Core.WarningSuite.CreateNewSuite(System.Type)': no suitable methods found to override\n" + + "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./TestRunnerThread.cs(5) error CS0234: The type or namespace name `Specialized' could not be found in namespace `System.Collections'\n" + + "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./TestRunnerThread.cs(5) error CS0246: The namespace `System.Collections.Specialized' can not be found (missing assembly reference?)\n" + + "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./Reflect.cs(4) error CS0234: The type or namespace name `Framework' could not be found in namespace `NUnit'\n" + + "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./Reflect.cs(4) error CS0246: The namespace `NUnit.Framework' can not be found (missing assembly reference?)\n" + + "Compilation failed: 14 error(s), 0 warnings"; List messages = - CSharpCompiler.parseCompilerOutput( new BufferedReader( new StringReader( input ) ) ); + CSharpCompiler.parseCompilerOutput(new BufferedReader(new StringReader(input))); - assertThat( messages, notNullValue() ); + assertThat(messages, notNullValue()); - assertThat( messages.size(), is(14) ); + assertThat(messages.size(), is(14)); } @Test - public void testParserCscWin() - throws Exception - { + public void testParserCscWin() throws Exception { String cscWin = - "src\\test\\csharp\\Hierarchy\\Logger.cs(77,4): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" - + - "src\\test\\csharp\\Hierarchy\\Logger.cs(98,4): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" - + - "src\\test\\csharp\\Hierarchy\\Logger.cs(126,4): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" - + - "src\\test\\csharp\\Hierarchy\\Logger.cs(151,4): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" - + - "src\\test\\csharp\\Hierarchy\\Logger.cs(187,4): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" - + - "src\\test\\csharp\\Hierarchy\\Logger.cs(222,4): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" - + - "src\\test\\csharp\\Hierarchy\\Logger.cs(255,33): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" - + - "src\\test\\csharp\\Hierarchy\\Logger.cs(270,4): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" - + - "src\\test\\csharp\\Util\\PropertiesDictionaryTest.cs(56,4): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" - + - "src\\main\\csharp\\Flow\\Loader.cs(62,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)\n" - + - "src\\main\\csharp\\Ctl\\Aspx\\AspxController.cs(18,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly\n" - + - "src\\main\\csharp\\Transform\\XsltTransform.cs(78,11): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly\n" - + - "src\\main\\csharp\\View\\DispatchedViewFactory.cs(20,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assemb\n" - + - "src\\main\\csharp\\Flow\\ViewRegistry.cs(31,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly refere\n" - + - "src\\main\\csharp\\Flow\\MasterFactory.cs(50,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly refer\n" - + - "src\\main\\csharp\\Dispatcher.cs(152,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)\n" - + - "src\\main\\csharp\\Flow\\MaverickContext.cs(43,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly ref\n" - + - "src\\main\\csharp\\Transform\\DocumentTransform.cs(38,12): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assem\n" - + - "src\\main\\csharp\\Flow\\CommandBase.cs(11,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly referen\n" - + - "src\\main\\csharp\\Shunt\\LanguageShuntFactory.cs(47,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assemb\n" - + - "src\\main\\csharp\\Shunt\\LanguageShuntFactory.cs(67,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assemb\n" - + - "src\\main\\csharp\\Util\\PropertyPopulator.cs(19,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly r\n" - + - "src\\main\\csharp\\Ctl\\ThrowawayForm.cs(30,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly refere\n" - + - "src\\main\\csharp\\AssemblyInfo.cs(68,12): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)\n"; + "src\\test\\csharp\\Hierarchy\\Logger.cs(77,4): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" + + "src\\test\\csharp\\Hierarchy\\Logger.cs(98,4): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" + + "src\\test\\csharp\\Hierarchy\\Logger.cs(126,4): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" + + "src\\test\\csharp\\Hierarchy\\Logger.cs(151,4): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" + + "src\\test\\csharp\\Hierarchy\\Logger.cs(187,4): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" + + "src\\test\\csharp\\Hierarchy\\Logger.cs(222,4): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" + + "src\\test\\csharp\\Hierarchy\\Logger.cs(255,33): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" + + "src\\test\\csharp\\Hierarchy\\Logger.cs(270,4): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" + + "src\\test\\csharp\\Util\\PropertiesDictionaryTest.cs(56,4): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'\n" + + "src\\main\\csharp\\Flow\\Loader.cs(62,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)\n" + + "src\\main\\csharp\\Ctl\\Aspx\\AspxController.cs(18,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly\n" + + "src\\main\\csharp\\Transform\\XsltTransform.cs(78,11): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly\n" + + "src\\main\\csharp\\View\\DispatchedViewFactory.cs(20,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assemb\n" + + "src\\main\\csharp\\Flow\\ViewRegistry.cs(31,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly refere\n" + + "src\\main\\csharp\\Flow\\MasterFactory.cs(50,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly refer\n" + + "src\\main\\csharp\\Dispatcher.cs(152,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)\n" + + "src\\main\\csharp\\Flow\\MaverickContext.cs(43,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly ref\n" + + "src\\main\\csharp\\Transform\\DocumentTransform.cs(38,12): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assem\n" + + "src\\main\\csharp\\Flow\\CommandBase.cs(11,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly referen\n" + + "src\\main\\csharp\\Shunt\\LanguageShuntFactory.cs(47,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assemb\n" + + "src\\main\\csharp\\Shunt\\LanguageShuntFactory.cs(67,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assemb\n" + + "src\\main\\csharp\\Util\\PropertyPopulator.cs(19,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly r\n" + + "src\\main\\csharp\\Ctl\\ThrowawayForm.cs(30,27): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly refere\n" + + "src\\main\\csharp\\AssemblyInfo.cs(68,12): error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)\n"; List messagesWinCsc = - CSharpCompiler.parseCompilerOutput( new BufferedReader( new StringReader( cscWin ) ) ); + CSharpCompiler.parseCompilerOutput(new BufferedReader(new StringReader(cscWin))); - assertThat( messagesWinCsc, notNullValue() ); + assertThat(messagesWinCsc, notNullValue()); - assertThat( messagesWinCsc.size(), is(24) ); - - assertThat( "Check that the line number is not -1", - messagesWinCsc.get( 0 ).getStartLine(), not(-1) ); - assertThat( "Check that the column number is not -1", - messagesWinCsc.get( 0 ).getStartColumn(), not(-1) ); + assertThat(messagesWinCsc.size(), is(24)); + assertThat("Check that the line number is not -1", messagesWinCsc.get(0).getStartLine(), not(-1)); + assertThat( + "Check that the column number is not -1", messagesWinCsc.get(0).getStartColumn(), not(-1)); } @Test - public void testParserMonoWin() - throws Exception - { + public void testParserMonoWin() throws Exception { String monoWin = - "C:\\Work\\SCM\\SVN\\javaforge\\maven-csharp\\trunk\\maverick-net\\src\\main\\csharp\\Ctl\\ThrowawayForm.cs(30,27): error CS0246: The type or namespace name `log4net' could not be found. Are you missing a using directive or an assembly reference? error CS0234: No such name or typespace log4net\n" - + - "C:\\Work\\SCM\\SVN\\javaforge\\maven-csharp\\trunk\\maverick-net\\src\\main\\csharp\\Util\\PropertyPopulator.cs(19,27): error CS0246: The type or namespace name `log4net' could not be found. Are you missing a using directive or an assembly reference? error CS0234: No such name or typespace log4net\n" - + - "C:\\Work\\SCM\\SVN\\javaforge\\maven-csharp\\trunk\\maverick-net\\src\\main\\csharp\\Flow\\ViewRegistry.cs(31,27): error CS0246: The type or namespace name `log4net' could not be found. Are you missing a using directive or an assembly reference? error CS0234: No such name or typespace log4net\n" - + - "C:\\Work\\SCM\\SVN\\javaforge\\maven-csharp\\trunk\\maverick-net\\src\\main\\csharp\\Shunt\\LanguageShuntFactory.cs(47,27): error CS0246: The type or namespace name `log4net' could not be found. Are you missing a using directive or an assembly reference? error CS0234: No such name or typespace log4net\n" - + - "C:\\Work\\SCM\\SVN\\javaforge\\maven-csharp\\trunk\\maverick-net\\src\\main\\csharp\\Shunt\\LanguageShuntFactory.cs(67,27): error CS0246: The type or namespace name `log4net' could not be found. Are you missing a using directive or an assembly reference? error CS0234: No such name or typespace log4net\n" - + - "Compilation failed: 28 error(s), 0 warnings"; + "C:\\Work\\SCM\\SVN\\javaforge\\maven-csharp\\trunk\\maverick-net\\src\\main\\csharp\\Ctl\\ThrowawayForm.cs(30,27): error CS0246: The type or namespace name `log4net' could not be found. Are you missing a using directive or an assembly reference? error CS0234: No such name or typespace log4net\n" + + "C:\\Work\\SCM\\SVN\\javaforge\\maven-csharp\\trunk\\maverick-net\\src\\main\\csharp\\Util\\PropertyPopulator.cs(19,27): error CS0246: The type or namespace name `log4net' could not be found. Are you missing a using directive or an assembly reference? error CS0234: No such name or typespace log4net\n" + + "C:\\Work\\SCM\\SVN\\javaforge\\maven-csharp\\trunk\\maverick-net\\src\\main\\csharp\\Flow\\ViewRegistry.cs(31,27): error CS0246: The type or namespace name `log4net' could not be found. Are you missing a using directive or an assembly reference? error CS0234: No such name or typespace log4net\n" + + "C:\\Work\\SCM\\SVN\\javaforge\\maven-csharp\\trunk\\maverick-net\\src\\main\\csharp\\Shunt\\LanguageShuntFactory.cs(47,27): error CS0246: The type or namespace name `log4net' could not be found. Are you missing a using directive or an assembly reference? error CS0234: No such name or typespace log4net\n" + + "C:\\Work\\SCM\\SVN\\javaforge\\maven-csharp\\trunk\\maverick-net\\src\\main\\csharp\\Shunt\\LanguageShuntFactory.cs(67,27): error CS0246: The type or namespace name `log4net' could not be found. Are you missing a using directive or an assembly reference? error CS0234: No such name or typespace log4net\n" + + "Compilation failed: 28 error(s), 0 warnings"; List messagesMonoWin = - CSharpCompiler.parseCompilerOutput( new BufferedReader( new StringReader( monoWin ) ) ); - - assertThat( messagesMonoWin, notNullValue() ); + CSharpCompiler.parseCompilerOutput(new BufferedReader(new StringReader(monoWin))); - assertThat( messagesMonoWin.size(), is(5) ); + assertThat(messagesMonoWin, notNullValue()); - assertThat( "Check that the line number is not -1", - messagesMonoWin.get( 0 ).getStartLine(), not(-1) ); - assertThat( "Check that the column number is not -1", - messagesMonoWin.get( 0 ).getStartColumn(), not(-1) ); + assertThat(messagesMonoWin.size(), is(5)); + assertThat( + "Check that the line number is not -1", messagesMonoWin.get(0).getStartLine(), not(-1)); + assertThat( + "Check that the column number is not -1", messagesMonoWin.get(0).getStartColumn(), not(-1)); } - } diff --git a/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/EcjFailureException.java b/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/EcjFailureException.java index 7fda6f47..d3f91310 100644 --- a/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/EcjFailureException.java +++ b/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/EcjFailureException.java @@ -4,19 +4,15 @@ * @author Frits Jalvingh * Created on 22-4-18. */ -public class EcjFailureException - extends RuntimeException -{ +public class EcjFailureException extends RuntimeException { private final String ecjOutput; - public EcjFailureException( String ecjOutput ) - { - super( "Failed to run the ecj compiler: " + ecjOutput ); + public EcjFailureException(String ecjOutput) { + super("Failed to run the ecj compiler: " + ecjOutput); this.ecjOutput = ecjOutput; } - public String getEcjOutput() - { + public String getEcjOutput() { return ecjOutput; } } diff --git a/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/EcjResponseParser.java b/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/EcjResponseParser.java index 651de08d..b02d052c 100644 --- a/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/EcjResponseParser.java +++ b/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/EcjResponseParser.java @@ -1,11 +1,9 @@ package org.codehaus.plexus.compiler.eclipse; -import org.codehaus.plexus.compiler.CompilerMessage; -import org.codehaus.plexus.compiler.CompilerMessage.Kind; - import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamReader; + import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -15,24 +13,25 @@ import java.util.ArrayList; import java.util.List; +import org.codehaus.plexus.compiler.CompilerMessage; +import org.codehaus.plexus.compiler.CompilerMessage.Kind; + /** * @author Frits Jalvingh * Created on 31-3-18. */ -public class EcjResponseParser -{ +public class EcjResponseParser { /*--------------------------------------------------------------*/ /* CODING: Decode ECJ -log format results. */ /*--------------------------------------------------------------*/ private static final XMLInputFactory FACTORY = getStreamFactory(); - static private XMLInputFactory getStreamFactory() - { + private static XMLInputFactory getStreamFactory() { XMLInputFactory xmlif = XMLInputFactory.newInstance(); - xmlif.setProperty( XMLInputFactory.IS_VALIDATING, Boolean.FALSE ); - xmlif.setProperty( XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE ); - xmlif.setProperty( XMLInputFactory.SUPPORT_DTD, Boolean.FALSE ); + xmlif.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE); + xmlif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); + xmlif.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); return xmlif; } @@ -41,54 +40,41 @@ static private XMLInputFactory getStreamFactory() * @param errorsAsWarnings should we treat errors as warnings * Scan the specified response file for compilation messages. */ - public List parse( File xmltf, boolean errorsAsWarnings ) - throws Exception - { - //if(xmltf.length() < 80) + public List parse(File xmltf, boolean errorsAsWarnings) throws Exception { + // if(xmltf.length() < 80) // return; List list = new ArrayList<>(); - try (Reader src = new BufferedReader( new InputStreamReader( new FileInputStream( xmltf ), "utf-8" ) )) - { - XMLStreamReader xsr = FACTORY.createXMLStreamReader( src ); + try (Reader src = new BufferedReader(new InputStreamReader(new FileInputStream(xmltf), "utf-8"))) { + XMLStreamReader xsr = FACTORY.createXMLStreamReader(src); // scan for "source" elements, skip all else. - while ( xsr.hasNext() ) - { + while (xsr.hasNext()) { int type = xsr.next(); - if ( type == XMLStreamConstants.START_ELEMENT && "source".equals( xsr.getLocalName() ) ) - { - decodeSourceElement( list, xsr, errorsAsWarnings ); + if (type == XMLStreamConstants.START_ELEMENT && "source".equals(xsr.getLocalName())) { + decodeSourceElement(list, xsr, errorsAsWarnings); } } } return list; } - private void decodeSourceElement( List list, XMLStreamReader xsr, boolean errorsAsWarnings ) - throws Exception - { - String filename = xsr.getAttributeValue( null, "path" ); + private void decodeSourceElement(List list, XMLStreamReader xsr, boolean errorsAsWarnings) + throws Exception { + String filename = xsr.getAttributeValue(null, "path"); - //-- Got a file- call handler - File path = new File( filename ).getCanonicalFile(); - while ( xsr.hasNext() ) - { + // -- Got a file- call handler + File path = new File(filename).getCanonicalFile(); + while (xsr.hasNext()) { int type = xsr.nextTag(); - if ( type == XMLStreamConstants.START_ELEMENT ) - { - if ( "problems".equals( xsr.getLocalName() ) ) - { - decodeProblems( list, path.toString(), xsr, errorsAsWarnings ); - } - else - { - ignoreTillEnd( xsr ); - } - } - else if ( type == XMLStreamConstants.END_ELEMENT ) - { + if (type == XMLStreamConstants.START_ELEMENT) { + if ("problems".equals(xsr.getLocalName())) { + decodeProblems(list, path.toString(), xsr, errorsAsWarnings); + } else { + ignoreTillEnd(xsr); + } + } else if (type == XMLStreamConstants.END_ELEMENT) { return; } } @@ -97,123 +83,87 @@ else if ( type == XMLStreamConstants.END_ELEMENT ) /** * Locate "problem" nodes. */ - private void decodeProblems( List list, String sourcePath, XMLStreamReader xsr, - boolean errorsAsWarnings ) - throws Exception - { - while ( xsr.hasNext() ) - { + private void decodeProblems( + List list, String sourcePath, XMLStreamReader xsr, boolean errorsAsWarnings) + throws Exception { + while (xsr.hasNext()) { int type = xsr.nextTag(); - if ( type == XMLStreamConstants.START_ELEMENT ) - { - if ( "problem".equals( xsr.getLocalName() ) ) - { - decodeProblem( list, sourcePath, xsr, errorsAsWarnings ); - } - else - { - ignoreTillEnd( xsr ); - } + if (type == XMLStreamConstants.START_ELEMENT) { + if ("problem".equals(xsr.getLocalName())) { + decodeProblem(list, sourcePath, xsr, errorsAsWarnings); + } else { + ignoreTillEnd(xsr); + } - } - else if ( type == XMLStreamConstants.END_ELEMENT ) - { + } else if (type == XMLStreamConstants.END_ELEMENT) { return; } } } - - private void decodeProblem( List list, String sourcePath, XMLStreamReader xsr, - boolean errorsAsWarnings ) - throws Exception - { - String id = xsr.getAttributeValue( null, "optionKey" ); // Key for the problem - int startline = getInt( xsr, "line" ); - int column = getInt( xsr, "charStart" ); - int endCol = getInt( xsr, "charEnd" ); - String sev = xsr.getAttributeValue( null, "severity" ); + private void decodeProblem( + List list, String sourcePath, XMLStreamReader xsr, boolean errorsAsWarnings) + throws Exception { + String id = xsr.getAttributeValue(null, "optionKey"); // Key for the problem + int startline = getInt(xsr, "line"); + int column = getInt(xsr, "charStart"); + int endCol = getInt(xsr, "charEnd"); + String sev = xsr.getAttributeValue(null, "severity"); String message = "Unknown message?"; - //-- Go watch for "message" - while ( xsr.hasNext() ) - { + // -- Go watch for "message" + while (xsr.hasNext()) { int type = xsr.nextTag(); - if ( type == XMLStreamConstants.START_ELEMENT ) - { - if ( "message".equals( xsr.getLocalName() ) ) - { - message = xsr.getAttributeValue( null, "value" ); + if (type == XMLStreamConstants.START_ELEMENT) { + if ("message".equals(xsr.getLocalName())) { + message = xsr.getAttributeValue(null, "value"); } - ignoreTillEnd( xsr ); + ignoreTillEnd(xsr); - } - else if ( type == XMLStreamConstants.END_ELEMENT ) - { + } else if (type == XMLStreamConstants.END_ELEMENT) { break; } } Kind msgtype; - if ( "warning".equalsIgnoreCase( sev ) ) - { - msgtype = Kind.WARNING; - } - else if ( "error".equalsIgnoreCase( sev ) ) - { - msgtype = errorsAsWarnings ? Kind.WARNING : Kind.ERROR; - } - else if ( "info".equalsIgnoreCase( sev ) ) - { - msgtype = Kind.NOTE; - } - else - { - msgtype = Kind.OTHER; - } - - CompilerMessage cm = new CompilerMessage( sourcePath, msgtype, startline, column, startline, endCol, message ); - list.add( cm ); + if ("warning".equalsIgnoreCase(sev)) { + msgtype = Kind.WARNING; + } else if ("error".equalsIgnoreCase(sev)) { + msgtype = errorsAsWarnings ? Kind.WARNING : Kind.ERROR; + } else if ("info".equalsIgnoreCase(sev)) { + msgtype = Kind.NOTE; + } else { + msgtype = Kind.OTHER; + } + + CompilerMessage cm = new CompilerMessage(sourcePath, msgtype, startline, column, startline, endCol, message); + list.add(cm); } - private static void ignoreTillEnd( XMLStreamReader xsr ) - throws Exception - { + private static void ignoreTillEnd(XMLStreamReader xsr) throws Exception { int depth = 1; - while ( xsr.hasNext() ) - { + while (xsr.hasNext()) { int type = xsr.next(); - if ( type == XMLStreamConstants.START_ELEMENT ) - { + if (type == XMLStreamConstants.START_ELEMENT) { depth++; - } - else if ( type == XMLStreamConstants.END_ELEMENT ) - { + } else if (type == XMLStreamConstants.END_ELEMENT) { depth--; - if ( depth == 0 ) - { - return; - } + if (depth == 0) { + return; + } } } } - private static int getInt( XMLStreamReader xsr, String name ) - throws IOException - { - String v = xsr.getAttributeValue( null, name ); - if ( null == v ) - { - return -1; - } - try - { - return Integer.parseInt( v.trim() ); + private static int getInt(XMLStreamReader xsr, String name) throws IOException { + String v = xsr.getAttributeValue(null, name); + if (null == v) { + return -1; } - catch ( Exception x ) - { - throw new IOException( "Illegal integer value '" + v + "' in attribute " + name ); + try { + return Integer.parseInt(v.trim()); + } catch (Exception x) { + throw new IOException("Illegal integer value '" + v + "' in attribute " + name); } } - } diff --git a/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/EclipseJavaCompiler.java b/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/EclipseJavaCompiler.java index 305e76a1..a45f8078 100644 --- a/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/EclipseJavaCompiler.java +++ b/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/EclipseJavaCompiler.java @@ -23,7 +23,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - import javax.inject.Named; import javax.inject.Singleton; import javax.tools.Diagnostic; @@ -45,6 +44,7 @@ import java.util.Locale; import java.util.Map.Entry; import java.util.ServiceLoader; + import org.codehaus.plexus.compiler.AbstractCompiler; import org.codehaus.plexus.compiler.CompilerConfiguration; import org.codehaus.plexus.compiler.CompilerException; @@ -58,14 +58,11 @@ /** * */ -@Named( "eclipse" ) +@Named("eclipse") @Singleton -public class EclipseJavaCompiler - extends AbstractCompiler -{ - public EclipseJavaCompiler() - { - super( CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE, ".java", ".class", null ); +public class EclipseJavaCompiler extends AbstractCompiler { + public EclipseJavaCompiler() { + super(CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE, ".java", ".class", null); } // ---------------------------------------------------------------------- @@ -74,93 +71,72 @@ public EclipseJavaCompiler() boolean errorsAsWarnings = false; @Override - public String getCompilerId() - { + public String getCompilerId() { return "eclipse"; } @Override - public CompilerResult performCompile( CompilerConfiguration config ) - throws CompilerException - { + public CompilerResult performCompile(CompilerConfiguration config) throws CompilerException { List args = new ArrayList<>(); - args.add( "-noExit" ); // Make sure ecj does not System.exit on us 8-/ + args.add("-noExit"); // Make sure ecj does not System.exit on us 8-/ // Build settings from configuration - if ( config.isDebug() ) - { - args.add( "-preserveAllLocals" ); - args.add( "-g:lines,vars,source" ); - } - else - { - args.add( "-g:lines,source" ); + if (config.isDebug()) { + args.add("-preserveAllLocals"); + args.add("-g:lines,vars,source"); + } else { + args.add("-g:lines,source"); } - String releaseVersion = decodeVersion( config.getReleaseVersion() ); + String releaseVersion = decodeVersion(config.getReleaseVersion()); // EcjFailureException: Failed to run the ecj compiler: option -source is not supported when --release is used - if ( releaseVersion != null ) - { - args.add( "--release" ); - args.add( releaseVersion ); - } - else - { - String sourceVersion = decodeVersion( config.getSourceVersion() ); - - if ( sourceVersion != null ) - { - args.add( "-source" ); - args.add( sourceVersion ); + if (releaseVersion != null) { + args.add("--release"); + args.add(releaseVersion); + } else { + String sourceVersion = decodeVersion(config.getSourceVersion()); + + if (sourceVersion != null) { + args.add("-source"); + args.add(sourceVersion); } - String targetVersion = decodeVersion( config.getTargetVersion() ); + String targetVersion = decodeVersion(config.getTargetVersion()); - if ( targetVersion != null ) - { - args.add( "-target" ); - args.add( targetVersion ); + if (targetVersion != null) { + args.add("-target"); + args.add(targetVersion); } } - if ( StringUtils.isNotEmpty( config.getSourceEncoding() ) ) - { - args.add( "-encoding" ); - args.add( config.getSourceEncoding() ); + if (StringUtils.isNotEmpty(config.getSourceEncoding())) { + args.add("-encoding"); + args.add(config.getSourceEncoding()); } - if ( !config.isShowWarnings() ) - { - args.add( "-warn:none" ); - } - else - { + if (!config.isShowWarnings()) { + args.add("-warn:none"); + } else { String warnings = config.getWarnings(); - StringBuilder warns = StringUtils.isEmpty(warnings) - ? new StringBuilder() - : new StringBuilder(warnings).append(','); + StringBuilder warns = + StringUtils.isEmpty(warnings) ? new StringBuilder() : new StringBuilder(warnings).append(','); - if ( config.isShowDeprecation() ) - { - append( warns, "+deprecation" ); - } - else - { - append( warns, "-deprecation" ); + if (config.isShowDeprecation()) { + append(warns, "+deprecation"); + } else { + append(warns, "-deprecation"); } - //-- Make room for more warnings to be enabled/disabled - args.add( "-warn:" + warns ); + // -- Make room for more warnings to be enabled/disabled + args.add("-warn:" + warns); } - if ( config.isParameters() ) - { - args.add( "-parameters" ); + if (config.isParameters()) { + args.add("-parameters"); } - if(config.isFailOnWarning()) - { - args.add("-failOnWarning"); + if (config.isFailOnWarning()) { + args.add("-failOnWarning"); } // Set Eclipse-specific options @@ -168,116 +144,99 @@ public CompilerResult performCompile( CompilerConfiguration config ) this.errorsAsWarnings = processCustomArguments(config, args); // Output path - args.add( "-d" ); - args.add( config.getOutputLocation() ); + args.add("-d"); + args.add(config.getOutputLocation()); // Annotation processors defined? - if ( !isPreJava1_6( config ) ) - { + if (!isPreJava1_6(config)) { File generatedSourcesDir = config.getGeneratedSourcesDirectory(); - if ( generatedSourcesDir != null ) - { + if (generatedSourcesDir != null) { generatedSourcesDir.mkdirs(); - //-- option to specify where annotation processor is to generate its output - args.add( "-s" ); - args.add( generatedSourcesDir.getAbsolutePath() ); + // -- option to specify where annotation processor is to generate its output + args.add("-s"); + args.add(generatedSourcesDir.getAbsolutePath()); } - //now add jdk 1.6 annotation processing related parameters + // now add jdk 1.6 annotation processing related parameters String[] annotationProcessors = config.getAnnotationProcessors(); List processorPathEntries = config.getProcessorPathEntries(); List processorModulePathEntries = config.getProcessorModulePathEntries(); - if ( ( annotationProcessors != null && annotationProcessors.length > 0 ) - || ( processorPathEntries != null && processorPathEntries.size() > 0 ) - || ( processorModulePathEntries != null && processorModulePathEntries.size() > 0 ) ) - { - if ( annotationProcessors != null && annotationProcessors.length > 0 ) - { - args.add( "-processor" ); + if ((annotationProcessors != null && annotationProcessors.length > 0) + || (processorPathEntries != null && processorPathEntries.size() > 0) + || (processorModulePathEntries != null && processorModulePathEntries.size() > 0)) { + if (annotationProcessors != null && annotationProcessors.length > 0) { + args.add("-processor"); StringBuilder sb = new StringBuilder(); - for ( String ap : annotationProcessors ) - { - if ( sb.length() > 0 ) - { - sb.append( ',' ); + for (String ap : annotationProcessors) { + if (sb.length() > 0) { + sb.append(','); } - sb.append( ap ); + sb.append(ap); } - args.add( sb.toString() ); + args.add(sb.toString()); } - if ( processorPathEntries != null && processorPathEntries.size() > 0 ) - { - if ( isReplaceProcessorPath( config ) ) - { - args.add( "--processor-module-path" ); - } - else - { - args.add( "-processorpath" ); + if (processorPathEntries != null && processorPathEntries.size() > 0) { + if (isReplaceProcessorPath(config)) { + args.add("--processor-module-path"); + } else { + args.add("-processorpath"); } - args.add( getPathString( processorPathEntries ) ); + args.add(getPathString(processorPathEntries)); } - if ( processorModulePathEntries != null && processorModulePathEntries.size() > 0 ) - { - args.add( "--processor-module-path" ); - args.add( getPathString( processorModulePathEntries ) ); + if (processorModulePathEntries != null && processorModulePathEntries.size() > 0) { + args.add("--processor-module-path"); + args.add(getPathString(processorModulePathEntries)); } - if ( config.getProc() != null ) - { - args.add( "-proc:" + config.getProc() ); + if (config.getProc() != null) { + args.add("-proc:" + config.getProc()); } } } - //-- classpath - List classpathEntries = new ArrayList<>( config.getClasspathEntries() ); - classpathEntries.add( config.getOutputLocation() ); - args.add( "-classpath" ); - args.add( getPathString( classpathEntries ) ); + // -- classpath + List classpathEntries = new ArrayList<>(config.getClasspathEntries()); + classpathEntries.add(config.getOutputLocation()); + args.add("-classpath"); + args.add(getPathString(classpathEntries)); List modulepathEntries = config.getModulepathEntries(); - if ( modulepathEntries != null && !modulepathEntries.isEmpty() ) - { - args.add( "--module-path" ); - args.add( getPathString( modulepathEntries ) ); + if (modulepathEntries != null && !modulepathEntries.isEmpty()) { + args.add("--module-path"); + args.add(getPathString(modulepathEntries)); } // Collect sources - List allSources = Arrays.asList( getSourceFiles( config ) ); + List allSources = Arrays.asList(getSourceFiles(config)); List messageList = new ArrayList<>(); - if ( allSources.isEmpty() ) - { + if (allSources.isEmpty()) { // -- Nothing to do -> bail out - return new CompilerResult( true, messageList ); + return new CompilerResult(true, messageList); } - allSources = resortSourcesToPutModuleInfoFirst( allSources ); + allSources = resortSourcesToPutModuleInfoFirst(allSources); - logCompiling( null, config ); + logCompiling(null, config); // Compile - try - { + try { StringWriter sw = new StringWriter(); - PrintWriter devNull = new PrintWriter( sw ); + PrintWriter devNull = new PrintWriter(sw); JavaCompiler compiler = getEcj(); boolean success = false; - if ( compiler != null ) - { - log.debug( "Using JSR-199 EclipseCompiler" ); + if (compiler != null) { + log.debug("Using JSR-199 EclipseCompiler"); // ECJ JSR-199 compiles against the latest Java version it supports if no source // version is given explicitly. BatchCompiler uses 1.3 as default. So check // whether a source version is specified, and if not supply 1.3 explicitly. - if ( !haveSourceOrReleaseArgument( args ) ) - { - log.debug( "ecj: no source level nor release specified, defaulting to Java 1.3" ); - args.add( "-source" ); - args.add( "1.3" ); + if (!haveSourceOrReleaseArgument(args)) { + log.debug("ecj: no source level nor release specified, defaulting to Java 1.3"); + args.add("-source"); + args.add("1.3"); } // Also check for the encoding. Could have been set via the CompilerConfig @@ -285,273 +244,214 @@ public CompilerResult performCompile( CompilerConfiguration config ) // StandardJavaFileManager below. String encoding = null; Iterator allArgs = args.iterator(); - while ( encoding == null && allArgs.hasNext() ) - { + while (encoding == null && allArgs.hasNext()) { String option = allArgs.next(); - if ( "-encoding".equals( option ) && allArgs.hasNext() ) - { + if ("-encoding".equals(option) && allArgs.hasNext()) { encoding = allArgs.next(); } } final Locale defaultLocale = Locale.getDefault(); final List messages = messageList; - DiagnosticListener messageCollector = new DiagnosticListener() - { + DiagnosticListener messageCollector = new DiagnosticListener() { @Override - public void report( Diagnostic diagnostic ) - { + public void report(Diagnostic diagnostic) { // Convert to Plexus' CompilerMessage and append to messageList String fileName = "Unknown source"; - try - { + try { JavaFileObject file = diagnostic.getSource(); - if ( file != null ) - { + if (file != null) { fileName = file.getName(); } - } - catch ( NullPointerException e ) - { + } catch (NullPointerException e) { // ECJ bug: diagnostic.getSource() may throw an NPE if there is no source } long startColumn = diagnostic.getColumnNumber(); // endColumn may be wrong if the endPosition is not on the same line. - long endColumn = startColumn + ( diagnostic.getEndPosition() - diagnostic.getStartPosition() ); - CompilerMessage message = new CompilerMessage( fileName, convert( diagnostic.getKind() ), - (int) diagnostic.getLineNumber(), - (int) startColumn, - (int) diagnostic.getLineNumber(), - (int) endColumn, - diagnostic.getMessage( defaultLocale ) ); - messages.add( message ); + long endColumn = startColumn + (diagnostic.getEndPosition() - diagnostic.getStartPosition()); + CompilerMessage message = new CompilerMessage( + fileName, + convert(diagnostic.getKind()), + (int) diagnostic.getLineNumber(), + (int) startColumn, + (int) diagnostic.getLineNumber(), + (int) endColumn, + diagnostic.getMessage(defaultLocale)); + messages.add(message); } }; Charset charset = null; - if ( encoding != null ) - { + if (encoding != null) { encoding = encoding.trim(); - try - { - charset = Charset.forName( encoding ); - } - catch ( IllegalCharsetNameException | UnsupportedCharsetException e ) - { - log.warn( - "ecj: invalid or unsupported character set '" + encoding + "', using default" ); + try { + charset = Charset.forName(encoding); + } catch (IllegalCharsetNameException | UnsupportedCharsetException e) { + log.warn("ecj: invalid or unsupported character set '" + encoding + "', using default"); // charset remains null } } - if ( charset == null ) - { + if (charset == null) { charset = Charset.defaultCharset(); } - if ( log.isDebugEnabled() ) - { - log.debug( "ecj: using character set " + charset.displayName() ); - log.debug( "ecj command line: " + args ); - log.debug( "ecj input source files: " + allSources ); + if (log.isDebugEnabled()) { + log.debug("ecj: using character set " + charset.displayName()); + log.debug("ecj command line: " + args); + log.debug("ecj input source files: " + allSources); } - try ( StandardJavaFileManager manager = - compiler.getStandardFileManager( messageCollector, defaultLocale, charset ) ) { - Iterable units = manager.getJavaFileObjectsFromStrings( allSources ); - success = Boolean.TRUE.equals( - compiler.getTask( devNull, manager, messageCollector, args, null, units ).call() ); - } - catch ( RuntimeException e ) - { - throw new EcjFailureException( e.getLocalizedMessage() ); + try (StandardJavaFileManager manager = + compiler.getStandardFileManager(messageCollector, defaultLocale, charset)) { + Iterable units = manager.getJavaFileObjectsFromStrings(allSources); + success = + Boolean.TRUE.equals(compiler.getTask(devNull, manager, messageCollector, args, null, units) + .call()); + } catch (RuntimeException e) { + throw new EcjFailureException(e.getLocalizedMessage()); } - log.debug( sw.toString() ); - } - else - { + log.debug(sw.toString()); + } else { // Use the BatchCompiler and send all errors to xml temp file. File errorF = null; - try - { - errorF = File.createTempFile( "ecjerr-", ".xml" ); - log.debug( "Using legacy BatchCompiler; error file " + errorF ); - - args.add( "-log" ); - args.add( errorF.toString() ); - args.addAll( allSources ); - - log.debug( "ecj command line: " + args ); - - success = BatchCompiler.compile( args.toArray( new String[args.size()] ), devNull, devNull, - new CompilationProgress() - { - @Override - public void begin( int i ) - { - } - - @Override - public void done() - { - } - - @Override - public boolean isCanceled() - { - return false; - } - - @Override - public void setTaskName( String s ) - { - } - - @Override - public void worked( int i, int i1 ) - { - } - } ); - log.debug( sw.toString() ); - - if ( errorF.length() < 80 ) - { - throw new EcjFailureException( sw.toString() ); + try { + errorF = File.createTempFile("ecjerr-", ".xml"); + log.debug("Using legacy BatchCompiler; error file " + errorF); + + args.add("-log"); + args.add(errorF.toString()); + args.addAll(allSources); + + log.debug("ecj command line: " + args); + + success = BatchCompiler.compile( + args.toArray(new String[args.size()]), devNull, devNull, new CompilationProgress() { + @Override + public void begin(int i) {} + + @Override + public void done() {} + + @Override + public boolean isCanceled() { + return false; + } + + @Override + public void setTaskName(String s) {} + + @Override + public void worked(int i, int i1) {} + }); + log.debug(sw.toString()); + + if (errorF.length() < 80) { + throw new EcjFailureException(sw.toString()); } - messageList = new EcjResponseParser().parse( errorF, errorsAsWarnings ); - } - finally - { - if ( null != errorF ) - { - try - { + messageList = new EcjResponseParser().parse(errorF, errorsAsWarnings); + } finally { + if (null != errorF) { + try { errorF.delete(); - } - catch ( Exception x ) - { + } catch (Exception x) { } } } } boolean hasError = false; - for ( CompilerMessage compilerMessage : messageList ) - { - if ( compilerMessage.isError() ) - { + for (CompilerMessage compilerMessage : messageList) { + if (compilerMessage.isError()) { hasError = true; break; } } - if ( !hasError && !success && !errorsAsWarnings ) - { + if (!hasError && !success && !errorsAsWarnings) { CompilerMessage.Kind kind = - errorsAsWarnings ? CompilerMessage.Kind.WARNING : CompilerMessage.Kind.ERROR; + errorsAsWarnings ? CompilerMessage.Kind.WARNING : CompilerMessage.Kind.ERROR; // -- Compiler reported failure but we do not seem to have one -> probable // exception - CompilerMessage cm = - new CompilerMessage( "[ecj] The compiler reported an error but has not written it to its logging", - kind ); - messageList.add( cm ); + CompilerMessage cm = new CompilerMessage( + "[ecj] The compiler reported an error but has not written it to its logging", kind); + messageList.add(cm); hasError = true; // -- Try to find the actual message by reporting the last 5 lines as a message - String stdout = getLastLines( sw.toString(), 5 ); - if ( stdout.length() > 0 ) - { - cm = - new CompilerMessage( "[ecj] The following line(s) might indicate the issue:\n" + stdout, kind ); - messageList.add( cm ); + String stdout = getLastLines(sw.toString(), 5); + if (stdout.length() > 0) { + cm = new CompilerMessage("[ecj] The following line(s) might indicate the issue:\n" + stdout, kind); + messageList.add(cm); } } - return new CompilerResult( !hasError || errorsAsWarnings, messageList ); - } - catch ( EcjFailureException x ) - { + return new CompilerResult(!hasError || errorsAsWarnings, messageList); + } catch (EcjFailureException x) { throw x; - } - catch ( Exception x ) - { - throw new RuntimeException( x ); // sigh + } catch (Exception x) { + throw new RuntimeException(x); // sigh } } private static final String OPT_REPLACE_PROCESSOR_PATH = "replaceProcessorPathWithProcessorModulePath"; private static final String OPT_REPLACE_PROCESSOR_PATH_ = "-" + OPT_REPLACE_PROCESSOR_PATH; - static boolean isReplaceProcessorPath( CompilerConfiguration config ) - { - for ( Entry entry : config.getCustomCompilerArgumentsEntries() ) - { + static boolean isReplaceProcessorPath(CompilerConfiguration config) { + for (Entry entry : config.getCustomCompilerArgumentsEntries()) { String opt = entry.getKey(); - if ( opt.equals( OPT_REPLACE_PROCESSOR_PATH ) || opt.equals( OPT_REPLACE_PROCESSOR_PATH_ ) ) - { + if (opt.equals(OPT_REPLACE_PROCESSOR_PATH) || opt.equals(OPT_REPLACE_PROCESSOR_PATH_)) { return true; } } return false; } - static List resortSourcesToPutModuleInfoFirst( List allSources ) - { - List resorted = new ArrayList<>( allSources.size() ); + static List resortSourcesToPutModuleInfoFirst(List allSources) { + List resorted = new ArrayList<>(allSources.size()); - for ( String mi : allSources ) - { - if ( mi.endsWith( "module-info.java" ) ) - { - resorted.add( mi ); + for (String mi : allSources) { + if (mi.endsWith("module-info.java")) { + resorted.add(mi); } } - for ( String nmi : allSources ) - { - if ( !nmi.endsWith( "module-info.java") ) - { - resorted.add( nmi ); + for (String nmi : allSources) { + if (!nmi.endsWith("module-info.java")) { + resorted.add(nmi); } } return resorted; } - static boolean processCustomArguments( CompilerConfiguration config, List args ) - { + static boolean processCustomArguments(CompilerConfiguration config, List args) { boolean result = false; - for ( Entry entry : config.getCustomCompilerArgumentsEntries() ) - { + for (Entry entry : config.getCustomCompilerArgumentsEntries()) { String opt = entry.getKey(); String optionValue = entry.getValue(); // handle errorsAsWarnings options - if ( opt.equals("errorsAsWarnings") || opt.equals("-errorsAsWarnings") ) - { + if (opt.equals("errorsAsWarnings") || opt.equals("-errorsAsWarnings")) { result = true; continue; } - if ( opt.equals( "-properties" ) ) - { - if ( null != optionValue ) - { - File propFile = new File( optionValue ); - if ( !propFile.exists() || !propFile.isFile() ) - { + if (opt.equals("-properties")) { + if (null != optionValue) { + File propFile = new File(optionValue); + if (!propFile.exists() || !propFile.isFile()) { throw new IllegalArgumentException( - "Properties file specified by -properties " + propFile + " does not exist" ); + "Properties file specified by -properties " + propFile + " does not exist"); } } } - //-- Write .class files even when error occur, but make sure methods with compile errors do abort when called - if ( opt.equals( "-proceedOnError" ) ) - { + // -- Write .class files even when error occur, but make sure methods with compile errors do abort when + // called + if (opt.equals("-proceedOnError")) { // Generate a class file even with errors, but make methods with errors fail when called - args.add( "-proceedOnError:Fatal" ); + args.add("-proceedOnError:Fatal"); continue; } - if ( !opt.equals( OPT_REPLACE_PROCESSOR_PATH ) && !opt.equals( OPT_REPLACE_PROCESSOR_PATH_ ) ) - { + if (!opt.equals(OPT_REPLACE_PROCESSOR_PATH) && !opt.equals(OPT_REPLACE_PROCESSOR_PATH_)) { /* * The compiler mojo makes quite a mess of passing arguments, depending on exactly WHICH * way is used to pass them. The method method using uses the tag names @@ -579,75 +479,60 @@ static boolean processCustomArguments( CompilerConfiguration config, List args ) - { + private static boolean haveSourceOrReleaseArgument(List args) { Iterator allArgs = args.iterator(); - while ( allArgs.hasNext() ) - { + while (allArgs.hasNext()) { String option = allArgs.next(); - if ( ( "-source".equals( option ) || "--release".equals( option ) ) && allArgs.hasNext() ) - { + if (("-source".equals(option) || "--release".equals(option)) && allArgs.hasNext()) { return true; } } return false; } - private JavaCompiler getEcj() - { + private JavaCompiler getEcj() { ServiceLoader javaCompilerLoader = - ServiceLoader.load( JavaCompiler.class, BatchCompiler.class.getClassLoader() ); + ServiceLoader.load(JavaCompiler.class, BatchCompiler.class.getClassLoader()); Class c = null; - try - { - c = Class.forName( "org.eclipse.jdt.internal.compiler.tool.EclipseCompiler", false, - BatchCompiler.class.getClassLoader() ); - } - catch ( ClassNotFoundException e ) - { + try { + c = Class.forName( + "org.eclipse.jdt.internal.compiler.tool.EclipseCompiler", + false, + BatchCompiler.class.getClassLoader()); + } catch (ClassNotFoundException e) { // Ignore } - if ( c != null ) - { - for ( JavaCompiler javaCompiler : javaCompilerLoader ) - { - if ( c.isInstance( javaCompiler ) ) - { + if (c != null) { + for (JavaCompiler javaCompiler : javaCompilerLoader) { + if (c.isInstance(javaCompiler)) { return javaCompiler; } } } - log.debug( "Cannot find org.eclipse.jdt.internal.compiler.tool.EclipseCompiler" ); + log.debug("Cannot find org.eclipse.jdt.internal.compiler.tool.EclipseCompiler"); return null; } - private CompilerMessage.Kind convert( Diagnostic.Kind kind ) - { - if ( kind == null ) - { + private CompilerMessage.Kind convert(Diagnostic.Kind kind) { + if (kind == null) { return CompilerMessage.Kind.OTHER; } - switch ( kind ) - { + switch (kind) { case ERROR: return errorsAsWarnings ? CompilerMessage.Kind.WARNING : CompilerMessage.Kind.ERROR; case WARNING: @@ -662,23 +547,19 @@ private CompilerMessage.Kind convert( Diagnostic.Kind kind ) } } - private String getLastLines( String text, int lines ) - { + private String getLastLines(String text, int lines) { List lineList = new ArrayList<>(); - text = text.replace( "\r\n", "\n" ); - text = text.replace( "\r", "\n" ); // make sure eoln is \n + text = text.replace("\r\n", "\n"); + text = text.replace("\r", "\n"); // make sure eoln is \n int index = text.length(); - while ( index > 0 ) - { - int before = text.lastIndexOf( '\n', index - 1 ); + while (index > 0) { + int before = text.lastIndexOf('\n', index - 1); - if ( before + 1 < index ) - { // Non empty line? - lineList.add( text.substring( before + 1, index ) ); + if (before + 1 < index) { // Non empty line? + lineList.add(text.substring(before + 1, index)); lines--; - if ( lines <= 0 ) - { + if (lines <= 0) { break; } } @@ -687,46 +568,42 @@ private String getLastLines( String text, int lines ) } StringBuilder sb = new StringBuilder(); - for ( int i = lineList.size() - 1; i >= 0; i-- ) - { - String s = lineList.get( i ); - sb.append( s ); - sb.append( System.getProperty( "line.separator" ) ); // 8-/ + for (int i = lineList.size() - 1; i >= 0; i--) { + String s = lineList.get(i); + sb.append(s); + sb.append(System.getProperty("line.separator")); // 8-/ } return sb.toString(); } - static private void append( StringBuilder warns, String s ) - { - if ( warns.length() > 0 ) - { - warns.append( ',' ); + private static void append(StringBuilder warns, String s) { + if (warns.length() > 0) { + warns.append(','); } - warns.append( s ); + warns.append(s); } - private boolean isPreJava1_6( CompilerConfiguration config ) - { + private boolean isPreJava1_6(CompilerConfiguration config) { String s = config.getSourceVersion(); - if ( s == null ) - { - //now return true, as the 1.6 version is not the default - 1.4 is. + if (s == null) { + // now return true, as the 1.6 version is not the default - 1.4 is. return true; } - return s.startsWith( "1.5" ) || s.startsWith( "1.4" ) || s.startsWith( "1.3" ) || s.startsWith( "1.2" ) - || s.startsWith( "1.1" ) || s.startsWith( "1.0" ); + return s.startsWith("1.5") + || s.startsWith("1.4") + || s.startsWith("1.3") + || s.startsWith("1.2") + || s.startsWith("1.1") + || s.startsWith("1.0"); } @Override - public String[] createCommandLine( CompilerConfiguration config ) - throws CompilerException - { + public String[] createCommandLine(CompilerConfiguration config) throws CompilerException { return null; } @Override - public boolean supportsIncrementalCompilation() - { + public boolean supportsIncrementalCompilation() { return true; } @@ -735,16 +612,13 @@ public boolean supportsIncrementalCompilation() * of the version: the compiler does that nicely, and this allows compiler updates without * changing the compiler plugin. This is important with the half year release cycle for Java. */ - private String decodeVersion( String versionSpec ) - { - if ( StringUtils.isEmpty( versionSpec ) ) - { + private String decodeVersion(String versionSpec) { + if (StringUtils.isEmpty(versionSpec)) { return null; } - if ( versionSpec.equals( "1.9" ) ) - { - log.warn( "Version 9 should be specified as 9, not 1.9" ); + if (versionSpec.equals("1.9")) { + log.warn("Version 9 should be specified as 9, not 1.9"); return "9"; } return versionSpec; diff --git a/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/SourceCodeLocator.java b/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/SourceCodeLocator.java index 76de9dcf..b8b1364d 100644 --- a/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/SourceCodeLocator.java +++ b/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/SourceCodeLocator.java @@ -23,7 +23,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - import java.io.File; import java.util.HashMap; import java.util.List; @@ -32,47 +31,41 @@ /** * @author Trygve Laugstøl */ -public class SourceCodeLocator -{ +public class SourceCodeLocator { private List sourceRoots; private Map cache; - public SourceCodeLocator( List sourceRoots ) - { + public SourceCodeLocator(List sourceRoots) { this.sourceRoots = sourceRoots; cache = new HashMap<>(); } - public File findSourceCodeForClass( String className ) - { - File f = cache.get( className ); + public File findSourceCodeForClass(String className) { + File f = cache.get(className); - if ( f != null ) - { + if (f != null) { return f; } - String sourceName = className.replace( '.', System.getProperty( "file.separator" ).charAt( 0 ) ); + String sourceName = + className.replace('.', System.getProperty("file.separator").charAt(0)); sourceName += ".java"; - f = findInRoots( sourceName ); + f = findInRoots(sourceName); - cache.put( className, f ); + cache.put(className, f); return f; } - private File findInRoots( String s ) - { - for ( String root : sourceRoots ) - { - File f = new File( root, s ); + private File findInRoots(String s) { + for (String root : sourceRoots) { + File f = new File(root, s); - if ( f.exists() ) - { + if (f.exists()) { return f; } } diff --git a/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerConfigurationTest.java b/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerConfigurationTest.java index e14b0476..607c7141 100644 --- a/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerConfigurationTest.java +++ b/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerConfigurationTest.java @@ -23,97 +23,93 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import org.codehaus.plexus.compiler.CompilerConfiguration; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.is; -public class EclipseCompilerConfigurationTest -{ +public class EclipseCompilerConfigurationTest { private static final String PROPERTIES_FILE_NAME = - "src/test/resources".replace( "/", File.separator ) + File.separator - + EclipseCompilerConfigurationTest.class.getName().replace( ".", File.separator ) + "src/test/resources".replace("/", File.separator) + File.separator + + EclipseCompilerConfigurationTest.class.getName().replace(".", File.separator) + "-test.properties"; private CompilerConfiguration configuration; @BeforeEach - protected void setUp() - { + protected void setUp() { configuration = new CompilerConfiguration(); } @Test - public void testProcessCustomArgumentsWithMultipleAddExports() - { - configuration.addCompilerCustomArgument( "--add-exports", "FROM-MOD/package1=OTHER-MOD" ); - configuration.addCompilerCustomArgument( "--add-exports", "FROM-MOD/package2=OTHER-MOD" ); + public void testProcessCustomArgumentsWithMultipleAddExports() { + configuration.addCompilerCustomArgument("--add-exports", "FROM-MOD/package1=OTHER-MOD"); + configuration.addCompilerCustomArgument("--add-exports", "FROM-MOD/package2=OTHER-MOD"); List args = new ArrayList<>(); - EclipseJavaCompiler.processCustomArguments( configuration, args ); - assertThat( args.size(), is(4) ); - assertThat( args, contains("--add-exports", "FROM-MOD/package1=OTHER-MOD", "--add-exports", "FROM-MOD/package2=OTHER-MOD")); -// assertThat( args.get( 0 ), is("--add-exports") ); -// assertThat( args.get( 1 ), is("FROM-MOD/package1=OTHER-MOD") ); -// assertThat( args.get( 2 ), is("--add-exports") ); -// assertThat( args.get( 3 ), is("FROM-MOD/package2=OTHER-MOD") ); + EclipseJavaCompiler.processCustomArguments(configuration, args); + assertThat(args.size(), is(4)); + assertThat( + args, + contains( + "--add-exports", + "FROM-MOD/package1=OTHER-MOD", + "--add-exports", + "FROM-MOD/package2=OTHER-MOD")); + // assertThat( args.get( 0 ), is("--add-exports") ); + // assertThat( args.get( 1 ), is("FROM-MOD/package1=OTHER-MOD") ); + // assertThat( args.get( 2 ), is("--add-exports") ); + // assertThat( args.get( 3 ), is("FROM-MOD/package2=OTHER-MOD") ); } @Test - public void testProcessCustomArgumentsWithProceedOnError() - { - configuration.addCompilerCustomArgument( "-proceedOnError", null ); + public void testProcessCustomArgumentsWithProceedOnError() { + configuration.addCompilerCustomArgument("-proceedOnError", null); List args = new ArrayList<>(); - EclipseJavaCompiler.processCustomArguments( configuration, args ); - assertThat( args.size(), is(1) ); - assertThat( args, contains("-proceedOnError:Fatal") ); + EclipseJavaCompiler.processCustomArguments(configuration, args); + assertThat(args.size(), is(1)); + assertThat(args, contains("-proceedOnError:Fatal")); } @Test - public void testProcessCustomArgumentsWithErrorsAsWarnings() - { - configuration.addCompilerCustomArgument( "errorsAsWarnings", null ); + public void testProcessCustomArgumentsWithErrorsAsWarnings() { + configuration.addCompilerCustomArgument("errorsAsWarnings", null); List args = new ArrayList<>(); - final boolean errorsAsWarnings = EclipseJavaCompiler.processCustomArguments( configuration, args ); - assertThat( errorsAsWarnings, is(true) ); + final boolean errorsAsWarnings = EclipseJavaCompiler.processCustomArguments(configuration, args); + assertThat(errorsAsWarnings, is(true)); } @Test - public void testProcessCustomArgumentsWithErrorsAsWarningsAndMinus() - { - configuration.addCompilerCustomArgument( "-errorsAsWarnings", null ); + public void testProcessCustomArgumentsWithErrorsAsWarningsAndMinus() { + configuration.addCompilerCustomArgument("-errorsAsWarnings", null); List args = new ArrayList<>(); - final boolean errorsAsWarnings = EclipseJavaCompiler.processCustomArguments( configuration, args ); - assertThat( errorsAsWarnings, is(true) ); + final boolean errorsAsWarnings = EclipseJavaCompiler.processCustomArguments(configuration, args); + assertThat(errorsAsWarnings, is(true)); } @Test - public void testProcessCustomArgumentsWithPropertiesAndNonExistingFile() - { - configuration.addCompilerCustomArgument( "-properties", "fooBar.txt" ); - IllegalArgumentException expected = - Assertions.assertThrows(IllegalArgumentException.class, - () -> EclipseJavaCompiler.processCustomArguments( configuration, Collections.emptyList() )); - assertThat( expected.getMessage(), - is( "Properties file specified by -properties fooBar.txt does not exist")); + public void testProcessCustomArgumentsWithPropertiesAndNonExistingFile() { + configuration.addCompilerCustomArgument("-properties", "fooBar.txt"); + IllegalArgumentException expected = Assertions.assertThrows( + IllegalArgumentException.class, + () -> EclipseJavaCompiler.processCustomArguments(configuration, Collections.emptyList())); + assertThat(expected.getMessage(), is("Properties file specified by -properties fooBar.txt does not exist")); } @Test - public void testProcessCustomArgumentsWithPropertiesAndValidFile() - { - configuration.addCompilerCustomArgument( "-properties", PROPERTIES_FILE_NAME ); + public void testProcessCustomArgumentsWithPropertiesAndValidFile() { + configuration.addCompilerCustomArgument("-properties", PROPERTIES_FILE_NAME); List args = new ArrayList<>(); - EclipseJavaCompiler.processCustomArguments( configuration, args ); - assertThat( args.size(), is(2)); + EclipseJavaCompiler.processCustomArguments(configuration, args); + assertThat(args.size(), is(2)); assertThat(args, contains("-properties", PROPERTIES_FILE_NAME)); } } diff --git a/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerDashedArgumentsTest.java b/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerDashedArgumentsTest.java index dc456488..3fc3dd6f 100644 --- a/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerDashedArgumentsTest.java +++ b/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerDashedArgumentsTest.java @@ -23,6 +23,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +import javax.inject.Inject; +import javax.inject.Named; + +import java.io.File; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import org.codehaus.plexus.compiler.Compiler; import org.codehaus.plexus.compiler.CompilerConfiguration; @@ -33,17 +41,8 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import javax.inject.Inject; -import javax.inject.Named; -import java.io.File; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import static org.codehaus.plexus.testing.PlexusExtension.getBasedir; - /** * @author Frits Jalvingh * Created on 22-4-18. @@ -60,11 +59,10 @@ public class EclipseCompilerDashedArgumentsTest { private CompilerConfiguration getConfig() throws Exception { String sourceDir = getBasedir() + "/src/test-input/src/main"; - List filenames = FileUtils.getFileNames( new File( sourceDir ), "**/*.java", null, false, true ); - Collections.sort( filenames ); + List filenames = FileUtils.getFileNames(new File(sourceDir), "**/*.java", null, false, true); + Collections.sort(filenames); Set files = new HashSet<>(); - for(String filename : filenames) - { + for (String filename : filenames) { files.add(new File(filename)); } @@ -72,11 +70,11 @@ private CompilerConfiguration getConfig() throws Exception { compilerConfig.setDebug(false); compilerConfig.setShowDeprecation(false); -// compilerConfig.setClasspathEntries( getClasspath() ); - compilerConfig.addSourceLocation( sourceDir ); - compilerConfig.setOutputLocation( getBasedir() + "/target/eclipse/classes"); - FileUtils.deleteDirectory( compilerConfig.getOutputLocation() ); -// compilerConfig.addInclude( filename ); + // compilerConfig.setClasspathEntries( getClasspath() ); + compilerConfig.addSourceLocation(sourceDir); + compilerConfig.setOutputLocation(getBasedir() + "/target/eclipse/classes"); + FileUtils.deleteDirectory(compilerConfig.getOutputLocation()); + // compilerConfig.addInclude( filename ); compilerConfig.setForceJavacCompilerUse(false); compilerConfig.setSourceFiles(files); @@ -94,15 +92,14 @@ private CompilerConfiguration getConfig() throws Exception { * the invalid option is not part of the error output but part of the data sent to stdout/stderr. */ @Test - public void testDoubleDashOptionsArePassedWithTwoDashes() throws Exception - { + public void testDoubleDashOptionsArePassedWithTwoDashes() throws Exception { CompilerConfiguration config = getConfig(); config.addCompilerCustomArgument(BAD_DOUBLEDASH_OPTION, "b0rk3d"); - EcjFailureException x = Assertions.assertThrows(EcjFailureException.class, () -> compiler.performCompile(config)); + EcjFailureException x = + Assertions.assertThrows(EcjFailureException.class, () -> compiler.performCompile(config)); MatcherAssert.assertThat(x.getEcjOutput(), Matchers.containsString(BAD_DOUBLEDASH_OPTION)); MatcherAssert.assertThat(x.getEcjOutput(), Matchers.not(Matchers.containsString("-" + BAD_DOUBLEDASH_OPTION))); - } } diff --git a/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerErrorsAsWarningsTest.java b/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerErrorsAsWarningsTest.java index af0f44ab..91580922 100644 --- a/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerErrorsAsWarningsTest.java +++ b/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerErrorsAsWarningsTest.java @@ -1,55 +1,50 @@ package org.codehaus.plexus.compiler.eclipse; +import java.util.Arrays; +import java.util.Collection; + import org.codehaus.plexus.compiler.AbstractCompilerTest; import org.codehaus.plexus.compiler.CompilerConfiguration; import org.junit.jupiter.api.BeforeEach; -import java.util.Arrays; -import java.util.Collection; - -public class EclipseCompilerErrorsAsWarningsTest extends AbstractCompilerTest -{ +public class EclipseCompilerErrorsAsWarningsTest extends AbstractCompilerTest { - protected void configureCompilerConfig( CompilerConfiguration compilerConfig ) - { - compilerConfig.addCompilerCustomArgument( "-errorsAsWarnings", "true" ); + protected void configureCompilerConfig(CompilerConfiguration compilerConfig) { + compilerConfig.addCompilerCustomArgument("-errorsAsWarnings", "true"); } @BeforeEach - public void setUp() throws Exception - { - setCompilerDebug( true ); - setCompilerDeprecationWarnings( true ); + public void setUp() throws Exception { + setCompilerDebug(true); + setCompilerDeprecationWarnings(true); } @Override - protected String getRoleHint() - { + protected String getRoleHint() { return "eclipse"; } @Override - protected int expectedErrors() - { + protected int expectedErrors() { return 0; } @Override - protected int expectedWarnings() - { + protected int expectedWarnings() { return 6; } @Override - protected Collection expectedOutputFiles() - { - return Arrays.asList("org/codehaus/foo/Deprecation.class", + protected Collection expectedOutputFiles() { + return Arrays.asList( + "org/codehaus/foo/Deprecation.class", "org/codehaus/foo/ExternalDeps.class", "org/codehaus/foo/Person.class", "org/codehaus/foo/ReservedWord.class" - //"org/codehaus/foo/Bad.class", // This one has no class file generated as it's one big issue - //"org/codehaus/foo/UnknownSymbol.class", - //"org/codehaus/foo/RightClassname.class" - ); + // "org/codehaus/foo/Bad.class", // This one has no class file generated as it's one big + // issue + // "org/codehaus/foo/UnknownSymbol.class", + // "org/codehaus/foo/RightClassname.class" + ); } } diff --git a/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerFailOnWarningsTest.java b/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerFailOnWarningsTest.java index 96756f58..c5a94b3d 100644 --- a/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerFailOnWarningsTest.java +++ b/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerFailOnWarningsTest.java @@ -1,41 +1,36 @@ package org.codehaus.plexus.compiler.eclipse; -import org.codehaus.plexus.compiler.AbstractCompilerTest; -import org.codehaus.plexus.compiler.CompilerConfiguration; - import java.util.Arrays; import java.util.Collection; -public class EclipseCompilerFailOnWarningsTest extends AbstractCompilerTest -{ +import org.codehaus.plexus.compiler.AbstractCompilerTest; +import org.codehaus.plexus.compiler.CompilerConfiguration; + +public class EclipseCompilerFailOnWarningsTest extends AbstractCompilerTest { - protected void configureCompilerConfig( CompilerConfiguration compilerConfig ) - { + protected void configureCompilerConfig(CompilerConfiguration compilerConfig) { compilerConfig.setFailOnWarning(true); } @Override - protected String getRoleHint() - { + protected String getRoleHint() { return "eclipse"; } @Override - protected int expectedErrors() - { + protected int expectedErrors() { return 6; } @Override - protected int expectedWarnings() - { + protected int expectedWarnings() { return 1; } @Override - protected Collection expectedOutputFiles() - { - return Arrays.asList("org/codehaus/foo/Deprecation.class", + protected Collection expectedOutputFiles() { + return Arrays.asList( + "org/codehaus/foo/Deprecation.class", "org/codehaus/foo/ExternalDeps.class", "org/codehaus/foo/Person.class", "org/codehaus/foo/ReservedWord.class"); diff --git a/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerTckTest.java b/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerTckTest.java index 567a183c..d165b143 100644 --- a/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerTckTest.java +++ b/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerTckTest.java @@ -23,18 +23,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - import org.codehaus.plexus.compiler.AbstractCompilerTckTest; /** * @author Trygve Laugstøl */ -public class EclipseCompilerTckTest - extends AbstractCompilerTckTest -{ - public EclipseCompilerTckTest() - { +public class EclipseCompilerTckTest extends AbstractCompilerTckTest { + public EclipseCompilerTckTest() { this.roleHint = "eclipse"; - } } diff --git a/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerTest.java b/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerTest.java index df224d94..de72e6b4 100644 --- a/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerTest.java +++ b/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseCompilerTest.java @@ -23,89 +23,77 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +import java.util.Arrays; +import java.util.Collection; import org.codehaus.plexus.compiler.AbstractCompilerTest; import org.codehaus.plexus.compiler.CompilerConfiguration; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -import java.util.Arrays; -import java.util.Collection; - import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.startsWith; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * @author Jason van Zyl */ -public class EclipseCompilerTest - extends AbstractCompilerTest -{ +public class EclipseCompilerTest extends AbstractCompilerTest { @BeforeEach - public void setUp() - { - setCompilerDebug( true ); - setCompilerDeprecationWarnings( true ); + public void setUp() { + setCompilerDebug(true); + setCompilerDeprecationWarnings(true); } @Override - protected String getRoleHint() - { + protected String getRoleHint() { return "eclipse"; } @Override - protected int expectedErrors() - { + protected int expectedErrors() { return 4; } @Override - protected int expectedWarnings() - { + protected int expectedWarnings() { return 2; } @Override - protected Collection expectedOutputFiles() - { - return Arrays.asList("org/codehaus/foo/Deprecation.class", "org/codehaus/foo/ExternalDeps.class", - "org/codehaus/foo/Person.class", "org/codehaus/foo/ReservedWord.class"); + protected Collection expectedOutputFiles() { + return Arrays.asList( + "org/codehaus/foo/Deprecation.class", + "org/codehaus/foo/ExternalDeps.class", + "org/codehaus/foo/Person.class", + "org/codehaus/foo/ReservedWord.class"); } // The test is fairly meaningless as we can not validate anything @Test - public void testCustomArgument() - throws Exception - { + public void testCustomArgument() throws Exception { CompilerConfiguration compilerConfig = createMinimalCompilerConfig(); - compilerConfig.addCompilerCustomArgument( "-key", "value" ); + compilerConfig.addCompilerCustomArgument("-key", "value"); - getCompiler().performCompile( compilerConfig ); + getCompiler().performCompile(compilerConfig); } @Test - public void testInitializeWarningsForPropertiesArgument() - { + public void testInitializeWarningsForPropertiesArgument() { CompilerConfiguration compilerConfig = createMinimalCompilerConfig(); - compilerConfig.addCompilerCustomArgument( "-properties", "file_does_not_exist" ); + compilerConfig.addCompilerCustomArgument("-properties", "file_does_not_exist"); IllegalArgumentException e = - assertThrows( IllegalArgumentException.class, () -> getCompiler().performCompile( compilerConfig ) ); - assertThat( "Message must start with 'Properties file'" , e.getMessage(), startsWith( "Properties file" )); + assertThrows(IllegalArgumentException.class, () -> getCompiler().performCompile(compilerConfig)); + assertThat("Message must start with 'Properties file'", e.getMessage(), startsWith("Properties file")); } - private CompilerConfiguration createMinimalCompilerConfig() - { + private CompilerConfiguration createMinimalCompilerConfig() { CompilerConfiguration compilerConfig = new CompilerConfiguration(); - compilerConfig.setOutputLocation( "target/" + getRoleHint() + "/classes-CustomArgument" ); + compilerConfig.setOutputLocation("target/" + getRoleHint() + "/classes-CustomArgument"); return compilerConfig; } - } diff --git a/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseJavaCompilerTest.java b/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseJavaCompilerTest.java index 095efe64..470eb57c 100644 --- a/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseJavaCompilerTest.java +++ b/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipse/EclipseJavaCompilerTest.java @@ -1,60 +1,38 @@ package org.codehaus.plexus.compiler.eclipse; +import java.util.List; +import java.util.stream.Stream; + import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import java.util.List; -import java.util.stream.Stream; - import static java.util.Arrays.asList; import static org.junit.jupiter.api.Assertions.assertEquals; -class EclipseJavaCompilerTest -{ +class EclipseJavaCompilerTest { @ParameterizedTest - @MethodSource( "sources" ) - void testReorderedSources( List expected, List inputSources ) - { - List resorted = EclipseJavaCompiler.resortSourcesToPutModuleInfoFirst( inputSources ); + @MethodSource("sources") + void testReorderedSources(List expected, List inputSources) { + List resorted = EclipseJavaCompiler.resortSourcesToPutModuleInfoFirst(inputSources); - assertEquals( expected, resorted ); + assertEquals(expected, resorted); } - static Stream sources() - { - List expectedOrder = asList( - "module-info.java", - "plexus/A.java", - "plexus/B.java", - "eclipse/A.java" - ); - - List moduleInfoAlreadyFirst = asList( - "module-info.java", - "plexus/A.java", - "plexus/B.java", - "eclipse/A.java" - ); - - List moduleInfoSomewhereInTheMiddle = asList( - "plexus/A.java", - "module-info.java", - "plexus/B.java", - "eclipse/A.java" - ); - - List moduleInfoAsLast = asList( - "plexus/A.java", - "plexus/B.java", - "eclipse/A.java", - "module-info.java" - ); + static Stream sources() { + List expectedOrder = asList("module-info.java", "plexus/A.java", "plexus/B.java", "eclipse/A.java"); + + List moduleInfoAlreadyFirst = + asList("module-info.java", "plexus/A.java", "plexus/B.java", "eclipse/A.java"); + + List moduleInfoSomewhereInTheMiddle = + asList("plexus/A.java", "module-info.java", "plexus/B.java", "eclipse/A.java"); + + List moduleInfoAsLast = asList("plexus/A.java", "plexus/B.java", "eclipse/A.java", "module-info.java"); return Stream.of( - Arguments.arguments( expectedOrder, moduleInfoAlreadyFirst ), - Arguments.arguments( expectedOrder, moduleInfoSomewhereInTheMiddle ), - Arguments.arguments( expectedOrder, moduleInfoAsLast ) - ); + Arguments.arguments(expectedOrder, moduleInfoAlreadyFirst), + Arguments.arguments(expectedOrder, moduleInfoSomewhereInTheMiddle), + Arguments.arguments(expectedOrder, moduleInfoAsLast)); } } diff --git a/plexus-compilers/plexus-compiler-j2objc/pom.xml b/plexus-compilers/plexus-compiler-j2objc/pom.xml index 0780bdee..6aa91bd7 100644 --- a/plexus-compilers/plexus-compiler-j2objc/pom.xml +++ b/plexus-compilers/plexus-compiler-j2objc/pom.xml @@ -40,7 +40,7 @@ !mac - + diff --git a/plexus-compilers/plexus-compiler-j2objc/src/main/java/org/codehaus/plexus/compiler/j2objc/DefaultJ2ObjCCompilerParser.java b/plexus-compilers/plexus-compiler-j2objc/src/main/java/org/codehaus/plexus/compiler/j2objc/DefaultJ2ObjCCompilerParser.java index ef4ae8bc..b68d553b 100644 --- a/plexus-compilers/plexus-compiler-j2objc/src/main/java/org/codehaus/plexus/compiler/j2objc/DefaultJ2ObjCCompilerParser.java +++ b/plexus-compilers/plexus-compiler-j2objc/src/main/java/org/codehaus/plexus/compiler/j2objc/DefaultJ2ObjCCompilerParser.java @@ -8,8 +8,7 @@ * * @author lmaitre */ -public class DefaultJ2ObjCCompilerParser -{ +public class DefaultJ2ObjCCompilerParser { private static String ERROR_PREFIX = "error: "; @@ -24,8 +23,7 @@ public class DefaultJ2ObjCCompilerParser * @return The compiler message for this line or null if there is no need of * a message. */ - public static CompilerMessage parseLine( String line ) - { + public static CompilerMessage parseLine(String line) { String file = null; boolean error = false; int startline = -1; @@ -34,29 +32,20 @@ public static CompilerMessage parseLine( String line ) int endcolumn = -1; String message; - if ( line.startsWith( ERROR_PREFIX ) ) - { - message = line.substring( ERROR_PREFIX.length() ); + if (line.startsWith(ERROR_PREFIX)) { + message = line.substring(ERROR_PREFIX.length()); error = true; - } - else if ( line.startsWith( CONVERT_PREFIX ) ) - { + } else if (line.startsWith(CONVERT_PREFIX)) { message = line; - } - else if ( line.startsWith( TRANSLATION_PREFIX ) ) - { + } else if (line.startsWith(TRANSLATION_PREFIX)) { message = line; - } - else - { - System.err.println( "Unknown output: " + line ); + } else { + System.err.println("Unknown output: " + line); return null; } - return new CompilerMessage( file, error ? Kind.ERROR : Kind.NOTE, startline, startcolumn, endline, endcolumn, - message ); - + return new CompilerMessage( + file, error ? Kind.ERROR : Kind.NOTE, startline, startcolumn, endline, endcolumn, message); } - } diff --git a/plexus-compilers/plexus-compiler-j2objc/src/main/java/org/codehaus/plexus/compiler/j2objc/J2ObjCCompiler.java b/plexus-compilers/plexus-compiler-j2objc/src/main/java/org/codehaus/plexus/compiler/j2objc/J2ObjCCompiler.java index 170caf76..b5c6bccb 100644 --- a/plexus-compilers/plexus-compiler-j2objc/src/main/java/org/codehaus/plexus/compiler/j2objc/J2ObjCCompiler.java +++ b/plexus-compilers/plexus-compiler-j2objc/src/main/java/org/codehaus/plexus/compiler/j2objc/J2ObjCCompiler.java @@ -16,6 +16,19 @@ * limitations under the License. */ +import javax.inject.Named; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + import org.codehaus.plexus.compiler.AbstractCompiler; import org.codehaus.plexus.compiler.CompilerConfiguration; import org.codehaus.plexus.compiler.CompilerException; @@ -30,18 +43,6 @@ import org.codehaus.plexus.util.cli.StreamConsumer; import org.codehaus.plexus.util.cli.WriterStreamConsumer; -import javax.inject.Named; -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - /** * A plexus compiler which use J2ObjC . It is derived from the CSharpCompiler to * compile with J2ObjC. @@ -50,10 +51,8 @@ * Maître * */ -@Named( "j2objc" ) -public class J2ObjCCompiler - extends AbstractCompiler -{ +@Named("j2objc") +public class J2ObjCCompiler extends AbstractCompiler { private static final String X_BOOTCLASSPATH = "Xbootclasspath"; @@ -73,24 +72,54 @@ public class J2ObjCCompiler * Put the arguments of j2objc who takes one dash inside an array, in order * the check the command line. */ - private static final List ONE_DASH_ARGS = Arrays.asList( - new String[]{ "-pluginpath", "-pluginoptions", "-t", "-Xno-jsni-warnings", "-sourcepath", "-classpath", "-d", - "-encoding", "-g", "-q", "-v", "-Werror", "-h", "-use-arc", "-use-reference-counting", "-x" } ); + private static final List ONE_DASH_ARGS = Arrays.asList(new String[] { + "-pluginpath", + "-pluginoptions", + "-t", + "-Xno-jsni-warnings", + "-sourcepath", + "-classpath", + "-d", + "-encoding", + "-g", + "-q", + "-v", + "-Werror", + "-h", + "-use-arc", + "-use-reference-counting", + "-x" + }); /** * Put the command line arguments with 2 dashes inside an array, in order * the check the command line and build it. */ - private static final List TWO_DASH_ARGS = Arrays.asList( - new String[]{ "--build-closure", "--dead-code-report", "--doc-comments", "--no-extract-unsequenced", - "--generate-deprecated", "--mapping", "--no-class-methods", "--no-final-methods-functions", - "--no-hide-private-members", "--no-package-directories", "--prefix", "--prefixes", "--preserve-full-paths", - "--strip-gwt-incompatible", "--strip-reflection", "--segmented-headers", "--timing-info", "--quiet", - "--verbose", "--help" } ); - - public J2ObjCCompiler() - { - super( CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE, ".java", null, null ); + private static final List TWO_DASH_ARGS = Arrays.asList(new String[] { + "--build-closure", + "--dead-code-report", + "--doc-comments", + "--no-extract-unsequenced", + "--generate-deprecated", + "--mapping", + "--no-class-methods", + "--no-final-methods-functions", + "--no-hide-private-members", + "--no-package-directories", + "--prefix", + "--prefixes", + "--preserve-full-paths", + "--strip-gwt-incompatible", + "--strip-reflection", + "--segmented-headers", + "--timing-info", + "--quiet", + "--verbose", + "--help" + }); + + public J2ObjCCompiler() { + super(CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE, ".java", null, null); } // ---------------------------------------------------------------------- @@ -98,59 +127,46 @@ public J2ObjCCompiler() // ---------------------------------------------------------------------- @Override - public String getCompilerId() - { + public String getCompilerId() { return "j2objc"; } - public boolean canUpdateTarget( CompilerConfiguration configuration ) - throws CompilerException - { + public boolean canUpdateTarget(CompilerConfiguration configuration) throws CompilerException { return false; } - public CompilerResult performCompile( CompilerConfiguration config ) - throws CompilerException - { - File destinationDir = new File( config.getOutputLocation() ); - if ( !destinationDir.exists() ) - { + public CompilerResult performCompile(CompilerConfiguration config) throws CompilerException { + File destinationDir = new File(config.getOutputLocation()); + if (!destinationDir.exists()) { destinationDir.mkdirs(); } - config.setSourceFiles( null ); + config.setSourceFiles(null); - String[] sourceFiles = J2ObjCCompiler.getSourceFiles( config ); + String[] sourceFiles = J2ObjCCompiler.getSourceFiles(config); - if ( sourceFiles.length == 0 ) - { - return new CompilerResult().success( true ); + if (sourceFiles.length == 0) { + return new CompilerResult().success(true); } - logCompiling( sourceFiles, config ); + logCompiling(sourceFiles, config); - String[] args = buildCompilerArguments( config, sourceFiles ); + String[] args = buildCompilerArguments(config, sourceFiles); List messages; - if ( config.isFork() ) - { - messages = - compileOutOfProcess( config.getWorkingDirectory(), config.getBuildDirectory(), findExecutable( config ), - args ); - } - else - { - throw new CompilerException( "This compiler doesn't support in-process compilation." ); + if (config.isFork()) { + messages = compileOutOfProcess( + config.getWorkingDirectory(), config.getBuildDirectory(), findExecutable(config), args); + } else { + throw new CompilerException("This compiler doesn't support in-process compilation."); } - return new CompilerResult().compilerMessages( messages ); + return new CompilerResult().compilerMessages(messages); } - public String[] createCommandLine( CompilerConfiguration config ) - throws CompilerException - { - return buildCompilerArguments( config, J2ObjCCompiler.getSourceFiles( config ) ); + public String[] createCommandLine(CompilerConfiguration config) throws CompilerException { + return buildCompilerArguments(config, J2ObjCCompiler.getSourceFiles(config)); } /** @@ -160,12 +176,10 @@ public String[] createCommandLine( CompilerConfiguration config ) * @param config * @return the List of args */ - private String findExecutable( CompilerConfiguration config ) - { + private String findExecutable(CompilerConfiguration config) { String executable = config.getExecutable(); - if ( !StringUtils.isEmpty( executable ) ) - { + if (!StringUtils.isEmpty(executable)) { return executable; } @@ -184,152 +198,121 @@ private String findExecutable( CompilerConfiguration config ) * @return The List to give to the command line tool * @throws CompilerException */ - private String[] buildCompilerArguments( CompilerConfiguration config, String[] sourceFiles ) - throws CompilerException - { + private String[] buildCompilerArguments(CompilerConfiguration config, String[] sourceFiles) + throws CompilerException { /* - * j2objc --help Usage: j2objc - */ + * j2objc --help Usage: j2objc + */ List args = new ArrayList<>(); Map compilerArguments = config.getCustomCompilerArgumentsAsMap(); // Verbose - if ( config.isVerbose() ) - { - args.add( "-v" ); + if (config.isVerbose()) { + args.add("-v"); } // Destination/output directory - args.add( "-d" ); - args.add( config.getOutputLocation() ); + args.add("-d"); + args.add(config.getOutputLocation()); - if ( !config.getClasspathEntries().isEmpty() ) - { + if (!config.getClasspathEntries().isEmpty()) { List classpath = new ArrayList<>(); - for ( String element : config.getClasspathEntries() ) - { - File f = new File( element ); - classpath.add( f.getAbsolutePath() ); + for (String element : config.getClasspathEntries()) { + File f = new File(element); + classpath.add(f.getAbsolutePath()); - classpath.add( element ); + classpath.add(element); } - args.add( "-classpath" ); - args.add( StringUtils.join( classpath.toArray(), File.pathSeparator ) ); + args.add("-classpath"); + args.add(StringUtils.join(classpath.toArray(), File.pathSeparator)); } - if ( config.isVerbose() ) - { - System.out.println( "Args: " ); + if (config.isVerbose()) { + System.out.println("Args: "); } - for ( String k : compilerArguments.keySet() ) - { - if ( config.isVerbose() ) - { - System.out.println( k + "=" + compilerArguments.get( k ) ); - } - String v = compilerArguments.get( k ); - if ( J_FLAG.equals( k ) ) - { - args.add( J_FLAG + v ); - } - else if ( X_BOOTCLASSPATH.equals( k ) ) - { - args.add( X_BOOTCLASSPATH + ":" + v ); - } - else if ( BATCH_SIZE.equals( k ) ) - { - args.add( "-" + BATCH_SIZE + "=" + v ); + for (String k : compilerArguments.keySet()) { + if (config.isVerbose()) { + System.out.println(k + "=" + compilerArguments.get(k)); } - else - { - if ( TWO_DASH_ARGS.contains( k ) ) - { - args.add( "-" + k ); + String v = compilerArguments.get(k); + if (J_FLAG.equals(k)) { + args.add(J_FLAG + v); + } else if (X_BOOTCLASSPATH.equals(k)) { + args.add(X_BOOTCLASSPATH + ":" + v); + } else if (BATCH_SIZE.equals(k)) { + args.add("-" + BATCH_SIZE + "=" + v); + } else { + if (TWO_DASH_ARGS.contains(k)) { + args.add("-" + k); + } else if (ONE_DASH_ARGS.contains(k)) { + args.add(k); + } else { + throw new IllegalArgumentException("The argument " + k + " isnt't a flag recognized by J2ObjC."); } - else if ( ONE_DASH_ARGS.contains( k ) ) - { - args.add( k ); - } - else - { - throw new IllegalArgumentException( "The argument " + k + " isnt't a flag recognized by J2ObjC." ); - } - if ( v != null ) - { - args.add( v ); + if (v != null) { + args.add(v); } } } - for ( String sourceFile : sourceFiles ) - { - args.add( sourceFile ); + for (String sourceFile : sourceFiles) { + args.add(sourceFile); } - return args.toArray( new String[args.size()] ); + return args.toArray(new String[args.size()]); } - private List compileOutOfProcess( File workingDirectory, File target, String executable, - String[] args ) - throws CompilerException - { + private List compileOutOfProcess( + File workingDirectory, File target, String executable, String[] args) throws CompilerException { Commandline cli = new Commandline(); - cli.setWorkingDirectory( workingDirectory.getAbsolutePath() ); + cli.setWorkingDirectory(workingDirectory.getAbsolutePath()); - cli.setExecutable( executable ); + cli.setExecutable(executable); - cli.addArguments( args ); + cli.addArguments(args); Writer stringWriter = new StringWriter(); - StreamConsumer out = new WriterStreamConsumer( stringWriter ); + StreamConsumer out = new WriterStreamConsumer(stringWriter); - StreamConsumer err = new WriterStreamConsumer( stringWriter ); + StreamConsumer err = new WriterStreamConsumer(stringWriter); int returnCode; List messages; - try - { - returnCode = CommandLineUtils.executeCommandLine( cli, out, err ); + try { + returnCode = CommandLineUtils.executeCommandLine(cli, out, err); - messages = parseCompilerOutput( new BufferedReader( new StringReader( stringWriter.toString() ) ) ); - } - catch ( CommandLineException | IOException e ) - { - throw new CompilerException( "Error while executing the external compiler.", e ); + messages = parseCompilerOutput(new BufferedReader(new StringReader(stringWriter.toString()))); + } catch (CommandLineException | IOException e) { + throw new CompilerException("Error while executing the external compiler.", e); } - if ( returnCode != 0 && messages.isEmpty() ) - { + if (returnCode != 0 && messages.isEmpty()) { // TODO: exception? - messages.add( new CompilerMessage( - "Failure executing the compiler, but could not parse the error:" + EOL + stringWriter.toString(), - Kind.ERROR ) ); + messages.add(new CompilerMessage( + "Failure executing the compiler, but could not parse the error:" + EOL + stringWriter.toString(), + Kind.ERROR)); } return messages; } - public static List parseCompilerOutput( BufferedReader bufferedReader ) - throws IOException - { + public static List parseCompilerOutput(BufferedReader bufferedReader) throws IOException { List messages = new ArrayList<>(); String line = bufferedReader.readLine(); System.out.println("start output"); - while ( line != null ) - { + while (line != null) { System.out.println(line); - CompilerMessage compilerError = DefaultJ2ObjCCompilerParser.parseLine( line ); + CompilerMessage compilerError = DefaultJ2ObjCCompilerParser.parseLine(line); - if ( compilerError != null ) - { - messages.add( compilerError ); + if (compilerError != null) { + messages.add(compilerError); } line = bufferedReader.readLine(); @@ -337,5 +320,4 @@ public static List parseCompilerOutput( BufferedReader buffered System.out.println("end output"); return messages; } - } diff --git a/plexus-compilers/plexus-compiler-j2objc/src/test/java/org/codehaus/plexus/compiler/j2objc/J2ObjCCompilerTest.java b/plexus-compilers/plexus-compiler-j2objc/src/test/java/org/codehaus/plexus/compiler/j2objc/J2ObjCCompilerTest.java index 0e3f55bd..1107e272 100644 --- a/plexus-compilers/plexus-compiler-j2objc/src/test/java/org/codehaus/plexus/compiler/j2objc/J2ObjCCompilerTest.java +++ b/plexus-compilers/plexus-compiler-j2objc/src/test/java/org/codehaus/plexus/compiler/j2objc/J2ObjCCompilerTest.java @@ -23,46 +23,41 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - -import org.hamcrest.io.FileMatchers; -import org.codehaus.plexus.compiler.CompilerConfiguration; -import org.junit.jupiter.api.Test; - import java.io.File; import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import org.codehaus.plexus.compiler.CompilerConfiguration; +import org.hamcrest.io.FileMatchers; +import org.junit.jupiter.api.Test; + import static org.hamcrest.MatcherAssert.assertThat; /** * j2objc must be in the PATH * @author lmaitre */ -public class J2ObjCCompilerTest -{ +public class J2ObjCCompilerTest { @Test - public void testJ2ObjCCompiler() - throws Exception - { + public void testJ2ObjCCompiler() throws Exception { J2ObjCCompiler comp = new J2ObjCCompiler(); Map customCompilerArguments = new HashMap<>(); - customCompilerArguments.put( "-use-arc", null ); - customCompilerArguments.put( "-sourcepath", "src/test/resources" ); + customCompilerArguments.put("-use-arc", null); + customCompilerArguments.put("-sourcepath", "src/test/resources"); CompilerConfiguration cc = new CompilerConfiguration(); - cc.setOutputLocation( "target/generated/objective-c" ); - cc.setSourceLocations( Arrays.asList( new String[]{ "src/test/resources" } ) ); - cc.setWorkingDirectory( new File( "." ) ); - cc.setFork( true ); - cc.setVerbose( true ); - cc.setCustomCompilerArgumentsAsMap( customCompilerArguments ); - - comp.performCompile( cc ); - File f = new File( "target/generated/objective-c/de/test/App.h" ); + cc.setOutputLocation("target/generated/objective-c"); + cc.setSourceLocations(Arrays.asList(new String[] {"src/test/resources"})); + cc.setWorkingDirectory(new File(".")); + cc.setFork(true); + cc.setVerbose(true); + cc.setCustomCompilerArgumentsAsMap(customCompilerArguments); + + comp.performCompile(cc); + File f = new File("target/generated/objective-c/de/test/App.h"); assertThat("file not exists:" + f, f, FileMatchers.anExistingFile()); - f = new File( "target/generated/objective-c/de/test/App.m" ); + f = new File("target/generated/objective-c/de/test/App.m"); assertThat("file not exists:" + f, f, FileMatchers.anExistingFile()); } - } diff --git a/plexus-compilers/plexus-compiler-javac-errorprone/pom.xml b/plexus-compilers/plexus-compiler-javac-errorprone/pom.xml index fe25300c..7e0d4a2d 100644 --- a/plexus-compilers/plexus-compiler-javac-errorprone/pom.xml +++ b/plexus-compilers/plexus-compiler-javac-errorprone/pom.xml @@ -13,8 +13,7 @@ Plexus Javac+error-prone Component Javac Compiler support for Plexus Compiler component, with error-prone static analysis checks enabled. - See https://errorprone.info - + See https://errorprone.info 11 @@ -47,8 +46,7 @@ org.apache.maven.plugins maven-surefire-plugin - - --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED + --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED @@ -57,8 +55,7 @@ --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED - --add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED - + --add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED diff --git a/plexus-compilers/plexus-compiler-javac-errorprone/src/main/java/org/codehaus/plexus/compiler/javac/errorprone/JavacCompilerWithErrorProne.java b/plexus-compilers/plexus-compiler-javac-errorprone/src/main/java/org/codehaus/plexus/compiler/javac/errorprone/JavacCompilerWithErrorProne.java index 2d206247..000ebbd8 100644 --- a/plexus-compilers/plexus-compiler-javac-errorprone/src/main/java/org/codehaus/plexus/compiler/javac/errorprone/JavacCompilerWithErrorProne.java +++ b/plexus-compilers/plexus-compiler-javac-errorprone/src/main/java/org/codehaus/plexus/compiler/javac/errorprone/JavacCompilerWithErrorProne.java @@ -16,8 +16,14 @@ package org.codehaus.plexus.compiler.javac.errorprone; -import com.google.errorprone.ErrorProneJavaCompiler; +import javax.inject.Named; +import javax.tools.JavaCompiler; + +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import com.google.errorprone.ErrorProneJavaCompiler; import org.codehaus.plexus.compiler.CompilerConfiguration; import org.codehaus.plexus.compiler.CompilerException; import org.codehaus.plexus.compiler.CompilerMessage; @@ -26,13 +32,6 @@ import org.codehaus.plexus.compiler.javac.JavacCompiler; import org.codehaus.plexus.compiler.javac.JavaxToolsCompiler; -import javax.inject.Named; -import javax.tools.JavaCompiler; - -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; - /** * This class overrides JavacCompiler with modifications to use the error-prone * entry point into Javac. @@ -40,78 +39,59 @@ * @author Alex Eagle */ @Named("javac-with-errorprone") -public class JavacCompilerWithErrorProne - extends JavacCompiler -{ +public class JavacCompilerWithErrorProne extends JavacCompiler { @Override - public String getCompilerId() - { + public String getCompilerId() { return "javac-with-errorprone"; } - private static class NonDelegatingClassLoader - extends URLClassLoader - { + private static class NonDelegatingClassLoader extends URLClassLoader { ClassLoader original; - public NonDelegatingClassLoader( URL[] urls, ClassLoader original ) - throws MalformedURLException - { - super( urls, null ); + public NonDelegatingClassLoader(URL[] urls, ClassLoader original) throws MalformedURLException { + super(urls, null); this.original = original; } @Override - public Class loadClass( String name, boolean complete ) - throws ClassNotFoundException - { + public Class loadClass(String name, boolean complete) throws ClassNotFoundException { // Classes loaded inside CompilerInvoker that need to reach back to the caller - if ( name.contentEquals( CompilerResult.class.getName() ) - || name.contentEquals( InProcessCompiler.class.getName() ) - || name.contentEquals( CompilerConfiguration.class.getName() ) - || name.contentEquals( CompilerConfiguration.CompilerReuseStrategy.class.getName() ) - || name.contentEquals( CompilerException.class.getName() ) - || name.contentEquals( CompilerMessage.class.getName() ) - || name.contentEquals( CompilerMessage.Kind.class.getName() ) ) - { - return original.loadClass( name ); + if (name.contentEquals(CompilerResult.class.getName()) + || name.contentEquals(InProcessCompiler.class.getName()) + || name.contentEquals(CompilerConfiguration.class.getName()) + || name.contentEquals(CompilerConfiguration.CompilerReuseStrategy.class.getName()) + || name.contentEquals(CompilerException.class.getName()) + || name.contentEquals(CompilerMessage.class.getName()) + || name.contentEquals(CompilerMessage.Kind.class.getName())) { + return original.loadClass(name); } - try - { - synchronized ( getClassLoadingLock( name ) ) - { - Class c = findLoadedClass( name ); - if ( c != null ) - { + try { + synchronized (getClassLoadingLock(name)) { + Class c = findLoadedClass(name); + if (c != null) { return c; } - return findClass( name ); + return findClass(name); } - } - catch ( ClassNotFoundException e ) - { - return super.loadClass( name, complete ); + } catch (ClassNotFoundException e) { + return super.loadClass(name, complete); } } } - protected InProcessCompiler inProcessCompiler() - { - if ( Thread.currentThread().getContextClassLoader().getResource("java/lang/module/ModuleReference.class") == null ) - { + protected InProcessCompiler inProcessCompiler() { + if (Thread.currentThread().getContextClassLoader().getResource("java/lang/module/ModuleReference.class") + == null) { ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); - URL[] urls = ( (URLClassLoader) contextClassLoader ).getURLs(); + URL[] urls = ((URLClassLoader) contextClassLoader).getURLs(); ClassLoader loader; - try - { - loader = new NonDelegatingClassLoader( urls, contextClassLoader ); - Class clazz = Class.forName( CompilerInvoker.class.getName(), true, loader ); - return ( InProcessCompiler ) clazz.newInstance(); - } - catch ( Exception e ) - { - throw new IllegalStateException( e ); + try { + loader = new NonDelegatingClassLoader(urls, contextClassLoader); + Class clazz = Class.forName(CompilerInvoker.class.getName(), true, loader); + return (InProcessCompiler) clazz.newInstance(); + } catch (Exception e) { + throw new IllegalStateException(e); } } return new CompilerInvoker(); @@ -122,13 +102,10 @@ protected InProcessCompiler inProcessCompiler() * non-delegating classloader ensures that error-prone's javac loads javax.tools.* classes from * javac.jar instead of from the bootclasspath. */ - public static class CompilerInvoker - extends JavaxToolsCompiler - { - @Override - protected JavaCompiler newJavaCompiler() - { - return new ErrorProneJavaCompiler(); - } + public static class CompilerInvoker extends JavaxToolsCompiler { + @Override + protected JavaCompiler newJavaCompiler() { + return new ErrorProneJavaCompiler(); + } } } diff --git a/plexus-compilers/plexus-compiler-javac-errorprone/src/test/java/org/codehaus/plexus/compiler/javac/JavacErrorProneCompilerTest.java b/plexus-compilers/plexus-compiler-javac-errorprone/src/test/java/org/codehaus/plexus/compiler/javac/JavacErrorProneCompilerTest.java index f1c21798..416b0310 100644 --- a/plexus-compilers/plexus-compiler-javac-errorprone/src/test/java/org/codehaus/plexus/compiler/javac/JavacErrorProneCompilerTest.java +++ b/plexus-compilers/plexus-compiler-javac-errorprone/src/test/java/org/codehaus/plexus/compiler/javac/JavacErrorProneCompilerTest.java @@ -5,19 +5,15 @@ /** * @author Jason van Zyl */ -public class JavacErrorProneCompilerTest - extends AbstractCompilerTest -{ +public class JavacErrorProneCompilerTest extends AbstractCompilerTest { @Override - protected String getRoleHint() - { + protected String getRoleHint() { return "javac-with-errorprone"; } @Override - protected int expectedWarnings() - { + protected int expectedWarnings() { String javaVersion = getJavaVersion(); if (javaVersion.startsWith("1.8")) { return 1; @@ -30,20 +26,17 @@ protected int expectedWarnings() } @Override - protected int expectedErrors() - { + protected int expectedErrors() { return 1; } @Override - public String getSourceVersion() - { + public String getSourceVersion() { return "1.8"; } @Override - public String getTargetVersion() - { + public String getTargetVersion() { return "1.8"; } } diff --git a/plexus-compilers/plexus-compiler-javac/pom.xml b/plexus-compilers/plexus-compiler-javac/pom.xml index 6d0862f3..8eb9b4c2 100644 --- a/plexus-compilers/plexus-compiler-javac/pom.xml +++ b/plexus-compilers/plexus-compiler-javac/pom.xml @@ -7,7 +7,7 @@ plexus-compilers 2.13.1-SNAPSHOT - + plexus-compiler-javac Plexus Javac Component @@ -33,5 +33,5 @@ test - + diff --git a/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/InProcessCompiler.java b/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/InProcessCompiler.java index c4374eee..58e4ac89 100644 --- a/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/InProcessCompiler.java +++ b/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/InProcessCompiler.java @@ -6,7 +6,6 @@ public interface InProcessCompiler { - CompilerResult compileInProcess(String[] args, final CompilerConfiguration config, String[] sourceFiles) - throws CompilerException; - + CompilerResult compileInProcess(String[] args, final CompilerConfiguration config, String[] sourceFiles) + throws CompilerException; } diff --git a/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/IsolatedClassLoader.java b/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/IsolatedClassLoader.java index 08933fce..9b3d0062 100644 --- a/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/IsolatedClassLoader.java +++ b/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/IsolatedClassLoader.java @@ -23,51 +23,38 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - -import java.net.URLClassLoader; import java.net.URL; +import java.net.URLClassLoader; -public class IsolatedClassLoader - extends URLClassLoader -{ +public class IsolatedClassLoader extends URLClassLoader { private ClassLoader parentClassLoader = ClassLoader.getSystemClassLoader(); - public IsolatedClassLoader() - { - super( new URL[0], null ); + public IsolatedClassLoader() { + super(new URL[0], null); } - public void addURL( URL url ) - { - super.addURL( url ); + public void addURL(URL url) { + super.addURL(url); } - public synchronized Class loadClass( String className ) - throws ClassNotFoundException - { - Class c = findLoadedClass( className ); + public synchronized Class loadClass(String className) throws ClassNotFoundException { + Class c = findLoadedClass(className); ClassNotFoundException ex = null; - if ( c == null ) - { - try - { - c = findClass( className ); - } - catch ( ClassNotFoundException e ) - { + if (c == null) { + try { + c = findClass(className); + } catch (ClassNotFoundException e) { ex = e; - if ( parentClassLoader != null ) - { - c = parentClassLoader.loadClass( className ); + if (parentClassLoader != null) { + c = parentClassLoader.loadClass(className); } } } - if ( c == null ) - { + if (c == null) { throw ex; } diff --git a/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java b/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java index 718d1d5e..dbee1de9 100644 --- a/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java +++ b/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java @@ -40,6 +40,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; import java.io.BufferedReader; import java.io.File; @@ -75,10 +78,6 @@ import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - /** * @author Trygve Laugstøl * @author Matthew Pocock @@ -88,18 +87,16 @@ */ @Named("javac") @Singleton -public class JavacCompiler - extends AbstractCompiler -{ +public class JavacCompiler extends AbstractCompiler { // see compiler.warn.warning in compiler.properties of javac sources - private static final String[] WARNING_PREFIXES = { "warning: ", "\u8b66\u544a: ", "\u8b66\u544a\uff1a " }; + private static final String[] WARNING_PREFIXES = {"warning: ", "\u8b66\u544a: ", "\u8b66\u544a\uff1a "}; // see compiler.note.note in compiler.properties of javac sources - private static final String[] NOTE_PREFIXES = { "Note: ", "\u6ce8: ", "\u6ce8\u610f\uff1a " }; + private static final String[] NOTE_PREFIXES = {"Note: ", "\u6ce8: ", "\u6ce8\u610f\uff1a "}; // see compiler.misc.verbose in compiler.properties of javac sources - private static final String[] MISC_PREFIXES = { "[" }; + private static final String[] MISC_PREFIXES = {"["}; private static final Object LOCK = new Object(); @@ -116,9 +113,8 @@ public class JavacCompiler // // ---------------------------------------------------------------------- - public JavacCompiler() - { - super( CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE, ".java", ".class", null ); + public JavacCompiler() { + super(CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE, ".java", ".class", null); } // ---------------------------------------------------------------------- @@ -126,331 +122,263 @@ public JavacCompiler() // ---------------------------------------------------------------------- @Override - public String getCompilerId() - { + public String getCompilerId() { return "javac"; } @Override - public CompilerResult performCompile( CompilerConfiguration config ) - throws CompilerException - { - File destinationDir = new File( config.getOutputLocation() ); + public CompilerResult performCompile(CompilerConfiguration config) throws CompilerException { + File destinationDir = new File(config.getOutputLocation()); - if ( !destinationDir.exists() ) - { + if (!destinationDir.exists()) { destinationDir.mkdirs(); } - String[] sourceFiles = getSourceFiles( config ); + String[] sourceFiles = getSourceFiles(config); - if ( ( sourceFiles == null ) || ( sourceFiles.length == 0 ) ) - { + if ((sourceFiles == null) || (sourceFiles.length == 0)) { return new CompilerResult(); } - logCompiling( sourceFiles, config ); + logCompiling(sourceFiles, config); - String[] args = buildCompilerArguments( config, sourceFiles ); + String[] args = buildCompilerArguments(config, sourceFiles); CompilerResult result; - if ( config.isFork() ) - { + if (config.isFork()) { String executable = config.getExecutable(); - if ( StringUtils.isEmpty( executable ) ) - { - try - { + if (StringUtils.isEmpty(executable)) { + try { executable = getJavacExecutable(); - } - catch ( IOException e ) - { - if ( log.isWarnEnabled()) { - log.warn( "Unable to autodetect 'javac' path, using 'javac' from the environment." ); + } catch (IOException e) { + if (log.isWarnEnabled()) { + log.warn("Unable to autodetect 'javac' path, using 'javac' from the environment."); } executable = "javac"; } } - result = compileOutOfProcess( config, executable, args ); - } - else - { - if ( isJava16() && !config.isForceJavacCompilerUse() ) - { + result = compileOutOfProcess(config, executable, args); + } else { + if (isJava16() && !config.isForceJavacCompilerUse()) { // use fqcn to prevent loading of the class on 1.5 environment ! - result = - inProcessCompiler().compileInProcess( args, config, sourceFiles ); - } - else - { - result = compileInProcess( args, config ); + result = inProcessCompiler().compileInProcess(args, config, sourceFiles); + } else { + result = compileInProcess(args, config); } } return result; } - protected InProcessCompiler inProcessCompiler() - { + protected InProcessCompiler inProcessCompiler() { return inProcessCompiler; } - protected static boolean isJava16() - { - try - { - Thread.currentThread().getContextClassLoader().loadClass( "javax.tools.ToolProvider" ); + protected static boolean isJava16() { + try { + Thread.currentThread().getContextClassLoader().loadClass("javax.tools.ToolProvider"); return true; - } - catch ( Exception e ) - { + } catch (Exception e) { return false; } } - public String[] createCommandLine( CompilerConfiguration config ) - throws CompilerException - { - return buildCompilerArguments( config, getSourceFiles( config ) ); + public String[] createCommandLine(CompilerConfiguration config) throws CompilerException { + return buildCompilerArguments(config, getSourceFiles(config)); } - public static String[] buildCompilerArguments( CompilerConfiguration config, String[] sourceFiles ) - { + public static String[] buildCompilerArguments(CompilerConfiguration config, String[] sourceFiles) { List args = new ArrayList<>(); // ---------------------------------------------------------------------- // Set output // ---------------------------------------------------------------------- - File destinationDir = new File( config.getOutputLocation() ); + File destinationDir = new File(config.getOutputLocation()); - args.add( "-d" ); + args.add("-d"); - args.add( destinationDir.getAbsolutePath() ); + args.add(destinationDir.getAbsolutePath()); // ---------------------------------------------------------------------- // Set the class and source paths // ---------------------------------------------------------------------- List classpathEntries = config.getClasspathEntries(); - if ( classpathEntries != null && !classpathEntries.isEmpty() ) - { - args.add( "-classpath" ); + if (classpathEntries != null && !classpathEntries.isEmpty()) { + args.add("-classpath"); - args.add( getPathString( classpathEntries ) ); + args.add(getPathString(classpathEntries)); } List modulepathEntries = config.getModulepathEntries(); - if ( modulepathEntries != null && !modulepathEntries.isEmpty() ) - { - args.add( "--module-path" ); + if (modulepathEntries != null && !modulepathEntries.isEmpty()) { + args.add("--module-path"); - args.add( getPathString( modulepathEntries ) ); + args.add(getPathString(modulepathEntries)); } List sourceLocations = config.getSourceLocations(); - if ( sourceLocations != null && !sourceLocations.isEmpty() ) - { - //always pass source path, even if sourceFiles are declared, - //needed for jsr269 annotation processing, see MCOMPILER-98 - args.add( "-sourcepath" ); + if (sourceLocations != null && !sourceLocations.isEmpty()) { + // always pass source path, even if sourceFiles are declared, + // needed for jsr269 annotation processing, see MCOMPILER-98 + args.add("-sourcepath"); - args.add( getPathString( sourceLocations ) ); + args.add(getPathString(sourceLocations)); } - if ( !isJava16() || config.isForceJavacCompilerUse() || config.isFork() ) - { - args.addAll( Arrays.asList( sourceFiles ) ); + if (!isJava16() || config.isForceJavacCompilerUse() || config.isFork()) { + args.addAll(Arrays.asList(sourceFiles)); } - if ( !isPreJava16( config ) ) - { - //now add jdk 1.6 annotation processing related parameters + if (!isPreJava16(config)) { + // now add jdk 1.6 annotation processing related parameters - if ( config.getGeneratedSourcesDirectory() != null ) - { + if (config.getGeneratedSourcesDirectory() != null) { config.getGeneratedSourcesDirectory().mkdirs(); - args.add( "-s" ); - args.add( config.getGeneratedSourcesDirectory().getAbsolutePath() ); + args.add("-s"); + args.add(config.getGeneratedSourcesDirectory().getAbsolutePath()); } - if ( config.getProc() != null ) - { - args.add( "-proc:" + config.getProc() ); + if (config.getProc() != null) { + args.add("-proc:" + config.getProc()); } - if ( config.getAnnotationProcessors() != null ) - { - args.add( "-processor" ); + if (config.getAnnotationProcessors() != null) { + args.add("-processor"); String[] procs = config.getAnnotationProcessors(); StringBuilder buffer = new StringBuilder(); - for ( int i = 0; i < procs.length; i++ ) - { - if ( i > 0 ) - { - buffer.append( "," ); + for (int i = 0; i < procs.length; i++) { + if (i > 0) { + buffer.append(","); } - buffer.append( procs[i] ); + buffer.append(procs[i]); } - args.add( buffer.toString() ); + args.add(buffer.toString()); } - if ( config.getProcessorPathEntries() != null && !config.getProcessorPathEntries().isEmpty() ) - { - args.add( "-processorpath" ); - args.add( getPathString( config.getProcessorPathEntries() ) ); + if (config.getProcessorPathEntries() != null + && !config.getProcessorPathEntries().isEmpty()) { + args.add("-processorpath"); + args.add(getPathString(config.getProcessorPathEntries())); } - if ( config.getProcessorModulePathEntries() != null && !config.getProcessorModulePathEntries().isEmpty() ) - { - args.add( "--processor-module-path" ); - args.add( getPathString( config.getProcessorModulePathEntries() ) ); + if (config.getProcessorModulePathEntries() != null + && !config.getProcessorModulePathEntries().isEmpty()) { + args.add("--processor-module-path"); + args.add(getPathString(config.getProcessorModulePathEntries())); } } - if ( config.isOptimize() ) - { - args.add( "-O" ); + if (config.isOptimize()) { + args.add("-O"); } - if ( config.isDebug() ) - { - if ( StringUtils.isNotEmpty( config.getDebugLevel() ) ) - { - args.add( "-g:" + config.getDebugLevel() ); - } - else - { - args.add( "-g" ); + if (config.isDebug()) { + if (StringUtils.isNotEmpty(config.getDebugLevel())) { + args.add("-g:" + config.getDebugLevel()); + } else { + args.add("-g"); } } - if ( config.isVerbose() ) - { - args.add( "-verbose" ); + if (config.isVerbose()) { + args.add("-verbose"); } - if ( !isPreJava18(config) && config.isParameters() ) - { - args.add( "-parameters" ); + if (!isPreJava18(config) && config.isParameters()) { + args.add("-parameters"); } - if ( config.isEnablePreview() ) - { - args.add( "--enable-preview" ); + if (config.isEnablePreview()) { + args.add("--enable-preview"); } - if ( config.getImplicitOption() != null ) - { - args.add( "-implicit:" + config.getImplicitOption() ); + if (config.getImplicitOption() != null) { + args.add("-implicit:" + config.getImplicitOption()); } - if ( config.isShowDeprecation() ) - { - args.add( "-deprecation" ); + if (config.isShowDeprecation()) { + args.add("-deprecation"); // This is required to actually display the deprecation messages - config.setShowWarnings( true ); + config.setShowWarnings(true); } - if ( !config.isShowWarnings() ) - { - args.add( "-nowarn" ); - } - else - { + if (!config.isShowWarnings()) { + args.add("-nowarn"); + } else { String warnings = config.getWarnings(); - if (config.isShowLint()) - { - if(config.isShowWarnings() && StringUtils.isNotEmpty(warnings)) - { - args.add( "-Xlint:" + warnings ); - } - else - { - args.add( "-Xlint" ); + if (config.isShowLint()) { + if (config.isShowWarnings() && StringUtils.isNotEmpty(warnings)) { + args.add("-Xlint:" + warnings); + } else { + args.add("-Xlint"); } } } - if ( config.isFailOnWarning() ) - { - args.add( "-Werror" ); + if (config.isFailOnWarning()) { + args.add("-Werror"); } - if ( !StringUtils.isEmpty( config.getReleaseVersion() ) ) - { - args.add( "--release" ); - args.add( config.getReleaseVersion() ); - } - else - { + if (!StringUtils.isEmpty(config.getReleaseVersion())) { + args.add("--release"); + args.add(config.getReleaseVersion()); + } else { // TODO: this could be much improved - if ( StringUtils.isEmpty( config.getTargetVersion() ) ) - { + if (StringUtils.isEmpty(config.getTargetVersion())) { // Required, or it defaults to the target of your JDK (eg 1.5) - args.add( "-target" ); - args.add( "1.1" ); - } - else - { - args.add( "-target" ); - args.add( config.getTargetVersion() ); + args.add("-target"); + args.add("1.1"); + } else { + args.add("-target"); + args.add(config.getTargetVersion()); } - if ( !suppressSource( config ) && StringUtils.isEmpty( config.getSourceVersion() ) ) - { + if (!suppressSource(config) && StringUtils.isEmpty(config.getSourceVersion())) { // If omitted, later JDKs complain about a 1.1 target - args.add( "-source" ); - args.add( "1.3" ); - } - else if ( !suppressSource( config ) ) - { - args.add( "-source" ); - args.add( config.getSourceVersion() ); + args.add("-source"); + args.add("1.3"); + } else if (!suppressSource(config)) { + args.add("-source"); + args.add(config.getSourceVersion()); } } - - if ( !suppressEncoding( config ) && !StringUtils.isEmpty( config.getSourceEncoding() ) ) - { - args.add( "-encoding" ); - args.add( config.getSourceEncoding() ); + if (!suppressEncoding(config) && !StringUtils.isEmpty(config.getSourceEncoding())) { + args.add("-encoding"); + args.add(config.getSourceEncoding()); } - if ( !StringUtils.isEmpty( config.getModuleVersion() ) ) - { - args.add( "--module-version" ); - args.add( config.getModuleVersion() ); + if (!StringUtils.isEmpty(config.getModuleVersion())) { + args.add("--module-version"); + args.add(config.getModuleVersion()); } - for ( Map.Entry entry : config.getCustomCompilerArgumentsEntries() ) - { + for (Map.Entry entry : config.getCustomCompilerArgumentsEntries()) { String key = entry.getKey(); - if ( StringUtils.isEmpty( key ) || key.startsWith( "-J" ) ) - { + if (StringUtils.isEmpty(key) || key.startsWith("-J")) { continue; } - args.add( key ); + args.add(key); String value = entry.getValue(); - if ( StringUtils.isEmpty( value ) ) - { + if (StringUtils.isEmpty(value)) { continue; } - args.add( value ); + args.add(value); } - if ( !config.isFork() ) - { - args.add( "-XDuseUnsharedTable=true" ); + if (!config.isFork()) { + args.add("-XDuseUnsharedTable=true"); } - return args.toArray( new String[0] ); + return args.toArray(new String[0]); } /** @@ -460,16 +388,14 @@ else if ( !suppressSource( config ) ) * @param config The compiler configuration to test. * @return true if the compiler configuration represents a Java 1.4 compiler or later, false otherwise */ - private static boolean isPreJava14( CompilerConfiguration config ) - { + private static boolean isPreJava14(CompilerConfiguration config) { String v = config.getCompilerVersion(); - if ( v == null ) - { + if (v == null) { return false; } - return v.startsWith( "1.3" ) || v.startsWith( "1.2" ) || v.startsWith( "1.1" ) || v.startsWith( "1.0" ); + return v.startsWith("1.3") || v.startsWith("1.2") || v.startsWith("1.1") || v.startsWith("1.0"); } /** @@ -479,85 +405,92 @@ private static boolean isPreJava14( CompilerConfiguration config ) * @param config The compiler configuration to test. * @return true if the compiler configuration represents a Java 1.6 compiler or later, false otherwise */ - private static boolean isPreJava16( CompilerConfiguration config ) - { + private static boolean isPreJava16(CompilerConfiguration config) { String v = config.getReleaseVersion(); - if ( v == null ) - { + if (v == null) { v = config.getCompilerVersion(); } - if ( v == null ) - { + if (v == null) { v = config.getSourceVersion(); } - if ( v == null ) - { + if (v == null) { return true; } - return v.startsWith( "5" ) || v.startsWith( "1.5" ) || v.startsWith( "1.4" ) || v.startsWith( "1.3" ) || v.startsWith( "1.2" ) - || v.startsWith( "1.1" ) || v.startsWith( "1.0" ); + return v.startsWith("5") + || v.startsWith("1.5") + || v.startsWith("1.4") + || v.startsWith("1.3") + || v.startsWith("1.2") + || v.startsWith("1.1") + || v.startsWith("1.0"); } - private static boolean isPreJava18( CompilerConfiguration config ) - { + private static boolean isPreJava18(CompilerConfiguration config) { String v = config.getReleaseVersion(); - if ( v == null ) - { + if (v == null) { v = config.getCompilerVersion(); } - if ( v == null ) - { + if (v == null) { v = config.getSourceVersion(); } - if ( v == null ) - { + if (v == null) { return true; } - return v.startsWith( "7" ) || v.startsWith( "1.7" ) || v.startsWith( "6" ) ||v.startsWith( "1.6" ) || v.startsWith( "1.5" ) || v.startsWith( "1.4" ) - || v.startsWith( "1.3" ) || v.startsWith( "1.2" ) || v.startsWith( "1.1" ) || v.startsWith( "1.0" ); + return v.startsWith("7") + || v.startsWith("1.7") + || v.startsWith("6") + || v.startsWith("1.6") + || v.startsWith("1.5") + || v.startsWith("1.4") + || v.startsWith("1.3") + || v.startsWith("1.2") + || v.startsWith("1.1") + || v.startsWith("1.0"); } - private static boolean isPreJava9( CompilerConfiguration config ) - { + private static boolean isPreJava9(CompilerConfiguration config) { String v = config.getReleaseVersion(); - if ( v == null ) - { + if (v == null) { v = config.getCompilerVersion(); } - if ( v == null ) - { + if (v == null) { v = config.getSourceVersion(); } - if ( v == null ) - { + if (v == null) { return true; } - return v.startsWith( "8" ) || v.startsWith( "1.8" ) || v.startsWith( "7" ) || v.startsWith( "1.7" ) || v.startsWith( "1.6" ) || v.startsWith( "1.5" ) || v.startsWith( "1.4" ) - || v.startsWith( "1.3" ) || v.startsWith( "1.2" ) || v.startsWith( "1.1" ) || v.startsWith( "1.0" ); + return v.startsWith("8") + || v.startsWith("1.8") + || v.startsWith("7") + || v.startsWith("1.7") + || v.startsWith("1.6") + || v.startsWith("1.5") + || v.startsWith("1.4") + || v.startsWith("1.3") + || v.startsWith("1.2") + || v.startsWith("1.1") + || v.startsWith("1.0"); } - - private static boolean suppressSource( CompilerConfiguration config ) - { - return isPreJava14( config ); + private static boolean suppressSource(CompilerConfiguration config) { + return isPreJava14(config); } - private static boolean suppressEncoding( CompilerConfiguration config ) - { - return isPreJava14( config ); + private static boolean suppressEncoding(CompilerConfiguration config) { + return isPreJava14(config); } /** @@ -570,42 +503,35 @@ private static boolean suppressEncoding( CompilerConfiguration config ) * @return a CompilerResult object encapsulating the result of the compilation and any compiler messages * @throws CompilerException */ - protected CompilerResult compileOutOfProcess( CompilerConfiguration config, String executable, String[] args ) - throws CompilerException - { + protected CompilerResult compileOutOfProcess(CompilerConfiguration config, String executable, String[] args) + throws CompilerException { Commandline cli = new Commandline(); - cli.setWorkingDirectory( config.getWorkingDirectory().getAbsolutePath() ); + cli.setWorkingDirectory(config.getWorkingDirectory().getAbsolutePath()); - cli.setExecutable( executable ); + cli.setExecutable(executable); - try - { - File argumentsFile = createFileWithArguments( args, config.getBuildDirectory().getAbsolutePath() ); + try { + File argumentsFile = + createFileWithArguments(args, config.getBuildDirectory().getAbsolutePath()); cli.addArguments( - new String[]{ "@" + argumentsFile.getCanonicalPath().replace( File.separatorChar, '/' ) } ); + new String[] {"@" + argumentsFile.getCanonicalPath().replace(File.separatorChar, '/')}); - if ( !StringUtils.isEmpty( config.getMaxmem() ) ) - { - cli.addArguments( new String[]{ "-J-Xmx" + config.getMaxmem() } ); + if (!StringUtils.isEmpty(config.getMaxmem())) { + cli.addArguments(new String[] {"-J-Xmx" + config.getMaxmem()}); } - if ( !StringUtils.isEmpty( config.getMeminitial() ) ) - { - cli.addArguments( new String[]{ "-J-Xms" + config.getMeminitial() } ); + if (!StringUtils.isEmpty(config.getMeminitial())) { + cli.addArguments(new String[] {"-J-Xms" + config.getMeminitial()}); } - for ( String key : config.getCustomCompilerArgumentsAsMap().keySet() ) - { - if ( StringUtils.isNotEmpty( key ) && key.startsWith( "-J" ) ) - { - cli.addArguments( new String[]{ key } ); + for (String key : config.getCustomCompilerArgumentsAsMap().keySet()) { + if (StringUtils.isNotEmpty(key) && key.startsWith("-J")) { + cli.addArguments(new String[] {key}); } } - } - catch ( IOException e ) - { - throw new CompilerException( "Error creating file with javac arguments", e ); + } catch (IOException e) { + throw new CompilerException("Error creating file with javac arguments", e); } CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer(); @@ -614,43 +540,36 @@ protected CompilerResult compileOutOfProcess( CompilerConfiguration config, Stri List messages; - if ( log.isDebugEnabled() ) - { + if (log.isDebugEnabled()) { String debugFileName = StringUtils.isEmpty(config.getDebugFileName()) ? "javac" : config.getDebugFileName(); - File commandLineFile = - new File( config.getBuildDirectory(), StringUtils.trim(debugFileName) + "." + ( Os.isFamily( Os.FAMILY_WINDOWS ) ? "bat" : "sh" ) ); - try - { - FileUtils.fileWrite( commandLineFile.getAbsolutePath(), cli.toString().replaceAll( "'", "" ) ); + File commandLineFile = new File( + config.getBuildDirectory(), + StringUtils.trim(debugFileName) + "." + (Os.isFamily(Os.FAMILY_WINDOWS) ? "bat" : "sh")); + try { + FileUtils.fileWrite( + commandLineFile.getAbsolutePath(), cli.toString().replaceAll("'", "")); - if ( !Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - Runtime.getRuntime().exec( new String[]{ "chmod", "a+x", commandLineFile.getAbsolutePath() } ); + if (!Os.isFamily(Os.FAMILY_WINDOWS)) { + Runtime.getRuntime().exec(new String[] {"chmod", "a+x", commandLineFile.getAbsolutePath()}); } - } - catch ( IOException e ) - { - if ( log.isWarnEnabled() ) - { - log.warn( "Unable to write '" + commandLineFile.getName() + "' debug script file", e ); + } catch (IOException e) { + if (log.isWarnEnabled()) { + log.warn("Unable to write '" + commandLineFile.getName() + "' debug script file", e); } } } - try - { - returnCode = CommandLineUtils.executeCommandLine( cli, out, out ); + try { + returnCode = CommandLineUtils.executeCommandLine(cli, out, out); - messages = parseModernStream( returnCode, new BufferedReader( new StringReader( out.getOutput() ) ) ); - } - catch ( CommandLineException | IOException e ) - { - throw new CompilerException( "Error while executing the external compiler.", e ); + messages = parseModernStream(returnCode, new BufferedReader(new StringReader(out.getOutput()))); + } catch (CommandLineException | IOException e) { + throw new CompilerException("Error while executing the external compiler.", e); } boolean success = returnCode == 0; - return new CompilerResult( success, messages ); + return new CompilerResult(success, messages); } /** @@ -662,59 +581,49 @@ protected CompilerResult compileOutOfProcess( CompilerConfiguration config, Stri * @return a CompilerResult object encapsulating the result of the compilation and any compiler messages * @throws CompilerException */ - CompilerResult compileInProcess( String[] args, CompilerConfiguration config ) - throws CompilerException - { - final Class javacClass = getJavacClass( config ); + CompilerResult compileInProcess(String[] args, CompilerConfiguration config) throws CompilerException { + final Class javacClass = getJavacClass(config); final Thread thread = Thread.currentThread(); final ClassLoader contextClassLoader = thread.getContextClassLoader(); - thread.setContextClassLoader( javacClass.getClassLoader() ); - if ( log.isDebugEnabled()) { + thread.setContextClassLoader(javacClass.getClassLoader()); + if (log.isDebugEnabled()) { log.debug("ttcl changed run compileInProcessWithProperClassloader"); } - try - { + try { return compileInProcessWithProperClassloader(javacClass, args); - } - finally - { - releaseJavaccClass( javacClass, config ); - thread.setContextClassLoader( contextClassLoader ); + } finally { + releaseJavaccClass(javacClass, config); + thread.setContextClassLoader(contextClassLoader); } } - protected CompilerResult compileInProcessWithProperClassloader( Class javacClass, String[] args ) - throws CompilerException { - return compileInProcess0(javacClass, args); + protected CompilerResult compileInProcessWithProperClassloader(Class javacClass, String[] args) + throws CompilerException { + return compileInProcess0(javacClass, args); } /** * Helper method for compileInProcess() */ - private static CompilerResult compileInProcess0( Class javacClass, String[] args ) - throws CompilerException - { + private static CompilerResult compileInProcess0(Class javacClass, String[] args) throws CompilerException { StringWriter out = new StringWriter(); Integer ok; List messages; - try - { - Method compile = javacClass.getMethod( "compile", new Class[]{ String[].class, PrintWriter.class } ); + try { + Method compile = javacClass.getMethod("compile", new Class[] {String[].class, PrintWriter.class}); - ok = (Integer) compile.invoke( null, new Object[]{ args, new PrintWriter( out ) } ); + ok = (Integer) compile.invoke(null, new Object[] {args, new PrintWriter(out)}); - messages = parseModernStream( ok, new BufferedReader( new StringReader( out.toString() ) ) ); - } - catch ( NoSuchMethodException | IOException | InvocationTargetException | IllegalAccessException e ) - { - throw new CompilerException( "Error while executing the compiler.", e ); + messages = parseModernStream(ok, new BufferedReader(new StringReader(out.toString()))); + } catch (NoSuchMethodException | IOException | InvocationTargetException | IllegalAccessException e) { + throw new CompilerException("Error while executing the compiler.", e); } boolean success = ok == 0; - return new CompilerResult( success, messages ); + return new CompilerResult(success, messages); } /** @@ -725,9 +634,7 @@ private static CompilerResult compileInProcess0( Class javacClass, String[] a * @return List of CompilerMessage objects * @throws IOException */ - static List parseModernStream( int exitCode, BufferedReader input ) - throws IOException - { + static List parseModernStream(int exitCode, BufferedReader input) throws IOException { List errors = new ArrayList<>(); String line; @@ -736,36 +643,28 @@ static List parseModernStream( int exitCode, BufferedReader inp boolean hasPointer = false; - while ( true ) - { + while (true) { line = input.readLine(); - if ( line == null ) - { + if (line == null) { // javac output not detected by other parsing // maybe better to ignore only the summary an mark the rest as error String bufferAsString = buffer.toString(); - if ( buffer.length() > 0 ) - { - if ( bufferAsString.startsWith("javac:")) - { - errors.add( new CompilerMessage( bufferAsString, CompilerMessage.Kind.ERROR ) ); - } - else if ( bufferAsString.startsWith("Error occurred during initialization of boot layer")) - { - errors.add( new CompilerMessage( bufferAsString, CompilerMessage.Kind.OTHER ) ); - } - else if ( hasPointer ) - { - //A compiler message remains in buffer at end of parse stream - errors.add( parseModernError( exitCode, bufferAsString ) ); + if (buffer.length() > 0) { + if (bufferAsString.startsWith("javac:")) { + errors.add(new CompilerMessage(bufferAsString, CompilerMessage.Kind.ERROR)); + } else if (bufferAsString.startsWith("Error occurred during initialization of boot layer")) { + errors.add(new CompilerMessage(bufferAsString, CompilerMessage.Kind.OTHER)); + } else if (hasPointer) { + // A compiler message remains in buffer at end of parse stream + errors.add(parseModernError(exitCode, bufferAsString)); } } return errors; } // A compiler error occurred, treat everything that follows as part of the error. - if (line.startsWith( "An exception has occurred in the compiler") ) { + if (line.startsWith("An exception has occurred in the compiler")) { buffer = new StringBuilder(); while (line != null) { @@ -774,19 +673,17 @@ else if ( hasPointer ) line = input.readLine(); } - errors.add( new CompilerMessage( buffer.toString(), CompilerMessage.Kind.ERROR ) ); + errors.add(new CompilerMessage(buffer.toString(), CompilerMessage.Kind.ERROR)); return errors; - } - else if ( line.startsWith( "An annotation processor threw an uncaught exception." ) ) { - CompilerMessage annotationProcessingError = parseAnnotationProcessorStream( input ); - errors.add( annotationProcessingError ); + } else if (line.startsWith("An annotation processor threw an uncaught exception.")) { + CompilerMessage annotationProcessingError = parseAnnotationProcessorStream(input); + errors.add(annotationProcessingError); } // new error block? - if ( !line.startsWith( " " ) && hasPointer ) - { + if (!line.startsWith(" ") && hasPointer) { // add the error bean - errors.add( parseModernError( exitCode, buffer.toString() ) ); + errors.add(parseModernError(exitCode, buffer.toString())); // reset for next error block buffer = new StringBuilder(); // this is quicker than clearing it @@ -795,70 +692,53 @@ else if ( line.startsWith( "An annotation processor threw an uncaught exception. } // TODO: there should be a better way to parse these - if ( ( buffer.length() == 0 ) && line.startsWith( "error: " ) ) - { - errors.add( new CompilerMessage( line, CompilerMessage.Kind.ERROR ) ); - } - else if ( ( buffer.length() == 0 ) && line.startsWith( "warning: " ) ) - { - errors.add( new CompilerMessage( line, CompilerMessage.Kind.WARNING ) ); - } - else if ( ( buffer.length() == 0 ) && isNote( line ) ) - { + if ((buffer.length() == 0) && line.startsWith("error: ")) { + errors.add(new CompilerMessage(line, CompilerMessage.Kind.ERROR)); + } else if ((buffer.length() == 0) && line.startsWith("warning: ")) { + errors.add(new CompilerMessage(line, CompilerMessage.Kind.WARNING)); + } else if ((buffer.length() == 0) && isNote(line)) { // skip, JDK 1.5 telling us deprecated APIs are used but -Xlint:deprecation isn't set - } - else if ( ( buffer.length() == 0 ) && isMisc( line ) ) - { + } else if ((buffer.length() == 0) && isMisc(line)) { // verbose output was set - errors.add( new CompilerMessage( line, CompilerMessage.Kind.OTHER ) ); - } - else - { - buffer.append( line ); + errors.add(new CompilerMessage(line, CompilerMessage.Kind.OTHER)); + } else { + buffer.append(line); - buffer.append( EOL ); + buffer.append(EOL); } - if ( line.endsWith( "^" ) ) - { + if (line.endsWith("^")) { hasPointer = true; } } } - private static CompilerMessage parseAnnotationProcessorStream( final BufferedReader input ) - throws IOException - { + private static CompilerMessage parseAnnotationProcessorStream(final BufferedReader input) throws IOException { String line = input.readLine(); final StringBuilder buffer = new StringBuilder(); while (line != null) { - if (!line.startsWith( "Consult the following stack trace for details." )) { + if (!line.startsWith("Consult the following stack trace for details.")) { buffer.append(line); buffer.append(EOL); } line = input.readLine(); } - return new CompilerMessage( buffer.toString(), CompilerMessage.Kind.ERROR ); + return new CompilerMessage(buffer.toString(), CompilerMessage.Kind.ERROR); } - private static boolean isMisc( String line ) - { - return startsWithPrefix( line, MISC_PREFIXES ); + private static boolean isMisc(String line) { + return startsWithPrefix(line, MISC_PREFIXES); } - private static boolean isNote( String line ) - { - return startsWithPrefix( line, NOTE_PREFIXES ); + private static boolean isNote(String line) { + return startsWithPrefix(line, NOTE_PREFIXES); } - private static boolean startsWithPrefix( String line, String[] prefixes ) - { - for ( String prefix : prefixes ) - { - if ( line.startsWith( prefix ) ) - { + private static boolean startsWithPrefix(String line, String[] prefixes) { + for (String prefix : prefixes) { + if (line.startsWith(prefix)) { return true; } } @@ -872,14 +752,12 @@ private static boolean startsWithPrefix( String line, String[] prefixes ) * @param error output line from the compiler * @return the CompilerMessage object */ - static CompilerMessage parseModernError( int exitCode, String error ) - { - final StringTokenizer tokens = new StringTokenizer( error, ":" ); + static CompilerMessage parseModernError(int exitCode, String error) { + final StringTokenizer tokens = new StringTokenizer(error, ":"); boolean isError = exitCode != 0; - try - { + try { // With Java 6 error output lines from the compiler got longer. For backward compatibility // .. and the time being, we eat up all (if any) tokens up to the erroneous file and source // .. line indicator tokens. @@ -890,16 +768,11 @@ static CompilerMessage parseModernError( int exitCode, String error ) String currentToken = null; - do - { - if ( currentToken != null ) - { - if ( file == null ) - { + do { + if (currentToken != null) { + if (file == null) { file = new StringBuilder(currentToken); - } - else - { + } else { file.append(':').append(currentToken); } } @@ -910,107 +783,85 @@ static CompilerMessage parseModernError( int exitCode, String error ) tokenIsAnInteger = true; - try - { - Integer.parseInt( currentToken ); - } - catch ( NumberFormatException e ) - { + try { + Integer.parseInt(currentToken); + } catch (NumberFormatException e) { tokenIsAnInteger = false; } - } - while ( !tokenIsAnInteger ); + } while (!tokenIsAnInteger); final String lineIndicator = currentToken; - final int startOfFileName = file.toString().lastIndexOf( ']' ); + final int startOfFileName = file.toString().lastIndexOf(']'); - if ( startOfFileName > -1 ) - { + if (startOfFileName > -1) { file = new StringBuilder(file.substring(startOfFileName + 1 + EOL.length())); } - final int line = Integer.parseInt( lineIndicator ); + final int line = Integer.parseInt(lineIndicator); final StringBuilder msgBuffer = new StringBuilder(); - String msg = tokens.nextToken( EOL ).substring( 2 ); + String msg = tokens.nextToken(EOL).substring(2); // Remove the 'warning: ' prefix - final String warnPrefix = getWarnPrefix( msg ); - if ( warnPrefix != null ) - { + final String warnPrefix = getWarnPrefix(msg); + if (warnPrefix != null) { isError = false; - msg = msg.substring( warnPrefix.length() ); - } - else - { + msg = msg.substring(warnPrefix.length()); + } else { isError = exitCode != 0; } - msgBuffer.append( msg ); + msgBuffer.append(msg); - msgBuffer.append( EOL ); + msgBuffer.append(EOL); - String context = tokens.nextToken( EOL ); + String context = tokens.nextToken(EOL); String pointer = null; - do - { - final String msgLine = tokens.nextToken( EOL ); + do { + final String msgLine = tokens.nextToken(EOL); - if ( pointer != null ) - { - msgBuffer.append( msgLine ); + if (pointer != null) { + msgBuffer.append(msgLine); - msgBuffer.append( EOL ); - } - else if ( msgLine.endsWith( "^" ) ) - { + msgBuffer.append(EOL); + } else if (msgLine.endsWith("^")) { pointer = msgLine; - } - else - { - msgBuffer.append( context ); + } else { + msgBuffer.append(context); - msgBuffer.append( EOL ); + msgBuffer.append(EOL); context = msgLine; } - } - while ( tokens.hasMoreTokens() ); + } while (tokens.hasMoreTokens()); - msgBuffer.append( EOL ); + msgBuffer.append(EOL); final String message = msgBuffer.toString(); - final int startcolumn = pointer.indexOf( "^" ); + final int startcolumn = pointer.indexOf("^"); int endcolumn = (context == null) ? startcolumn : context.indexOf(" ", startcolumn); - if ( endcolumn == -1 ) - { + if (endcolumn == -1) { endcolumn = context.length(); } - return new CompilerMessage(file.toString(), isError, line, startcolumn, line, endcolumn, message.trim() ); - } - catch ( NoSuchElementException e ) - { - return new CompilerMessage( "no more tokens - could not parse error message: " + error, isError ); - } catch ( Exception e ) - { - return new CompilerMessage( "could not parse error message: " + error, isError ); + return new CompilerMessage(file.toString(), isError, line, startcolumn, line, endcolumn, message.trim()); + } catch (NoSuchElementException e) { + return new CompilerMessage("no more tokens - could not parse error message: " + error, isError); + } catch (Exception e) { + return new CompilerMessage("could not parse error message: " + error, isError); } } - private static String getWarnPrefix( String msg ) - { - for ( String warningPrefix : WARNING_PREFIXES ) - { - if ( msg.startsWith( warningPrefix ) ) - { + private static String getWarnPrefix(String msg) { + for (String warningPrefix : WARNING_PREFIXES) { + if (msg.startsWith(warningPrefix)) { return warningPrefix; } } @@ -1024,31 +875,23 @@ private static String getWarnPrefix( String msg ) * @return the temporary file wth the arguments * @throws IOException */ - private File createFileWithArguments( String[] args, String outputDirectory ) - throws IOException - { + private File createFileWithArguments(String[] args, String outputDirectory) throws IOException { PrintWriter writer = null; - try - { + try { File tempFile; - if ( log.isDebugEnabled() ) - { - tempFile = - File.createTempFile( JavacCompiler.class.getName(), "arguments", new File( outputDirectory ) ); - } - else - { - tempFile = File.createTempFile( JavacCompiler.class.getName(), "arguments" ); + if (log.isDebugEnabled()) { + tempFile = File.createTempFile(JavacCompiler.class.getName(), "arguments", new File(outputDirectory)); + } else { + tempFile = File.createTempFile(JavacCompiler.class.getName(), "arguments"); tempFile.deleteOnExit(); } - writer = new PrintWriter( new FileWriter( tempFile ) ); + writer = new PrintWriter(new FileWriter(tempFile)); - for ( String arg : args ) - { - String argValue = arg.replace( File.separatorChar, '/' ); + for (String arg : args) { + String argValue = arg.replace(File.separatorChar, '/'); - writer.write( "\"" + argValue + "\"" ); + writer.write("\"" + argValue + "\""); writer.println(); } @@ -1057,11 +900,8 @@ private File createFileWithArguments( String[] args, String outputDirectory ) return tempFile; - } - finally - { - if ( writer != null ) - { + } finally { + if (writer != null) { writer.close(); } } @@ -1074,63 +914,49 @@ private File createFileWithArguments( String[] args, String outputDirectory ) * @return the path of the Javadoc tool * @throws IOException if not found */ - private static String getJavacExecutable() - throws IOException - { - String javacCommand = "javac" + ( Os.isFamily( Os.FAMILY_WINDOWS ) ? ".exe" : "" ); + private static String getJavacExecutable() throws IOException { + String javacCommand = "javac" + (Os.isFamily(Os.FAMILY_WINDOWS) ? ".exe" : ""); - String javaHome = System.getProperty( "java.home" ); + String javaHome = System.getProperty("java.home"); File javacExe; - if ( Os.isName( "AIX" ) ) - { - javacExe = new File( javaHome + File.separator + ".." + File.separator + "sh", javacCommand ); - } - else if ( Os.isName( "Mac OS X" ) ) - { - javacExe = new File( javaHome + File.separator + "bin", javacCommand ); - } - else - { - javacExe = new File( javaHome + File.separator + ".." + File.separator + "bin", javacCommand ); + if (Os.isName("AIX")) { + javacExe = new File(javaHome + File.separator + ".." + File.separator + "sh", javacCommand); + } else if (Os.isName("Mac OS X")) { + javacExe = new File(javaHome + File.separator + "bin", javacCommand); + } else { + javacExe = new File(javaHome + File.separator + ".." + File.separator + "bin", javacCommand); } // ---------------------------------------------------------------------- // Try to find javacExe from JAVA_HOME environment variable // ---------------------------------------------------------------------- - if ( !javacExe.isFile() ) - { + if (!javacExe.isFile()) { Properties env = CommandLineUtils.getSystemEnvVars(); - javaHome = env.getProperty( "JAVA_HOME" ); - if ( StringUtils.isEmpty( javaHome ) ) - { - throw new IOException( "The environment variable JAVA_HOME is not correctly set." ); + javaHome = env.getProperty("JAVA_HOME"); + if (StringUtils.isEmpty(javaHome)) { + throw new IOException("The environment variable JAVA_HOME is not correctly set."); } - if ( !new File( javaHome ).isDirectory() ) - { - throw new IOException( - "The environment variable JAVA_HOME=" + javaHome + " doesn't exist or is not a valid directory." ); + if (!new File(javaHome).isDirectory()) { + throw new IOException("The environment variable JAVA_HOME=" + javaHome + + " doesn't exist or is not a valid directory."); } - javacExe = new File( env.getProperty( "JAVA_HOME" ) + File.separator + "bin", javacCommand ); + javacExe = new File(env.getProperty("JAVA_HOME") + File.separator + "bin", javacCommand); } - if ( !javacExe.isFile() ) - { - throw new IOException( "The javadoc executable '" + javacExe - + "' doesn't exist or is not a file. Verify the JAVA_HOME environment variable." ); + if (!javacExe.isFile()) { + throw new IOException("The javadoc executable '" + javacExe + + "' doesn't exist or is not a file. Verify the JAVA_HOME environment variable."); } return javacExe.getAbsolutePath(); } - private void releaseJavaccClass( Class javaccClass, CompilerConfiguration compilerConfiguration ) - { - if ( compilerConfiguration.getCompilerReuseStrategy() - == CompilerConfiguration.CompilerReuseStrategy.ReuseCreated ) - { - javaccClasses.add( javaccClass ); + private void releaseJavaccClass(Class javaccClass, CompilerConfiguration compilerConfiguration) { + if (compilerConfiguration.getCompilerReuseStrategy() + == CompilerConfiguration.CompilerReuseStrategy.ReuseCreated) { + javaccClasses.add(javaccClass); } - } /** @@ -1139,21 +965,16 @@ private void releaseJavaccClass( Class javaccClass, CompilerConfiguration com * @return the non-null class. * @throws CompilerException if the class has not been found. */ - private Class getJavacClass( CompilerConfiguration compilerConfiguration ) - throws CompilerException - { + private Class getJavacClass(CompilerConfiguration compilerConfiguration) throws CompilerException { Class c = null; - switch ( compilerConfiguration.getCompilerReuseStrategy() ) - { + switch (compilerConfiguration.getCompilerReuseStrategy()) { case AlwaysNew: return createJavacClass(); case ReuseCreated: - synchronized ( javaccClasses ) - { - if ( javaccClasses.size() > 0 ) - { - c = javaccClasses.get( 0 ); - javaccClasses.remove( c ); + synchronized (javaccClasses) { + if (javaccClasses.size() > 0) { + c = javaccClasses.get(0); + javaccClasses.remove(c); return c; } } @@ -1162,49 +983,36 @@ private Class getJavacClass( CompilerConfiguration compilerConfiguration ) case ReuseSame: default: c = JavacCompiler.JAVAC_CLASS; - if ( c != null ) - { + if (c != null) { return c; } - synchronized ( JavacCompiler.LOCK ) - { - if ( c == null ) - { + synchronized (JavacCompiler.LOCK) { + if (c == null) { JavacCompiler.JAVAC_CLASS = c = createJavacClass(); } return c; } - - } } - /** * Helper method for create Javac class */ - protected Class createJavacClass() - throws CompilerException - { - try - { + protected Class createJavacClass() throws CompilerException { + try { // look whether JavaC is on Maven's classpath - //return Class.forName( JavacCompiler.JAVAC_CLASSNAME, true, JavacCompiler.class.getClassLoader() ); - return JavacCompiler.class.getClassLoader().loadClass( JavacCompiler.JAVAC_CLASSNAME ); - } - catch ( ClassNotFoundException ex ) - { + // return Class.forName( JavacCompiler.JAVAC_CLASSNAME, true, JavacCompiler.class.getClassLoader() ); + return JavacCompiler.class.getClassLoader().loadClass(JavacCompiler.JAVAC_CLASSNAME); + } catch (ClassNotFoundException ex) { // ok } - final File toolsJar = new File( System.getProperty( "java.home" ), "../lib/tools.jar" ); - if ( !toolsJar.exists() ) - { - throw new CompilerException( "tools.jar not found: " + toolsJar ); + final File toolsJar = new File(System.getProperty("java.home"), "../lib/tools.jar"); + if (!toolsJar.exists()) { + throw new CompilerException("tools.jar not found: " + toolsJar); } - try - { + try { // Combined classloader with no parent/child relationship, so classes in our classloader // can reference classes in tools.jar URL[] originalUrls = ((URLClassLoader) JavacCompiler.class.getClassLoader()).getURLs(); @@ -1215,31 +1023,26 @@ protected Class createJavacClass() final Thread thread = Thread.currentThread(); final ClassLoader contextClassLoader = thread.getContextClassLoader(); - thread.setContextClassLoader( javacClassLoader ); - try - { - //return Class.forName( JavacCompiler.JAVAC_CLASSNAME, true, javacClassLoader ); - return javacClassLoader.loadClass( JavacCompiler.JAVAC_CLASSNAME ); - } - finally - { - thread.setContextClassLoader( contextClassLoader ); + thread.setContextClassLoader(javacClassLoader); + try { + // return Class.forName( JavacCompiler.JAVAC_CLASSNAME, true, javacClassLoader ); + return javacClassLoader.loadClass(JavacCompiler.JAVAC_CLASSNAME); + } finally { + thread.setContextClassLoader(contextClassLoader); } - } - catch ( MalformedURLException ex ) - { + } catch (MalformedURLException ex) { throw new CompilerException( - "Could not convert the file reference to tools.jar to a URL, path to tools.jar: '" - + toolsJar.getAbsolutePath() + "'.", ex ); - } - catch ( ClassNotFoundException ex ) - { - throw new CompilerException( "Unable to locate the Javac Compiler in:" + EOL + " " + toolsJar + EOL - + "Please ensure you are using JDK 1.4 or above and" + EOL - + "not a JRE (the com.sun.tools.javac.Main class is required)." + EOL - + "In most cases you can change the location of your Java" + EOL - + "installation by setting the JAVA_HOME environment variable.", ex ); + "Could not convert the file reference to tools.jar to a URL, path to tools.jar: '" + + toolsJar.getAbsolutePath() + "'.", + ex); + } catch (ClassNotFoundException ex) { + throw new CompilerException( + "Unable to locate the Javac Compiler in:" + EOL + " " + toolsJar + EOL + + "Please ensure you are using JDK 1.4 or above and" + EOL + + "not a JRE (the com.sun.tools.javac.Main class is required)." + EOL + + "In most cases you can change the location of your Java" + EOL + + "installation by setting the JAVA_HOME environment variable.", + ex); } } - } diff --git a/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavaxToolsCompiler.java b/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavaxToolsCompiler.java index 0114c8f1..ad929986 100644 --- a/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavaxToolsCompiler.java +++ b/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavaxToolsCompiler.java @@ -18,13 +18,6 @@ * under the License. */ -import org.codehaus.plexus.compiler.CompilerConfiguration; -import org.codehaus.plexus.compiler.CompilerMessage; -import org.codehaus.plexus.compiler.CompilerException; -import org.codehaus.plexus.compiler.CompilerResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import javax.inject.Named; import javax.tools.Diagnostic; import javax.tools.DiagnosticCollector; @@ -32,6 +25,7 @@ import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; import javax.tools.ToolProvider; + import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; @@ -40,42 +34,43 @@ import java.util.Locale; import java.util.concurrent.CopyOnWriteArrayList; +import org.codehaus.plexus.compiler.CompilerConfiguration; +import org.codehaus.plexus.compiler.CompilerException; +import org.codehaus.plexus.compiler.CompilerMessage; +import org.codehaus.plexus.compiler.CompilerResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * @author Olivier Lamy * @author David M. Lloyd * @since 2.0 */ @Named -public class JavaxToolsCompiler implements InProcessCompiler -{ - private final Logger log = LoggerFactory.getLogger( getClass() ); +public class JavaxToolsCompiler implements InProcessCompiler { + private final Logger log = LoggerFactory.getLogger(getClass()); /** * is that thread safe ??? */ - @SuppressWarnings( "restriction" ) + @SuppressWarnings("restriction") private final JavaCompiler COMPILER = newJavaCompiler(); - protected JavaCompiler newJavaCompiler() - { - return ToolProvider.getSystemJavaCompiler(); - } + protected JavaCompiler newJavaCompiler() { + return ToolProvider.getSystemJavaCompiler(); + } private final List JAVA_COMPILERS = new CopyOnWriteArrayList<>(); - private JavaCompiler getJavaCompiler( CompilerConfiguration compilerConfiguration ) - { - switch ( compilerConfiguration.getCompilerReuseStrategy() ) - { + private JavaCompiler getJavaCompiler(CompilerConfiguration compilerConfiguration) { + switch (compilerConfiguration.getCompilerReuseStrategy()) { case AlwaysNew: return newJavaCompiler(); case ReuseCreated: JavaCompiler javaCompiler; - synchronized ( JAVA_COMPILERS ) - { - if ( JAVA_COMPILERS.size() > 0 ) - { - javaCompiler = JAVA_COMPILERS.get( 0 ); - JAVA_COMPILERS.remove( javaCompiler ); + synchronized (JAVA_COMPILERS) { + if (JAVA_COMPILERS.size() > 0) { + javaCompiler = JAVA_COMPILERS.get(0); + JAVA_COMPILERS.remove(javaCompiler); return javaCompiler; } } @@ -85,130 +80,111 @@ private JavaCompiler getJavaCompiler( CompilerConfiguration compilerConfiguratio default: return COMPILER; } - } - private void releaseJavaCompiler( JavaCompiler javaCompiler, CompilerConfiguration compilerConfiguration ) - { - if ( javaCompiler == null ) - { + private void releaseJavaCompiler(JavaCompiler javaCompiler, CompilerConfiguration compilerConfiguration) { + if (javaCompiler == null) { return; } - if ( compilerConfiguration.getCompilerReuseStrategy() - == CompilerConfiguration.CompilerReuseStrategy.ReuseCreated ) - { - JAVA_COMPILERS.add( javaCompiler ); + if (compilerConfiguration.getCompilerReuseStrategy() + == CompilerConfiguration.CompilerReuseStrategy.ReuseCreated) { + JAVA_COMPILERS.add(javaCompiler); } } - public CompilerResult compileInProcess( String[] args, final CompilerConfiguration config, String[] sourceFiles ) - throws CompilerException - { - JavaCompiler compiler = getJavaCompiler( config ); - try - { - if ( compiler == null ) - { - CompilerMessage message = new CompilerMessage( "No compiler is provided in this environment. " - + "Perhaps you are running on a JRE rather than a JDK?", - CompilerMessage.Kind.ERROR ); - return new CompilerResult( false, Collections.singletonList( message ) ); + public CompilerResult compileInProcess(String[] args, final CompilerConfiguration config, String[] sourceFiles) + throws CompilerException { + JavaCompiler compiler = getJavaCompiler(config); + try { + if (compiler == null) { + CompilerMessage message = new CompilerMessage( + "No compiler is provided in this environment. " + + "Perhaps you are running on a JRE rather than a JDK?", + CompilerMessage.Kind.ERROR); + return new CompilerResult(false, Collections.singletonList(message)); } String sourceEncoding = config.getSourceEncoding(); - Charset sourceCharset = sourceEncoding == null ? null : Charset.forName( sourceEncoding ); + Charset sourceCharset = sourceEncoding == null ? null : Charset.forName(sourceEncoding); DiagnosticCollector collector = new DiagnosticCollector<>(); - try ( StandardJavaFileManager standardFileManager = - compiler.getStandardFileManager( collector, null, sourceCharset ) ) - { + try (StandardJavaFileManager standardFileManager = + compiler.getStandardFileManager(collector, null, sourceCharset)) { Iterable fileObjects = - standardFileManager.getJavaFileObjectsFromStrings( Arrays.asList( sourceFiles ) ); + standardFileManager.getJavaFileObjectsFromStrings(Arrays.asList(sourceFiles)); - /*(Writer out, - JavaFileManager fileManager, - DiagnosticListener diagnosticListener, - Iterable options, - Iterable classes, - Iterable compilationUnits)*/ + /*(Writer out, + JavaFileManager fileManager, + DiagnosticListener diagnosticListener, + Iterable options, + Iterable classes, + Iterable compilationUnits)*/ - List arguments = Arrays.asList( args ); + List arguments = Arrays.asList(args); JavaCompiler.CompilationTask task = - compiler.getTask( null, standardFileManager, collector, arguments, null, fileObjects ); + compiler.getTask(null, standardFileManager, collector, arguments, null, fileObjects); Boolean result = task.call(); List compilerMsgs = new ArrayList<>(); - for ( Diagnostic diagnostic : collector.getDiagnostics() ) - { - CompilerMessage.Kind kind = convertKind( diagnostic ); + for (Diagnostic diagnostic : collector.getDiagnostics()) { + CompilerMessage.Kind kind = convertKind(diagnostic); String baseMessage; - try - { - baseMessage = diagnostic.getMessage( Locale.getDefault() ); - } - catch ( Throwable e ) //ignore any possible error from jdk + try { + baseMessage = diagnostic.getMessage(Locale.getDefault()); + } catch (Throwable e) // ignore any possible error from jdk { // workaround for https://bugs.openjdk.java.net/browse/JDK-8210649 // workaround for https://bugs.openjdk.java.net/browse/JDK-8216202 - log.debug( "Ignore Issue get JavaCompiler Diagnostic message (see https://bugs.openjdk.java.net/browse/JDK-8210649):" + e.getMessage(), e ); - // in this case we try to replace the baseMessage with toString (hoping this does not throw a new exception.. + log.debug( + "Ignore Issue get JavaCompiler Diagnostic message (see https://bugs.openjdk.java.net/browse/JDK-8210649):" + + e.getMessage(), + e); + // in this case we try to replace the baseMessage with toString (hoping this does not throw a + // new exception.. baseMessage = diagnostic.toString(); } - if ( baseMessage == null ) - { + if (baseMessage == null) { continue; } JavaFileObject source = diagnostic.getSource(); String longFileName = source == null ? null : source.toUri().getPath(); String shortFileName = source == null ? null : source.getName(); String formattedMessage = baseMessage; - int lineNumber = Math.max( 0, (int) diagnostic.getLineNumber() ); - int columnNumber = Math.max( 0, (int) diagnostic.getColumnNumber() ); - if ( source != null && lineNumber > 0 ) - { + int lineNumber = Math.max(0, (int) diagnostic.getLineNumber()); + int columnNumber = Math.max(0, (int) diagnostic.getColumnNumber()); + if (source != null && lineNumber > 0) { // Some compilers like to copy the file name into the message, which makes it appear twice. String possibleTrimming = longFileName + ":" + lineNumber + ": "; - if ( formattedMessage.startsWith( possibleTrimming ) ) - { - formattedMessage = formattedMessage.substring( possibleTrimming.length() ); - } - else - { + if (formattedMessage.startsWith(possibleTrimming)) { + formattedMessage = formattedMessage.substring(possibleTrimming.length()); + } else { possibleTrimming = shortFileName + ":" + lineNumber + ": "; - if ( formattedMessage.startsWith( possibleTrimming ) ) - { - formattedMessage = formattedMessage.substring( possibleTrimming.length() ); + if (formattedMessage.startsWith(possibleTrimming)) { + formattedMessage = formattedMessage.substring(possibleTrimming.length()); } } } - compilerMsgs.add( - new CompilerMessage( longFileName, kind, lineNumber, columnNumber, lineNumber, columnNumber, - formattedMessage ) ); + compilerMsgs.add(new CompilerMessage( + longFileName, kind, lineNumber, columnNumber, lineNumber, columnNumber, formattedMessage)); } - if ( result != Boolean.TRUE && compilerMsgs.isEmpty() ) - { + if (result != Boolean.TRUE && compilerMsgs.isEmpty()) { compilerMsgs.add( - new CompilerMessage( "An unknown compilation problem occurred", CompilerMessage.Kind.ERROR ) ); + new CompilerMessage("An unknown compilation problem occurred", CompilerMessage.Kind.ERROR)); } - return new CompilerResult( result, compilerMsgs ); + return new CompilerResult(result, compilerMsgs); } - } - catch ( Exception e ) - { - throw new CompilerException( e.getMessage(), e ); - } - finally - { - releaseJavaCompiler( compiler, config ); + } catch (Exception e) { + throw new CompilerException(e.getMessage(), e); + } finally { + releaseJavaCompiler(compiler, config); } } private CompilerMessage.Kind convertKind(Diagnostic diagnostic) { CompilerMessage.Kind kind; - switch ( diagnostic.getKind() ) - { + switch (diagnostic.getKind()) { case ERROR: kind = CompilerMessage.Kind.ERROR; break; diff --git a/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/AbstractJavacCompilerTest.java b/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/AbstractJavacCompilerTest.java index cfccb28a..9cb656a5 100644 --- a/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/AbstractJavacCompilerTest.java +++ b/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/AbstractJavacCompilerTest.java @@ -23,14 +23,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - -import org.codehaus.plexus.compiler.AbstractCompilerTest; -import org.codehaus.plexus.compiler.CompilerConfiguration; -import org.codehaus.plexus.util.StringUtils; -import org.hamcrest.Matchers; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - import java.io.File; import java.util.ArrayList; import java.util.Arrays; @@ -39,68 +31,78 @@ import java.util.List; import java.util.Map; +import org.codehaus.plexus.compiler.AbstractCompilerTest; +import org.codehaus.plexus.compiler.CompilerConfiguration; +import org.codehaus.plexus.util.StringUtils; +import org.hamcrest.Matchers; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; /** * @author Jason van Zyl */ -public abstract class AbstractJavacCompilerTest - extends AbstractCompilerTest -{ +public abstract class AbstractJavacCompilerTest extends AbstractCompilerTest { private static final String PS = File.pathSeparator; @BeforeEach - public void setUp() - { - setCompilerDebug( true ); - setCompilerDeprecationWarnings( true ); + public void setUp() { + setCompilerDebug(true); + setCompilerDeprecationWarnings(true); } @Override - protected String getRoleHint() - { + protected String getRoleHint() { return "javac"; } @Override - protected int expectedErrors() - { + protected int expectedErrors() { String javaVersion = getJavaVersion(); - if (javaVersion.contains("9.0")||javaVersion.contains("11")||javaVersion.contains("14")|| - javaVersion.contains("15")||javaVersion.contains("16")||javaVersion.contains("17")|| - javaVersion.contains("18")||javaVersion.contains("19")||javaVersion.contains("20")|| - javaVersion.contains("21")){ + if (javaVersion.contains("9.0") + || javaVersion.contains("11") + || javaVersion.contains("14") + || javaVersion.contains("15") + || javaVersion.contains("16") + || javaVersion.contains("17") + || javaVersion.contains("18") + || javaVersion.contains("19") + || javaVersion.contains("20") + || javaVersion.contains("21")) { return 5; } - // javac output changed for misspelled modifiers starting in 1.6...they now generate 2 errors per occurrence, not one. - if ( "1.5".compareTo( javaVersion ) < 0 ) - { + // javac output changed for misspelled modifiers starting in 1.6...they now generate 2 errors per occurrence, + // not one. + if ("1.5".compareTo(javaVersion) < 0) { return 4; - } - else - { + } else { return 3; } } @Override - protected int expectedWarnings() - { + protected int expectedWarnings() { String javaVersion = getJavaVersion(); - if (javaVersion.contains("9.0")||javaVersion.contains("11")||javaVersion.contains("14")|| - javaVersion.contains("15")||javaVersion.contains("16")||javaVersion.contains("17")|| - javaVersion.contains("18")||javaVersion.contains("19")||javaVersion.contains("20")|| - javaVersion.contains("21")){ + if (javaVersion.contains("9.0") + || javaVersion.contains("11") + || javaVersion.contains("14") + || javaVersion.contains("15") + || javaVersion.contains("16") + || javaVersion.contains("17") + || javaVersion.contains("18") + || javaVersion.contains("19") + || javaVersion.contains("20") + || javaVersion.contains("21")) { return 1; } - if (javaVersion.contains("1.8")){ + if (javaVersion.contains("1.8")) { // lots of new warnings about obsoletions for future releases return 30; } - if ( "1.6".compareTo( javaVersion ) < 0 ) - { + if ("1.6".compareTo(javaVersion) < 0) { // with 1.7 some warning with bootstrap class path not set in conjunction with -source 1.3 return 9; } @@ -109,238 +111,234 @@ protected int expectedWarnings() } @Override - public String getTargetVersion() - { + public String getTargetVersion() { String javaVersion = getJavaVersion(); - if (javaVersion.contains("9.0")){ + if (javaVersion.contains("9.0")) { return "1.7"; } - if (javaVersion.contains("11")){ + if (javaVersion.contains("11")) { return "11"; } - if (javaVersion.contains("14")){ + if (javaVersion.contains("14")) { return "14"; } - if (javaVersion.contains("15")){ + if (javaVersion.contains("15")) { return "15"; } - if (javaVersion.contains("16")){ + if (javaVersion.contains("16")) { return "16"; } - if (javaVersion.contains("17")){ + if (javaVersion.contains("17")) { return "17"; } - if (javaVersion.contains("18")){ + if (javaVersion.contains("18")) { return "18"; } - if (javaVersion.contains("19")){ + if (javaVersion.contains("19")) { return "19"; } - if (javaVersion.contains("20")){ + if (javaVersion.contains("20")) { return "20"; } - if (javaVersion.contains("21")){ + if (javaVersion.contains("21")) { return "21"; } return super.getTargetVersion(); } @Override - public String getSourceVersion() - { + public String getSourceVersion() { String javaVersion = getJavaVersion(); - if (javaVersion.contains("9.0")) - { + if (javaVersion.contains("9.0")) { return "1.7"; } - if (javaVersion.contains("11")) - { + if (javaVersion.contains("11")) { return "11"; } - if (javaVersion.contains("14")) - { + if (javaVersion.contains("14")) { return "14"; } - if (javaVersion.contains("15")) - { + if (javaVersion.contains("15")) { return "15"; } - if (javaVersion.contains("16")){ + if (javaVersion.contains("16")) { return "16"; } - if (javaVersion.contains("17")){ + if (javaVersion.contains("17")) { return "17"; } - if (javaVersion.contains("18")){ + if (javaVersion.contains("18")) { return "18"; } - if (javaVersion.contains("19")){ + if (javaVersion.contains("19")) { return "19"; } - if (javaVersion.contains("20")){ + if (javaVersion.contains("20")) { return "20"; } - if (javaVersion.contains("21")){ + if (javaVersion.contains("21")) { return "21"; } return super.getTargetVersion(); } @Override - protected Collection expectedOutputFiles() - { + protected Collection expectedOutputFiles() { String javaVersion = getJavaVersion(); - if (javaVersion.contains("9.0")||javaVersion.contains("11")||javaVersion.contains("14")|| - javaVersion.contains("15")||javaVersion.contains("16")||javaVersion.contains("17")|| - javaVersion.contains("18")||javaVersion.contains("19")||javaVersion.contains("20")|| - javaVersion.contains("21") - ){ - return Arrays.asList( "org/codehaus/foo/Deprecation.class", "org/codehaus/foo/ExternalDeps.class", - "org/codehaus/foo/Person.class" ); - } - return Arrays.asList( "org/codehaus/foo/Deprecation.class", "org/codehaus/foo/ExternalDeps.class", - "org/codehaus/foo/Person.class", "org/codehaus/foo/ReservedWord.class" ); + if (javaVersion.contains("9.0") + || javaVersion.contains("11") + || javaVersion.contains("14") + || javaVersion.contains("15") + || javaVersion.contains("16") + || javaVersion.contains("17") + || javaVersion.contains("18") + || javaVersion.contains("19") + || javaVersion.contains("20") + || javaVersion.contains("21")) { + return Arrays.asList( + "org/codehaus/foo/Deprecation.class", + "org/codehaus/foo/ExternalDeps.class", + "org/codehaus/foo/Person.class"); + } + return Arrays.asList( + "org/codehaus/foo/Deprecation.class", + "org/codehaus/foo/ExternalDeps.class", + "org/codehaus/foo/Person.class", + "org/codehaus/foo/ReservedWord.class"); } protected void internalTest(CompilerConfiguration compilerConfiguration, List expectedArguments) { internalTest(compilerConfiguration, expectedArguments, new String[0]); } - public void internalTest(CompilerConfiguration compilerConfiguration, List expectedArguments, String[] sources) - { - String[] actualArguments = JavacCompiler.buildCompilerArguments( compilerConfiguration, sources ); + public void internalTest( + CompilerConfiguration compilerConfiguration, List expectedArguments, String[] sources) { + String[] actualArguments = JavacCompiler.buildCompilerArguments(compilerConfiguration, sources); - assertThat( "The expected and actual argument list sizes differ.", - actualArguments, Matchers.arrayWithSize(expectedArguments.size() )); + assertThat( + "The expected and actual argument list sizes differ.", + actualArguments, + Matchers.arrayWithSize(expectedArguments.size())); - for ( int i = 0; i < actualArguments.length; i++ ) - { - assertThat( "Unexpected argument", actualArguments[i], is( expectedArguments.get( i ) )); + for (int i = 0; i < actualArguments.length; i++) { + assertThat("Unexpected argument", actualArguments[i], is(expectedArguments.get(i))); } } @Test - public void testBuildCompilerArgs13() - { + public void testBuildCompilerArgs13() { List expectedArguments = new ArrayList<>(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); - compilerConfiguration.setCompilerVersion( "1.3" ); + compilerConfiguration.setCompilerVersion("1.3"); - populateArguments( compilerConfiguration, expectedArguments, true, true, false ); + populateArguments(compilerConfiguration, expectedArguments, true, true, false); - internalTest( compilerConfiguration, expectedArguments ); + internalTest(compilerConfiguration, expectedArguments); } @Test - public void testBuildCompilerArgs14() - { + public void testBuildCompilerArgs14() { List expectedArguments = new ArrayList<>(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); - compilerConfiguration.setCompilerVersion( "1.4" ); + compilerConfiguration.setCompilerVersion("1.4"); - populateArguments( compilerConfiguration, expectedArguments, false, false, false ); + populateArguments(compilerConfiguration, expectedArguments, false, false, false); - internalTest( compilerConfiguration, expectedArguments ); + internalTest(compilerConfiguration, expectedArguments); } @Test - public void testBuildCompilerArgs15() - { + public void testBuildCompilerArgs15() { List expectedArguments = new ArrayList<>(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); - compilerConfiguration.setCompilerVersion( "1.5" ); + compilerConfiguration.setCompilerVersion("1.5"); - populateArguments( compilerConfiguration, expectedArguments, false, false, false ); + populateArguments(compilerConfiguration, expectedArguments, false, false, false); - internalTest( compilerConfiguration, expectedArguments ); + internalTest(compilerConfiguration, expectedArguments); } @Test - public void testBuildCompilerArgs18() - { + public void testBuildCompilerArgs18() { List expectedArguments = new ArrayList<>(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); - compilerConfiguration.setCompilerVersion( "1.8" ); + compilerConfiguration.setCompilerVersion("1.8"); - populateArguments( compilerConfiguration, expectedArguments, false, false, true ); + populateArguments(compilerConfiguration, expectedArguments, false, false, true); - internalTest( compilerConfiguration, expectedArguments ); + internalTest(compilerConfiguration, expectedArguments); } @Test - public void testBuildCompilerArgsUnspecifiedVersion() - { + public void testBuildCompilerArgsUnspecifiedVersion() { List expectedArguments = new ArrayList<>(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); - populateArguments( compilerConfiguration, expectedArguments, false, false, false ); + populateArguments(compilerConfiguration, expectedArguments, false, false, false); - internalTest( compilerConfiguration, expectedArguments ); + internalTest(compilerConfiguration, expectedArguments); } @Test - public void testBuildCompilerDebugLevel() - { + public void testBuildCompilerDebugLevel() { List expectedArguments = new ArrayList<>(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); - compilerConfiguration.setDebug( true ); + compilerConfiguration.setDebug(true); - compilerConfiguration.setDebugLevel( "none" ); + compilerConfiguration.setDebugLevel("none"); - populateArguments( compilerConfiguration, expectedArguments, false, false, false ); + populateArguments(compilerConfiguration, expectedArguments, false, false, false); - internalTest( compilerConfiguration, expectedArguments ); + internalTest(compilerConfiguration, expectedArguments); } // PLXCOMP-190 @Test - public void testJRuntimeArguments() - { + public void testJRuntimeArguments() { List expectedArguments = new ArrayList<>(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); // outputLocation - compilerConfiguration.setOutputLocation( "/output" ); - expectedArguments.add( "-d" ); - expectedArguments.add( new File( "/output" ).getAbsolutePath() ); + compilerConfiguration.setOutputLocation("/output"); + expectedArguments.add("-d"); + expectedArguments.add(new File("/output").getAbsolutePath()); // targetVersion - compilerConfiguration.setTargetVersion( "1.3" ); - expectedArguments.add( "-target" ); - expectedArguments.add( "1.3" ); + compilerConfiguration.setTargetVersion("1.3"); + expectedArguments.add("-target"); + expectedArguments.add("1.3"); // sourceVersion - compilerConfiguration.setSourceVersion( "1.3" ); - expectedArguments.add( "-source" ); - expectedArguments.add( "1.3" ); + compilerConfiguration.setSourceVersion("1.3"); + expectedArguments.add("-source"); + expectedArguments.add("1.3"); // unshared table - expectedArguments.add( "-XDuseUnsharedTable=true" ); + expectedArguments.add("-XDuseUnsharedTable=true"); // customCompilerArguments Map customCompilerArguments = new LinkedHashMap<>(); - customCompilerArguments.put( "-J-Duser.language=en_us", null ); - compilerConfiguration.setCustomCompilerArgumentsAsMap( customCompilerArguments ); + customCompilerArguments.put("-J-Duser.language=en_us", null); + compilerConfiguration.setCustomCompilerArgumentsAsMap(customCompilerArguments); // don't expect this argument!! - internalTest( compilerConfiguration, expectedArguments ); + internalTest(compilerConfiguration, expectedArguments); } @Test - public void testModulePathAnnotations() throws Exception - { + public void testModulePathAnnotations() throws Exception { List expectedArguments = new ArrayList<>(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); @@ -348,175 +346,168 @@ public void testModulePathAnnotations() throws Exception final String[] source = {"module-info.java"}; // outputLocation - compilerConfiguration.setOutputLocation( "/output" ); - expectedArguments.add( "-d" ); - expectedArguments.add( new File( "/output" ).getAbsolutePath() ); + compilerConfiguration.setOutputLocation("/output"); + expectedArguments.add("-d"); + expectedArguments.add(new File("/output").getAbsolutePath()); // failOnWarning - compilerConfiguration.setModulepathEntries( Arrays.asList( "/repo/a/b/1.0/b-1.0.jar", - "/repo/c/d/1.0/d-1.0.jar" ) ); - expectedArguments.add( "--module-path" ); - expectedArguments.add( "/repo/a/b/1.0/b-1.0.jar" + File.pathSeparator + - "/repo/c/d/1.0/d-1.0.jar" + File.pathSeparator ); - - compilerConfiguration.setProcessorModulePathEntries(Arrays.asList("/repo/a/b/1.0/annotations-1.0.jar", - "/repo/f/a/1.0/annotations-4.0.jar")); - expectedArguments.add( "--processor-module-path" ); - expectedArguments.add("/repo/a/b/1.0/annotations-1.0.jar" + File.pathSeparator + - "/repo/f/a/1.0/annotations-4.0.jar" + File.pathSeparator ); + compilerConfiguration.setModulepathEntries(Arrays.asList("/repo/a/b/1.0/b-1.0.jar", "/repo/c/d/1.0/d-1.0.jar")); + expectedArguments.add("--module-path"); + expectedArguments.add( + "/repo/a/b/1.0/b-1.0.jar" + File.pathSeparator + "/repo/c/d/1.0/d-1.0.jar" + File.pathSeparator); + + compilerConfiguration.setProcessorModulePathEntries( + Arrays.asList("/repo/a/b/1.0/annotations-1.0.jar", "/repo/f/a/1.0/annotations-4.0.jar")); + expectedArguments.add("--processor-module-path"); + expectedArguments.add("/repo/a/b/1.0/annotations-1.0.jar" + File.pathSeparator + + "/repo/f/a/1.0/annotations-4.0.jar" + File.pathSeparator); // releaseVersion - compilerConfiguration.setReleaseVersion( "9" ); - expectedArguments.add( "--release" ); - expectedArguments.add( "9" ); + compilerConfiguration.setReleaseVersion("9"); + expectedArguments.add("--release"); + expectedArguments.add("9"); // unshared table - expectedArguments.add( "-XDuseUnsharedTable=true" ); + expectedArguments.add("-XDuseUnsharedTable=true"); - internalTest( compilerConfiguration, expectedArguments, source); + internalTest(compilerConfiguration, expectedArguments, source); } @Test - public void testModulePath() throws Exception - { + public void testModulePath() throws Exception { List expectedArguments = new ArrayList<>(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); // outputLocation - compilerConfiguration.setOutputLocation( "/output" ); - expectedArguments.add( "-d" ); - expectedArguments.add( new File( "/output" ).getAbsolutePath() ); + compilerConfiguration.setOutputLocation("/output"); + expectedArguments.add("-d"); + expectedArguments.add(new File("/output").getAbsolutePath()); // failOnWarning - compilerConfiguration.setModulepathEntries( Arrays.asList( "/repo/a/b/1.0/b-1.0.jar", - "/repo/c/d/1.0/d-1.0.jar" ) ); - expectedArguments.add( "--module-path" ); - expectedArguments.add( "/repo/a/b/1.0/b-1.0.jar" + File.pathSeparator + - "/repo/c/d/1.0/d-1.0.jar" + File.pathSeparator ); + compilerConfiguration.setModulepathEntries(Arrays.asList("/repo/a/b/1.0/b-1.0.jar", "/repo/c/d/1.0/d-1.0.jar")); + expectedArguments.add("--module-path"); + expectedArguments.add( + "/repo/a/b/1.0/b-1.0.jar" + File.pathSeparator + "/repo/c/d/1.0/d-1.0.jar" + File.pathSeparator); // default source + target - expectedArguments.add( "-target" ); - expectedArguments.add( "1.1" ); - expectedArguments.add( "-source" ); - expectedArguments.add( "1.3" ); + expectedArguments.add("-target"); + expectedArguments.add("1.1"); + expectedArguments.add("-source"); + expectedArguments.add("1.3"); // unshared table - expectedArguments.add( "-XDuseUnsharedTable=true" ); + expectedArguments.add("-XDuseUnsharedTable=true"); - internalTest( compilerConfiguration, expectedArguments ); + internalTest(compilerConfiguration, expectedArguments); } @Test - public void testModuleVersion() - { + public void testModuleVersion() { List expectedArguments = new ArrayList<>(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); // outputLocation - compilerConfiguration.setOutputLocation( "/output" ); - expectedArguments.add( "-d" ); - expectedArguments.add( new File( "/output" ).getAbsolutePath() ); + compilerConfiguration.setOutputLocation("/output"); + expectedArguments.add("-d"); + expectedArguments.add(new File("/output").getAbsolutePath()); // default source + target - expectedArguments.add( "-target" ); - expectedArguments.add( "1.1" ); - expectedArguments.add( "-source" ); - expectedArguments.add( "1.3" ); + expectedArguments.add("-target"); + expectedArguments.add("1.1"); + expectedArguments.add("-source"); + expectedArguments.add("1.3"); // module version - compilerConfiguration.setModuleVersion( "1.2.0-SNAPSHOT" ); - expectedArguments.add( "--module-version" ); - expectedArguments.add( "1.2.0-SNAPSHOT" ); + compilerConfiguration.setModuleVersion("1.2.0-SNAPSHOT"); + expectedArguments.add("--module-version"); + expectedArguments.add("1.2.0-SNAPSHOT"); // unshared table - expectedArguments.add( "-XDuseUnsharedTable=true" ); + expectedArguments.add("-XDuseUnsharedTable=true"); - internalTest( compilerConfiguration, expectedArguments ); + internalTest(compilerConfiguration, expectedArguments); } @Test - public void testReleaseVersion() - { + public void testReleaseVersion() { List expectedArguments = new ArrayList<>(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); // outputLocation - compilerConfiguration.setOutputLocation( "/output" ); - expectedArguments.add( "-d" ); - expectedArguments.add( new File( "/output" ).getAbsolutePath() ); + compilerConfiguration.setOutputLocation("/output"); + expectedArguments.add("-d"); + expectedArguments.add(new File("/output").getAbsolutePath()); // releaseVersion - compilerConfiguration.setReleaseVersion( "6" ); - expectedArguments.add( "--release" ); - expectedArguments.add( "6" ); + compilerConfiguration.setReleaseVersion("6"); + expectedArguments.add("--release"); + expectedArguments.add("6"); // unshared table - expectedArguments.add( "-XDuseUnsharedTable=true" ); + expectedArguments.add("-XDuseUnsharedTable=true"); - internalTest( compilerConfiguration, expectedArguments ); + internalTest(compilerConfiguration, expectedArguments); } @Test - public void testFailOnWarning() - { + public void testFailOnWarning() { List expectedArguments = new ArrayList<>(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); // outputLocation - compilerConfiguration.setOutputLocation( "/output" ); - expectedArguments.add( "-d" ); - expectedArguments.add( new File( "/output" ).getAbsolutePath() ); + compilerConfiguration.setOutputLocation("/output"); + expectedArguments.add("-d"); + expectedArguments.add(new File("/output").getAbsolutePath()); // failOnWarning - compilerConfiguration.setFailOnWarning( true ); - expectedArguments.add( "-Werror" ); - + compilerConfiguration.setFailOnWarning(true); + expectedArguments.add("-Werror"); + // default source + target - expectedArguments.add( "-target" ); - expectedArguments.add( "1.1" ); - expectedArguments.add( "-source" ); - expectedArguments.add( "1.3" ); + expectedArguments.add("-target"); + expectedArguments.add("1.1"); + expectedArguments.add("-source"); + expectedArguments.add("1.3"); // unshared table - expectedArguments.add( "-XDuseUnsharedTable=true" ); + expectedArguments.add("-XDuseUnsharedTable=true"); - internalTest( compilerConfiguration, expectedArguments ); + internalTest(compilerConfiguration, expectedArguments); } @Test - public void testMultipleAddExports() - { + public void testMultipleAddExports() { List expectedArguments = new ArrayList<>(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); // outputLocation - compilerConfiguration.setOutputLocation( "/output" ); - expectedArguments.add( "-d" ); - expectedArguments.add( new File( "/output" ).getAbsolutePath() ); + compilerConfiguration.setOutputLocation("/output"); + expectedArguments.add("-d"); + expectedArguments.add(new File("/output").getAbsolutePath()); // default source + target - expectedArguments.add( "-target" ); - expectedArguments.add( "1.1" ); - expectedArguments.add( "-source" ); - expectedArguments.add( "1.3" ); + expectedArguments.add("-target"); + expectedArguments.add("1.1"); + expectedArguments.add("-source"); + expectedArguments.add("1.3"); // add multiple --add-exports - compilerConfiguration.addCompilerCustomArgument( "--add-exports", "FROM-MOD/package1=OTHER-MOD" ); - expectedArguments.add( "--add-exports" ); - expectedArguments.add( "FROM-MOD/package1=OTHER-MOD" ); - compilerConfiguration.addCompilerCustomArgument( "--add-exports", "FROM-MOD/package2=OTHER-MOD" ); - expectedArguments.add( "--add-exports" ); - expectedArguments.add( "FROM-MOD/package2=OTHER-MOD" ); + compilerConfiguration.addCompilerCustomArgument("--add-exports", "FROM-MOD/package1=OTHER-MOD"); + expectedArguments.add("--add-exports"); + expectedArguments.add("FROM-MOD/package1=OTHER-MOD"); + compilerConfiguration.addCompilerCustomArgument("--add-exports", "FROM-MOD/package2=OTHER-MOD"); + expectedArguments.add("--add-exports"); + expectedArguments.add("FROM-MOD/package2=OTHER-MOD"); // unshared table - expectedArguments.add( "-XDuseUnsharedTable=true" ); + expectedArguments.add("-XDuseUnsharedTable=true"); - internalTest( compilerConfiguration, expectedArguments ); + internalTest(compilerConfiguration, expectedArguments); } /* This test fails on Java 1.4. The multiple parameters of the same source file cause an error, as it is interpreted as a DuplicateClass @@ -548,119 +539,116 @@ public void testCommandLineTooLongWhenForking() } */ - private void populateArguments( CompilerConfiguration compilerConfiguration, List expectedArguments, - boolean suppressSourceVersion, boolean suppressEncoding, boolean parameters ) - { + private void populateArguments( + CompilerConfiguration compilerConfiguration, + List expectedArguments, + boolean suppressSourceVersion, + boolean suppressEncoding, + boolean parameters) { // outputLocation - compilerConfiguration.setOutputLocation( "/output" ); + compilerConfiguration.setOutputLocation("/output"); - expectedArguments.add( "-d" ); + expectedArguments.add("-d"); - expectedArguments.add( new File( "/output" ).getAbsolutePath() ); + expectedArguments.add(new File("/output").getAbsolutePath()); // classpathEntires List classpathEntries = new ArrayList<>(); - classpathEntries.add( "/myjar1.jar" ); + classpathEntries.add("/myjar1.jar"); - classpathEntries.add( "/myjar2.jar" ); + classpathEntries.add("/myjar2.jar"); - compilerConfiguration.setClasspathEntries( classpathEntries ); + compilerConfiguration.setClasspathEntries(classpathEntries); - expectedArguments.add( "-classpath" ); + expectedArguments.add("-classpath"); - expectedArguments.add( "/myjar1.jar" + PS + "/myjar2.jar" + PS ); + expectedArguments.add("/myjar1.jar" + PS + "/myjar2.jar" + PS); // sourceRoots List compileSourceRoots = new ArrayList<>(); - compileSourceRoots.add( "/src/main/one" ); + compileSourceRoots.add("/src/main/one"); - compileSourceRoots.add( "/src/main/two" ); + compileSourceRoots.add("/src/main/two"); - compilerConfiguration.setSourceLocations( compileSourceRoots ); + compilerConfiguration.setSourceLocations(compileSourceRoots); - expectedArguments.add( "-sourcepath" ); + expectedArguments.add("-sourcepath"); - expectedArguments.add( "/src/main/one" + PS + "/src/main/two" + PS ); + expectedArguments.add("/src/main/one" + PS + "/src/main/two" + PS); // debug - compilerConfiguration.setDebug( true ); + compilerConfiguration.setDebug(true); - if ( StringUtils.isNotEmpty( compilerConfiguration.getDebugLevel() ) ) - { - expectedArguments.add( "-g:" + compilerConfiguration.getDebugLevel() ); - } - else - { - expectedArguments.add( "-g" ); + if (StringUtils.isNotEmpty(compilerConfiguration.getDebugLevel())) { + expectedArguments.add("-g:" + compilerConfiguration.getDebugLevel()); + } else { + expectedArguments.add("-g"); } // parameters - compilerConfiguration.setParameters( true ); + compilerConfiguration.setParameters(true); - if (parameters) - { - expectedArguments.add( "-parameters" ); + if (parameters) { + expectedArguments.add("-parameters"); } - + // showDeprecation - compilerConfiguration.setShowDeprecation( true ); + compilerConfiguration.setShowDeprecation(true); - expectedArguments.add( "-deprecation" ); + expectedArguments.add("-deprecation"); // targetVersion - compilerConfiguration.setTargetVersion( "1.3" ); + compilerConfiguration.setTargetVersion("1.3"); - expectedArguments.add( "-target" ); + expectedArguments.add("-target"); - expectedArguments.add( "1.3" ); + expectedArguments.add("1.3"); // sourceVersion - compilerConfiguration.setSourceVersion( "1.3" ); + compilerConfiguration.setSourceVersion("1.3"); - if ( !suppressSourceVersion ) - { - expectedArguments.add( "-source" ); + if (!suppressSourceVersion) { + expectedArguments.add("-source"); - expectedArguments.add( "1.3" ); + expectedArguments.add("1.3"); } // sourceEncoding - compilerConfiguration.setSourceEncoding( "iso-8859-1" ); + compilerConfiguration.setSourceEncoding("iso-8859-1"); - if ( !suppressEncoding ) - { - expectedArguments.add( "-encoding" ); + if (!suppressEncoding) { + expectedArguments.add("-encoding"); - expectedArguments.add( "iso-8859-1" ); + expectedArguments.add("iso-8859-1"); } // customerCompilerArguments Map customerCompilerArguments = new LinkedHashMap<>(); - customerCompilerArguments.put( "arg1", null ); + customerCompilerArguments.put("arg1", null); - customerCompilerArguments.put( "foo", "bar" ); + customerCompilerArguments.put("foo", "bar"); - compilerConfiguration.setCustomCompilerArgumentsAsMap( customerCompilerArguments ); + compilerConfiguration.setCustomCompilerArgumentsAsMap(customerCompilerArguments); - expectedArguments.add( "arg1" ); + expectedArguments.add("arg1"); - expectedArguments.add( "foo" ); + expectedArguments.add("foo"); - expectedArguments.add( "bar" ); + expectedArguments.add("bar"); - expectedArguments.add( "-XDuseUnsharedTable=true" ); + expectedArguments.add("-XDuseUnsharedTable=true"); } } diff --git a/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/ErrorMessageParserTest.java b/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/ErrorMessageParserTest.java index b54b4128..bfc416a4 100644 --- a/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/ErrorMessageParserTest.java +++ b/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/ErrorMessageParserTest.java @@ -23,7 +23,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; @@ -44,215 +43,204 @@ /** * @author Trygve Laugstøl */ -public class ErrorMessageParserTest -{ - private static final String EOL = System.getProperty( "line.separator" ); +public class ErrorMessageParserTest { + private static final String EOL = System.getProperty("line.separator"); @Test - public void testDeprecationMessage() - throws Exception - { + public void testDeprecationMessage() throws Exception { String error = - "target/compiler-src/testDeprecation/Foo.java:1: warning: Date(java.lang.String) in java.util.Date has been deprecated" - + EOL + - "import java.util.Date;public class Foo{ private Date date = new Date( \"foo\");}" + EOL + - " ^" + EOL; + "target/compiler-src/testDeprecation/Foo.java:1: warning: Date(java.lang.String) in java.util.Date has been deprecated" + + EOL + "import java.util.Date;public class Foo{ private Date date = new Date( \"foo\");}" + + EOL + " ^" + + EOL; - CompilerMessage compilerError = JavacCompiler.parseModernError( 0, error ); + CompilerMessage compilerError = JavacCompiler.parseModernError(0, error); - assertThat( compilerError, notNullValue() ); + assertThat(compilerError, notNullValue()); - assertThat( compilerError.isError(), is( false)); + assertThat(compilerError.isError(), is(false)); - assertThat( compilerError.getMessage(), is("Date(java.lang.String) in java.util.Date has been deprecated") ); + assertThat(compilerError.getMessage(), is("Date(java.lang.String) in java.util.Date has been deprecated")); - assertThat( compilerError.getStartColumn(), is( 63 ) ); + assertThat(compilerError.getStartColumn(), is(63)); - assertThat( compilerError.getEndColumn(), is( 66 ) ); + assertThat(compilerError.getEndColumn(), is(66)); - assertThat( compilerError.getStartLine(), is( 1 ) ); + assertThat(compilerError.getStartLine(), is(1)); - assertThat( compilerError.getEndLine(), is (1 ) ); + assertThat(compilerError.getEndLine(), is(1)); } @Test - public void testWarningMessage() - { - String error = - "target/compiler-src/testWarning/Foo.java:8: warning: finally clause cannot complete normally" + EOL + - " finally { return; }" + EOL + - " ^" + EOL; + public void testWarningMessage() { + String error = "target/compiler-src/testWarning/Foo.java:8: warning: finally clause cannot complete normally" + + EOL + " finally { return; }" + + EOL + " ^" + + EOL; - CompilerMessage compilerError = JavacCompiler.parseModernError( 0, error ); + CompilerMessage compilerError = JavacCompiler.parseModernError(0, error); - assertThat( compilerError, notNullValue() ); + assertThat(compilerError, notNullValue()); - assertThat( compilerError.isError(), is( false ) ); + assertThat(compilerError.isError(), is(false)); - assertThat( compilerError.getMessage(), is( "finally clause cannot complete normally" ) ); + assertThat(compilerError.getMessage(), is("finally clause cannot complete normally")); - assertThat( compilerError.getStartColumn(), is(26) ); + assertThat(compilerError.getStartColumn(), is(26)); - assertThat( compilerError.getEndColumn(), is(27) ); + assertThat(compilerError.getEndColumn(), is(27)); - assertThat( compilerError.getStartLine(), is(8) ); + assertThat(compilerError.getStartLine(), is(8)); - assertThat( compilerError.getEndLine(), is(8) ); + assertThat(compilerError.getEndLine(), is(8)); } @Test - public void testErrorMessage() - { - String error = "Foo.java:7: not a statement" + EOL + - " i;" + EOL + - " ^" + EOL; + public void testErrorMessage() { + String error = "Foo.java:7: not a statement" + EOL + " i;" + EOL + " ^" + EOL; - CompilerMessage compilerError = JavacCompiler.parseModernError( 1, error ); + CompilerMessage compilerError = JavacCompiler.parseModernError(1, error); - assertThat( compilerError, notNullValue() ); + assertThat(compilerError, notNullValue()); - assertThat( compilerError.isError(), is( true ) ); + assertThat(compilerError.isError(), is(true)); - assertThat( compilerError.getMessage(), is("not a statement") ); + assertThat(compilerError.getMessage(), is("not a statement")); - assertThat( compilerError.getStartColumn(), is(9) ); + assertThat(compilerError.getStartColumn(), is(9)); - assertThat( compilerError.getEndColumn(), is(11) ); + assertThat(compilerError.getEndColumn(), is(11)); - assertThat( compilerError.getStartLine(), is(7) ); + assertThat(compilerError.getStartLine(), is(7)); - assertThat( compilerError.getEndLine(), is(7) ); + assertThat(compilerError.getEndLine(), is(7)); } @Test - public void testUnknownSymbolError() - { - String error = "./org/codehaus/foo/UnknownSymbol.java:7: cannot find symbol" + EOL + - "symbol : method foo()" + EOL + - "location: class org.codehaus.foo.UnknownSymbol" + EOL + - " foo();" + EOL + - " ^" + EOL; + public void testUnknownSymbolError() { + String error = "./org/codehaus/foo/UnknownSymbol.java:7: cannot find symbol" + EOL + "symbol : method foo()" + + EOL + "location: class org.codehaus.foo.UnknownSymbol" + + EOL + " foo();" + + EOL + " ^" + + EOL; - CompilerMessage compilerError = JavacCompiler.parseModernError( 1, error ); + CompilerMessage compilerError = JavacCompiler.parseModernError(1, error); - assertThat( compilerError, notNullValue() ); + assertThat(compilerError, notNullValue()); - assertThat( compilerError.isError(), is( true ) ); + assertThat(compilerError.isError(), is(true)); - assertThat( compilerError.getMessage(), is("cannot find symbol" + EOL + - "symbol : method foo()" + EOL + - "location: class org.codehaus.foo.UnknownSymbol") ); + assertThat( + compilerError.getMessage(), + is("cannot find symbol" + EOL + "symbol : method foo()" + EOL + + "location: class org.codehaus.foo.UnknownSymbol")); - assertThat( compilerError.getStartColumn(), is(8) ); + assertThat(compilerError.getStartColumn(), is(8)); - assertThat( compilerError.getEndColumn(), is(14) ); + assertThat(compilerError.getEndColumn(), is(14)); - assertThat( compilerError.getStartLine(), is(7) ); + assertThat(compilerError.getStartLine(), is(7)); - assertThat( compilerError.getEndLine(), is(7) ); + assertThat(compilerError.getEndLine(), is(7)); } @Test - public void testTwoErrors() - throws IOException - { - String errors = "./org/codehaus/foo/ExternalDeps.java:4: package org.apache.commons.lang does not exist" + EOL + - "import org.apache.commons.lang.StringUtils;" + EOL + - " ^" + EOL + - "./org/codehaus/foo/ExternalDeps.java:12: cannot find symbol" + EOL + - "symbol : variable StringUtils" + EOL + - "location: class org.codehaus.foo.ExternalDeps" + EOL + - " System.out.println( StringUtils.upperCase( str) );" + EOL + - " ^" + EOL + - "2 errors" + EOL; + public void testTwoErrors() throws IOException { + String errors = "./org/codehaus/foo/ExternalDeps.java:4: package org.apache.commons.lang does not exist" + EOL + + "import org.apache.commons.lang.StringUtils;" + + EOL + " ^" + + EOL + "./org/codehaus/foo/ExternalDeps.java:12: cannot find symbol" + + EOL + "symbol : variable StringUtils" + + EOL + "location: class org.codehaus.foo.ExternalDeps" + + EOL + " System.out.println( StringUtils.upperCase( str) );" + + EOL + " ^" + + EOL + "2 errors" + + EOL; List messages = - JavacCompiler.parseModernStream( 1, new BufferedReader( new StringReader( errors ) ) ); + JavacCompiler.parseModernStream(1, new BufferedReader(new StringReader(errors))); - assertThat( messages.size(), is(2) ); + assertThat(messages.size(), is(2)); } @Test - public void testAnotherTwoErrors() - throws IOException - { - String errors = "./org/codehaus/foo/ExternalDeps.java:4: package org.apache.commons.lang does not exist" + EOL + - "import org.apache.commons.lang.StringUtils;" + EOL + - " ^" + EOL + - "./org/codehaus/foo/ExternalDeps.java:12: cannot find symbol" + EOL + - "symbol : variable StringUtils" + EOL + - "location: class org.codehaus.foo.ExternalDeps" + EOL + - " System.out.println( StringUtils.upperCase( str) );" + EOL + - " ^" + EOL + - "2 errors" + EOL; + public void testAnotherTwoErrors() throws IOException { + String errors = "./org/codehaus/foo/ExternalDeps.java:4: package org.apache.commons.lang does not exist" + EOL + + "import org.apache.commons.lang.StringUtils;" + + EOL + " ^" + + EOL + "./org/codehaus/foo/ExternalDeps.java:12: cannot find symbol" + + EOL + "symbol : variable StringUtils" + + EOL + "location: class org.codehaus.foo.ExternalDeps" + + EOL + " System.out.println( StringUtils.upperCase( str) );" + + EOL + " ^" + + EOL + "2 errors" + + EOL; List messages = - JavacCompiler.parseModernStream( 1, new BufferedReader( new StringReader( errors ) ) ); + JavacCompiler.parseModernStream(1, new BufferedReader(new StringReader(errors))); - assertThat( messages.size(), is(2) ); + assertThat(messages.size(), is(2)); } @Test - public void testAssertError() - throws IOException - { + public void testAssertError() throws IOException { String errors = - "./org/codehaus/foo/ReservedWord.java:5: as of release 1.4, 'assert' is a keyword, and may not be used as an identifier" - + EOL + - "(try -source 1.3 or lower to use 'assert' as an identifier)" + EOL + - " String assert;" + EOL + - " ^" + EOL + - "1 error" + EOL; + "./org/codehaus/foo/ReservedWord.java:5: as of release 1.4, 'assert' is a keyword, and may not be used as an identifier" + + EOL + "(try -source 1.3 or lower to use 'assert' as an identifier)" + + EOL + " String assert;" + + EOL + " ^" + + EOL + "1 error" + + EOL; List messages = - JavacCompiler.parseModernStream( 1, new BufferedReader( new StringReader( errors ) ) ); + JavacCompiler.parseModernStream(1, new BufferedReader(new StringReader(errors))); - assertThat( messages.size(), is(1) ); + assertThat(messages.size(), is(1)); } @Test - public void testLocalizedWarningNotTreatedAsError() - throws IOException - { + public void testLocalizedWarningNotTreatedAsError() throws IOException { String errors = - "./src/main/java/Main.java:9: \u8b66\u544a:[deprecation] java.io.File \u306e toURL() \u306f\u63a8\u5968\u3055\u308c\u307e\u305b\u3093\u3002" - + EOL + - " new File( path ).toURL()" + EOL + - " ^" + EOL + - "\u8b66\u544a 1 \u500b" + EOL; + "./src/main/java/Main.java:9: \u8b66\u544a:[deprecation] java.io.File \u306e toURL() \u306f\u63a8\u5968\u3055\u308c\u307e\u305b\u3093\u3002" + + EOL + " new File( path ).toURL()" + + EOL + " ^" + + EOL + "\u8b66\u544a 1 \u500b" + + EOL; List messages = - JavacCompiler.parseModernStream( 0, new BufferedReader( new StringReader( errors ) ) ); + JavacCompiler.parseModernStream(0, new BufferedReader(new StringReader(errors))); - assertThat( messages.size(), is(1) ); - assertThat( messages.get( 0 ).isError(), is(false) ); + assertThat(messages.size(), is(1)); + assertThat(messages.get(0).isError(), is(false)); } @Test - public void testUnixFileNames() - { - String error = "/my/prj/src/main/java/test/prj/App.java:11: not a statement" + EOL + - " System.out.println( \"Hello World!\" );x" + EOL + - " ^" + EOL; + public void testUnixFileNames() { + String error = "/my/prj/src/main/java/test/prj/App.java:11: not a statement" + EOL + + " System.out.println( \"Hello World!\" );x" + + EOL + " ^" + + EOL; - CompilerMessage compilerError = JavacCompiler.parseModernError( 1, error ); + CompilerMessage compilerError = JavacCompiler.parseModernError(1, error); - assertThat( String.valueOf( compilerError ), is("/my/prj/src/main/java/test/prj/App.java:[11,45] not a statement")); + assertThat( + String.valueOf(compilerError), is("/my/prj/src/main/java/test/prj/App.java:[11,45] not a statement")); } @Test - public void testWindowsDriveLettersMCOMPILER140() - { + public void testWindowsDriveLettersMCOMPILER140() { String error = - "c:\\Documents and Settings\\My Self\\Documents\\prj\\src\\main\\java\\test\\prj\\App.java:11: not a statement" - + EOL + - " System.out.println( \"Hello World!\" );x" + EOL + - " ^" + EOL; + "c:\\Documents and Settings\\My Self\\Documents\\prj\\src\\main\\java\\test\\prj\\App.java:11: not a statement" + + EOL + " System.out.println( \"Hello World!\" );x" + + EOL + " ^" + + EOL; - CompilerMessage compilerError = JavacCompiler.parseModernError( 1, error ); + CompilerMessage compilerError = JavacCompiler.parseModernError(1, error); - assertThat( String.valueOf( compilerError ), - is("c:\\Documents and Settings\\My Self\\Documents\\prj\\src\\main\\java\\test\\prj\\App.java:[11,45] not a statement") ); + assertThat( + String.valueOf(compilerError), + is( + "c:\\Documents and Settings\\My Self\\Documents\\prj\\src\\main\\java\\test\\prj\\App.java:[11,45] not a statement")); } /** @@ -261,738 +249,781 @@ public void testWindowsDriveLettersMCOMPILER140() * @throws Exception */ @Test - public void testCRLF_windows() - throws Exception - { + public void testCRLF_windows() throws Exception { // This test is only relevant on windows (test hardcodes EOL) - if ( !Os.isFamily( "windows" ) ) - { + if (!Os.isFamily("windows")) { return; } - String CRLF = new String( new byte[]{ (byte) 0x0D, (byte) 0x0A } ); - String errors = "warning: [options] bootstrap class path not set in conjunction with -source 1.6" + CRLF + - "[parsing started RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpServerImpl.java]]" - + CRLF + - "[parsing completed 19ms]" + CRLF + - "[parsing started RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpServer.java]]" - + CRLF + - "[parsing completed 1ms]" + CRLF + - "[parsing started RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpServerAware.java]]" - + CRLF + - "[parsing completed 1ms]" + CRLF + - "[parsing started RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpUtil.java]]" - + CRLF + - "[parsing completed 3ms]" + CRLF + - "[parsing started RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpThreadPool.java]]" - + CRLF + - "[parsing completed 3ms]" + CRLF + - "[parsing started RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpQueueAware.java]]" - + CRLF + - "[parsing completed 0ms]" + CRLF + - "[parsing started RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpThreadPoolAware.java]]" - + CRLF + - "[parsing completed 1ms]" + CRLF + - "[search path for source files: C:\\commander\\pre\\ec\\ec-http\\src\\main\\java]" + CRLF + - "[search path for class files: C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\resources.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\rt.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\sunrsasign.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\jsse.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\jce.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\charsets.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\jfr.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\classes,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\ext\\dnsns.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\ext\\localedata.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\ext\\sunec.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\ext\\sunjce_provider.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\ext\\sunmscapi.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\ext\\zipfs.jar,C:\\commander\\pre\\ec\\ec-http\\target\\classes,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-core\\1.0.0-SNAPSHOT\\ec-core-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-lock\\1.0.0-SNAPSHOT\\ec-lock-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-timer\\1.0.0-SNAPSHOT\\ec-timer-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\org\\apache\\commons\\commons-math\\2.2\\commons-math-2.2.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-validation\\1.0.0-SNAPSHOT\\ec-validation-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-xml\\1.0.0-SNAPSHOT\\ec-xml-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\commons-beanutils\\commons-beanutils\\1.8.3-PATCH1\\commons-beanutils-1.8.3-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\commons-collections\\commons-collections\\3.2.1\\commons-collections-3.2.1.jar,C:\\Users\\anders\\.m2\\repository\\dom4j\\dom4j\\1.6.1-PATCH1\\dom4j-1.6.1-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\javax\\validation\\validation-api\\1.0.0.GA\\validation-api-1.0.0.GA.jar,C:\\Users\\anders\\.m2\\repository\\org\\codehaus\\jackson\\jackson-core-asl\\1.9.7\\jackson-core-asl-1.9.7.jar,C:\\Users\\anders\\.m2\\repository\\org\\codehaus\\jackson\\jackson-mapper-asl\\1.9.7\\jackson-mapper-asl-1.9.7.jar,C:\\Users\\anders\\.m2\\repository\\org\\hibernate\\hibernate-core\\3.6.7-PATCH14\\hibernate-core-3.6.7-PATCH14.jar,C:\\Users\\anders\\.m2\\repository\\antlr\\antlr\\2.7.6\\antlr-2.7.6.jar,C:\\Users\\anders\\.m2\\repository\\org\\hibernate\\hibernate-commons-annotations\\3.2.0.Final\\hibernate-commons-annotations-3.2.0.Final.jar,C:\\Users\\anders\\.m2\\repository\\javax\\transaction\\jta\\1.1\\jta-1.1.jar,C:\\Users\\anders\\.m2\\repository\\org\\hibernate\\javax\\persistence\\hibernate-jpa-2.0-api\\1.0.1.Final\\hibernate-jpa-2.0-api-1.0.1.Final.jar,C:\\Users\\anders\\.m2\\repository\\org\\hyperic\\sigar\\1.6.5.132\\sigar-1.6.5.132.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-context\\3.1.1.RELEASE-PATCH1\\spring-context-3.1.1.RELEASE-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-expression\\3.1.1.RELEASE-PATCH1\\spring-expression-3.1.1.RELEASE-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-core\\3.1.1.RELEASE-PATCH1\\spring-core-3.1.1.RELEASE-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\tanukisoft\\wrapper\\3.5.14\\wrapper-3.5.14.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-log\\1.0.0-SNAPSHOT\\ec-log-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\ch\\qos\\logback\\logback-classic\\1.0.3-PATCH4\\logback-classic-1.0.3-PATCH4.jar,C:\\Users\\anders\\.m2\\repository\\ch\\qos\\logback\\logback-core\\1.0.3-PATCH4\\logback-core-1.0.3-PATCH4.jar,C:\\Users\\anders\\.m2\\repository\\org\\slf4j\\slf4j-api\\1.6.4\\slf4j-api-1.6.4.jar,C:\\Users\\anders\\.m2\\repository\\org\\slf4j\\jul-to-slf4j\\1.6.4\\jul-to-slf4j-1.6.4.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-queue\\1.0.0-SNAPSHOT\\ec-queue-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-security\\1.0.0-SNAPSHOT\\ec-security-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-acl\\1.0.0-SNAPSHOT\\ec-acl-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-transaction\\1.0.0-SNAPSHOT\\ec-transaction-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\org\\aspectj\\aspectjrt\\1.7.0.M1-PATCH1\\aspectjrt-1.7.0.M1-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-crypto\\1.0.0-SNAPSHOT\\ec-crypto-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\org\\bouncycastle\\bcprov-jdk16\\1.46\\bcprov-jdk16-1.46.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-property\\1.0.0-SNAPSHOT\\ec-property-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\org\\apache\\commons\\commons-lang3\\3.1\\commons-lang3-3.1.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-tx\\3.1.1.RELEASE-PATCH1\\spring-tx-3.1.1.RELEASE-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\org\\aopalliance\\com.springsource.org.aopalliance\\1.0.0\\com.springsource.org.aopalliance-1.0.0.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\ldap\\spring-ldap-core\\1.3.1.RELEASE\\spring-ldap-core-1.3.1.RELEASE.jar,C:\\Users\\anders\\.m2\\repository\\commons-lang\\commons-lang\\2.5\\commons-lang-2.5.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\security\\spring-security-core\\2.0.6.PATCH1\\spring-security-core-2.0.6.PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-util\\1.0.0-SNAPSHOT\\ec-util-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\cglib\\cglib-nodep\\2.2.2\\cglib-nodep-2.2.2.jar,C:\\Users\\anders\\.m2\\repository\\org\\apache\\commons\\commons-digester3\\3.2-PATCH5\\commons-digester3-3.2-PATCH5.jar,C:\\Users\\anders\\.m2\\repository\\cglib\\cglib\\2.2.2\\cglib-2.2.2.jar,C:\\Users\\anders\\.m2\\repository\\asm\\asm\\3.3.1\\asm-3.3.1.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-aop\\3.1.1.RELEASE-PATCH1\\spring-aop-3.1.1.RELEASE-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\com\\google\\guava\\guava\\12.0\\guava-12.0.jar,C:\\Users\\anders\\.m2\\repository\\com\\google\\code\\findbugs\\jsr305\\2.0.0\\jsr305-2.0.0.jar,C:\\Users\\anders\\.m2\\repository\\com\\intellij\\annotations\\116.108\\annotations-116.108.jar,C:\\Users\\anders\\.m2\\repository\\commons-io\\commons-io\\2.3\\commons-io-2.3.jar,C:\\Users\\anders\\.m2\\repository\\net\\jcip\\jcip-annotations\\1.0\\jcip-annotations-1.0.jar,C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar,C:\\Users\\anders\\.m2\\repository\\commons-codec\\commons-codec\\1.6\\commons-codec-1.6.jar,C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar,C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar,C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\orbit\\javax.servlet\\3.0.0.v201112011016\\javax.servlet-3.0.0.v201112011016.jar,C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-continuation\\8.1.4.v20120524\\jetty-continuation-8.1.4.v20120524.jar,C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-http\\8.1.4.v20120524\\jetty-http-8.1.4.v20120524.jar,C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-io\\8.1.4.v20120524\\jetty-io-8.1.4.v20120524.jar,C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-util\\8.1.4.v20120524\\jetty-util-8.1.4.v20120524.jar,C:\\Users\\anders\\.m2\\repository\\org\\mortbay\\jetty\\servlet-api\\3.0.20100224\\servlet-api-3.0.20100224.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-beans\\3.1.1.RELEASE-PATCH1\\spring-beans-3.1.1.RELEASE-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-asm\\3.1.1.RELEASE-PATCH1\\spring-asm-3.1.1.RELEASE-PATCH1.jar,.]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/net/BindException.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/ArrayList.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/Collection.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/Collections.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/HashSet.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/concurrent/TimeUnit.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/Handler.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/Server.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/nio/SelectChannelConnector.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/ssl/SslSelectChannelConnector.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-util\\8.1.4.v20120524\\jetty-util-8.1.4.v20120524.jar(org/eclipse/jetty/util/ssl/SslContextFactory.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\intellij\\annotations\\116.108\\annotations-116.108.jar(org/jetbrains/annotations/NonNls.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\intellij\\annotations\\116.108\\annotations-116.108.jar(org/jetbrains/annotations/NotNull.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\intellij\\annotations\\116.108\\annotations-116.108.jar(org/jetbrains/annotations/TestOnly.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-beans\\3.1.1.RELEASE-PATCH1\\spring-beans-3.1.1.RELEASE-PATCH1.jar(org/springframework/beans/factory/BeanNameAware.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-beans\\3.1.1.RELEASE-PATCH1\\spring-beans-3.1.1.RELEASE-PATCH1.jar(org/springframework/beans/factory/annotation/Autowired.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\google\\guava\\guava\\12.0\\guava-12.0.jar(com/google/common/collect/Iterables.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-log\\1.0.0-SNAPSHOT\\ec-log-1.0.0-SNAPSHOT.jar(com/electriccloud/log/Log.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-log\\1.0.0-SNAPSHOT\\ec-log-1.0.0-SNAPSHOT.jar(com/electriccloud/log/LogFactory.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-core\\1.0.0-SNAPSHOT\\ec-core-1.0.0-SNAPSHOT.jar(com/electriccloud/service/ServiceManager.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-core\\1.0.0-SNAPSHOT\\ec-core-1.0.0-SNAPSHOT.jar(com/electriccloud/service/ServiceState.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-util\\1.0.0-SNAPSHOT\\ec-util-1.0.0-SNAPSHOT.jar(com/electriccloud/util/ExceptionUtil.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-util\\1.0.0-SNAPSHOT\\ec-util-1.0.0-SNAPSHOT.jar(com/electriccloud/util/SystemUtil.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-util\\1.0.0-SNAPSHOT\\ec-util-1.0.0-SNAPSHOT.jar(com/electriccloud/util/ToString.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-util\\1.0.0-SNAPSHOT\\ec-util-1.0.0-SNAPSHOT.jar(com/electriccloud/util/ToStringSupport.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/String.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Object.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/io/Serializable.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Comparable.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/CharSequence.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Enum.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-util\\1.0.0-SNAPSHOT\\ec-util-1.0.0-SNAPSHOT.jar(com/electriccloud/util/ToStringAware.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-beans\\3.1.1.RELEASE-PATCH1\\spring-beans-3.1.1.RELEASE-PATCH1.jar(org/springframework/beans/factory/Aware.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-core\\1.0.0-SNAPSHOT\\ec-core-1.0.0-SNAPSHOT.jar(com/electriccloud/service/Service.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Integer.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/concurrent/RejectedExecutionException.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-util\\8.1.4.v20120524\\jetty-util-8.1.4.v20120524.jar(org/eclipse/jetty/util/component/AbstractLifeCycle.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-util\\8.1.4.v20120524\\jetty-util-8.1.4.v20120524.jar(org/eclipse/jetty/util/thread/ThreadPool.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-queue\\1.0.0-SNAPSHOT\\ec-queue-1.0.0-SNAPSHOT.jar(com/electriccloud/queue/ExecuteQueue.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-core\\1.0.0-SNAPSHOT\\ec-core-1.0.0-SNAPSHOT.jar(com/electriccloud/service/ServiceManagerAware.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-util\\1.0.0-SNAPSHOT\\ec-util-1.0.0-SNAPSHOT.jar(com/electriccloud/util/ToStringImpl.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-util\\8.1.4.v20120524\\jetty-util-8.1.4.v20120524.jar(org/eclipse/jetty/util/component/LifeCycle.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/InterruptedException.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Runnable.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Exception.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/io/IOException.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/security/KeyManagementException.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/security/NoSuchAlgorithmException.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/security/SecureRandom.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/javax/net/ssl/SSLContext.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/javax/net/ssl/TrustManager.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/HttpResponse.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/HttpClient.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/methods/HttpGet.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/methods/HttpPost.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/methods/HttpUriRequest.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/scheme/Scheme.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/ssl/SSLSocketFactory.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/entity/StringEntity.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/impl/client/DefaultConnectionKeepAliveStrategy.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/impl/client/DefaultHttpClient.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/impl/client/DefaultHttpRequestRetryHandler.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.class)]]" - + CRLF + - "C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpUtil.java:31: warning: [deprecation] ThreadSafeClientConnManager in org.apache.http.impl.conn.tsccm has been deprecated" - + CRLF + - "import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;" + CRLF + - " ^" + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/params/HttpParams.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/protocol/HttpContext.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/util/EntityUtils.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-security\\1.0.0-SNAPSHOT\\ec-security-1.0.0-SNAPSHOT.jar(com/electriccloud/security/DummyX509TrustManager.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/scheme/SchemeLayeredSocketFactory.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/scheme/SchemeSocketFactory.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/scheme/LayeredSchemeSocketFactory.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/scheme/LayeredSocketFactory.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/scheme/SocketFactory.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/params/CoreConnectionPNames.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/SuppressWarnings.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/annotation/Retention.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/annotation/RetentionPolicy.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/annotation/Target.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/annotation/ElementType.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\google\\guava\\guava\\12.0\\guava-12.0.jar(com/google/common/annotations/GwtCompatible.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\google\\guava\\guava\\12.0\\guava-12.0.jar(com/google/common/annotations/GwtIncompatible.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-core\\1.0.0-SNAPSHOT\\ec-core-1.0.0-SNAPSHOT.jar(com/electriccloud/infoset/InfosetType.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/annotation/Annotation.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Override.class)]]" - + CRLF + - "[checking com.electriccloud.http.HttpServerImpl]" + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Error.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Throwable.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/RuntimeException.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/AutoCloseable.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Class.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Number.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/AbstractList.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/AbstractCollection.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Iterable.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Byte.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Character.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Short.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/nio/AbstractNIOConnector.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/AbstractConnector.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-util\\8.1.4.v20120524\\jetty-util-8.1.4.v20120524.jar(org/eclipse/jetty/util/component/AggregateLifeCycle.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/Connector.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-util\\8.1.4.v20120524\\jetty-util-8.1.4.v20120524.jar(org/eclipse/jetty/util/component/Destroyable.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-util\\8.1.4.v20120524\\jetty-util-8.1.4.v20120524.jar(org/eclipse/jetty/util/component/Dumpable.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-http\\8.1.4.v20120524\\jetty-http-8.1.4.v20120524.jar(org/eclipse/jetty/http/HttpBuffers.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/handler/HandlerWrapper.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/handler/AbstractHandlerContainer.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/handler/AbstractHandler.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/net/SocketException.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Thread.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/IllegalStateException.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/AbstractSet.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/Iterator.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/IllegalArgumentException.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/Locale.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Long.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Float.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Double.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Boolean.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Void.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/AssertionError.class)]]" - + CRLF + - "[wrote RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\target\\classes\\com\\electriccloud\\http\\HttpServerImpl.class]]" - + CRLF + - "[checking com.electriccloud.http.HttpServer]" + CRLF + - "[wrote RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\target\\classes\\com\\electriccloud\\http\\HttpServer.class]]" - + CRLF + - "[checking com.electriccloud.http.HttpThreadPoolAware]" + CRLF + - "[wrote RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\target\\classes\\com\\electriccloud\\http\\HttpThreadPoolAware.class]]" - + CRLF + - "[checking com.electriccloud.http.HttpThreadPool]" + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/concurrent/Future.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/concurrent/Callable.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/Date.class)]]" - + CRLF + - "[wrote RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\target\\classes\\com\\electriccloud\\http\\HttpThreadPool.class]]" - + CRLF + - "[checking com.electriccloud.http.HttpQueueAware]" + CRLF + - "[wrote RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\target\\classes\\com\\electriccloud\\http\\HttpQueueAware.class]]" - + CRLF + - "[checking com.electriccloud.http.HttpServerAware]" + CRLF + - "[wrote RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\target\\classes\\com\\electriccloud\\http\\HttpServerAware.class]]" - + CRLF + - "[checking com.electriccloud.http.HttpUtil]" + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/net/URI.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/methods/HttpRequestBase.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/message/AbstractHttpMessage.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/HttpMessage.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/impl/client/AbstractHttpClient.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/annotation/GuardedBy.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/ResponseHandler.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/ClientProtocolException.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/HttpEntity.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/methods/HttpEntityEnclosingRequestBase.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/entity/AbstractHttpEntity.class)]]" - + CRLF + - "C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpUtil.java:151: warning: [deprecation] ThreadSafeClientConnManager in org.apache.http.impl.conn.tsccm has been deprecated" - + CRLF + - " ThreadSafeClientConnManager connectionManager =" + CRLF + - " ^" + CRLF + - "C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpUtil.java:152: warning: [deprecation] ThreadSafeClientConnManager in org.apache.http.impl.conn.tsccm has been deprecated" - + CRLF + - " new ThreadSafeClientConnManager();" + CRLF + - " ^" + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/security/GeneralSecurityException.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/javax/net/ssl/X509TrustManager.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/security/KeyException.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/ssl/X509HostnameVerifier.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/javax/net/ssl/SSLSocketFactory.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/scheme/HostNameResolver.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/javax/net/ssl/HostnameVerifier.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/ssl/TrustStrategy.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/security/KeyStore.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/scheme/SchemeRegistry.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/ClientConnectionManager.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/HttpRequestRetryHandler.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/ConnectionKeepAliveStrategy.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/ParseException.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/io/UnsupportedEncodingException.class)]]" - + CRLF + - "[wrote RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\target\\classes\\com\\electriccloud\\http\\HttpUtil$1.class]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/StringBuilder.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/AbstractStringBuilder.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/StringBuffer.class)]]" - + CRLF + - "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/javax/net/ssl/KeyManager.class)]]" - + CRLF + - "[wrote RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\target\\classes\\com\\electriccloud\\http\\HttpUtil.class]]" - + CRLF + - "[total 654ms]" + CRLF + - "4 warnings" + CRLF; + String CRLF = new String(new byte[] {(byte) 0x0D, (byte) 0x0A}); + String errors = "warning: [options] bootstrap class path not set in conjunction with -source 1.6" + CRLF + + "[parsing started RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpServerImpl.java]]" + + CRLF + "[parsing completed 19ms]" + + CRLF + + "[parsing started RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpServer.java]]" + + CRLF + "[parsing completed 1ms]" + + CRLF + + "[parsing started RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpServerAware.java]]" + + CRLF + "[parsing completed 1ms]" + + CRLF + + "[parsing started RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpUtil.java]]" + + CRLF + "[parsing completed 3ms]" + + CRLF + + "[parsing started RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpThreadPool.java]]" + + CRLF + "[parsing completed 3ms]" + + CRLF + + "[parsing started RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpQueueAware.java]]" + + CRLF + "[parsing completed 0ms]" + + CRLF + + "[parsing started RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpThreadPoolAware.java]]" + + CRLF + "[parsing completed 1ms]" + + CRLF + "[search path for source files: C:\\commander\\pre\\ec\\ec-http\\src\\main\\java]" + + CRLF + + "[search path for class files: C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\resources.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\rt.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\sunrsasign.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\jsse.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\jce.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\charsets.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\jfr.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\classes,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\ext\\dnsns.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\ext\\localedata.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\ext\\sunec.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\ext\\sunjce_provider.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\ext\\sunmscapi.jar,C:\\Program Files\\Java\\jdk1.7.0_04\\jre\\lib\\ext\\zipfs.jar,C:\\commander\\pre\\ec\\ec-http\\target\\classes,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-core\\1.0.0-SNAPSHOT\\ec-core-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-lock\\1.0.0-SNAPSHOT\\ec-lock-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-timer\\1.0.0-SNAPSHOT\\ec-timer-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\org\\apache\\commons\\commons-math\\2.2\\commons-math-2.2.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-validation\\1.0.0-SNAPSHOT\\ec-validation-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-xml\\1.0.0-SNAPSHOT\\ec-xml-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\commons-beanutils\\commons-beanutils\\1.8.3-PATCH1\\commons-beanutils-1.8.3-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\commons-collections\\commons-collections\\3.2.1\\commons-collections-3.2.1.jar,C:\\Users\\anders\\.m2\\repository\\dom4j\\dom4j\\1.6.1-PATCH1\\dom4j-1.6.1-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\javax\\validation\\validation-api\\1.0.0.GA\\validation-api-1.0.0.GA.jar,C:\\Users\\anders\\.m2\\repository\\org\\codehaus\\jackson\\jackson-core-asl\\1.9.7\\jackson-core-asl-1.9.7.jar,C:\\Users\\anders\\.m2\\repository\\org\\codehaus\\jackson\\jackson-mapper-asl\\1.9.7\\jackson-mapper-asl-1.9.7.jar,C:\\Users\\anders\\.m2\\repository\\org\\hibernate\\hibernate-core\\3.6.7-PATCH14\\hibernate-core-3.6.7-PATCH14.jar,C:\\Users\\anders\\.m2\\repository\\antlr\\antlr\\2.7.6\\antlr-2.7.6.jar,C:\\Users\\anders\\.m2\\repository\\org\\hibernate\\hibernate-commons-annotations\\3.2.0.Final\\hibernate-commons-annotations-3.2.0.Final.jar,C:\\Users\\anders\\.m2\\repository\\javax\\transaction\\jta\\1.1\\jta-1.1.jar,C:\\Users\\anders\\.m2\\repository\\org\\hibernate\\javax\\persistence\\hibernate-jpa-2.0-api\\1.0.1.Final\\hibernate-jpa-2.0-api-1.0.1.Final.jar,C:\\Users\\anders\\.m2\\repository\\org\\hyperic\\sigar\\1.6.5.132\\sigar-1.6.5.132.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-context\\3.1.1.RELEASE-PATCH1\\spring-context-3.1.1.RELEASE-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-expression\\3.1.1.RELEASE-PATCH1\\spring-expression-3.1.1.RELEASE-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-core\\3.1.1.RELEASE-PATCH1\\spring-core-3.1.1.RELEASE-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\tanukisoft\\wrapper\\3.5.14\\wrapper-3.5.14.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-log\\1.0.0-SNAPSHOT\\ec-log-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\ch\\qos\\logback\\logback-classic\\1.0.3-PATCH4\\logback-classic-1.0.3-PATCH4.jar,C:\\Users\\anders\\.m2\\repository\\ch\\qos\\logback\\logback-core\\1.0.3-PATCH4\\logback-core-1.0.3-PATCH4.jar,C:\\Users\\anders\\.m2\\repository\\org\\slf4j\\slf4j-api\\1.6.4\\slf4j-api-1.6.4.jar,C:\\Users\\anders\\.m2\\repository\\org\\slf4j\\jul-to-slf4j\\1.6.4\\jul-to-slf4j-1.6.4.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-queue\\1.0.0-SNAPSHOT\\ec-queue-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-security\\1.0.0-SNAPSHOT\\ec-security-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-acl\\1.0.0-SNAPSHOT\\ec-acl-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-transaction\\1.0.0-SNAPSHOT\\ec-transaction-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\org\\aspectj\\aspectjrt\\1.7.0.M1-PATCH1\\aspectjrt-1.7.0.M1-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-crypto\\1.0.0-SNAPSHOT\\ec-crypto-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\org\\bouncycastle\\bcprov-jdk16\\1.46\\bcprov-jdk16-1.46.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-property\\1.0.0-SNAPSHOT\\ec-property-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\org\\apache\\commons\\commons-lang3\\3.1\\commons-lang3-3.1.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-tx\\3.1.1.RELEASE-PATCH1\\spring-tx-3.1.1.RELEASE-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\org\\aopalliance\\com.springsource.org.aopalliance\\1.0.0\\com.springsource.org.aopalliance-1.0.0.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\ldap\\spring-ldap-core\\1.3.1.RELEASE\\spring-ldap-core-1.3.1.RELEASE.jar,C:\\Users\\anders\\.m2\\repository\\commons-lang\\commons-lang\\2.5\\commons-lang-2.5.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\security\\spring-security-core\\2.0.6.PATCH1\\spring-security-core-2.0.6.PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-util\\1.0.0-SNAPSHOT\\ec-util-1.0.0-SNAPSHOT.jar,C:\\Users\\anders\\.m2\\repository\\cglib\\cglib-nodep\\2.2.2\\cglib-nodep-2.2.2.jar,C:\\Users\\anders\\.m2\\repository\\org\\apache\\commons\\commons-digester3\\3.2-PATCH5\\commons-digester3-3.2-PATCH5.jar,C:\\Users\\anders\\.m2\\repository\\cglib\\cglib\\2.2.2\\cglib-2.2.2.jar,C:\\Users\\anders\\.m2\\repository\\asm\\asm\\3.3.1\\asm-3.3.1.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-aop\\3.1.1.RELEASE-PATCH1\\spring-aop-3.1.1.RELEASE-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\com\\google\\guava\\guava\\12.0\\guava-12.0.jar,C:\\Users\\anders\\.m2\\repository\\com\\google\\code\\findbugs\\jsr305\\2.0.0\\jsr305-2.0.0.jar,C:\\Users\\anders\\.m2\\repository\\com\\intellij\\annotations\\116.108\\annotations-116.108.jar,C:\\Users\\anders\\.m2\\repository\\commons-io\\commons-io\\2.3\\commons-io-2.3.jar,C:\\Users\\anders\\.m2\\repository\\net\\jcip\\jcip-annotations\\1.0\\jcip-annotations-1.0.jar,C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar,C:\\Users\\anders\\.m2\\repository\\commons-codec\\commons-codec\\1.6\\commons-codec-1.6.jar,C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar,C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar,C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\orbit\\javax.servlet\\3.0.0.v201112011016\\javax.servlet-3.0.0.v201112011016.jar,C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-continuation\\8.1.4.v20120524\\jetty-continuation-8.1.4.v20120524.jar,C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-http\\8.1.4.v20120524\\jetty-http-8.1.4.v20120524.jar,C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-io\\8.1.4.v20120524\\jetty-io-8.1.4.v20120524.jar,C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-util\\8.1.4.v20120524\\jetty-util-8.1.4.v20120524.jar,C:\\Users\\anders\\.m2\\repository\\org\\mortbay\\jetty\\servlet-api\\3.0.20100224\\servlet-api-3.0.20100224.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-beans\\3.1.1.RELEASE-PATCH1\\spring-beans-3.1.1.RELEASE-PATCH1.jar,C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-asm\\3.1.1.RELEASE-PATCH1\\spring-asm-3.1.1.RELEASE-PATCH1.jar,.]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/net/BindException.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/ArrayList.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/Collection.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/Collections.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/HashSet.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/concurrent/TimeUnit.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/Handler.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/Server.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/nio/SelectChannelConnector.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/ssl/SslSelectChannelConnector.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-util\\8.1.4.v20120524\\jetty-util-8.1.4.v20120524.jar(org/eclipse/jetty/util/ssl/SslContextFactory.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\intellij\\annotations\\116.108\\annotations-116.108.jar(org/jetbrains/annotations/NonNls.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\intellij\\annotations\\116.108\\annotations-116.108.jar(org/jetbrains/annotations/NotNull.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\intellij\\annotations\\116.108\\annotations-116.108.jar(org/jetbrains/annotations/TestOnly.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-beans\\3.1.1.RELEASE-PATCH1\\spring-beans-3.1.1.RELEASE-PATCH1.jar(org/springframework/beans/factory/BeanNameAware.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-beans\\3.1.1.RELEASE-PATCH1\\spring-beans-3.1.1.RELEASE-PATCH1.jar(org/springframework/beans/factory/annotation/Autowired.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\google\\guava\\guava\\12.0\\guava-12.0.jar(com/google/common/collect/Iterables.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-log\\1.0.0-SNAPSHOT\\ec-log-1.0.0-SNAPSHOT.jar(com/electriccloud/log/Log.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-log\\1.0.0-SNAPSHOT\\ec-log-1.0.0-SNAPSHOT.jar(com/electriccloud/log/LogFactory.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-core\\1.0.0-SNAPSHOT\\ec-core-1.0.0-SNAPSHOT.jar(com/electriccloud/service/ServiceManager.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-core\\1.0.0-SNAPSHOT\\ec-core-1.0.0-SNAPSHOT.jar(com/electriccloud/service/ServiceState.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-util\\1.0.0-SNAPSHOT\\ec-util-1.0.0-SNAPSHOT.jar(com/electriccloud/util/ExceptionUtil.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-util\\1.0.0-SNAPSHOT\\ec-util-1.0.0-SNAPSHOT.jar(com/electriccloud/util/SystemUtil.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-util\\1.0.0-SNAPSHOT\\ec-util-1.0.0-SNAPSHOT.jar(com/electriccloud/util/ToString.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-util\\1.0.0-SNAPSHOT\\ec-util-1.0.0-SNAPSHOT.jar(com/electriccloud/util/ToStringSupport.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/String.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Object.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/io/Serializable.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Comparable.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/CharSequence.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Enum.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-util\\1.0.0-SNAPSHOT\\ec-util-1.0.0-SNAPSHOT.jar(com/electriccloud/util/ToStringAware.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\springframework\\spring-beans\\3.1.1.RELEASE-PATCH1\\spring-beans-3.1.1.RELEASE-PATCH1.jar(org/springframework/beans/factory/Aware.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-core\\1.0.0-SNAPSHOT\\ec-core-1.0.0-SNAPSHOT.jar(com/electriccloud/service/Service.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Integer.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/concurrent/RejectedExecutionException.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-util\\8.1.4.v20120524\\jetty-util-8.1.4.v20120524.jar(org/eclipse/jetty/util/component/AbstractLifeCycle.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-util\\8.1.4.v20120524\\jetty-util-8.1.4.v20120524.jar(org/eclipse/jetty/util/thread/ThreadPool.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-queue\\1.0.0-SNAPSHOT\\ec-queue-1.0.0-SNAPSHOT.jar(com/electriccloud/queue/ExecuteQueue.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-core\\1.0.0-SNAPSHOT\\ec-core-1.0.0-SNAPSHOT.jar(com/electriccloud/service/ServiceManagerAware.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-util\\1.0.0-SNAPSHOT\\ec-util-1.0.0-SNAPSHOT.jar(com/electriccloud/util/ToStringImpl.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-util\\8.1.4.v20120524\\jetty-util-8.1.4.v20120524.jar(org/eclipse/jetty/util/component/LifeCycle.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/InterruptedException.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Runnable.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Exception.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/io/IOException.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/security/KeyManagementException.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/security/NoSuchAlgorithmException.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/security/SecureRandom.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/javax/net/ssl/SSLContext.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/javax/net/ssl/TrustManager.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/HttpResponse.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/HttpClient.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/methods/HttpGet.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/methods/HttpPost.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/methods/HttpUriRequest.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/scheme/Scheme.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/ssl/SSLSocketFactory.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/entity/StringEntity.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/impl/client/DefaultConnectionKeepAliveStrategy.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/impl/client/DefaultHttpClient.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/impl/client/DefaultHttpRequestRetryHandler.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.class)]]" + + CRLF + + "C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpUtil.java:31: warning: [deprecation] ThreadSafeClientConnManager in org.apache.http.impl.conn.tsccm has been deprecated" + + CRLF + "import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;" + + CRLF + " ^" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/params/HttpParams.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/protocol/HttpContext.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/util/EntityUtils.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-security\\1.0.0-SNAPSHOT\\ec-security-1.0.0-SNAPSHOT.jar(com/electriccloud/security/DummyX509TrustManager.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/scheme/SchemeLayeredSocketFactory.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/scheme/SchemeSocketFactory.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/scheme/LayeredSchemeSocketFactory.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/scheme/LayeredSocketFactory.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/scheme/SocketFactory.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/params/CoreConnectionPNames.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/SuppressWarnings.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/annotation/Retention.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/annotation/RetentionPolicy.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/annotation/Target.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/annotation/ElementType.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\google\\guava\\guava\\12.0\\guava-12.0.jar(com/google/common/annotations/GwtCompatible.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\google\\guava\\guava\\12.0\\guava-12.0.jar(com/google/common/annotations/GwtIncompatible.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\com\\electriccloud\\ec-core\\1.0.0-SNAPSHOT\\ec-core-1.0.0-SNAPSHOT.jar(com/electriccloud/infoset/InfosetType.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/annotation/Annotation.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Override.class)]]" + + CRLF + "[checking com.electriccloud.http.HttpServerImpl]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Error.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Throwable.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/RuntimeException.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/AutoCloseable.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Class.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Number.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/AbstractList.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/AbstractCollection.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Iterable.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Byte.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Character.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Short.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/nio/AbstractNIOConnector.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/AbstractConnector.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-util\\8.1.4.v20120524\\jetty-util-8.1.4.v20120524.jar(org/eclipse/jetty/util/component/AggregateLifeCycle.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/Connector.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-util\\8.1.4.v20120524\\jetty-util-8.1.4.v20120524.jar(org/eclipse/jetty/util/component/Destroyable.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-util\\8.1.4.v20120524\\jetty-util-8.1.4.v20120524.jar(org/eclipse/jetty/util/component/Dumpable.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-http\\8.1.4.v20120524\\jetty-http-8.1.4.v20120524.jar(org/eclipse/jetty/http/HttpBuffers.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/handler/HandlerWrapper.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/handler/AbstractHandlerContainer.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\eclipse\\jetty\\jetty-server\\8.1.4.v20120524\\jetty-server-8.1.4.v20120524.jar(org/eclipse/jetty/server/handler/AbstractHandler.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/net/SocketException.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Thread.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/IllegalStateException.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/AbstractSet.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/Iterator.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/IllegalArgumentException.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/Locale.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Long.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Float.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Double.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Boolean.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/Void.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/AssertionError.class)]]" + + CRLF + + "[wrote RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\target\\classes\\com\\electriccloud\\http\\HttpServerImpl.class]]" + + CRLF + "[checking com.electriccloud.http.HttpServer]" + + CRLF + + "[wrote RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\target\\classes\\com\\electriccloud\\http\\HttpServer.class]]" + + CRLF + "[checking com.electriccloud.http.HttpThreadPoolAware]" + + CRLF + + "[wrote RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\target\\classes\\com\\electriccloud\\http\\HttpThreadPoolAware.class]]" + + CRLF + "[checking com.electriccloud.http.HttpThreadPool]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/concurrent/Future.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/concurrent/Callable.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/util/Date.class)]]" + + CRLF + + "[wrote RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\target\\classes\\com\\electriccloud\\http\\HttpThreadPool.class]]" + + CRLF + "[checking com.electriccloud.http.HttpQueueAware]" + + CRLF + + "[wrote RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\target\\classes\\com\\electriccloud\\http\\HttpQueueAware.class]]" + + CRLF + "[checking com.electriccloud.http.HttpServerAware]" + + CRLF + + "[wrote RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\target\\classes\\com\\electriccloud\\http\\HttpServerAware.class]]" + + CRLF + "[checking com.electriccloud.http.HttpUtil]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/net/URI.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/methods/HttpRequestBase.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/message/AbstractHttpMessage.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/HttpMessage.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/impl/client/AbstractHttpClient.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/annotation/GuardedBy.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/ResponseHandler.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/ClientProtocolException.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/HttpEntity.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/methods/HttpEntityEnclosingRequestBase.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/entity/AbstractHttpEntity.class)]]" + + CRLF + + "C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpUtil.java:151: warning: [deprecation] ThreadSafeClientConnManager in org.apache.http.impl.conn.tsccm has been deprecated" + + CRLF + " ThreadSafeClientConnManager connectionManager =" + + CRLF + " ^" + + CRLF + + "C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpUtil.java:152: warning: [deprecation] ThreadSafeClientConnManager in org.apache.http.impl.conn.tsccm has been deprecated" + + CRLF + " new ThreadSafeClientConnManager();" + + CRLF + " ^" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/security/GeneralSecurityException.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/javax/net/ssl/X509TrustManager.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/security/KeyException.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/ssl/X509HostnameVerifier.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/javax/net/ssl/SSLSocketFactory.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/scheme/HostNameResolver.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/javax/net/ssl/HostnameVerifier.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/ssl/TrustStrategy.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/security/KeyStore.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/scheme/SchemeRegistry.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/ClientConnectionManager.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/client/HttpRequestRetryHandler.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpclient\\4.2\\httpclient-4.2.jar(org/apache/http/conn/ConnectionKeepAliveStrategy.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Users\\anders\\.m2\\repository\\org\\apache\\httpcomponents\\httpcore\\4.2\\httpcore-4.2.jar(org/apache/http/ParseException.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/io/UnsupportedEncodingException.class)]]" + + CRLF + + "[wrote RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\target\\classes\\com\\electriccloud\\http\\HttpUtil$1.class]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/StringBuilder.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/AbstractStringBuilder.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/java/lang/StringBuffer.class)]]" + + CRLF + + "[loading ZipFileIndexFileObject[C:\\Program Files\\Java\\jdk1.7.0_04\\lib\\ct.sym(META-INF/sym/rt.jar/javax/net/ssl/KeyManager.class)]]" + + CRLF + + "[wrote RegularFileObject[C:\\commander\\pre\\ec\\ec-http\\target\\classes\\com\\electriccloud\\http\\HttpUtil.class]]" + + CRLF + "[total 654ms]" + + CRLF + "4 warnings" + + CRLF; List compilerMessages = - JavacCompiler.parseModernStream( 0, new BufferedReader( new StringReader( errors ) ) ); - assertThat( "count", compilerMessages.size(), is(187) ); - List compilerErrors = new ArrayList<>( 3 ); - for ( CompilerMessage message : compilerMessages ) { - if ( message.getKind() != CompilerMessage.Kind.OTHER ) { - compilerErrors.add( message ); + JavacCompiler.parseModernStream(0, new BufferedReader(new StringReader(errors))); + assertThat("count", compilerMessages.size(), is(187)); + List compilerErrors = new ArrayList<>(3); + for (CompilerMessage message : compilerMessages) { + if (message.getKind() != CompilerMessage.Kind.OTHER) { + compilerErrors.add(message); } } - assertEquivalent(new CompilerMessage("[options] bootstrap class path not set in conjunction with -source " + - "1.6", CompilerMessage.Kind.WARNING), compilerErrors.get(0)); - CompilerMessage error1 = compilerErrors.get( 1 ); - assertThat( "file", - error1.getFile(), - is ("C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpUtil.java")); - assertThat( "message", - error1.getMessage(), + assertEquivalent( + new CompilerMessage( + "[options] bootstrap class path not set in conjunction with -source " + "1.6", + CompilerMessage.Kind.WARNING), + compilerErrors.get(0)); + CompilerMessage error1 = compilerErrors.get(1); + assertThat( + "file", + error1.getFile(), + is("C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpUtil.java")); + assertThat( + "message", + error1.getMessage(), is("[deprecation] ThreadSafeClientConnManager in org.apache.http.impl.conn.tsccm has been deprecated")); - assertThat( "line", error1.getStartLine(), is(31) ); - assertThat( "column", error1.getStartColumn(), is(38) ); - CompilerMessage error2 = compilerErrors.get( 2 ); - assertThat( "file", - error2.getFile(), - is("C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpUtil.java")); - assertThat( "message", - error2.getMessage(), - is("[deprecation] ThreadSafeClientConnManager in org.apache.http.impl.conn.tsccm has been deprecated")); - assertThat( "line", error2.getStartLine(), is(151) ); - assertThat( "column", error2.getStartColumn() , is(8)); - CompilerMessage error3 = compilerErrors.get( 3 ); - assertThat( "file", - error3.getFile(), - is("C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpUtil.java")); - assertThat( "message", - error3.getMessage(), + assertThat("line", error1.getStartLine(), is(31)); + assertThat("column", error1.getStartColumn(), is(38)); + CompilerMessage error2 = compilerErrors.get(2); + assertThat( + "file", + error2.getFile(), + is("C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpUtil.java")); + assertThat( + "message", + error2.getMessage(), is("[deprecation] ThreadSafeClientConnManager in org.apache.http.impl.conn.tsccm has been deprecated")); - assertThat( "line", error3.getStartLine(), is(152) ); - assertThat( "column", error3.getStartColumn(), is(16) ); + assertThat("line", error2.getStartLine(), is(151)); + assertThat("column", error2.getStartColumn(), is(8)); + CompilerMessage error3 = compilerErrors.get(3); + assertThat( + "file", + error3.getFile(), + is("C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpUtil.java")); + assertThat( + "message", + error3.getMessage(), + is("[deprecation] ThreadSafeClientConnManager in org.apache.http.impl.conn.tsccm has been deprecated")); + assertThat("line", error3.getStartLine(), is(152)); + assertThat("column", error3.getStartColumn(), is(16)); } @Test - public void testJava6Error() throws Exception - { - String out = "Error.java:3: cannot find symbol" + EOL + - "symbol : class Properties" + EOL + - "location: class Error" + EOL + - " Properties p = new Properties();" + EOL + - " ^" + EOL + - "Error.java:3: cannot find symbol" + EOL + - "symbol : class Properties" + EOL + - "location: class Error" + EOL + - " Properties p = new Properties();" + EOL + - " ^" + EOL + - "2 errors"; + public void testJava6Error() throws Exception { + String out = "Error.java:3: cannot find symbol" + EOL + "symbol : class Properties" + + EOL + "location: class Error" + + EOL + " Properties p = new Properties();" + + EOL + " ^" + + EOL + "Error.java:3: cannot find symbol" + + EOL + "symbol : class Properties" + + EOL + "location: class Error" + + EOL + " Properties p = new Properties();" + + EOL + " ^" + + EOL + "2 errors"; + + List compilerErrors = + JavacCompiler.parseModernStream(1, new BufferedReader(new StringReader(out))); - List compilerErrors = JavacCompiler.parseModernStream( 1, new BufferedReader( new StringReader( out ) )); + assertThat(compilerErrors, notNullValue()); - assertThat( compilerErrors, notNullValue() ); + CompilerMessage message1 = compilerErrors.get(0); - CompilerMessage message1 = compilerErrors.get( 0 ); + assertThat(message1.isError(), is(true)); - assertThat( message1.isError(), is(true) ); + assertThat( + message1.getMessage(), + is("cannot find symbol" + EOL + "symbol : class Properties" + EOL + "location: class Error")); - assertThat( message1.getMessage(), is ("cannot find symbol" + EOL + - "symbol : class Properties" + EOL + - "location: class Error") ); + assertThat(message1.getStartColumn(), is(16)); - assertThat( message1.getStartColumn(), is(16) ); + assertThat(message1.getEndColumn(), is(26)); - assertThat( message1.getEndColumn(), is(26) ); + assertThat(message1.getStartLine(), is(3)); - assertThat( message1.getStartLine(), is(3) ); + assertThat(message1.getEndLine(), is(3)); - assertThat( message1.getEndLine(), is(3) ); - - CompilerMessage message2 = compilerErrors.get( 1 ); + CompilerMessage message2 = compilerErrors.get(1); - assertThat( message2.isError(), is(true) ); + assertThat(message2.isError(), is(true)); - assertThat( message2.getMessage(), is("cannot find symbol" + EOL + - "symbol : class Properties" + EOL + - "location: class Error") ); + assertThat( + message2.getMessage(), + is("cannot find symbol" + EOL + "symbol : class Properties" + EOL + "location: class Error")); - assertThat( message2.getStartColumn(), is(35) ); + assertThat(message2.getStartColumn(), is(35)); - assertThat( message2.getEndColumn(), is(48) ); + assertThat(message2.getEndColumn(), is(48)); - assertThat( message2.getStartLine(), is(3) ); + assertThat(message2.getStartLine(), is(3)); - assertThat( message2.getEndLine(), is(3) ); + assertThat(message2.getEndLine(), is(3)); } @Test - public void testJava7Error() throws Exception - { - String out = "Error.java:3: error: cannot find symbol" + EOL + - " Properties p = new Properties();" + EOL + - " ^" + EOL + - " symbol: class Properties" + EOL + - " location: class Error" + EOL + - "Error.java:3: error: cannot find symbol" + EOL + - " Properties p = new Properties();" + EOL + - " ^" + EOL + - " symbol: class Properties" + EOL + - " location: class Error" + EOL + - "2 errors"; - - List compilerErrors = JavacCompiler.parseModernStream( 1, new BufferedReader( new StringReader( out ) )); - - assertThat( compilerErrors, notNullValue() ); - - CompilerMessage message1 = compilerErrors.get( 0 ); - - assertThat( message1.isError(), is(true) ); - - assertThat( message1.getMessage(), is("error: cannot find symbol" + EOL + - " symbol: class Properties" + EOL + - " location: class Error") ); - - assertThat( message1.getStartColumn(), is(16) ); - - assertThat( message1.getEndColumn(), is(26) ); - - assertThat( message1.getStartLine(), is(3) ); - - assertThat( message1.getEndLine(), is(3) ); - - CompilerMessage message2 = compilerErrors.get( 1 ); - - assertThat( message2.isError(), is(true) ); - - assertThat( message2.getMessage(), is("error: cannot find symbol" + EOL + - " symbol: class Properties" + EOL + - " location: class Error") ); - - assertThat( message2.getStartColumn(), is(35) ); - - assertThat( message2.getEndColumn(), is(48) ); - - assertThat( message2.getStartLine(), is(3) ); - - assertThat( message2.getEndLine(), is(3) ); + public void testJava7Error() throws Exception { + String out = + "Error.java:3: error: cannot find symbol" + EOL + " Properties p = new Properties();" + + EOL + " ^" + + EOL + " symbol: class Properties" + + EOL + " location: class Error" + + EOL + "Error.java:3: error: cannot find symbol" + + EOL + " Properties p = new Properties();" + + EOL + " ^" + + EOL + " symbol: class Properties" + + EOL + " location: class Error" + + EOL + "2 errors"; + + List compilerErrors = + JavacCompiler.parseModernStream(1, new BufferedReader(new StringReader(out))); + + assertThat(compilerErrors, notNullValue()); + + CompilerMessage message1 = compilerErrors.get(0); + + assertThat(message1.isError(), is(true)); + + assertThat( + message1.getMessage(), + is("error: cannot find symbol" + EOL + " symbol: class Properties" + EOL + + " location: class Error")); + + assertThat(message1.getStartColumn(), is(16)); + + assertThat(message1.getEndColumn(), is(26)); + + assertThat(message1.getStartLine(), is(3)); + + assertThat(message1.getEndLine(), is(3)); + + CompilerMessage message2 = compilerErrors.get(1); + + assertThat(message2.isError(), is(true)); + + assertThat( + message2.getMessage(), + is("error: cannot find symbol" + EOL + " symbol: class Properties" + EOL + + " location: class Error")); + + assertThat(message2.getStartColumn(), is(35)); + + assertThat(message2.getEndColumn(), is(48)); + + assertThat(message2.getStartLine(), is(3)); + + assertThat(message2.getEndLine(), is(3)); } @Test - public void testBugParade() throws Exception - { + public void testBugParade() throws Exception { String out = "An exception has occurred in the compiler (1.7.0_80). " - + "Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. " - + "Include your program and the following diagnostic in your report. Thank you." + EOL + - "com.sun.tools.javac.code.Symbol$CompletionFailure: class file for java.util.Optional not found"; - - List compilerErrors = JavacCompiler.parseModernStream( 4, new BufferedReader( new StringReader( out ) )); - - assertThat( compilerErrors, notNullValue() ); - - assertThat( compilerErrors.size(), is(1) ); + + "Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. " + + "Include your program and the following diagnostic in your report. Thank you." + EOL + + "com.sun.tools.javac.code.Symbol$CompletionFailure: class file for java.util.Optional not found"; + + List compilerErrors = + JavacCompiler.parseModernStream(4, new BufferedReader(new StringReader(out))); + + assertThat(compilerErrors, notNullValue()); + + assertThat(compilerErrors.size(), is(1)); } @Test public void testNonAnchoredWarning() throws IOException { - final String error = - "warning: [options] bootstrap class path not set in conjunction with -source 1.6" + EOL + - "1 warning" + EOL; + final String error = "warning: [options] bootstrap class path not set in conjunction with -source 1.6" + EOL + + "1 warning" + EOL; - final List compilerErrors = JavacCompiler.parseModernStream(0, new BufferedReader(new - StringReader( - error))); + final List compilerErrors = + JavacCompiler.parseModernStream(0, new BufferedReader(new StringReader(error))); assertThat(compilerErrors, notNullValue()); assertThat(compilerErrors.size(), is(1)); assertEquivalent( - new CompilerMessage( - "[options] bootstrap class path not set in conjunction with -source 1.6", CompilerMessage.Kind.WARNING), - compilerErrors.get(0)); + new CompilerMessage( + "[options] bootstrap class path not set in conjunction with -source 1.6", + CompilerMessage.Kind.WARNING), + compilerErrors.get(0)); } @Test public void testAnchoredWarning() throws IOException { - final String error = - "C:\\repo\\src\\it\\includes-output-when-compiler-forked\\src\\main" + - "\\java\\MyClass.java:23: warning: [divzero] division by zero" + EOL + - " System.out.println(1/0);" + EOL + - " ^" + EOL + - "1 warnings" + EOL; + final String error = "C:\\repo\\src\\it\\includes-output-when-compiler-forked\\src\\main" + + "\\java\\MyClass.java:23: warning: [divzero] division by zero" + + EOL + " System.out.println(1/0);" + + EOL + " ^" + + EOL + "1 warnings" + + EOL; final List compilerErrors = - JavacCompiler.parseModernStream(0, new BufferedReader(new StringReader(error))); + JavacCompiler.parseModernStream(0, new BufferedReader(new StringReader(error))); assertThat(compilerErrors, notNullValue()); assertThat(compilerErrors.size(), is(1)); assertEquivalent( - new CompilerMessage("C:\\repo\\src\\it\\includes-output-when-compiler-forked\\src\\main\\java\\MyClass" + - ".java", CompilerMessage.Kind.WARNING, 23, 27, 23, 30, "[divzero] division by zero"), - compilerErrors.get(0)); + new CompilerMessage( + "C:\\repo\\src\\it\\includes-output-when-compiler-forked\\src\\main\\java\\MyClass" + ".java", + CompilerMessage.Kind.WARNING, + 23, + 27, + 23, + 30, + "[divzero] division by zero"), + compilerErrors.get(0)); } @Test public void testMixedWarnings() throws IOException { - final String error = - "warning: [options] bootstrap class path not set in conjunction with -source 1.6" + EOL + - "C:\\repo\\src\\it\\includes-output-when-compiler-forked\\src\\main\\java" + - "\\MyClass.java:23: warning: [divzero] division by zero" + EOL + - " System.out.println(1/0);" + EOL + - " ^" + EOL + - "2 warnings"; + final String error = "warning: [options] bootstrap class path not set in conjunction with -source 1.6" + EOL + + "C:\\repo\\src\\it\\includes-output-when-compiler-forked\\src\\main\\java" + + "\\MyClass.java:23: warning: [divzero] division by zero" + + EOL + " System.out.println(1/0);" + + EOL + " ^" + + EOL + "2 warnings"; final List compilerErrors = - JavacCompiler.parseModernStream(0, new BufferedReader(new StringReader(error))); + JavacCompiler.parseModernStream(0, new BufferedReader(new StringReader(error))); assertThat(compilerErrors, notNullValue()); assertThat(compilerErrors.size(), is(2)); assertEquivalent( - new CompilerMessage( - "[options] bootstrap class path not set in conjunction with -source 1.6", CompilerMessage.Kind.WARNING), - compilerErrors.get(0)); + new CompilerMessage( + "[options] bootstrap class path not set in conjunction with -source 1.6", + CompilerMessage.Kind.WARNING), + compilerErrors.get(0)); assertEquivalent( - new CompilerMessage("C:\\repo\\src\\it\\includes-output-when-compiler-forked\\src\\main\\java\\MyClass" + - ".java", CompilerMessage.Kind.WARNING, 23, 27, 23, 30, "[divzero] division by zero"), - compilerErrors.get(1)); + new CompilerMessage( + "C:\\repo\\src\\it\\includes-output-when-compiler-forked\\src\\main\\java\\MyClass" + ".java", + CompilerMessage.Kind.WARNING, + 23, + 27, + 23, + 30, + "[divzero] division by zero"), + compilerErrors.get(1)); } @Test public void testIssue37() throws IOException { String error = - "warning: [path] bad path element \"d:\\maven_repo\\.m2\\repository\\org\\ow2\\asm\\asm-xml\\5.0.3\\asm-5.0.3.jar\": no such file or directory" + EOL + - "warning: [path] bad path element \"d:\\maven_repo\\.m2\\repository\\org\\ow2\\asm\\asm-xml\\5.0.3\\asm-util-5.0.3.jar\": no such file or directory" + EOL + - "warning: [options] bootstrap class path not set in conjunction with -source 1.7" + EOL + - "3 warnings" + EOL + - "An exception has occurred in the compiler (9). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you." + EOL + - "java.lang.NullPointerException" + EOL + - "\tat jdk.zipfs/jdk.nio.zipfs.JarFileSystem.getVersionMap(JarFileSystem.java:137)" + EOL + - "\tat jdk.zipfs/jdk.nio.zipfs.JarFileSystem.createVersionedLinks(JarFileSystem.java:112)" + EOL + - "\tat jdk.zipfs/jdk.nio.zipfs.JarFileSystem.(JarFileSystem.java:85)" + EOL + - "\tat jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:134)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.file.JavacFileManager$ArchiveContainer.(JavacFileManager.java:517)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.file.JavacFileManager.getContainer(JavacFileManager.java:319)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.file.JavacFileManager.list(JavacFileManager.java:715)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.code.ClassFinder.list(ClassFinder.java:722)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.code.ClassFinder.scanUserPaths(ClassFinder.java:655)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:526)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:293)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:633)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.code.Symbol$PackageSymbol.members(Symbol.java:1120)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.code.Symtab.listPackageModules(Symtab.java:810)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:344)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:529)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.comp.Enter.classEnter(Enter.java:285)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.comp.Enter.classEnter(Enter.java:300)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.comp.Enter.complete(Enter.java:570)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.comp.Enter.main(Enter.java:554)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1052)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:923)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:302)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:162)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)" + EOL + - "\tat jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)"; + "warning: [path] bad path element \"d:\\maven_repo\\.m2\\repository\\org\\ow2\\asm\\asm-xml\\5.0.3\\asm-5.0.3.jar\": no such file or directory" + + EOL + + "warning: [path] bad path element \"d:\\maven_repo\\.m2\\repository\\org\\ow2\\asm\\asm-xml\\5.0.3\\asm-util-5.0.3.jar\": no such file or directory" + + EOL + "warning: [options] bootstrap class path not set in conjunction with -source 1.7" + + EOL + "3 warnings" + + EOL + + "An exception has occurred in the compiler (9). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you." + + EOL + "java.lang.NullPointerException" + + EOL + "\tat jdk.zipfs/jdk.nio.zipfs.JarFileSystem.getVersionMap(JarFileSystem.java:137)" + + EOL + + "\tat jdk.zipfs/jdk.nio.zipfs.JarFileSystem.createVersionedLinks(JarFileSystem.java:112)" + + EOL + "\tat jdk.zipfs/jdk.nio.zipfs.JarFileSystem.(JarFileSystem.java:85)" + + EOL + + "\tat jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:134)" + + EOL + + "\tat jdk.compiler/com.sun.tools.javac.file.JavacFileManager$ArchiveContainer.(JavacFileManager.java:517)" + + EOL + + "\tat jdk.compiler/com.sun.tools.javac.file.JavacFileManager.getContainer(JavacFileManager.java:319)" + + EOL + + "\tat jdk.compiler/com.sun.tools.javac.file.JavacFileManager.list(JavacFileManager.java:715)" + + EOL + "\tat jdk.compiler/com.sun.tools.javac.code.ClassFinder.list(ClassFinder.java:722)" + + EOL + + "\tat jdk.compiler/com.sun.tools.javac.code.ClassFinder.scanUserPaths(ClassFinder.java:655)" + + EOL + "\tat jdk.compiler/com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:526)" + + EOL + "\tat jdk.compiler/com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:293)" + + EOL + "\tat jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:633)" + + EOL + + "\tat jdk.compiler/com.sun.tools.javac.code.Symbol$PackageSymbol.members(Symbol.java:1120)" + + EOL + "\tat jdk.compiler/com.sun.tools.javac.code.Symtab.listPackageModules(Symtab.java:810)" + + EOL + "\tat jdk.compiler/com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:344)" + + EOL + + "\tat jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:529)" + + EOL + "\tat jdk.compiler/com.sun.tools.javac.comp.Enter.classEnter(Enter.java:285)" + + EOL + "\tat jdk.compiler/com.sun.tools.javac.comp.Enter.classEnter(Enter.java:300)" + + EOL + "\tat jdk.compiler/com.sun.tools.javac.comp.Enter.complete(Enter.java:570)" + + EOL + "\tat jdk.compiler/com.sun.tools.javac.comp.Enter.main(Enter.java:554)" + + EOL + + "\tat jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1052)" + + EOL + "\tat jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:923)" + + EOL + "\tat jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:302)" + + EOL + "\tat jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:162)" + + EOL + "\tat jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)" + + EOL + "\tat jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)"; List compilerErrors = - JavacCompiler.parseModernStream(0, new BufferedReader(new StringReader(error))); + JavacCompiler.parseModernStream(0, new BufferedReader(new StringReader(error))); - assertThat( compilerErrors, notNullValue()); + assertThat(compilerErrors, notNullValue()); assertThat(compilerErrors.size(), is(4)); - assertEquivalent(new CompilerMessage("[path] bad path element \"d:\\maven_repo\\" + - ".m2\\repository\\org\\ow2\\asm\\asm-xml\\5.0.3\\asm-5.0.3.jar\": no such file or directory", - CompilerMessage.Kind.WARNING), compilerErrors.get(0)); - assertEquivalent(new CompilerMessage("warning: [path] bad path element \"d:\\maven_repo\\.m2\\repository\\org\\ow2\\asm\\asm-xml\\5.0.3\\asm-util-5.0.3.jar\": no such file or directory", - CompilerMessage.Kind.WARNING), compilerErrors.get(1)); - assertEquivalent(new CompilerMessage("[options] bootstrap class path not set in conjunction with -source 1.7", - CompilerMessage.Kind.WARNING), compilerErrors.get(2)); + assertEquivalent( + new CompilerMessage( + "[path] bad path element \"d:\\maven_repo\\" + + ".m2\\repository\\org\\ow2\\asm\\asm-xml\\5.0.3\\asm-5.0.3.jar\": no such file or directory", + CompilerMessage.Kind.WARNING), + compilerErrors.get(0)); + assertEquivalent( + new CompilerMessage( + "warning: [path] bad path element \"d:\\maven_repo\\.m2\\repository\\org\\ow2\\asm\\asm-xml\\5.0.3\\asm-util-5.0.3.jar\": no such file or directory", + CompilerMessage.Kind.WARNING), + compilerErrors.get(1)); + assertEquivalent( + new CompilerMessage( + "[options] bootstrap class path not set in conjunction with -source 1.7", + CompilerMessage.Kind.WARNING), + compilerErrors.get(2)); CompilerMessage finalMessage = compilerErrors.get(3); - assertThat( finalMessage.getKind(), is(CompilerMessage.Kind.ERROR)); - assertThat("Starts correctly", finalMessage.getMessage(), startsWith("An exception has occurred in the compiler")); - assertThat("continues through end of output", finalMessage.getMessage(), endsWith("\tat jdk.compiler/com.sun" + - ".tools.javac.Main.main(Main.java:43)" + EOL)); + assertThat(finalMessage.getKind(), is(CompilerMessage.Kind.ERROR)); + assertThat( + "Starts correctly", finalMessage.getMessage(), startsWith("An exception has occurred in the compiler")); + assertThat( + "continues through end of output", + finalMessage.getMessage(), + endsWith("\tat jdk.compiler/com.sun" + ".tools.javac.Main.main(Main.java:43)" + EOL)); } @Test - public void testJvmError() throws Exception - { - String out = "Error occurred during initialization of boot layer" + EOL + - "java.lang.module.FindException: Module java.xml.bind not found"; + public void testJvmError() throws Exception { + String out = "Error occurred during initialization of boot layer" + EOL + + "java.lang.module.FindException: Module java.xml.bind not found"; - List compilerErrors = JavacCompiler.parseModernStream( 1, new BufferedReader( new StringReader( out ) )); + List compilerErrors = + JavacCompiler.parseModernStream(1, new BufferedReader(new StringReader(out))); - assertThat( compilerErrors, notNullValue()); + assertThat(compilerErrors, notNullValue()); - assertThat( compilerErrors.size(), is(1) ); + assertThat(compilerErrors.size(), is(1)); } @Test - public void testBadSourceFileError() throws Exception - { - String out = "/MTOOLCHAINS-19/src/main/java/ch/pecunifex/x/Cls1.java:12: error: cannot access Cls2\n" + - " Cls2 tvar;\n" + - " ^\n" + - " bad source file: /MTOOLCHAINS-19/src/main/java/ch/pecunifex/x/Cls2.java\n" + - " file does not contain class ch.pecunifex.x.Cls2\n" + - " Please remove or make sure it appears in the correct subdirectory of the sourcepath."; + public void testBadSourceFileError() throws Exception { + String out = "/MTOOLCHAINS-19/src/main/java/ch/pecunifex/x/Cls1.java:12: error: cannot access Cls2\n" + + " Cls2 tvar;\n" + + " ^\n" + + " bad source file: /MTOOLCHAINS-19/src/main/java/ch/pecunifex/x/Cls2.java\n" + + " file does not contain class ch.pecunifex.x.Cls2\n" + + " Please remove or make sure it appears in the correct subdirectory of the sourcepath."; - List compilerErrors = JavacCompiler.parseModernStream( 1, new BufferedReader( new StringReader( out ) )); + List compilerErrors = + JavacCompiler.parseModernStream(1, new BufferedReader(new StringReader(out))); - assertThat( compilerErrors, notNullValue() ); + assertThat(compilerErrors, notNullValue()); - assertThat( compilerErrors.size(), is(1)); + assertThat(compilerErrors.size(), is(1)); - CompilerMessage message = compilerErrors.get( 0 ); + CompilerMessage message = compilerErrors.get(0); validateBadSourceFile(message); } @Test - public void testWarningFollowedByBadSourceFileError() throws Exception - { - String out = "/MTOOLCHAINS-19/src/main/java/ch/pecunifex/x/Cls1.java:3: warning: FontDesignMetrics is internal proprietary API and may be removed in a future release\n" + - "import sun.font.FontDesignMetrics;\n" + - " ^\n" + - "/MTOOLCHAINS-19/src/main/java/ch/pecunifex/x/Cls1.java:12: error: cannot access Cls2\n" + - " Cls2 tvar;\n" + - " ^\n" + - " bad source file: /MTOOLCHAINS-19/src/main/java/ch/pecunifex/x/Cls2.java\n" + - " file does not contain class ch.pecunifex.x.Cls2\n" + - " Please remove or make sure it appears in the correct subdirectory of the sourcepath."; - - List compilerErrors = JavacCompiler.parseModernStream( 1, new BufferedReader( new StringReader( out ) )); - - assertThat( compilerErrors, notNullValue()); - - assertThat( compilerErrors, hasSize(2) ); - - CompilerMessage firstMessage = compilerErrors.get( 0 ); - assertThat( "Is a Warning", firstMessage.getKind(), - is(CompilerMessage.Kind.WARNING) ); - assertThat( "On Correct File",firstMessage.getFile(), - is("/MTOOLCHAINS-19/src/main/java/ch/pecunifex/x/Cls1.java") ); - assertThat( "Internal API Warning", + public void testWarningFollowedByBadSourceFileError() throws Exception { + String out = + "/MTOOLCHAINS-19/src/main/java/ch/pecunifex/x/Cls1.java:3: warning: FontDesignMetrics is internal proprietary API and may be removed in a future release\n" + + "import sun.font.FontDesignMetrics;\n" + + " ^\n" + + "/MTOOLCHAINS-19/src/main/java/ch/pecunifex/x/Cls1.java:12: error: cannot access Cls2\n" + + " Cls2 tvar;\n" + + " ^\n" + + " bad source file: /MTOOLCHAINS-19/src/main/java/ch/pecunifex/x/Cls2.java\n" + + " file does not contain class ch.pecunifex.x.Cls2\n" + + " Please remove or make sure it appears in the correct subdirectory of the sourcepath."; + + List compilerErrors = + JavacCompiler.parseModernStream(1, new BufferedReader(new StringReader(out))); + + assertThat(compilerErrors, notNullValue()); + + assertThat(compilerErrors, hasSize(2)); + + CompilerMessage firstMessage = compilerErrors.get(0); + assertThat("Is a Warning", firstMessage.getKind(), is(CompilerMessage.Kind.WARNING)); + assertThat( + "On Correct File", + firstMessage.getFile(), + is("/MTOOLCHAINS-19/src/main/java/ch/pecunifex/x/Cls1.java")); + assertThat( + "Internal API Warning", firstMessage.getMessage(), is("FontDesignMetrics is internal proprietary API and may be removed in a future release")); - CompilerMessage secondMessage = compilerErrors.get( 1 ); + CompilerMessage secondMessage = compilerErrors.get(1); validateBadSourceFile(secondMessage); } - private void validateBadSourceFile(CompilerMessage message) - { - assertThat( "Is an Error", message.getKind(), is(CompilerMessage.Kind.ERROR) ); - assertThat( "On Correct File",message.getFile(), is("/MTOOLCHAINS-19/src/main/java/ch/pecunifex/x/Cls1.java") ); - assertThat( "Message starts with access Error", message.getMessage(), startsWith("error: cannot access Cls2") ); + private void validateBadSourceFile(CompilerMessage message) { + assertThat("Is an Error", message.getKind(), is(CompilerMessage.Kind.ERROR)); + assertThat("On Correct File", message.getFile(), is("/MTOOLCHAINS-19/src/main/java/ch/pecunifex/x/Cls1.java")); + assertThat("Message starts with access Error", message.getMessage(), startsWith("error: cannot access Cls2")); } - private static void assertEquivalent(CompilerMessage expected, CompilerMessage actual){ - assertThat("Message did not match",actual.getMessage(), is( expected.getMessage())); + private static void assertEquivalent(CompilerMessage expected, CompilerMessage actual) { + assertThat("Message did not match", actual.getMessage(), is(expected.getMessage())); assertThat("Kind did not match", actual.getKind(), is(expected.getKind())); assertThat("File did not match", actual.getFile(), is(expected.getFile())); - assertThat( "Start line did not match", actual.getStartLine(), is(expected.getStartLine())); - assertThat( "Start column did not match", actual.getStartColumn(), is(expected.getStartColumn())); + assertThat("Start line did not match", actual.getStartLine(), is(expected.getStartLine())); + assertThat("Start column did not match", actual.getStartColumn(), is(expected.getStartColumn())); assertThat("End line did not match", actual.getEndLine(), is(expected.getEndLine())); assertThat("End column did not match", actual.getEndColumn(), is(expected.getEndColumn())); } diff --git a/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/JavacCompilerTest.java b/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/JavacCompilerTest.java index 85abcba8..c8edab96 100644 --- a/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/JavacCompilerTest.java +++ b/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/JavacCompilerTest.java @@ -1,14 +1,14 @@ package org.codehaus.plexus.compiler.javac; -import org.codehaus.plexus.compiler.CompilerMessage; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; import java.util.List; +import org.codehaus.plexus.compiler.CompilerMessage; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.collection.IsCollectionWithSize.hasSize; @@ -34,45 +34,39 @@ /** * @author Olivier Lamy */ -public class JavacCompilerTest - extends AbstractJavacCompilerTest -{ +public class JavacCompilerTest extends AbstractJavacCompilerTest { @BeforeEach - public void setUp() - { + public void setUp() { super.setUp(); - setForceJavacCompilerUse( true ); + setForceJavacCompilerUse(true); } @Test - void parseModernStream_withAnnotationProcessingErrors() throws IOException - { - String input = - "\n" + - "\n" + - "An annotation processor threw an uncaught exception.\n" + - "Consult the following stack trace for details.\n" + - "java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x1da51a35) cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module @0x1da51a35\n" + - "\tat lombok.javac.apt.LombokProcessor.getJavacProcessingEnvironment(LombokProcessor.java:433)\n" + - "\tat lombok.javac.apt.LombokProcessor.init(LombokProcessor.java:92)\n" + - "\tat lombok.core.AnnotationProcessor$JavacDescriptor.want(AnnotationProcessor.java:160)\n" + - "\tat lombok.core.AnnotationProcessor.init(AnnotationProcessor.java:213)\n" + - "\tat lombok.launch.AnnotationProcessorHider$AnnotationProcessor.init(AnnotationProcessor.java:64)\n" + - "\tat jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.(JavacProcessingEnvironment.java:702)\n" + - "\tat jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.next(JavacProcessingEnvironment.java:829)\n" + - "\tat jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:925)\n" + - "\tat jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1269)\n" + - "\tat jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1384)\n" + - "\tat jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1261)\n" + - "\tat jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:935)\n" + - "\tat jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:317)\n" + - "\tat jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)\n" + - "\tat jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)\n" + - "\tat jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)\n"; + void parseModernStream_withAnnotationProcessingErrors() throws IOException { + String input = "\n" + "\n" + + "An annotation processor threw an uncaught exception.\n" + + "Consult the following stack trace for details.\n" + + "java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x1da51a35) cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module @0x1da51a35\n" + + "\tat lombok.javac.apt.LombokProcessor.getJavacProcessingEnvironment(LombokProcessor.java:433)\n" + + "\tat lombok.javac.apt.LombokProcessor.init(LombokProcessor.java:92)\n" + + "\tat lombok.core.AnnotationProcessor$JavacDescriptor.want(AnnotationProcessor.java:160)\n" + + "\tat lombok.core.AnnotationProcessor.init(AnnotationProcessor.java:213)\n" + + "\tat lombok.launch.AnnotationProcessorHider$AnnotationProcessor.init(AnnotationProcessor.java:64)\n" + + "\tat jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.(JavacProcessingEnvironment.java:702)\n" + + "\tat jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.next(JavacProcessingEnvironment.java:829)\n" + + "\tat jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:925)\n" + + "\tat jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1269)\n" + + "\tat jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1384)\n" + + "\tat jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1261)\n" + + "\tat jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:935)\n" + + "\tat jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:317)\n" + + "\tat jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)\n" + + "\tat jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)\n" + + "\tat jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)\n"; - List compilerMessages = JavacCompiler.parseModernStream( 1, - new BufferedReader( new StringReader( input ) ) ); + List compilerMessages = + JavacCompiler.parseModernStream(1, new BufferedReader(new StringReader(input))); - assertThat( compilerMessages, hasSize( 1 ) ); + assertThat(compilerMessages, hasSize(1)); } } diff --git a/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/JavaxToolsCompilerTest.java b/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/JavaxToolsCompilerTest.java index 598bad40..5daa1717 100644 --- a/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/JavaxToolsCompilerTest.java +++ b/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/JavaxToolsCompilerTest.java @@ -21,9 +21,7 @@ /** * @author Olivier Lamy */ -public class JavaxToolsCompilerTest - extends AbstractJavacCompilerTest -{ +public class JavaxToolsCompilerTest extends AbstractJavacCompilerTest { // no op default is to javax.tools if available @Override @@ -35,5 +33,4 @@ protected int expectedWarnings() { return super.expectedWarnings(); } } - } diff --git a/plexus-compilers/pom.xml b/plexus-compilers/pom.xml index f874e17c..13a8f086 100644 --- a/plexus-compilers/pom.xml +++ b/plexus-compilers/pom.xml @@ -38,5 +38,5 @@ test - + diff --git a/pom.xml b/pom.xml index 9ef8efd3..075bbe27 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,4 @@ - 4.0.0 @@ -27,8 +26,8 @@ ${scm.url} ${scm.url} - http://github.com/codehaus-plexus/plexus-compiler/tree/${project.scm.tag}/ HEAD + http://github.com/codehaus-plexus/plexus-compiler/tree/${project.scm.tag}/ github @@ -96,9 +95,9 @@ org.junit junit-bom + ${jupiter.version} pom import - ${jupiter.version} org.codehaus.plexus