mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Don't use Gradle toolchains to specify Java version
This commit is contained in:
parent
630fae3093
commit
8800e7153b
|
@ -52,6 +52,10 @@ gradlePlugin {
|
||||||
id = "mavenPlugin"
|
id = "mavenPlugin"
|
||||||
implementationClass = "org.teavm.buildutil.MavenPluginPlugin"
|
implementationClass = "org.teavm.buildutil.MavenPluginPlugin"
|
||||||
}
|
}
|
||||||
|
create("javaVersion") {
|
||||||
|
id = "javaVersion"
|
||||||
|
implementationClass = "org.teavm.buildutil.JavaVersionPlugin"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,9 +65,7 @@ checkstyle {
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain {
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
languageVersion.set(JavaLanguageVersion.of(11))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val generatedConfigDir = project.layout.buildDirectory.dir("generated/config").get()
|
val generatedConfigDir = project.layout.buildDirectory.dir("generated/config").get()
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Alexey Andreev.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.teavm.buildutil;
|
||||||
|
|
||||||
|
import org.gradle.api.JavaVersion;
|
||||||
|
|
||||||
|
public interface JavaVersionExtension {
|
||||||
|
JavaVersion getVersion();
|
||||||
|
|
||||||
|
void setVersion(JavaVersion version);
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Alexey Andreev.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.teavm.buildutil;
|
||||||
|
|
||||||
|
import org.gradle.api.JavaVersion;
|
||||||
|
import org.gradle.api.Plugin;
|
||||||
|
import org.gradle.api.Project;
|
||||||
|
import org.gradle.api.plugins.JavaPluginExtension;
|
||||||
|
|
||||||
|
public class JavaVersionPlugin implements Plugin<Project> {
|
||||||
|
@Override
|
||||||
|
public void apply(Project project) {
|
||||||
|
var ext = new ExtensionImpl();
|
||||||
|
project.getExtensions().add(JavaVersionExtension.class, "javaVersion", ext);
|
||||||
|
project.afterEvaluate(p -> {
|
||||||
|
var java = p.getExtensions().findByType(JavaPluginExtension.class);
|
||||||
|
if (java != null) {
|
||||||
|
if (ext.version != null) {
|
||||||
|
java.setSourceCompatibility(ext.version);
|
||||||
|
java.setTargetCompatibility(ext.version);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ExtensionImpl implements JavaVersionExtension {
|
||||||
|
private JavaVersion version = JavaVersion.VERSION_11;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JavaVersion getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setVersion(JavaVersion version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -84,10 +84,7 @@ gradle.afterProject {
|
||||||
.findVersion("checkstyle").get().requiredVersion
|
.findVersion("checkstyle").get().requiredVersion
|
||||||
configDirectory.set(File(settings.rootDir, "../config/checkstyle"))
|
configDirectory.set(File(settings.rootDir, "../config/checkstyle"))
|
||||||
}
|
}
|
||||||
java.toolchain {
|
java.sourceCompatibility = JavaVersion.VERSION_11
|
||||||
if (!languageVersion.isPresent) {
|
java.targetCompatibility = JavaVersion.VERSION_11
|
||||||
languageVersion.set(JavaLanguageVersion.of(11))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -59,6 +59,10 @@ gradle.allprojects {
|
||||||
version = teavmVersion
|
version = teavmVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gradle.allprojects {
|
||||||
|
apply(plugin = "javaVersion")
|
||||||
|
}
|
||||||
|
|
||||||
gradle.afterProject {
|
gradle.afterProject {
|
||||||
val java = extensions.findByType<JavaPluginExtension>()
|
val java = extensions.findByType<JavaPluginExtension>()
|
||||||
if (java != null) {
|
if (java != null) {
|
||||||
|
@ -67,11 +71,6 @@ gradle.afterProject {
|
||||||
toolVersion = extensions.getByType<VersionCatalogsExtension>().named("libs")
|
toolVersion = extensions.getByType<VersionCatalogsExtension>().named("libs")
|
||||||
.findVersion("checkstyle").get().requiredVersion
|
.findVersion("checkstyle").get().requiredVersion
|
||||||
}
|
}
|
||||||
java.toolchain {
|
|
||||||
if (!languageVersion.isPresent) {
|
|
||||||
languageVersion.set(JavaLanguageVersion.of(11))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extensions.findByType<PublishingExtension>()?.apply {
|
extensions.findByType<PublishingExtension>()?.apply {
|
||||||
|
|
|
@ -20,10 +20,8 @@ plugins {
|
||||||
|
|
||||||
description = "Tests"
|
description = "Tests"
|
||||||
|
|
||||||
java {
|
javaVersion {
|
||||||
toolchain {
|
version = JavaVersion.VERSION_17
|
||||||
languageVersion.set(JavaLanguageVersion.of(17))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user