Skip to content

Commit eaed249

Browse files
committed
This allows a global jruby to be set. Currently jrubyWar configuration uses tat, but it forms a basis for future configurations and tasks to also use it.
1 parent 57893cb commit eaed249

File tree

4 files changed

+56
-5
lines changed

4 files changed

+56
-5
lines changed

build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ test {
3333
showStandardStreams = true
3434
exceptionFormat "full"
3535
}
36+
37+
systemProperties TESTROOT : new File(buildDir,'tmp/test/unittests').absolutePath
38+
3639
}
3740

3841

@@ -45,7 +48,6 @@ artifacts {
4548
archives sourcesJar
4649
}
4750

48-
4951
// Ensure we don't fail in CI or on a system without these values set in
5052
// ~/.gradle/gradle.properties
5153
if( !hasProperty( 'bintrayUser' ) )

src/main/groovy/com/lookout/gradle/jruby/JRubyPlugin.groovy

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ class JRubyPlugin implements Plugin<Project> {
3737

3838
// In order for jrubyWar to work we'll need to pull in the warbler
3939
// bootstrap code from this artifact
40-
project.dependencies {
41-
jrubyEmbeds group: 'com.lookout', name: 'warbler-bootstrap', version: '1.+'
42-
jrubyWar group: 'org.jruby.rack', name: 'jruby-rack', version: '1.1.+'
43-
jrubyWar group: 'org.jruby', name: 'jruby-complete', version: '1.7.+'
40+
project.afterEvaluate {
41+
project.dependencies {
42+
jrubyEmbeds group: 'com.lookout', name: 'warbler-bootstrap', version: '1.+'
43+
jrubyWar group: 'org.jruby', name: 'jruby-complete', version: project.jruby.defaultVersion
44+
jrubyWar (group: 'org.jruby.rack', name: 'jruby-rack', version: '1.1.+') {
45+
exclude module : 'jruby-complete'
46+
}
47+
}
4448
}
4549

4650
project.task('jrubyClean', type: Delete) {
@@ -74,6 +78,13 @@ class JRubyPlugin implements Plugin<Project> {
7478
project.task('jrubyCacheJars', type: Copy) {
7579
group 'JRuby'
7680
description 'Cache .jar-based dependencies into .jarcache/'
81+
82+
doFirst {
83+
dependencies {
84+
jrubyWar group: 'org.jruby', name: 'jruby-complete', version: project.jruby.defaultVersion
85+
}
86+
}
87+
7788
from project.configurations.jrubyWar
7889
into ".jarcache"
7990
include '**/*.jar'

src/main/groovy/com/lookout/gradle/jruby/JRubyPluginExtension.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
class JRubyPluginExtension {
33
// More details here: <http://rubygems-proxy.torquebox.org/>
44
def String gemrepo_url = "http://rubygems-proxy.torquebox.org/releases"
5+
6+
String defaultVersion = '1.7.13'
57
}

src/test/groovy/com/lookout/gradle/jruby/JRubyPluginTest.groovy

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@ import static org.junit.Assert.*
1313

1414

1515
class JRubyPluginTest {
16+
static final File TESTROOT = new File(System.getProperty('TESTROOT') ?: 'build/tmp/test/unittests')
17+
1618
def project
1719

1820
@Before
1921
void setUp() {
22+
if(TESTROOT.exists()) {
23+
TESTROOT.deleteDir()
24+
}
25+
TESTROOT.mkdirs()
2026
project = ProjectBuilder.builder().build()
2127
project.apply plugin: 'jruby'
2228
}
@@ -63,6 +69,36 @@ class JRubyPluginTest {
6369
assertEquals(gem_name, JRubyPlugin.gemFullNameFromFile(filename))
6470
}
6571

72+
// NOTE: This test will fail if no network is available
73+
// It really needs Spock's @IgnoreIf annotation
74+
// See https://gist.github.com/ysb33r/74574a45c67c9e9e8187
75+
@Test
76+
public void jrubyWarTaskNeedsToAddJrubyCompleteJar() {
77+
final String useVersion = '1.7.3'
78+
assertNotEquals "We need the test version to be different from the defaultVersion that is compiled in",
79+
useVersion,project.jruby.defaultVersion
80+
81+
project.jruby {
82+
defaultVersion useVersion
83+
}
84+
85+
Task jrw = project.tasks.jrubyWar
86+
new File(TESTROOT,'libs').mkdirs()
87+
new File(TESTROOT,'classes/main').mkdirs()
88+
project.buildDir = TESTROOT
89+
project.evaluate()
90+
jrw.copy()
91+
92+
assertTrue jrw.outputs.files.singleFile.exists()
93+
94+
def item = project.configurations.jrubyWar.files.find { it.toString().find('jruby-complete') }
95+
assertNotNull 'Would expected to have a jruby-complete-XXX.jar',item
96+
97+
def matches = item =~ /.*(jruby-complete-.+.jar)/
98+
assertNotNull 'jruby-complete-XXX.jar did not match', matches
99+
assertEquals "jruby-complete-${useVersion}.jar".toString(), matches[0][1]
100+
101+
}
66102
//
67103
// Helper methods for testing
68104
////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)