Skip to content

Commit bad7588

Browse files
committed
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
1 parent e1ef18e commit bad7588

File tree

9 files changed

+202
-2
lines changed

9 files changed

+202
-2
lines changed

Diff for: .github/workflows/ci.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ jobs:
2828
- uses: actions/setup-java@v3
2929
with:
3030
distribution: adopt
31-
java-version: ${{ matrix.java }}
31+
java-version: |
32+
22
33+
17
3234
cache: gradle
3335
- name: Build
3436
run: ./gradlew build
@@ -41,7 +43,9 @@ jobs:
4143
- uses: actions/setup-java@v3
4244
with:
4345
distribution: adopt
44-
java-version: 17
46+
java-version: |
47+
22
48+
17
4549
cache: gradle
4650
- uses: jfrog/setup-jfrog-cli@v3
4751
with:

Diff for: buildSrc/build.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,9 @@ gradlePlugin {
5252
id = "org.springframework.shell.sample"
5353
implementationClass = "org.springframework.shell.gradle.SamplePlugin"
5454
}
55+
toolchainPlugin {
56+
id = "org.springframework.shell.toolchain"
57+
implementationClass = "org.springframework.shell.gradle.ToolchainPlugin"
58+
}
5559
}
5660
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.shell.gradle;
17+
18+
import org.gradle.api.Project;
19+
import org.gradle.api.provider.Property;
20+
import org.gradle.jvm.toolchain.JavaLanguageVersion;
21+
22+
public class ToolchainExtension {
23+
24+
private final Property<JavaLanguageVersion> maximumCompatibleJavaVersion;
25+
26+
private final JavaLanguageVersion javaVersion;
27+
28+
public ToolchainExtension(Project project) {
29+
this.maximumCompatibleJavaVersion = project.getObjects().property(JavaLanguageVersion.class);
30+
String toolchainVersion = (String) project.findProperty("toolchainVersion");
31+
this.javaVersion = (toolchainVersion != null) ? JavaLanguageVersion.of(toolchainVersion) : null;
32+
}
33+
34+
public Property<JavaLanguageVersion> getMaximumCompatibleJavaVersion() {
35+
return this.maximumCompatibleJavaVersion;
36+
}
37+
38+
JavaLanguageVersion getJavaVersion() {
39+
return this.javaVersion;
40+
}
41+
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.shell.gradle;
17+
18+
import org.gradle.api.Plugin;
19+
import org.gradle.api.Project;
20+
import org.gradle.api.plugins.JavaPluginExtension;
21+
import org.gradle.jvm.toolchain.JavaLanguageVersion;
22+
import org.gradle.jvm.toolchain.JavaToolchainSpec;
23+
24+
public class ToolchainPlugin implements Plugin<Project> {
25+
26+
@Override
27+
public void apply(Project project) {
28+
configureToolchain(project);
29+
}
30+
31+
private void configureToolchain(Project project) {
32+
ToolchainExtension toolchain = project.getExtensions().create("toolchain", ToolchainExtension.class, project);
33+
project.afterEvaluate((evaluated) -> configure(evaluated, toolchain));
34+
}
35+
36+
private void configure(Project project, ToolchainExtension toolchain) {
37+
JavaLanguageVersion toolchainVersion = toolchain.getJavaVersion();
38+
if (toolchainVersion == null) {
39+
toolchainVersion = JavaLanguageVersion.of(22);
40+
}
41+
JavaToolchainSpec toolchainSpec = project.getExtensions()
42+
.getByType(JavaPluginExtension.class)
43+
.getToolchain();
44+
toolchainSpec.getLanguageVersion().set(toolchainVersion);
45+
}
46+
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
plugins {
2+
id 'org.springframework.shell.sample'
3+
id 'org.springframework.shell.toolchain'
4+
}
5+
6+
description = 'Spring Shell Sample FFM'
7+
8+
tasks.named("bootJar") {
9+
manifest {
10+
attributes 'Enable-Native-Access': 'ALL-UNNAMED'
11+
}
12+
}
13+
14+
dependencies {
15+
management platform(project(":spring-shell-management"))
16+
implementation project(':spring-shell-starters:spring-shell-starter-ffm')
17+
testImplementation project(':spring-shell-starters:spring-shell-starter-test')
18+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
19+
testImplementation 'org.awaitility:awaitility'
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.shell.samples.ffm;
17+
18+
import org.springframework.boot.Banner.Mode;
19+
import org.springframework.boot.SpringApplication;
20+
import org.springframework.boot.autoconfigure.SpringBootApplication;
21+
import org.springframework.shell.command.annotation.CommandScan;
22+
23+
@SpringBootApplication
24+
@CommandScan
25+
public class SpringShellApplication {
26+
27+
public static void main(String[] args) throws Exception {
28+
SpringApplication application = new SpringApplication(SpringShellApplication.class);
29+
application.setBannerMode(Mode.OFF);
30+
application.run(args);
31+
}
32+
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
spring:
2+
main:
3+
banner-mode: off
4+
shell:
5+
interactive:
6+
enabled: true
7+
## disable console logging
8+
logging:
9+
pattern:
10+
console:
11+
## log debug from a cli
12+
# file:
13+
# name: shell-ffm.log
14+
# level:
15+
# root: debug
16+
# org:
17+
# springframework:
18+
# shell: debug
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.shell.samples.ffm;
17+
18+
public class SpringShellApplicationTests {
19+
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
plugins {
2+
id 'org.springframework.shell.starter'
3+
id 'org.springframework.shell.toolchain'
4+
}
5+
6+
description = 'Spring Shell Starter FFM'
7+
8+
dependencies {
9+
management platform(project(':spring-shell-management'))
10+
api(project(':spring-shell-starters:spring-shell-starter'))
11+
implementation 'org.jline:jline-terminal-ffm'
12+
}

0 commit comments

Comments
 (0)