Skip to content

Commit c27b85f

Browse files
committed
Split sample app
- spring-shell-sample-commands and spring-shell-sample-e2e - Needed changes in e2e tests and workflow - Fixes #754
1 parent 71ed646 commit c27b85f

File tree

58 files changed

+257
-31
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+257
-31
lines changed

Diff for: .github/workflows/e2e.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ jobs:
4242
name: spring-shell-samples-${{ matrix.nickname }}
4343
retention-days: 1
4444
path: |
45-
spring-shell-samples/build/libs/*.jar
46-
spring-shell-samples/build/native/nativeCompile/spring-shell-samples
47-
spring-shell-samples/build/native/nativeCompile/spring-shell-samples.exe
45+
spring-shell-samples/spring-shell-sample-commands/build/libs/*.jar
46+
spring-shell-samples/spring-shell-sample-commands/build/native/nativeCompile/spring-shell-sample-commands
47+
spring-shell-samples/spring-shell-sample-commands/build/native/nativeCompile/spring-shell-sample-commands.exe
48+
spring-shell-samples/spring-shell-sample-e2e/build/libs/*.jar
49+
spring-shell-samples/spring-shell-sample-e2e/build/native/nativeCompile/spring-shell-sample-e2e
50+
spring-shell-samples/spring-shell-sample-e2e/build/native/nativeCompile/spring-shell-sample-e2e.exe
4851
- name: Upload Build Logs
4952
if: ${{ failure() }}
5053
uses: actions/upload-artifact@v3

Diff for: .vscode/launch.json

+22-15
Original file line numberDiff line numberDiff line change
@@ -3,89 +3,96 @@
33
"configurations": [
44
{
55
"type": "java",
6-
"name": "Sample interactive",
6+
"name": "commands interactive",
77
"request": "launch",
88
"mainClass": "org.springframework.shell.samples.SpringShellSample",
9-
"projectName": "spring-shell-samples"
9+
"projectName": "spring-shell-sample-commands"
1010
},
1111
{
1212
"type": "java",
13-
"name": "Sample help",
13+
"name": "commands help",
1414
"request": "launch",
1515
"mainClass": "org.springframework.shell.samples.SpringShellSample",
16-
"projectName": "spring-shell-samples",
16+
"projectName": "spring-shell-sample-commands",
1717
"args": "help"
1818
},
1919
{
2020
"type": "java",
21-
"name": "Sample fail noarg",
21+
"name": "commands fail noarg",
2222
"request": "launch",
2323
"mainClass": "org.springframework.shell.samples.SpringShellSample",
24-
"projectName": "spring-shell-samples",
24+
"projectName": "spring-shell-sample-commands",
2525
"args": "fail"
2626
},
2727
{
2828
"type": "java",
29-
"name": "Sample fail arg",
29+
"name": "commands fail arg",
3030
"request": "launch",
3131
"mainClass": "org.springframework.shell.samples.SpringShellSample",
32-
"projectName": "spring-shell-samples",
32+
"projectName": "spring-shell-sample-commands",
3333
"args": "fail --elementType TYPE"
3434
},
35+
{
36+
"type": "java",
37+
"name": "e2e interactive",
38+
"request": "launch",
39+
"mainClass": "org.springframework.shell.samples.SpringShellSample",
40+
"projectName": "spring-shell-sample-e2e"
41+
},
3542
{
3643
"type": "java",
3744
"name": "e2e reg error-handling",
3845
"request": "launch",
3946
"mainClass": "org.springframework.shell.samples.SpringShellSample",
40-
"projectName": "spring-shell-samples",
47+
"projectName": "spring-shell-sample-e2e",
4148
"args": "e2e reg error-handling"
4249
},
4350
{
4451
"type": "java",
4552
"name": "e2e reg error-handling arg1 throw1",
4653
"request": "launch",
4754
"mainClass": "org.springframework.shell.samples.SpringShellSample",
48-
"projectName": "spring-shell-samples",
55+
"projectName": "spring-shell-sample-e2e",
4956
"args": "e2e reg error-handling --arg1 throw1"
5057
},
5158
{
5259
"type": "java",
5360
"name": "e2e reg error-handling arg1 throw2",
5461
"request": "launch",
5562
"mainClass": "org.springframework.shell.samples.SpringShellSample",
56-
"projectName": "spring-shell-samples",
63+
"projectName": "spring-shell-sample-e2e",
5764
"args": "e2e reg error-handling --arg1 throw2"
5865
},
5966
{
6067
"type": "java",
6168
"name": "e2e reg error-handling arg1 throw3",
6269
"request": "launch",
6370
"mainClass": "org.springframework.shell.samples.SpringShellSample",
64-
"projectName": "spring-shell-samples",
71+
"projectName": "spring-shell-sample-e2e",
6572
"args": "e2e reg error-handling --arg1 throw3"
6673
},
6774
{
6875
"type": "java",
6976
"name": "e2e exit-code noarg",
7077
"request": "launch",
7178
"mainClass": "org.springframework.shell.samples.SpringShellSample",
72-
"projectName": "spring-shell-samples",
79+
"projectName": "spring-shell-sample-e2e",
7380
"args": "e2e reg exit-code"
7481
},
7582
{
7683
"type": "java",
7784
"name": "e2e exit-code arg hi",
7885
"request": "launch",
7986
"mainClass": "org.springframework.shell.samples.SpringShellSample",
80-
"projectName": "spring-shell-samples",
87+
"projectName": "spring-shell-sample-e2e",
8188
"args": "e2e reg exit-code --arg1 hi"
8289
},
8390
{
8491
"type": "java",
8592
"name": "e2e exit-code arg fun",
8693
"request": "launch",
8794
"mainClass": "org.springframework.shell.samples.SpringShellSample",
88-
"projectName": "spring-shell-samples",
95+
"projectName": "spring-shell-sample-e2e",
8996
"args": "e2e reg exit-code --arg1 fun"
9097
}
9198
]

Diff for: e2e/README.adoc

+1-1

Diff for: e2e/spring-shell-e2e-tests/src/utils.ts

+14-4
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,28 @@ import * as path from 'path';
44
export const tempDir = path.join(__dirname, 'spring-shell', 'temp');
55
export const isWindows = os.platform() === 'win32';
66
export const cliPathRelative = isWindows
7-
? '..\\..\\spring-shell-samples\\build\\native\\nativeCompile\\spring-shell-samples.exe'
8-
: '../../spring-shell-samples/build/native/nativeCompile/spring-shell-samples';
7+
? '..\\..\\spring-shell-samples\\spring-shell-sample-e2e\\build\\native\\nativeCompile\\spring-shell-sample-e2e.exe'
8+
: '../../spring-shell-samples/spring-shell-sample-e2e/build/native/nativeCompile/spring-shell-sample-e2e';
9+
export const commandsCliPathRelative = isWindows
10+
? '..\\..\\spring-shell-samples\\spring-shell-sample-commands\\build\\native\\nativeCompile\\spring-shell-sample-commands.exe'
11+
: '../../spring-shell-samples/spring-shell-sample-commands/build/native/nativeCompile/spring-shell-sample-commands';
912
export const jarPathRelative = isWindows
10-
? '..\\..\\spring-shell-samples\\build\\libs\\spring-shell-samples.jar'
11-
: '../../spring-shell-samples/build/libs/spring-shell-samples.jar';
13+
? '..\\..\\spring-shell-samples\\spring-shell-sample-e2e\\build\\libs\\spring-shell-sample-e2e.jar'
14+
: '../../spring-shell-samples/spring-shell-sample-e2e/build/libs/spring-shell-sample-e2e.jar';
15+
export const commandsJarPathRelative = isWindows
16+
? '..\\..\\spring-shell-samples\\spring-shell-sample-commands\\build\\libs\\spring-shell-sample-commands.jar'
17+
: '../../spring-shell-samples/spring-shell-sample-commands/build/libs/spring-shell-sample-commands.jar';
1218
export const cliPath = path.resolve(cliPathRelative);
19+
export const commandsCliPath = path.resolve(commandsCliPathRelative);
1320
export const jarPath = path.resolve(jarPathRelative);
21+
export const commandsJarPath = path.resolve(commandsJarPathRelative);
1422
export const nativeDesc = 'native';
1523
export const jarDesc = 'jar';
1624
export const jarCommand = isWindows ? 'java.exe' : 'java';
1725
export const nativeCommand = cliPath;
26+
export const commandsNativeCommand = commandsCliPath;
1827
export const jarOptions = ['-jar', jarPath];
28+
export const commandsJarOptions = ['-jar', commandsJarPath];
1929
export const waitForExpectDefaultTimeout = 30000;
2030
export const waitForExpectDefaultInterval = 2000;
2131
export const testTimeout = 120000;

Diff for: e2e/spring-shell-e2e-tests/test/flow.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
nativeDesc,
66
jarDesc,
77
jarCommand,
8-
nativeCommand,
9-
jarOptions,
8+
commandsNativeCommand,
9+
commandsJarOptions,
1010
waitForExpectDefaultTimeout,
1111
waitForExpectDefaultInterval,
1212
testTimeout
@@ -71,7 +71,7 @@ describe('flow commands', () => {
7171
describe(jarDesc, () => {
7272
beforeAll(() => {
7373
command = jarCommand;
74-
options = jarOptions;
74+
options = commandsJarOptions;
7575
});
7676

7777
it(
@@ -92,7 +92,7 @@ describe('flow commands', () => {
9292
*/
9393
describe(nativeDesc, () => {
9494
beforeAll(() => {
95-
command = nativeCommand;
95+
command = commandsNativeCommand;
9696
options = [];
9797
});
9898

Diff for: settings.gradle

+12-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ include 'spring-shell-core-test-support'
4545
include 'spring-shell-management'
4646
include 'spring-shell-dependencies'
4747
include 'spring-shell-docs'
48-
include 'spring-shell-samples'
4948
include 'spring-shell-standard'
5049
include 'spring-shell-standard-commands'
5150
include 'spring-shell-table'
@@ -56,12 +55,22 @@ file("${rootDir}/spring-shell-starters").eachDirMatch(~/spring-shell-starter.*/)
5655
include "spring-shell-starters:${it.name}"
5756
}
5857

58+
file("${rootDir}/spring-shell-samples").eachDirMatch(~/spring-shell-sample.*/) {
59+
include "spring-shell-samples:${it.name}"
60+
}
61+
5962
rootProject.children.each { project ->
6063
if (project.name == 'spring-shell-starters') {
6164
project.children.each { subproject ->
62-
subproject.buildFileName = "${subproject.name}.gradle"
65+
subproject.buildFileName = "${subproject.name}.gradle"
66+
}
67+
}
68+
else if (project.name == 'spring-shell-samples') {
69+
project.children.each { subproject ->
70+
subproject.buildFileName = "${subproject.name}.gradle"
6371
}
64-
} else {
72+
}
73+
else {
6574
project.buildFileName = "${project.name}.gradle"
6675
}
6776
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
plugins {
2+
id 'org.springframework.shell.sample'
3+
id 'org.springframework.boot'
4+
id 'org.graalvm.buildtools.native'
5+
}
6+
7+
description = 'Spring Shell Sample Commands'
8+
9+
dependencies {
10+
management platform(project(":spring-shell-management"))
11+
implementation project(':spring-shell-starters:spring-shell-starter-jna')
12+
testImplementation project(':spring-shell-starters:spring-shell-starter-test')
13+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
14+
testImplementation 'org.awaitility:awaitility'
15+
}
16+
17+
springBoot {
18+
buildInfo()
19+
}
20+
21+
if (project.hasProperty('springShellSampleE2E') && springShellSampleE2E.toBoolean()) {
22+
bootJar {
23+
archiveName = "$baseName.$extension"
24+
}
25+
}
26+
27+
graalvmNative {
28+
metadataRepository {
29+
enabled = true
30+
}
31+
binaries {
32+
main {
33+
if (project.hasProperty('springShellSampleMusl') && springShellSampleMusl.toBoolean()) {
34+
buildArgs.add('--static')
35+
buildArgs.add('--libc=musl')
36+
}
37+
}
38+
}
39+
}

Diff for: spring-shell-samples/spring-shell-samples.gradle renamed to spring-shell-samples/spring-shell-sample-e2e/spring-shell-sample-e2e.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
id 'org.graalvm.buildtools.native'
55
}
66

7-
description = 'Spring Shell Samples'
7+
description = 'Spring Shell Sample E2E'
88

99
dependencies {
1010
management platform(project(":spring-shell-management"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2017-2023 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;
17+
18+
import org.jline.utils.AttributedString;
19+
import org.jline.utils.AttributedStyle;
20+
21+
import org.springframework.boot.Banner.Mode;
22+
import org.springframework.boot.SpringApplication;
23+
import org.springframework.boot.autoconfigure.SpringBootApplication;
24+
import org.springframework.context.annotation.Bean;
25+
import org.springframework.shell.command.annotation.CommandScan;
26+
import org.springframework.shell.jline.PromptProvider;
27+
28+
/**
29+
* Main entry point for the application.
30+
*
31+
* <p>Creates the application context and start the REPL.</p>
32+
*
33+
* @author Eric Bottard
34+
* @author Janne Valkealahti
35+
*/
36+
@SpringBootApplication
37+
@CommandScan
38+
public class SpringShellSample {
39+
40+
public static void main(String[] args) throws Exception {
41+
SpringApplication application = new SpringApplication(SpringShellSample.class);
42+
application.setBannerMode(Mode.OFF);
43+
application.run(args);
44+
// TODO: follow up with boot why spring.main.banner-mode=off doesn't work
45+
// SpringApplication.run(SpringShellSample.class, args);
46+
}
47+
48+
@Bean
49+
public PromptProvider myPromptProvider() {
50+
return () -> new AttributedString("my-shell:>", AttributedStyle.DEFAULT.foreground(AttributedStyle.YELLOW));
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
spring:
2+
main:
3+
banner-mode: off
4+
shell:
5+
## pick global default option naming
6+
# option:
7+
# naming:
8+
# case-type: noop
9+
# case-type: camel
10+
# case-type: snake
11+
# case-type: kebab
12+
# case-type: pascal
13+
config:
14+
env: SPRING_SHELL_SAMPLES_USER_HOME
15+
location: "{userconfig}/spring-shell-samples"
16+
history:
17+
name: spring-shell-samples-history.log
18+
command:
19+
help:
20+
grouping-mode: group
21+
completion:
22+
root-command: spring-shell-samples
23+
## disable console logging
24+
logging:
25+
pattern:
26+
console:
27+
## log debug from a cli
28+
# file:
29+
# name: shell.log
30+
# level:
31+
# root: debug
32+
# org:
33+
# springframework:
34+
# shell: debug

0 commit comments

Comments
 (0)