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

jrubyPrepare fails to resolve dependencies like 1.5.0.alpha.8 #325

Closed
xlijun opened this issue Mar 10, 2018 · 6 comments
Closed

jrubyPrepare fails to resolve dependencies like 1.5.0.alpha.8 #325

xlijun opened this issue Mar 10, 2018 · 6 comments

Comments

@xlijun
Copy link

xlijun commented Mar 10, 2018

Backgroud:
I am trying to requires asciidoctor-pdf-cjk-kai_gen_gothic into asciidoc gradle plugin.

Error Message (from jrubyPrepare):
Could not find any matches for rubygems:asciidoctor-pdf:[1.5.0.alpha.8-SNAPSHOT,1.5.99999] as no versions of rubygems:asciidoctor-pdf are available.

Configuration:

buildscript {
  ...
  dependencies {
    'com.github.jruby-gradle:jruby-gradle-plugin:1.5.0'
  }
}
apply plugin: "com.github.jruby-gradle.base"
dependencies {
    gems "rubygems:asciidoctor-pdf-cjk-kai_gen_gothic:0.1.1"
}
asciidoctor {
  ...
  dependsOn test
  dependsOn jrubyPrepare
  gemPath jrubyPrepare.outputDir

  attributes 'pdf-style': 'KaiGenGothicCN'
  requires 'asciidoctor-pdf-cjk-kai_gen_gothic'
  ...
}

It seems like the version resolution algorithm used by jrubyPrepare is not fully compatible with native ruby.

@mkristian
Copy link
Contributor

@smartg00se you are right the gradle version resolution or the underlying mapping from rubygems to maven is not 100% compatible. for example it will not pick prereleased versions of gems from a range of versions, otherwise we would default to --prerelease install gems which is rarely what you want.

the maven repository excludes these prerelease version from the version range BUT they can be cherrypicked. so the only workaround for you is to add a gem dependency rubygems asciidoctor-pdf 1.5.0.alpha.8. once there is a released version of this gem you can remove this cherrypick.

@xlijun
Copy link
Author

xlijun commented Mar 12, 2018

I've tried to cherrypick rubygems asciidoctor-pdf 1.5.0.alpha.8, however the resolution also fails with the same exception above. It seems 1.5.0.alpha.8 is not treated as in the range [1.5.0.alpha.8-SNAPSHOT,1.5.99999].

@ysb33r ysb33r added the core label Jun 9, 2019
@ysb33r ysb33r changed the title jrubyPrepare fails to resolve dpendencies like 1.5.0.alpha.8 jrubyPrepare fails to resolve dependencies like 1.5.0.alpha.8 Jun 16, 2019
@ysb33r
Copy link
Contributor

ysb33r commented Jun 16, 2019

@xlijun This issue does show a defect, but before I address the potential solution to this, I would to say that if you use a GEM that has asciidoctor or asciidoctor-pdf has a transitive dependency you should exclude those, because they are bundled within the specific asciidoctorj and asciidoctorj-pdf JARS. So you would do

dependencies {
    gems 'rubygems:asciidoctor-pdf-cjk-kai_gen_gothic:0.1.1', {
        exclude module : 'asciidoctor-pdf'
    }
}

@ysb33r
Copy link
Contributor

ysb33r commented Jun 16, 2019

Now as to the fix for the most general case, I now have a solution that will go into 2.0.0 when it is released. The idea with the fix is that specific configurations or just modules can use Gradle's standard Ivy resolution rules rather the GEM version (bundler-like) resolution rules.

        gemResolverStrategy {
            excludeModule ~/^asciidoctor-pdf$/, ~/.+(alpha|beta).*/ 
        }
        
        dependencies {
            gems 'rubygems:asciidoctor-pdf-cjk-kai_gen_gothic:0.1.1'
            gems 'rubygems:asciidoctor-pdf:1.5.0.alpha.8'
        }

In gemResolverStrategy one would be able to configure the behaviour of the GemVersionResolver. In this case we specifically exclude asciidoctor-pdf, but allow asciidoctor-pdf-cjk* to be resolved by bundler-like rules.

ysb33r added a commit to ysb33r/jruby-gradle-plugin that referenced this issue Jun 16, 2019
ysb33r added a commit to ysb33r/jruby-gradle-plugin that referenced this issue Jun 16, 2019
…ruby-gradle#325)

For specific cases it might be better to use the standard Gradle resolution strategies rather than
the bundler-like atrategy suppleid vua GemVersionResolver. To accomplish this a script author may
configure specific configurations and modules (or modules+revisions) to be excluded.
@ysb33r
Copy link
Contributor

ysb33r commented Jun 16, 2019

PR #377 addresses this.

ysb33r added a commit to ysb33r/jruby-gradle-plugin that referenced this issue Jun 16, 2019
…ruby-gradle#325)

For specific cases it might be better to use the standard Gradle resolution strategies rather than
the bundler-like atrategy suppleid vua GemVersionResolver. To accomplish this a script author may
configure specific configurations and modules (or modules+revisions) to be excluded.
ysb33r added a commit to ysb33r/jruby-gradle-plugin that referenced this issue Jun 16, 2019
…ruby-gradle#325)

For specific cases it might be better to use the standard Gradle resolution strategies rather than
the bundler-like atrategy suppleid vua GemVersionResolver. To accomplish this a script author may
configure specific configurations and modules (or modules+revisions) to be excluded.
ysb33r added a commit to ysb33r/jruby-gradle-plugin that referenced this issue Jun 17, 2019
ysb33r added a commit to ysb33r/jruby-gradle-plugin that referenced this issue Jun 17, 2019
…ruby-gradle#325)

For specific cases it might be better to use the standard Gradle resolution strategies rather than
the bundler-like atrategy suppleid vua GemVersionResolver. To accomplish this a script author may
configure specific configurations and modules (or modules+revisions) to be excluded.
ysb33r added a commit to ysb33r/jruby-gradle-plugin that referenced this issue Jun 17, 2019
…ruby-gradle#325)

For specific cases it might be better to use the standard Gradle resolution strategies rather than
the bundler-like strategy supplied via GemVersionResolver. To accomplish this a script author may
configure specific configurations and modules (or modules+revisions) to be excluded.
ysb33r added a commit to ysb33r/jruby-gradle-plugin that referenced this issue Jun 17, 2019
…ruby-gradle#325)

For specific cases it might be better to use the standard Gradle resolution strategies rather than
the bundler-like strategy supplied via GemVersionResolver. To accomplish this a script author may
configure specific configurations and modules (or modules+revisions) to be excluded.
@rtyler rtyler added this to the 2.0.0 - Stuttgart milestone Jun 17, 2019
@rtyler
Copy link
Member

rtyler commented Jun 17, 2019

I'm going to close this, the work that @ysb33r I believe do address this use case, and will be documented as part of #378

@rtyler rtyler closed this as completed Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants