Skip to content

Commit 6c5352d

Browse files
Convert jshell-based scripts to plain java programs
This commit also upgrades minimal JDK to 24, except for JDK 21 being still used in Bazel-based builds. --------- Co-authored-by: Marc Philipp <[email protected]>
1 parent f7ee10c commit 6c5352d

File tree

19 files changed

+470
-208
lines changed

19 files changed

+470
-208
lines changed

.github/workflows/build-all-examples.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20-
- name: 'Set up JDK 21'
20+
- name: 'Set up JDK 24'
2121
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
2222
with:
23-
java-version: 21
23+
java-version: 24
2424
distribution: temurin
2525
- uses: sbt/setup-sbt@a9d38be6cfa0c7bfb8be93b4cc4e1edaa6351728 # v1.1.10
26-
- name: 'Build all examples using JShell'
26+
- name: 'Build all examples'
2727
run: java src/Builder.java
2828
- name: 'Check automation for updating versions'
2929
run: java src/Updater.java 42

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
build-mode: manual
2626
steps:
2727
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28-
- name: 'Set up JDK 21'
28+
- name: 'Set up JDK 24'
2929
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
3030
with:
31-
java-version: 21
31+
java-version: 24
3232
distribution: temurin
3333
- uses: sbt/setup-sbt@a9d38be6cfa0c7bfb8be93b4cc4e1edaa6351728 # v1.1.10
3434
- name: Initialize CodeQL

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
Welcome to _JUnit Examples_, a collection of example applications and extensions
44
using JUnit Jupiter, JUnit Vintage, and the JUnit Platform on various build systems.
55

6-
CI builds for example projects are performed by [GitHub Actions][ci-actions]. Using JDK 11+'s
7-
`jshell` tool, you may build all examples via the `build-all-examples.jsh` script.
6+
CI builds for example projects are performed by [GitHub Actions][ci-actions]. Using JDK 24+'s
7+
`java` multi-file source-code launcher feature, you may build all examples by running
8+
`java src/Builder.java` in the main directory of this project.
89

910
## Jupiter Starter Examples
1011

junit-jupiter-starter-ant/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# junit-jupiter-starter-ant
22

33
The `junit-jupiter-starter-ant` project demonstrates how to execute JUnit Jupiter
4-
tests using [Apache Ant](https://ant.apache.org/) 1.10.4 or higher.
4+
tests using [Apache Ant](https://ant.apache.org/) 1.10.15 or higher.
55

66
This example project does not aim to demonstrate how to use the JUnit Jupiter APIs.
77

junit-jupiter-starter-ant/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -e
55
# Set constants.
66
#
77
junit_platform_version='1.13.2'
8-
ant_version='1.10.13'
8+
ant_version='1.10.15'
99
ant_folder="apache-ant-${ant_version}"
1010
ant_archive="${ant_folder}-bin.tar.gz"
1111
standalone_jar="${ant_folder}/lib/junit-platform-console-standalone-${junit_platform_version}.jar"

junit-jupiter-starter-ant/build.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project name="junit-jupiter-starter-ant" default="build" basedir=".">
33

4-
<fail message="Ant 1.10.4+ is required!">
4+
<fail message="Ant 1.10.15+ is required!">
55
<condition>
66
<not>
7-
<antversion atleast="1.10.4"/>
7+
<antversion atleast="1.10.15"/>
88
</not>
99
</condition>
1010
</fail>

junit-jupiter-starter-bazel/.bazelrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
build --java_language_version=21
2+
build --java_runtime_version=remotejdk_21
3+
4+
build --tool_java_language_version=21
5+
build --tool_java_runtime_version=remotejdk_21
6+
7+
test --test_output=all

junit-modular-world/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
bin/
22
lib/
3+
!src/build/
34
.jqwik-database

junit-modular-world/README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
The project layout structure and command line tools usages are based on proposals
44
introduced by the [**Module System Quick-Start Guide**](https://openjdk.java.net/projects/jigsaw/quick-start).
5-
Invoke the [jshell](https://docs.oracle.com/javase/9/tools/jshell.htm) script
6-
`./build.jsh` (Windows: `jshell build.jsh`) to build this example project.
5+
Invoke [java](https://openjdk.org/jeps/458)'s source launcher
6+
`java src/build/Build.java` to build this example project.
77

8-
This example project does not aim to demonstrate how to use the JUnit Platform APIs.
9-
For detailed information on the JUnit Platform programming and extension models,
8+
This example project does not aim to demonstrate how to use the JUnit Framework APIs.
9+
For detailed information on the JUnit Framework programming and extension models,
1010
please consult the [User Guide](https://docs.junit.org/current/user-guide/).
1111

1212
## Source Layout
@@ -22,7 +22,7 @@ It tests the exported packages and types of the main modules.
2222

2323
## Binary Layout
2424

25-
Main binaries are compiled and packaged using `./compile.jsh`.
25+
Main binaries are compiled and packaged using `java src/build/Compile.java`.
2626

2727
For example, here are the commands to compile and package the `com.example.tool` module.
2828
This and the `com.example.application` module don't need external module dependencies.
@@ -57,18 +57,16 @@ jar
5757
.
5858
```
5959

60-
Here is the partly expanded tree of the `bin/` directory after running `./compile.jsh`:
60+
Here is the partly expanded tree of the `bin/` directory after running `java src/build/Compile.java`:
6161

6262
![junit-modular-world/bin](doc/screenshot-bin.png)
6363

6464

6565
## Running Tests
6666

67-
Compiling and running tests is achieved by calling the following test scripts:
67+
Compiling and running tests is achieved by calling the following Java program:
6868

69-
- `test-classpath.jsh`
70-
- `test-patch-compile.jsh`
71-
- `test-patch-runtime.jsh`
69+
- `java src/build/Build.java`
7270

7371
```
7472
@@ -116,7 +114,7 @@ Compiling and running tests is achieved by calling the following test scripts:
116114
## Ice Cream Test Engine
117115

118116
The `ice.cream` module demonstrates how to write and register your own `TestEngine`
119-
implementation using the Java Platform Module System.
117+
implementation using a Java module descriptor.
120118
This engine does not find any tests in containers, but _discovers_ a configurable
121119
amount of ice cream scoops.
122120

junit-modular-world/build.jsh

Lines changed: 0 additions & 18 deletions
This file was deleted.

junit-modular-world/compile.jsh

Lines changed: 0 additions & 57 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2015-2025 the original author or authors.
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License v2.0 which
6+
* accompanies this distribution and is available at
7+
*
8+
* https://www.eclipse.org/legal/epl-v20.html
9+
*/
10+
11+
// default package
12+
13+
public class Build {
14+
public static void main(String[] args) throws Exception {
15+
var project = Project.ofCurrentWorkingDirectory();
16+
project.clean();
17+
project.compile();
18+
project.test();
19+
}
20+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright 2015-2025 the original author or authors.
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License v2.0 which
6+
* accompanies this distribution and is available at
7+
*
8+
* https://www.eclipse.org/legal/epl-v20.html
9+
*/
10+
11+
// default package
12+
13+
public class Compile {
14+
public static void main(String[] args) throws Exception {
15+
Project.ofCurrentWorkingDirectory().compile();
16+
}
17+
}

0 commit comments

Comments
 (0)