Skip to content

Commit 4385845

Browse files
committed
describe compiler configuration on run
1 parent dcac4ea commit 4385845

File tree

5 files changed

+76
-4
lines changed

5 files changed

+76
-4
lines changed

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
* SOFTWARE.
2525
*/
2626

27+
import org.codehaus.plexus.util.StringUtils;
28+
2729
import java.io.File;
2830
import java.util.AbstractMap;
2931
import java.util.ArrayList;
@@ -812,4 +814,54 @@ public void setImplicitOption( String implicitOption )
812814
{
813815
this.implicitOption = implicitOption;
814816
}
817+
818+
public String describe( String id )
819+
{
820+
List<String> params = new ArrayList<>();
821+
params.add( id );
822+
if ( isFork() )
823+
{
824+
params.add( "forked" );
825+
}
826+
827+
// base options: debug, optimize, verbose, deprecation
828+
if ( isDebug() )
829+
{
830+
if ( StringUtils.isNotEmpty( getDebugLevel() ) )
831+
{
832+
params.add( "debug:" + getDebugLevel() );
833+
}
834+
else
835+
{
836+
params.add( "debug" );
837+
}
838+
}
839+
if ( isOptimize() )
840+
{
841+
params.add( "optimize" );
842+
}
843+
if ( isVerbose() )
844+
{
845+
params.add( "verbose" );
846+
}
847+
if ( isShowDeprecation() )
848+
{
849+
params.add( "deprecation" );
850+
}
851+
852+
// target bytecode options: release or target, module-path
853+
if ( !StringUtils.isEmpty( getReleaseVersion() ) )
854+
{
855+
params.add( "release " + getReleaseVersion() );
856+
}
857+
else if ( !StringUtils.isEmpty( getTargetVersion() ) )
858+
{
859+
params.add( "target " + getTargetVersion() );
860+
}
861+
if ( getModulepathEntries() != null && !getModulepathEntries().isEmpty() )
862+
{
863+
params.add( "module-path" );
864+
}
865+
return String.join( " ", params );
866+
}
815867
}

plexus-compiler-its/src/main/it/simple-javac-fork/pom.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@
2424
<modelVersion>4.0.0</modelVersion>
2525

2626
<groupId>org.codehaus.plexus.compiler.it</groupId>
27-
<artifactId>simple-javac</artifactId>
27+
<artifactId>simple-javac-forked</artifactId>
2828
<version>1.0-SNAPSHOT</version>
2929

30-
<name>Test for default configuration</name>
30+
<name>Test for default configuration with forked=true</name>
3131

3232
<properties>
3333
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3434
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
35-
<maven.compiler.source>11</maven.compiler.source>
36-
<maven.compiler.target>11</maven.compiler.target>
35+
<maven.compiler.release>11</maven.compiler.release>
3736
<plexus.compiler.version>@pom.version@</plexus.compiler.version>
3837
</properties>
3938

plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajc/AspectJCompiler.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,14 @@ public CompilerResult performCompile( CompilerConfiguration config )
320320
return new CompilerResult();
321321
}
322322

323+
<<<<<<< Upstream, based on plexus/master
323324
logCompiling( sourceFiles, config );
325+
=======
326+
System.out.println(
327+
"Compiling " + sourceFiles.length + " source file" + ( sourceFiles.length == 1 ? "" : "s" ) +
328+
" with " + config.describe( "aspectj" ) +
329+
" to " + destinationDir.getAbsolutePath() );
330+
>>>>>>> 97348ff describe compiler configuration on run
324331

325332
// String[] args = buildCompilerArguments( config, sourceFiles );
326333
AjBuildConfig buildConfig = buildCompilerConfig( config );

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@ public void report( Diagnostic<? extends JavaFileObject> diagnostic )
371371
args.add( errorF.toString() );
372372
args.addAll( allSources );
373373

374+
String to = ( config.getWorkingDirectory() == null ) ? config.getOutputLocation() :
375+
config.getWorkingDirectory().toPath().relativize( new File( config.getOutputLocation() ).toPath() ).toString();
376+
getLogger().info( "Compiling with " + config.describe( "eclipse" ) +
377+
" to " + to );
374378
getLogger().debug( "ecj command line: " + args );
375379

376380
success = BatchCompiler.compile( args.toArray( new String[args.size()] ), devNull, devNull,

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,17 @@ public CompilerResult performCompile( CompilerConfiguration config )
141141
return new CompilerResult();
142142
}
143143

144+
<<<<<<< Upstream, based on plexus/master
144145
logCompiling( sourceFiles, config );
146+
=======
147+
if ( ( getLogger() != null ) && getLogger().isInfoEnabled() )
148+
{
149+
getLogger().info( "Compiling " + sourceFiles.length +
150+
" source file" + ( sourceFiles.length == 1 ? "" : "s" ) +
151+
" with " + config.describe( "javac" ) +
152+
" to " + destinationDir.getAbsolutePath() );
153+
}
154+
>>>>>>> 97348ff describe compiler configuration on run
145155

146156
String[] args = buildCompilerArguments( config, sourceFiles );
147157

0 commit comments

Comments
 (0)