desruisseaux opened a new issue, #11441:
URL: https://github.com/apache/maven/issues/11441

   ### Affected version
   
   4.0.0-rc-5
   
   ### Bug description
   
   I tried to upgrade Maven JAR plugin from Maven 4.0.0-rc-4 to Maven 
4.0.0-rc-5 with [this 
commit](https://github.com/Geomatys/maven-jar-plugin/commit/e82b7a4740fd46912e6241c056027583a3db16d3).
 The JUnit tests pass, but 9 integration tests fail (22 passes). Many failures 
have the same cause:
   
   ```
   org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute 
goal org.apache.maven.plugins:maven-jar-plugin:4.0.0-beta-2-SNAPSHOT:test-jar 
(default) on project maven-jar-plugin-test-mjar-199: Execution default of goal 
org.apache.maven.plugins:maven-jar-plugin:4.0.0-beta-2-SNAPSHOT:test-jar 
failed: basedir is not allowed to be null
       at 
org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:346)
       (...strip...)
   Caused by: org.apache.maven.plugin.PluginExecutionException: Execution 
default of goal 
org.apache.maven.plugins:maven-jar-plugin:4.0.0-beta-2-SNAPSHOT:test-jar 
failed: basedir is not allowed to be null
       at 
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:159)
       (...strip...)
   Caused by: java.lang.NullPointerException: basedir is not allowed to be null
       at java.util.Objects.requireNonNull(Objects.java:246)
       at 
org.apache.maven.plugins.jar.AbstractJarMojo.getJarFile(AbstractJarMojo.java:218)
       at 
org.apache.maven.plugins.jar.AbstractJarMojo.createArchive(AbstractJarMojo.java:231)
       at 
org.apache.maven.plugins.jar.AbstractJarMojo.execute(AbstractJarMojo.java:301)
       at org.apache.maven.plugins.jar.TestJarMojo.execute(TestJarMojo.java:86)
       (...strip...)
   ```
   
   By running the plugin in a debugger, we can see that the following field of 
`AbstractJarMojo`:
   
   ```java
       /**
        * Directory containing the generated JAR.
        */
       @Parameter(defaultValue = "${project.build.directory}", required = true)
       private Path outputDirectory;
   ```
   
   Is correctly set to a non-null value when running the `jar` goal, but is 
null when running the `test-jar` goal. The `pom.xml` contains the following:
   
   ```xml
       <plugins>
         <plugin>
           <artifactId>maven-jar-plugin</artifactId>
           <executions>
             <execution>
               <goals>
                 <goal>test-jar</goal>
               </goals>
             </execution>
           </executions>
         </plugin>
       </plugins>
   ```
   
   The issue can be reproduced as below:
   
   * Checkout the master branch of https://github.com/apache/maven-jar-plugin
   * In the `pom.xml`, set `<mavenVersion>4.0.0-rc-5</mavenVersion>`.
   * Run `mvn clean install` with Maven 4.0.0-rc-5. Is should succeed.
   * Run `-P run-its verify`. There is test failures.
   * `cd target/it/MJAR-199`, which is the simplest test case.
   * `mvn package --debug` with a breakpoint on the `getJarFile` method. First 
execution is okay (the main JAR), the second execution is not (the test JAR).
   
   Note: it seems to be a more generic issue than only the `outputDirectory` 
field. Doing the same experiment in `MJAR-162`, which contains a 
`<skipIfEmpty>true</skipIfEmpty>` configuration, the debugger tells me that the 
`AbstractJarMojo.skipIfEmpty` field stay `false`.


-- 
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