Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE when running shamrock:create in existing Maven project #527

Closed
gsmet opened this issue Jan 16, 2019 · 4 comments
Closed

NPE when running shamrock:create in existing Maven project #527

gsmet opened this issue Jan 16, 2019 · 4 comments
Assignees
Labels
kind/bug Something isn't working
Milestone

Comments

@gsmet
Copy link
Member

gsmet commented Jan 16, 2019

I accidentally run mvn -X org.jboss.shamrock:shamrock-maven-plugin:1.0.0.Alpha1-SNAPSHOT:create -DprojectGroupId=org.acme -DprojectArtifactId=using-opentracing -DclassName="org.acme.opentracing.TracedResource" -Dpath="/hello" -Dextensions="tracing" in the root of my Shamrock git clone.

I end up with a weird state:

  • a src/ directory created at the root
  • a NPE:
Caused by: java.lang.NullPointerException
    at org.jboss.shamrock.maven.CreateProjectMojo.addPluginManagementSection (CreateProjectMojo.java:218)
    at org.jboss.shamrock.maven.CreateProjectMojo.addMainPluginConfig (CreateProjectMojo.java:186)
    at org.jboss.shamrock.maven.CreateProjectMojo.execute (CreateProjectMojo.java:136)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    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:954)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)

While it's a user error, I thought it was supposed to create a subdirectory if the directory was not empty? Moreover failing with a NPE does not look nice.

I wouldn't mind if we threw an error altogether if we try to do that in an existing Maven project.

@cescoffier
Copy link
Member

good catch! Right now it tries to make a guess if you want to create or extend. It should be improved and not failed with an NPE.

@cescoffier
Copy link
Member

typically, if there is a pom.xml using packaging pom - it should report a user error.

@gsmet
Copy link
Member Author

gsmet commented Jan 16, 2019

Hmmm, I'm not sure we should try to extend an existing project with a create operation. I would simplify that.

@cescoffier
Copy link
Member

Yes, that would simplify a LOT! so +1.
However, add-extension will still need to do some lookup, but it's much simpler in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants