jruby-gradle/jruby-gradle-plugin

Cannot pull gems on restricted environments implemented via a Gradle mirror (init scripts)

Closed this issue · 2 comments

Might be related to #13 and #17.

Plugin cannot pull gems when it's doing so in an environment where a mirror enforces certain repositories to be used instead

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':printDocs'.
> Could not resolve all dependencies for configuration ':jrubyExec'.
  > Could not resolve rubygems:asciidoctor:[1.5.5,1.5.5].
    Required by:
       acme-project:0.2.0-SNAPSHOT
     > Could not resolve rubygems:asciidoctor:[1.5.5,1.5.5].
        > Failed to list versions for rubygems:asciidoctor.
           > Unable to load Maven meta-data from https://artifactory.acme.com/artifactory/api/gems/rubygems-remote/rubygems/asciidoctor/maven-metadata.xml.
              > Could not GET 'https://artifactory.acme.com/artifactory/api/gems/rubygems-remote/rubygems/asciidoctor/maven-metadata.xml'.
                 > Premature end of chunk coded message body: closing chunk expected

I'm currently using this Gradle init script to act as the mirror to some Artifactory repositories:

apply plugin:EnterpriseRepositoryPlugin

class EnterpriseRepositoryPlugin implements Plugin<Gradle> {

    private static String ENTERPRISE_REPOSITORY_URL = "https://artifactory.acme.com/artifactory/lib-release"
    private static String ENTERPRISE_RUBY_REPOSITORY_URL = "https://artifactory.acme.com/artifactory/api/gems/rubygems-remote/"

    void apply(Gradle gradle) {
        // ONLY USE ENTERPRISE REPO FOR DEPENDENCIES
        gradle.allprojects{ project ->
            project.repositories {

                // Remove all repositories not pointing to the enterprise repository url
                all { ArtifactRepository repo ->
                    if (!repo.url.toString().contains('artifactory.acme')) {
                        project.logger.lifecycle "Repository ${repo.url} removed. Only repositories under artifactory.valuex.com is allowed"
                        remove repo
                    }
                }

                // add the enterprise repository
                maven {
                    name "ACME STANDARD_ENTERPRISE_REPO"
                    url ENTERPRISE_REPOSITORY_URL
                    credentials {
                        username = "${artifactory_user}"
                        password = "${artifactory_password}"
                    }
                }

                // add the ruby enterprise repository
                maven {
                    name "ACME STANDARD RUBY ENTERPRISE REPO"
                    url ENTERPRISE_RUBY_REPOSITORY_URL
                    credentials {
                        username = "${artifactory_user}"
                        password = "${artifactory_password}"
                    }
                }
            }
        }
    }
}

Could this be a limitation to Gradle not having a rubygems repository format as it seems to try to find a Maven metadata file which is allowed to not be in a Ruby Gem repository?

the rubygems repo needs to a maven repository. gradle does not allow to plugin a new repo format. so artifactory proxy/mirror will not work. nexus2 proxy/mirror offers this feature.

That worked! This issue should help Artifactory admins get through with this