Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plexus-compiler-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
* SOFTWARE.
*/

import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.DirectoryScanner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
Expand All @@ -39,9 +40,9 @@
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
public abstract class AbstractCompiler
extends AbstractLogEnabled
implements Compiler
{
protected Logger log = LoggerFactory.getLogger ( getClass() );
protected static final String EOL = System.lineSeparator();

protected static final String PS = System.getProperty( "path.separator" );
Expand Down Expand Up @@ -280,11 +281,11 @@ private static String getCanonicalPath( File origFile )

protected void logCompiling( String[] sourceFiles, CompilerConfiguration config )
{
if ( ( getLogger() != null ) && getLogger().isInfoEnabled() )
if ( log.isInfoEnabled() )
{
String to = ( config.getWorkingDirectory() == null ) ? config.getOutputLocation() :
config.getWorkingDirectory().toPath().relativize( new File( config.getOutputLocation() ).toPath() ).toString();
getLogger().info( "Compiling " +
log.info( "Compiling " +
( sourceFiles == null ? "" : ( sourceFiles.length + " source file" + ( sourceFiles.length == 1 ? " " : "s " ) ) ) +
"with " + getCompilerId() + " [" + config.describe() + "]" +
" to " + to );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.codehaus.plexus.compiler.Compiler;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.AbstractLogEnabled;

import java.util.Map;

Expand All @@ -36,7 +35,6 @@
*/
@Component( role = CompilerManager.class )
public class DefaultCompilerManager
extends AbstractLogEnabled
implements CompilerManager
{
@Requirement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,13 @@ public CompilerResult performCompile( CompilerConfiguration config )
boolean success = false;
if ( compiler != null )
{
getLogger().debug( "Using JSR-199 EclipseCompiler" );
log.debug( "Using JSR-199 EclipseCompiler" );
// ECJ JSR-199 compiles against the latest Java version it supports if no source
// version is given explicitly. BatchCompiler uses 1.3 as default. So check
// whether a source version is specified, and if not supply 1.3 explicitly.
if ( !haveSourceOrReleaseArgument( args ) )
{
getLogger().debug( "ecj: no source level nor release specified, defaulting to Java 1.3" );
log.debug( "ecj: no source level nor release specified, defaulting to Java 1.3" );
args.add( "-source" );
args.add( "1.3" );
}
Expand Down Expand Up @@ -336,7 +336,7 @@ public void report( Diagnostic<? extends JavaFileObject> diagnostic )
}
catch ( IllegalCharsetNameException | UnsupportedCharsetException e )
{
getLogger().warn(
log.warn(
"ecj: invalid or unsupported character set '" + encoding + "', using default" );
// charset remains null
}
Expand All @@ -345,11 +345,11 @@ public void report( Diagnostic<? extends JavaFileObject> diagnostic )
{
charset = Charset.defaultCharset();
}
if ( getLogger().isDebugEnabled() )
if ( log.isDebugEnabled() )
{
getLogger().debug( "ecj: using character set " + charset.displayName() );
getLogger().debug( "ecj command line: " + args );
getLogger().debug( "ecj input source files: " + allSources );
log.debug( "ecj: using character set " + charset.displayName() );
log.debug( "ecj command line: " + args );
log.debug( "ecj input source files: " + allSources );
}

try ( StandardJavaFileManager manager =
Expand All @@ -362,7 +362,7 @@ public void report( Diagnostic<? extends JavaFileObject> diagnostic )
{
throw new EcjFailureException( e.getLocalizedMessage() );
}
getLogger().debug( sw.toString() );
log.debug( sw.toString() );
}
else
{
Expand All @@ -371,13 +371,13 @@ public void report( Diagnostic<? extends JavaFileObject> diagnostic )
try
{
errorF = File.createTempFile( "ecjerr-", ".xml" );
getLogger().debug( "Using legacy BatchCompiler; error file " + errorF );
log.debug( "Using legacy BatchCompiler; error file " + errorF );

args.add( "-log" );
args.add( errorF.toString() );
args.addAll( allSources );

getLogger().debug( "ecj command line: " + args );
log.debug( "ecj command line: " + args );

success = BatchCompiler.compile( args.toArray( new String[args.size()] ), devNull, devNull,
new CompilationProgress()
Expand Down Expand Up @@ -408,7 +408,7 @@ public void worked( int i, int i1 )
{
}
} );
getLogger().debug( sw.toString() );
log.debug( sw.toString() );

if ( errorF.length() < 80 )
{
Expand Down Expand Up @@ -635,7 +635,7 @@ private JavaCompiler getEcj()
}
}
}
getLogger().debug( "Cannot find org.eclipse.jdt.internal.compiler.tool.EclipseCompiler" );
log.debug( "Cannot find org.eclipse.jdt.internal.compiler.tool.EclipseCompiler" );
return null;
}

Expand Down Expand Up @@ -743,7 +743,7 @@ private String decodeVersion( String versionSpec )

if ( versionSpec.equals( "1.9" ) )
{
getLogger().warn( "Version 9 should be specified as 9, not 1.9" );
log.warn( "Version 9 should be specified as 9, not 1.9" );
return "9";
}
return versionSpec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import org.codehaus.plexus.compiler.CompilerConfiguration;
import org.codehaus.plexus.compiler.CompilerException;
import org.codehaus.plexus.compiler.CompilerResult;
import org.codehaus.plexus.logging.LogEnabled;

public interface InProcessCompiler extends LogEnabled {
public interface InProcessCompiler {

CompilerResult compileInProcess(String[] args, final CompilerConfiguration config, String[] sourceFiles)
throws CompilerException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ public CompilerResult performCompile( CompilerConfiguration config )
}
catch ( IOException e )
{
if ( (getLogger() != null ) && getLogger().isWarnEnabled()) {
getLogger().warn( "Unable to autodetect 'javac' path, using 'javac' from the environment." );
if ( log.isWarnEnabled()) {
log.warn( "Unable to autodetect 'javac' path, using 'javac' from the environment." );
}
executable = "javac";
}
Expand Down Expand Up @@ -607,7 +607,7 @@ protected CompilerResult compileOutOfProcess( CompilerConfiguration config, Stri

List<CompilerMessage> messages;

if ( ( getLogger() != null ) && getLogger().isDebugEnabled() )
if ( log.isDebugEnabled() )
{
String debugFileName = StringUtils.isEmpty(config.getDebugFileName()) ? "javac" : config.getDebugFileName();

Expand All @@ -624,9 +624,9 @@ protected CompilerResult compileOutOfProcess( CompilerConfiguration config, Stri
}
catch ( IOException e )
{
if ( ( getLogger() != null ) && getLogger().isWarnEnabled() )
if ( log.isWarnEnabled() )
{
getLogger().warn( "Unable to write '" + commandLineFile.getName() + "' debug script file", e );
log.warn( "Unable to write '" + commandLineFile.getName() + "' debug script file", e );
}
}
}
Expand Down Expand Up @@ -662,8 +662,8 @@ CompilerResult compileInProcess( String[] args, CompilerConfiguration config )
final Thread thread = Thread.currentThread();
final ClassLoader contextClassLoader = thread.getContextClassLoader();
thread.setContextClassLoader( javacClass.getClassLoader() );
if ( (getLogger() != null ) && getLogger().isDebugEnabled()) {
getLogger().debug("ttcl changed run compileInProcessWithProperClassloader");
if ( log.isDebugEnabled()) {
log.debug("ttcl changed run compileInProcessWithProperClassloader");
}
try
{
Expand Down Expand Up @@ -1024,7 +1024,7 @@ private File createFileWithArguments( String[] args, String outputDirectory )
try
{
File tempFile;
if ( ( getLogger() != null ) && getLogger().isDebugEnabled() )
if ( log.isDebugEnabled() )
{
tempFile =
File.createTempFile( JavacCompiler.class.getName(), "arguments", new File( outputDirectory ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import org.codehaus.plexus.compiler.CompilerException;
import org.codehaus.plexus.compiler.CompilerResult;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.tools.Diagnostic;
import javax.tools.DiagnosticCollector;
Expand All @@ -45,8 +46,9 @@
* @since 2.0
*/
@Component( role = InProcessCompiler.class )
public class JavaxToolsCompiler extends AbstractLogEnabled implements InProcessCompiler
public class JavaxToolsCompiler implements InProcessCompiler
{
private final Logger log = LoggerFactory.getLogger( getClass() );
/**
* is that thread safe ???
*/
Expand Down Expand Up @@ -149,7 +151,7 @@ public CompilerResult compileInProcess( String[] args, final CompilerConfigurati
{
// workaround for https://bugs.openjdk.java.net/browse/JDK-8210649
// workaround for https://bugs.openjdk.java.net/browse/JDK-8216202
getLogger().debug( "Ignore Issue get JavaCompiler Diagnostic message (see https://bugs.openjdk.java.net/browse/JDK-8210649):" + e.getMessage(), e );
log.debug( "Ignore Issue get JavaCompiler Diagnostic message (see https://bugs.openjdk.java.net/browse/JDK-8210649):" + e.getMessage(), e );
// in this case we try to replace the baseMessage with toString (hoping this does not throw a new exception..
baseMessage = diagnostic.toString();
}
Expand Down
7 changes: 0 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,6 @@
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
Expand Down