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

Depending on internal dependencies #7

Closed
amaltson opened this issue May 22, 2012 · 16 comments
Closed

Depending on internal dependencies #7

amaltson opened this issue May 22, 2012 · 16 comments

Comments

@amaltson
Copy link

I'm trying to depend on some internal JARs inside our company, and I've added the internal repository to my Mvnfile, which looks something like this:

repository 'http://internal-repository/url'
jar 'groupId:artifactId', '2.3.5'

bundle install works fine, but when I bundle exec <ruby file>, I get the following:

$ bundle exec <ruby file>
downloading http://repo1.maven.org/maven2//internal_dependency/2.3.5/internal-dependency-2.3.5.pom
artifact downloaded: internal_dependency:pom:2.3.5
downloading http://internal-repository/url
/internal_dependency/2.3.5/internal-dependency-2.3.5.pom
artifact downloaded: internal_dependency:pom:2.3.5
NativeException: org.sonatype.aether.collection.DependencyCollectionException: Failed to collect dependencies for [internal_dependency:jar:2.3.5 (compile)]
  resolve at /home/arthur/.rvm/gems/jruby-1.6.7/gems/jbundler-0.0.1/lib/jbundler/aether.rb:84
   (root) at /home/arthur/.rvm/gems/jruby-1.6.7/gems/jbundler-0.0.1/lib/jbundler.rb:19
  require at org/jruby/RubyKernel.java:1033
  require at /home/arthur/.rvm/gems/jruby-1.6.7/gems/jbundler-0.0.1/lib/jbundler.rb:68
     each at org/jruby/RubyArray.java:1615
  require at /home/arthur/.rvm/gems/jruby-1.6.7@global/gems/bundler-1.1.3/lib/bundler/runtime.rb:66
     each at org/jruby/RubyArray.java:1615
  require at /home/arthur/.rvm/gems/jruby-1.6.7@global/gems/bundler-1.1.3/lib/bundler/runtime.rb:55
  require at /home/arthur/.rvm/gems/jruby-1.6.7@global/gems/bundler-1.1.3/lib/bundler.rb:119
   (root) at call-cews.rb:1

But I can depend on that dependency in Maven fine. I'm also able to install it using maven_gem.

$ gem install mvn:groupId:artifactId --version '=2.3.5'
Successfully installed mvn:groupId:artifactId-2.3.5-java
1 gem installed

Do you know why aether is failing to resolve the dependency? Looking at the source code it looked like putting in the repository line should work.

@rosenfeld
Copy link
Contributor

Just out of curiosity: have you tried adding your custom Nexus server URLs to your ~/.m2/settings.xml?

Something like this:

http://www.sonatype.com/books/nexus-book/reference/maven-sect-single-group.html

@rosenfeld
Copy link
Contributor

From here, it seems your syntax is wrong:

https://github.com/mkristian/jbundler/blob/master/spec/mavenfile_spec.rb#L46

Try something like this:

repository :internal, 'http://internal-repository/url'

@rosenfeld
Copy link
Contributor

I'm not sure what was the code intention of this:

https://github.com/mkristian/jbundler/blob/master/lib/jbundler/mavenfile.rb#L57

But this is the effect (try on irb):

line = "repository 'http://internal-repository/url'"
name, url = line.sub(/.*(repository|source)\s+/, '').gsub(/['":]/,'').split(/,/)

After that url is nil and name is "http//internal-repository/url"

Notice that gsub will remove the colon :)

@amaltson
Copy link
Author

@rosenfeld sounds like that would be the culprit, it's probably the gsub.... I'll try it tomorrow morning and see if I can get it working. I'll also give the :internal a try. Thanks!

@rosenfeld
Copy link
Contributor

No problem, good luck :)

@mkristian
Copy link
Owner

I pushed a fix - and added that case to specs :)

thanx for reporting and finding the problematic code

@mkristian
Copy link
Owner

if it works for you I happy to push a bug fixed gem. the next release is in making but I need a day or two more

@rosenfeld
Copy link
Contributor

Maybe creating a DSL wouldn't be that hard:

https://github.com/carlhuda/bundler/blob/master/lib/bundler/dsl.rb

There are lots of malformed Mvnfile possibilities that would be hard to track with your current approach and regular expressions. I guess it would be easier to support a DSL and let Ruby help you with the parser :)

@amaltson
Copy link
Author

@mkristian sorry, newbie question since I'm fairly new to this stuff.. how can I build a jbundler gem from source and then use it in my app that's using bundler? I'd love to test out the code changes.

@mkristian
Copy link
Owner

https://github.com/mkristian/jbundler/blob/master/Build.md

please let me know if something goes wrong !

  • Kristian

@amaltson
Copy link
Author

@mkristian thanks again! I appreciate all the help. I'm running into issues when running rmvn prepare-package. It's passing the minitest tests but failing on the cucumber tests. Here's a Gist: https://gist.github.com/2775837

@mkristian
Copy link
Owner

you can skip the tests by

rmvn prepare-package -- -Dmaven.test.skip

@amaltson
Copy link
Author

@mkristian thanks, got that working (also sent a pull request to skip the tests). However, I'm still getting this issue. The URL for the internal dependency is correct, I can see the POM file that Aether is downloading. However, that stacktrace isn't telling me where Aether is failing to resolve dependencies. I tried setting $JRUBY_OPTS to "-d" so I could see the stacktrace but didn't get any additional information. Thanks again for your help.

P.S. I set my Mvnfile repository line to:

repository '<our internal dependency>'

And JBundler is setting the correct repository. I think I'll open up some Java code I have that's using Aether and see if I can get some more insight.

@mkristian
Copy link
Owner

I think I found the problem at least a similar error on my side
vanished - see my last commit:
f06dead

@amaltson
Copy link
Author

@mkristian thanks, I'll give it a go tomorrow.

@amaltson
Copy link
Author

@mkristian it works! Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants