diff --git a/.github/workflows/cli-unit-tests.yml b/.github/workflows/cli-unit-tests.yml
index 49a9608..d4b613e 100644
--- a/.github/workflows/cli-unit-tests.yml
+++ b/.github/workflows/cli-unit-tests.yml
@@ -27,4 +27,4 @@ jobs:
- name: Test with JBang
run: |
export PATH="$HOME/.jbang/bin:$PATH"
- jbang TestJythonCli.java execute --disable-ansi-colors --select-class=TestJythonCli
+ jbang src/test/java/TestJythonCli.java execute --disable-ansi-colors --select-class=TestJythonCli
diff --git a/.gitignore b/.gitignore
index ee2228f..f74f70a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,6 @@
/jython-jbang-catalog.iml
/.vscode/
+/.gradle/
+/build/
+/target/
diff --git a/.sdkmanrc b/.sdkmanrc
index b10ab7d..5be2f76 100644
--- a/.sdkmanrc
+++ b/.sdkmanrc
@@ -2,8 +2,8 @@
# Add key=value pairs of SDKs to use below
# Java
-java=8.0.452-tem
+java=17.0.16-tem
# JBang
-jbang=0.126.1
+jbang=0.132.1
diff --git a/README.md b/README.md
index be1ace8..fe86cd2 100644
--- a/README.md
+++ b/README.md
@@ -252,18 +252,13 @@ Also test the jython-cli script with Java 8:
* jbang run --java 8 jython-cli examples/turtle.py
* jbang run --java 8 jython-cli examples/simpletest.py
-On Linux or MacOS the JythonCli.java script can be run directly for testing purposes:
-
-* ./JythonCli.java -V
-* ./JythonCli.java examples/banner.py
-
## Java Source File Formatting
-Use the `google-java-format` to format the `JythonCli.java` and `TestJythonCli.java` programs.
+Use the Gradle task `spotlessApply` to format the `JythonCli.java` and `TestJythonCli.java` programs. Task `spotlessCheck` will only check if the Java source files are correctly formatted.
-```
-jbang run com.google.googlejavaformat:google-java-format:1.29.0 --aosp -r *.java
-```
+The configuration file used by the Eclipse Java Formatter, when running the `spotless` tasks, can be imported into your preferred IDE (if supported).
+
+* See file `tools\eclipse-java-formatter\Jython-2017-v2.xml`
## Articles about Jython and JBang
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..eaf89b7
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,46 @@
+import dev.jbang.gradle.tasks.JBangTask
+
+// Apply the standard Java plugin
+plugins {
+ id 'java'
+ // Apply the Spotless plugin (using the same version as in the Kotlin DSL)
+ id 'com.diffplug.spotless' version '7.2.1'
+ id 'dev.jbang' version '0.3.0'
+}
+
+// Standard repository configuration
+repositories {
+ mavenCentral()
+}
+
+// === Spotless Configuration ===
+spotless {
+ // Define the formatting rules for Java files
+ java {
+ eclipse().configFile('tools/eclipse-java-formatter/Jython-2017-v2.xml')
+
+ importOrder()
+ removeUnusedImports()
+ toggleOffOn()
+ }
+}
+
+// Define a custom task to run jython-cli tests
+tasks.register("runTests", JBangTask) {
+ // Specify the script file to run
+ script = "src/test/java/TestJythonCli.java"
+
+ // Optional: Pass arguments to the script
+ jbangArgs = ["--java", "17"]
+ args = ["execute", "--disable-ansi-colors", "--select-class=TestJythonCli"]
+}
+
+// Add a standard task for running the application
+tasks.register('hello') {
+ doLast {
+ println 'Spotless is now configured using Groovy DSL with Google Java Format. To format your code, run:'
+ println './gradlew spotlessApply'
+ println 'To check if files need formatting (useful for CI), run:'
+ println './gradlew spotlessCheck'
+ }
+}
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8bdaf60
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..d4081da
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..adff685
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,248 @@
+#!/bin/sh
+
+#
+# Copyright © 2015 the original 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.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..c4bdd3a
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,93 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/jbang-catalog.json b/jbang-catalog.json
index 4c004f3..c067754 100644
--- a/jbang-catalog.json
+++ b/jbang-catalog.json
@@ -1,7 +1,7 @@
{
"aliases": {
"jython-cli": {
- "script-ref": "JythonCli.java",
+ "script-ref": "src/main/java/JythonCli.java",
"description": "Run Jython 2.7"
}
}
diff --git a/JythonCli.java b/src/main/java/JythonCli.java
similarity index 86%
rename from JythonCli.java
rename to src/main/java/JythonCli.java
index a9210dc..90c26e4 100755
--- a/JythonCli.java
+++ b/src/main/java/JythonCli.java
@@ -1,13 +1,10 @@
-///usr/bin/env jbang "$0" "$@" ; exit $?
-
//DEPS org.tomlj:tomlj:1.1.1
import java.io.*;
import java.util.*;
-
import org.tomlj.Toml;
-import org.tomlj.TomlParseResult;
import org.tomlj.TomlParseError;
+import org.tomlj.TomlParseResult;
public class JythonCli {
@@ -16,8 +13,8 @@ public class JythonCli {
*/
String jythonVersion = "2.7.4";
/**
- * Default version of Java to use as determined by the JVM version running
- * {@code jython-cli}. Only Java 8 or higher is supported.
+ * Default version of Java to use as determined by the JVM version
+ * running {@code jython-cli}. Only Java 8 or higher is supported.
*/
String javaVersion = getJvmMajorVersion();
/**
@@ -37,20 +34,20 @@ public class JythonCli {
*/
String scriptFilename;
/**
- * (optional) TOML text block extracted from the Jython script specified on
- * the command-line
+ * (optional) TOML text block extracted from the Jython script
+ * specified on the command-line
*/
StringBuilder tomlText = new StringBuilder();
/**
- * (optional) TOML parsed result object from which runtime information is
- * extracted
+ * (optional) TOML parsed result object from which runtime information
+ * is extracted
*/
TomlParseResult tpr = null;
/**
- * Debug output can be specified by the {@code --cli-debug} command line
- * option. If set, various critical state is displayed including the
- * {@code jbang} block, its meaning as TOML and the arguments passed to
- * ProcessBuilder.
+ * Debug output can be specified by the {@code --cli-debug} command
+ * line option. If set, various critical state is displayed including
+ * the {@code jbang} block, its meaning as TOML and the arguments
+ * passed to ProcessBuilder.
*/
boolean debug = false;
@@ -58,8 +55,8 @@ public class JythonCli {
* Determine the major version number of the JVM {@code jython-cli} is
* running on.
*
- * @return the major version number of the current JVM, that is "8", "9",
- * "10", etc.
+ * @return the major version number of the current JVM, that is "8",
+ * "9", "10", etc.
*/
static String getJvmMajorVersion() {
String version = System.getProperty("java.version");
@@ -71,7 +68,8 @@ static String getJvmMajorVersion() {
/**
* Process the command line arguments, giving special tratment to the
- * {@code --cli-debug} option and the (optional) Jython script specified.
+ * {@code --cli-debug} option and the (optional) Jython script
+ * specified.
*
* @param args program arguments as specified on the command-line
* @throws IOException
@@ -97,8 +95,8 @@ void initEnvironment(String[] args) throws IOException {
/**
* Read a script and parse out a {@code jbang} block if possible,
- * later to be interpreted as TOML data. Errors to do with framing
- * the block are detected here, while errors in content must wait.
+ * later to be interpreted as TOML data. Errors to do with framing the
+ * block are detected here, while errors in content must wait.
*
* @param script supplying text of the script
* @throws IOException
@@ -111,7 +109,7 @@ void readJBangBlock(Reader script) throws IOException {
boolean found = false;
printIfDebug("");
printIfDebug("TOML data in Jython script:");
- while ((line = lines.readLine())!=null) {
+ while ((line = lines.readLine()) != null) {
int lineno = lines.getLineNumber();
if (found && !line.startsWith("# ")) {
found = false;
@@ -138,9 +136,9 @@ void readJBangBlock(Reader script) throws IOException {
/**
* Interpret the jbang block from the Jython script specified on the
- * command-line as TOML data. The runtime options that are extracted from
- * the TOML data will override default version specifications determined
- * earlier.
+ * command-line as TOML data. The runtime options that are extracted
+ * from the TOML data will override default version specifications
+ * determined earlier.
*
* @throws IOException
*/
@@ -150,19 +148,20 @@ void interpretJBangBlock() throws IOException {
int lineno = 0;
printIfDebug("");
printIfDebug("TOML data extracted from Jython script:");
- for (String line: tomlText.toString().split("\\n", -1)) {
+ for (String line : tomlText.toString().split("\\n", -1)) {
lineno += 1;
printIfDebug(lineno, line);
}
tpr = Toml.parse(tomlText.toString());
if (tpr.hasErrors()) {
- for (TomlParseError err: tpr.errors()) {
+ for (TomlParseError err : tpr.errors()) {
System.err.println(err.toString());
}
if (debug) {
throw new IOException("Error interpreting JBang TOML data.");
} else {
- throw new IOException("Error interpreting JBang TOML data. Re-run with '--cli-debug' for details.");
+ throw new IOException(
+ "Error interpreting JBang TOML data. Re-run with '--cli-debug' for details.");
}
}
}
@@ -182,13 +181,13 @@ void interpretJBangBlock() throws IOException {
// dependencies
for (Object e : tpr.getArrayOrEmpty("dependencies").toList()) {
- String dep = (String) e;
+ String dep = (String)e;
deps.add(dep);
}
// runtime-options
for (Object e : tpr.getArrayOrEmpty("runtime-options").toList()) {
- String ropt = (String) e;
+ String ropt = (String)e;
ropts.add(ropt);
}
}
@@ -238,8 +237,8 @@ void runProcess() throws IOException, InterruptedException {
}
/**
- * Shorthand to print a line of the source jbang block if {@link #debug} is
- * set.
+ * Shorthand to print a line of the source jbang block if
+ * {@link #debug} is set.
*
* @param lineno source line number
* @param line text captured to {@link #tomlText}
@@ -264,8 +263,8 @@ void printIfDebug(String text) {
/**
* Main {@code jython-cli} (JythonCli.java) program. The arguments are
* exactly the same command-line arguments Jython itself supports as
- * documented in
- * Jython
+ * documented in Jython
* Command Line
*
* @param args arguments to the program.
@@ -282,8 +281,7 @@ public static void main(String[] args) {
// Normally we have a script file (but it's optional)
if (jythonCli.scriptFilename != null) {
Reader script = new BufferedReader(
- new InputStreamReader(
- new FileInputStream(jythonCli.scriptFilename)));
+ new InputStreamReader(new FileInputStream(jythonCli.scriptFilename)));
jythonCli.readJBangBlock(script);
jythonCli.interpretJBangBlock();
}
diff --git a/TestJythonCli.java b/src/test/java/TestJythonCli.java
similarity index 86%
rename from TestJythonCli.java
rename to src/test/java/TestJythonCli.java
index c6a7443..8521b04 100644
--- a/TestJythonCli.java
+++ b/src/test/java/TestJythonCli.java
@@ -1,30 +1,24 @@
-/// usr/bin/env jbang "$0" "$@" ; exit $?
+//DEPS org.junit.jupiter:junit-jupiter:5.14.1
+//DEPS org.junit.platform:junit-platform-console:1.14.1
-//SOURCES JythonCli.java
+//SOURCES ../../main/java/JythonCli.java
-//DEPS org.tomlj:tomlj:1.1.1
-//DEPS org.junit.jupiter:junit-jupiter:5.13.3
-//DEPS org.junit.platform:junit-platform-console:1.13.3
+import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException;
import java.io.StringReader;
-
-import static org.junit.jupiter.api.Assertions.*;
-
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.platform.console.ConsoleLauncher;
/**
- * A class to run tests on aspects of {@link JythonCli} by delegating to
- * the JUnit console {@link ConsoleLauncher}.
+ * A class to run tests on aspects of {@link JythonCli} by delegating
+ * to the JUnit console {@link ConsoleLauncher}.
*/
public class TestJythonCli {
- static final String[] ARGS_DEBUG_FOO =
- {"--cli-debug", "foo.py", "bar", "baz"};
- static final String[] ARGS_FOO =
- {"--version", "foo.py", "bar.py", "baz"};
+ static final String[] ARGS_DEBUG_FOO = {"--cli-debug", "foo.py", "bar", "baz"};
+ static final String[] ARGS_FOO = {"--version", "foo.py", "bar.py", "baz"};
static final String[] ARGS_NONE = {"--cli-debug"};
/** The {@code --cli-debug} flag is spotted */
@@ -59,8 +53,7 @@ void testJythonArgs() throws IOException {
@Test
@Disabled("readJBangBlock does not throw on an unterminated block")
void testUnterminated() throws IOException {
- String script =
- """
+ String script = """
# /// jbang
# requires-jython = "2.7.2"
# requires-java = "17"
@@ -71,16 +64,15 @@ void testUnterminated() throws IOException {
}
/**
- * An unterminated block may gobble up a {@code jbang} block. This
- * is not detectable by {@link JythonCli} as the text of a
- * {@code jbang} header could be legitimate content.
+ * An unterminated block may gobble up a {@code jbang} block. This is
+ * not detectable by {@link JythonCli} as the text of a {@code jbang}
+ * header could be legitimate content.
*/
@Test
@Disabled("readJBangBlock treats '/// jbang' inside another block as valid start")
void testGobbledBlock() throws IOException {
JythonCli cli = new JythonCli();
- processScript(cli,
- """
+ processScript(cli, """
# /// script
# requires-python = ">=3.11"
# /// jbang
@@ -101,8 +93,7 @@ void testGobbledBlock() throws IOException {
@Test
@Disabled("interpretJBangBlock treats '/// script' as valid terminator")
void testCollision() throws IOException {
- String script =
- """
+ String script = """
# /// jbang
# requires-jython = "2.7.2"
# requires-java = "8"
@@ -120,8 +111,7 @@ void testCollision() throws IOException {
@Test
@Disabled("readJBangBlock does not throw on a second jbang block")
void testTwoBlocks() throws IOException {
- String script =
- """
+ String script = """
# /// jbang
# requires-jython = "2.7.2"
# requires-java = "8"
@@ -143,8 +133,7 @@ void testTwoBlocks() throws IOException {
/** Invalid TOML is an error. */
@Test
void testInvalidTOML() throws IOException {
- String script =
- """
+ String script = """
# /// jbang
# requires-jython = "2.7.4"
# requires-java = "21"
@@ -163,8 +152,8 @@ void testInvalidTOML() throws IOException {
}
/**
- * Take an initialised {@link JythonCli} and have it process (but
- * not run) the given {@code String} as if the contents of a file.
+ * Take an initialised {@link JythonCli} and have it process (but not
+ * run) the given {@code String} as if the contents of a file.
*
* @param cli to exercise
* @param script to process as script
diff --git a/tools/eclipse-java-formatter/Jython-2017-v2.xml b/tools/eclipse-java-formatter/Jython-2017-v2.xml
new file mode 100644
index 0000000..16b53c1
--- /dev/null
+++ b/tools/eclipse-java-formatter/Jython-2017-v2.xml
@@ -0,0 +1,404 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+