pax_global_header 0000666 0000000 0000000 00000000064 12415075014 0014511 g ustar 00root root 0000000 0000000 52 comment=35ca8c7ce91bdf7f831653c33bd92709bf81a69b
plexus-compiler-plexus-compiler-2.4/ 0000775 0000000 0000000 00000000000 12415075014 0017634 5 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/.gitignore 0000664 0000000 0000000 00000000105 12415075014 0021620 0 ustar 00root root 0000000 0000000 target/
.project
.classpath
.settings/
bin
.idea
*.iml
.java-version
plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/ 0000775 0000000 0000000 00000000000 12415075014 0023533 5 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/pom.xml 0000664 0000000 0000000 00000001541 12415075014 0025051 0 ustar 00root root 0000000 0000000
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/ 0000775 0000000 0000000 00000000000 12415075014 0024322 5 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/ 0000775 0000000 0000000 00000000000 12415075014 0025246 5 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/ 0000775 0000000 0000000 00000000000 12415075014 0026167 5 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/ 0000775 0000000 0000000 00000000000 12415075014 0026756 5 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/ 0000775 0000000 0000000 00000000000 12415075014 0030551 5 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/ 0000775 0000000 0000000 00000000000 12415075014 0032071 5 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/ 0000775 0000000 0000000 00000000000 12415075014 0033703 5 ustar 00root root 0000000 0000000 AbstractCompiler.java 0000664 0000000 0000000 00000021765 12415075014 0037740 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler package 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.java 0000664 0000000 0000000 00000006764 12415075014 0036256 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler package 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.java 0000664 0000000 0000000 00000032613 12415075014 0040776 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler package 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.java 0000664 0000000 0000000 00000002125 12415075014 0037253 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler package 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.java 0000664 0000000 0000000 00000002751 12415075014 0040125 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler package 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.java 0000664 0000000 0000000 00000024650 12415075014 0037555 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler package 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.java 0000664 0000000 0000000 00000003030 12415075014 0042761 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler package 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.java 0000664 0000000 0000000 00000004525 12415075014 0040511 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler package 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.java 0000664 0000000 0000000 00000004752 12415075014 0037450 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler package 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;
}
}
0000775 0000000 0000000 00000000000 12415075014 0034601 5 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util StreamPumper.java 0000664 0000000 0000000 00000004636 12415075014 0040101 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util package 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);
}
}
}
0000775 0000000 0000000 00000000000 12415075014 0035525 5 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan AbstractSourceInclusionScanner.java 0000664 0000000 0000000 00000004366 12415075014 0044523 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan package 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.java 0000664 0000000 0000000 00000001705 12415075014 0043022 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan package 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.java 0000664 0000000 0000000 00000005052 12415075014 0044202 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan package 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.java 0000664 0000000 0000000 00000002225 12415075014 0043027 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan package 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.java 0000664 0000000 0000000 00000006666 12415075014 0042151 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan package 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;
}
}
0000775 0000000 0000000 00000000000 12415075014 0037160 5 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mapping SingleTargetSourceMapping.java 0000664 0000000 0000000 00000004062 12415075014 0045112 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mapping package 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.java 0000664 0000000 0000000 00000001675 12415075014 0042610 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mapping package 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.java 0000664 0000000 0000000 00000003454 12415075014 0042611 0 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/mapping package 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/ 0000775 0000000 0000000 00000000000 12415075014 0025266 5 ustar 00root root 0000000 0000000 plexus-compiler-plexus-compiler-2.4/plexus-compiler-api/src/site/site.xml 0000664 0000000 0000000 00000001126 12415075014 0026754 0 ustar 00root root 0000000 0000000