File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed
main/groovy/com/github/jrubygradle
test/groovy/com/github/jrubygradle Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,17 @@ class JRubyExec extends JavaExec {
114
114
this . jrubyArgs. addAll(args as List )
115
115
}
116
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
+
117
128
/* * Setting the {@code jruby-complete} version allows for tasks to be run using different versions of JRuby.
118
129
* This is useful for comparing the results of different version or running with a gem that is only
119
130
* compatible with a specific version or when running a script with a different version that what will
@@ -141,13 +152,9 @@ class JRubyExec extends JavaExec {
141
152
GemUtils.OverwriteAction overwrite = project. gradle. startParameter. refreshDependencies ? GemUtils.OverwriteAction . OVERWRITE : GemUtils.OverwriteAction . SKIP
142
153
def jrubyCompletePath = project. configurations. getByName(jrubyConfigurationName)
143
154
File gemDir = tmpGemDir()
144
- File path = new File ([project. buildDir,
145
- ' tmp' ,
146
- configuration,
147
- ' bin' ]. join(File . separator))
148
155
gemDir. mkdirs()
149
156
environment ' GEM_HOME' : gemDir,
150
- ' PATH' : path . absolutePath + File . pathSeparatorChar + environment . PATH
157
+ ' PATH' : getComputedPATH(configuration, System . env . PATH )
151
158
152
159
if (configuration != null ) {
153
160
GemUtils . extractGems(
Original file line number Diff line number Diff line change @@ -164,4 +164,16 @@ class JRubyExecSpec extends Specification {
164
164
thrown(InvalidUserDataException )
165
165
}
166
166
167
+ def " Properly set the PATH in the Exec envirionment" () {
168
+ given :
169
+ project. configurations. maybeCreate(' foo' )
170
+
171
+ when :
172
+ project. configure(execTask) {
173
+ configuration ' foo'
174
+ }
175
+
176
+ then :
177
+ execTask. getComputedPATH(' foo' , System . env. PATH ). contains(' foo' )
178
+ }
167
179
}
You can’t perform that action at this time.
0 commit comments