pax_global_header00006660000000000000000000000064124150750140014511gustar00rootroot0000000000000052 comment=35ca8c7ce91bdf7f831653c33bd92709bf81a69b plexus-compiler-plexus-compiler-2.4/000077500000000000000000000000001241507501400176345ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/.gitignore000066400000000000000000000001051241507501400216200ustar00rootroot00000000000000target/ .project .classpath .settings/ bin .idea *.iml .java-version plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/000077500000000000000000000000001241507501400235335ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/pom.xml000066400000000000000000000015411241507501400250510ustar00rootroot00000000000000 4.0.0 org.codehaus.plexus plexus-compiler 2.4 plexus-compiler-api Plexus Compiler Api Plexus Compilers component's API to manipulate compilers. org.codehaus.plexus plexus-utils junit junit plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/000077500000000000000000000000001241507501400243225ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/000077500000000000000000000000001241507501400252465ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/000077500000000000000000000000001241507501400261675ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/000077500000000000000000000000001241507501400267565ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/000077500000000000000000000000001241507501400305515ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/000077500000000000000000000000001241507501400320715ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/000077500000000000000000000000001241507501400337035ustar00rootroot00000000000000AbstractCompiler.java000066400000000000000000000217651241507501400377400ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compilerpackage org.codehaus.plexus.compiler; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.DirectoryScanner; import java.io.File; import java.io.IOException; import java.util.HashSet; import java.util.List; import java.util.Set; /** * @author Jason van Zyl * @author Michal Maczka * @author Trygve Laugstøl */ public abstract class AbstractCompiler extends AbstractLogEnabled implements Compiler { protected static final String EOL = System.getProperty( "line.separator" ); protected static final String PS = System.getProperty( "path.separator" ); private CompilerOutputStyle compilerOutputStyle; private String inputFileEnding; private String outputFileEnding; private String outputFile; // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- protected AbstractCompiler( CompilerOutputStyle compilerOutputStyle, String inputFileEnding, String outputFileEnding, String outputFile ) { this.compilerOutputStyle = compilerOutputStyle; this.inputFileEnding = inputFileEnding; this.outputFileEnding = outputFileEnding; this.outputFile = outputFile; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public CompilerResult performCompile(CompilerConfiguration configuration) throws CompilerException { throw new CompilerNotImplementedException("The performCompile method has not been implemented."); } @Deprecated public List compile(CompilerConfiguration configuration) throws CompilerException { throw new CompilerNotImplementedException("The compile method has not been implemented."); } public CompilerOutputStyle getCompilerOutputStyle() { return compilerOutputStyle; } 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." ); } 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." ); } return outputFile; } public boolean canUpdateTarget( CompilerConfiguration configuration ) throws CompilerException { return true; } // ---------------------------------------------------------------------- // Utility Methods // ---------------------------------------------------------------------- public static String getPathString( List pathElements ) { StringBuilder sb = new StringBuilder(); for ( String pathElement : pathElements ) { sb.append( pathElement ).append( File.pathSeparator ); } return sb.toString(); } protected static Set getSourceFilesForSourceRoot( CompilerConfiguration config, String sourceLocation ) { DirectoryScanner scanner = new DirectoryScanner(); 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" } ); } Set excludes = config.getExcludes(); if ( excludes != null && !excludes.isEmpty() ) { String[] exclStrs = excludes.toArray( new String[excludes.size()] ); scanner.setExcludes( exclStrs ); } scanner.scan(); String[] sourceDirectorySources = scanner.getIncludedFiles(); Set sources = new HashSet(); for ( String sourceDirectorySource : sourceDirectorySources ) { File f = new File( sourceLocation, sourceDirectorySource ); sources.add( f.getPath() ); } return sources; } 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() ); } } else { for ( String sourceLocation : config.getSourceLocations() ) { sources.addAll( getSourceFilesForSourceRoot( config, sourceLocation ) ); } } String[] result; if ( sources.isEmpty() ) { result = new String[0]; } else { result = sources.toArray( new String[sources.size()] ); } return result; } 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 ( 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 ); result = result.replace( '/', '.' ); return result; } } else { File t = new File( sourceDir, fileName ); if ( t.exists() ) { String str = getCanonicalPath( t ).replace( '\\', '/' ); return str.substring( prefix.length() + 1, str.length() - 5 ).replace( '/', '.' ); } } } if ( fileName.endsWith( ".java" ) ) { fileName = fileName.substring( 0, fileName.length() - 5 ); } fileName = fileName.replace( '\\', '.' ); return fileName.replace( '/', '.' ); } private static String getCanonicalPath( File origFile ) throws CompilerException { try { return origFile.getCanonicalPath(); } catch ( IOException e ) { throw new CompilerException( "Error while getting the canonical path of '" + origFile.getAbsolutePath() + "'.", e ); } } /** * @deprecated use (String[]) arguments.toArray( new String[ arguments.size() ] ); instead */ protected static String[] toStringArray( List arguments ) { String[] args = new String[arguments.size()]; int argLength = arguments.size(); for ( int i = 0; i < argLength; i++ ) { args[i] = arguments.get( i ); } return args; } } Compiler.java000066400000000000000000000067641241507501400362560ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compilerpackage org.codehaus.plexus.compiler; /** * The MIT License * * Copyright (c) 2004, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * 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 { String ROLE = Compiler.class.getName(); CompilerOutputStyle getCompilerOutputStyle(); String getInputFileEnding( CompilerConfiguration configuration ) throws CompilerException; String getOutputFileEnding( CompilerConfiguration configuration ) throws CompilerException; String getOutputFile( 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; /** * This method is provided for backwards compatibility only. Clients should * use {@link #performCompile(CompilerConfiguration)} instead. * * @param configuration the configuration description of the compilation * to perform * @return the result of the compilation returned by the language processor * @throws CompilerException */ @Deprecated List compile( CompilerConfiguration configuration ) throws CompilerException; /** * Create the command line that would be executed using this configuration. * If this particular compiler has no concept of a command line then returns * null. * * @param config the CompilerConfiguration describing the compilation * @return an array of Strings that make up the command line, or null if * this compiler has no concept of command line * @throws CompilerException if there was an error generating the command * line */ String[] createCommandLine( CompilerConfiguration config ) throws CompilerException; } CompilerConfiguration.java000066400000000000000000000326131241507501400407760ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compilerpackage org.codehaus.plexus.compiler; /** * The MIT License * * Copyright (c) 2004, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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.HashSet; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; /** * @author jdcasey */ public class CompilerConfiguration { private String outputLocation; private List classpathEntries = new LinkedList(); // ---------------------------------------------------------------------- // Source Files // ---------------------------------------------------------------------- private Set sourceFiles = new HashSet(); private List sourceLocations = new LinkedList(); private Set includes = new HashSet(); private Set excludes = new HashSet(); // ---------------------------------------------------------------------- // Compiler Settings // ---------------------------------------------------------------------- private boolean debug; private String debugLevel; private boolean showWarnings = true; private boolean showDeprecation; private String sourceVersion; private String targetVersion; private String sourceEncoding; private Map customCompilerArguments = new LinkedHashMap(); private boolean fork; private boolean optimize; private String meminitial; private String maxmem; private String executable; private File workingDirectory; private String compilerVersion; private boolean verbose = false; /** * A build temporary directory, eg target/. *

* Used by the compiler implementation to put temporary files. */ private File buildDirectory; /** * Used to control the name of the output file when compiling a set of * sources to a single file. */ private String outputFileName; /** * in jdk 1.6+, used to hold value of the -s path parameter. */ private File generatedSourcesDirectory; /** * value of the -proc parameter in jdk 1.6+ */ private String proc; /** * -processor parameters in jdk 1.6+ */ private String[] annotationProcessors; /** * default value {@link CompilerReuseStrategy.ReuseCreated} * * @since 1.9 */ private CompilerReuseStrategy compilerReuseStrategy = CompilerReuseStrategy.ReuseCreated; /** * force usage of old JavacCompiler even if javax.tools is detected * @since 2.0 */ private boolean forceJavacCompilerUse=false; // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public void setOutputLocation( String outputLocation ) { this.outputLocation = outputLocation; } public String getOutputLocation() { return outputLocation; } // ---------------------------------------------------------------------- // Class path // ---------------------------------------------------------------------- public void addClasspathEntry( String classpathEntry ) { classpathEntries.add( classpathEntry ); } public void setClasspathEntries( List classpathEntries ) { if ( classpathEntries == null ) { this.classpathEntries = Collections.emptyList(); } else { this.classpathEntries = new LinkedList( classpathEntries ); } } public List getClasspathEntries() { return Collections.unmodifiableList( classpathEntries ); } // ---------------------------------------------------------------------- // Source files // ---------------------------------------------------------------------- public void setSourceFiles( Set sourceFiles ) { if ( sourceFiles == null ) { this.sourceFiles = Collections.emptySet(); } else { this.sourceFiles = new HashSet( sourceFiles ); } } public Set getSourceFiles() { return sourceFiles; } public void addSourceLocation( String sourceLocation ) { sourceLocations.add( sourceLocation ); } public void setSourceLocations( List sourceLocations ) { if ( sourceLocations == null ) { this.sourceLocations = Collections.emptyList(); } else { this.sourceLocations = new LinkedList( sourceLocations ); } } public List getSourceLocations() { return Collections.unmodifiableList( sourceLocations ); } public void addInclude( String include ) { includes.add( include ); } public void setIncludes( Set includes ) { if ( includes == null ) { this.includes = Collections.emptySet(); } else { this.includes = new HashSet( includes ); } } public Set getIncludes() { return Collections.unmodifiableSet( includes ); } public void addExclude( String exclude ) { excludes.add( exclude ); } public void setExcludes( Set excludes ) { if ( excludes == null ) { this.excludes = Collections.emptySet(); } else { this.excludes = new HashSet( excludes ); } } public Set getExcludes() { return Collections.unmodifiableSet( excludes ); } // ---------------------------------------------------------------------- // Compiler Settings // ---------------------------------------------------------------------- public void setDebug( boolean debug ) { this.debug = debug; } public boolean isDebug() { return debug; } public void setDebugLevel( String debugLevel ) { this.debugLevel = debugLevel; } public String getDebugLevel() { return debugLevel; } public void setShowWarnings( boolean showWarnings ) { this.showWarnings = showWarnings; } public boolean isShowWarnings() { return showWarnings; } public boolean isShowDeprecation() { return showDeprecation; } public void setShowDeprecation( boolean showDeprecation ) { this.showDeprecation = showDeprecation; } public String getSourceVersion() { return sourceVersion; } public void setSourceVersion( String sourceVersion ) { this.sourceVersion = sourceVersion; } public String getTargetVersion() { return targetVersion; } public void setTargetVersion( String targetVersion ) { this.targetVersion = targetVersion; } public String getSourceEncoding() { return sourceEncoding; } public void setSourceEncoding( String sourceEncoding ) { this.sourceEncoding = sourceEncoding; } public void addCompilerCustomArgument( String customArgument, String value ) { customCompilerArguments.put( customArgument, value ); } /** * @deprecated will be removed in 2.X use #getCustomCompilerArgumentsAsMap * @return */ public LinkedHashMap getCustomCompilerArguments() { return new LinkedHashMap( customCompilerArguments ); } /** * @deprecated will be removed in 2.X use #setCustomCompilerArgumentsAsMap * @param customCompilerArguments */ public void setCustomCompilerArguments( LinkedHashMap customCompilerArguments ) { if ( customCompilerArguments == null ) { this.customCompilerArguments = new LinkedHashMap(); } else { this.customCompilerArguments = customCompilerArguments; } } public Map getCustomCompilerArgumentsAsMap() { return new LinkedHashMap( customCompilerArguments ); } public void setCustomCompilerArgumentsAsMap( Map customCompilerArguments ) { if ( customCompilerArguments == null ) { this.customCompilerArguments = new LinkedHashMap(); } else { this.customCompilerArguments = customCompilerArguments; } } public boolean isFork() { return fork; } public void setFork( boolean fork ) { this.fork = fork; } public String getMeminitial() { return meminitial; } public void setMeminitial( String meminitial ) { this.meminitial = meminitial; } public String getMaxmem() { return maxmem; } public void setMaxmem( String maxmem ) { this.maxmem = maxmem; } public String getExecutable() { return executable; } public void setExecutable( String executable ) { this.executable = executable; } public File getWorkingDirectory() { return workingDirectory; } public void setWorkingDirectory( File workingDirectory ) { this.workingDirectory = workingDirectory; } public File getBuildDirectory() { return buildDirectory; } public void setBuildDirectory( File buildDirectory ) { this.buildDirectory = buildDirectory; } public String getOutputFileName() { return outputFileName; } public void setOutputFileName( String outputFileName ) { this.outputFileName = outputFileName; } public boolean isOptimize() { return optimize; } public void setOptimize( boolean optimize ) { this.optimize = optimize; } public String getCompilerVersion() { return compilerVersion; } public void setCompilerVersion( String compilerVersion ) { this.compilerVersion = compilerVersion; } public boolean isVerbose() { return verbose; } public void setVerbose( boolean verbose ) { this.verbose = verbose; } public void setProc( String proc ) { this.proc = proc; } public void setGeneratedSourcesDirectory( File generatedSourcesDirectory ) { this.generatedSourcesDirectory = generatedSourcesDirectory; } public File getGeneratedSourcesDirectory() { return generatedSourcesDirectory; } public String getProc() { return proc; } public void setAnnotationProcessors( String[] annotationProcessors ) { this.annotationProcessors = annotationProcessors; } public String[] getAnnotationProcessors() { return annotationProcessors; } public CompilerReuseStrategy getCompilerReuseStrategy() { return compilerReuseStrategy; } public void setCompilerReuseStrategy( CompilerReuseStrategy compilerReuseStrategy ) { this.compilerReuseStrategy = compilerReuseStrategy; } /** * Re-use strategy of the compiler (implement for java only). */ public enum CompilerReuseStrategy { /** * Always reuse the same. * Default strategy. */ ReuseSame( "reuseSame" ), /** * Re-create a new compiler for each use. */ 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" ); private String strategy; CompilerReuseStrategy( String strategy ) { this.strategy = strategy; } public String getStrategy() { return strategy; } @Override public String toString() { return "CompilerReuseStrategy:" + this.strategy; } } public boolean isForceJavacCompilerUse() { return forceJavacCompilerUse; } public void setForceJavacCompilerUse( boolean forceJavacCompilerUse ) { this.forceJavacCompilerUse = forceJavacCompilerUse; } } CompilerError.java000066400000000000000000000021251241507501400372530ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compilerpackage org.codehaus.plexus.compiler; /** * * Copyright 2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * This class encapsulates a message from a compiler. This class is deprecated * and only exists for backwards compatibility. Clients should be using * {@link CompilerMessage} instead. * * @author Andrew Eisenberg */ @Deprecated public class CompilerError extends CompilerMessage { public CompilerError( String message, boolean error ) { super( message, error ); } } CompilerException.java000066400000000000000000000027511241507501400401250ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compilerpackage org.codehaus.plexus.compiler; /** * The MIT License * * Copyright (c) 2004, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /** * @author Trygve Laugstøl */ public class CompilerException extends Exception { public CompilerException( String message ) { super( message ); } public CompilerException( String message, Throwable cause ) { super( message, cause ); } } CompilerMessage.java000066400000000000000000000246501241507501400375550ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compilerpackage org.codehaus.plexus.compiler; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /** * * Copyright 2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * This class encapsulates a message produced by a programming language * processor (whether interpreted or compiled). * * @author Stefano Mazzocchi * @since 2.0 */ public class CompilerMessage { private static final String JDK_6_NOTE_PREFIX = "note: "; private static final String JDK_6_WARNING_PREFIX = "warning: "; /** * The kind of message. */ private final Kind kind; /** * The start line number of the offending program text */ private int startline; /** * The start column number of the offending program text */ private int startcolumn; /** * The end line number of the offending program text */ private int endline; /** * The end column number of the offending program text */ private int endcolumn; /** * The name of the file containing the offending program text */ private String file; /** * The actual message text produced by the language processor */ private final String message; /** * Constructs a compiler message. * * @param file The name of the file containing the offending program text * @param error true if this is a error message, or false if it * is a warning message * @param startline The start line number of the offending program text * @param startcolumn The start column number of the offending program text * @param endline The end line number of the offending program text * @param endcolumn The end column number of the offending program text * @param message The actual message text produced by the language processor * @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 ) { this.file = file; this.kind = error ? Kind.ERROR : Kind.WARNING; this.startline = startline; this.startcolumn = startcolumn; this.endline = endline; this.endcolumn = endcolumn; this.message = cleanupMessage( message ); } /** * Constructs a compiler message. * * @param file The name of the file containing the offending program text * @param kind The kind of message * @param startline The start line number of the offending program text * @param startcolumn The start column number of the offending program text * @param endline The end line number of the offending program text * @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 ) { this.file = file; this.kind = kind; this.startline = startline; this.startcolumn = startcolumn; this.endline = endline; this.endcolumn = endcolumn; this.message = cleanupMessage( message ); } /** * The warning message constructor. * * @param message The actual message text produced by the language processor * @deprecated Use {@link #CompilerMessage(String, Kind)} instead */ @Deprecated public CompilerMessage( final String message ) { this.kind = Kind.WARNING; this.message = cleanupMessage( message ); } /** * Constructs a compiler message. * * @param message The actual message text produced by the language processor * @param error true if this is a error message, or false if it * is a warning message * @deprecated Use {@link #CompilerMessage(String, Kind)} instead */ @Deprecated public CompilerMessage( final String message, final boolean error ) { this.kind = error ? Kind.ERROR : Kind.WARNING; this.message = cleanupMessage( message ); } /** * Constructs a compiler message. * * @param message The actual message text produced by the language processor * @param kind The kind of message * @since 2.0 */ public CompilerMessage( final String message, final Kind kind ) { this.kind = kind; this.message = cleanupMessage( message ); } /** * Returns the filename associated with this compiler message. * * @return The filename associated with this compiler message */ public String getFile() { return file; } /** * Asserts whether this is an error message or not. * * @return Whether the message is an error message */ public boolean isError() { return kind == Kind.ERROR; } /** * Returns the starting line number of the program text originating this compiler * message. * * @return The starting line number of the program text originating this message */ public int getStartLine() { return startline; } /** * Returns the starting column number of the program text originating this * compiler message. * * @return The starting column number of the program text originating this * message */ public int getStartColumn() { return startcolumn; } /** * Return the ending line number of the program text originating this compiler * message. * * @return The ending line number of the program text originating this message */ public int getEndLine() { return endline; } /** * Returns the ending column number of the program text originating this * compiler message. * * @return The ending column number of the program text originating this * message */ public int getEndColumn() { return endcolumn; } /** * Returns the message produced by the language processor. * * @return The message produced by the language processor */ public String getMessage() { return message; } /** * Returns the kind of the compiler message. * * @return the kind of the message * @since 2.0 */ public Kind getKind() { return kind; } @Override public String toString() { if ( file != null ) { if ( startline != 0 ) { if ( startcolumn != 0 ) { return file + ":" + "[" + startline + "," + startcolumn + "] " + message; } else { return file + ":" + "[" + startline + "] " + message; } } else { return file + ": " + message; } } 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() ); } return msg; } /** * As we are still 1.5 required we use a wrapper to Diagnostic.Kind and some compilers don't know jdk constants. * * @since 2.0 */ public enum Kind { /** * Problem which prevents the tool's normal completion. */ ERROR( "error" ), /** * Problem similar to a warning, but is mandated by the tool's specification. */ MANDATORY_WARNING( "mandatory_warning" ), /** * Informative message from the tool. */ NOTE( "note" ), /** * Diagnostic which does not fit within the other kinds. */ OTHER( "other" ), /** * Problem which does not usually prevent the tool from completing normally. */ WARNING( "warning" ); private String type; private Kind( final String type ) { this.type = type; } } } CompilerNotImplementedException.java000066400000000000000000000030301241507501400427610ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compilerpackage org.codehaus.plexus.compiler; /** * The MIT License * * Copyright (c) 2004, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /** * @author Andrew Eisenberg */ public class CompilerNotImplementedException extends CompilerException { public CompilerNotImplementedException( String message ) { super( message ); } public CompilerNotImplementedException( String message, Throwable cause ) { super( message, cause ); } } CompilerOutputStyle.java000066400000000000000000000045251241507501400405110ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compilerpackage org.codehaus.plexus.compiler; /** * The MIT License * * Copyright (c) 2004, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /** * @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 static CompilerOutputStyle ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES = new CompilerOutputStyle( "one-output-file" ); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- private String id; private CompilerOutputStyle( String id ) { this.id = id; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public String toString() { return id; } public boolean equals( Object other ) { if ( other == null || !( other instanceof CompilerOutputStyle ) ) { return false; } return id.equals( ( (CompilerOutputStyle) other ).id ); } public int hashCode() { return id.hashCode(); } } CompilerResult.java000066400000000000000000000047521241507501400374500ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compilerpackage org.codehaus.plexus.compiler; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.ArrayList; import java.util.List; /** * The result returned from a compiling language processor (aka compiler), possibly including * some messages. * * @author Olivier Lamy * @since 2.0 */ public class CompilerResult { private boolean success; private List compilerMessages; /** * Constructs a successful compiler result with no messages. */ 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 ) { this.success = success; this.compilerMessages = compilerMessages; } public boolean isSuccess() { return success; } public void setSuccess( boolean success ) { this.success = success; } public CompilerResult success( boolean success ) { this.setSuccess( success ); return this; } public List getCompilerMessages() { if ( compilerMessages == null ) { this.compilerMessages = new ArrayList(); } return compilerMessages; } public void setCompilerMessages( List compilerMessages ) { this.compilerMessages = compilerMessages; } public CompilerResult compilerMessages( List compilerMessages ) { this.setCompilerMessages( compilerMessages ); return this; } } 000077500000000000000000000000001241507501400346015ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/utilStreamPumper.java000066400000000000000000000046361241507501400401010ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/utilpackage org.codehaus.plexus.compiler.util; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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; /** * @author Jason van Zyl */ public class StreamPumper extends Thread { private static final int BUFFER_SIZE = 512; private BufferedInputStream stream; private boolean endOfStream = false; private int SLEEP_TIME = 5; private OutputStream out; public StreamPumper( BufferedInputStream is, OutputStream out ) { this.stream = is; this.out = out; } public void pumpStream() throws IOException { byte[] buf = new byte[BUFFER_SIZE]; if ( !endOfStream ) { int bytesRead = stream.read( buf, 0, BUFFER_SIZE ); if ( bytesRead > 0 ) { out.write( buf, 0, bytesRead ); } else if ( bytesRead == -1 ) { endOfStream = true; } } } public void run() { try { while ( !endOfStream ) { pumpStream(); sleep( SLEEP_TIME ); } } catch ( Exception e ) { // getLogger().warn("Jikes.run()", e); } } } 000077500000000000000000000000001241507501400355255ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scanAbstractSourceInclusionScanner.java000066400000000000000000000043661241507501400445230ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scanpackage org.codehaus.plexus.compiler.util.scan; /* * Copyright 2001-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * 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; /** * @author jdcasey */ public abstract class AbstractSourceInclusionScanner implements SourceInclusionScanner { private final List sourceMappings = new ArrayList(); public final void addSourceMapping( SourceMapping sourceMapping ) { sourceMappings.add( sourceMapping ); } protected final List getSourceMappings() { return Collections.unmodifiableList( sourceMappings ); } protected String[] scanForSources( File sourceDir, Set sourceIncludes, Set sourceExcludes ) { DirectoryScanner ds = new DirectoryScanner(); ds.setFollowSymlinks( true ); ds.setBasedir( sourceDir ); String[] includes; if ( sourceIncludes.isEmpty() ) { includes = new String[0]; } else { includes = sourceIncludes.toArray( new String[sourceIncludes.size()] ); } ds.setIncludes( includes ); String[] excludes; if ( sourceExcludes.isEmpty() ) { excludes = new String[0]; } else { excludes = sourceExcludes.toArray( new String[sourceExcludes.size()] ); } ds.setExcludes( excludes ); ds.addDefaultExcludes(); ds.scan(); return ds.getIncludedFiles(); } } InclusionScanException.java000066400000000000000000000017051241507501400430220ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scanpackage org.codehaus.plexus.compiler.util.scan; /* * Copyright 2001-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @author jdcasey */ public class InclusionScanException extends Exception { public InclusionScanException( String message ) { super( message ); } public InclusionScanException( String message, Throwable cause ) { super( message, cause ); } } SimpleSourceInclusionScanner.java000066400000000000000000000050521241507501400442020ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scanpackage org.codehaus.plexus.compiler.util.scan; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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; /** * @author Trygve Laugstøl */ public class SimpleSourceInclusionScanner extends AbstractSourceInclusionScanner { private Set sourceIncludes; private Set sourceExcludes; public SimpleSourceInclusionScanner( Set sourceIncludes, Set sourceExcludes ) { this.sourceIncludes = sourceIncludes; this.sourceExcludes = sourceExcludes; } public Set getIncludedSources( File sourceDir, File targetDir ) throws InclusionScanException { List srcMappings = getSourceMappings(); if ( srcMappings.isEmpty() ) { return Collections.emptySet(); } String[] potentialSources = scanForSources( sourceDir, sourceIncludes, sourceExcludes ); Set matchingSources = new HashSet( potentialSources != null ? potentialSources.length : 0 ); if ( potentialSources != null ) { for ( String potentialSource : potentialSources ) { matchingSources.add( new File( sourceDir, potentialSource ) ); } } return matchingSources; } } SourceInclusionScanner.java000066400000000000000000000022251241507501400430270ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scanpackage org.codehaus.plexus.compiler.util.scan; /* * Copyright 2001-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping; import java.io.File; import java.util.Set; /** * @author jdcasey */ public interface SourceInclusionScanner { void addSourceMapping( SourceMapping sourceMapping ); /** * @param sourceDir * @param targetDir * @return Set of File objects * @throws InclusionScanException */ Set getIncludedSources( File sourceDir, File targetDir ) throws InclusionScanException; } StaleSourceScanner.java000066400000000000000000000066661241507501400421510ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scanpackage org.codehaus.plexus.compiler.util.scan; /* * Copyright 2001-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * 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; /** * @author jdcasey */ public class StaleSourceScanner extends AbstractSourceInclusionScanner { private final long lastUpdatedWithinMsecs; private final Set sourceIncludes; private final Set sourceExcludes; // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public StaleSourceScanner() { this( 0, Collections.singleton( "**/*" ), Collections.emptySet() ); } public StaleSourceScanner( long lastUpdatedWithinMsecs ) { this( lastUpdatedWithinMsecs, Collections.singleton( "**/*" ), Collections.emptySet() ); } public StaleSourceScanner( long lastUpdatedWithinMsecs, Set sourceIncludes, Set sourceExcludes ) { this.lastUpdatedWithinMsecs = lastUpdatedWithinMsecs; this.sourceIncludes = sourceIncludes; this.sourceExcludes = sourceExcludes; } // ---------------------------------------------------------------------- // SourceInclusionScanner Implementation // ---------------------------------------------------------------------- public Set getIncludedSources( File sourceDir, File targetDir ) throws InclusionScanException { List srcMappings = getSourceMappings(); if ( srcMappings.isEmpty() ) { return Collections.emptySet(); } String[] potentialIncludes = scanForSources( sourceDir, sourceIncludes, sourceExcludes ); Set matchingSources = new HashSet(); for ( String path : potentialIncludes ) { File sourceFile = new File( sourceDir, path ); staleSourceFileTesting: 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 ); break staleSourceFileTesting; } } } } return matchingSources; } } 000077500000000000000000000000001241507501400371605ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mappingSingleTargetSourceMapping.java000066400000000000000000000040621241507501400451120ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mappingpackage org.codehaus.plexus.compiler.util.scan.mapping; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ 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 { private String sourceSuffix; private 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 ) ) { return Collections.emptySet(); } return Collections.singleton( new File( targetDir, outputFile ) ); } } SourceMapping.java000066400000000000000000000016751241507501400426100ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mappingpackage org.codehaus.plexus.compiler.util.scan.mapping; /* * Copyright 2001-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.codehaus.plexus.compiler.util.scan.InclusionScanException; import java.io.File; import java.util.Set; /** * @author jdcasey */ public interface SourceMapping { Set getTargetFiles( File targetDir, String source ) throws InclusionScanException; } SuffixMapping.java000066400000000000000000000034541241507501400426110ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mappingpackage org.codehaus.plexus.compiler.util.scan.mapping; /* * Copyright 2001-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.File; import java.util.Collections; import java.util.HashSet; import java.util.Set; /** * @author jdcasey */ public final class SuffixMapping implements SourceMapping { private final String sourceSuffix; private final Set targetSuffixes; public SuffixMapping( String sourceSuffix, String targetSuffix ) { this.sourceSuffix = sourceSuffix; this.targetSuffixes = Collections.singleton( targetSuffix ); } public SuffixMapping( String sourceSuffix, Set targetSuffixes ) { this.sourceSuffix = sourceSuffix; this.targetSuffixes = Collections.unmodifiableSet( targetSuffixes ); } public Set getTargetFiles( File targetDir, String source ) { Set targetFiles = new HashSet(); if ( source.endsWith( sourceSuffix ) ) { String base = source.substring( 0, source.length() - sourceSuffix.length() ); for ( String suffix : targetSuffixes ) { targetFiles.add( new File( targetDir, base + suffix ) ); } } return targetFiles; } } plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/site/000077500000000000000000000000001241507501400252665ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/site/site.xml000066400000000000000000000011261241507501400267540ustar00rootroot00000000000000

plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/000077500000000000000000000000001241507501400253015ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/java/000077500000000000000000000000001241507501400262225ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/java/org/000077500000000000000000000000001241507501400270115ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/java/org/codehaus/000077500000000000000000000000001241507501400306045ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/java/org/codehaus/plexus/000077500000000000000000000000001241507501400321245ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/000077500000000000000000000000001241507501400337365ustar00rootroot00000000000000000077500000000000000000000000001241507501400346345ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util000077500000000000000000000000001241507501400355605ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scanAbstractSourceInclusionScannerTest.java000066400000000000000000000066431241507501400454160ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scanpackage org.codehaus.plexus.compiler.util.scan; /* * Copyright 2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.net.URL; import java.util.Set; import junit.framework.TestCase; import org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping; import org.codehaus.plexus.util.IOUtil; /** * Tests for all the implementations of SourceInclusionScanner * * @author Carlos Sanchez */ public abstract class AbstractSourceInclusionScannerTest extends TestCase { private static final String TESTFILE_DEST_MARKER_FILE = SourceInclusionScanner.class.getName().replace( '.', '/' ) + "-testMarker.txt"; protected SourceInclusionScanner scanner; public void testGetIncludedSources() throws Exception { File base = new File( getTestBaseDir(), "testGetIncludedSources" ); File sourceFile = new File( base, "file.java" ); writeFile( sourceFile ); sourceFile.setLastModified( System.currentTimeMillis() ); SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); scanner.addSourceMapping( mapping ); Set includedSources = scanner.getIncludedSources( base, base ); assertTrue( "no sources were included", !includedSources.isEmpty() ); for ( File file : includedSources ) { assertTrue( "file included does not exist", file.exists() ); } } // ---------------------------------------------------------------------- // Utilities // ---------------------------------------------------------------------- protected File getTestBaseDir() { ClassLoader cl = Thread.currentThread().getContextClassLoader(); URL markerResource = cl.getResource( TESTFILE_DEST_MARKER_FILE ); File basedir; if ( markerResource != null ) { File marker = new File( markerResource.getPath() ); basedir = marker.getParentFile().getAbsoluteFile(); } else { // punt. System.out.println( "Cannot find marker file: \'" + TESTFILE_DEST_MARKER_FILE + "\' in classpath. " + "Using '.' for basedir." ); basedir = new File( "." ).getAbsoluteFile(); } return basedir; } protected void writeFile( File file ) throws IOException { FileWriter fWriter = null; try { File parent = file.getParentFile(); if ( !parent.exists() ) { parent.mkdirs(); } file.deleteOnExit(); fWriter = new FileWriter( file ); fWriter.write( "This is just a test file." ); } finally { IOUtil.close( fWriter ); } } } SimpleSourceInclusionScannerTest.java000066400000000000000000000023241241507501400450740ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scanpackage org.codehaus.plexus.compiler.util.scan; /* * Copyright 2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.Collections; import java.util.HashSet; import java.util.Set; /** * Test for * * @author Carlos Sanchez */ public class SimpleSourceInclusionScannerTest extends AbstractSourceInclusionScannerTest { private Set includes, excludes; protected void setUp() throws Exception { super.setUp(); includes = Collections.singleton( "*.java" ); excludes = new HashSet(); scanner = new SimpleSourceInclusionScanner( includes, excludes ); } } StaleSourceScannerTest.java000066400000000000000000000345201241507501400430320ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scanpackage org.codehaus.plexus.compiler.util.scan; /* * Copyright 2001-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.File; import java.util.Collections; import java.util.Set; import org.codehaus.plexus.compiler.util.scan.mapping.SingleTargetSourceMapping; import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping; import org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping; /** * @author jdcasey * @author Trygve Laugstøl */ public class StaleSourceScannerTest extends AbstractSourceInclusionScannerTest { protected void setUp() throws Exception { super.setUp(); scanner = new StaleSourceScanner(); } // test 1. public void testWithDefaultConstructorShouldFindOneStaleSource() throws Exception { File base = new File( getTestBaseDir(), "test1" ); long now = System.currentTimeMillis(); File targetFile = new File( base, "file.xml" ); writeFile( targetFile ); targetFile.setLastModified( now - 60000 ); File sourceFile = new File( base, "file.java" ); writeFile( sourceFile ); sourceFile.setLastModified( now ); SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); scanner.addSourceMapping( mapping ); Set result = scanner.getIncludedSources( base, base ); assertEquals( "wrong number of stale sources returned.", 1, result.size() ); assertTrue( "expected stale source file not found in result", result.contains( sourceFile ) ); } // test 2. public void testWithDefaultConstructorShouldNotFindStaleSources() throws Exception { File base = new File( getTestBaseDir(), "test2" ); long now = System.currentTimeMillis(); File sourceFile = new File( base, "file.java" ); writeFile( sourceFile ); sourceFile.setLastModified( now - 60000 ); File targetFile = new File( base, "file.xml" ); writeFile( targetFile ); targetFile.setLastModified( now ); SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); scanner.addSourceMapping( mapping ); Set result = scanner.getIncludedSources( base, base ); assertEquals( "wrong number of stale sources returned.", 0, result.size() ); assertFalse( "expected stale source file not found in result", result.contains( sourceFile ) ); } // test 3. public void testWithDefaultConstructorShouldFindStaleSourcesBecauseOfMissingTargetFile() throws Exception { File base = new File( getTestBaseDir(), "test3" ); File sourceFile = new File( base, "file.java" ); writeFile( sourceFile ); SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); scanner.addSourceMapping( mapping ); Set result = scanner.getIncludedSources( base, base ); assertEquals( "wrong number of stale sources returned.", 1, result.size() ); assertTrue( "expected stale source file not found in result", result.contains( sourceFile ) ); } // test 4. public void testWithDefaultConstructorShouldFindStaleSourcesOneBecauseOfMissingTargetAndOneBecauseOfStaleTarget() throws Exception { File base = new File( getTestBaseDir(), "test4" ); long now = System.currentTimeMillis(); File targetFile = new File( base, "file2.xml" ); writeFile( targetFile ); targetFile.setLastModified( now - 60000 ); File sourceFile = new File( base, "file.java" ); writeFile( sourceFile ); File sourceFile2 = new File( base, "file2.java" ); writeFile( sourceFile2 ); sourceFile2.setLastModified( now ); SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); scanner.addSourceMapping( mapping ); Set result = scanner.getIncludedSources( base, base ); assertEquals( "wrong number of stale sources returned.", 2, result.size() ); assertTrue( "expected stale source file not found in result", result.contains( sourceFile ) ); assertTrue( "expected stale source file not found in result", result.contains( sourceFile2 ) ); } // test 5. public void testWithDefaultConstructorShouldFindOneStaleSourcesWithStaleTargetAndOmitUpToDateSource() throws Exception { File base = new File( getTestBaseDir(), "test5" ); long now = System.currentTimeMillis(); // target/source (1) should result in source being included. // 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" ); writeFile( targetFile ); targetFile.setLastModified( now - 60000 ); // now write the source file, and set the lastmod to now. File sourceFile = new File( base, "file.java" ); writeFile( sourceFile ); 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" ); writeFile( sourceFile2 ); sourceFile2.setLastModified( now - 60000 ); // now write the target file, with lastmod of now. File targetFile2 = new File( base, "file2.xml" ); writeFile( targetFile2 ); targetFile2.setLastModified( now ); SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); scanner.addSourceMapping( mapping ); Set result = scanner.getIncludedSources( base, base ); assertEquals( "wrong number of stale sources returned.", 1, result.size() ); assertTrue( "expected stale source file not found in result", result.contains( sourceFile ) ); } // test 6. public void testConstructedWithMsecsShouldReturnOneSourceFileOfTwoDueToLastMod() throws Exception { File base = new File( getTestBaseDir(), "test6" ); long now = System.currentTimeMillis(); File targetFile = new File( base, "file.xml" ); writeFile( targetFile ); // should be within the threshold of lastMod for stale sources. targetFile.setLastModified( now - 8000 ); File sourceFile = new File( base, "file.java" ); writeFile( sourceFile ); // modified 'now' for comparison with the above target file. sourceFile.setLastModified( now ); File targetFile2 = new File( base, "file2.xml" ); writeFile( targetFile2 ); targetFile2.setLastModified( now - 12000 ); File sourceFile2 = new File( base, "file2.java" ); writeFile( sourceFile2 ); // modified 'now' for comparison to above target file. sourceFile2.setLastModified( now ); SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); scanner = new StaleSourceScanner( 10000 ); scanner.addSourceMapping( mapping ); Set result = scanner.getIncludedSources( base, base ); assertEquals( "wrong number of stale sources returned.", 1, result.size() ); assertTrue( "expected stale source file not found in result", result.contains( sourceFile2 ) ); assertFalse( "expected stale source file not found in result", result.contains( sourceFile ) ); } // test 7. public void testConstructedWithMsecsIncludesAndExcludesShouldReturnOneSourceFileOfThreeDueToIncludePattern() throws Exception { File base = new File( getTestBaseDir(), "test7" ); long now = System.currentTimeMillis(); File targetFile = new File( base, "file.xml" ); writeFile( targetFile ); // should be within the threshold of lastMod for stale sources. targetFile.setLastModified( now - 12000 ); File sourceFile = new File( base, "file.java" ); writeFile( sourceFile ); // modified 'now' for comparison with the above target file. sourceFile.setLastModified( now ); File targetFile2 = new File( base, "file2.xml" ); writeFile( targetFile2 ); targetFile2.setLastModified( now - 12000 ); File sourceFile2 = new File( base, "file2.java" ); writeFile( sourceFile2 ); // modified 'now' for comparison to above target file. sourceFile2.setLastModified( now ); File targetFile3 = new File( base, "file3.xml" ); writeFile( targetFile3 ); targetFile3.setLastModified( now - 12000 ); File sourceFile3 = new File( base, "file3.java" ); writeFile( sourceFile3 ); // modified 'now' for comparison to above target file. sourceFile3.setLastModified( now ); SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); scanner = new StaleSourceScanner( 0, Collections.singleton( "*3.java" ), Collections.emptySet() ); scanner.addSourceMapping( mapping ); Set result = scanner.getIncludedSources( base, base ); assertEquals( "wrong number of stale sources returned.", 1, result.size() ); assertFalse( "expected stale source file not found in result", result.contains( sourceFile ) ); assertFalse( "unexpected stale source file found in result", result.contains( sourceFile2 ) ); assertTrue( "unexpected stale source file found in result", result.contains( sourceFile3 ) ); } // test 8. public void testConstructedWithMsecsIncludesAndExcludesShouldReturnTwoSourceFilesOfThreeDueToExcludePattern() throws Exception { File base = new File( getTestBaseDir(), "test8" ); long now = System.currentTimeMillis(); File targetFile = new File( base, "fileX.xml" ); writeFile( targetFile ); // should be within the threshold of lastMod for stale sources. targetFile.setLastModified( now - 12000 ); File sourceFile = new File( base, "fileX.java" ); writeFile( sourceFile ); // modified 'now' for comparison with the above target file. sourceFile.setLastModified( now ); File targetFile2 = new File( base, "file2.xml" ); writeFile( targetFile2 ); targetFile2.setLastModified( now - 12000 ); File sourceFile2 = new File( base, "file2.java" ); writeFile( sourceFile2 ); // modified 'now' for comparison to above target file. sourceFile2.setLastModified( now ); File targetFile3 = new File( base, "file3.xml" ); writeFile( targetFile3 ); targetFile3.setLastModified( now - 12000 ); File sourceFile3 = new File( base, "file3.java" ); writeFile( sourceFile3 ); // modified 'now' for comparison to above target file. sourceFile3.setLastModified( now ); SuffixMapping mapping = new SuffixMapping( ".java", ".xml" ); scanner = new StaleSourceScanner( 0, Collections.singleton( "**/*" ), Collections.singleton( "*X.*" ) ); scanner.addSourceMapping( mapping ); Set result = scanner.getIncludedSources( base, base ); assertEquals( "wrong number of stale sources returned.", 2, result.size() ); assertFalse( "unexpected stale source file found in result", result.contains( sourceFile ) ); assertTrue( "expected stale source not file found in result", result.contains( sourceFile2 ) ); assertTrue( "expected stale source not file found in result", result.contains( sourceFile3 ) ); } // test 9. public void testSingleFileSourceMapping() throws Exception { File src = new File( getTestBaseDir(), "test9-src" ); File target = new File( getTestBaseDir(), "test9-target" ); long now = System.currentTimeMillis(); // ---------------------------------------------------------------------- // The output file is missing // ---------------------------------------------------------------------- File fooCs = new File( src, "Foo.cs" ); writeFile( fooCs ); fooCs.setLastModified( now - 10000 ); SourceMapping mapping = new SingleTargetSourceMapping( ".cs", "Application.exe" ); scanner = new StaleSourceScanner( 0 ); scanner.addSourceMapping( mapping ); Set result = scanner.getIncludedSources( src, target ); assertEquals( 1, result.size() ); assertTrue( result.contains( fooCs ) ); // ---------------------------------------------------------------------- // Add another source file // ---------------------------------------------------------------------- File barCs = new File( src, "Bar.cs" ); writeFile( barCs ); barCs.setLastModified( now - 20000 ); result = scanner.getIncludedSources( src, target ); assertEquals( 2, result.size() ); assertTrue( result.contains( fooCs ) ); assertTrue( result.contains( barCs ) ); // ---------------------------------------------------------------------- // Now add the result file // ---------------------------------------------------------------------- File applicationExe = new File( target, "Application.exe" ); writeFile( applicationExe ); applicationExe.setLastModified( now ); result = scanner.getIncludedSources( src, target ); assertEquals( 0, result.size() ); // ---------------------------------------------------------------------- // Make Application.exe older than the Foo.cs // ---------------------------------------------------------------------- applicationExe.setLastModified( now - 15000 ); result = scanner.getIncludedSources( src, target ); assertEquals( 1, result.size() ); assertTrue( result.contains( fooCs ) ); } } 000077500000000000000000000000001241507501400372135ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/mappingSuffixMappingTest.java000066400000000000000000000073201241507501400435000ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/java/org/codehaus/plexus/compiler/util/scan/mappingpackage org.codehaus.plexus.compiler.util.scan.mapping; /* * Copyright 2001-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import junit.framework.TestCase; import org.codehaus.plexus.compiler.util.scan.InclusionScanException; import java.io.File; import java.util.HashSet; import java.util.Set; /** * @author jdcasey */ public class SuffixMappingTest extends TestCase { public void testShouldReturnSingleClassFileForSingleJavaFile() throws InclusionScanException { String base = "path/to/file"; File basedir = new File( "." ); SuffixMapping mapping = new SuffixMapping( ".java", ".class" ); Set results = mapping.getTargetFiles( basedir, base + ".java" ); assertEquals( "Returned wrong number of target files.", 1, results.size() ); assertEquals( "Target file is wrong.", new File( basedir, base + ".class" ), results.iterator().next() ); } public void testShouldNotReturnClassFileWhenSourceFileHasWrongSuffix() throws InclusionScanException { String base = "path/to/file"; File basedir = new File( "." ); SuffixMapping mapping = new SuffixMapping( ".java", ".class" ); Set results = mapping.getTargetFiles( basedir, base + ".xml" ); assertTrue( "Returned wrong number of target files.", results.isEmpty() ); } public void testShouldReturnOneClassFileAndOneXmlFileForSingleJavaFile() throws InclusionScanException { String base = "path/to/file"; File basedir = new File( "." ); Set targets = new HashSet(); targets.add( ".class" ); targets.add( ".xml" ); SuffixMapping mapping = new SuffixMapping( ".java", targets ); Set results = mapping.getTargetFiles( basedir, base + ".java" ); assertEquals( "Returned wrong number of target files.", 2, results.size() ); assertTrue( "Targets do not contain class target.", results.contains( new File( basedir, base + ".class" ) ) ); assertTrue( "Targets do not contain class target.", results.contains( new File( basedir, base + ".xml" ) ) ); } public void testShouldReturnNoTargetFilesWhenSourceFileHasWrongSuffix() throws InclusionScanException { String base = "path/to/file"; File basedir = new File( "." ); Set targets = new HashSet(); targets.add( ".class" ); targets.add( ".xml" ); SuffixMapping mapping = new SuffixMapping( ".java", targets ); Set results = mapping.getTargetFiles( basedir, base + ".apt" ); assertTrue( "Returned wrong number of target files.", results.isEmpty() ); } public void testSingleTargetMapper() throws InclusionScanException { String base = "path/to/file"; File basedir = new File( "target/" ); SingleTargetSourceMapping mapping = new SingleTargetSourceMapping( ".cs", "/foo" ); Set results = mapping.getTargetFiles( basedir, base + ".apt" ); assertTrue( results.isEmpty() ); results = mapping.getTargetFiles( basedir, base + ".cs" ); assertEquals( 1, results.size() ); } } plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/resources/000077500000000000000000000000001241507501400273135ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/resources/org/000077500000000000000000000000001241507501400301025ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/resources/org/codehaus/000077500000000000000000000000001241507501400316755ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/resources/org/codehaus/plexus/000077500000000000000000000000001241507501400332155ustar00rootroot00000000000000000077500000000000000000000000001241507501400347505ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/resources/org/codehaus/plexus/compiler000077500000000000000000000000001241507501400357255ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/resources/org/codehaus/plexus/compiler/util000077500000000000000000000000001241507501400366515ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/resources/org/codehaus/plexus/compiler/util/scanSourceInclusionScanner-testMarker.txt000066400000000000000000000000621241507501400461650ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/test/resources/org/codehaus/plexus/compiler/util/scanmarker for finding this location on the classpath.plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/000077500000000000000000000000001241507501400243745ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/pom.xml000066400000000000000000000012621241507501400257120ustar00rootroot00000000000000 4.0.0 org.codehaus.plexus plexus-compiler 2.4 plexus-compiler-manager Plexus Compiler Manager org.codehaus.plexus plexus-compiler-api plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/000077500000000000000000000000001241507501400251635ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/main/000077500000000000000000000000001241507501400261075ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/main/java/000077500000000000000000000000001241507501400270305ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/main/java/org/000077500000000000000000000000001241507501400276175ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/main/java/org/codehaus/000077500000000000000000000000001241507501400314125ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/main/java/org/codehaus/plexus/000077500000000000000000000000001241507501400327325ustar00rootroot00000000000000000077500000000000000000000000001241507501400344655ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler000077500000000000000000000000001241507501400360775ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/managerCompilerManager.java000066400000000000000000000027231241507501400420130ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/managerpackage org.codehaus.plexus.compiler.manager; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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 { String ROLE = CompilerManager.class.getName(); Compiler getCompiler( String compilerId ) throws NoSuchCompilerException; } DefaultCompilerManager.java000066400000000000000000000041431241507501400433160ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/managerpackage org.codehaus.plexus.compiler.manager; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import org.codehaus.plexus.compiler.Compiler; import org.codehaus.plexus.logging.AbstractLogEnabled; import java.util.Map; /** * @author Trygve Laugstøl * @plexus.component */ public class DefaultCompilerManager extends AbstractLogEnabled implements CompilerManager { /** * @plexus.requirement role="org.codehaus.plexus.compiler.Compiler" */ private Map compilers; // ---------------------------------------------------------------------- // CompilerManager Implementation // ---------------------------------------------------------------------- public Compiler getCompiler( String compilerId ) throws NoSuchCompilerException { Compiler compiler = compilers.get( compilerId ); if ( compiler == null ) { throw new NoSuchCompilerException( compilerId ); } return compiler; } } NoSuchCompilerException.java000066400000000000000000000031121241507501400435100ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/managerpackage org.codehaus.plexus.compiler.manager; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /** * @author Trygve Laugstøl */ public class NoSuchCompilerException extends Exception { private final String compilerId; public NoSuchCompilerException( String compilerId ) { super( "No such compiler '" + compilerId + "'." ); this.compilerId = compilerId; } public String getCompilerId() { return compilerId; } } plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/site/000077500000000000000000000000001241507501400261275ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/site/site.xml000066400000000000000000000011261241507501400276150ustar00rootroot00000000000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/test/000077500000000000000000000000001241507501400261425ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/test/java/000077500000000000000000000000001241507501400270635ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/test/java/org/000077500000000000000000000000001241507501400276525ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/test/java/org/codehaus/000077500000000000000000000000001241507501400314455ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/test/java/org/codehaus/plexus/000077500000000000000000000000001241507501400327655ustar00rootroot00000000000000000077500000000000000000000000001241507501400345205ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/test/java/org/codehaus/plexus/compiler000077500000000000000000000000001241507501400361325ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/test/java/org/codehaus/plexus/compiler/managerCompilerManagerTest.java000066400000000000000000000033411241507501400427030ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-manager/src/test/java/org/codehaus/plexus/compiler/managerpackage org.codehaus.plexus.compiler.manager; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import org.codehaus.plexus.PlexusTestCase; /** * @author Trygve Laugstøl */ public class CompilerManagerTest extends PlexusTestCase { public void testBasic() throws Exception { CompilerManager compilerManager = (CompilerManager) lookup( CompilerManager.ROLE ); try { compilerManager.getCompiler( "foo" ); fail( "Expected NoSuchCompilerException" ); } catch ( NoSuchCompilerException e ) { // ignored } } } plexus-compiler-plexus-compiler-2.4/plexus-compiler-test/000077500000000000000000000000001241507501400237415ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-test/pom.xml000066400000000000000000000035451241507501400252650ustar00rootroot00000000000000 4.0.0 org.codehaus.plexus plexus-compiler 2.4 plexus-compiler-test Plexus Compiler Test Harness org.codehaus.plexus plexus-compiler-api junit junit compile org.apache.maven maven-artifact-test 2.0.10 org.apache.maven maven-artifact 2.0 org.apache.maven maven-artifact-manager 2.0 org.apache.maven maven-settings 2.0 org.codehaus.plexus plexus-utils commons-lang commons-lang 2.0 runtime plexus-compiler-plexus-compiler-2.4/plexus-compiler-test/src/000077500000000000000000000000001241507501400245305ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-test/src/main/000077500000000000000000000000001241507501400254545ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-test/src/main/java/000077500000000000000000000000001241507501400263755ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-test/src/main/java/org/000077500000000000000000000000001241507501400271645ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-test/src/main/java/org/codehaus/000077500000000000000000000000001241507501400307575ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-test/src/main/java/org/codehaus/plexus/000077500000000000000000000000001241507501400322775ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-test/src/main/java/org/codehaus/plexus/compiler/000077500000000000000000000000001241507501400341115ustar00rootroot00000000000000AbstractCompilerTckTest.java000066400000000000000000000145701241507501400414440ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-test/src/main/java/org/codehaus/plexus/compilerpackage org.codehaus.plexus.compiler; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.util.FileUtils; import java.io.File; import java.io.IOException; import java.util.List; /** * @author Trygve Laugstøl */ public abstract class AbstractCompilerTckTest extends PlexusTestCase { private static final String EOL = System.getProperty( "line.separator" ); private String roleHint; protected AbstractCompilerTckTest( String roleHint ) { this.roleHint = roleHint; } public void testDeprecation() throws Exception { File foo = new File( getSrc(), "Foo.java" ); writeFileWithDeprecatedApi( foo, "Foo" ); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- CompilerConfiguration configuration = new CompilerConfiguration(); configuration.setShowDeprecation( true ); configuration.addSourceLocation( getSrc().getAbsolutePath() ); List result = compile( configuration ); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- assertEquals( 1, result.size() ); CompilerMessage error = result.get( 0 ); System.out.println( error.getMessage() ); assertFalse( error.isError() ); assertTrue( error.getMessage().indexOf( "Date" ) != -1 ); assertTrue( error.getMessage().indexOf( "deprecated" ) != -1 ); } public void testWarning() throws Exception { File foo = new File( getSrc(), "Foo.java" ); writeFileWithWarning( foo, "Foo" ); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- CompilerConfiguration configuration = new CompilerConfiguration(); configuration.setShowWarnings( true ); configuration.addSourceLocation( getSrc().getAbsolutePath() ); List result = compile( configuration ); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- assertEquals( 1, result.size() ); CompilerMessage error = result.get( 0 ); assertFalse( error.isError() ); assertTrue( error.getMessage().indexOf( "finally block does not complete normally" ) != -1 ); } protected List compile( CompilerConfiguration configuration ) throws Exception { // ---------------------------------------------------------------------- // Set up configuration // ---------------------------------------------------------------------- File compilerOutput = getCompilerOutput(); if ( compilerOutput.exists() ) { FileUtils.deleteDirectory( compilerOutput ); } configuration.setOutputLocation( compilerOutput.getAbsolutePath() ); // ---------------------------------------------------------------------- // Compile! // ---------------------------------------------------------------------- Compiler compiler = (Compiler) lookup( Compiler.ROLE, roleHint ); List result = compiler.performCompile( configuration ).getCompilerMessages(); assertNotNull( result ); return result; } private File getCompilerOutput() { return getTestFile( "target/compiler-output/" + getName() ); } private File getSrc() { return getTestFile( "target/compiler-src/" + getName() ); } protected void writeFileWithDeprecatedApi( File path, String className ) throws IOException { File parent = path.getParentFile(); if ( !parent.exists() ) { assertTrue( parent.mkdirs() ); } 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 { File parent = path.getParentFile(); if ( !parent.exists() ) { assertTrue( parent.mkdirs() ); } 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 ); } } AbstractCompilerTest.java000066400000000000000000000211361241507501400407760ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-test/src/main/java/org/codehaus/plexus/compilerpackage org.codehaus.plexus.compiler; /** * The MIT License * * Copyright (c) 2004, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.DefaultArtifactHandler; import org.apache.maven.artifact.test.ArtifactTestCase; import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.plexus.util.FileUtils; 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.TreeSet; /** * */ public abstract class AbstractCompilerTest extends ArtifactTestCase { private boolean compilerDebug = false; private boolean compilerDeprecationWarnings = false; private boolean forceJavacCompilerUse = false; protected abstract String getRoleHint(); protected void setCompilerDebug( boolean flag ) { compilerDebug = flag; } protected void setCompilerDeprecationWarnings( boolean flag ) { compilerDeprecationWarnings = flag; } public void setForceJavacCompilerUse( boolean forceJavacCompilerUse ) { this.forceJavacCompilerUse = forceJavacCompilerUse; } protected List getClasspath() throws Exception { List cp = new ArrayList(); File file = getLocalArtifactPath( "commons-lang", "commons-lang", "2.0", "jar" ); assertTrue( "test prerequisite: commons-lang library must be available in local repository, expected " + file.getAbsolutePath(), file.canRead() ); cp.add( file.getAbsolutePath() ); return cp; } @SuppressWarnings( "unchecked" ) public void testCompilingSources() throws Exception { List messages = new ArrayList(); Collection files = new TreeSet(); for ( CompilerConfiguration compilerConfig : getCompilerConfigurations() ) { File outputDir = new File( compilerConfig.getOutputLocation() ); Compiler compiler = (Compiler) lookup( Compiler.ROLE, getRoleHint() ); messages.addAll( compiler.performCompile( compilerConfig ).getCompilerMessages() ); if ( outputDir.isDirectory() ) { files.addAll( normalizePaths( FileUtils.getFileNames( outputDir, null, null, false ) ) ); } } int numCompilerErrors = compilerErrorCount( messages ); int numCompilerWarnings = messages.size() - numCompilerErrors; if ( expectedErrors() != numCompilerErrors ) { System.out.println( numCompilerErrors + " error(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( "----" ); } assertEquals( "Wrong number of compilation errors.", expectedErrors(), numCompilerErrors ); } if ( expectedWarnings() != numCompilerWarnings ) { 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( "----" ); } assertEquals( "Wrong number of compilation warnings.", expectedWarnings(), numCompilerWarnings ); } assertEquals( new TreeSet( normalizePaths( expectedOutputFiles() ) ), files ); } private List getCompilerConfigurations() throws Exception { String sourceDir = getBasedir() + "/src/test-input/src/main"; @SuppressWarnings( "unchecked" ) 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++ ) { String filename = it.next(); CompilerConfiguration compilerConfig = new CompilerConfiguration(); compilerConfig.setDebug( compilerDebug ); compilerConfig.setShowDeprecation( compilerDeprecationWarnings ); compilerConfig.setClasspathEntries( getClasspath() ); compilerConfig.addSourceLocation( sourceDir ); compilerConfig.setOutputLocation( getBasedir() + "/target/" + getRoleHint() + "/classes-" + index ); FileUtils.deleteDirectory( compilerConfig.getOutputLocation() ); compilerConfig.addInclude( filename ); compilerConfig.setForceJavacCompilerUse( this.forceJavacCompilerUse ); //compilerConfig.setTargetVersion( "1.5" ); //compilerConfig.setSourceVersion( "1.5" ); compilerConfigurations.add( compilerConfig ); } return compilerConfigurations; } private List normalizePaths( Collection relativePaths ) { List normalizedPaths = new ArrayList(); for ( String relativePath : relativePaths ) { normalizedPaths.add( relativePath.replace( File.separatorChar, '/' ) ); } return normalizedPaths; } protected int compilerErrorCount( List messages ) { int count = 0; for ( CompilerMessage message : messages ) { count += message.isError() ? 1 : 0; } return count; } protected int expectedErrors() { return 1; } protected int expectedWarnings() { return 0; } protected Collection expectedOutputFiles() { return Collections.emptyList(); } 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 ) ); return getLocalArtifactPath( artifact ); } protected String getJavaVersion() { String javaVersion = System.getProperty( "java.version" ); String realJavaVersion = javaVersion; 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 ); } } System.out.println( "java.version is: " + realJavaVersion + "\ntrimmed java version is: " + javaVersion + "\ncomparison: \"1.5\".compareTo( \"" + javaVersion + "\" ) == " + ( "1.5".compareTo( javaVersion ) ) + "\n" ); return javaVersion; } } plexus-compiler-plexus-compiler-2.4/plexus-compiler-test/src/site/000077500000000000000000000000001241507501400254745ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compiler-test/src/site/site.xml000066400000000000000000000011261241507501400271620ustar00rootroot00000000000000 plexus-compiler-plexus-compiler-2.4/plexus-compilers/000077500000000000000000000000001241507501400231475ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/000077500000000000000000000000001241507501400277265ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/pom.xml000066400000000000000000000027151241507501400312500ustar00rootroot00000000000000 4.0.0 org.codehaus.plexus plexus-compilers 2.4 plexus-compiler-aspectj Plexus AspectJ Compiler AspectJ Compiler support for Plexus Compiler component. 1.7.1 org.aspectj aspectjrt ${aspectj.version} org.aspectj aspectjtools ${aspectj.version} org.apache.maven.plugins maven-surefire-plugin ${aspectj.version} plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/000077500000000000000000000000001241507501400305155ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/main/000077500000000000000000000000001241507501400314415ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/main/java/000077500000000000000000000000001241507501400323625ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/000077500000000000000000000000001241507501400331515ustar00rootroot00000000000000000077500000000000000000000000001241507501400346655ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus000077500000000000000000000000001241507501400362055ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus000077500000000000000000000000001241507501400400175ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler000077500000000000000000000000001241507501400405545ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajcAspectJCompiler.java000066400000000000000000000443461241507501400444560ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajcpackage org.codehaus.plexus.compiler.ajc; import org.aspectj.ajdt.internal.core.builder.AjBuildConfig; import org.aspectj.ajdt.internal.core.builder.AjBuildManager; import org.aspectj.bridge.AbortException; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.ISourceLocation; import org.aspectj.bridge.MessageHandler; import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; 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 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.LinkedList; import java.util.List; import java.util.Map; /** *

* Options *

* -injars JarList *

* Accept as source bytecode any .class files inside the specified .jar files. The output will include these * classes, possibly as woven with any applicable aspects. JarList, like classpath, is a single argument * containing a list of paths to jar files, delimited by the platform- specific classpath delimiter. *

* -aspectpath JarList *

* Weave binary aspects from JarList zip files into all sources. The aspects should have been output by * the same version of the compiler. To run the output classes requires putting all the aspectpath entries on * the run classpath. JarList, like classpath, is a single argument containing a list of paths to jar files, * delimited by the platform- specific classpath delimiter. *

* -argfile File *

* The file is a line-delimited list of arguments. These arguments are inserted into the argument list. *

* -outjar output.jar *

* Put output classes in zip file output.jar. *

* -incremental *

* Run the compiler continuously. After the initial compilation, the compiler will wait to recompile until it * reads a newline from the standard input, and will quit when it reads a 'q'. It will only recompile necessary * components, so a recompile should be much faster than doing a second compile. This requires -sourceroots. *

* -sourceroots DirPaths *

* Find and build all .java or .aj source files under any directory listed in DirPaths. DirPaths, like * classpath, is a single argument containing a list of paths to directories, delimited by the platform- * specific classpath delimiter. Required by -incremental. *

* -emacssym *

* Generate .ajesym symbol files for emacs support *

* -Xlint *

* Same as -Xlint:warning (enabled by default) *

* -Xlint:{level} *

* Set default level for messages about potential programming mistakes in crosscutting code. {level} may be * ignore, warning, or error. This overrides entries in org/aspectj/weaver/XlintDefault.properties from * aspectjtools.jar, but does not override levels set using the -Xlintfile option. *

* -Xlintfile PropertyFile *

* Specify properties file to set levels for specific crosscutting messages. PropertyFile is a path to a * Java .properties file that takes the same property names and values as * org/aspectj/weaver/XlintDefault.properties from aspectjtools.jar, which it also overrides. * -help *

* Emit information on compiler options and usage *

* -version *

* Emit the version of the AspectJ compiler *

* -classpath Path *

* Specify where to find user class files. Path is a single argument containing a list of paths to zip files * or directories, delimited by the platform-specific path delimiter. *

* -bootclasspath Path *

* Override location of VM's bootclasspath for purposes of evaluating types when compiling. Path is a single * argument containing a list of paths to zip files or directories, delimited by the platform-specific path * delimiter. *

* -extdirs Path *

* Override location of VM's extension directories for purposes of evaluating types when compiling. Path is * a single argument containing a list of paths to directories, delimited by the platform-specific path * delimiter. *

* -d Directory *

* Specify where to place generated .class files. If not specified, Directory defaults to the current * working dir. *

* -target [1.1|1.2] *

* Specify classfile target setting (1.1 or 1.2, default is 1.1) *

* -1.3 *

* Set compliance level to 1.3 (default) * -1.4 *

* Set compliance level to 1.4 * -source [1.3|1.4] *

* Toggle assertions (1.3 or 1.4, default is 1.3 in -1.3 mode and 1.4 in -1.4 mode). When using -source 1.3, * an assert() statement valid under Java 1.4 will result in a compiler error. When using -source 1.4, treat * assert as a keyword and implement assertions according to the 1.4 language spec. *

* -nowarn *

* Emit no warnings (equivalent to '-warn:none') This does not suppress messages generated by declare warning * or Xlint. *

* -warn: items *

* Emit warnings for any instances of the comma-delimited list of questionable code * (eg '-warn:unusedLocals,deprecation'): *

* constructorName method with constructor name * packageDefaultMethod attempt to override package-default method * deprecation usage of deprecated type or member * maskedCatchBlocks hidden catch block * unusedLocals local variable never read * unusedArguments method argument never read * unusedImports import statement not used by code in file * none suppress all compiler warnings *

*

* -warn:none does not suppress messages generated by declare warning or Xlint. *

* -deprecation *

* Same as -warn:deprecation *

* -noImportError *

* Emit no errors for unresolved imports *

* -proceedOnError *

* Keep compiling after error, dumping class files with problem methods *

* -g:[lines,vars,source] *

* debug attributes level, that may take three forms: *

* -g all debug info ('-g:lines,vars,source') * -g:none no debug info * -g:{items} debug info for any/all of [lines, vars, source], e.g., * -g:lines,source *

*

* -preserveAllLocals *

* Preserve all local variables during code generation (to facilitate debugging). *

* -referenceInfo *

* Compute reference information. *

* -encoding format *

* Specify default source encoding format. Specify custom encoding on a per file basis by suffixing each * input source file/folder name with '[encoding]'. *

* -verbose *

* Emit messages about accessed/processed compilation units *

* -log file *

* Specify a log file for compiler messages. * -progress *

* Show progress (requires -log mode). * -time *

* Display speed information. * -noExit *

* Do not call System.exit(n) at end of compilation (n=0 if no error) * -repeat N *

* Repeat compilation process N times (typically to do performance analysis). * -Xnoweave *

* (Experimental) produce unwoven class files for input using -injars. * -Xnoinline *

* (Experimental) do not inline around advice * -XincrementalFile file *

* (Experimental) This works like incremental mode, but using a file rather than standard input to control * the compiler. It will recompile each time file is changed and and halt when file is deleted. *

* -XserializableAspects *

* (Experimental) Normally it is an error to declare aspects Serializable. This option removes that restriction. * * @author Jason van Zyl * @plexus.component role="org.codehaus.plexus.compiler.Compiler" role-hint="aspectj" */ public class AspectJCompiler extends AbstractCompiler { // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public AspectJCompiler() { super( CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE, ".java", ".class", null ); } public CompilerResult performCompile( CompilerConfiguration config ) throws CompilerException { File destinationDir = new File( config.getOutputLocation() ); if ( !destinationDir.exists() ) { destinationDir.mkdirs(); } String[] sourceFiles = getSourceFiles( config ); if ( sourceFiles.length == 0 ) { return new CompilerResult(); } System.out.println( "Compiling " + sourceFiles.length + " " + "source file" + ( sourceFiles.length == 1 ? "" : "s" ) + " to " + destinationDir.getAbsolutePath() ); // String[] args = buildCompilerArguments( config, sourceFiles ); AjBuildConfig buildConfig = buildCompilerConfig( config ); return new CompilerResult().compilerMessages( compileInProcess( buildConfig ) ); } private AjBuildConfig buildCompilerConfig( CompilerConfiguration config ) throws CompilerException { AjBuildConfig buildConfig = new AjBuildConfig(); buildConfig.setIncrementalMode( false ); String[] files = getSourceFiles( config ); if ( files != null ) { buildConfig.setFiles( buildFileList( Arrays.asList( files ) ) ); } setSourceVersion( buildConfig, config.getSourceVersion() ); if ( config.isDebug() ) { buildConfig.getOptions().produceDebugAttributes = ClassFileConstants.ATTR_SOURCE + ClassFileConstants.ATTR_LINES + ClassFileConstants.ATTR_VARS; } Map javaOpts = config.getCustomCompilerArguments(); 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() ); } } } 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() ); } buildConfig.setClasspath( elements ); } String outputLocation = config.getOutputLocation(); if ( outputLocation != null ) { File outDir = new File( outputLocation ); if ( !outDir.exists() ) { outDir.mkdirs(); } buildConfig.setOutputDir( outDir ); } if ( config instanceof AspectJCompilerConfiguration ) { AspectJCompilerConfiguration ajCfg = (AspectJCompilerConfiguration) config; Map sourcePathResources = ajCfg.getSourcePathResources(); if ( sourcePathResources != null && !sourcePathResources.isEmpty() ) { buildConfig.setSourcePathResources( sourcePathResources ); } Map ajOptions = ajCfg.getAJOptions(); if ( ajOptions != null && !ajOptions.isEmpty() ) { // TODO not supported //buildConfig.setAjOptions( ajCfg.getAJOptions() ); } 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 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() ) ); } } return buildConfig; } private List compileInProcess( AjBuildConfig buildConfig ) throws CompilerException { MessageHandler messageHandler = new MessageHandler(); AjBuildManager manager = new AjBuildManager( messageHandler ); try { manager.batchBuild( buildConfig, messageHandler ); } catch ( AbortException e ) { throw new CompilerException( "Unknown error while compiling", e ); } catch ( IOException e ) { throw new CompilerException( "Unknown error while compiling", e ); } // We need the location of the maven so we have a couple of options // here. // // The aspectjrt jar is something this component needs to function so we // can either // bake it into the plugin and retrieve it somehow or use a system // property or we // could pass in a set of parameters in a Map. boolean errors = messageHandler.hasAnyMessage( IMessage.ERROR, true ); List messages = new ArrayList(); if ( errors ) { IMessage[] errorMessages = messageHandler.getMessages( IMessage.ERROR, true ); 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() ); } 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 { URL[] urls = new URL[cp.size()]; for ( int i = 0; i < urls.length; i++ ) { urls[i] = ( new File( cp.get( i ) ) ).toURL(); } 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" ); } } } private List buildFileList( List locations ) { List fileList = new LinkedList(); for ( String location : locations ) { fileList.add( new File( location ) ); } return fileList; } /** * Set the source version in ajc compiler * * @param buildConfig * @param sourceVersion */ private void setSourceVersion( AjBuildConfig buildConfig, String sourceVersion ) throws CompilerException { if ( "1.7".equals( sourceVersion ) ) { buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_7; } else if ( "1.6".equals( sourceVersion ) ) { buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_6; } else if ( "1.5".equals( sourceVersion ) ) { buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_5; } else if ( "5.0".equals( sourceVersion ) ) { buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_5; } else if ( "1.4".equals( sourceVersion ) ) { buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_4; } else if ( "1.3".equals( sourceVersion ) ) { buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_3; } else if ( "1.2".equals( sourceVersion ) ) { buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_2; } else if ( "1.1".equals( sourceVersion ) ) { buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_1; } else if ( sourceVersion == null || sourceVersion.length() <= 0 ) { buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_3; } else { throw new CompilerException( "The source version was not recognized: " + sourceVersion ); } } /** * @return null */ public String[] createCommandLine( CompilerConfiguration config ) throws CompilerException { return null; } } AspectJCompilerConfiguration.java000066400000000000000000000052251241507501400471770ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajc/* Created on Oct 4, 2004 */ package org.codehaus.plexus.compiler.ajc; import java.io.File; import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.TreeMap; import org.codehaus.plexus.compiler.CompilerConfiguration; /** * @author jdcasey */ public class AspectJCompilerConfiguration extends CompilerConfiguration { private List aspectPath = new LinkedList(); private List inJars = new LinkedList(); private List inPath = new LinkedList(); private String outputJar; private Map ajOptions = new TreeMap(); private Map sourcePathResources; public void setAspectPath( List aspectPath ) { this.aspectPath = new LinkedList( aspectPath ); } public void addAspectPath( String aspectPath ) { this.aspectPath.add( aspectPath ); } public List getAspectPath() { return Collections.unmodifiableList( aspectPath ); } public void setInJars( List inJars ) { this.inJars = new LinkedList( inJars ); } public void addInJar( String inJar ) { this.inJars.add( inJar ); } public List getInJars() { return Collections.unmodifiableList( inJars ); } public void setInPath( List inPath ) { this.inPath = new LinkedList( inPath ); } public void addInPath( String inPath ) { this.inPath.add( inPath ); } public List getInPath() { return Collections.unmodifiableList( inPath ); } public void setOutputJar( String outputJar ) { this.outputJar = outputJar; } public String getOutputJar() { return outputJar; } /** * Ignored, not supported yet * @param ajOptions */ public void setAJOptions( Map ajOptions ) { //TODO //this.ajOptions = new TreeMap( ajOptions ); } 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 void setSourcePathResources( Map sourcePathResources ) { this.sourcePathResources = new TreeMap( sourcePathResources ); } public Map getSourcePathResources() { return sourcePathResources; } }plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/site/000077500000000000000000000000001241507501400314615ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/site/site.xml000066400000000000000000000011261241507501400331470ustar00rootroot00000000000000

plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test-input/000077500000000000000000000000001241507501400326315ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test-input/src/000077500000000000000000000000001241507501400334205ustar00rootroot00000000000000000077500000000000000000000000001241507501400342655ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test-input/src/main000077500000000000000000000000001241507501400350545ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test-input/src/main/org000077500000000000000000000000001241507501400366475ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test-input/src/main/org/codehaus000077500000000000000000000000001241507501400374325ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test-input/src/main/org/codehaus/fooBad.class000066400000000000000000000007421241507501400411520ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test-input/src/main/org/codehaus/fooĘţşľ.org/codehaus/foo/Badjava/lang/Object()VCodejava/lang/ErroržUnresolved compilation problems: pubic cannot be resolved (or is not a valid type) for the field Bad.String Syntax error on token "pubic", public expected  (Ljava/lang/String;)V  LineNumberTableLocalVariableTablethisLorg/codehaus/foo/Bad; SourceFileBad.java!4 » Y ·ż  Bad.java000066400000000000000000000001611241507501400407610ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class Bad { // Intentionally misspelled modifier. pubic String name; } ExternalDeps.class000066400000000000000000000012111241507501400430520ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test-input/src/main/org/codehaus/fooĘţşľ.org/codehaus/foo/ExternalDepsjava/lang/Object()VCodejava/lang/ErrortUnresolved compilation problems: The import org.apache.commons cannot be resolved StringUtils cannot be resolved  (Ljava/lang/String;)V  LineNumberTableLocalVariableTablethisLorg/codehaus/foo/ExternalDeps;helloAUnresolved compilation problem: StringUtils cannot be resolved strLjava/lang/String; SourceFileExternalDeps.java!4 » Y ·ż   > » Y·ż  ExternalDeps.java000066400000000000000000000003101241507501400426650ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; import org.apache.commons.lang.StringUtils; public class ExternalDeps { public void hello( String str ) { System.out.println( StringUtils.upperCase( str) ); } } Person.class000066400000000000000000000004251241507501400417300ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test-input/src/main/org/codehaus/fooĘţşľ.org/codehaus/foo/Personjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLorg/codehaus/foo/Person; SourceFile Person.java!/*· ±   Person.java000066400000000000000000000000631241507501400415420ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class Person { } plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test/000077500000000000000000000000001241507501400314745ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test/java/000077500000000000000000000000001241507501400324155ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test/java/org/000077500000000000000000000000001241507501400332045ustar00rootroot00000000000000000077500000000000000000000000001241507501400347205ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test/java/org/codehaus000077500000000000000000000000001241507501400362405ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test/java/org/codehaus/plexus000077500000000000000000000000001241507501400400525ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test/java/org/codehaus/plexus/compiler000077500000000000000000000000001241507501400406075ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test/java/org/codehaus/plexus/compiler/ajcAspectJCompilerTest.java000066400000000000000000000020721241507501400453370ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-aspectj/src/test/java/org/codehaus/plexus/compiler/ajcpackage org.codehaus.plexus.compiler.ajc; import java.io.File; import java.util.Arrays; import java.util.Collection; import java.util.List; import org.codehaus.plexus.compiler.AbstractCompilerTest; /** * @author Jason van Zyl */ public class AspectJCompilerTest extends AbstractCompilerTest { public AspectJCompilerTest() { super(); } protected String getRoleHint() { return "aspectj"; } protected int expectedErrors() { return 1; } protected Collection expectedOutputFiles() { return Arrays.asList( new String[]{ "org/codehaus/foo/ExternalDeps.class", "org/codehaus/foo/Person.class" } ); } protected List getClasspath() throws Exception { List cp = super.getClasspath(); File localArtifactPath = getLocalArtifactPath( "org.aspectj", "aspectjrt", System.getProperty( "aspectj.version" ), "jar" ); cp.add( localArtifactPath.getAbsolutePath() ); return cp; } } plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/000077500000000000000000000000001241507501400275555ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/pom.xml000066400000000000000000000013661241507501400311000ustar00rootroot00000000000000 4.0.0 org.codehaus.plexus plexus-compilers 2.4 plexus-compiler-csharp Plexus C# Compiler C# Compiler support for Plexus Compiler component. org.codehaus.plexus plexus-utils plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/000077500000000000000000000000001241507501400303445ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/main/000077500000000000000000000000001241507501400312705ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/main/java/000077500000000000000000000000001241507501400322115ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/main/java/org/000077500000000000000000000000001241507501400330005ustar00rootroot00000000000000000077500000000000000000000000001241507501400345145ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus000077500000000000000000000000001241507501400360345ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus000077500000000000000000000000001241507501400376465ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler000077500000000000000000000000001241507501400411265ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler/csharpCSharpCompiler.java000066400000000000000000000505611241507501400446530ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler/csharppackage org.codehaus.plexus.compiler.csharp; /* * Copyright 2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * 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 java.io.BufferedReader; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.io.StringReader; import java.io.StringWriter; import java.io.Writer; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; /** * @author Gilles Dodinet * @author Trygve Laugstøl * @author Matthew Pocock * @author Chris Stevenson * @plexus.component role="org.codehaus.plexus.compiler.Compiler" * role-hint="csharp" */ public class CSharpCompiler extends AbstractCompiler { private static final String ARGUMENTS_FILE_NAME = "csharp-arguments"; private static final String[] DEFAULT_INCLUDES = { "**/**" }; // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public CSharpCompiler() { super( CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES, ".cs", null, null ); } // ---------------------------------------------------------------------- // Compiler Implementation // ---------------------------------------------------------------------- public boolean canUpdateTarget( CompilerConfiguration configuration ) throws CompilerException { return false; } 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() ); if ( !destinationDir.exists() ) { destinationDir.mkdirs(); } config.setSourceFiles( null ); String[] sourceFiles = CSharpCompiler.getSourceFiles( config ); if ( sourceFiles.length == 0 ) { return new CompilerResult().success( true ); } System.out.println( "Compiling " + sourceFiles.length + " " + "source file" + ( sourceFiles.length == 1 ? "" : "s" ) + " to " + destinationDir.getAbsolutePath() ); 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." ); } return new CompilerResult().compilerMessages( messages ); } public String[] createCommandLine( CompilerConfiguration config ) throws CompilerException { return buildCompilerArguments( config, CSharpCompiler.getSourceFiles( config ) ); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- private String findExecutable( CompilerConfiguration config ) { String executable = config.getExecutable(); if ( !StringUtils.isEmpty( executable ) ) { return executable; } if ( Os.isFamily( "windows" ) ) { return "csc"; } return "mcs"; } /* $ 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-" ); } // config.isShowWarnings() // config.getSourceVersion() // config.getTargetVersion() // config.getSourceEncoding() // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- for ( String element : config.getClasspathEntries() ) { File f = new File( element ); if ( !f.isFile() ) { continue; } args.add( "/reference:\"" + element + "\"" ); } // ---------------------------------------------------------------------- // Main class // ---------------------------------------------------------------------- Map compilerArguments = config.getCustomCompilerArguments(); String mainClass = compilerArguments.get( "-main" ); if ( !StringUtils.isEmpty( mainClass ) ) { args.add( "/main:" + mainClass ); } // ---------------------------------------------------------------------- // Xml Doc output // ---------------------------------------------------------------------- String doc = compilerArguments.get( "-doc" ); if ( !StringUtils.isEmpty( doc ) ) { args.add( "/doc:" + new File( config.getOutputLocation(), config.getOutputFileName() + ".xml" ).getAbsolutePath() ); } // ---------------------------------------------------------------------- // Xml Doc output // ---------------------------------------------------------------------- String nowarn = compilerArguments.get( "-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" ); 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" ); if ( !StringUtils.isEmpty( resourcefile ) ) { String resourceTarget = (String) compilerArguments.get( "-resourcetarget" ); args.add( "/res:" + new File( resourcefile ).getAbsolutePath() + "," + resourceTarget ); } // ---------------------------------------------------------------------- // Target - type of assembly to produce, lib,exe,winexe etc... // ---------------------------------------------------------------------- String target = compilerArguments.get( "-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" ); if ( !StringUtils.isEmpty( nologo ) ) { args.add( "/nologo" ); } // ---------------------------------------------------------------------- // add any resource files // ---------------------------------------------------------------------- this.addResourceArgs( config, args ); // ---------------------------------------------------------------------- // add source files // ---------------------------------------------------------------------- for ( String sourceFile : sourceFiles ) { args.add( sourceFile ); } return args.toArray( new String[args.size()] ); } 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.addDefaultExcludes(); scanner.scan(); 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 ); } args.add( argLine ); } } } private File findResourceDir( CompilerConfiguration config ) { if ( config.isDebug() ) { System.out.println( "Looking for resourcesDir" ); } Map compilerArguments = config.getCustomCompilerArguments(); String tempResourcesDirAsString = (String) compilerArguments.get( "-resourceDir" ); File filteredResourceDir = null; 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." ); } } return filteredResourceDir; } 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 { // ---------------------------------------------------------------------- // Build the @arguments file // ---------------------------------------------------------------------- File file; PrintWriter output = null; try { file = new File( target, ARGUMENTS_FILE_NAME ); output = new PrintWriter( new FileWriter( file ) ); for ( String arg : args ) { output.println( arg ); } } catch ( IOException e ) { throw new CompilerException( "Error writing arguments file.", e ); } finally { IOUtil.close( output ); } // ---------------------------------------------------------------------- // Execute! // ---------------------------------------------------------------------- Commandline cli = new Commandline(); cli.setWorkingDirectory( workingDirectory.getAbsolutePath() ); cli.setExecutable( executable ); cli.createArgument().setValue( "@" + file.getAbsolutePath() ); Writer stringWriter = new StringWriter(); StreamConsumer out = new WriterStreamConsumer( stringWriter ); StreamConsumer err = new WriterStreamConsumer( stringWriter ); int returnCode; List messages; try { returnCode = CommandLineUtils.executeCommandLine( cli, out, err ); messages = parseCompilerOutput( new BufferedReader( new StringReader( stringWriter.toString() ) ) ); } catch ( CommandLineException e ) { throw new CompilerException( "Error while executing the external compiler.", e ); } catch ( IOException e ) { throw new CompilerException( "Error while executing the external compiler.", e ); } 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 ) ); } return messages; } public static List parseCompilerOutput( BufferedReader bufferedReader ) throws IOException { List messages = new ArrayList(); String line = bufferedReader.readLine(); while ( line != null ) { CompilerMessage compilerError = DefaultCSharpCompilerParser.parseLine( line ); if ( compilerError != null ) { messages.add( compilerError ); } line = bufferedReader.readLine(); } return messages; } private String getType( Map compilerArguments ) { String type = compilerArguments.get( "-target" ); if ( StringUtils.isEmpty( type ) ) { return "library"; } return type; } private String getTypeExtension( CompilerConfiguration configuration ) throws CompilerException { String type = getType( configuration.getCustomCompilerArguments() ); if ( "exe".equals( type ) || "winexe".equals( type ) ) { return "exe"; } if ( "library".equals( type ) || "module".equals( type ) ) { return "dll"; } throw new CompilerException( "Unrecognized type '" + type + "'." ); } // added for debug purposes.... protected static String[] getSourceFiles( CompilerConfiguration config ) { Set sources = new HashSet(); //Set sourceFiles = null; //was: Set sourceFiles = config.getSourceFiles(); if ( sourceFiles != null && !sourceFiles.isEmpty() ) { for ( File sourceFile : sourceFiles ) { sources.add( sourceFile.getAbsolutePath() ); } } else { for ( String sourceLocation : config.getSourceLocations() ) { sources.addAll( getSourceFilesForSourceRoot( config, sourceLocation ) ); } } String[] result; if ( sources.isEmpty() ) { result = new String[0]; } else { result = (String[]) sources.toArray( new String[sources.size()] ); } return result; } /** * This method is just here to maintain the public api. This is now handled in the parse * compiler output function. * * @author Chris Stevenson * @deprecated */ public static CompilerMessage parseLine( String line ) { return DefaultCSharpCompilerParser.parseLine( line ); } protected static Set getSourceFilesForSourceRoot( CompilerConfiguration config, String sourceLocation ) { DirectoryScanner scanner = new DirectoryScanner(); 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" } ); } Set excludes = config.getExcludes(); if ( excludes != null && !excludes.isEmpty() ) { String[] exclStrs = excludes.toArray( new String[excludes.size()] ); scanner.setIncludes( exclStrs ); } scanner.scan(); String[] sourceDirectorySources = scanner.getIncludedFiles(); Set sources = new HashSet(); for ( String source : sourceDirectorySources ) { File f = new File( sourceLocation, source ); sources.add( f.getPath() ); } return sources; } } DefaultCSharpCompilerParser.java000066400000000000000000000122151241507501400473270ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler/csharppackage org.codehaus.plexus.compiler.csharp; import org.codehaus.plexus.compiler.CompilerMessage; import org.codehaus.plexus.util.StringUtils; /** * Handles output from both mono with only the line number *

* ex error = "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./TestRunnerThread.cs(29) error CS0246: Cannot find type 'NameValueCollection'" *

* and errors from mono & csc on windows which has column num also *

* ex error = "src\\test\\csharp\\Hierarchy\\Logger.cs(98,4): warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'"; * * @author Gilles Dodinet * @author Trygve Laugstøl * @author Matthew Pocock * @author Chris Stevenson */ public class DefaultCSharpCompilerParser { private static String ERROR_PREFIX = "error "; private static String COMPILATION_PREFIX = "Compilation "; private static String MAGIC_LINE_MARKER = ".cs("; private static String MAGIC_LINE_MARKER_2 = ")"; public static CompilerMessage parseLine( String line ) { CompilerMessage ce = null; if ( isOutputWithNoColumnNumber( line ) ) { ce = parseLineWithNoColumnNumber( line ); } else { ce = parseLineWithColumnNumberAndLineNumber( line ); } return ce; } private static boolean isOutputWithNoColumnNumber( String line ) { int i = line.indexOf( MAGIC_LINE_MARKER ); if ( i == -1 ) { return true; } String chunk1 = line.substring( i + MAGIC_LINE_MARKER.length() ); int j = chunk1.indexOf( MAGIC_LINE_MARKER_2 ); String chunk2 = chunk1.substring( 0, j ); return ( chunk2.indexOf( "," ) == -1 ); } private static CompilerMessage parseLineWithNoColumnNumber( String line ) { String file = null; boolean error = true; int startline = -1; int startcolumn = -1; int endline = -1; int endcolumn = -1; String message; if ( line.startsWith( ERROR_PREFIX ) ) { message = line.substring( ERROR_PREFIX.length() ); } else if ( line.startsWith( COMPILATION_PREFIX ) ) { // ignore return null; } else if ( line.indexOf( MAGIC_LINE_MARKER ) != -1 ) { int i = line.indexOf( MAGIC_LINE_MARKER ); int j = line.indexOf( ' ', i ); file = line.substring( 0, i + 3 ); String num = line.substring( i + MAGIC_LINE_MARKER.length(), j - 1 ); startline = Integer.parseInt( num ); endline = startline; message = line.substring( j + 1 + ERROR_PREFIX.length() ); error = line.indexOf( ") error" ) != -1; } else { System.err.println( "Unknown output: " + line ); return null; } return new CompilerMessage( file, error, startline, startcolumn, endline, endcolumn, message ); } private static CompilerMessage parseLineWithColumnNumberAndLineNumber( String line ) { String file = null; boolean error = true; int startline = -1; int startcolumn = -1; int endline = -1; int endcolumn = -1; String message; if ( line.startsWith( ERROR_PREFIX ) ) { message = line.substring( ERROR_PREFIX.length() ); } else if ( line.startsWith( COMPILATION_PREFIX ) ) { return null; } else if ( line.indexOf( MAGIC_LINE_MARKER ) != -1 ) { int i = line.indexOf( MAGIC_LINE_MARKER ); int j = line.indexOf( ' ', i ); file = line.substring( 0, i + 3 ); String linecol = line.substring( i + MAGIC_LINE_MARKER.length(), j - 2 ); String linenum = null; String colnum = null; if ( linecol.indexOf( "," ) > -1 && 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 { linenum = linecol.trim(); colnum = "-1"; } startline = StringUtils.isEmpty( linenum ) ? -1 : Integer.parseInt( linenum ); startcolumn = StringUtils.isEmpty( colnum ) ? -1 : Integer.parseInt( colnum ); endline = startline; endcolumn = startcolumn; message = line.substring( j + 1 + ERROR_PREFIX.length() ); error = line.indexOf( "): error" ) != -1; } else { System.err.println( "Unknown output: " + line ); return null; } return new CompilerMessage( file, error, startline, startcolumn, endline, endcolumn, message ); } } plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/site/000077500000000000000000000000001241507501400313105ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/site/site.xml000066400000000000000000000011261241507501400327760ustar00rootroot00000000000000

plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/test/000077500000000000000000000000001241507501400313235ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/test/java/000077500000000000000000000000001241507501400322445ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/test/java/org/000077500000000000000000000000001241507501400330335ustar00rootroot00000000000000000077500000000000000000000000001241507501400345475ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/test/java/org/codehaus000077500000000000000000000000001241507501400360675ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/test/java/org/codehaus/plexus000077500000000000000000000000001241507501400377015ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/test/java/org/codehaus/plexus/compiler000077500000000000000000000000001241507501400411615ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/test/java/org/codehaus/plexus/compiler/csharpCSharpCompilerTest.java000066400000000000000000000331651241507501400455470ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-csharp/src/test/java/org/codehaus/plexus/compiler/csharppackage org.codehaus.plexus.compiler.csharp; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import junit.framework.TestCase; import org.codehaus.plexus.compiler.CompilerMessage; import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; import java.util.List; /** * @author Trygve Laugstøl */ public class CSharpCompilerTest extends TestCase { public void testParser() throws IOException { CompilerMessage error; // ---------------------------------------------------------------------- // Test a few concrete lines // ---------------------------------------------------------------------- error = DefaultCSharpCompilerParser.parseLine( "error CS2008: No files to compile were specified" ); assertNotNull( error ); assertEquals( "CS2008: No files to compile were specified", error.getMessage() ); error = DefaultCSharpCompilerParser.parseLine( "Compilation failed: 1 error(s), 0 warnings" ); assertNull( error ); error = DefaultCSharpCompilerParser.parseLine( "Compilation succeeded - 2 warning(s)" ); assertNull( error ); error = DefaultCSharpCompilerParser.parseLine( "/home/trygvis/dev/com.myrealbox/trunk/mcs/nunit20/core/./TestRunnerThread.cs(29) error CS0246: Cannot find type 'NameValueCollection'" ); assertNotNull( error ); assertEquals( 29, error.getStartLine() ); assertEquals( -1, error.getStartColumn() ); assertEquals( 29, error.getEndLine() ); assertEquals( -1, error.getEndColumn() ); assertEquals( "CS0246: Cannot find type 'NameValueCollection'", error.getMessage() ); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- 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"; List messages = CSharpCompiler.parseCompilerOutput( new BufferedReader( new StringReader( input ) ) ); assertNotNull( messages ); assertEquals( 14, messages.size() ); } 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"; List messagesWinCsc = CSharpCompiler.parseCompilerOutput( new BufferedReader( new StringReader( cscWin ) ) ); assertNotNull( messagesWinCsc ); assertEquals( 24, messagesWinCsc.size() ); assertTrue( "Check that the line number is not -1", ( (CompilerMessage) messagesWinCsc.get( 0 ) ).getStartLine() != -1 ); assertTrue( "Check that the column number is not -1", ( (CompilerMessage) messagesWinCsc.get( 0 ) ).getStartColumn() != -1 ); } 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"; List messagesMonoWin = CSharpCompiler.parseCompilerOutput( new BufferedReader( new StringReader( monoWin ) ) ); assertNotNull( messagesMonoWin ); assertEquals( 5, messagesMonoWin.size() ); assertTrue( "Check that the line number is not -1", ( (CompilerMessage) messagesMonoWin.get( 0 ) ).getStartLine() != -1 ); assertTrue( "Check that the column number is not -1", ( (CompilerMessage) messagesMonoWin.get( 0 ) ).getStartColumn() != -1 ); } } plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/000077500000000000000000000000001241507501400277215ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/pom.xml000066400000000000000000000027321241507501400312420ustar00rootroot00000000000000 4.0.0 org.codehaus.plexus plexus-compilers 2.4 plexus-compiler-eclipse Plexus Eclipse Compiler Eclipse Compiler support for Plexus Compiler component. org.codehaus.plexus plexus-utils org.eclipse.tycho org.eclipse.jdt.core 3.8.1.v20120531-0637 org.eclipse.core resources org.eclipse.core runtime org.eclipse.core filesystem org.eclipse text plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/000077500000000000000000000000001241507501400305105ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/main/000077500000000000000000000000001241507501400314345ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/main/java/000077500000000000000000000000001241507501400323555ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/000077500000000000000000000000001241507501400331445ustar00rootroot00000000000000000077500000000000000000000000001241507501400346605ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus000077500000000000000000000000001241507501400362005ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus000077500000000000000000000000001241507501400400125ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler000077500000000000000000000000001241507501400414365ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipseEclipseJavaCompiler.java000066400000000000000000000550231241507501400461670ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipsepackage org.codehaus.plexus.compiler.eclipse; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ 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.FileUtils; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; import org.eclipse.jdt.core.compiler.IProblem; import org.eclipse.jdt.internal.compiler.ClassFile; import org.eclipse.jdt.internal.compiler.CompilationResult; import org.eclipse.jdt.internal.compiler.Compiler; import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies; import org.eclipse.jdt.internal.compiler.ICompilerRequestor; import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy; import org.eclipse.jdt.internal.compiler.IProblemFactory; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException; import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; import org.eclipse.jdt.internal.compiler.env.INameEnvironment; import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.StringTokenizer; /** * @plexus.component role="org.codehaus.plexus.compiler.Compiler" role-hint="eclipse" */ public class EclipseJavaCompiler extends AbstractCompiler { public EclipseJavaCompiler() { super( CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE, ".java", ".class", null ); } // ---------------------------------------------------------------------- // Compiler Implementation // ---------------------------------------------------------------------- public CompilerResult performCompile( CompilerConfiguration config ) throws CompilerException { List errors = new LinkedList(); List classpathEntries = config.getClasspathEntries(); URL[] urls = new URL[1 + classpathEntries.size()]; int i = 0; try { urls[i++] = new File( config.getOutputLocation() ).toURL(); for ( String entry : classpathEntries ) { urls[i++] = new File( entry ).toURL(); } } catch ( MalformedURLException e ) { throw new CompilerException( "Error while converting the classpath entries to URLs.", e ); } ClassLoader classLoader = new URLClassLoader( urls ); SourceCodeLocator sourceCodeLocator = new SourceCodeLocator( config.getSourceLocations() ); INameEnvironment env = new EclipseCompilerINameEnvironment( sourceCodeLocator, classLoader, errors ); IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems(); // ---------------------------------------------------------------------- // Build settings from configuration // ---------------------------------------------------------------------- Map settings = new HashMap(); if ( config.isDebug() ) { settings.put( CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE ); settings.put( CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE ); settings.put( CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE ); } if ( !config.isShowWarnings() ) { Map opts = new CompilerOptions().getMap(); for (Object optKey : opts.keySet()) { if (opts.get(optKey).equals(CompilerOptions.WARNING)) { settings.put((String) optKey, CompilerOptions.IGNORE); } } } String sourceVersion = decodeVersion( config.getSourceVersion() ); if ( sourceVersion != null ) { settings.put( CompilerOptions.OPTION_Source, sourceVersion ); } String targetVersion = decodeVersion( config.getTargetVersion() ); if ( targetVersion != null ) { settings.put( CompilerOptions.OPTION_TargetPlatform, targetVersion ); if ( config.isOptimize() ) { settings.put( CompilerOptions.OPTION_Compliance, targetVersion ); } } if ( StringUtils.isNotEmpty( config.getSourceEncoding() ) ) { settings.put( CompilerOptions.OPTION_Encoding, config.getSourceEncoding() ); } if ( config.isShowDeprecation() ) { settings.put( CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.WARNING ); } else { settings.put( CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE ); } // ---------------------------------------------------------------------- // Set Eclipse-specific options // ---------------------------------------------------------------------- settings.put( CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE ); settings.put( CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE ); // compiler-specific extra options override anything else in the config object... Map extras = config.getCustomCompilerArguments(); if ( extras != null && !extras.isEmpty() ) { settings.putAll( extras ); } if ( settings.containsKey( "-properties" ) ) { initializeWarnings( settings.get( "-properties" ), settings ); settings.remove( "-properties" ); } IProblemFactory problemFactory = new DefaultProblemFactory( Locale.getDefault() ); ICompilerRequestor requestor = new EclipseCompilerICompilerRequestor( config.getOutputLocation(), errors ); List compilationUnits = new ArrayList(); for ( String sourceRoot : config.getSourceLocations() ) { Set sources = getSourceFilesForSourceRoot( config, sourceRoot ); for ( String source : sources ) { CompilationUnit unit = new CompilationUnit( source, makeClassName( source, sourceRoot ), errors, config.getSourceEncoding() ); compilationUnits.add( unit ); } } // ---------------------------------------------------------------------- // Compile! // ---------------------------------------------------------------------- CompilerOptions options = new CompilerOptions( settings ); Compiler compiler = new Compiler( env, policy, options, requestor, problemFactory ); ICompilationUnit[] units = compilationUnits.toArray( new ICompilationUnit[compilationUnits.size()] ); compiler.compile( units ); CompilerResult compilerResult = new CompilerResult().compilerMessages( errors ); for ( CompilerMessage compilerMessage : errors ) { if ( compilerMessage.isError() ) { compilerResult.setSuccess( false ); continue; } } return compilerResult; } public String[] createCommandLine( CompilerConfiguration config ) throws CompilerException { return null; } private CompilerMessage handleError( String className, int line, int column, Object errorMessage ) { if ( className.endsWith( ".java" ) ) { className = className.substring( 0, className.lastIndexOf( '.' ) ); } String fileName = className.replace( '.', File.separatorChar ) + ".java"; if ( column < 0 ) { column = 0; } String message; if ( errorMessage != null ) { message = errorMessage.toString(); } else { message = "No message"; } return new CompilerMessage( fileName, CompilerMessage.Kind.ERROR, line, column, line, column, message ); } private CompilerMessage handleWarning( String fileName, IProblem warning ) { return new CompilerMessage( fileName, CompilerMessage.Kind.WARNING, warning.getSourceLineNumber(), warning.getSourceStart(), warning.getSourceLineNumber(), warning.getSourceEnd(), warning.getMessage() ); } private String decodeVersion( String versionSpec ) { if ( StringUtils.isEmpty( versionSpec ) ) { return null; } else if ( "1.1".equals( versionSpec ) ) { return CompilerOptions.VERSION_1_1; } else if ( "1.2".equals( versionSpec ) ) { return CompilerOptions.VERSION_1_2; } else if ( "1.3".equals( versionSpec ) ) { return CompilerOptions.VERSION_1_3; } else if ( "1.4".equals( versionSpec ) ) { return CompilerOptions.VERSION_1_4; } else if ( "1.5".equals( versionSpec ) ) { return CompilerOptions.VERSION_1_5; } else if ( "1.6".equals( versionSpec ) ) { return CompilerOptions.VERSION_1_6; } else if ( "1.7".equals( versionSpec ) ) { return CompilerOptions.VERSION_1_7; } else { getLogger().warn( "Unknown version '" + versionSpec + "', no version setting will be given to the compiler." ); return null; } } // ---------------------------------------------------------------------- // Classes // ---------------------------------------------------------------------- private class CompilationUnit implements ICompilationUnit { private final String className; private final String sourceFile; private final String sourceEncoding; private final List errors; CompilationUnit( String sourceFile, String className, List errors ) { this( sourceFile, className, errors, null ); } CompilationUnit( String sourceFile, String className, List errors, String sourceEncoding ) { this.className = className; this.sourceFile = sourceFile; this.errors = errors; this.sourceEncoding = sourceEncoding; } public char[] getFileName() { String fileName = sourceFile; int lastSeparator = fileName.lastIndexOf( File.separatorChar ); if ( lastSeparator > 0 ) { fileName = fileName.substring( lastSeparator + 1 ); } return fileName.toCharArray(); } String getAbsolutePath() { return sourceFile; } public char[] getContents() { try { return FileUtils.fileRead( sourceFile, sourceEncoding ).toCharArray(); } catch ( FileNotFoundException e ) { errors.add( handleError( className, -1, -1, e.getMessage() ) ); return null; } catch ( IOException e ) { errors.add( handleError( className, -1, -1, e.getMessage() ) ); return null; } } public char[] getMainTypeName() { int dot = className.lastIndexOf( '.' ); if ( dot > 0 ) { return className.substring( dot + 1 ).toCharArray(); } return className.toCharArray(); } public char[][] getPackageName() { StringTokenizer izer = new StringTokenizer( className, "." ); char[][] result = new char[izer.countTokens() - 1][]; for ( int i = 0; i < result.length; i++ ) { String tok = izer.nextToken(); result[i] = tok.toCharArray(); } return result; } public boolean ignoreOptionalProblems() { return false; } } private class EclipseCompilerINameEnvironment implements INameEnvironment { private SourceCodeLocator sourceCodeLocator; private ClassLoader classLoader; private List errors; public EclipseCompilerINameEnvironment( SourceCodeLocator sourceCodeLocator, ClassLoader classLoader, List errors ) { this.sourceCodeLocator = sourceCodeLocator; this.classLoader = classLoader; this.errors = errors; } public NameEnvironmentAnswer findType( char[][] compoundTypeName ) { String result = ""; String sep = ""; for ( int i = 0; i < compoundTypeName.length; i++ ) { result += sep; result += new String( compoundTypeName[i] ); sep = "."; } return findType( result ); } public NameEnvironmentAnswer findType( char[] typeName, char[][] packageName ) { String result = ""; String sep = ""; for ( int i = 0; i < packageName.length; i++ ) { result += sep; result += new String( packageName[i] ); sep = "."; } result += sep; result += new String( typeName ); return findType( result ); } private NameEnvironmentAnswer findType( String className ) { try { File f = sourceCodeLocator.findSourceCodeForClass( className ); if ( f != null ) { ICompilationUnit compilationUnit = new CompilationUnit( f.getAbsolutePath(), className, errors ); return new NameEnvironmentAnswer( compilationUnit, null ); } String resourceName = className.replace( '.', '/' ) + ".class"; InputStream is = classLoader.getResourceAsStream( resourceName ); if ( is == null ) { return null; } byte[] classBytes = IOUtil.toByteArray( is ); char[] fileName = className.toCharArray(); ClassFileReader classFileReader = new ClassFileReader( classBytes, fileName, true ); return new NameEnvironmentAnswer( classFileReader, null ); } catch ( IOException e ) { errors.add( handleError( className, -1, -1, e.getMessage() ) ); return null; } catch ( ClassFormatException e ) { errors.add( handleError( className, -1, -1, e.getMessage() ) ); return null; } } private boolean isPackage( String result ) { if ( sourceCodeLocator.findSourceCodeForClass( result ) != null ) { return false; } String resourceName = "/" + result.replace( '.', '/' ) + ".class"; InputStream is = classLoader.getResourceAsStream( resourceName ); return is == null; } public boolean isPackage( char[][] parentPackageName, char[] packageName ) { String result = ""; String sep = ""; if ( parentPackageName != null ) { for ( int i = 0; i < parentPackageName.length; i++ ) { result += sep; result += new String( parentPackageName[i] ); sep = "."; } } if ( Character.isUpperCase( packageName[0] ) ) { return false; } String str = new String( packageName ); result += sep; result += str; return isPackage( result ); } public void cleanup() { // nothing to do } } private class EclipseCompilerICompilerRequestor implements ICompilerRequestor { private String destinationDirectory; private List errors; public EclipseCompilerICompilerRequestor( String destinationDirectory, List errors ) { this.destinationDirectory = destinationDirectory; this.errors = errors; } public void acceptResult( CompilationResult result ) { boolean hasErrors = false; if ( result.hasProblems() ) { IProblem[] problems = result.getProblems(); for ( IProblem problem : problems ) { String name = getFileName(result.getCompilationUnit(), problem.getOriginatingFileName()); if ( problem.isWarning() ) { errors.add( handleWarning( name, problem ) ); } else { hasErrors = true; errors.add( handleError( name, problem.getSourceLineNumber(), -1, problem.getMessage() ) ); } } } if ( !hasErrors ) { ClassFile[] classFiles = result.getClassFiles(); for ( ClassFile classFile : classFiles ) { char[][] compoundName = classFile.getCompoundName(); String className = ""; String sep = ""; for ( int j = 0; j < compoundName.length; j++ ) { className += sep; className += new String( compoundName[j] ); sep = "."; } byte[] bytes = classFile.getBytes(); File outFile = new File( destinationDirectory, className.replace( '.', '/' ) + ".class" ); if ( !outFile.getParentFile().exists() ) { outFile.getParentFile().mkdirs(); } FileOutputStream fout = null; try { fout = new FileOutputStream( outFile ); fout.write( bytes ); } catch ( FileNotFoundException e ) { errors.add( handleError( className, -1, -1, e.getMessage() ) ); } catch ( IOException e ) { errors.add( handleError( className, -1, -1, e.getMessage() ) ); } finally { IOUtil.close( fout ); } } } } private String getFileName( ICompilationUnit compilationUnit, char[] originalFileName ) { if ( compilationUnit instanceof CompilationUnit ) { return ((CompilationUnit)compilationUnit).getAbsolutePath(); } else { return String.valueOf(originalFileName); } } } private void initializeWarnings( String propertiesFile, Map setting ) { File file = new File( propertiesFile ); if ( !file.exists() ) { throw new IllegalArgumentException( "Properties file not exist" ); } BufferedInputStream stream = null; Properties properties = null; try { stream = new BufferedInputStream( new FileInputStream( propertiesFile ) ); properties = new Properties(); properties.load( stream ); } catch ( IOException e ) { throw new IllegalArgumentException( "Properties file load error" ); } finally { if ( stream != null ) { try { stream.close(); } catch ( IOException e ) { // ignore } } } for ( Iterator iterator = properties.entrySet().iterator(); iterator.hasNext(); ) { Map.Entry entry = (Map.Entry) iterator.next(); final String key = (String) entry.getKey(); setting.put( key, entry.getValue().toString() ); } } } SourceCodeLocator.java000066400000000000000000000044051241507501400456630ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipsepackage org.codehaus.plexus.compiler.eclipse; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import java.util.List; import java.util.Map; import java.util.HashMap; import java.io.File; /** * @author Trygve Laugstøl */ public class SourceCodeLocator { private List sourceRoots; private Map cache; public SourceCodeLocator( List sourceRoots ) { this.sourceRoots = sourceRoots; cache = new HashMap(); } public File findSourceCodeForClass( String className ) { File f = cache.get( className ); if ( f != null ) { return f; } String sourceName = className.replace( '.', System.getProperty( "file.separator" ).charAt( 0 ) ); sourceName += ".java"; f = findInRoots( sourceName ); cache.put( className, f ); return f; } private File findInRoots( String s ) { for ( String root : sourceRoots ) { File f = new File( root, s ); if ( f.exists() ) { return f; } } return null; } } plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/site/000077500000000000000000000000001241507501400314545ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/site/site.xml000066400000000000000000000011261241507501400331420ustar00rootroot00000000000000 plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test-input/000077500000000000000000000000001241507501400326245ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test-input/src/000077500000000000000000000000001241507501400334135ustar00rootroot00000000000000000077500000000000000000000000001241507501400342605ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test-input/src/main000077500000000000000000000000001241507501400350475ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test-input/src/main/org000077500000000000000000000000001241507501400366425ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test-input/src/main/org/codehaus000077500000000000000000000000001241507501400374255ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test-input/src/main/org/codehaus/fooBad.java000066400000000000000000000001611241507501400407540ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class Bad { // Intentionally misspelled modifier. pubic String name; } Deprecation.java000066400000000000000000000001771241507501400425320ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class Deprecation { public Deprecation() { new java.util.Date("testDate"); } } ExternalDeps.java000066400000000000000000000003101241507501400426600ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; import org.apache.commons.lang.StringUtils; public class ExternalDeps { public void hello( String str ) { System.out.println( StringUtils.upperCase( str) ); } } Person.java000066400000000000000000000000631241507501400415350ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class Person { } ReservedWord.java000066400000000000000000000001111241507501400426740ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class ReservedWord { String assert; } UnknownSymbol.java000066400000000000000000000001601241507501400431120ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class UnknownSymbol { public UnknownSymbol() { foo(); } } WrongClassname.java000066400000000000000000000000731241507501400432130ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class RightClassname { } plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test/000077500000000000000000000000001241507501400314675ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test/java/000077500000000000000000000000001241507501400324105ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/000077500000000000000000000000001241507501400331775ustar00rootroot00000000000000000077500000000000000000000000001241507501400347135ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus000077500000000000000000000000001241507501400362335ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus000077500000000000000000000000001241507501400400455ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler000077500000000000000000000000001241507501400414715ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipseEclipseCompilerTckTest.java000066400000000000000000000027131241507501400467200ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipsepackage org.codehaus.plexus.compiler.eclipse; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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() { super( "eclipse" ); } } EclipseCompilerTest.java000066400000000000000000000040621241507501400462550ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-eclipse/src/test/java/org/codehaus/plexus/compiler/eclipsepackage org.codehaus.plexus.compiler.eclipse; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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; /** * @author Jason van Zyl */ public class EclipseCompilerTest extends AbstractCompilerTest { public void setUp() throws Exception { super.setUp(); setCompilerDebug( true ); setCompilerDeprecationWarnings( true ); } protected String getRoleHint() { return "eclipse"; } protected int expectedErrors() { return 4; } protected int expectedWarnings() { return 2; } protected Collection expectedOutputFiles() { return Arrays.asList( new String[]{ "org/codehaus/foo/Deprecation.class", "org/codehaus/foo/ExternalDeps.class", "org/codehaus/foo/Person.class", "org/codehaus/foo/ReservedWord.class" } ); } } plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/000077500000000000000000000000001241507501400315545ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/pom.xml000066400000000000000000000045721241507501400331010ustar00rootroot00000000000000 4.0.0 org.codehaus.plexus plexus-compilers 2.4 plexus-compiler-javac-errorprone Plexus Javac+error-prone Component Javac Compiler support for Plexus Compiler component, with error-prone static analysis checks enabled. See http://error-prone.googlecode.com (Note: this component should be merged into plexus-compiler-javac when it is matured.) org.codehaus.plexus plexus-utils org.codehaus.plexus plexus-compiler-javac ${project.version} com.google.errorprone error_prone_core 1.1.1 openjdk tools org.apache.maven.plugins maven-surefire-plugin true plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/000077500000000000000000000000001241507501400323435ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/main/000077500000000000000000000000001241507501400332675ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/main/java/000077500000000000000000000000001241507501400342105ustar00rootroot00000000000000000077500000000000000000000000001241507501400347205ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/main/java/org000077500000000000000000000000001241507501400365135ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/main/java/org/codehaus000077500000000000000000000000001241507501400400335ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/main/java/org/codehaus/plexus000077500000000000000000000000001241507501400416455ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/main/java/org/codehaus/plexus/compiler000077500000000000000000000000001241507501400427315ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/main/java/org/codehaus/plexus/compiler/javac000077500000000000000000000000001241507501400451265ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/main/java/org/codehaus/plexus/compiler/javac/errorproneJavacCompilerWithErrorProne.java000066400000000000000000000206511241507501400533660ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/main/java/org/codehaus/plexus/compiler/javac/errorprone/* * Copyright 2011 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.codehaus.plexus.compiler.javac.errorprone; import org.codehaus.classworlds.ClassRealm; import org.codehaus.classworlds.ClassWorld; import org.codehaus.classworlds.DuplicateRealmException; import org.codehaus.classworlds.NoSuchRealmException; 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.codehaus.plexus.compiler.javac.JavacCompiler; import org.codehaus.plexus.compiler.javac.JavaxToolsCompiler; import javax.tools.Diagnostic; import javax.tools.DiagnosticListener; import javax.tools.JavaFileObject; import java.io.File; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Locale; /** * This class overrides JavacCompiler with modifications to use the error-prone * entry point into Javac. * * @author Alex Eagle * @plexus.component role="org.codehaus.plexus.compiler.Compiler" * role-hint="javac-with-errorprone" */ public class JavacCompilerWithErrorProne extends JavacCompiler { private ClassWorld classWorld = new ClassWorld(); private static final String REALM_ID = "error-prone"; @Override protected CompilerResult compileOutOfProcess( CompilerConfiguration config, String executable, String[] args ) throws CompilerException { throw new UnsupportedOperationException( "Cannot compile out-of-process with error-prone" ); } protected ClassLoader getErrorProneCompilerClassLoader() throws MalformedURLException, NoSuchRealmException { try { final String javaHome = System.getProperty( "java.home" ); final File toolsJar = new File( javaHome, "../lib/tools.jar" ); ClassLoader tccl = Thread.currentThread().getContextClassLoader(); getLogger().debug( "javaHome:" + javaHome ); getLogger().debug( "toolsJar:" + toolsJar.getPath() ); URL[] originalUrls = ( (URLClassLoader) tccl ).getURLs(); URL[] urls = new URL[originalUrls.length + 1]; urls[0] = toolsJar.toURI().toURL(); System.arraycopy( originalUrls, 0, urls, 1, originalUrls.length ); ClassRealm urlClassLoader = classWorld.newRealm( REALM_ID ); for ( URL url : urls ) { urlClassLoader.addConstituent( url ); } getLogger().debug( "urls:" + Arrays.asList( urls ) ); return urlClassLoader.getClassLoader(); } catch ( DuplicateRealmException e ) { if ( REALM_ID.equals( e.getId() ) ) { return classWorld.getRealm( REALM_ID ).getClassLoader(); } // should not happen ... throw new NoSuchRealmException( classWorld, REALM_ID ); } } @Override protected Class createJavacClass() throws CompilerException { try { return getErrorProneCompilerClassLoader().loadClass( "com.google.errorprone.ErrorProneCompiler$Builder" ); } catch ( ClassNotFoundException e ) { throw new CompilerException( e.getMessage(), e ); } catch ( MalformedURLException e ) { throw new CompilerException( e.getMessage(), e ); } catch ( NoSuchRealmException e ) { throw new CompilerException( e.getMessage(), e ); } } @Override protected CompilerResult compileInProcessWithProperClassloader( Class javacClass, String[] args ) throws CompilerException { ClassLoader original = Thread.currentThread().getContextClassLoader(); try { // TODO(alexeagle): perhaps error-prone can conform to the 1.6 JavaCompiler API. // Then we could use the JavaxToolsCompiler approach instead, which would reuse more code. // olamy: except we have a bunch of issues with classloader hierarchy final List messages = new ArrayList(); DiagnosticListener listener = new DiagnosticListener() { public void report( Diagnostic diagnostic ) { CompilerMessage compilerMessage = new CompilerMessage( diagnostic.getSource() == null ? null : diagnostic.getSource().getName(), JavaxToolsCompiler.convertKind( diagnostic ), (int) diagnostic.getLineNumber(), (int) diagnostic.getColumnNumber(), -1, -1,// end pos line:column is hard to calculate diagnostic.getMessage( Locale.getDefault() ) ); messages.add( compilerMessage ); } }; /* int result = new com.google.errorprone.ErrorProneCompiler.Builder().listenToDiagnostics( listener ).build().compile( args ); return new CompilerResult( result == 0, messages ); */ // here we need to use the new classloader containing tools.jar and use reflection with classworld class loader // whereas default jdk classloader will try to load com.sun.* classes from the plugin classloader!! Thread.currentThread().setContextClassLoader( getErrorProneCompilerClassLoader() ); Object builderInstance = javacClass.newInstance(); Method listenToDiagnostics = javacClass.getMethod( "listenToDiagnostics", DiagnosticListener.class ); builderInstance = listenToDiagnostics.invoke( builderInstance, listener ); Method build = javacClass.getMethod( "build" ); Object compiler = build.invoke( builderInstance ); Method compile = compiler.getClass().getMethod( "compile", new Class[]{ String[].class } ); Object resultObj = compile.invoke( compiler, new Object[]{ args } ); boolean success = (resultObj instanceof Integer) ? ((Integer)resultObj) == 0 : isJdk8OK(resultObj); return new CompilerResult( success, messages ); } catch ( InvocationTargetException e ) { throw new CompilerException( e.getMessage(), e ); } catch ( NoSuchMethodException e ) { throw new CompilerException( e.getMessage(), e ); } catch ( InstantiationException e ) { throw new CompilerException( e.getMessage(), e ); } catch ( IllegalAccessException e ) { throw new CompilerException( e.getMessage(), e ); } catch ( MalformedURLException e ) { throw new CompilerException( e.getMessage(), e ); } catch ( NoSuchRealmException e ) { throw new CompilerException( e.getMessage(), e ); } finally { Thread.currentThread().setContextClassLoader( original ); } } private boolean isJdk8OK(Object resultObj) throws CompilerException { try { return (Boolean) resultObj.getClass().getMethod("isOK").invoke(resultObj); } catch (IllegalAccessException e) { throw new CompilerException(e.getMessage(), e); } catch (InvocationTargetException e) { throw new CompilerException(e.getMessage(), e); } catch (NoSuchMethodException e) { throw new CompilerException(e.getMessage(), e); } } } 000077500000000000000000000000001241507501400344005ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test-input000077500000000000000000000000001241507501400351675ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test-input/src000077500000000000000000000000001241507501400361135ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test-input/src/main000077500000000000000000000000001241507501400367025ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test-input/src/main/org000077500000000000000000000000001241507501400404755ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test-input/src/main/org/codehaus000077500000000000000000000000001241507501400412605ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test-input/src/main/org/codehaus/fooBad.java000066400000000000000000000001611241507501400426070ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class Bad { // Intentionally misspelled modifier. pubic String name; } Deprecation.java000066400000000000000000000001771241507501400443650ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class Deprecation { public Deprecation() { new java.util.Date("testDate"); } } ExternalDeps.java000066400000000000000000000003111241507501400445140ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; import org.apache.commons.lang.StringUtils; public class ExternalDeps { public void hello( String str ) { System.out.println( StringUtils.upperCase( str) ); } } Person.java000066400000000000000000000000631241507501400433700ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class Person { } ReservedWord.java000066400000000000000000000001111241507501400445270ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class ReservedWord { String assert; } UnknownSymbol.java000066400000000000000000000001601241507501400447450ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class UnknownSymbol { public UnknownSymbol() { foo(); } } WrongClassname.java000066400000000000000000000000731241507501400450460ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class RightClassname { } plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test/000077500000000000000000000000001241507501400333225ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test/java/000077500000000000000000000000001241507501400342435ustar00rootroot00000000000000000077500000000000000000000000001241507501400347535ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test/java/org000077500000000000000000000000001241507501400365465ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test/java/org/codehaus000077500000000000000000000000001241507501400400665ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test/java/org/codehaus/plexus000077500000000000000000000000001241507501400417005ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test/java/org/codehaus/plexus/compiler000077500000000000000000000000001241507501400427645ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test/java/org/codehaus/plexus/compiler/javacJavacErrorProneCompilerTest.java000066400000000000000000000044201241507501400512240ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac-errorprone/src/test/java/org/codehaus/plexus/compiler/javacpackage org.codehaus.plexus.compiler.javac; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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 java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; /** * @author Jason van Zyl */ public class JavacErrorProneCompilerTest extends AbstractCompilerTest { public void setUp() throws Exception { super.setUp(); setForceJavacCompilerUse( true ); } protected String getRoleHint() { return "javac-with-errorprone"; } protected int expectedWarnings() { return 10; } @Override protected int expectedErrors() { return 4; } protected Collection expectedOutputFiles() { return Arrays.asList( new String[]{ "org/codehaus/foo/Deprecation.class", "org/codehaus/foo/ExternalDeps.class", "org/codehaus/foo/Person.class", "org/codehaus/foo/ReservedWord.class" } ); } } plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/000077500000000000000000000000001241507501400273615ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/pom.xml000066400000000000000000000014011241507501400306720ustar00rootroot00000000000000 4.0.0 org.codehaus.plexus plexus-compilers 2.4 plexus-compiler-javac Plexus Javac Component Javac Compiler support for Plexus Compiler component. org.codehaus.plexus plexus-utils plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/000077500000000000000000000000001241507501400301505ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/main/000077500000000000000000000000001241507501400310745ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/main/java/000077500000000000000000000000001241507501400320155ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/main/java/org/000077500000000000000000000000001241507501400326045ustar00rootroot00000000000000000077500000000000000000000000001241507501400343205ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus000077500000000000000000000000001241507501400356405ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus000077500000000000000000000000001241507501400374525ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler000077500000000000000000000000001241507501400405365ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javacIsolatedClassLoader.java000066400000000000000000000042561241507501400452710ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javacpackage org.codehaus.plexus.compiler.javac; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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; public class IsolatedClassLoader extends URLClassLoader { private ClassLoader parentClassLoader = ClassLoader.getSystemClassLoader(); public IsolatedClassLoader() { super( new URL[0], null ); } public void addURL( URL url ) { super.addURL( url ); } 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 ) { ex = e; if ( parentClassLoader != null ) { c = parentClassLoader.loadClass( className ); } } } if ( c == null ) { throw ex; } return c; } } JavacCompiler.java000066400000000000000000001051051241507501400441220ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javacpackage org.codehaus.plexus.compiler.javac; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /** * * Copyright 2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * 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.FileUtils; 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 java.io.BufferedReader; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.io.StringReader; import java.io.StringWriter; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.Properties; import java.util.StringTokenizer; import java.util.concurrent.CopyOnWriteArrayList; /** * @author Trygve Laugstøl * @author Matthew Pocock * @author Jörg Waßmer * @author Others * @plexus.component role="org.codehaus.plexus.compiler.Compiler" * role-hint="javac" */ 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 " }; // see compiler.note.note in compiler.properties of javac sources private static final String[] NOTE_PREFIXES = { "Note: ", "\u6ce8: ", "\u6ce8\u610f\uff1a " }; private static final Object LOCK = new Object(); private static final String JAVAC_CLASSNAME = "com.sun.tools.javac.Main"; private static volatile Class JAVAC_CLASS; private List> javaccClasses = new CopyOnWriteArrayList>(); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public JavacCompiler() { super( CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE, ".java", ".class", null ); } // ---------------------------------------------------------------------- // Compiler Implementation // ---------------------------------------------------------------------- public CompilerResult performCompile( CompilerConfiguration config ) throws CompilerException { File destinationDir = new File( config.getOutputLocation() ); if ( !destinationDir.exists() ) { destinationDir.mkdirs(); } String[] sourceFiles = getSourceFiles( config ); if ( ( sourceFiles == null ) || ( sourceFiles.length == 0 ) ) { return new CompilerResult(); } if ( ( getLogger() != null ) && getLogger().isInfoEnabled() ) { getLogger().info( "Compiling " + sourceFiles.length + " " + "source file" + ( sourceFiles.length == 1 ? "" : "s" ) + " to " + destinationDir.getAbsolutePath() ); } String[] args = buildCompilerArguments( config, sourceFiles ); CompilerResult result; if ( config.isFork() ) { String executable = config.getExecutable(); if ( StringUtils.isEmpty( executable ) ) { try { executable = getJavacExecutable(); } catch ( IOException e ) { getLogger().warn( "Unable to autodetect 'javac' path, using 'javac' from the environment." ); executable = "javac"; } } result = compileOutOfProcess( config, executable, args ); } else { if ( isJava16() && !config.isForceJavacCompilerUse() ) { // use fqcn to prevent loading of the class on 1.5 environment ! result = org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess( args, config, sourceFiles ); } else { result = compileInProcess( args, config ); } } return result; } protected static boolean isJava16() { try { Thread.currentThread().getContextClassLoader().loadClass( "javax.tools.ToolProvider" ); return true; } catch ( Exception e ) { return false; } } public String[] createCommandLine( CompilerConfiguration config ) throws CompilerException { return buildCompilerArguments( config, getSourceFiles( config ) ); } public static String[] buildCompilerArguments( CompilerConfiguration config, String[] sourceFiles ) { List args = new ArrayList(); // ---------------------------------------------------------------------- // Set output // ---------------------------------------------------------------------- File destinationDir = new File( config.getOutputLocation() ); args.add( "-d" ); args.add( destinationDir.getAbsolutePath() ); // ---------------------------------------------------------------------- // Set the class and source paths // ---------------------------------------------------------------------- List classpathEntries = config.getClasspathEntries(); if ( classpathEntries != null && !classpathEntries.isEmpty() ) { args.add( "-classpath" ); args.add( getPathString( classpathEntries ) ); } 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" ); args.add( getPathString( sourceLocations ) ); } if ( !isJava16() || config.isForceJavacCompilerUse() || config.isFork() ) { args.addAll( Arrays.asList( sourceFiles ) ); } if ( !isPreJava16( config ) ) { //now add jdk 1.6 annotation processing related parameters if ( config.getGeneratedSourcesDirectory() != null ) { config.getGeneratedSourcesDirectory().mkdirs(); args.add( "-s" ); args.add( config.getGeneratedSourcesDirectory().getAbsolutePath() ); } if ( config.getProc() != null ) { args.add( "-proc:" + config.getProc() ); } 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( "," ); } buffer.append( procs[i] ); } args.add( buffer.toString() ); } } 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.isVerbose() ) { args.add( "-verbose" ); } if ( config.isShowDeprecation() ) { args.add( "-deprecation" ); // This is required to actually display the deprecation messages config.setShowWarnings( true ); } if ( !config.isShowWarnings() ) { args.add( "-nowarn" ); } // TODO: this could be much improved 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() ); } 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() ); } if ( !suppressEncoding( config ) && !StringUtils.isEmpty( config.getSourceEncoding() ) ) { args.add( "-encoding" ); args.add( config.getSourceEncoding() ); } for ( Map.Entry entry : config.getCustomCompilerArgumentsAsMap().entrySet() ) { String key = entry.getKey(); if ( StringUtils.isEmpty( key ) || key.startsWith( "-J" ) ) { continue; } args.add( key ); String value = entry.getValue(); if ( StringUtils.isEmpty( value ) ) { continue; } args.add( value ); } return args.toArray( new String[args.size()] ); } /** * Determine if the compiler is a version prior to 1.4. * This is needed as 1.3 and earlier did not support -source or -encoding parameters * * @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 ) { String v = config.getCompilerVersion(); if ( v == null ) { return false; } return v.startsWith( "1.3" ) || v.startsWith( "1.2" ) || v.startsWith( "1.1" ) || v.startsWith( "1.0" ); } /** * Determine if the compiler is a version prior to 1.6. * This is needed for annotation processing parameters. * * @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 ) { String v = config.getCompilerVersion(); if ( v == null ) { //mkleint: i haven't completely understood the reason for the //compiler version parameter, checking source as well, as most projects will have this one set, not the compiler String s = config.getSourceVersion(); 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 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 suppressEncoding( CompilerConfiguration config ) { return isPreJava14( config ); } /** * Compile the java sources in a external process, calling an external executable, * like javac. * * @param config compiler configuration * @param executable name of the executable to launch * @param args arguments for the executable launched * @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 { Commandline cli = new Commandline(); cli.setWorkingDirectory( config.getWorkingDirectory().getAbsolutePath() ); cli.setExecutable( executable ); try { File argumentsFile = createFileWithArguments( args, config.getOutputLocation() ); cli.addArguments( new String[]{ "@" + argumentsFile.getCanonicalPath().replace( File.separatorChar, '/' ) } ); 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() } ); } 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 ); } CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); int returnCode; List messages; if ( ( getLogger() != null ) && getLogger().isDebugEnabled() ) { File commandLineFile = new File( config.getOutputLocation(), "javac." + ( 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() } ); } } catch ( IOException e ) { if ( ( getLogger() != null ) && getLogger().isWarnEnabled() ) { getLogger().warn( "Unable to write '" + commandLineFile.getName() + "' debug script file", e ); } } } try { returnCode = CommandLineUtils.executeCommandLine( cli, out, err ); messages = parseModernStream( returnCode, new BufferedReader( new StringReader( err.getOutput() ) ) ); } catch ( CommandLineException e ) { throw new CompilerException( "Error while executing the external compiler.", e ); } catch ( IOException e ) { throw new CompilerException( "Error while executing the external compiler.", e ); } boolean success = returnCode == 0; return new CompilerResult( success, messages ); } /** * Compile the java sources in the current JVM, without calling an external executable, * using com.sun.tools.javac.Main class * * @param args arguments for the compiler as they would be used in the command line javac * @param config compiler configuration * @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 ); final Thread thread = Thread.currentThread(); final ClassLoader contextClassLoader = thread.getContextClassLoader(); thread.setContextClassLoader( javacClass.getClassLoader() ); getLogger().debug( "ttcl changed run compileInProcessWithProperClassloader" ); try { return compileInProcessWithProperClassloader(javacClass, args); } finally { releaseJavaccClass( javacClass, config ); thread.setContextClassLoader( contextClassLoader ); } } 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 { StringWriter out = new StringWriter(); Integer ok; List messages; try { Method compile = javacClass.getMethod( "compile", new Class[]{ String[].class, PrintWriter.class } ); ok = (Integer) compile.invoke( null, new Object[]{ args, new PrintWriter( out ) } ); messages = parseModernStream( ok.intValue(), new BufferedReader( new StringReader( out.toString() ) ) ); } catch ( NoSuchMethodException e ) { throw new CompilerException( "Error while executing the compiler.", e ); } catch ( IllegalAccessException e ) { throw new CompilerException( "Error while executing the compiler.", e ); } catch ( InvocationTargetException e ) { throw new CompilerException( "Error while executing the compiler.", e ); } catch ( IOException e ) { throw new CompilerException( "Error while executing the compiler.", e ); } boolean success = ok.intValue() == 0; return new CompilerResult( success, messages ); } /** * Parse the output from the compiler into a list of CompilerMessage objects * * @param exitCode The exit code of javac. * @param input The output of the compiler * @return List of CompilerMessage objects * @throws IOException */ static List parseModernStream( int exitCode, BufferedReader input ) throws IOException { List errors = new ArrayList(); String line; StringBuilder buffer; while ( true ) { // cleanup the buffer buffer = new StringBuilder(); // this is quicker than clearing it // most errors terminate with the '^' char do { line = input.readLine(); if ( line == null ) { // javac output not detected by other parsing if ( buffer.length() > 0 && buffer.toString().startsWith( "javac:" ) ) { errors.add( new CompilerMessage( buffer.toString(), CompilerMessage.Kind.ERROR ) ); } return errors; } // TODO: there should be a better way to parse these if ( ( buffer.length() == 0 ) && line.startsWith( "error: " ) ) { errors.add( new CompilerMessage( line, true ) ); } else if ( ( buffer.length() == 0 ) && isNote( line ) ) { // skip, JDK 1.5 telling us deprecated APIs are used but -Xlint:deprecation isn't set } else { buffer.append( line ); buffer.append( EOL ); } } while ( !line.endsWith( "^" ) ); // add the error bean errors.add( parseModernError( exitCode, buffer.toString() ) ); } } private static boolean isNote( String line ) { for ( int i = 0; i < NOTE_PREFIXES.length; i++ ) { if ( line.startsWith( NOTE_PREFIXES[i] ) ) { return true; } } return false; } /** * Construct a CompilerMessage object from a line of the compiler output * * @param exitCode The exit code from javac. * @param error output line from the compiler * @return the CompilerMessage object */ static CompilerMessage parseModernError( int exitCode, String error ) { StringTokenizer tokens = new StringTokenizer( error, ":" ); boolean isError = exitCode != 0; StringBuilder msgBuffer; 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. boolean tokenIsAnInteger; String file = null; String currentToken = null; do { if ( currentToken != null ) { if ( file == null ) { file = currentToken; } else { file = file + ':' + currentToken; } } currentToken = tokens.nextToken(); // Probably the only backward compatible means of checking if a string is an integer. tokenIsAnInteger = true; try { Integer.parseInt( currentToken ); } catch ( NumberFormatException e ) { tokenIsAnInteger = false; } } while ( !tokenIsAnInteger ); String lineIndicator = currentToken; int startOfFileName = file.lastIndexOf( ']' ); if ( startOfFileName > -1 ) { file = file.substring( startOfFileName + 1 + EOL.length() ); } int line = Integer.parseInt( lineIndicator ); msgBuffer = new StringBuilder(); String msg = tokens.nextToken( EOL ).substring( 2 ); // Remove the 'warning: ' prefix String warnPrefix = getWarnPrefix( msg ); if ( warnPrefix != null ) { isError = false; msg = msg.substring( warnPrefix.length() ); } else { isError = exitCode != 0; } msgBuffer.append( msg ); msgBuffer.append( EOL ); String context = tokens.nextToken( EOL ); String pointer = tokens.nextToken( EOL ); if ( tokens.hasMoreTokens() ) { msgBuffer.append( context ); // 'symbol' line msgBuffer.append( EOL ); msgBuffer.append( pointer ); // 'location' line msgBuffer.append( EOL ); context = tokens.nextToken( EOL ); try { pointer = tokens.nextToken( EOL ); } catch ( NoSuchElementException e ) { pointer = context; context = null; } } String message = msgBuffer.toString(); int startcolumn = pointer.indexOf( "^" ); int endcolumn = context == null ? startcolumn : context.indexOf( " ", startcolumn ); if ( endcolumn == -1 ) { endcolumn = context.length(); } return new CompilerMessage( file, isError, line, startcolumn, line, endcolumn, message.trim() ); } catch ( NoSuchElementException e ) { return new CompilerMessage( "no more tokens - could not parse error message: " + error, isError ); } catch ( NumberFormatException e ) { return new CompilerMessage( "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 ( int i = 0; i < WARNING_PREFIXES.length; i++ ) { if ( msg.startsWith( WARNING_PREFIXES[i] ) ) { return WARNING_PREFIXES[i]; } } return null; } /** * put args into a temp file to be referenced using the @ option in javac command line * * @param args * @return the temporary file wth the arguments * @throws IOException */ private File createFileWithArguments( String[] args, String outputDirectory ) throws IOException { PrintWriter writer = null; try { File tempFile; if ( ( getLogger() != null ) && getLogger().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 ) ); for ( int i = 0; i < args.length; i++ ) { String argValue = args[i].replace( File.separatorChar, '/' ); writer.write( "\"" + argValue + "\"" ); writer.println(); } writer.flush(); return tempFile; } finally { if ( writer != null ) { writer.close(); } } } /** * Get the path of the javac tool executable: try to find it depending the OS or the java.home * system property or the JAVA_HOME environment variable. * * @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" : "" ); 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 ); } // ---------------------------------------------------------------------- // Try to find javacExe from JAVA_HOME environment variable // ---------------------------------------------------------------------- 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." ); } 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 ); } 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 ); } } /** * Find the main class of JavaC. Return the same class for subsequent calls. * * @return the non-null class. * @throws CompilerException if the class has not been found. */ private Class getJavacClass( CompilerConfiguration compilerConfiguration ) throws CompilerException { Class c = null; switch ( compilerConfiguration.getCompilerReuseStrategy() ) { case AlwaysNew: return createJavacClass(); case ReuseCreated: synchronized ( javaccClasses ) { if ( javaccClasses.size() > 0 ) { c = javaccClasses.get( 0 ); javaccClasses.remove( c ); return c; } } c = createJavacClass(); return c; case ReuseSame: default: c = JavacCompiler.JAVAC_CLASS; if ( c != null ) { return c; } 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 { // 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 ) { // ok } final File toolsJar = new File( System.getProperty( "java.home" ), "../lib/tools.jar" ); if ( !toolsJar.exists() ) { throw new CompilerException( "tools.jar not found: " + toolsJar ); } 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(); URL[] urls = new URL[originalUrls.length + 1]; urls[0] = toolsJar.toURI().toURL(); System.arraycopy(originalUrls, 0, urls, 1, originalUrls.length); ClassLoader javacClassLoader = new URLClassLoader(urls); 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 ); } } 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 ); } } } JavaxToolsCompiler.java000066400000000000000000000202231241507501400451650ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javacpackage org.codehaus.plexus.compiler.javac; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * 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 javax.tools.Diagnostic; import javax.tools.DiagnosticCollector; import javax.tools.JavaCompiler; 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; import java.util.Collections; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; /** * @author Olivier Lamy * @author David M. Lloyd * @since 2.0 */ public class JavaxToolsCompiler { /** * is that thread safe ??? */ static final JavaCompiler COMPILER = ToolProvider.getSystemJavaCompiler(); private static List JAVA_COMPILERS = new CopyOnWriteArrayList(); protected static JavaCompiler getJavaCompiler( CompilerConfiguration compilerConfiguration ) { switch ( compilerConfiguration.getCompilerReuseStrategy() ) { case AlwaysNew: return ToolProvider.getSystemJavaCompiler(); case ReuseCreated: JavaCompiler javaCompiler; synchronized ( JAVA_COMPILERS ) { if ( JAVA_COMPILERS.size() > 0 ) { javaCompiler = JAVA_COMPILERS.get( 0 ); JAVA_COMPILERS.remove( javaCompiler ); return javaCompiler; } } javaCompiler = ToolProvider.getSystemJavaCompiler(); return javaCompiler; case ReuseSame: default: return COMPILER; } } static void releaseJavaCompiler( JavaCompiler javaCompiler, CompilerConfiguration compilerConfiguration ) { if ( javaCompiler == null ) { return; } if ( compilerConfiguration.getCompilerReuseStrategy() == CompilerConfiguration.CompilerReuseStrategy.ReuseCreated ) { JAVA_COMPILERS.add( javaCompiler ); } } static 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 ) ); } final String sourceEncoding = config.getSourceEncoding(); final Charset sourceCharset = sourceEncoding == null ? null : Charset.forName( sourceEncoding ); final DiagnosticCollector collector = new DiagnosticCollector(); final StandardJavaFileManager standardFileManager = compiler.getStandardFileManager( collector, null, sourceCharset ); final Iterable fileObjects = standardFileManager.getJavaFileObjectsFromStrings( Arrays.asList( sourceFiles ) ); /*(Writer out, JavaFileManager fileManager, DiagnosticListener diagnosticListener, Iterable options, Iterable classes, Iterable compilationUnits)*/ List arguments = Arrays.asList( args ); final JavaCompiler.CompilationTask task = compiler.getTask( null, standardFileManager, collector, arguments, null, fileObjects ); final Boolean result = task.call(); final ArrayList compilerMsgs = new ArrayList(); for ( Diagnostic diagnostic : collector.getDiagnostics() ) { CompilerMessage.Kind kind = convertKind(diagnostic); String baseMessage = diagnostic.getMessage( 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 ) { // 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 { possibleTrimming = shortFileName + ":" + lineNumber + ": "; if ( formattedMessage.startsWith( possibleTrimming ) ) { formattedMessage = formattedMessage.substring( possibleTrimming.length() ); } } } compilerMsgs.add( new CompilerMessage( longFileName, kind, lineNumber, columnNumber, lineNumber, columnNumber, formattedMessage ) ); } if ( result != Boolean.TRUE && compilerMsgs.isEmpty() ) { compilerMsgs.add( new CompilerMessage( "An unknown compilation problem occurred", CompilerMessage.Kind.ERROR ) ); } return new CompilerResult( result, compilerMsgs ); } catch ( Exception e ) { throw new CompilerException( e.getMessage(), e ); } finally { releaseJavaCompiler( compiler, config ); } } public static CompilerMessage.Kind convertKind(Diagnostic diagnostic) { CompilerMessage.Kind kind; switch ( diagnostic.getKind() ) { case ERROR: kind = CompilerMessage.Kind.ERROR; break; case WARNING: kind = CompilerMessage.Kind.WARNING; break; case MANDATORY_WARNING: kind = CompilerMessage.Kind.MANDATORY_WARNING; break; case NOTE: kind = CompilerMessage.Kind.NOTE; break; default: kind = CompilerMessage.Kind.OTHER; break; } return kind; } } plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/site/000077500000000000000000000000001241507501400311145ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/site/site.xml000066400000000000000000000011261241507501400326020ustar00rootroot00000000000000 plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test-input/000077500000000000000000000000001241507501400322645ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test-input/src/000077500000000000000000000000001241507501400330535ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test-input/src/main/000077500000000000000000000000001241507501400337775ustar00rootroot00000000000000000077500000000000000000000000001241507501400345075ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test-input/src/main/org000077500000000000000000000000001241507501400363025ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test-input/src/main/org/codehaus000077500000000000000000000000001241507501400370655ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test-input/src/main/org/codehaus/fooBad.java000066400000000000000000000001611241507501400404140ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class Bad { // Intentionally misspelled modifier. pubic String name; } Deprecation.java000066400000000000000000000001771241507501400421720ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class Deprecation { public Deprecation() { new java.util.Date("testDate"); } } ExternalDeps.java000066400000000000000000000003111241507501400423210ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; import org.apache.commons.lang.StringUtils; public class ExternalDeps { public void hello( String str ) { System.out.println( StringUtils.upperCase( str) ); } } Person.java000066400000000000000000000000631241507501400411750ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class Person { } ReservedWord.java000066400000000000000000000001111241507501400423340ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class ReservedWord { String assert; } UnknownSymbol.java000066400000000000000000000001601241507501400425520ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class UnknownSymbol { public UnknownSymbol() { foo(); } } WrongClassname.java000066400000000000000000000000731241507501400426530ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class RightClassname { } plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test/000077500000000000000000000000001241507501400311275ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test/java/000077500000000000000000000000001241507501400320505ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test/java/org/000077500000000000000000000000001241507501400326375ustar00rootroot00000000000000000077500000000000000000000000001241507501400343535ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus000077500000000000000000000000001241507501400356735ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus000077500000000000000000000000001241507501400375055ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler000077500000000000000000000000001241507501400405715ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javacAbstractJavacCompilerTest.java000066400000000000000000000244341241507501400465060ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javacpackage org.codehaus.plexus.compiler.javac; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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 java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; /** * @author Jason van Zyl */ public abstract class AbstractJavacCompilerTest extends AbstractCompilerTest { private static final String PS = File.pathSeparator; public void setUp() throws Exception { super.setUp(); setCompilerDebug( true ); setCompilerDeprecationWarnings( true ); } protected String getRoleHint() { return "javac"; } protected int expectedErrors() { // javac output changed for misspelled modifiers starting in 1.6...they now generate 2 errors per occurrence, not one. if ( "1.5".compareTo( getJavaVersion() ) < 0 ) { return 4; } else { return 3; } } protected int expectedWarnings() { return 2; } protected Collection expectedOutputFiles() { return Arrays.asList( new String[]{ "org/codehaus/foo/Deprecation.class", "org/codehaus/foo/ExternalDeps.class", "org/codehaus/foo/Person.class", "org/codehaus/foo/ReservedWord.class" } ); } public void internalTest( CompilerConfiguration compilerConfiguration, List expectedArguments ) { String[] actualArguments = JavacCompiler.buildCompilerArguments( compilerConfiguration, new String[0] ); assertEquals( "The expected and actual argument list sizes differ.", expectedArguments.size(), actualArguments.length ); for ( int i = 0; i < actualArguments.length; i++ ) { assertEquals( "Unexpected argument", expectedArguments.get( i ), actualArguments[i] ); } } public void testBuildCompilerArgs13() { List expectedArguments = new ArrayList(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); compilerConfiguration.setCompilerVersion( "1.3" ); populateArguments( compilerConfiguration, expectedArguments, true, true ); internalTest( compilerConfiguration, expectedArguments ); } public void testBuildCompilerArgs14() { List expectedArguments = new ArrayList(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); compilerConfiguration.setCompilerVersion( "1.4" ); populateArguments( compilerConfiguration, expectedArguments, false, false ); internalTest( compilerConfiguration, expectedArguments ); } public void testBuildCompilerArgs15() { List expectedArguments = new ArrayList(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); compilerConfiguration.setCompilerVersion( "1.5" ); populateArguments( compilerConfiguration, expectedArguments, false, false ); internalTest( compilerConfiguration, expectedArguments ); } public void testBuildCompilerArgsUnspecifiedVersion() { List expectedArguments = new ArrayList(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); populateArguments( compilerConfiguration, expectedArguments, false, false ); internalTest( compilerConfiguration, expectedArguments ); } public void testBuildCompilerDebugLevel() { List expectedArguments = new ArrayList(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); compilerConfiguration.setDebug( true ); compilerConfiguration.setDebugLevel( "none" ); populateArguments( compilerConfiguration, expectedArguments, false, false ); internalTest( compilerConfiguration, expectedArguments ); } // PLXCOMP-190 public void testJRuntimeArguments() { List expectedArguments = new ArrayList(); CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); // outputLocation compilerConfiguration.setOutputLocation( "/output" ); expectedArguments.add( "-d" ); expectedArguments.add( new File( "/output" ).getAbsolutePath() ); // targetVersion compilerConfiguration.setTargetVersion( "1.3" ); expectedArguments.add( "-target" ); expectedArguments.add( "1.3" ); // sourceVersion compilerConfiguration.setSourceVersion( "1.3" ); expectedArguments.add( "-source" ); expectedArguments.add( "1.3" ); // customCompilerArguments Map customCompilerArguments = new LinkedHashMap(); customCompilerArguments.put( "-J-Duser.language=en_us", null ); compilerConfiguration.setCustomCompilerArgumentsAsMap( customCompilerArguments ); // don't expect this argument!! 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 * Setting the size of the array to 3 is fine, but does not exactly test what it is supposed to - disabling the test for now public void testCommandLineTooLongWhenForking() throws Exception { JavacCompiler compiler = (JavacCompiler) lookup( org.codehaus.plexus.compiler.Compiler.ROLE, getRoleHint() ); File destDir = new File( "target/test-classes-cmd" ); destDir.mkdirs(); // fill the cmd line arguments, 300 is enough to make it break String[] args = new String[400]; args[0] = "-d"; args[1] = destDir.getAbsolutePath(); for ( int i = 2; i < args.length; i++ ) { args[i] = "org/codehaus/foo/Person.java"; } CompilerConfiguration config = new CompilerConfiguration(); config.setWorkingDirectory( new File( getBasedir() + "/src/test-input/src/main" ) ); config.setFork( true ); List messages = compiler.compileOutOfProcess( config, "javac", args ); assertEquals( "There were errors launching the external compiler: " + messages, 0, messages.size() ); } */ private void populateArguments( CompilerConfiguration compilerConfiguration, List expectedArguments, boolean suppressSourceVersion, boolean suppressEncoding ) { // outputLocation compilerConfiguration.setOutputLocation( "/output" ); expectedArguments.add( "-d" ); expectedArguments.add( new File( "/output" ).getAbsolutePath() ); // classpathEntires List classpathEntries = new ArrayList(); classpathEntries.add( "/myjar1.jar" ); classpathEntries.add( "/myjar2.jar" ); compilerConfiguration.setClasspathEntries( classpathEntries ); expectedArguments.add( "-classpath" ); expectedArguments.add( "/myjar1.jar" + PS + "/myjar2.jar" + PS ); // sourceRoots List compileSourceRoots = new ArrayList(); compileSourceRoots.add( "/src/main/one" ); compileSourceRoots.add( "/src/main/two" ); compilerConfiguration.setSourceLocations( compileSourceRoots ); expectedArguments.add( "-sourcepath" ); expectedArguments.add( "/src/main/one" + PS + "/src/main/two" + PS ); // debug compilerConfiguration.setDebug( true ); if ( StringUtils.isNotEmpty( compilerConfiguration.getDebugLevel() ) ) { expectedArguments.add( "-g:" + compilerConfiguration.getDebugLevel() ); } else { expectedArguments.add( "-g" ); } // showDeprecation compilerConfiguration.setShowDeprecation( true ); expectedArguments.add( "-deprecation" ); // targetVersion compilerConfiguration.setTargetVersion( "1.3" ); expectedArguments.add( "-target" ); expectedArguments.add( "1.3" ); // sourceVersion compilerConfiguration.setSourceVersion( "1.3" ); if ( !suppressSourceVersion ) { expectedArguments.add( "-source" ); expectedArguments.add( "1.3" ); } // sourceEncoding compilerConfiguration.setSourceEncoding( "iso-8859-1" ); if ( !suppressEncoding ) { expectedArguments.add( "-encoding" ); expectedArguments.add( "iso-8859-1" ); } // customerCompilerArguments Map customerCompilerArguments = new LinkedHashMap(); customerCompilerArguments.put( "arg1", null ); customerCompilerArguments.put( "foo", "bar" ); compilerConfiguration.setCustomCompilerArgumentsAsMap( customerCompilerArguments ); expectedArguments.add( "arg1" ); expectedArguments.add( "foo" ); expectedArguments.add( "bar" ); } } ErrorMessageParserTest.java000066400000000000000000001521641241507501400460600ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javacpackage org.codehaus.plexus.compiler.javac; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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; import java.util.List; import junit.framework.TestCase; import org.codehaus.plexus.compiler.CompilerMessage; import org.codehaus.plexus.util.Os; /** * @author Trygve Laugstøl */ public class ErrorMessageParserTest extends TestCase { private static final String EOL = System.getProperty( "line.separator" ); 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; CompilerMessage compilerError = JavacCompiler.parseModernError( 0, error ); assertNotNull( compilerError ); assertFalse( compilerError.isError() ); assertEquals( "Date(java.lang.String) in java.util.Date has been deprecated", compilerError.getMessage() ); assertEquals( 63, compilerError.getStartColumn() ); assertEquals( 66, compilerError.getEndColumn() ); assertEquals( 1, compilerError.getStartLine() ); assertEquals( 1, compilerError.getEndLine() ); } 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 ); assertNotNull( compilerError ); assertFalse( compilerError.isError() ); assertEquals( "finally clause cannot complete normally", compilerError.getMessage() ); assertEquals( 26, compilerError.getStartColumn() ); assertEquals( 27, compilerError.getEndColumn() ); assertEquals( 8, compilerError.getStartLine() ); assertEquals( 8, compilerError.getEndLine() ); } public void testErrorMessage() { String error = "Foo.java:7: not a statement" + EOL + " i;" + EOL + " ^" + EOL; CompilerMessage compilerError = JavacCompiler.parseModernError( 1, error ); assertNotNull( compilerError ); assertTrue( compilerError.isError() ); assertEquals( "not a statement", compilerError.getMessage() ); assertEquals( 9, compilerError.getStartColumn() ); assertEquals( 11, compilerError.getEndColumn() ); assertEquals( 7, compilerError.getStartLine() ); assertEquals( 7, compilerError.getEndLine() ); } 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 ); assertNotNull( compilerError ); assertTrue( compilerError.isError() ); assertEquals( "cannot find symbol" + EOL + "symbol : method foo()" + EOL + "location: class org.codehaus.foo.UnknownSymbol", compilerError.getMessage() ); assertEquals( 8, compilerError.getStartColumn() ); assertEquals( 14, compilerError.getEndColumn() ); assertEquals( 7, compilerError.getStartLine() ); assertEquals( 7, compilerError.getEndLine() ); } 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 ) ) ); assertEquals( 2, messages.size() ); } 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 ) ) ); assertEquals( 2, messages.size() ); } 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; List messages = JavacCompiler.parseModernStream( 1, new BufferedReader( new StringReader( errors ) ) ); assertEquals( 1, messages.size() ); } 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; List messages = JavacCompiler.parseModernStream( 0, new BufferedReader( new StringReader( errors ) ) ); assertEquals( 1, messages.size() ); assertFalse( ( (CompilerMessage) messages.get( 0 ) ).isError() ); } 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 ); assertEquals( "/my/prj/src/main/java/test/prj/App.java:[11,45] not a statement", String.valueOf( compilerError ) ); } 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; CompilerMessage compilerError = JavacCompiler.parseModernError( 1, error ); assertEquals( "c:\\Documents and Settings\\My Self\\Documents\\prj\\src\\main\\java\\test\\prj\\App.java:[11,45] not a statement", String.valueOf( compilerError ) ); } /** * Test that CRLF is parsed correctly wrt. the filename in warnings. * * @throws Exception */ public void testCRLF_windows() throws Exception { // This test is only relevant on windows (test hardcodes EOL) 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; List compilerErrors = JavacCompiler.parseModernStream( 0, new BufferedReader( new StringReader( errors ) ) ); assertEquals( "count", 3, compilerErrors.size() ); CompilerMessage error1 = compilerErrors.get( 0 ); assertEquals( "file", "C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpUtil.java", error1.getFile() ); assertEquals( "message", "[deprecation] ThreadSafeClientConnManager in org.apache.http.impl.conn.tsccm has been deprecated", error1.getMessage() ); assertEquals( "line", 31, error1.getStartLine() ); assertEquals( "column", 38, error1.getStartColumn() ); CompilerMessage error2 = compilerErrors.get( 1 ); assertEquals( "file", "C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpUtil.java", error2.getFile() ); assertEquals( "message", "[deprecation] ThreadSafeClientConnManager in org.apache.http.impl.conn.tsccm has been deprecated", error2.getMessage() ); assertEquals( "line", 151, error2.getStartLine() ); assertEquals( "column", 8, error2.getStartColumn() ); CompilerMessage error3 = compilerErrors.get( 2 ); assertEquals( "file", "C:\\commander\\pre\\ec\\ec-http\\src\\main\\java\\com\\electriccloud\\http\\HttpUtil.java", error3.getFile() ); assertEquals( "message", "[deprecation] ThreadSafeClientConnManager in org.apache.http.impl.conn.tsccm has been deprecated", error3.getMessage() ); assertEquals( "line", 152, error3.getStartLine() ); assertEquals( "column", 16, error3.getStartColumn() ); } } JavacCompilerTest.java000066400000000000000000000020741241507501400450160ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javacpackage org.codehaus.plexus.compiler.javac; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author Olivier Lamy */ public class JavacCompilerTest extends AbstractJavacCompilerTest { public void setUp() throws Exception { super.setUp(); setForceJavacCompilerUse( true ); } } JavaxToolsCompilerTest.java000066400000000000000000000027071241507501400460670ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javacpackage org.codehaus.plexus.compiler.javac; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author Olivier Lamy */ public class JavaxToolsCompilerTest extends AbstractJavacCompilerTest { // no op default is to javax.tools if available protected int expectedWarnings() { if (getJavaVersion().contains("1.8")){ // lots of new warnings about obsoletions for future releases return 30; } else if ( "1.6".compareTo( getJavaVersion() ) < 0 ) { // with 1.7 some warning with bootstrap class path not set in conjunction with -source 1.3 return 9; } else { return 2; } } } plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/000077500000000000000000000000001241507501400274025ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/pom.xml000066400000000000000000000031161241507501400307200ustar00rootroot00000000000000 4.0.0 org.codehaus.plexus plexus-compilers 2.4 plexus-compiler-jikes Plexus Jikes Compiler Jikes Compiler support for Plexus Compiler component. org.codehaus.plexus plexus-utils org.apache.maven.plugins maven-surefire-plugin true jikes-enabled jikes-enabled true org.apache.maven.plugins maven-surefire-plugin true plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/000077500000000000000000000000001241507501400301715ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/main/000077500000000000000000000000001241507501400311155ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/main/java/000077500000000000000000000000001241507501400320365ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/main/java/org/000077500000000000000000000000001241507501400326255ustar00rootroot00000000000000000077500000000000000000000000001241507501400343415ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/main/java/org/codehaus000077500000000000000000000000001241507501400356615ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/main/java/org/codehaus/plexus000077500000000000000000000000001241507501400374735ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/main/java/org/codehaus/plexus/compiler000077500000000000000000000000001241507501400406005ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/main/java/org/codehaus/plexus/compiler/jikesJikesCompiler.java000066400000000000000000000371551241507501400442160ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/main/java/org/codehaus/plexus/compiler/jikespackage org.codehaus.plexus.compiler.jikes; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /*============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi . For more information on the Apache Software Foundation, please see . */ 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.compiler.util.StreamPumper; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.Os; import org.codehaus.plexus.util.StringUtils; import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileFilter; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * @plexus.component role="org.codehaus.plexus.compiler.Compiler" role-hint="jikes" */ public class JikesCompiler extends AbstractCompiler { private static final int OUTPUT_BUFFER_SIZE = 1024; public JikesCompiler() { super( CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE, ".java", ".class", null ); } // ----------------------------------------------------------------------- // Compiler Implementation // ----------------------------------------------------------------------- public CompilerResult performCompile( CompilerConfiguration config ) throws CompilerException { // Ensures that the directory exist. getDestinationDir( config ); try { // TODO: This should use the CommandLine stuff from plexus-utils. // ----------------------------------------------------------------------- // Execute the compiler // ----------------------------------------------------------------------- Process p = Runtime.getRuntime().exec( createCommandLine( config ) ); BufferedInputStream compilerErr = new BufferedInputStream( p.getErrorStream() ); ByteArrayOutputStream tmpErr = new ByteArrayOutputStream( OUTPUT_BUFFER_SIZE ); StreamPumper errPumper = new StreamPumper( compilerErr, tmpErr ); errPumper.start(); p.waitFor(); int exitValue = p.exitValue(); // Wait until the complete error stream has been read errPumper.join(); compilerErr.close(); p.destroy(); tmpErr.close(); // ----------------------------------------------------------------------- // Parse the output // ----------------------------------------------------------------------- BufferedReader input = new BufferedReader( new InputStreamReader( new ByteArrayInputStream( tmpErr.toByteArray() ) ) ); List messages = new ArrayList(); parseStream( input, messages ); if ( exitValue != 0 && exitValue != 1 ) { messages.add( new CompilerMessage( "Exit code from jikes was not 0 or 1 ->" + exitValue, true ) ); } return new CompilerResult().compilerMessages( messages ); } catch ( IOException e ) { throw new CompilerException( "Error while compiling.", e ); } catch ( InterruptedException e ) { throw new CompilerException( "Error while compiling.", e ); } } public String[] createCommandLine( CompilerConfiguration config ) throws CompilerException { List args = new ArrayList(); args.add( "jikes" ); String bootClassPath = getPathString( getBootClassPath() ); getLogger().debug( "Bootclasspath: " + bootClassPath ); if ( !StringUtils.isEmpty( bootClassPath ) ) { args.add( "-bootclasspath" ); args.add( bootClassPath ); } String classPath = getPathString( config.getClasspathEntries() ); getLogger().debug( "Classpath: " + classPath ); if ( !StringUtils.isEmpty( classPath ) ) { args.add( "-classpath" ); args.add( classPath ); } args.add( "+E" ); if ( config.getCustomCompilerArguments().size() > 0 ) { for ( Map.Entry arg : config.getCustomCompilerArgumentsAsMap().entrySet() ) { args.add( arg.getKey() ); args.add( arg.getValue() ); } } args.add( "-target" ); if ( StringUtils.isNotEmpty( config.getTargetVersion() ) ) { args.add( config.getTargetVersion() ); } else { args.add( "1.1" ); } args.add( "-source" ); if ( StringUtils.isNotEmpty( config.getSourceVersion() ) ) { args.add( config.getSourceVersion() ); } else { args.add( "1.3" ); } if ( !config.isShowWarnings() ) { args.add( "-nowarn" ); } if ( config.isShowDeprecation() ) { args.add( "-deprecation" ); } if ( config.isOptimize() ) { args.add( "-O" ); } if ( config.isVerbose() ) { args.add( "-verbose" ); } if ( config.isDebug() ) { args.add( "-g:lines" ); } args.add( "-d" ); args.add( getDestinationDir( config ).getAbsolutePath() ); String sourcePath = getPathString( config.getSourceLocations() ); getLogger().debug( "Source path:" + sourcePath ); if ( !StringUtils.isEmpty( sourcePath ) ) { args.add( "-sourcepath" ); args.add( sourcePath ); } String[] sourceFiles = getSourceFiles( config ); if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { String tempFileName = null; BufferedWriter fw = null; try { File tempFile = File.createTempFile( "compList", ".cmp" ); tempFileName = tempFile.getAbsolutePath(); getLogger().debug( "create TempFile" + tempFileName ); tempFile.getParentFile().mkdirs(); fw = new BufferedWriter( new FileWriter( tempFile ) ); for ( int i = 0; i < sourceFiles.length; i++ ) { fw.write( sourceFiles[i] ); fw.newLine(); } fw.flush(); tempFile.deleteOnExit(); } catch ( IOException e ) { throw new CompilerException( "Could not create temporary file " + tempFileName, e ); } finally { IOUtil.close( fw ); } args.add( "@" + tempFileName ); } else { for ( int i = 0; i < sourceFiles.length; i++ ) { args.add( sourceFiles[i] ); } } return (String[]) args.toArray( new String[args.size()] ); } // ----------------------------------------------------------------------- // Private // ----------------------------------------------------------------------- private File getDestinationDir( CompilerConfiguration config ) { File destinationDir = new File( config.getOutputLocation() ); if ( !destinationDir.exists() ) { destinationDir.mkdirs(); } return destinationDir; } private List getBootClassPath() { List bootClassPath = new ArrayList(); FileFilter filter = new FileFilter() { public boolean accept( File file ) { String name = file.getName(); return name.endsWith( ".jar" ) || name.endsWith( ".zip" ); } }; File javaHomeDir = new File( System.getProperty( "java.home" ) ); File javaLibDir = new File( javaHomeDir, "lib" ); if ( javaLibDir.isDirectory() ) { bootClassPath.addAll( asList( javaLibDir.listFiles( filter ) ) ); } File javaClassesDir = new File( javaHomeDir, "../Classes" ); if ( javaClassesDir.isDirectory() ) { bootClassPath.addAll( asList( javaClassesDir.listFiles( filter ) ) ); } File javaExtDir = new File( javaLibDir, "ext" ); if ( javaExtDir.isDirectory() ) { bootClassPath.addAll( asList( javaExtDir.listFiles( filter ) ) ); } return bootClassPath; } private List asList( File[] files ) { List filenames = new ArrayList( files.length ); for ( File file : files ) { filenames.add( file.toString() ); } return filenames; } /** * Parse the compiler error stream to produce a list of * CompilerMessages * * @param input The error stream * @return The list of compiler error messages * @throws IOException If an error occurs during message collection */ protected List parseStream( BufferedReader input, List messages ) throws IOException { String line = null; StringBuilder buffer; while ( true ) { // cleanup the buffer buffer = new StringBuilder(); // this is faster than clearing it // first line is not space-starting if ( line == null ) { line = input.readLine(); } if ( line == null ) { return messages; } buffer.append( line ); // all other space-starting lines are one error while ( true ) { line = input.readLine(); // EOF if ( line == null ) { break; } // Continuation of previous error starts with ' ' if ( line.length() > 0 && line.charAt( 0 ) != ' ' ) { break; } buffer.append( EOL ); buffer.append( line ); } if ( buffer.length() > 0 ) { // add the error bean messages.add( parseError( buffer.toString() ) ); } } } /** * Parse an individual compiler error message * * @param error The error text * @return A mssaged CompilerMessage */ private CompilerMessage parseError( String error ) { if ( error.startsWith( "Error:" ) ) { return new CompilerMessage( error, true ); } String[] errorBits = StringUtils.split( error, ":" ); int i; String file; if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { file = errorBits[0] + ':' + errorBits[1]; i = 2; } else { file = errorBits[0]; i = 1; } int startline = Integer.parseInt( errorBits[i++] ); int startcolumn = Integer.parseInt( errorBits[i++] ); int endline = Integer.parseInt( errorBits[i++] ); int endcolumn = Integer.parseInt( errorBits[i++] ); String type = errorBits[i++]; StringBuilder message = new StringBuilder( errorBits[i++] ); while ( i < errorBits.length ) { message.append( ':' ).append( errorBits[i++] ); } return new CompilerMessage( file, type.indexOf( "Error" ) > -1, startline, startcolumn, endline, endcolumn, message.toString() ); } } plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/site/000077500000000000000000000000001241507501400311355ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/site/site.xml000066400000000000000000000011261241507501400326230ustar00rootroot00000000000000 plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test-input/000077500000000000000000000000001241507501400323055ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test-input/src/000077500000000000000000000000001241507501400330745ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/000077500000000000000000000000001241507501400340205ustar00rootroot00000000000000000077500000000000000000000000001241507501400345305ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org000077500000000000000000000000001241507501400363235ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus000077500000000000000000000000001241507501400371065ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/fooBad.java000066400000000000000000000001611241507501400404350ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class Bad { // Intentionally misspelled modifier. pubic String name; } Deprecation.java000066400000000000000000000001771241507501400422130ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class Deprecation { public Deprecation() { new java.util.Date("testDate"); } } ExternalDeps.java000066400000000000000000000003101241507501400423410ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; import org.apache.commons.lang.StringUtils; public class ExternalDeps { public void hello( String str ) { System.out.println( StringUtils.upperCase( str) ); } } Person.java000066400000000000000000000000631241507501400412160ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class Person { } ReservedWord.java000066400000000000000000000001111241507501400423550ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class ReservedWord { String assert; } UnknownSymbol.java000066400000000000000000000001601241507501400425730ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class UnknownSymbol { public UnknownSymbol() { foo(); } } WrongClassname.java000066400000000000000000000000731241507501400426740ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foopackage org.codehaus.foo; public class RightClassname { } plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test/000077500000000000000000000000001241507501400311505ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test/java/000077500000000000000000000000001241507501400320715ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test/java/org/000077500000000000000000000000001241507501400326605ustar00rootroot00000000000000000077500000000000000000000000001241507501400343745ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test/java/org/codehaus000077500000000000000000000000001241507501400357145ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test/java/org/codehaus/plexus000077500000000000000000000000001241507501400375265ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test/java/org/codehaus/plexus/compiler000077500000000000000000000000001241507501400406335ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test/java/org/codehaus/plexus/compiler/jikesJikesCompilerTest.java000066400000000000000000000041401241507501400450750ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/plexus-compilers/plexus-compiler-jikes/src/test/java/org/codehaus/plexus/compiler/jikespackage org.codehaus.plexus.compiler.jikes; /** * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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; /** * @author Jason van Zyl */ public class JikesCompilerTest extends AbstractCompilerTest { protected String getRoleHint() { return "jikes"; } public void setUp() throws Exception { super.setUp(); setCompilerDebug( true ); setCompilerDeprecationWarnings( true ); } protected int expectedErrors() { return 2; } protected int expectedWarnings() { return 3; } protected Collection expectedOutputFiles() { return Arrays.asList( new String[]{ "org/codehaus/foo/Deprecation.class", "org/codehaus/foo/ExternalDeps.class", "org/codehaus/foo/Person.class", "org/codehaus/foo/ReservedWord.class", "org/codehaus/foo/RightClassname.class" } ); } } plexus-compiler-plexus-compiler-2.4/plexus-compilers/pom.xml000066400000000000000000000024171241507501400244700ustar00rootroot00000000000000 4.0.0 org.codehaus.plexus plexus-compiler 2.4 plexus-compilers pom Plexus Compilers plexus-compiler-aspectj plexus-compiler-csharp plexus-compiler-eclipse plexus-compiler-jikes plexus-compiler-javac plexus-compiler-javac-errorprone junit junit test org.codehaus.plexus plexus-compiler-api org.codehaus.plexus plexus-compiler-test test plexus-compiler-plexus-compiler-2.4/pom.xml000066400000000000000000000122601241507501400211520ustar00rootroot00000000000000 4.0.0 org.codehaus.plexus plexus-components 1.3.1 plexus-compiler 2.4 pom Plexus Compiler Plexus Compiler is a Plexus component to use different compilers through a uniform API. plexus-compiler-api plexus-compiler-manager plexus-compilers plexus-compiler-test scm:git:git@github.com:sonatype/plexus-compiler.git scm:git:git@github.com:sonatype/plexus-compiler.git http://github.com/sonatype/plexus-compiler plexus-compiler-2.4 jira http://jira.codehaus.org/browse/PLXCOMP/component/12541 org.codehaus.plexus plexus-compiler-api ${project.version} org.codehaus.plexus plexus-compiler-test ${project.version} org.codehaus.plexus plexus-utils 3.0.10 org.codehaus.plexus plexus-container-default provided junit junit test 4.11 org.apache.maven.plugins maven-compiler-plugin 3.1 org.apache.maven.plugins maven-surefire-plugin 2.17 org.apache.maven.plugins maven-site-plugin 3.4 org.apache.maven.plugins maven-release-plugin 2.5.1 plexus-release,tools.jar org.codehaus.plexus plexus-component-metadata generate-metadata merge-metadata org.apache.maven.plugins maven-gpg-plugin org.apache.maven.plugins maven-project-info-reports-plugin 2.7 org.codehaus.mojo findbugs-maven-plugin 3.0.0 org.codehaus.mojo cobertura-maven-plugin 2.6 maven.repo.local maven.repo.local org.apache.maven.plugins maven-surefire-plugin maven.repo.local ${maven.repo.local} plexus-compiler-plexus-compiler-2.4/src/000077500000000000000000000000001241507501400204235ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/src/site/000077500000000000000000000000001241507501400213675ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/src/site/apt/000077500000000000000000000000001241507501400221535ustar00rootroot00000000000000plexus-compiler-plexus-compiler-2.4/src/site/apt/index.apt000066400000000000000000000042231241507501400237710ustar00rootroot00000000000000 ------ Plexus Compiler ------ HervĂ© Boutemy ------ 2012-05-08 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ NOTE: For help with the syntax of this file, see: ~~ http://maven.apache.org/doxia/references/apt-format.html Plexus Compiler Plexus Compiler is a Plexus component to use different compilers through a uniform API. It is composed by: * {{{./plexus-compiler-api/}<<>>}}: the API to use compilers, * {{{./plexus-compiler-manager/}<<>>}}: a manager to choose a compiler, * {{{./plexus-compilers/}<<>>}}: different compilers * {{{./plexus-compilers/plexus-compiler-aspectj/}<<>>}}: AspectJ compiler, * {{{./plexus-compilers/plexus-compiler-csharp/}<<>>}}: C#/Mono compiler, * {{{./plexus-compilers/plexus-compiler-eclipse/}<<>>}}: Eclipse compiler, * {{{./plexus-compilers/plexus-compiler-javac/}<<>>}}: javac compiler, * {{{./plexus-compilers/plexus-compiler-javac-errorprone/}<<>>}}: javac compiler with {{{http://error-prone.googlecode.com}error-prone}} static analysis checks enabled , * {{{./plexus-compilers/plexus-compiler-jikes/}<<>>}}: jikes compiler, [] * {{{./plexus-compiler-test/}<<>>}}: a test harness. [] plexus-compiler-plexus-compiler-2.4/src/site/site.xml000066400000000000000000000022361241507501400230600ustar00rootroot00000000000000