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 2024/06/02 09:02:45 UTC
(groovy) 01/01: Support configuring source java version
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch danielsun/source_version
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 46347a6ee850096ba6dafe8c7eae411383eb7373
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Jun 2 18:02:26 2024 +0900
Support configuring source java version
---
build-logic/src/main/groovy/org.apache.groovy-base.gradle | 4 ++--
build-logic/src/main/groovy/org.apache.groovy-documented.gradle | 2 +-
.../main/groovy/org/apache/groovy/gradle/SharedConfiguration.groovy | 2 ++
build.gradle | 2 +-
gradle.properties | 1 +
gradle/idea.gradle | 4 ++--
6 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/build-logic/src/main/groovy/org.apache.groovy-base.gradle b/build-logic/src/main/groovy/org.apache.groovy-base.gradle
index 99b1334e45..e84e53d8d0 100644
--- a/build-logic/src/main/groovy/org.apache.groovy-base.gradle
+++ b/build-logic/src/main/groovy/org.apache.groovy-base.gradle
@@ -217,12 +217,12 @@ tasks.register("jarjar", JarJarTask) {
}
tasks.withType(AbstractCompile).configureEach {
- sourceCompatibility(sharedConfiguration.targetJavaVersion.get())
+ sourceCompatibility(sharedConfiguration.sourceJavaVersion.get())
targetCompatibility(sharedConfiguration.targetJavaVersion.get())
}
tasks.withType(Javadoc).configureEach {
- options.source = sharedConfiguration.targetJavaVersion.get()
+ options.source = sharedConfiguration.sourceJavaVersion.get()
}
tasks.named("compileTestGroovy") {
diff --git a/build-logic/src/main/groovy/org.apache.groovy-documented.gradle b/build-logic/src/main/groovy/org.apache.groovy-documented.gradle
index 6be381533c..493627db1a 100644
--- a/build-logic/src/main/groovy/org.apache.groovy-documented.gradle
+++ b/build-logic/src/main/groovy/org.apache.groovy-documented.gradle
@@ -57,7 +57,7 @@ tasks.withType(Javadoc).configureEach {
version = true
overview = project.relativePath(rootProject.file('src/main/java/overviewj.html'))
bottom = 'Copyright © 2003-2024 The Apache Software Foundation. All rights reserved.'
- source = sharedConfiguration.targetJavaVersion.get()
+ source = sharedConfiguration.sourceJavaVersion.get()
links('https://docs.oracle.com/en/java/javase/11/docs/api/',
'https://docs.oracle.com/javaee/7/api/',
'https://commons.apache.org/proper/commons-cli/javadocs/api-release/',
diff --git a/build-logic/src/main/groovy/org/apache/groovy/gradle/SharedConfiguration.groovy b/build-logic/src/main/groovy/org/apache/groovy/gradle/SharedConfiguration.groovy
index 81e6aca9fc..bce40b12d2 100644
--- a/build-logic/src/main/groovy/org/apache/groovy/gradle/SharedConfiguration.groovy
+++ b/build-logic/src/main/groovy/org/apache/groovy/gradle/SharedConfiguration.groovy
@@ -43,6 +43,7 @@ class SharedConfiguration {
final Provider<String> installationDirectory
final Provider<String> binaryCompatibilityBaselineVersion
final Provider<Boolean> hasCodeCoverage
+ final Provider<String> sourceJavaVersion
final Provider<String> targetJavaVersion
final Provider<String> groovyTargetBytecodeVersion
final boolean isRunningOnCI
@@ -79,6 +80,7 @@ class SharedConfiguration {
providers.provider { startParameter.taskNames.any { it =~ /jacoco/ } }
)
.orElse(false)
+ sourceJavaVersion = providers.gradleProperty("sourceJavaVersion")
targetJavaVersion = providers.gradleProperty("targetJavaVersion")
groovyTargetBytecodeVersion = providers.gradleProperty("groovyTargetBytecodeVersion")
File javaHome = new File(providers.systemProperty('java.home').get())
diff --git a/build.gradle b/build.gradle
index f24ee350b3..59392f1e0b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -195,7 +195,7 @@ def compileTestExtensionModule = tasks.register("compileTestExtensionModule", Ja
classpath = files(tasks.named('jar'))
source fileTree(extModuleFixtureDir.dir("src/main/java"))
destinationDirectory = extModuleOutputDir.map { it.dir("classes") }
- sourceCompatibility = sharedConfiguration.targetJavaVersion.get()
+ sourceCompatibility = sharedConfiguration.sourceJavaVersion.get()
targetCompatibility = sharedConfiguration.targetJavaVersion.get()
}
diff --git a/gradle.properties b/gradle.properties
index d7700cc928..e91d5a285b 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -18,6 +18,7 @@ groovyVersion=5.0.0-SNAPSHOT
groovyBundleVersion=5.0.0.SNAPSHOT
groovyTargetBytecodeVersion=11
+sourceJavaVersion=17
targetJavaVersion=11
binaryCompatibilityBaseline=4.0.18
diff --git a/gradle/idea.gradle b/gradle/idea.gradle
index 159e42e5bd..ebf139ea71 100644
--- a/gradle/idea.gradle
+++ b/gradle/idea.gradle
@@ -50,8 +50,8 @@ if (gradle.startParameter.taskNames.any { it =~ /(?i)idea/ }) {
// jdk, language level fix
def pRoot = node.component.find { it.'@name' == 'ProjectRootManager' }
- pRoot.'@languageLevel' = 'JDK_' + sharedConfiguration.targetJavaVersion.get()
- pRoot.'@project-jdk-name' = sharedConfiguration.targetJavaVersion.get()
+ pRoot.'@languageLevel' = 'JDK_' + sharedConfiguration.sourceJavaVersion.get()
+ pRoot.'@project-jdk-name' = sharedConfiguration.sourceJavaVersion.get()
// Use git
def vcsConfig = node.component.find { it.'@name' == 'VcsDirectoryMappings' }