Cleaning and some optimizations
Build and Test j3270 / Build JAR & Run Tests (Java 11) (push) Successful in 1m19s
Build and Test j3270 / Build JAR & Run Tests (Java 17) (push) Successful in 37s
Build and Test j3270 / Build JAR & Run Tests (Java 21) (push) Failing after 1m27s

This commit is contained in:
2026-09-28 14:16:01 +00:00
parent cf0c0999bf
commit f8d078a23b
14 changed files with 15 additions and 250 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ jobs:
- name: Make scripts executable
run: |
chmod +x ./build_all.sh ./test_all.sh ./run.sh
chmod +x ./setup.sh ./test_all.sh
- name: Build & Run Unit Tests
run: |
+1 -1
View File
@@ -44,7 +44,7 @@ jobs:
- name: Make scripts executable
run: |
chmod +x ./build_all.sh ./test_all.sh ./run.sh
chmod +x ./setup.sh ./test_all.sh
- name: Build & Run Unit Tests
run: |
+1 -1
View File
@@ -51,7 +51,7 @@ jobs:
- name: Make scripts executable
run: |
chmod +x ./build_all.sh ./test_all.sh ./run.sh
chmod +x ./setup.sh ./test_all.sh
- name: Build & Run Unit Tests
run: |
+1 -1
View File
@@ -44,7 +44,7 @@ jobs:
- name: Make scripts executable
run: |
chmod +x ./build_all.sh ./test_all.sh ./run.sh
chmod +x ./setup.sh ./test_all.sh
- name: Build & Run Unit Tests
run: |
+4 -8
View File
@@ -62,8 +62,8 @@ java -jar j3270.jar -c config.ini
# Enable protocol and diagnostic debug logging to j3270.log
java -jar j3270.jar -d mainframe.example.com
# Launch directly from source runner script
./run.sh
# Launch directly from source setup script
./setup.sh --run
```
---
@@ -160,15 +160,11 @@ Self-contained setup scripts automatically locate an installed Java 11+ JDK (sea
# Clean build and connect to host:
.\setup.ps1 -Clean -Run -- mainframe.example.com 23 4
```
*(Also available as `.\setup.ps`)*
### Standalone Build (Advanced / CI)
The project also provides low-level scripts and optional Gradle support:
### Standalone Testing & CI
Run automated tests directly via the standalone test runner:
```bash
# Direct compile and package without diagnostics:
sh ./build_all.sh
# Run all 851 automated unit tests (~25s):
sh ./test_all.sh
```
-168
View File
@@ -1,168 +0,0 @@
#!/bin/sh
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
echo "=== Building j3270 Terminal Emulator ==="
# 1. Locate Java toolchain
JAVAC_BIN=""
JAR_BIN=""
if [ -n "$JAVA_HOME" ] && [ -x "$JAVA_HOME/bin/javac" ] && [ -x "$JAVA_HOME/bin/jar" ]; then
JAVAC_BIN="$JAVA_HOME/bin/javac"
JAR_BIN="$JAVA_HOME/bin/jar"
elif command -v javac >/dev/null 2>&1 && command -v jar >/dev/null 2>&1; then
if javac -version >/dev/null 2>&1; then
JAVAC_BIN="$(command -v javac)"
JAR_BIN="$(command -v jar)"
fi
fi
if [ -z "$JAVAC_BIN" ] || [ -z "$JAR_BIN" ]; then
if [ -x /usr/libexec/java_home ]; then
MAC_JAVA_HOME="$(/usr/libexec/java_home 2>/dev/null || true)"
if [ -n "$MAC_JAVA_HOME" ] && [ -x "$MAC_JAVA_HOME/bin/javac" ] && [ -x "$MAC_JAVA_HOME/bin/jar" ]; then
export JAVA_HOME="$MAC_JAVA_HOME"
JAVAC_BIN="$JAVA_HOME/bin/javac"
JAR_BIN="$JAVA_HOME/bin/jar"
fi
fi
fi
if [ -z "$JAVAC_BIN" ] || [ -z "$JAR_BIN" ]; then
# Check standard system JDK installation locations
for h in /usr/lib/jvm/default-java \
/usr/lib/jvm/java-21-openjdk* \
/usr/lib/jvm/java-17-openjdk* \
/usr/lib/jvm/java-11-openjdk* \
/Library/Java/JavaVirtualMachines/*/Contents/Home \
/opt/homebrew/opt/openjdk/libexec/openjdk.jdk/Contents/Home \
/opt/homebrew/opt/openjdk; do
if [ -d "$h" ] && [ -x "$h/bin/javac" ] && [ -x "$h/bin/jar" ]; then
export JAVA_HOME="$h"
JAVAC_BIN="$JAVA_HOME/bin/javac"
JAR_BIN="$JAVA_HOME/bin/jar"
break
fi
done
fi
if [ -z "$JAVAC_BIN" ] || [ -z "$JAR_BIN" ]; then
echo "ERROR: Java development tools (javac, jar) could not be found."
echo "Please install JDK 11+ or set JAVA_HOME."
exit 1
fi
echo "Using Java compiler: $JAVAC_BIN"
echo "Using JAR utility: $JAR_BIN"
BUILD_DIR="$SCRIPT_DIR/build"
rm -rf "$BUILD_DIR/lib3270j" "$BUILD_DIR/j3270" "$BUILD_DIR/MANIFEST.MF"
mkdir -p "$BUILD_DIR/lib3270j" "$BUILD_DIR/j3270"
# 2. Compile lib3270j
echo "Compiling lib3270j..."
find "$SCRIPT_DIR/lib3270j/src/main/java" -name "*.java" > "$BUILD_DIR/lib_sources.txt"
if [ ! -s "$BUILD_DIR/lib_sources.txt" ]; then
echo "ERROR: No sources found in lib3270j/src/main/java"
exit 1
fi
"$JAVAC_BIN" -d "$BUILD_DIR/lib3270j" @"$BUILD_DIR/lib_sources.txt"
# 3. Compile j3270
echo "Compiling j3270 application..."
find "$SCRIPT_DIR/j3270/src/main/java" -name "*.java" > "$BUILD_DIR/app_sources.txt"
if [ ! -s "$BUILD_DIR/app_sources.txt" ]; then
echo "ERROR: No sources found in j3270/src/main/java"
exit 1
fi
"$JAVAC_BIN" -cp "$BUILD_DIR/lib3270j" -d "$BUILD_DIR/j3270" @"$BUILD_DIR/app_sources.txt"
# Clean up temporary source lists
rm -f "$BUILD_DIR/lib_sources.txt" "$BUILD_DIR/app_sources.txt"
# Copy any resources if present
if [ -d "$SCRIPT_DIR/j3270/src/main/resources" ]; then
cp -r "$SCRIPT_DIR/j3270/src/main/resources/"* "$BUILD_DIR/j3270/" 2>/dev/null || true
fi
if [ -d "$SCRIPT_DIR/lib3270j/src/main/resources" ]; then
cp -r "$SCRIPT_DIR/lib3270j/src/main/resources/"* "$BUILD_DIR/lib3270j/" 2>/dev/null || true
fi
# 4. Package JARs
echo "Packaging lib3270j.jar (standalone library)..."
printf "Manifest-Version: 1.0\nImplementation-Title: lib3270j\nImplementation-Version: 1.2.4\nCreated-By: j3270 build_all.sh\n\n" > "$BUILD_DIR/LIB_MANIFEST.MF"
"$JAR_BIN" cvfm "$BUILD_DIR/lib3270j.jar" "$BUILD_DIR/LIB_MANIFEST.MF" \
-C "$BUILD_DIR/lib3270j" . > /dev/null
echo "Packaging j3270.jar (standalone executable)..."
printf "Manifest-Version: 1.0\nMain-Class: haus.nightmare.j3270.J3270App\nImplementation-Title: j3270\nImplementation-Version: 1.2.4\nCreated-By: j3270 build_all.sh\n\n" > "$BUILD_DIR/MANIFEST.MF"
"$JAR_BIN" cvfm "$BUILD_DIR/j3270.jar" "$BUILD_DIR/MANIFEST.MF" \
-C "$BUILD_DIR/lib3270j" . \
-C "$BUILD_DIR/j3270" . > /dev/null
echo "=== Build Complete ==="
echo "Library JAR created: $BUILD_DIR/lib3270j.jar"
ls -lh "$BUILD_DIR/lib3270j.jar"
echo "Executable JAR created: $BUILD_DIR/j3270.jar"
ls -lh "$BUILD_DIR/j3270.jar"
# 5. Compile and run tests if requested
if [ "$1" = "test" ] || [ "$1" = "check" ]; then
echo "=== Running Tests ==="
TEST_BUILD_DIR="$BUILD_DIR/test-classes"
mkdir -p "$TEST_BUILD_DIR"
JUNIT_CP=$(find "$HOME/.gradle/caches/modules-2/files-2.1/" -name "*.jar" 2>/dev/null | grep -E "junit|opentest|apiguardian" | tr "\n" ":" || true)
FULL_CP="$BUILD_DIR/lib3270j:$BUILD_DIR/j3270:$JUNIT_CP"
find "$SCRIPT_DIR/lib3270j/src/test/java" -name "*.java" > "$BUILD_DIR/test_sources.txt" 2>/dev/null || true
if [ -d "$SCRIPT_DIR/j3270/src/test/java" ]; then
find "$SCRIPT_DIR/j3270/src/test/java" -name "*.java" >> "$BUILD_DIR/test_sources.txt" 2>/dev/null || true
fi
if [ -s "$BUILD_DIR/test_sources.txt" ] && [ -n "$JUNIT_CP" ]; then
echo "Compiling tests..."
"$JAVAC_BIN" -cp "$FULL_CP" -d "$TEST_BUILD_DIR" @"$BUILD_DIR/test_sources.txt"
rm -f "$BUILD_DIR/test_sources.txt"
echo "Executing tests with JUnit Platform..."
cat << 'EOF' > "$BUILD_DIR/TestRunner.java"
import org.junit.platform.launcher.*;
import org.junit.platform.launcher.core.*;
import org.junit.platform.launcher.listeners.*;
import org.junit.platform.engine.discovery.*;
import static org.junit.platform.engine.discovery.DiscoverySelectors.*;
import java.io.PrintWriter;
public class TestRunner {
public static void main(String[] args) {
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
.selectors(
selectPackage("haus.nightmare")
)
.build();
Launcher launcher = LauncherFactory.create();
SummaryGeneratingListener listener = new SummaryGeneratingListener();
launcher.registerTestExecutionListeners(listener);
launcher.execute(request);
TestExecutionSummary summary = listener.getSummary();
summary.printTo(new PrintWriter(System.out));
summary.printFailuresTo(new PrintWriter(System.err));
System.exit(summary.getTotalFailureCount() > 0 ? 1 : 0);
}
}
EOF
"$JAVAC_BIN" -cp "$FULL_CP:$TEST_BUILD_DIR" -d "$BUILD_DIR" "$BUILD_DIR/TestRunner.java"
JAVA_BIN_EXEC="${JAVA_HOME:+$JAVA_HOME/bin/java}"
JAVA_BIN_EXEC="${JAVA_BIN_EXEC:-java}"
"$JAVA_BIN_EXEC" -cp "$FULL_CP:$TEST_BUILD_DIR:$BUILD_DIR" TestRunner
fi
fi
+3 -3
View File
@@ -2,7 +2,7 @@
This repository includes Gitea Actions workflows in `.gitea/workflows/build.yaml` to automatically:
1. Compile and run the JUnit 5 test suite across the 3 LTS Java versions (Java 11, 17, and 21) via `test_all.sh`.
2. Build standalone executables for each LTS version via `build_all.sh`.
2. Build standalone executables for each LTS version via `setup.sh`.
3. Upload `j3270-java11.jar`, `j3270-java17.jar`, and `j3270-java21.jar` as downloadable artifacts.
4. Report test results and diagnostics per runtime.
@@ -102,8 +102,8 @@ You can verify the entire build and test suite locally at any time without exter
sh ./test_all.sh
# Build executable standalone JAR:
sh ./build_all.sh
./setup.sh
# Run the emulator:
sh ./run.sh
java -jar build/j3270.jar
```
-1
View File
@@ -1,6 +1,5 @@
; j3270 Configuration File
; Load with: java -jar j3270.jar -c j3270.ini
; or: ./run.sh -c j3270.ini
[appearance]
; UI font settings (menus, dialogs, status bar)
@@ -43,12 +43,6 @@ public class Phase27BuildAndRenderTest {
assertTrue(buildGradleContent.contains("version = '1.2.4'"), "build.gradle must define version = '1.2.4'");
assertFalse(buildGradleContent.contains("0.1.0"), "build.gradle must not contain 0.1.0");
// 2. Verify build_all.sh Implementation-Version: 1.2.4
File buildAll = new File(projectRoot, "build_all.sh");
assertTrue(buildAll.exists(), "build_all.sh must exist");
String buildAllContent = Files.readString(buildAll.toPath());
assertTrue(buildAllContent.contains("Implementation-Version: 1.2.4"), "build_all.sh must specify Implementation-Version: 1.2.4");
assertFalse(buildAllContent.contains("Implementation-Version: 0.1.0"), "build_all.sh must not contain 0.1.0");
// 3. Verify setup.ps1 Implementation-Version: 1.2.4
File setupPs1 = new File(projectRoot, "setup.ps1");
@@ -59,13 +59,6 @@ public class Phase30LibraryDistributionTest {
public void testBuildScriptsStandaloneLibraryPackaging() throws Exception {
File projectRoot = locateProjectRoot();
// 1. build_all.sh
File buildAll = new File(projectRoot, "build_all.sh");
assertTrue(buildAll.exists(), "build_all.sh must exist");
String buildAllContent = Files.readString(buildAll.toPath());
assertTrue(buildAllContent.contains("lib3270j.jar"), "build_all.sh must package lib3270j.jar");
assertTrue(buildAllContent.contains("Implementation-Title: lib3270j"), "build_all.sh must set Implementation-Title: lib3270j");
assertTrue(buildAllContent.contains("Implementation-Version: 1.2.4"), "build_all.sh must set Implementation-Version: 1.2.4");
// 2. setup.sh
File setupSh = new File(projectRoot, "setup.sh");
-16
View File
@@ -1,16 +0,0 @@
#!/bin/bash
# Launch j3270 - Java TN3270 Terminal Emulator
# Usage: ./run.sh [host] [port] [model]
# Example: ./run.sh mainframe.example.com 23 4
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
BUILD_DIR="$SCRIPT_DIR/build"
# Build if jar is missing or rebuild requested
if [ ! -f "$BUILD_DIR/j3270.jar" ]; then
"$SCRIPT_DIR/build_all.sh"
fi
exec java -Dapple.laf.useScreenMenuBar=true \
-Dapple.awt.application.name=j3270 \
-jar "$BUILD_DIR/j3270.jar" "$@"
-31
View File
@@ -1,31 +0,0 @@
<#
.SYNOPSIS
j3270 Terminal Emulator - Setup and Build Script (PowerShell Entrypoint)
Forwards execution directly to setup.ps1 with all supplied parameters.
.DESCRIPTION
See setup.ps1 for full implementation, parameter definitions, and documentation.
#>
[CmdletBinding()]
param (
[switch]$Run,
[switch]$Test,
[switch]$Clean,
[switch]$Help,
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$RunArgs
)
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
if (-not $scriptDir) {
$scriptDir = Get-Location
}
$ps1Script = Join-Path $scriptDir "setup.ps1"
if (Test-Path $ps1Script) {
& $ps1Script @PSBoundParameters @RunArgs
} else {
Write-Error "setup.ps1 not found in $scriptDir"
exit 1
}
+3 -5
View File
@@ -411,9 +411,9 @@ log_success "Library JAR: $BUILD_DIR/lib3270j.jar ($LIB_JAR_SIZE)"
log_success "Executable JAR: $BUILD_DIR/j3270.jar ($JAR_SIZE)"
printf "\n%bTo run j3270:%b\n" "$BOLD" "$RESET"
printf " ./run.sh\n"
printf " # Or directly:\n"
printf " %s -jar \"%s/build/j3270.jar\"\n\n" "$JAVA_BIN" "$SCRIPT_DIR"
printf " java -jar \"%s/build/j3270.jar\"\n" "$SCRIPT_DIR"
printf " # Or launch via setup script:\n"
printf " ./setup.sh --run\n\n"
# ------------------------------------------------------------------------------
# 6. Run Tests (if requested)
@@ -422,8 +422,6 @@ if [ "$DO_TEST" -eq 1 ]; then
printf "%b=== Running Unit Tests ===%b\n" "$BOLD" "$RESET"
if [ -x "$SCRIPT_DIR/test_all.sh" ]; then
sh "$SCRIPT_DIR/test_all.sh"
elif [ -x "$SCRIPT_DIR/build_all.sh" ]; then
sh "$SCRIPT_DIR/build_all.sh" test
fi
fi
+1 -1
View File
@@ -7,7 +7,7 @@ cd "$SCRIPT_DIR"
echo "=== Running j3270 Test Suite ==="
# 1. First build the core libraries
sh "$SCRIPT_DIR/build_all.sh"
sh "$SCRIPT_DIR/setup.sh"
# 2. Locate Java toolchain
JAVAC_BIN=""