These are chat archives for jruby-gradle/jruby-gradle-plugin

7th
Sep 2018
Schalk W. Cronjé
@ysb33r
Sep 07 2018 09:51
@mkristian I need some help. I have wired a new repo type, but I want to understand the code that currently translates rubygems info into Maven-style info. Basically where do I find this (on GitHub) and what is the correct branch./tag to look at. Maybe then I can wire the basics into the new repo type.
Christian Meier
@mkristian
Sep 07 2018 10:18
@ysb33r https://github.com/torquebox/mavengem contains all the code and more.
and https://github.com/torquebox/mavengem/tree/master/mavengem-protocol/src/main/java/org/torquebox/mojo/mavengem wraps the whole rubygems to maven transformation into a custom uri-protocol handler. the MavenGemURLConnection.java is used by the above maven binding.
so the actual mapping is a beast: https://github.com/torquebox/mavengem/tree/master/rubygems-tools plus at least one rubygem used internally: maven-tools
Christian Meier
@mkristian
Sep 07 2018 10:23
but the MavenGemWagon is small and shows how to use the MavenGemURLConnection
Schalk W. Cronjé
@ysb33r
Sep 07 2018 12:35
I don't think we can use the protocol binding as in Gradle it will need be to be available at start-up - it cannot be provided by a plugin AFAIK
So it will need to be something in between. But I'll see where this leads
If the maven-tools GEM is used internally, we might need to bundle that GEM within the plugin
Christian Meier
@mkristian
Sep 07 2018 12:50
maven-wagon does not use the protocal binding either but the MavenGemURLConnection. regarding the gem - let me see
so ruby-tools does embed the gem already in way the java codes finds it, i.e. it is part of the jar artifact
Schalk W. Cronjé
@ysb33r
Sep 07 2018 12:56
Cool!
So for a start I need to new RubyGemsFactory( new File('/some/gradle/cache-dir/path'), new URL('https://rubygems.org') )?
Christian Meier
@mkristian
Sep 07 2018 13:25
then you need
RubygemsFactory factory = new RubugemsFactory(new File('/some/gradle/cache-dir/path'));
new MavenGemURLConnection(rubygemsFactory,
                     'http://rubygems.org/rubygems/rails/5.0.0/rails-5.0.0.gem', Proxy.NO_PROXY);
so the factory is to configure the cache location (and the a possible mirror).
with this factory you can use any rubugems repo:
new MavenGemURLConnection(rubygemsFactory, "http://rails-assets.org/rubygems/some-asset/1.0/some-asset-1.0.pom")
so first the url for the repo and then the maven path to the maven artifact or file.
http://rails-assets.org/rubygems/some-asset/1.0/metadata.xml
using the groupID = rubygems and then artifactId = gem-name and version = version
Schalk W. Cronjé
@ysb33r
Sep 07 2018 13:34
let me see if I understand this in Gradle context where we would like to do
repositories {
  rubygems {
    url 'https://rubygems.org/rubygems'
  }
  rubygems {
    url 'https://my.private.repo'
    credentials {
      username 'foo'
      password 'bar'
    }
  }
}

dependencies {
   gems 'rubygems:rails:5.0.0'
}
So let's say habe two repoS, one with credentials. I would want to translate that into mavengems speak.
Firstly we declare a cache for both:
RubygemsFactory factory = new RubugemsFactory(new File('/some/gradle/cache-dir/path'));
Schalk W. Cronjé
@ysb33r
Sep 07 2018 13:42

When Gradle resolves the dependencies, it won't find it on other repoS and it gets to the rubygems repo. Somehow it is going to tell it to resolve the group, the artifact and the version. Thus at that point I have to translate it to:

new MavenGemURLConnection(rubygemsFactory,
                     'https://rubygems.org/rubygems/rails/5.0.0/rails-5.0.0.gem', Proxy.NO_PROXY);

or

new MavenGemURLConnection(rubygemsFactory,
                     'https://foo:bar@my.private.repo/rails/5.0.0/rails-5.0.0.gem', Proxy.NO_PROXY);