Skip to content

Commit

Permalink
share "Compiling" log message logic in AbstractCompiler
Browse files Browse the repository at this point in the history
  • Loading branch information
hboutemy committed Dec 15, 2022
1 parent b396872 commit 37f6843
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,16 @@ protected static String[] toStringArray( List<String> arguments )

return args;
}

protected void logCompiling( String[] sourceFiles, CompilerConfiguration config )
{
if ( ( getLogger() != null ) && getLogger().isInfoEnabled() )
{
String to = ( config.getWorkingDirectory() == null ) ? config.getOutputLocation() :
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 );
}
}
}
17 changes: 17 additions & 0 deletions plexus-compiler-its/src/main/it/error-prone-compiler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@
</path>
</annotationProcessorPaths>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-api</artifactId>
<version>${plexus.compiler.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac-errorprone</artifactId>
<version>${plexus.compiler.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac</artifactId>
<version>${plexus.compiler.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,7 @@ public CompilerResult performCompile( CompilerConfiguration config )
return new CompilerResult();
}

String to = ( config.getWorkingDirectory() == null ) ? config.getOutputLocation() :
config.getWorkingDirectory().toPath().relativize( destinationDir.toPath() ).toString();
System.out.println(
"Compiling " + sourceFiles.length + " " + "source file" + ( sourceFiles.length == 1 ? "" : "s" ) + " to "
+ to );
logCompiling( sourceFiles, config );

// String[] args = buildCompilerArguments( config, sourceFiles );
AjBuildConfig buildConfig = buildCompilerConfig( config );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ public CompilerResult performCompile( CompilerConfiguration config )
return new CompilerResult().success( true );
}

System.out.println( "Compiling " + sourceFiles.length + " " + "source file" +
( sourceFiles.length == 1 ? "" : "s" ) + " to " + destinationDir.getAbsolutePath() );
logCompiling( sourceFiles, config );

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ public CompilerResult performCompile( CompilerConfiguration config )

allSources = resortSourcesToPutModuleInfoFirst( allSources );

logCompiling( null, config );

// Compile
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ public CompilerResult performCompile( CompilerConfiguration config )
return new CompilerResult().success( true );
}

System.out.println(
"Compiling " + sourceFiles.length + " " + "source file" + ( sourceFiles.length == 1 ? "" : "s" ) + " to "
+ destinationDir.getAbsolutePath() );
logCompiling( sourceFiles, config );

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,7 @@ public CompilerResult performCompile( CompilerConfiguration config )
return new CompilerResult();
}

if ( ( getLogger() != null ) && getLogger().isInfoEnabled() )
{
String to = ( config.getWorkingDirectory() == null ) ? config.getOutputLocation() :
config.getWorkingDirectory().toPath().relativize( destinationDir.toPath() ).toString();
getLogger().info( "Compiling " + sourceFiles.length + " " +
"source file" + ( sourceFiles.length == 1 ? "" : "s" ) +
" to " + to );
}
logCompiling( sourceFiles, config );

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

Expand Down

0 comments on commit 37f6843

Please sign in to comment.