Skip to content

Commit

Permalink
simplify "Compiling" info message: display relative path (#250)
Browse files Browse the repository at this point in the history
simplify "Compiling" info message: display relative path
  • Loading branch information
hboutemy authored Dec 15, 2022
1 parent 2bbba88 commit dcac4ea
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 14 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,9 +320,7 @@ public CompilerResult performCompile( CompilerConfiguration config )
return new CompilerResult();
}

System.out.println(
"Compiling " + sourceFiles.length + " " + "source file" + ( sourceFiles.length == 1 ? "" : "s" ) + " to "
+ destinationDir.getAbsolutePath() );
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,12 +141,7 @@ public CompilerResult performCompile( CompilerConfiguration config )
return new CompilerResult();
}

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

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

Expand Down

0 comments on commit dcac4ea

Please sign in to comment.