From 9161a4354d0f34edc3e08833f626a2117c80ccb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schalk=20W=2E=20Cronj=C3=A9?= Date: Mon, 16 May 2022 19:04:47 +0200 Subject: [PATCH] Use main/mainClass depending on Gradle version --- .../com/github/jrubygradle/api/gems/GemUtils.groovy | 13 ++++++++++++- gradle.properties | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core-plugin/src/main/groovy/com/github/jrubygradle/api/gems/GemUtils.groovy b/core-plugin/src/main/groovy/com/github/jrubygradle/api/gems/GemUtils.groovy index 30eb4cf..b6958b8 100644 --- a/core-plugin/src/main/groovy/com/github/jrubygradle/api/gems/GemUtils.groovy +++ b/core-plugin/src/main/groovy/com/github/jrubygradle/api/gems/GemUtils.groovy @@ -23,6 +23,7 @@ */ package com.github.jrubygradle.api.gems +import groovy.transform.CompileDynamic import groovy.transform.CompileStatic import groovy.util.logging.Slf4j import org.gradle.api.Action @@ -33,6 +34,7 @@ import org.gradle.api.file.CopySpec import org.gradle.api.file.DuplicateFileCopyingException import org.gradle.api.file.FileCollection import org.gradle.process.JavaExecSpec +import org.ysb33r.grolifant.api.core.LegacyLevel import org.ysb33r.grolifant.api.core.OperatingSystem import org.ysb33r.grolifant.api.core.ProjectOperations @@ -178,6 +180,7 @@ class GemUtils { log.info("Installing ${gemsToProcess*.name.join(',')}") project.javaexec { JavaExecSpec spec -> + setMainClass(spec, JRUBY_MAINCLASS) spec.with { // Setting these environment variables will ensure that // jbundler and/or jar-dependencies will not attempt to invoke @@ -187,7 +190,6 @@ class GemUtils { JARS_SKIP: true, GEM_HOME: destDir.absolutePath, GEM_PATH: destDir.absolutePath - mainClass = JRUBY_MAINCLASS classpath jRubyClasspath args '-S', GEM, 'install' @@ -467,6 +469,15 @@ class GemUtils { } } + @CompileDynamic + private void setMainClass(JavaExecSpec spec, String mainClassName) { + if(LegacyLevel.PRE_7_0) { + spec.main = mainClassName + } else { + spec.mainClass = mainClassName + } + } + private static final String GEM = 'gem' private static final String GEM_EXTENSION = '.gem' private static final String EVERYTHING = '**' diff --git a/gradle.properties b/gradle.properties index facec1c..ea5b8d8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,7 +14,7 @@ releaseBuild=false targetCompatibility=1.8 sourceCompatibility=1.8 -grolifantVersion=1.0.0-alpha.6 +grolifantVersion=1.3.3 jrubyVersion=9.2.9.0 jettyVersion=9.2.12.v20150709 bcprovVersion=1.46