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

Specify different repository for gem resolution #546

Open
MarkusAmshove opened this issue Apr 17, 2020 · 5 comments
Open

Specify different repository for gem resolution #546

MarkusAmshove opened this issue Apr 17, 2020 · 5 comments

Comments

@MarkusAmshove
Copy link

Hello,

I'm trying to use the gradle plugin behind a corporate proxy and took the gradle pdf example.
I'm sitting behind a corporal proxy which won't let me resolve stuff from mavencentral, jcenter or ruby gems.

However, we do have Artifactory to proxy those repositories.

My build.gradle looks like this:

buildscript {
    repositories {
        maven {
            url 'http://corporation/artifactory/java-repos'
        }
    }
    dependencies {
        classpath 'org.asciidoctor:asciidoctor-gradle-jvm-pdf:3.2.0'
        classpath 'org.asciidoctor:asciidoctor-gradle-jvm-gems:3.2.0'
    }
}

apply plugin: 'java'
apply plugin: 'org.asciidoctor.jvm.pdf'
apply plugin: 'org.asciidoctor.jvm.gems'

version = '1.0.0'

repositories {
    maven {
        url 'http://corporation/artifactory/java-repos'
    }
    ruby {
        gems 'http://corporation/artifactory/api/gems/ruby-remote'
    }
}

dependencies {
  asciidoctorGems 'rubygems:rouge:3.15.0'
}

asciidoctorPdf {
  dependsOn asciidoctorGemsPrepare

  baseDirFollowsSourceFile()

  asciidoctorj {
    requires 'rouge'
    attributes 'build-gradle': file('build.gradle'),
        'sourcedir': project.sourceSets.main.java.srcDirs[0],
        'endpoint-url': 'http://example.org',
        'source-highlighter': 'rouge',
        'imagesdir': './images',
        'toc': 'left',
        'icons': 'font',
        'idprefix': '',
        'idseparator': '-'
  }
}

// alias
task asciidoctor(dependsOn: asciidoctorPdf)

The Gradle and Java dependencies seem to resolve correctly, but I'm faced with the following error:

$ gradlew asciidoctor --console=plain


404 client error for request to /rubygems/rouge/3.15.0/ivy.xml
> Task :asciidoctorGemsPrepare FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':asciidoctorGemsPrepare'.
> Could not resolve all files for configuration ':asciidoctorGems'.
   > Could not find rubygems:rouge:3.15.0.
     Searched in the following locations:
       - http://corporation/artifactory/java-repos/rubygems/rouge/3.15.0/rouge-3.15.0.pom
       - http://localhost:59605/rubygems/rouge/3.15.0/ivy.xml
     Required by:
         project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s
1 actionable task: 1 executed

It doesn't seem to take the specified gem repository into account.
Is there anything I can do to point asciidoctorGems to the correct repository?

@ysb33r
Copy link
Member

ysb33r commented Apr 17, 2020

@MarkusAmshove Is your corporate GEMs repo maven-based or rubygems-based?

By using ruby.gems you are setting up an internal proxy that will translate Gradle dependency requests in to requests for a service that implements rubygems. SO if your corporate Artifactory also supports GEM repositories using ruby.gems will work. If your Artifactory repo is already a translation of RubyGems into Maven (such as which Torquebox used to do), then you cannot use this approach and should rather just do maven { url = '....' }.

(Of course having said of that, there could always be a bug in the jruby-gradle core plugin w.r.t. to private repositories).

@MarkusAmshove
Copy link
Author

@ysb33r that particular repository is gem based, as it can also work with ruby directly.

Do I have to tell gradle to use the gem protocol? The error is strange because it tries to resolve the dependency with the maven repository, which tells me it tries to resolve the maven way.

The Artifactory documentation also doesn't state JRuby for this repository type

@ysb33r
Copy link
Member

ysb33r commented Apr 17, 2020

Try using

    ruby.gems('http://corporation/artifactory/api/gems/ruby-remote')

This is just in case the closure delegation does not work correctly.

Basically in your case what should happen is that the internal proxy will query your artifact repo and then cache locally as Ivy repo.

If you run with --debug you should get quite a bit more information come out.

@MarkusAmshove
Copy link
Author

I've tried ruby.gems('...') but got the same error.

I also tried to change the order of repositories:

repositories {
    ruby.gems('...')
    maven {
        url '...'
    }
}

and now the error order shifts (notice that localhost comes first now):

020-04-18T11:28:57.739+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Could not resolve all files for configuration ':asciidoctorGems'.
2020-04-18T11:28:57.739+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]    > Could not find rubygems:rouge:3.15.0.
2020-04-18T11:28:57.739+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]      Searched in the following locations:
2020-04-18T11:28:57.739+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]        - http://localhost:55488/rubygems/rouge/3.15.0/ivy.xml
2020-04-18T11:28:57.739+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]        - http://corporation/artifactory/java-repos/rubygems/rouge/3.15.0/rouge-3.15.0.pom

I've also run the build with --debug and the specified gem url isn`t mentioned once in the log :-/

@tkrah
Copy link

tkrah commented Oct 1, 2021

Just want to add my 2 cents that this is not working for me too - same problem like @MarkusAmshove - I do have the correct ruby gem mirror configured and can browse the gem repo with my browser but if I run it via gradle it does not even look at the configured ruby.gems url but always going to use the configured maven repository instead (which I need too for other dependencies).
Any hints to debug this further - "--debug" does not provide something valuable.

Seems like an upstream issue though because it does not work just using the jruby-gradle-plugin, reported here:

jruby-gradle/jruby-gradle-plugin#429

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