groovy / GMavenPlus

A rewrite of GMaven, a Maven plugin for Groovy
Other
285 stars 35 forks source link

NPE in AbstractToolsMojo.initializeProperties when enabling bindSessionUserOverrideProperties #203

Closed sebthom closed 2 years ago

sebthom commented 3 years ago

To access maven property values that were overridden on the command line I enabled:

<bindAllProjectProperties>true</bindAllProjectProperties>
<bindSessionUserOverrideProperties>true</bindSessionUserOverrideProperties>

The moment I do this and run my build I get the following exception:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.gmavenplus:gmavenplus-plugin:1.13.0:execute (compile) on project jstuff-parent: Execution compile of goal org.codehaus.gmavenplus:gmavenplus-plugin:1.13.0:execute failed.            
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)                                                                                                                                                                                           
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)                                                                                                                                                                                           
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)                                                                                                                                                                                           
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)                                                                                                                                                                  
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)                                                                                                                                                                   
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)                                                                                                                                                     
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)                                                                                                                                                                                   
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)                                                                                                                                                                                                            
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)                                                                                                                                                                                                            
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)                                                                                                                                                                                                              
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)                                                                                                                                                                                                                  
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)                                                                                                                                                                                                                   
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)                                                                                                                                                                                                                     
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)                                                                                                                                                                                                      
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)                                                                                                                                                                                    
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)                                                                                                                                                                            
    at java.lang.reflect.Method.invoke (Method.java:566)                                                                                                                                                                                                                          
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)                                                                                                                                                                                       
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)                                                                                                                                                                                               
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)                                                                                                                                                                                     
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)                                                                                                                                                                                                 
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution compile of goal org.codehaus.gmavenplus:gmavenplus-plugin:1.13.0:execute failed.                                                                                                                           
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)                                                                                                                                                                         
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)                                                                                                                                                                                           
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)                                                                                                                                                                                           
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)                                                                                                                                                                                           
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)                                                                                                                                                                  
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)                                                                                                                                                                   
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)                                                                                                                                                     
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)                                                                                                                                                                                   
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)                                                                                                                                                                                                            
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)                                                                                                                                                                                                            
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)                                                                                                                                                                                                              
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)                                                                                                                                                                                                                  
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)                                                                                                                                                                                                                   
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)                                                                                                                                                                                                                     
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)                                                                                                                                                                                                      
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)                                                                                                                                                                                    
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)                                                                                                                                                                            
    at java.lang.reflect.Method.invoke (Method.java:566)                                                                                                                                                                                                                          
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)                                                                                                                                                                                       
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)                                                                                                                                                                                               
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)                                                                                                                                                                                     
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)                                                                                                                                                                                                 
Caused by: java.lang.NullPointerException                                                                                                                                                                                                                                         
    at java.util.concurrent.ConcurrentHashMap.putVal (ConcurrentHashMap.java:1011)                                                                                                                                                                                                
    at java.util.concurrent.ConcurrentHashMap.put (ConcurrentHashMap.java:1006)                                                                                                                                                                                                   
    at java.util.Properties.put (Properties.java:1340)                                                                                                                                                                                                                            
    at org.codehaus.gmavenplus.mojo.AbstractToolsMojo.initializeProperties (AbstractToolsMojo.java:188)                                                                                                                                                                           
    at org.codehaus.gmavenplus.mojo.ExecuteMojo.setupShell (ExecuteMojo.java:181)                                                                                                                                                                                                 
    at org.codehaus.gmavenplus.mojo.ExecuteMojo.doExecute (ExecuteMojo.java:139)                                                                                                                                                                                                  
    at org.codehaus.gmavenplus.mojo.ExecuteMojo.execute (ExecuteMojo.java:90)                                                                                                                                                                                                     
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)                                                                                                                                                                         
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)                                                                                                                                                                                           
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)                                                                                                                                                                                           
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)                                                                                                                                                                                           
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)                                                                                                                                                                  
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)                                                                                                                                                                   
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)                                                                                                                                                     
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)                                                                                                                                                                                   
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)                                                                                                                                                                                                            
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)                                                                                                                                                                                                            
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)                                                                                                                                                                                                              
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)                                                                                                                                                                                                                  
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)                                                                                                                                                                                                                   
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)                                                                                                                                                                                                                     
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)                                                                                                                                                                                                      
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)                                                                                                                                                                                    
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)                                                                                                                                                                            
    at java.lang.reflect.Method.invoke (Method.java:566)                                                                                                                                                                                                                          
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)                                                                                                                                                                                       
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)                                                                                                                                                                                               
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)                                                                                                                                                                                     
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)                                                                                                                                                                                                 

When I set bindSessionUserOverrideProperties to false the NPE does not occur.

keeganwitt commented 3 years ago

Thanks for reporting this! I think I missed a null check (doh!).

Can you do me a favor and verify this is fixed with 1.13.1-SNAPSHOT? It's published at the repo below, if you don't already have that one configured.

<repository>
  <id>sonatype-oss-snapshots</id>
  <url>https://oss.sonatype.org/content/repositories/snapshots</url>
  <releases>
    <enabled>false</enabled>
  </releases>
  <snapshots>
    <enabled>true</enabled>
    <updatePolicy>always</updatePolicy>
    <checksumPolicy>warn</checksumPolicy>
  </snapshots>
</repository>
sebthom commented 2 years ago

@keeganwitt Works for me. Thanks!

I would really appreciate if you could release 1.13.1 with the fix included soon.

keeganwitt commented 2 years ago

Thank you for verifying. It's available now.