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

8th
Sep 2018
Schalk W. Cronjé
@ysb33r
Sep 08 2018 13:47
After guite a bit of delving I hit one dead-end, so I need to go back on an earlier proposal to also have an extension on the dependency handler. This means that I am now looking at implementing the DSL rather to be more like.
repositories {
  rubygems {
    url 'https://rubygems.org/rubygems'
  }
  rubygems {
    url 'https://my.private.repo'
    credentials {
      username 'foo'
      password 'bar'
    }
  }
}

dependencies {
   gems gem('rails', '5.0.0')
}
In the above gem will create a special GemDependency type.

@mkristian What I now need to figure out is the following. Once I have something like (pseudo Groovy code):

MavenGemURLConnection mavenURI = new MavenGemURLConnection(
                    rubygemsFactory,
                    baseURI.toURL(),
                    "${gem.name}/${gem.version}/${gem.name}-${gem.version}.gem"
                )

How do I resolve that to a local file (and additional files for transitive dependencies) on the filesystem?

Schalk W. Cronjé
@ysb33r
Sep 08 2018 13:53
Can I not just do
Rubygems gems = rubygemFactory.getOrCreate("${baseURI}/${gem.name}/${gem.version}/${gem.name}-${gem.version}.gem")
Christian Meier
@mkristian
Sep 08 2018 16:06

@ysb33r not sure I do understand your last questions but let's answer it anyways. on any URLConnection you can call the openStream method. then metadata on the gem you get with

MavenGemURLConnection mavenURI = new MavenGemURLConnection(
                    rubygemsFactory,
                    baseURI.toURL(),
                    "${gem.name}/${gem.version}/${gem.name}-${gem.version}.pom"
                )

or version info on the artifact via

MavenGemURLConnection mavenURI = new MavenGemURLConnection(
                    rubygemsFactory,
                    baseURI.toURL(),
                    "${gem.name}/maven-metadata.xml"
                )

using the rubygems-repository url as base and then on top it spawns a maven repo starting under /rubygems

Schalk W. Cronjé
@ysb33r
Sep 08 2018 16:12

@mkristian I am myself not quite sure what I am asking :smirk: .
I am trying to get my head around how mavengems work. In the end I want to be able to say: For GEM (name,version) given me the GEM and its metadata. How it is done in the background should be of little concern to me (for now).

Now I think what I get from your answer is that I have to provide "virtual URLs" and then the MavenGemRLConnection will allow be to 'stream' that data. I then pass the INputStream to something that can interpret the data.

Christian Meier
@mkristian
Sep 08 2018 16:14
yes, you can think of it as a viruatl server but it is not actually a server. instad of HttpURLConnections to a maven repository you use MAvenGemURLConnection to maven repository following some 'naming' rules to get the right stuff
so is a perfect fit for the maven-wagon and I hopped it can be helpful/useful for gradle as well.
Schalk W. Cronjé
@ysb33r
Sep 08 2018 16:17
@mkristian it should be, but we might have to side-step some of the code - meaning that we do not necessarily need the full Maven proxy stuff. (Maybe we do, but I am not point where I can make that decision).
Christian Meier
@mkristian
Sep 08 2018 16:22
the maven proxy stuff is used and by now quite old, it more or less works, small bugs still pop up. if we can reuse it as gradle can handle maven dependencies it would help IMO - but who knows maybe I am not able to see alternatives anymore.
Schalk W. Cronjé
@ysb33r
Sep 08 2018 16:27

The only way we can get it work as is, is to create the protocol handler and submnit it to a PR to Gradle itself. However, I do not think it will be accepted as it is going to introdice a dependency no mavengems which the Gradle team will not like. (That is the only way to get a new transport protocol accepted for Maven/Ivy).

The alternative is what I am nwo trying to do: Let the usee specify a gem as I mentioned eralier in the channel and then let your torquebox code take care of working out the dependencies, dowload the GEMs, cahce them and extract the metadata. Then from a users PoV they would hardly notice the difference

I am now at the point where I am trying to ensure that given a rubygemn name & version, I can get it downlaoded and cached and have the metadata so that the same can be done for transitives.