Skip to content

Commit 6da74a3

Browse files
author
R. Tyler Croy
committed
Merge pull request #14 from ysb33r/master
Allowing user to set a default JRuby version
2 parents d603644 + 308a77e commit 6da74a3

File tree

4 files changed

+50
-5
lines changed

4 files changed

+50
-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/jruby/JRubyPlugin.groovy

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

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

4751
project.task('jrubyClean', type: Delete) {
@@ -75,6 +79,7 @@ class JRubyPlugin implements Plugin<Project> {
7579
project.task('jrubyCacheJars', type: Copy) {
7680
group 'JRuby'
7781
description 'Cache .jar-based dependencies into .jarcache/'
82+
7883
from project.configurations.jrubyWar
7984
into ".jarcache"
8085
include '**/*.jar'

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

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

src/test/groovy/com/lookout/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: 'com.lookout.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)