@@ -2,7 +2,10 @@ package com.github.jrubygradle
2
2
3
3
import org.gradle.api.Plugin
4
4
import org.gradle.api.Project
5
+ import org.gradle.api.Task
6
+ import org.gradle.api.UnknownTaskException
5
7
import org.gradle.api.tasks.bundling.Jar
8
+ import org.gradle.api.tasks.testing.Test
6
9
7
10
/**
8
11
* @author Schalk W. Cronjé
@@ -16,20 +19,31 @@ class JRubyJarPlugin implements Plugin<Project> {
16
19
project. configurations. maybeCreate(' testGems' )
17
20
project. configurations. maybeCreate(' runtimeGems' )
18
21
22
+ // TODO: This is currently fixed. Really need to find a way to allow user to configure the version
19
23
project. dependencies {
20
24
jrubyEmbeds group : ' com.lookout' , name : ' warbler-bootstrap' , version : ' 1.0.0'
21
25
}
22
26
23
- // TODO: This will depend on which plugin we pull in
24
- // // In order to update the testing cycle we need to tell unit tests where to
25
- // // find GEMs. We are assuming that if someone includes this plugin, that they
26
- // // will be writing tests that includes jruby and that they might need some
27
- // // GEMs as part of the tests.
28
- // project.tasks.test {
29
- // environment GEM_HOME : project.extensions.getByName('jruby').gemInstallDir
30
- // dependsOn 'jrubyPrepareGems'
31
- // }
32
-
27
+ // In order to update the testing cycle we need to tell unit tests where to
28
+ // find GEMs. We are assuming that if someone includes this plugin, that they
29
+ // will be writing tests that includes jruby and that they might need some
30
+ // GEMs as part of the tests.
31
+ def testConfiguration = { Task t ->
32
+ environment GEM_HOME : project. extensions. getByName(' jruby' ). gemInstallDir
33
+ dependsOn ' jrubyPrepareGems'
34
+ }
35
+ try {
36
+ Task t = project. tasks. getByName(' test' )
37
+ if ( t instanceof Test ) {
38
+ project. configure(t,testConfiguration)
39
+ }
40
+ } catch (UnknownTaskException ) {
41
+ project. tasks. whenTaskAdded { Task t ->
42
+ if (t. name == ' test' && t instanceof Test ) {
43
+ project. configure(t,testConfiguration)
44
+ }
45
+ }
46
+ }
33
47
34
48
if (! Jar . metaClass. respondsTo(Jar . class,' jruby' ,Closure )) {
35
49
Jar . metaClass. jruby = { Closure extraConfig ->
0 commit comments