Skip to content

Commit 5215286

Browse files
authored
Merge pull request #342 from rtyler/install-time-dep-341
Handle dependencies which are needed at installation time
2 parents 2806519 + 8194b27 commit 5215286

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

jruby-gradle-base-plugin/src/integTest/groovy/com/github/jrubygradle/JRubyPrepareGemsIntegrationSpec.groovy

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,25 @@ class JRubyPrepareGemsIntegrationSpec extends Specification {
126126
new File(prepTask.outputDir,"gems/slim-${SLIM_VERSION}").exists()
127127
!new File(prepTask.outputDir,"gems/temple-${TEMPLE_VERSION}").exists()
128128
!new File(prepTask.outputDir,"gems/tilt-${TILT_VERSION}").exists()
129-
}
129+
}
130+
131+
@Issue('https://github.com/jruby-gradle/jruby-gradle-plugin/issues/341')
132+
def "Make a install-time gem dependency available"() {
133+
given:
134+
def root= new File(TESTROOT, "childprocess")
135+
def project = BasicProjectBuilder.buildWithStdRepo(root,CACHEDIR)
136+
def jrpg = project.tasks.jrubyPrepare
137+
project.jruby.gemInstallDir = root.absolutePath
138+
139+
project.dependencies {
140+
gems "rubygems:childprocess:1.0.1"
141+
}
142+
project.evaluate()
143+
jrpg.copy()
144+
145+
expect:
146+
new File(jrpg.outputDir,"gems/childprocess-1.0.1").exists()
147+
}
148+
130149

131150
}

jruby-gradle-base-plugin/src/main/groovy/com/github/jrubygradle/GemUtils.groovy

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,24 @@ class GemUtils {
101101
main JRUBY_MAINCLASS
102102
classpath jRubyClasspath
103103
args '-S', GEM, 'install'
104-
gemsToProcess.each { File gem ->
104+
105+
/*
106+
* NOTE: gemsToProcess is assumed to typically be sourced from
107+
* a FileCollection generated elsewhere in the code. The
108+
* FileCollection a flattened version of the dependency tree.
109+
*
110+
* In order to handle Rubygems which depend on their
111+
* dependencies at _installation time_, we need to reverse the
112+
* order to make sure that the .gem files for the
113+
* transitive/nested dependencies are installed first
114+
*
115+
* See:
116+
* https://gikhub.com/jruby-gradle/jruby-gradle-plugin/issues/341
117+
*/
118+
gemsToProcess.collect { it }.reverse().each { File gem ->
105119
args gem
106120
}
121+
107122
// there are a few extra args which look like defaults
108123
// but we need to make sure any config in $HOME/.gemrc
109124
// is overwritten

0 commit comments

Comments
 (0)