@@ -30,8 +30,9 @@ class JRubyExec extends JavaExec {
30
30
}
31
31
32
32
proj. tasks. withType(JRubyExec ) { t ->
33
- if (t. jrubyConfigurationName != proj. configurations. jrubyExec) {
34
- proj. dependencies. add(t. jrubyConfigurationName," org.jruby:jruby-complete:${ t.jrubyVersion} " )
33
+ if (t. jrubyConfigurationName != proj. configurations. jrubyExec) {
34
+ proj. dependencies. add(t. jrubyConfigurationName,
35
+ " org.jruby:jruby-complete:${ t.jrubyVersion} " )
35
36
}
36
37
}
37
38
}
@@ -78,16 +79,18 @@ class JRubyExec extends JavaExec {
78
79
script= fName
79
80
break
80
81
case String :
81
- script= new File (fName)
82
+ script = new File (fName)
82
83
break
83
84
default :
84
- script= new File (fName. toString())
85
+ script = new File (fName. toString())
85
86
}
86
87
}
87
88
88
89
/* * Returns a list of script arguments
89
90
*/
90
- List<String > scriptArgs () {CollectionUtils . stringize(this . scriptArgs)}
91
+ List<String > scriptArgs () {
92
+ CollectionUtils . stringize(this . scriptArgs)
93
+ }
91
94
92
95
/* * Set arguments for script
93
96
*
@@ -99,7 +102,9 @@ class JRubyExec extends JavaExec {
99
102
100
103
/* * Returns a list of jruby arguments
101
104
*/
102
- List<String > jrubyArgs () {CollectionUtils . stringize(this . jrubyArgs)}
105
+ List<String > jrubyArgs () {
106
+ CollectionUtils . stringize(this . jrubyArgs)
107
+ }
103
108
104
109
/* * Set arguments for jruby
105
110
*
@@ -109,6 +114,17 @@ class JRubyExec extends JavaExec {
109
114
this . jrubyArgs. addAll(args as List )
110
115
}
111
116
117
+ /* * Return the computed `PATH` for the task
118
+ *
119
+ */
120
+ String getComputedPATH (String configuration , String originalPath ) {
121
+ File path = new File ([project. buildDir,
122
+ ' tmp' ,
123
+ configuration,
124
+ ' bin' ]. join(File . separator))
125
+ return path. absolutePath + File . pathSeparatorChar + originalPath
126
+ }
127
+
112
128
/* * Setting the {@code jruby-complete} version allows for tasks to be run using different versions of JRuby.
113
129
* This is useful for comparing the results of different version or running with a gem that is only
114
130
* compatible with a specific version or when running a script with a different version that what will
@@ -117,7 +133,7 @@ class JRubyExec extends JavaExec {
117
133
* @param version String in the form '1.7.13'
118
134
*/
119
135
void setJrubyVersion (final String version ) {
120
- if (version == project. jruby. execVersion) {
136
+ if (version == project. jruby. execVersion) {
121
137
jrubyConfigurationName = JRUBYEXEC_CONFIG
122
138
} else {
123
139
final String cfgName= ' jrubyExec$$' + name
@@ -129,17 +145,18 @@ class JRubyExec extends JavaExec {
129
145
130
146
@Override
131
147
void exec () {
132
- if (configuration == null && jrubyConfigurationName == JRUBYEXEC_CONFIG ) {
148
+ if (configuration == null && jrubyConfigurationName == JRUBYEXEC_CONFIG ) {
133
149
configuration = JRUBYEXEC_CONFIG
134
150
}
135
151
136
152
GemUtils.OverwriteAction overwrite = project. gradle. startParameter. refreshDependencies ? GemUtils.OverwriteAction . OVERWRITE : GemUtils.OverwriteAction . SKIP
137
153
def jrubyCompletePath = project. configurations. getByName(jrubyConfigurationName)
138
154
File gemDir = tmpGemDir()
139
155
gemDir. mkdirs()
140
- environment ' GEM_HOME' : gemDir
156
+ environment ' GEM_HOME' : gemDir,
157
+ ' PATH' : getComputedPATH(configuration, System . env. PATH )
141
158
142
- if (configuration != null ) {
159
+ if (configuration != null ) {
143
160
GemUtils . extractGems(
144
161
project,
145
162
jrubyCompletePath,
@@ -174,7 +191,7 @@ class JRubyExec extends JavaExec {
174
191
175
192
@Override
176
193
JavaExec setMain (final String mainClassName ) {
177
- if (mainClassName == ' org.jruby.Main' ) {
194
+ if (mainClassName == ' org.jruby.Main' ) {
178
195
super . setMain(mainClassName)
179
196
} else {
180
197
throw notAllowed(" Setting main class for jruby to ${ mainClassName} is not a valid operation" )
@@ -208,7 +225,7 @@ class JRubyExec extends JavaExec {
208
225
209
226
private File tmpGemDir () {
210
227
String ext = FileUtils . toSafeFileName(jrubyConfigurationName)
211
- if (configuration && configuration!= jrubyConfigurationName) {
228
+ if (configuration && configuration != jrubyConfigurationName) {
212
229
ext= ext + " -${ FileUtils.toSafeFileName(configuration)} "
213
230
}
214
231
new File ( project. buildDir, " tmp/${ ext} " ). absoluteFile
0 commit comments