Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Depending on internal dependencies #7

Closed
amaltson opened this Issue · 16 comments

3 participants

@amaltson

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

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

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

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

@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

No problem, good luck :)

@mkristian
Owner

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

thanx for reporting and finding the problematic code

@mkristian mkristian closed this
@mkristian
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

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

@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
Owner
@amaltson

@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
Owner
@amaltson

@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
Owner
@amaltson

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

@amaltson

@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
Something went wrong with that request. Please try again.