23
23
*/
24
24
package com.github.jrubygradle.api.gems
25
25
26
+ import groovy.transform.CompileDynamic
26
27
import groovy.transform.CompileStatic
27
28
import groovy.util.logging.Slf4j
28
29
import org.gradle.api.Action
@@ -33,6 +34,7 @@ import org.gradle.api.file.CopySpec
33
34
import org.gradle.api.file.DuplicateFileCopyingException
34
35
import org.gradle.api.file.FileCollection
35
36
import org.gradle.process.JavaExecSpec
37
+ import org.ysb33r.grolifant.api.core.LegacyLevel
36
38
import org.ysb33r.grolifant.api.core.OperatingSystem
37
39
import org.ysb33r.grolifant.api.core.ProjectOperations
38
40
@@ -136,6 +138,7 @@ class GemUtils {
136
138
*
137
139
* @since 2.1.0
138
140
*/
141
+ @SuppressWarnings (' DuplicateStringLiteral' )
139
142
static void extractGems (
140
143
ProjectOperations project ,
141
144
File jRubyClasspath ,
@@ -178,6 +181,7 @@ class GemUtils {
178
181
log. info(" Installing ${ gemsToProcess*.name.join(',')} " )
179
182
180
183
project. javaexec { JavaExecSpec spec ->
184
+ applyMainClassName(spec, JRUBY_MAINCLASS )
181
185
spec. with {
182
186
// Setting these environment variables will ensure that
183
187
// jbundler and/or jar-dependencies will not attempt to invoke
@@ -187,23 +191,26 @@ class GemUtils {
187
191
JARS_SKIP : true ,
188
192
GEM_HOME : destDir. absolutePath,
189
193
GEM_PATH : destDir. absolutePath
190
- main = JRUBY_MAINCLASS
191
194
classpath jRubyClasspath
192
195
args ' -S' , GEM , ' install'
193
196
197
+ if (OperatingSystem . current(). windows) {
198
+ systemProperty(' jdk.io.File.enableADS' , ' true' )
199
+ }
200
+
194
201
/*
195
- * NOTE: gemsToProcess is assumed to typically be sourced from
196
- * a FileCollection generated elsewhere in the code. The
197
- * FileCollection a flattened version of the dependency tree.
198
- *
199
- * In order to handle Rubygems which depend on their
200
- * dependencies at _installation time_, we need to reverse the
201
- * order to make sure that the .gem files for the
202
- * transitive/nested dependencies are installed first
203
- *
204
- * See:
205
- * https://gikhub .com/jruby-gradle/jruby-gradle-plugin/issues/341
206
- */
202
+ * NOTE: gemsToProcess is assumed to typically be sourced from
203
+ * a FileCollection generated elsewhere in the code. The
204
+ * FileCollection a flattened version of the dependency tree.
205
+ *
206
+ * In order to handle Rubygems which depend on their
207
+ * dependencies at _installation time_, we need to reverse the
208
+ * order to make sure that the .gem files for the
209
+ * transitive/nested dependencies are installed first
210
+ *
211
+ * See:
212
+ * https://github .com/jruby-gradle/jruby-gradle-plugin/issues/341
213
+ */
207
214
gemsToProcess. toList(). reverse(). each { File gem ->
208
215
args gem
209
216
}
@@ -467,6 +474,15 @@ class GemUtils {
467
474
}
468
475
}
469
476
477
+ @CompileDynamic
478
+ private static void applyMainClassName (JavaExecSpec spec , String mainClassName ) {
479
+ if (LegacyLevel . PRE_7_0 ) {
480
+ spec. main = mainClassName
481
+ } else {
482
+ spec. mainClass = mainClassName
483
+ }
484
+ }
485
+
470
486
private static final String GEM = ' gem'
471
487
private static final String GEM_EXTENSION = ' .gem'
472
488
private static final String EVERYTHING = ' **'
0 commit comments