jruby / jruby-maven-plugins

maven plugin to handle rubygems in a maven way. including support for rspec, rails, cucumber, rake, etc
MIT License
112 stars 46 forks source link

NPE in GemsInstaller.installGems #52

Closed ddossot closed 10 years ago

ddossot commented 10 years ago

Using rmvn and gem-maven-plugin, I get an NPE when packaging my application.

The reason is that new File(this.config.getGemHome(), "specifications") returns null because target/rubygems/ doesn't exist.

[INFO] Successfully installed ruby-maven-3.1.1.0.2
[INFO] Successfully installed maven-tools-0.34.3
[INFO] Successfully installed virtus-0.5.5
[INFO] Successfully installed backports-3.6.0
[INFO] Successfully installed descendants_tracker-0.0.4
[INFO] Successfully installed ruby-maven-libs-3.1.1
[INFO] Successfully installed aws-sdk-1.36.0
[INFO] Successfully installed uuidtools-2.1.4
[INFO] Successfully installed nokogiri-1.6.1-java
[INFO] Successfully installed mini_portile-0.5.3
[INFO] Successfully installed json-1.8.1-java
[INFO] Successfully installed deep_merge-1.0.1
[INFO] Successfully installed hashr-0.0.22
[INFO] Successfully installed json-schema-2.2.2
[INFO] Successfully installed activerecord-jdbcmysql-adapter-1.3.6
[INFO] Successfully installed activerecord-jdbc-adapter-1.3.6
[INFO] Successfully installed activerecord-4.1.0
[INFO] Successfully installed activemodel-4.1.0
[INFO] Successfully installed builder-3.2.2
[INFO] Successfully installed arel-5.0.0
[INFO] Successfully installed jdbc-mysql-5.1.28
[INFO] Successfully installed guard-rspec-4.0.4
[INFO] Successfully installed guard-2.6.0
[INFO] Successfully installed thor-0.19.1
[INFO] Successfully installed listen-2.7.1
[INFO] Successfully installed celluloid-0.15.2
[INFO] Successfully installed timers-1.1.0
[INFO] Successfully installed celluloid-io-0.15.0
[INFO] Successfully installed nio4r-1.0.0-java
[INFO] Successfully installed rb-fsevent-0.9.4
[INFO] Successfully installed rb-inotify-0.9.3
[INFO] Successfully installed ffi-1.9.3-java
[INFO] Successfully installed pry-0.9.12.6-java
[INFO] Successfully installed coderay-1.1.0
[INFO] Successfully installed slop-3.5.0
[INFO] Successfully installed method_source-0.8.2
[INFO] Successfully installed spoon-0.0.4
[INFO] Successfully installed lumberjack-1.0.5
[INFO] Successfully installed formatador-0.2.4
[INFO] Successfully installed rspec-mocks-2.14.6
[INFO] Successfully installed shoulda-matchers-2.4.0
[INFO] Successfully installed activesupport-4.1.0
[INFO] Successfully installed i18n-0.6.9
[INFO] Successfully installed tzinfo-1.1.0
[INFO] Successfully installed minitest-5.3.2
[INFO] Successfully installed thread_safe-0.3.3-java
[INFO] Successfully installed simplecov-0.7.1
[INFO] Successfully installed multi_json-1.9.2
[INFO] Successfully installed simplecov-html-0.7.1
[INFO] Successfully installed vcr-2.6.0
[INFO] Successfully installed webmock-1.14.0
[INFO] Successfully installed addressable-2.3.6
[INFO] Successfully installed crack-0.4.2
[INFO] Successfully installed safe_yaml-1.0.2
[INFO] 54 gems installed
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3:58.834s
[INFO] Finished at: Thu Apr 10 09:21:04 PDT 2014
[INFO] Final Memory: 36M/162M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal de.saumya.mojo:gem-maven-plugin:1.0.0-rc4:initialize (default) on project lp-leads-viewer: Execution default of goal de.saumya.mojo:gem-maven-plugin:1.0.0-rc4:initialize failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal de.saumya.mojo:gem-maven-plugin:1.0.0-rc4:initialize (default) on project lp-leads-viewer: Execution default of goal de.saumya.mojo:gem-maven-plugin:1.0.0-rc4:initialize failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.PolyglotMavenCli.main(PolyglotMavenCli.java:64)
    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:483)
    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 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:483)
    at org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:455)
    at org.jruby.javasupport.JavaMethod.invokeStaticDirect(JavaMethod.java:367)
    at org.jruby.java.invokers.StaticMethodInvoker.call(StaticMethodInvoker.java:60)
    at org.jruby.internal.runtime.methods.AliasMethod.call(AliasMethod.java:61)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
    at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
    at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    at org.jruby.ast.EnsureNode.interpret(EnsureNode.java:96)
    at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
    at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:182)
    at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:198)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
    at org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36)
    at org.jruby.ast.LocalAsgnNode.interpret(LocalAsgnNode.java:123)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
    at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    at org.jruby.ast.IfNode.interpret(IfNode.java:116)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
    at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
    at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:182)
    at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:198)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
    at org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
    at org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)
    at org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:206)
    at org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:157)
    at org.jruby.runtime.Interpreted19Block.yieldSpecific(Interpreted19Block.java:130)
    at org.jruby.runtime.Block.yieldSpecific(Block.java:111)
    at org.jruby.ast.ZYieldNode.interpret(ZYieldNode.java:25)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
    at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    at org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)
    at org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:206)
    at org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:157)
    at org.jruby.runtime.Interpreted19Block.yieldSpecific(Interpreted19Block.java:130)
    at org.jruby.runtime.Block.yieldSpecific(Block.java:111)
    at org.jruby.ast.ZYieldNode.interpret(ZYieldNode.java:25)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
    at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    at org.jruby.ast.EnsureNode.interpret(EnsureNode.java:96)
    at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
    at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:161)
    at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:190)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:316)
    at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:145)
    at org.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:154)
    at org.jruby.ast.FCallNoArgBlockNode.interpret(FCallNoArgBlockNode.java:32)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
    at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
    at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:161)
    at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:190)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:316)
    at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:145)
    at org.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:154)
    at org.jruby.ast.CallNoArgBlockNode.interpret(CallNoArgBlockNode.java:64)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
    at org.jruby.ast.IfNode.interpret(IfNode.java:116)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
    at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
    at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:112)
    at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:126)
    at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:173)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:296)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:72)
    at org.jruby.ast.CallSpecialArgNode.interpret(CallSpecialArgNode.java:73)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
    at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    at org.jruby.ast.RootNode.interpret(RootNode.java:129)
    at org.jruby.evaluator.ASTInterpreter.INTERPRET_ROOT(ASTInterpreter.java:121)
    at org.jruby.Ruby.runInterpreter(Ruby.java:838)
    at org.jruby.Ruby.loadFile(Ruby.java:2727)
    at org.jruby.runtime.load.ExternalScript.load(ExternalScript.java:66)
    at org.jruby.runtime.load.LoadService.load(LoadService.java:359)
    at org.jruby.RubyKernel.loadCommon(RubyKernel.java:1107)
    at org.jruby.RubyKernel.load19(RubyKernel.java:1099)
    at org.jruby.RubyKernel$INVOKER$s$0$1$load19.call(RubyKernel$INVOKER$s$0$1$load19.gen)
    at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:210)
    at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:206)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
    at org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
    at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    at org.jruby.ast.RootNode.interpret(RootNode.java:129)
    at org.jruby.evaluator.ASTInterpreter.INTERPRET_EVAL(ASTInterpreter.java:95)
    at org.jruby.evaluator.ASTInterpreter.evalWithBinding(ASTInterpreter.java:184)
    at org.jruby.RubyKernel.evalCommon(RubyKernel.java:1156)
    at org.jruby.RubyKernel.eval19(RubyKernel.java:1119)
    at org.jruby.RubyKernel$INVOKER$s$0$3$eval19.call(RubyKernel$INVOKER$s$0$3$eval19.gen)
    at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:226)
    at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:222)
    at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:636)
    at org.jruby.runtime.invokedynamic.InvocationLinker.invocationFallback(InvocationLinker.java:189)
    at home.ddossot.$_dot_rvm.gems.jruby_minus_1_dot_7_dot_9.bin.jruby_executable_hooks.__file__(/home/ddossot/.rvm/gems/jruby-1.7.9/bin/jruby_executable_hooks:15)
    at home.ddossot.$_dot_rvm.gems.jruby_minus_1_dot_7_dot_9.bin.jruby_executable_hooks.load(/home/ddossot/.rvm/gems/jruby-1.7.9/bin/jruby_executable_hooks)
    at org.jruby.Ruby.runScript(Ruby.java:811)
    at org.jruby.Ruby.runScript(Ruby.java:804)
    at org.jruby.Ruby.runNormally(Ruby.java:673)
    at org.jruby.Ruby.runFromMain(Ruby.java:522)
    at org.jruby.Main.doRunFromMain(Main.java:395)
    at org.jruby.Main.internalRun(Main.java:290)
    at org.jruby.Main.run(Main.java:217)
    at org.jruby.Main.main(Main.java:197)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal de.saumya.mojo:gem-maven-plugin:1.0.0-rc4:initialize failed.
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:115)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 132 more
Caused by: java.lang.NullPointerException
    at de.saumya.mojo.ruby.gems.GemsInstaller.installGems(GemsInstaller.java:174)
    at de.saumya.mojo.ruby.gems.GemsInstaller.installGems(GemsInstaller.java:99)
    at de.saumya.mojo.ruby.gems.GemsInstaller.installGems(GemsInstaller.java:87)
    at de.saumya.mojo.ruby.gems.GemsInstaller.installPom(GemsInstaller.java:55)
    at de.saumya.mojo.gem.AbstractGemMojo.executeJRuby(AbstractGemMojo.java:274)
    at de.saumya.mojo.jruby.AbstractJRubyMojo.execute(AbstractJRubyMojo.java:275)
    at de.saumya.mojo.gem.AbstractGemMojo.execute(AbstractGemMojo.java:174)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
    ... 133 more
mkristian commented 10 years ago

could you past the output when adding -Djruby.verbose to the commandline ?

is there any specific setup in your pom.xml regarding rvm ?

somehow the gem-maven-plugin picks up some setup of rvm like /home/ddossot/.rvm/gems/jruby-1.7.9/bin/jruby_executable_hooks which it really should not.

another thing is rmvn via rvm ;)

if you have Mavenfile or pom.rb could you add properties( 'tesla.dump.pom' => 'pom-test.xml', 'tesla.dump.readonly' => true )

and see what happens when you execute it with proper maven

$ mvn -f pom-test.xml

does this produce the same error ?

so basically there is rvm involved and rmvn and gem-maven-plugin and it would be great if you could help me to figure out which part can be excluded from the equation ;)

but I guess you configured rvm to use jruby-1.7.9 and the problem is related to rvm and those bin/jruby_executable_hooks. anyways that is just a guess from remote.

ddossot commented 10 years ago

I'm closing this as an unfortunate PEBCAK and apologize for it.

I had attempted getting the gems with bundler instead of fully relying on gem-maven-plugin to do it. After removing the Gemfile.lock that bundler created, rmvn clean package triggers gem-maven-plugin correctly and all the gems are placed in target/rubygems (even the test scoped ones, I still need to find out a way to only bring the runtime/compile scoped gems, but that's another story).

Thank you very much for your support.

mkristian commented 10 years ago

@ddossot yes that is something which really needs a fix soon that all scoped gems into the 'same' repo. if you add the gems to a plugin, i.e. minitest-maven-plugin then those gems go already into a plugin-only repo (the gem-path will also have the regulare gems).

so I was thinking that scoped gems with provided and test will go into target/rubygems-test target/rubygems-provided respectively and compile+runtime into target/rubygems that way it is easy to pack only the compile+runtime gems into the jar and leave the other out.

please let me know if that would help in your situation !!

ddossot commented 10 years ago

That would help tremendously.

To give you an idea, for projects where I use pure Maven, I put all the test gems in a specific profile that I activate when I want to run specs. This profile also defines gemHome/gemPath to point to ${project.build.directory}/rspec-rubygems, which is conceptually the same as the target/rubygems-test directory you're proposing.

So a big +1 to have target/rubygems-test supported OOTB :smile:

mkristian commented 10 years ago

yes, I did something similar in projects of mine to separate the test gems. I just pushed a new snapshot to

https://oss.sonatype.org/content/repositories/snapshots/de/saumya/mojo/jruby-maven-plugins/

which will have that separation of gems via scope. in case you find time to check it out and see if it works for you that would be really helpful. it is time to release version 1.0.0 of the plugins (and time to to get to start 2.0.0 with removed garbage).

ddossot commented 10 years ago

Success :)

[INFO] installing gems for compile scope . . .
[INFO] Successfully installed grape-0.7.0
[INFO] Successfully installed rack-1.5.2
[INFO] Successfully installed rack-accept-0.4.5
[INFO] Successfully installed activesupport-4.1.0
[INFO] Successfully installed i18n-0.6.9
[INFO] Successfully installed json-1.8.1-java
[INFO] Successfully installed tzinfo-1.1.0
[INFO] Successfully installed minitest-5.3.3
[INFO] Successfully installed thread_safe-0.3.3-java
[INFO] Successfully installed multi_json-1.9.2
[INFO] Successfully installed multi_xml-0.5.5
[INFO] Successfully installed hashie-2.1.1
[INFO] Successfully installed virtus-1.0.2
[INFO] Successfully installed descendants_tracker-0.0.4
[INFO] Successfully installed equalizer-0.0.9
[INFO] Successfully installed coercible-1.0.0
[INFO] Successfully installed axiom-types-0.1.1
[INFO] Successfully installed ice_nine-0.11.0
[INFO] Successfully installed builder-3.2.2
[INFO] Successfully installed rack-mount-0.8.3
[INFO] Successfully installed deep_merge-1.0.1
[INFO] 21 gems installed
[INFO] installing gems for runtime scope . . .
[INFO] installing gems for provided scope . . .
[INFO] installing gems for test scope . . .
[INFO] Successfully installed a-0.1.1
[INFO] 1 gem installed

Thanks a lot :+1: