You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2021/11/27 19:45:33 UTC

[groovy] 01/01: Tweak build: extract versions

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch danielsun/tweak-build-20211128
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit d3b9f639b8e6a37e7390fda31a39febd57e05332
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Nov 28 03:41:50 2021 +0800

    Tweak build: extract versions
---
 buildSrc/src/main/groovy/org.apache.groovy-internal.gradle            | 2 +-
 buildSrc/src/main/groovy/org/apache/groovy/gradle/DgmConverter.groovy | 2 +-
 .../main/groovy/org/apache/groovy/gradle/SharedConfiguration.groovy   | 4 +++-
 gradle.properties                                                     | 3 +++
 4 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/buildSrc/src/main/groovy/org.apache.groovy-internal.gradle b/buildSrc/src/main/groovy/org.apache.groovy-internal.gradle
index 529c0b2..21fcf9b 100644
--- a/buildSrc/src/main/groovy/org.apache.groovy-internal.gradle
+++ b/buildSrc/src/main/groovy/org.apache.groovy-internal.gradle
@@ -74,7 +74,7 @@ tasks.withType(AbstractCompile).configureEach {
 }
 
 tasks.withType(GroovyCompile).configureEach {
-    groovyOptions.forkOptions.jvmArgs += ["-Dgroovy.antlr4.cache.threshold=100", "-Dgroovy.target.bytecode=1.8"]
+    groovyOptions.forkOptions.jvmArgs += ["-Dgroovy.antlr4.cache.threshold=100", "-Dgroovy.target.bytecode=${sharedConfiguration.groovyTargetBytecodeVersion.get()}" as String]
     groovyOptions.fork(memoryMaximumSize: sharedConfiguration.groovycMaxMemory.get())
     groovyClasspath = configurations.groovyCompilerClasspath
 
diff --git a/buildSrc/src/main/groovy/org/apache/groovy/gradle/DgmConverter.groovy b/buildSrc/src/main/groovy/org/apache/groovy/gradle/DgmConverter.groovy
index a3bc277..e639c41 100644
--- a/buildSrc/src/main/groovy/org/apache/groovy/gradle/DgmConverter.groovy
+++ b/buildSrc/src/main/groovy/org/apache/groovy/gradle/DgmConverter.groovy
@@ -71,7 +71,7 @@ class DgmConverter extends DefaultTask {
         execOperations.javaexec {
             it.mainClass.set('org.codehaus.groovy.tools.DgmConverter')
             it.classpath = this.classpath
-            it.jvmArgs("-Dgroovy.target.bytecode=1.8")
+            it.jvmArgs("-Dgroovy.target.bytecode=${project.rootProject.extensions.getByType(SharedConfiguration).groovyTargetBytecodeVersion.get()}" as String)
             it.args('--info', outputDirectory.asFile.get().absolutePath)
         }
     }
diff --git a/buildSrc/src/main/groovy/org/apache/groovy/gradle/SharedConfiguration.groovy b/buildSrc/src/main/groovy/org/apache/groovy/gradle/SharedConfiguration.groovy
index e047d19..b033046 100644
--- a/buildSrc/src/main/groovy/org/apache/groovy/gradle/SharedConfiguration.groovy
+++ b/buildSrc/src/main/groovy/org/apache/groovy/gradle/SharedConfiguration.groovy
@@ -44,6 +44,7 @@ class SharedConfiguration {
     final Provider<String> binaryCompatibilityBaselineVersion
     final Provider<Boolean> hasCodeCoverage
     final Provider<String> targetJavaVersion
+    final Provider<String> groovyTargetBytecodeVersion
     final boolean isRunningOnCI
 
     @Nested
@@ -78,7 +79,8 @@ class SharedConfiguration {
                         providers.provider { startParameter.taskNames.any { it =~ /jacoco/ } }
                 )
                 .orElse(false)
-        targetJavaVersion = objects.property(String).convention("8")
+        targetJavaVersion = providers.gradleProperty("targetJavaVersion")
+        groovyTargetBytecodeVersion = providers.gradleProperty("groovyTargetBytecodeVersion")
         File javaHome = new File(providers.systemProperty('java.home').forUseAtConfigurationTime().get())
         String javaVersion = providers.systemProperty('java.version').forUseAtConfigurationTime().get()
         String userdir = providers.systemProperty('user.dir').forUseAtConfigurationTime().get()
diff --git a/gradle.properties b/gradle.properties
index 0d498db..c177e72 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -17,6 +17,9 @@ groovyVersion=4.0.0-SNAPSHOT
 # bundle version format: major('.'minor('.'micro('.'qualifier)?)?)? (first 3 only digits)
 groovyBundleVersion=4.0.0.SNAPSHOT
 
+groovyTargetBytecodeVersion=1.8
+targetJavaVersion=8
+
 binaryCompatibilityBaseline=3.0.9
 gradle_version=7.3