Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

describe compiler configuration on run #248

Merged
merged 1 commit into from
Dec 16, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ protected AbstractCompiler( CompilerOutputStyle compilerOutputStyle, String inpu
//
// ----------------------------------------------------------------------

public abstract String getCompilerId();

public CompilerResult performCompile(CompilerConfiguration configuration)
throws CompilerException
{
Expand Down Expand Up @@ -308,7 +310,8 @@ protected void logCompiling( String[] sourceFiles, CompilerConfiguration config
config.getWorkingDirectory().toPath().relativize( new File( config.getOutputLocation() ).toPath() ).toString();
getLogger().info( "Compiling " +
( sourceFiles == null ? "" : ( sourceFiles.length + " source file" + ( sourceFiles.length == 1 ? " " : "s " ) ) ) +
"to " + to );
"with " + getCompilerId() + " [" + config.describe() + "]" +
" to " + to );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* SOFTWARE.
*/

import org.codehaus.plexus.util.StringUtils;

import java.io.File;
import java.util.AbstractMap;
import java.util.ArrayList;
Expand Down Expand Up @@ -812,4 +814,54 @@ public void setImplicitOption( String implicitOption )
{
this.implicitOption = implicitOption;
}

public String describe()
{
List<String> params = new ArrayList<>();

if ( isFork() )
{
params.add( "forked" );
}

// base options: debug, optimize, verbose, deprecation
if ( isDebug() )
{
if ( StringUtils.isNotEmpty( getDebugLevel() ) )
{
params.add( "debug:" + getDebugLevel() );
}
else
{
params.add( "debug" );
}
}
if ( isOptimize() )
{
params.add( "optimize" );
}
if ( isVerbose() )
{
params.add( "verbose" );
}
if ( isShowDeprecation() )
{
params.add( "deprecation" );
}

// target bytecode options: release or target, module-path
if ( !StringUtils.isEmpty( getReleaseVersion() ) )
{
params.add( "release " + getReleaseVersion() );
}
else if ( !StringUtils.isEmpty( getTargetVersion() ) )
{
params.add( "target " + getTargetVersion() );
}
if ( getModulepathEntries() != null && !getModulepathEntries().isEmpty() )
{
params.add( "module-path" );
}
return String.join( " ", params );
}
}
7 changes: 3 additions & 4 deletions plexus-compiler-its/src/main/it/simple-javac-fork/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@
<modelVersion>4.0.0</modelVersion>

<groupId>org.codehaus.plexus.compiler.it</groupId>
<artifactId>simple-javac</artifactId>
<artifactId>simple-javac-forked</artifactId>
<version>1.0-SNAPSHOT</version>

<name>Test for default configuration</name>
<name>Test for default configuration with forked=true</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<plexus.compiler.version>@pom.version@</plexus.compiler.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@ public AspectJCompiler()
super( CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE, "", ".class", null );
}

@Override
public String getCompilerId()
{
return "aspectj";
}

public CompilerResult performCompile( CompilerConfiguration config )
throws CompilerException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ public CSharpCompiler()
// Compiler Implementation
// ----------------------------------------------------------------------

@Override
public String getCompilerId()
{
return "csharp";
}

public boolean canUpdateTarget( CompilerConfiguration configuration )
throws CompilerException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public EclipseJavaCompiler()
// ----------------------------------------------------------------------
boolean errorsAsWarnings = false;

@Override
public String getCompilerId()
{
return "eclipse";
}

@Override
public CompilerResult performCompile( CompilerConfiguration config )
throws CompilerException
Expand Down Expand Up @@ -371,6 +377,10 @@ public void report( Diagnostic<? extends JavaFileObject> diagnostic )
args.add( errorF.toString() );
args.addAll( allSources );

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

success = BatchCompiler.compile( args.toArray( new String[args.size()] ), devNull, devNull,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
* Ma&icirc;tre</a>
*
*/
@Component( role = Compiler.class, hint = "j2objc ")
@Component( role = Compiler.class, hint = "j2objc")
public class J2ObjCCompiler
extends AbstractCompiler
{
Expand Down Expand Up @@ -98,6 +98,12 @@ public J2ObjCCompiler()
// Compiler Implementation
// ----------------------------------------------------------------------

@Override
public String getCompilerId()
{
return "j2objc";
}

public boolean canUpdateTarget( CompilerConfiguration configuration )
throws CompilerException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
public class JavacCompilerWithErrorProne
extends JavacCompiler
{
@Override
public String getCompilerId()
{
return "javac-with-errorprone";
}

private static class NonDelegatingClassLoader
extends URLClassLoader
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ public JavacCompiler()
// Compiler Implementation
// ----------------------------------------------------------------------

@Override
public String getCompilerId()
{
return "javac";
}

@Override
public CompilerResult performCompile( CompilerConfiguration config )
throws CompilerException
Expand Down