Initial ffm support

- Starter for jline ffm terminal provider
- Build changes for compiling with gradle toolchains
  defaulting to jdk22
- spring-shell-sample-ffm which compiles with jdk22
- ci workflow setups jdk 17/22
- Relates #1131
This commit is contained in:
Janne Valkealahti
2024-08-30 07:05:03 +01:00
parent e1ef18e8b4
commit bad75882e1
9 changed files with 202 additions and 2 deletions

View File

@@ -52,5 +52,9 @@ gradlePlugin {
id = "org.springframework.shell.sample"
implementationClass = "org.springframework.shell.gradle.SamplePlugin"
}
toolchainPlugin {
id = "org.springframework.shell.toolchain"
implementationClass = "org.springframework.shell.gradle.ToolchainPlugin"
}
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2024 the original author or authors.
*
* 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
*
* https://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.springframework.shell.gradle;
import org.gradle.api.Project;
import org.gradle.api.provider.Property;
import org.gradle.jvm.toolchain.JavaLanguageVersion;
public class ToolchainExtension {
private final Property<JavaLanguageVersion> maximumCompatibleJavaVersion;
private final JavaLanguageVersion javaVersion;
public ToolchainExtension(Project project) {
this.maximumCompatibleJavaVersion = project.getObjects().property(JavaLanguageVersion.class);
String toolchainVersion = (String) project.findProperty("toolchainVersion");
this.javaVersion = (toolchainVersion != null) ? JavaLanguageVersion.of(toolchainVersion) : null;
}
public Property<JavaLanguageVersion> getMaximumCompatibleJavaVersion() {
return this.maximumCompatibleJavaVersion;
}
JavaLanguageVersion getJavaVersion() {
return this.javaVersion;
}
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright 2024 the original author or authors.
*
* 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
*
* https://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.springframework.shell.gradle;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.jvm.toolchain.JavaLanguageVersion;
import org.gradle.jvm.toolchain.JavaToolchainSpec;
public class ToolchainPlugin implements Plugin<Project> {
@Override
public void apply(Project project) {
configureToolchain(project);
}
private void configureToolchain(Project project) {
ToolchainExtension toolchain = project.getExtensions().create("toolchain", ToolchainExtension.class, project);
project.afterEvaluate((evaluated) -> configure(evaluated, toolchain));
}
private void configure(Project project, ToolchainExtension toolchain) {
JavaLanguageVersion toolchainVersion = toolchain.getJavaVersion();
if (toolchainVersion == null) {
toolchainVersion = JavaLanguageVersion.of(22);
}
JavaToolchainSpec toolchainSpec = project.getExtensions()
.getByType(JavaPluginExtension.class)
.getToolchain();
toolchainSpec.getLanguageVersion().set(toolchainVersion);
}
}