Skip to content

Commit 0f97702

Browse files
committed
describe compiler configuration on run
1 parent 3a4d8bd commit 0f97702

File tree

5 files changed

+59
-8
lines changed

5 files changed

+59
-8
lines changed

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

Lines changed: 48 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,50 @@ 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+
if ( !StringUtils.isEmpty( getReleaseVersion() ) )
827+
{
828+
params.add( "release " + getReleaseVersion() );
829+
}
830+
else if ( !StringUtils.isEmpty( getTargetVersion() ) )
831+
{
832+
params.add( "target " + getTargetVersion() );
833+
}
834+
if ( getModulepathEntries() != null && !getModulepathEntries().isEmpty() )
835+
{
836+
params.add( "module-path" );
837+
}
838+
if ( isDebug() )
839+
{
840+
if ( StringUtils.isNotEmpty( getDebugLevel() ) )
841+
{
842+
params.add( "debug:" + getDebugLevel() );
843+
}
844+
else
845+
{
846+
params.add( "debug" );
847+
}
848+
}
849+
if ( isOptimize() )
850+
{
851+
params.add( "optimize" );
852+
}
853+
if ( isVerbose() )
854+
{
855+
params.add( "verbose" );
856+
}
857+
if ( isShowDeprecation() )
858+
{
859+
params.add( "deprecation" );
860+
}
861+
return String.join( " ", params );
862+
}
815863
}

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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,9 @@ public CompilerResult performCompile( CompilerConfiguration config )
321321
}
322322

323323
System.out.println(
324-
"Compiling " + sourceFiles.length + " " + "source file" + ( sourceFiles.length == 1 ? "" : "s" ) + " to "
325-
+ destinationDir.getAbsolutePath() );
324+
"Compiling " + sourceFiles.length + " source file" + ( sourceFiles.length == 1 ? "" : "s" ) +
325+
" with " + config.describe( "javac" ) +
326+
" to " + destinationDir.getAbsolutePath() );
326327

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

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ public void report( Diagnostic<? extends JavaFileObject> diagnostic )
369369
args.add( errorF.toString() );
370370
args.addAll( allSources );
371371

372+
getLogger().info( "Compiling with " + config.describe( "eclipse" ) +
373+
" to " + config.getOutputLocation() );
372374
getLogger().debug( "ecj command line: " + args );
373375

374376
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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ public CompilerResult performCompile( CompilerConfiguration config )
143143

144144
if ( ( getLogger() != null ) && getLogger().isInfoEnabled() )
145145
{
146-
getLogger().info( "Compiling " + sourceFiles.length + " " +
147-
"source file" + ( sourceFiles.length == 1 ? "" : "s" ) +
146+
getLogger().info( "Compiling " + sourceFiles.length +
147+
" source file" + ( sourceFiles.length == 1 ? "" : "s" ) +
148+
" with " + config.describe( "javac" ) +
148149
" to " + destinationDir.getAbsolutePath() );
149150
}
150151

0 commit comments

Comments
 (0)