Skip to content

Commit 2ed77f5

Browse files
committed
Drop dependency to plexus-container-default - replace logging with slf4j
1 parent da2c714 commit 2ed77f5

File tree

8 files changed

+37
-39
lines changed

8 files changed

+37
-39
lines changed

plexus-compiler-api/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
<groupId>org.codehaus.plexus</groupId>
1919
<artifactId>plexus-utils</artifactId>
2020
</dependency>
21+
<dependency>
22+
<groupId>org.slf4j</groupId>
23+
<artifactId>slf4j-api</artifactId>
24+
<version>1.7.36</version>
25+
</dependency>
2126
<dependency>
2227
<groupId>org.junit.jupiter</groupId>
2328
<artifactId>junit-jupiter-api</artifactId>

plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/AbstractCompiler.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
* SOFTWARE.
2525
*/
2626

27-
import org.codehaus.plexus.logging.AbstractLogEnabled;
2827
import org.codehaus.plexus.util.DirectoryScanner;
28+
import org.slf4j.Logger;
29+
import org.slf4j.LoggerFactory;
2930

3031
import java.io.File;
3132
import java.io.IOException;
@@ -39,9 +40,9 @@
3940
* @author <a href="mailto:[email protected]">Trygve Laugst&oslash;l</a>
4041
*/
4142
public abstract class AbstractCompiler
42-
extends AbstractLogEnabled
4343
implements Compiler
4444
{
45+
protected Logger log = LoggerFactory.getLogger ( getClass() );
4546
protected static final String EOL = System.lineSeparator();
4647

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

281282
protected void logCompiling( String[] sourceFiles, CompilerConfiguration config )
282283
{
283-
if ( ( getLogger() != null ) && getLogger().isInfoEnabled() )
284+
if ( log.isInfoEnabled() )
284285
{
285286
String to = ( config.getWorkingDirectory() == null ) ? config.getOutputLocation() :
286287
config.getWorkingDirectory().toPath().relativize( new File( config.getOutputLocation() ).toPath() ).toString();
287-
getLogger().info( "Compiling " +
288+
log.info( "Compiling " +
288289
( sourceFiles == null ? "" : ( sourceFiles.length + " source file" + ( sourceFiles.length == 1 ? " " : "s " ) ) ) +
289290
"with " + getCompilerId() + " [" + config.describe() + "]" +
290291
" to " + to );

plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/manager/DefaultCompilerManager.java

-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.codehaus.plexus.compiler.Compiler;
2828
import org.codehaus.plexus.component.annotations.Component;
2929
import org.codehaus.plexus.component.annotations.Requirement;
30-
import org.codehaus.plexus.logging.AbstractLogEnabled;
3130

3231
import java.util.Map;
3332

@@ -36,7 +35,6 @@
3635
*/
3736
@Component( role = CompilerManager.class )
3837
public class DefaultCompilerManager
39-
extends AbstractLogEnabled
4038
implements CompilerManager
4139
{
4240
@Requirement

plexus-compilers/plexus-compiler-eclipse/src/main/java/org/codehaus/plexus/compiler/eclipse/EclipseJavaCompiler.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,13 @@ public CompilerResult performCompile( CompilerConfiguration config )
268268
boolean success = false;
269269
if ( compiler != null )
270270
{
271-
getLogger().debug( "Using JSR-199 EclipseCompiler" );
271+
log.debug( "Using JSR-199 EclipseCompiler" );
272272
// ECJ JSR-199 compiles against the latest Java version it supports if no source
273273
// version is given explicitly. BatchCompiler uses 1.3 as default. So check
274274
// whether a source version is specified, and if not supply 1.3 explicitly.
275275
if ( !haveSourceOrReleaseArgument( args ) )
276276
{
277-
getLogger().debug( "ecj: no source level nor release specified, defaulting to Java 1.3" );
277+
log.debug( "ecj: no source level nor release specified, defaulting to Java 1.3" );
278278
args.add( "-source" );
279279
args.add( "1.3" );
280280
}
@@ -336,7 +336,7 @@ public void report( Diagnostic<? extends JavaFileObject> diagnostic )
336336
}
337337
catch ( IllegalCharsetNameException | UnsupportedCharsetException e )
338338
{
339-
getLogger().warn(
339+
log.warn(
340340
"ecj: invalid or unsupported character set '" + encoding + "', using default" );
341341
// charset remains null
342342
}
@@ -345,11 +345,11 @@ public void report( Diagnostic<? extends JavaFileObject> diagnostic )
345345
{
346346
charset = Charset.defaultCharset();
347347
}
348-
if ( getLogger().isDebugEnabled() )
348+
if ( log.isDebugEnabled() )
349349
{
350-
getLogger().debug( "ecj: using character set " + charset.displayName() );
351-
getLogger().debug( "ecj command line: " + args );
352-
getLogger().debug( "ecj input source files: " + allSources );
350+
log.debug( "ecj: using character set " + charset.displayName() );
351+
log.debug( "ecj command line: " + args );
352+
log.debug( "ecj input source files: " + allSources );
353353
}
354354

355355
try ( StandardJavaFileManager manager =
@@ -362,7 +362,7 @@ public void report( Diagnostic<? extends JavaFileObject> diagnostic )
362362
{
363363
throw new EcjFailureException( e.getLocalizedMessage() );
364364
}
365-
getLogger().debug( sw.toString() );
365+
log.debug( sw.toString() );
366366
}
367367
else
368368
{
@@ -371,13 +371,13 @@ public void report( Diagnostic<? extends JavaFileObject> diagnostic )
371371
try
372372
{
373373
errorF = File.createTempFile( "ecjerr-", ".xml" );
374-
getLogger().debug( "Using legacy BatchCompiler; error file " + errorF );
374+
log.debug( "Using legacy BatchCompiler; error file " + errorF );
375375

376376
args.add( "-log" );
377377
args.add( errorF.toString() );
378378
args.addAll( allSources );
379379

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

382382
success = BatchCompiler.compile( args.toArray( new String[args.size()] ), devNull, devNull,
383383
new CompilationProgress()
@@ -408,7 +408,7 @@ public void worked( int i, int i1 )
408408
{
409409
}
410410
} );
411-
getLogger().debug( sw.toString() );
411+
log.debug( sw.toString() );
412412

413413
if ( errorF.length() < 80 )
414414
{
@@ -635,7 +635,7 @@ private JavaCompiler getEcj()
635635
}
636636
}
637637
}
638-
getLogger().debug( "Cannot find org.eclipse.jdt.internal.compiler.tool.EclipseCompiler" );
638+
log.debug( "Cannot find org.eclipse.jdt.internal.compiler.tool.EclipseCompiler" );
639639
return null;
640640
}
641641

@@ -743,7 +743,7 @@ private String decodeVersion( String versionSpec )
743743

744744
if ( versionSpec.equals( "1.9" ) )
745745
{
746-
getLogger().warn( "Version 9 should be specified as 9, not 1.9" );
746+
log.warn( "Version 9 should be specified as 9, not 1.9" );
747747
return "9";
748748
}
749749
return versionSpec;

plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/InProcessCompiler.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
import org.codehaus.plexus.compiler.CompilerConfiguration;
44
import org.codehaus.plexus.compiler.CompilerException;
55
import org.codehaus.plexus.compiler.CompilerResult;
6-
import org.codehaus.plexus.logging.LogEnabled;
76

8-
public interface InProcessCompiler extends LogEnabled {
7+
public interface InProcessCompiler {
98

109
CompilerResult compileInProcess(String[] args, final CompilerConfiguration config, String[] sourceFiles)
1110
throws CompilerException;

plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ public CompilerResult performCompile( CompilerConfiguration config )
165165
}
166166
catch ( IOException e )
167167
{
168-
if ( (getLogger() != null ) && getLogger().isWarnEnabled()) {
169-
getLogger().warn( "Unable to autodetect 'javac' path, using 'javac' from the environment." );
168+
if ( log.isWarnEnabled()) {
169+
log.warn( "Unable to autodetect 'javac' path, using 'javac' from the environment." );
170170
}
171171
executable = "javac";
172172
}
@@ -607,7 +607,7 @@ protected CompilerResult compileOutOfProcess( CompilerConfiguration config, Stri
607607

608608
List<CompilerMessage> messages;
609609

610-
if ( ( getLogger() != null ) && getLogger().isDebugEnabled() )
610+
if ( log.isDebugEnabled() )
611611
{
612612
String debugFileName = StringUtils.isEmpty(config.getDebugFileName()) ? "javac" : config.getDebugFileName();
613613

@@ -624,9 +624,9 @@ protected CompilerResult compileOutOfProcess( CompilerConfiguration config, Stri
624624
}
625625
catch ( IOException e )
626626
{
627-
if ( ( getLogger() != null ) && getLogger().isWarnEnabled() )
627+
if ( log.isWarnEnabled() )
628628
{
629-
getLogger().warn( "Unable to write '" + commandLineFile.getName() + "' debug script file", e );
629+
log.warn( "Unable to write '" + commandLineFile.getName() + "' debug script file", e );
630630
}
631631
}
632632
}
@@ -662,8 +662,8 @@ CompilerResult compileInProcess( String[] args, CompilerConfiguration config )
662662
final Thread thread = Thread.currentThread();
663663
final ClassLoader contextClassLoader = thread.getContextClassLoader();
664664
thread.setContextClassLoader( javacClass.getClassLoader() );
665-
if ( (getLogger() != null ) && getLogger().isDebugEnabled()) {
666-
getLogger().debug("ttcl changed run compileInProcessWithProperClassloader");
665+
if ( log.isDebugEnabled()) {
666+
log.debug("ttcl changed run compileInProcessWithProperClassloader");
667667
}
668668
try
669669
{
@@ -1024,7 +1024,7 @@ private File createFileWithArguments( String[] args, String outputDirectory )
10241024
try
10251025
{
10261026
File tempFile;
1027-
if ( ( getLogger() != null ) && getLogger().isDebugEnabled() )
1027+
if ( log.isDebugEnabled() )
10281028
{
10291029
tempFile =
10301030
File.createTempFile( JavacCompiler.class.getName(), "arguments", new File( outputDirectory ) );

plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavaxToolsCompiler.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
import org.codehaus.plexus.compiler.CompilerException;
2424
import org.codehaus.plexus.compiler.CompilerResult;
2525
import org.codehaus.plexus.component.annotations.Component;
26-
import org.codehaus.plexus.logging.AbstractLogEnabled;
26+
import org.slf4j.Logger;
27+
import org.slf4j.LoggerFactory;
2728

2829
import javax.tools.Diagnostic;
2930
import javax.tools.DiagnosticCollector;
@@ -45,8 +46,9 @@
4546
* @since 2.0
4647
*/
4748
@Component( role = InProcessCompiler.class )
48-
public class JavaxToolsCompiler extends AbstractLogEnabled implements InProcessCompiler
49+
public class JavaxToolsCompiler implements InProcessCompiler
4950
{
51+
private final Logger log = LoggerFactory.getLogger( getClass() );
5052
/**
5153
* is that thread safe ???
5254
*/
@@ -149,7 +151,7 @@ public CompilerResult compileInProcess( String[] args, final CompilerConfigurati
149151
{
150152
// workaround for https://bugs.openjdk.java.net/browse/JDK-8210649
151153
// workaround for https://bugs.openjdk.java.net/browse/JDK-8216202
152-
getLogger().debug( "Ignore Issue get JavaCompiler Diagnostic message (see https://bugs.openjdk.java.net/browse/JDK-8210649):" + e.getMessage(), e );
154+
log.debug( "Ignore Issue get JavaCompiler Diagnostic message (see https://bugs.openjdk.java.net/browse/JDK-8210649):" + e.getMessage(), e );
153155
// in this case we try to replace the baseMessage with toString (hoping this does not throw a new exception..
154156
baseMessage = diagnostic.toString();
155157
}

pom.xml

-7
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,6 @@
107107
</dependency>
108108
</dependencies>
109109
</dependencyManagement>
110-
<dependencies>
111-
<dependency>
112-
<groupId>org.codehaus.plexus</groupId>
113-
<artifactId>plexus-container-default</artifactId>
114-
<scope>provided</scope>
115-
</dependency>
116-
</dependencies>
117110

118111
<build>
119112
<pluginManagement>

0 commit comments

Comments
 (0)