desruisseaux commented on code in PR #997:
URL: 
https://github.com/apache/maven-compiler-plugin/pull/997#discussion_r2541651021


##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -1775,7 +1781,11 @@ private void writeDebugFile(final ToolExecutor executor, 
final Options configura
         final var commandLine = new StringBuilder("For trying to compile from 
the command-line, use:");
         Path dir = basedir;
         if (dir != null) { // Should never be null, but it has been observed 
with some Maven versions.

Review Comment:
   `basedir` is a field declared in this class as below:
   
   ```java
   @Parameter(defaultValue = "${project.basedir}", required = true, readonly = 
true)
   protected Path basedir;
   ```
   
   A value should always be injected by Maven core. But during the development 
of this plugin, sometime when upgrading from a Maven version to the next one, 
or when using a snapshot version compiled from `master`, the value was not 
supplied anymore by Maven core. For example, a similar issue can be reproduced 
with https://github.com/apache/maven/issues/11441 (I don't know if it was the 
same cause).
   
   Even if a null `basedir` may be an indication of a serious problem that we 
want to be aware of, in this particular context, `basedir` is used only for 
making a path relative when creating a debug file. This code is executed only 
if the build failed (or was executed with `--verbose`), so we probably don't 
want the original cause to be hidden by a `NullPointerException` while writing 
debug information.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to