Ruby GEM repositories
Quick start
Adding a repository that proxies the standard rubygems.org
repository is as simple as adding ruby.gems()
to the repositories
block.
It will now resolve anything in the rubygems
group to that repository.
build.gradle
repositories {
ruby.gems() (1)
}
configurations {
something {
canBeResolved(true)
}
}
dependencies {
something 'rubygems:credit_card_validator:1.3.2' (2)
}
1 | Add the repository |
2 | Declare the GEM using group rubygems .
This is important as only artifacts in that group will be queries against the default GEMs repository. |
And the Kotlin DSL equivalent.
(You might need the org.ysb33r.jruby.resolver.kt
plugin for this to work).
build.gradle.kts
import org.ysb33r.gradle.jruby.kt.resolver.ruby
val something by configurations.creating
dependencies {
something("rubygems:credit_card_validator:1.3.2")
}
repositories {
ruby.gems()
}
Customising GEM repositories
It is possible to configure repositories at custom URLs and also assign custom groups.
build.gradle
repositories {
ruby.gems('https://other-url') (1)
ruby.gems('otherGroup', 'https://other-url') (2)
}
1 | Use an alternative URL for the Ruby GEM repository. |
2 | User a custom group and an alternative URL. |
Using the Maven GEM repository
The JRuby group support their own Maven proxy repository for GEMs. If you prefer to use that rather than the proxy service insider Gradle, you can configure as follows.
build.gradle
repositories {
ruby {
mavengems() (1)
mavengems('https://goo1') (2)
mavengems('goo2', 'https://goo2') (3)
}
}
1 | Use the default Maven GEMs proxy. |
2 | Use a Maven GEMs proxy, located at the given URL. |
3 | Use a Maven GEMs proxy at a different URL and with a custom group other than rubygems . |