Skip to content

Commit 85f1169

Browse files
author
R. Tyler Croy
committed
Merge pull request #30 from ysb33r/master
Proposed changes to the handling of default repositories
2 parents d565248 + e667a1d commit 85f1169

File tree

12 files changed

+82
-33
lines changed

12 files changed

+82
-33
lines changed

HACKING.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ Unit tests are in 'src/test' and integration tests are in 'src/integTest'. To ru
88
do `./gradlew check` or `./gradlew build`. For unittests just doing `./gradlew test` is enough.
99

1010
Test logging is controlled via `logback-test.xml`. Be aware that integration tests generate a lot of debug information.
11-
Please do not commit the config file back with DEBUG turned on
11+
Please do not commit the config file back with DEBUG turned on.
12+
13+
=== Running single test suites
14+
15+
If you only want to run the unittests in say `JRubyPlugin` then you can do `./gradlew test -Dtest.single=JRubyPlugin`.
16+
In a similar manner for integration tests one can do `./gradlew integrationTest -Dtest.single=JRubyIntegrationSpec`.
1217

1318
== Release HOWTO
1419

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,13 @@ task needSomeRubyLove {
255255
}
256256
```
257257

258-
The behaviour of ```project.jrubyexec``` is slightly different to that of ```JRubyExec```.
258+
The behaviour of `project.jrubyexec` is slightly different to that of `JRubyExec`.
259259

260-
* The version of ```jruby-complete``` is strictly tied to to ```jruby.defaultVersion```. Therefore trying to set ```jrubyVersion```
260+
* The version of `jruby-complete` is strictly tied to the `jruby.execVersion`. Therefore trying to set `jrubyVersion`
261261
in the ```jrubyexec``` closure will cause a failure
262-
* GEMs and additional JARs are only taken from the ```jrubyExec``` configuration.
263-
* It is not possible to supply a ```configuration``` parameter to the ```jrubyexec``` closure.
264-
* GEMs will be installed to ```jruby.gemInstallDir```. Existing gems will not be overwritten.
262+
* GEMs and additional JARs are only taken from the `jrubyExec` configuration.
263+
* It is not possible to supply a `configuration` parameter to the `jrubyexec` closure.
264+
* GEMs will be installed to `jruby.gemInstallDir`. Existing gems will not be overwritten.
265265

266-
As with ```JRubyExec```, ```args```, ```setArgs``` and ```main``` are illegal within the ```jrubyexec``` closure.
266+
As with `JRubyExec`, `args`, `setArgs` and `main` are illegal within the `jrubyexec` closure.
267267
All other methods should work.

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ test {
4545
}
4646

4747
systemProperties TESTROOT : new File(buildDir,'tmp/test/unittests').absolutePath
48-
systemProperties TEST_SCRIPT_DIR : new File(projectDir,'src/test/resources/scripts').absolutePath
4948
systemProperties 'logback.configurationFile' : new File(projectDir,'src/test/resources/logback-test.xml').absolutePath
5049

5150
}

gradle/integration-tests.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ sourceSets {
1515
java.srcDir file("src/integTest/java")
1616
groovy.srcDir file("src/integTest/groovy")
1717
resources.srcDir file("src/integTest/resources")
18-
compileClasspath = sourceSets.main.output + sourceSets.test.output + configurations.integrationTestCompile
18+
compileClasspath = sourceSets.main.output + configurations.integrationTestCompile
1919
runtimeClasspath = output + compileClasspath + configurations.integrationTestRuntime
2020
}
2121
}
2222

2323
task integrationTest(type: Test, dependsOn: jar) {
2424
testClassesDir = sourceSets.integrationTest.output.classesDir
2525
classpath = sourceSets.integrationTest.runtimeClasspath
26-
systemProperties["integTest.projects"] = new File(sourceSets.integrationTest.output.resourcesDir, "projects").absolutePath
26+
mustRunAfter test
2727
}
2828

2929
check.dependsOn integrationTest
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Fri Aug 08 12:16:10 PDT 2014
1+
#Fri Aug 15 18:13:15 BST 2014
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-all.zip

src/integTest/groovy/com/lookout/jruby/JRubyExecExtensionIntegrationSpec.groovy

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
package com.lookout.jruby
22

3+
import org.gradle.api.artifacts.repositories.ArtifactRepository
34
import org.gradle.testfixtures.ProjectBuilder
45
import spock.lang.Ignore
56
import spock.lang.IgnoreIf
67
import spock.lang.Specification
8+
import spock.lang.Stepwise
79

810
import static org.gradle.api.logging.LogLevel.LIFECYCLE
911

1012
/**
1113
* @author Schalk W. Cronjé
1214
*/
15+
@Stepwise
1316
class JRubyExecExtensionIntegrationSpec extends Specification {
1417
static final boolean TESTS_ARE_OFFLINE = System.getProperty('TESTS_ARE_OFFLINE') != null
1518
static final File TEST_SCRIPT_DIR = new File( System.getProperty('TESTS_SCRIPT_DIR') ?: 'src/integTest/resources/scripts')
16-
static final File TESTROOT = new File(System.getProperty('TESTROOT') ?: 'build/tmp/test/integration-tests')
19+
static final File TESTROOT = new File("${System.getProperty('TESTROOT') ?: 'build/tmp/test/integration-tests'}/jreeis")
1720

1821
def project
1922

2023
void setup() {
24+
if(TESTROOT.exists()) {
25+
TESTROOT.deleteDir()
26+
}
27+
TESTROOT.mkdirs()
2128
project = ProjectBuilder.builder().build()
2229
project.with {
2330
buildDir = TESTROOT

src/integTest/groovy/com/lookout/jruby/JRubyExecIntegrationSpec.groovy

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@ import static org.gradle.api.logging.LogLevel.LIFECYCLE
88
/**
99
* Created by schalkc on 20/08/2014.
1010
*/
11+
@Stepwise
1112
class JRubyExecIntegrationSpec extends Specification {
1213
static final boolean TESTS_ARE_OFFLINE = System.getProperty('TESTS_ARE_OFFLINE') != null
1314
static final File TEST_SCRIPT_DIR = new File( System.getProperty('TEST_SCRIPT_DIR') ?: 'src/integTest/resources/scripts')
14-
static final File TESTROOT = new File(System.getProperty('TESTROOT') ?: 'build/tmp/test/integration-tests')
15+
static final File TESTROOT = new File("${System.getProperty('TESTROOT') ?: 'build/tmp/test/integration-tests'}/jreis")
1516
static final String TASK_NAME = 'RubyWax'
1617

1718
def project
1819
def execTask
1920

2021
void setup() {
22+
if(TESTROOT.exists()) {
23+
TESTROOT.deleteDir()
24+
}
25+
TESTROOT.mkdirs()
2126
project = ProjectBuilder.builder().build()
2227
project.buildDir = TESTROOT
2328
project.logging.level = LIFECYCLE
@@ -93,7 +98,6 @@ class JRubyExecIntegrationSpec extends Specification {
9398
}
9499
}
95100

96-
97101
when:
98102
project.evaluate()
99103
execTask.exec()

src/integTest/groovy/com/lookout/jruby/JRubyPluginIntegrationSpec.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import static org.gradle.api.logging.LogLevel.LIFECYCLE
88
/**
99
* Created by schalkc on 20/08/2014.
1010
*/
11+
@Stepwise
1112
class JRubyPluginIntegrationSpec extends Specification {
1213

1314
static final boolean TESTS_ARE_OFFLINE = System.getProperty('TESTS_ARE_OFFLINE') != null

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ class JRubyExec extends JavaExec {
134134

135135
def jrubyCompletePath = project.configurations.getByName(jrubyConfigurationName)
136136
File gemDir = tmpGemDir()
137+
gemDir.mkdirs()
137138
environment 'GEM_HOME' : gemDir
138139

139140
if(configuration != null) {
140141
project.configurations.getByName(jrubyConfigurationName)
141142
project.with {
142-
mkdir gemDir
143143
configurations.getByName(configuration).files.findAll { File f ->
144144
f.name.endsWith('.gem')
145145
}.each { File f ->

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

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,14 @@ class JRubyPlugin implements Plugin<Project> {
1313
project.apply plugin: 'war'
1414
project.extensions.create('jruby', JRubyPluginExtension, project)
1515

16-
project.ext {
17-
gemInstallDir = "${project.buildDir}/${project.jruby.gemInstallDir}"
18-
}
19-
20-
project.repositories {
21-
maven {
22-
// The url is in a closure to ensure that we can overwrite this
23-
// at runtime and have the right value come through.
24-
url { project.jruby.defaultGemRepo }
16+
if(!project.repositories.metaClass.respondsTo(project.repositories,'rubygemsRelease')) {
17+
project.repositories.metaClass.rubygemsRelease << { ->
18+
maven { url 'http://rubygems-proxy.torquebox.org/releases' }
2519
}
20+
}
2621

27-
// Required to pull in our warbler-bootstrap dependency
28-
maven { url 'http://dl.bintray.com/rtyler/jruby' }
29-
30-
// We'll need jcenter to resolve the jruby .jar deps
31-
jcenter()
22+
project.ext {
23+
gemInstallDir = "${project.buildDir}/${project.jruby.gemInstallDir}"
3224
}
3325

3426
// Set up a special configuration group for our embedding jars
@@ -37,12 +29,23 @@ class JRubyPlugin implements Plugin<Project> {
3729
jrubyWar
3830
gems
3931
}
32+
4033
project.configurations.create(JRubyExec.JRUBYEXEC_CONFIG)
4134
JRubyExecDelegate.addToProject(project)
4235

4336
// In order for jrubyWar to work we'll need to pull in the warbler
4437
// bootstrap code from this artifact
4538
project.afterEvaluate {
39+
if(project.jruby.defaultRepositories) {
40+
project.repositories {
41+
jcenter()
42+
rubygemsRelease()
43+
44+
// Required to pull in our warbler-bootstrap dependency
45+
maven { url 'http://dl.bintray.com/rtyler/jruby' }
46+
47+
}
48+
}
4649
project.dependencies {
4750
jrubyEmbeds group: 'com.lookout', name: 'warbler-bootstrap', version: '1.+'
4851
jrubyWar group: 'org.jruby', name: 'jruby-complete', version: project.jruby.defaultVersion
@@ -105,7 +108,7 @@ class JRubyPlugin implements Plugin<Project> {
105108
from "$project.buildDir/classes/main"
106109
// Bring our vendored gems into the created war file
107110
webInf {
108-
from project.gemInstallDir
111+
from project.jruby.gemInstallDir
109112
into 'gems'
110113
}
111114

0 commit comments

Comments
 (0)