Skip to content

Commit a12e3e3

Browse files
rhoriguchiRyan HoriguchiStefan Kapferer
authored
Feature/improve user experience (#9)
Co-authored-by: Ryan Horiguchi <ryan.horiguchi@mimacom.com> Co-authored-by: Stefan Kapferer <stefan.kapferer@mimacom.com>
1 parent 83d3df5 commit a12e3e3

6 files changed

Lines changed: 88 additions & 11 deletions

File tree

.github/FUNDING.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
github: stefan-ka
2-

.github/workflows/build_master.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
build_and_publish_snapshot:
1212
runs-on: ubuntu-18.04
13-
13+
1414
steps:
1515
- uses: actions/checkout@v2
1616
with:
@@ -48,4 +48,3 @@ jobs:
4848
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
4949
- name: Upload coverage to Codecov
5050
uses: codecov/codecov-action@v1
51-

.github/workflows/build_standard.yml

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
build:
1111
runs-on: ubuntu-18.04
12-
12+
1313
steps:
1414
- uses: actions/checkout@v2
1515
with:
@@ -20,7 +20,7 @@ jobs:
2020
java-version: 11
2121
- name: Install Graphviz
2222
run: sudo apt-get -y install graphviz
23-
- name: Gradle caches
23+
- name: Gradle caches
2424
uses: actions/cache@v2
2525
with:
2626
path: |
@@ -35,4 +35,71 @@ jobs:
3535
run: ./gradlew clean build snapshot
3636
- name: Upload coverage to Codecov
3737
uses: codecov/codecov-action@v1
38+
- name: Unpack tar
39+
run: mkdir ./out && tar -xf ./build/distributions/*.tar --strip-components 1 -C ./out
40+
- name: Upload build
41+
uses: actions/upload-artifact@v2
42+
with:
43+
name: build
44+
path: ./out
45+
if-no-files-found: error
46+
47+
validate_java_8:
48+
runs-on: ubuntu-18.04
49+
needs:
50+
- build
3851

52+
steps:
53+
- name: Download build
54+
uses: actions/download-artifact@v2
55+
with:
56+
name: build
57+
path: ./out
58+
- name: Grant execute permission for cm
59+
run: chmod +x ./out/bin/cm
60+
- name: Set up JDK 8
61+
uses: actions/setup-java@v1
62+
with:
63+
java-version: 8
64+
- name: Execute to check if Java version is compatible
65+
run: ./out/bin/cm
66+
67+
validate_java_11:
68+
runs-on: ubuntu-18.04
69+
needs:
70+
- build
71+
72+
steps:
73+
- name: Download build
74+
uses: actions/download-artifact@v2
75+
with:
76+
name: build
77+
path: ./out
78+
- name: Grant execute permission for cm
79+
run: chmod +x ./out/bin/cm
80+
- name: Set up JDK 11
81+
uses: actions/setup-java@v1
82+
with:
83+
java-version: 11
84+
- name: Execute to check if Java version is compatible
85+
run: ./out/bin/cm
86+
87+
validate_java_17:
88+
runs-on: ubuntu-18.04
89+
needs:
90+
- build
91+
92+
steps:
93+
- name: Download build
94+
uses: actions/download-artifact@v2
95+
with:
96+
name: build
97+
path: ./out
98+
- name: Grant execute permission for cm
99+
run: chmod +x ./out/bin/cm
100+
- name: Set up JDK 17
101+
uses: actions/setup-java@v1
102+
with:
103+
java-version: 17
104+
- name: Execute to check if Java version is compatible
105+
run: ./out/bin/cm || if [ $? != 1 ]; then exit -1; fi

.github/workflows/release.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
release:
1010
runs-on: ubuntu-18.04
11-
11+
1212
steps:
1313
- uses: actions/checkout@v2
1414
with:
@@ -19,7 +19,7 @@ jobs:
1919
java-version: 11
2020
- name: Install Graphviz
2121
run: sudo apt-get -y install graphviz
22-
- name: Gradle caches
22+
- name: Gradle caches
2323
uses: actions/cache@v2
2424
with:
2525
path: |
@@ -46,4 +46,3 @@ jobs:
4646
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
4747
- name: Upload coverage to Codecov
4848
uses: codecov/codecov-action@v1
49-

src/main/java/org/contextmapper/cli/ContextMapperCLI.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@
2020
import org.contextmapper.cli.commands.ValidateCommand;
2121

2222
import java.util.Arrays;
23+
import java.util.Collections;
24+
import java.util.List;
2325

2426
public class ContextMapperCLI {
2527

28+
private static final List<String> REQUIRED_JAVA_VERSIONS = Collections.unmodifiableList(Arrays.asList("1.8", "11"));
2629
private static final String VALIDATE_COMMAND = "validate";
2730
private static final String GENERATE_COMMAND = "generate";
2831

@@ -35,7 +38,14 @@ public ContextMapperCLI() {
3538
}
3639

3740
public static void main(String[] args) {
38-
new ContextMapperCLI().run(args);
41+
String javaVersion = System.getProperty("java.version");
42+
43+
if (REQUIRED_JAVA_VERSIONS.stream().anyMatch(javaVersion::startsWith)) {
44+
new ContextMapperCLI().run(args);
45+
} else {
46+
System.out.printf("Invalid Java version '%s', please set JAVA_HOME to major version '%s'%n", javaVersion, String.join("' or '", REQUIRED_JAVA_VERSIONS));
47+
System.exit(1);
48+
}
3949
}
4050

4151
protected void run(String[] args) {
@@ -47,6 +57,9 @@ protected void run(String[] args) {
4757
validateCommand.run(Arrays.copyOfRange(args, 1, args.length));
4858
} else if (GENERATE_COMMAND.equalsIgnoreCase(args[0])) {
4959
generateCommand.run(Arrays.copyOfRange(args, 1, args.length));
60+
} else {
61+
System.out.println("Invalid input");
62+
System.exit(127);
5063
}
5164
}
5265

src/main/java/org/contextmapper/cli/commands/GenerateCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ private Options createOptions() {
8080
options.addOption(input);
8181

8282
Option generator = new Option("g", "generator", true,
83-
"The generator you want to call. Use one of the following values: " + String.join(", ", Arrays
84-
.asList(ContextMapperGenerator.values()).stream().map(g -> g.toString()).collect(Collectors.toList())));
83+
"The generator you want to call. Use one of the following values: " +
84+
Arrays.stream(ContextMapperGenerator.values()).map(ContextMapperGenerator::toString).collect(Collectors.joining(", ")));
8585
generator.setRequired(true);
8686
options.addOption(generator);
8787

0 commit comments

Comments
 (0)