From 548cabe25151361b8658fc4fb47363302360ae35 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Wed, 12 Nov 2025 01:57:18 +0100 Subject: [PATCH 01/15] Initial migrate JAR creation to maven-jar-plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace manual JAR creation with maven-jar-plugin for cleaner Maven integration for three examples. This eliminates shell-based JAR packaging and follows standard Maven conventions. Changes: * Migration approach (Phase 2): - Use maven-jar-plugin to create module-specific JARs - JARs created in target/ directory (not mlib/) - Simplified compile.sh: just 'mvn clean package' - Updated run.sh: use '--module-path target' - Removed mlib/ from .gitignore and clean.sh * Examples migrated: - example_requires_exports (3 modules) - example_annotations (3 modules) - example_hiddenmain (1 module) * Documentation: - Added Phase 2 approach to maven-4-migration.md - Documented maven-jar-plugin configuration pattern - Added migration guide from Phase 1 to Phase 2 - Added step to update documentation (remove mlib references) - Updated directory layout to clarify Phase 1 vs Phase 2 - Listed reference examples for both phases Benefits: - Simpler build scripts (no manual JAR loops) - Standard Maven artifact location (target/) - Easier to maintain (more declarative, less scripting) - JAR naming follows Maven conventions All migrated examples pass golden master verification. πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Introduced in the course of support-and-care/maven-support-and-care#137 --- .claude/transformations/maven-4-migration.md | 276 ++++++++++++++++-- .../example_annotations/m4/.gitignore | 1 - .../example_annotations/m4/clean.sh | 1 - .../example_annotations/m4/compile.sh | 18 +- .../example_annotations/m4/pom.xml | 46 +++ jigsaw-examples/example_annotations/m4/run.sh | 3 +- .../example_hiddenmain/m4/.gitignore | 1 - .../example_hiddenmain/m4/clean.sh | 1 - .../example_hiddenmain/m4/compile.sh | 18 +- jigsaw-examples/example_hiddenmain/m4/pom.xml | 24 ++ jigsaw-examples/example_hiddenmain/m4/run.sh | 5 +- .../example_requires_exports/m4/.gitignore | 1 - .../example_requires_exports/m4/clean.sh | 1 - .../example_requires_exports/m4/compile.sh | 18 +- .../example_requires_exports/m4/pom.xml | 46 +++ .../example_requires_exports/m4/run.sh | 3 +- 16 files changed, 388 insertions(+), 75 deletions(-) diff --git a/.claude/transformations/maven-4-migration.md b/.claude/transformations/maven-4-migration.md index ad7baa5b..435f9f05 100644 --- a/.claude/transformations/maven-4-migration.md +++ b/.claude/transformations/maven-4-migration.md @@ -85,13 +85,13 @@ example_foo/ β”‚ β”‚ └── modb/ β”‚ β”‚ └── main/ β”‚ β”‚ └── java -> ../../../../src/modb # Symlink to module source -β”‚ β”œβ”€β”€ mlib/ # Module JARs (separate from ../mlib) +β”‚ β”œβ”€β”€ mlib/ # Module JARs (Phase 1 only - not used in Phase 2) β”‚ β”œβ”€β”€ run-result/ # Runtime output (for verification) -β”‚ β”œβ”€β”€ target/ # Maven build output -β”‚ β”œβ”€β”€ .gitignore # Ignore build artifacts (target/, mlib/, run-result/) +β”‚ β”œβ”€β”€ target/ # Maven build output (Phase 2: also contains JARs) +β”‚ β”œβ”€β”€ .gitignore # Ignore build artifacts (Phase 1: target/, mlib/, run-result/; Phase 2: target/, run-result/) β”‚ β”œβ”€β”€ clean.sh # Clean m4 artifacts -β”‚ β”œβ”€β”€ compile.sh # Maven compile + jar packaging -β”‚ β”œβ”€β”€ run.sh # Execution (uses m4/mlib) +β”‚ β”œβ”€β”€ compile.sh # Phase 1: Maven compile + jar; Phase 2: Maven package +β”‚ β”œβ”€β”€ run.sh # Phase 1: uses mlib; Phase 2: uses target β”‚ β”œβ”€β”€ verify.sh # Golden master verification β”‚ └── javadoc.sh # Maven javadoc wrapper (optional) β”œβ”€β”€ m3/ # (Future) Maven 3 alternative approach @@ -384,16 +384,106 @@ popd >/dev/null 2>&1 - Creates JARs directly to `mlib/` (not `../mlib/`) for complete separation - Uses same JAR creation pattern as original compile.sh -**Phase 2: Full Maven (Future)** +**Phase 2: Maven JAR Plugin (Current Best Practice)** -Once Maven plugins prove compatible with JPMS: +Replace manual JAR creation with maven-jar-plugin for cleaner Maven integration: ```bash #!/usr/bin/env bash set -eu -o pipefail -echo "=== Maven 4 Compile (Full Maven) ===" +# shellcheck source=../../env.sh +source ../../env.sh + +# Ensure we're using Maven 4 +if [ -z "${M4_HOME:-}" ]; then + echo "ERROR: M4_HOME is not set. Please configure it in .envrc or env.sh" + exit 1 +fi + +# Maven 4 requires Java 17+ to run +if [ -n "${JAVA17_HOME:-}" ]; then + export JAVA_HOME="${JAVA17_HOME}" +fi + +# Add Maven 4 to PATH +export PATH="${M4_HOME}/bin:${PATH}" + +echo "mvn --version" +mvn --version echo + +echo "mvn clean package" +echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(JARs are created by maven-jar-plugin in target/ directory)" +mvn clean package +``` + +**Benefits**: +- Eliminates manual JAR creation loop +- JARs created directly in `target/` directory by Maven +- Simpler script - just `mvn clean package` +- No need for `mlib/` directory +- Follows standard Maven conventions + +**POM Configuration**: + +Add maven-jar-plugin to create module-specific JARs: + +```xml + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + modb + package + + jar + + + ${project.build.outputDirectory}/modb + modb + + + + + +``` + +**JAR Naming Convention**: +- Pattern: `${artifactId}-${version}-${classifier}.jar` +- Example: `example-requires-exports-m4-1.0-SNAPSHOT-modmain.jar` +- Location: `target/` directory +- Java's `--module-path target` automatically finds these JARs + +**Phase 3: Full Maven (Future)** + +Once all examples migrated to maven-jar-plugin, scripts could be further simplified: + +```bash +#!/usr/bin/env bash +set -eu -o pipefail + +echo "=== Maven 4 Build ===" mvn --version echo mvn clean package @@ -404,6 +494,8 @@ echo "βœ… Build complete" Execute the example using artifacts from Maven build (stays close to original run.sh): +**Phase 1: Using mlib/ directory (Hybrid Approach)** + ```bash #!/usr/bin/env bash set -eu -o pipefail @@ -424,9 +516,33 @@ mkdir -p run-result "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho ``` +**Phase 2: Using target/ directory (Maven JAR Plugin)** + +```bash +#!/usr/bin/env bash +set -eu -o pipefail + +# shellcheck source=../../env.sh +source ../../env.sh + +# Show Java version for user information +echo "Using Java version:" +"${JAVA_HOME}/bin/java" -version +echo + +# Create run-result directory if it doesn't exist +mkdir -p run-result + +# Run the Java code, save output to run-result/run.txt, and display with highlighting +# JARs are now in target/ (created by maven-jar-plugin) +# shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho +``` + **Important**: - Copy structure from original `run.sh` to stay close to original -- Use `mlib` (not `../mlib`) since artifacts are in m4/mlib +- **Phase 1**: Use `mlib` (not `../mlib`) since artifacts are in m4/mlib +- **Phase 2**: Use `target` since JARs are created directly in target/ by maven-jar-plugin - Preserve any special JVM flags from original (--add-exports, --add-reads, --add-modules, etc.) - No M4_HOME needed here - only Maven runtime uses it - Output to `run-result/run.txt` for golden master verification @@ -504,6 +620,8 @@ fi Clean all m4 build artifacts: +**Phase 1: Hybrid Approach (with mlib/)** + ```bash #!/usr/bin/env bash rm -rf target @@ -511,7 +629,17 @@ rm -rf mlib rm -rf run-result ``` -**Note**: Simple cleanup matching original pattern - removes Maven output, JARs, and runtime results +**Phase 2: Maven JAR Plugin (no mlib/)** + +```bash +#!/usr/bin/env bash +rm -rf target +rm -rf run-result +``` + +**Note**: +- **Phase 1**: Removes Maven output (target/), manually created JARs (mlib/), and runtime results (run-result/) +- **Phase 2**: Simpler - only removes Maven output (target/) and runtime results (run-result/), no mlib/ needed ### javadoc.sh - Documentation Wrapper (Optional) @@ -564,12 +692,23 @@ echo "βœ… Javadoc generated in target/site/apidocs" ``` 5. **Create .gitignore**: + + **Phase 1: Hybrid Approach** ```bash # Create .gitignore to exclude build artifacts cat > .gitignore << 'EOF' target/ mlib/ run-result/ +EOF + ``` + + **Phase 2: Maven JAR Plugin** + ```bash + # Create .gitignore to exclude build artifacts (no mlib needed) + cat > .gitignore << 'EOF' +target/ +run-result/ EOF ``` @@ -579,32 +718,47 @@ EOF - Declare each module with matching `` name and `` path - Add dependencies if needed - Configure compiler plugin for JPMS + - **Phase 2**: Add maven-jar-plugin configuration (see Phase 2 compile.sh section above) - Adjust release version per example requirements - Include test sources declaration if example has tests -6. **Create compile.sh**: +7. **Create compile.sh**: + + **Phase 1: Hybrid Approach** - Follow hybrid approach (Maven compile + traditional jar) - Inspect original compile.sh for jar commands - Adapt paths to Maven's target/ structure - - Copy JARs to ../mlib for compatibility + - Create JARs in mlib/ + + **Phase 2: Maven JAR Plugin** (Recommended) + - Use `mvn clean package` instead of `mvn clean compile` + - Remove manual JAR creation loop + - JARs created automatically in target/ by maven-jar-plugin + +8. **Create run.sh**: -7. **Create run.sh**: + **Phase 1: Using mlib/** - Copy module path configuration from original - - Adjust paths to use ../mlib (populated by compile.sh) + - Adjust paths to use `mlib` (populated by compile.sh) - Preserve any special JVM flags -8. **Create verify.sh**: + **Phase 2: Using target/** + - Change `--module-path mlib` to `--module-path target` + - JARs automatically found in target/ directory + - Preserve any special JVM flags + +9. **Create verify.sh**: - Integrate with golden master framework - Reuse existing expected-result.txt - Follow verification script pattern above -9. **Test Migration**: +10. **Test Migration**: ```bash cd m4 ./verify.sh ``` -10. **Update Example README**: Add both Maven 4 output section and Maven 4 Migration section to the example's README.adoc: +11. **Update Example README**: Add both Maven 4 output section and Maven 4 Migration section to the example's README.adoc: a. Add the Maven 4 output section (if not already present): ```adoc @@ -650,7 +804,78 @@ EOF This documents the migration completion and shows that Maven 4 produces equivalent output. For examples with special requirements, it provides valuable documentation for similar migrations. -11. **Document Issues**: Note any JPMS/Maven plugin compatibility issues for future resolution +12. **Document Issues**: Note any JPMS/Maven plugin compatibility issues for future resolution + +### Migrating from Phase 1 (Hybrid) to Phase 2 (Maven JAR Plugin) + +To migrate an existing Phase 1 example to Phase 2: + +1. **Update pom.xml**: + Add maven-jar-plugin configuration with one execution per module: + ```xml + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + default-jar + none + + + + modmain + package + jar + + ${project.build.outputDirectory}/modmain + modmain + + + + + ``` + +2. **Update compile.sh**: + Replace: + ```bash + mvn clean compile + # ... JAR creation loop ... + ``` + With: + ```bash + mvn clean package + ``` + Remove the `mkdir -p mlib` and the entire JAR creation loop. + +3. **Update run*.sh scripts**: + Change all occurrences of `--module-path mlib` to `--module-path target` + +4. **Update .gitignore**: + Remove the `mlib/` line + +5. **Update clean.sh**: + Remove the `rm -rf mlib` line + +6. **Update documentation**: + Check the example's README.adoc for any `mlib` references and update them: + ```bash + grep -n "mlib" ../README.adoc + ``` + Replace `mlib` references with `target` where appropriate. + Note: Most examples reference `mlib` in their Maven 4 Migration sections if they document directory structure. + +7. **Test the migration**: + ```bash + ./clean.sh + ./verify.sh + ``` + +8. **Verify JARs are in target/**: + ```bash + ls -la target/*.jar + ``` + Should show files like `example-foo-m4-1.0-SNAPSHOT-modmain.jar` ### Example Selection Criteria @@ -744,6 +969,17 @@ A migration is considered successful when: ## Reference Examples -Once first examples are migrated, list them here as references: +### Phase 2 Migrations (Maven JAR Plugin) + +Examples fully migrated to maven-jar-plugin (no manual JAR creation): + +- **example_requires_exports** - 3 modules (modmain, modb, modc) - Standard multi-module example +- **example_annotations** - 3 modules (mod.annotations, modb, modmain) - Demonstrates module with dot in name +- **example_hiddenmain** - 1 module (modmain) - Single module example with multiple main classes + +### Phase 1 Migrations (Hybrid Approach) + +Examples using Maven compile + manual JAR creation (33 examples total): -- (TBD - will be populated as migrations complete) \ No newline at end of file +- See `git log` for full list of Phase 1 migrations +- These examples are candidates for Phase 2 migration \ No newline at end of file diff --git a/jigsaw-examples/example_annotations/m4/.gitignore b/jigsaw-examples/example_annotations/m4/.gitignore index 25275013..52aee332 100644 --- a/jigsaw-examples/example_annotations/m4/.gitignore +++ b/jigsaw-examples/example_annotations/m4/.gitignore @@ -1,3 +1,2 @@ target/ -mlib/ run-result/ diff --git a/jigsaw-examples/example_annotations/m4/clean.sh b/jigsaw-examples/example_annotations/m4/clean.sh index 94f380eb..d7faaade 100755 --- a/jigsaw-examples/example_annotations/m4/clean.sh +++ b/jigsaw-examples/example_annotations/m4/clean.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_annotations/m4/compile.sh b/jigsaw-examples/example_annotations/m4/compile.sh index f872668c..49b39320 100755 --- a/jigsaw-examples/example_annotations/m4/compile.sh +++ b/jigsaw-examples/example_annotations/m4/compile.sh @@ -20,23 +20,11 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib - echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +echo "(JARs are created by maven-jar-plugin in target/ directory)" +mvn clean package diff --git a/jigsaw-examples/example_annotations/m4/pom.xml b/jigsaw-examples/example_annotations/m4/pom.xml index 8e7f9f1a..099555e2 100644 --- a/jigsaw-examples/example_annotations/m4/pom.xml +++ b/jigsaw-examples/example_annotations/m4/pom.xml @@ -36,6 +36,52 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + mod.annotations + package + + jar + + + ${project.build.outputDirectory}/mod.annotations + mod.annotations + + + + modb + package + + jar + + + ${project.build.outputDirectory}/modb + modb + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_annotations/m4/run.sh b/jigsaw-examples/example_annotations/m4/run.sh index f17cda9b..8b288067 100755 --- a/jigsaw-examples/example_annotations/m4/run.sh +++ b/jigsaw-examples/example_annotations/m4/run.sh @@ -13,5 +13,6 @@ echo mkdir -p run-result # Run the Java code, save output to run-result/run.txt, and display with highlighting +# JARs are now in target/ (created by maven-jar-plugin) # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_hiddenmain/m4/.gitignore b/jigsaw-examples/example_hiddenmain/m4/.gitignore index 25275013..52aee332 100644 --- a/jigsaw-examples/example_hiddenmain/m4/.gitignore +++ b/jigsaw-examples/example_hiddenmain/m4/.gitignore @@ -1,3 +1,2 @@ target/ -mlib/ run-result/ diff --git a/jigsaw-examples/example_hiddenmain/m4/clean.sh b/jigsaw-examples/example_hiddenmain/m4/clean.sh index 94f380eb..d7faaade 100755 --- a/jigsaw-examples/example_hiddenmain/m4/clean.sh +++ b/jigsaw-examples/example_hiddenmain/m4/clean.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_hiddenmain/m4/compile.sh b/jigsaw-examples/example_hiddenmain/m4/compile.sh index f872668c..49b39320 100755 --- a/jigsaw-examples/example_hiddenmain/m4/compile.sh +++ b/jigsaw-examples/example_hiddenmain/m4/compile.sh @@ -20,23 +20,11 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib - echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +echo "(JARs are created by maven-jar-plugin in target/ directory)" +mvn clean package diff --git a/jigsaw-examples/example_hiddenmain/m4/pom.xml b/jigsaw-examples/example_hiddenmain/m4/pom.xml index d21ab1e1..60d61c5e 100644 --- a/jigsaw-examples/example_hiddenmain/m4/pom.xml +++ b/jigsaw-examples/example_hiddenmain/m4/pom.xml @@ -28,6 +28,30 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_hiddenmain/m4/run.sh b/jigsaw-examples/example_hiddenmain/m4/run.sh index 8eeb5611..9afa043b 100755 --- a/jigsaw-examples/example_hiddenmain/m4/run.sh +++ b/jigsaw-examples/example_hiddenmain/m4/run.sh @@ -13,9 +13,10 @@ echo mkdir -p run-result # Run the first Java command, save output to run-result/run.txt, and display with highlighting +# JARs are now in target/ (created by maven-jar-plugin) # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho # Run the second Java command, append output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmain/pkgmainhidden.HiddenMain 2>&1 | normalize | tee -a run-result/run.txt | myecho +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmainhidden.HiddenMain 2>&1 | normalize | tee -a run-result/run.txt | myecho diff --git a/jigsaw-examples/example_requires_exports/m4/.gitignore b/jigsaw-examples/example_requires_exports/m4/.gitignore index 25275013..52aee332 100644 --- a/jigsaw-examples/example_requires_exports/m4/.gitignore +++ b/jigsaw-examples/example_requires_exports/m4/.gitignore @@ -1,3 +1,2 @@ target/ -mlib/ run-result/ diff --git a/jigsaw-examples/example_requires_exports/m4/clean.sh b/jigsaw-examples/example_requires_exports/m4/clean.sh index 94f380eb..d7faaade 100755 --- a/jigsaw-examples/example_requires_exports/m4/clean.sh +++ b/jigsaw-examples/example_requires_exports/m4/clean.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_requires_exports/m4/compile.sh b/jigsaw-examples/example_requires_exports/m4/compile.sh index f872668c..49b39320 100755 --- a/jigsaw-examples/example_requires_exports/m4/compile.sh +++ b/jigsaw-examples/example_requires_exports/m4/compile.sh @@ -20,23 +20,11 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib - echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +echo "(JARs are created by maven-jar-plugin in target/ directory)" +mvn clean package diff --git a/jigsaw-examples/example_requires_exports/m4/pom.xml b/jigsaw-examples/example_requires_exports/m4/pom.xml index 84327bf1..81b3c19b 100644 --- a/jigsaw-examples/example_requires_exports/m4/pom.xml +++ b/jigsaw-examples/example_requires_exports/m4/pom.xml @@ -36,6 +36,52 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + modb + package + + jar + + + ${project.build.outputDirectory}/modb + modb + + + + modc + package + + jar + + + ${project.build.outputDirectory}/modc + modc + + + + diff --git a/jigsaw-examples/example_requires_exports/m4/run.sh b/jigsaw-examples/example_requires_exports/m4/run.sh index f17cda9b..8b288067 100755 --- a/jigsaw-examples/example_requires_exports/m4/run.sh +++ b/jigsaw-examples/example_requires_exports/m4/run.sh @@ -13,5 +13,6 @@ echo mkdir -p run-result # Run the Java code, save output to run-result/run.txt, and display with highlighting +# JARs are now in target/ (created by maven-jar-plugin) # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho From 1084ec4b0c459a1da236e2d545dc66208a3b5c71 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Wed, 12 Nov 2025 10:09:57 +0100 Subject: [PATCH 02/15] Migrate jerrymouse and dependencies to Phase 2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Migrate three examples to use maven-jar-plugin (Phase 2): - example_requires_exports-to (4 modules) - example_derived_private-package-protected (2 modules) - example_jerrymouse (1 module) These migrations were required because example_jerrymouse depends on the other two examples and copies their JARs at runtime. Changes: - Replace manual JAR creation with maven-jar-plugin in pom.xml - Update compile.sh to use 'mvn clean package' instead of 'compile' - Update run.sh scripts to use target/ instead of mlib/ for module-path - Remove mlib/ from .gitignore and clean.sh Jerrymouse-specific changes: - Fix apps_copyallexamples2appdir.sh to copy from target/ directory - Fix shellcheck warning: use compgen instead of -e with glob pattern (compgen -G tests if glob matches files, unlike -e which fails with globs) - Update README.adoc to document Phase 2 JAR location (target/) All examples verified with golden master tests. πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Introduced in the course of support-and-care/maven-support-and-care#137 --- .../m4/.gitignore | 1 - .../m4/clean.sh | 1 - .../m4/compile.sh | 19 ++----- .../m4/pom.xml | 35 ++++++++++++ .../m4/run.sh | 3 +- .../example_jerrymouse/README.adoc | 2 +- .../example_jerrymouse/m4/.gitignore | 1 - .../m4/apps_copyallexamples2appdir.sh | 12 ++-- .../example_jerrymouse/m4/clean.sh | 1 - .../example_jerrymouse/m4/compile.sh | 18 ++---- jigsaw-examples/example_jerrymouse/m4/pom.xml | 24 ++++++++ jigsaw-examples/example_jerrymouse/m4/run.sh | 3 +- .../example_requires_exports-to/m4/.gitignore | 1 - .../example_requires_exports-to/m4/clean.sh | 1 - .../example_requires_exports-to/m4/compile.sh | 19 ++----- .../example_requires_exports-to/m4/pom.xml | 57 +++++++++++++++++++ .../example_requires_exports-to/m4/run.sh | 3 +- 17 files changed, 142 insertions(+), 59 deletions(-) diff --git a/jigsaw-examples/example_derived_private-package-protected/m4/.gitignore b/jigsaw-examples/example_derived_private-package-protected/m4/.gitignore index 25275013..52aee332 100644 --- a/jigsaw-examples/example_derived_private-package-protected/m4/.gitignore +++ b/jigsaw-examples/example_derived_private-package-protected/m4/.gitignore @@ -1,3 +1,2 @@ target/ -mlib/ run-result/ diff --git a/jigsaw-examples/example_derived_private-package-protected/m4/clean.sh b/jigsaw-examples/example_derived_private-package-protected/m4/clean.sh index 94f380eb..d7faaade 100755 --- a/jigsaw-examples/example_derived_private-package-protected/m4/clean.sh +++ b/jigsaw-examples/example_derived_private-package-protected/m4/clean.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_derived_private-package-protected/m4/compile.sh b/jigsaw-examples/example_derived_private-package-protected/m4/compile.sh index f872668c..62fbc949 100755 --- a/jigsaw-examples/example_derived_private-package-protected/m4/compile.sh +++ b/jigsaw-examples/example_derived_private-package-protected/m4/compile.sh @@ -20,23 +20,12 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib echo "mvn --version" mvn --version echo -echo "mvn clean compile" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +echo "mvn clean package" +echo "(JARs are created by maven-jar-plugin in target/ directory)"echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +mvn clean package + diff --git a/jigsaw-examples/example_derived_private-package-protected/m4/pom.xml b/jigsaw-examples/example_derived_private-package-protected/m4/pom.xml index 123940a0..3bb1fe25 100644 --- a/jigsaw-examples/example_derived_private-package-protected/m4/pom.xml +++ b/jigsaw-examples/example_derived_private-package-protected/m4/pom.xml @@ -32,6 +32,41 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modb + package + + jar + + + ${project.build.outputDirectory}/modb + modb + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_derived_private-package-protected/m4/run.sh b/jigsaw-examples/example_derived_private-package-protected/m4/run.sh index f17cda9b..d972ba45 100755 --- a/jigsaw-examples/example_derived_private-package-protected/m4/run.sh +++ b/jigsaw-examples/example_derived_private-package-protected/m4/run.sh @@ -14,4 +14,5 @@ mkdir -p run-result # Run the Java code, save output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho +# JARs are now in target/ (created by maven-jar-plugin) +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_jerrymouse/README.adoc b/jigsaw-examples/example_jerrymouse/README.adoc index 78adf257..700d7b88 100644 --- a/jigsaw-examples/example_jerrymouse/README.adoc +++ b/jigsaw-examples/example_jerrymouse/README.adoc @@ -121,7 +121,7 @@ Created `m4/apps_copyallexamples2appdir.sh` script. + * Copies Maven 4 versions of example applications from whitelisted examples * Builds M4 versions of dependencies if they don't exist yet -* Sources from `../example_*/m4/mlib/` instead of `../example_*/mlib/` +* Sources from `../example_*/m4/target/` (Phase 2: JARs created by maven-jar-plugin) * Creates `app.json` descriptors for each application Runtime Configuration:: diff --git a/jigsaw-examples/example_jerrymouse/m4/.gitignore b/jigsaw-examples/example_jerrymouse/m4/.gitignore index 3cd36bb3..d893b34a 100644 --- a/jigsaw-examples/example_jerrymouse/m4/.gitignore +++ b/jigsaw-examples/example_jerrymouse/m4/.gitignore @@ -1,5 +1,4 @@ target/ -mlib/ amlib/ apps/ run-result/ \ No newline at end of file diff --git a/jigsaw-examples/example_jerrymouse/m4/apps_copyallexamples2appdir.sh b/jigsaw-examples/example_jerrymouse/m4/apps_copyallexamples2appdir.sh index b24b2996..de103cbb 100755 --- a/jigsaw-examples/example_jerrymouse/m4/apps_copyallexamples2appdir.sh +++ b/jigsaw-examples/example_jerrymouse/m4/apps_copyallexamples2appdir.sh @@ -3,8 +3,8 @@ set -eu -o pipefail # -# Copy all apps from our app whitelist (Maven 4 versions) -# This is the Maven 4 variant that copies from ../example_*/m4/mlib/ directories +# Copy all apps from our app whitelist (Maven 4 versions - Phase 2) +# This is the Maven 4 variant that copies from ../example_*/m4/target/ directories # # source the list of apps which we want to run in the Jerry Mouse app server @@ -17,14 +17,15 @@ do MODDIR="${dir%*/}" # if the example really is "worth" to be copied, i.e. not empty... - if [ ! -e "../../${MODDIR}/m4/mlib/modmain.jar" ]; then + # Check for JAR files in target/ directory (Phase 2 migration) + if ! compgen -G "../../${MODDIR}/m4/target"/*.jar > /dev/null; then echo "Building Maven 4 version of ${MODDIR}..." (cd "../../${MODDIR}/m4" && ./compile.sh) fi pushd "../../${MODDIR}/m4" > /dev/null 2>&1 echo "###################################################################################################################################" - echo "Copy ${MODDIR}/m4/mlib/*.jar to ${APPSERVER_TARGET}/${MODDIR} ..." + echo "Copy ${MODDIR}/m4/target/*.jar to ${APPSERVER_TARGET}/${MODDIR}/mlib ..." mkdir -p "${APPSERVER_TARGET}"/"${MODDIR}" pushd "${APPSERVER_TARGET}"/"${MODDIR}" > /dev/null 2>&1 @@ -40,7 +41,8 @@ EOFAPPJSON mkdir -p "${APPSERVER_TARGET}"/"${MODDIR}/mlib" popd >/dev/null 2>&1 - pushd mlib > /dev/null 2>&1 + # Copy JARs from target/ directory (Phase 2 migration) + pushd target > /dev/null 2>&1 cp -R ./*.jar "${APPSERVER_TARGET}"/"${MODDIR}/mlib" popd >/dev/null 2>&1 diff --git a/jigsaw-examples/example_jerrymouse/m4/clean.sh b/jigsaw-examples/example_jerrymouse/m4/clean.sh index 756a7e72..fd9dedc5 100755 --- a/jigsaw-examples/example_jerrymouse/m4/clean.sh +++ b/jigsaw-examples/example_jerrymouse/m4/clean.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf amlib rm -rf apps rm -rf run-result diff --git a/jigsaw-examples/example_jerrymouse/m4/compile.sh b/jigsaw-examples/example_jerrymouse/m4/compile.sh index f872668c..19bfe757 100755 --- a/jigsaw-examples/example_jerrymouse/m4/compile.sh +++ b/jigsaw-examples/example_jerrymouse/m4/compile.sh @@ -20,23 +20,13 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" +echo "(JARs are created by maven-jar-plugin in target/ directory)" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +mvn clean package + diff --git a/jigsaw-examples/example_jerrymouse/m4/pom.xml b/jigsaw-examples/example_jerrymouse/m4/pom.xml index b12578f5..495329bc 100644 --- a/jigsaw-examples/example_jerrymouse/m4/pom.xml +++ b/jigsaw-examples/example_jerrymouse/m4/pom.xml @@ -62,6 +62,30 @@ + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modstarter + package + + jar + + + ${project.build.outputDirectory}/modstarter + modstarter + + + + diff --git a/jigsaw-examples/example_jerrymouse/m4/run.sh b/jigsaw-examples/example_jerrymouse/m4/run.sh index 459b69f3..2252b1fa 100755 --- a/jigsaw-examples/example_jerrymouse/m4/run.sh +++ b/jigsaw-examples/example_jerrymouse/m4/run.sh @@ -16,5 +16,6 @@ mkdir -p run-result # Run the app server (modstarter/pkgstarter.Starter) echo "" +# JARs are now in target/ (created by maven-jar-plugin) # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path "mlib${PATH_SEPARATOR}../amlib" --module modstarter/pkgstarter.Starter . run-result --sync 2>&1 | normalize | tee run-result/run.txt | myecho +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path "target${PATH_SEPARATOR}../amlib" --module modstarter/pkgstarter.Starter . run-result --sync 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_requires_exports-to/m4/.gitignore b/jigsaw-examples/example_requires_exports-to/m4/.gitignore index 25275013..52aee332 100644 --- a/jigsaw-examples/example_requires_exports-to/m4/.gitignore +++ b/jigsaw-examples/example_requires_exports-to/m4/.gitignore @@ -1,3 +1,2 @@ target/ -mlib/ run-result/ diff --git a/jigsaw-examples/example_requires_exports-to/m4/clean.sh b/jigsaw-examples/example_requires_exports-to/m4/clean.sh index 94f380eb..d7faaade 100755 --- a/jigsaw-examples/example_requires_exports-to/m4/clean.sh +++ b/jigsaw-examples/example_requires_exports-to/m4/clean.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_requires_exports-to/m4/compile.sh b/jigsaw-examples/example_requires_exports-to/m4/compile.sh index f872668c..62fbc949 100755 --- a/jigsaw-examples/example_requires_exports-to/m4/compile.sh +++ b/jigsaw-examples/example_requires_exports-to/m4/compile.sh @@ -20,23 +20,12 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib echo "mvn --version" mvn --version echo -echo "mvn clean compile" -echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +echo "mvn clean package" +echo "(JARs are created by maven-jar-plugin in target/ directory)"echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +mvn clean package + diff --git a/jigsaw-examples/example_requires_exports-to/m4/pom.xml b/jigsaw-examples/example_requires_exports-to/m4/pom.xml index 44cfbf44..eb99eb99 100644 --- a/jigsaw-examples/example_requires_exports-to/m4/pom.xml +++ b/jigsaw-examples/example_requires_exports-to/m4/pom.xml @@ -40,6 +40,63 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modb1 + package + + jar + + + ${project.build.outputDirectory}/modb1 + modb1 + + + + modb2 + package + + jar + + + ${project.build.outputDirectory}/modb2 + modb2 + + + + modc + package + + jar + + + ${project.build.outputDirectory}/modc + modc + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_requires_exports-to/m4/run.sh b/jigsaw-examples/example_requires_exports-to/m4/run.sh index f17cda9b..d972ba45 100755 --- a/jigsaw-examples/example_requires_exports-to/m4/run.sh +++ b/jigsaw-examples/example_requires_exports-to/m4/run.sh @@ -14,4 +14,5 @@ mkdir -p run-result # Run the Java code, save output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho +# JARs are now in target/ (created by maven-jar-plugin) +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho From e45d3d818bea692efb4cd47f951c4a356639d51f Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Thu, 13 Nov 2025 12:19:52 +0100 Subject: [PATCH 03/15] Complete Maven Phase 2 migration for JAR creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Migrate 32 examples to use maven-jar-plugin for JAR creation instead of manual jar commands in compile.sh scripts. Key changes: Phase 2 JAR Creation (26 examples with pom.xml updates): - Add maven-jar-plugin configuration with classifier-based executions - Skip default JAR creation, create module-specific JARs with classifiers - Results in JARs like: ${artifactId}-${version}-${classifier}.jar - Remove manual jar commands from compile.sh scripts - Update run.sh scripts to use --module-path target - Remove mlib/ directory cleanup from clean.sh scripts - Remove mlib/ from .gitignore (JARs now in target/ only) Special Cases - Dynamic Module Loading (4 examples): Add committed mlibβ†’target symlinks for compatibility with ModuleLayer API: - example_patch/m4/mlib - example_layer-hierarchy/m4/mlib - example_layer-modules-grouped-in-hierarchy/m4/mlib - example_layer-modules-module-resolution/m4/mlib These symlinks enable: - Running from IDE without executing compile.sh - Compatibility with hardcoded "mlib" paths in shared source code - Consistent approach with source symlinks Special Case - jlink Compatibility (1 example): - example_resolved-modules uses JAR copying to mlib/ for simple names - Necessary because jlink outputs actual JAR filenames in verbose mode - Maintains golden master compatibility Documentation Updates: - Update READMEs for examples with special handling - Document symlink approach and rationale - Document JAR copying approach for jlink - Clarify that symlinks are committed, not dynamically created - Remove now-redundant comments about JAR locations Minor Fixes: - Standardize approach across all migrated examples - Clean up obsolete comments in compile.sh and run.sh scripts - Align .gitignore patterns with new structure This completes the Maven Phase 2 migration, standardizing JAR creation via Maven plugins while handling edge cases (dynamic loading, jlink) with appropriate solutions (symlinks, JAR copying). πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Introduced in the course of support-and-care/maven-support-and-care#137 --- .../example_addExports_manifest/m4/.gitignore | 1 - .../example_addExports_manifest/m4/clean.sh | 1 - .../example_addExports_manifest/m4/compile.sh | 24 +-- .../example_addExports_manifest/m4/pom.xml | 38 +++++ .../example_addExports_manifest/m4/run.sh | 6 +- .../example_addReads_addExports/m4/.gitignore | 1 - .../example_addReads_addExports/m4/clean.sh | 1 - .../example_addReads_addExports/m4/compile.sh | 17 +- .../example_addReads_addExports/m4/pom.xml | 46 ++++++ .../example_addReads_addExports/m4/run.sh | 2 +- .../m4/.gitignore | 1 - .../m4/clean.sh | 1 - .../m4/compile.sh | 17 +- .../m4/pom.xml | 35 +++++ .../m4/run.sh | 2 +- .../example_annotations/m4/compile.sh | 1 - jigsaw-examples/example_annotations/m4/run.sh | 1 - .../m4/.gitignore | 1 - .../m4/clean.sh | 1 - .../m4/compile.sh | 17 +- .../m4/pom.xml | 24 +++ .../m4/run.sh | 6 +- .../m4/compile.sh | 2 +- .../m4/run.sh | 1 - .../example_exceptions/m4/.gitignore | 1 - .../example_exceptions/m4/clean.sh | 1 - .../example_exceptions/m4/compile.sh | 17 +- jigsaw-examples/example_exceptions/m4/pom.xml | 35 +++++ jigsaw-examples/example_exceptions/m4/run.sh | 2 +- .../example_hiddenmain/m4/compile.sh | 1 - jigsaw-examples/example_hiddenmain/m4/run.sh | 1 - .../example_interface-callback/m4/.gitignore | 1 - .../example_interface-callback/m4/clean.sh | 1 - .../example_interface-callback/m4/compile.sh | 17 +- .../example_interface-callback/m4/pom.xml | 46 ++++++ .../example_interface-callback/m4/run.sh | 2 +- .../example_jerrymouse/README.adoc | 2 +- .../example_jerrymouse/m4/compile.sh | 1 - jigsaw-examples/example_jerrymouse/m4/run.sh | 1 - .../example_layer-hierarchy/README.adoc | 44 +++++- .../example_layer-hierarchy/m4/.gitignore | 1 - .../example_layer-hierarchy/m4/clean.sh | 1 - .../example_layer-hierarchy/m4/compile.sh | 31 ++-- .../example_layer-hierarchy/m4/mlib | 1 + .../example_layer-hierarchy/m4/pom.xml | 145 ++++++++++++++++++ .../example_layer-hierarchy/m4/run.sh | 2 +- .../m4/clean.sh | 1 - .../m4/compile.sh | 15 +- .../m4/pom.xml | 57 +++++++ .../m4/run.sh | 2 +- .../README.adoc | 40 +++++ .../m4/clean.sh | 1 - .../m4/compile.sh | 36 ++--- .../m4/mlib | 1 + .../m4/pom.xml | 35 +++++ .../m4/run.sh | 2 +- .../README.adoc | 30 +++- .../m4/clean.sh | 1 - .../m4/compile.sh | 50 ++---- .../m4/mlib | 1 + .../m4/pom.xml | 79 ++++++++++ .../m4/run.sh | 2 +- .../example_naming-modules/m4/clean.sh | 1 - .../example_naming-modules/m4/compile.sh | 17 +- .../example_naming-modules/m4/pom.xml | 81 +++++++++- .../example_naming-modules/m4/run.sh | 11 +- jigsaw-examples/example_patch/README.adoc | 35 ++++- jigsaw-examples/example_patch/m4/.gitignore | 4 - jigsaw-examples/example_patch/m4/clean.sh | 1 - jigsaw-examples/example_patch/m4/compile.sh | 20 +-- jigsaw-examples/example_patch/m4/mlib | 1 + jigsaw-examples/example_patch/m4/pom.xml | 35 +++++ .../example_reflection/m4/.gitignore | 1 - .../example_reflection/m4/clean.sh | 1 - .../example_reflection/m4/compile.sh | 17 +- jigsaw-examples/example_reflection/m4/pom.xml | 35 +++++ jigsaw-examples/example_reflection/m4/run.sh | 2 +- .../example_requires-static/m4/.gitignore | 1 - .../example_requires-static/m4/clean.sh | 1 - .../example_requires-static/m4/compile.sh | 17 +- .../example_requires-static/m4/pom.xml | 46 ++++++ .../example_requires-static/m4/run.sh | 2 +- .../example_requires_exports-to/m4/compile.sh | 2 +- .../example_requires_exports-to/m4/run.sh | 1 - .../example_requires_exports/m4/compile.sh | 1 - .../example_requires_exports/m4/run.sh | 1 - .../m4/.gitignore | 1 - .../m4/clean.sh | 1 - .../m4/compile.sh | 17 +- .../m4/pom.xml | 79 ++++++++++ .../m4/run.sh | 4 +- .../example_resolved-modules/README.adoc | 35 +++++ .../example_resolved-modules/m4/clean.sh | 1 - .../example_resolved-modules/m4/compile.sh | 23 ++- .../example_resolved-modules/m4/pom.xml | 46 ++++++ .../example_resolved-modules/m4/run.sh | 16 +- .../example_resources/m4/.gitignore | 1 - jigsaw-examples/example_resources/m4/clean.sh | 1 - .../example_resources/m4/compile.sh | 17 +- jigsaw-examples/example_resources/m4/pom.xml | 46 ++++++ jigsaw-examples/example_resources/m4/run.sh | 2 +- .../example_splitpackage/m4/.gitignore | 1 - .../example_splitpackage/m4/clean.sh | 1 - .../example_splitpackage/m4/compile.sh | 17 +- .../example_splitpackage/m4/pom.xml | 46 ++++++ .../example_splitpackage/m4/run.sh | 4 +- .../m4/clean.sh | 1 - .../m4/compile.sh | 17 +- .../m4/pom.xml | 24 +++ .../m4/run.sh | 2 +- .../m4/clean.sh | 1 - .../m4/compile.sh | 17 +- .../m4/pom.xml | 35 +++++ .../m4/run.sh | 40 ++--- .../m4/clean.sh | 1 - .../m4/compile.sh | 17 +- .../m4/pom.xml | 35 +++++ .../m4/run.sh | 2 +- .../m4/clean.sh | 1 - .../m4/compile.sh | 15 +- .../m4/pom.xml | 35 +++++ .../m4/run.sh | 2 +- .../m4/clean.sh | 1 - .../m4/compile.sh | 20 +-- .../m4/pom.xml | 24 +++ .../m4/run.sh | 2 +- .../example_uses-provides/m4/.gitignore | 1 - .../example_uses-provides/m4/clean.sh | 1 - .../example_uses-provides/m4/compile.sh | 17 +- .../example_uses-provides/m4/pom.xml | 57 +++++++ .../example_uses-provides/m4/run.sh | 2 +- .../m4/.gitignore | 1 - .../m4/clean.sh | 1 - .../m4/compile.sh | 17 +- .../m4/pom.xml | 57 +++++++ .../m4/run.sh | 2 +- jigsaw-examples/example_version/m4/.gitignore | 1 - jigsaw-examples/example_version/m4/clean.sh | 1 - jigsaw-examples/example_version/m4/compile.sh | 17 +- jigsaw-examples/example_version/m4/pom.xml | 24 +++ jigsaw-examples/example_version/m4/run.sh | 2 +- 141 files changed, 1609 insertions(+), 531 deletions(-) create mode 120000 jigsaw-examples/example_layer-hierarchy/m4/mlib create mode 120000 jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/mlib create mode 120000 jigsaw-examples/example_layer-modules-module-resolution/m4/mlib create mode 120000 jigsaw-examples/example_patch/m4/mlib diff --git a/jigsaw-examples/example_addExports_manifest/m4/.gitignore b/jigsaw-examples/example_addExports_manifest/m4/.gitignore index 39cc9516..6f7cb630 100644 --- a/jigsaw-examples/example_addExports_manifest/m4/.gitignore +++ b/jigsaw-examples/example_addExports_manifest/m4/.gitignore @@ -1,2 +1 @@ -mlib/ run-result/ diff --git a/jigsaw-examples/example_addExports_manifest/m4/clean.sh b/jigsaw-examples/example_addExports_manifest/m4/clean.sh index 94f380eb..d7faaade 100755 --- a/jigsaw-examples/example_addExports_manifest/m4/clean.sh +++ b/jigsaw-examples/example_addExports_manifest/m4/clean.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_addExports_manifest/m4/compile.sh b/jigsaw-examples/example_addExports_manifest/m4/compile.sh index cc480531..8b068d83 100755 --- a/jigsaw-examples/example_addExports_manifest/m4/compile.sh +++ b/jigsaw-examples/example_addExports_manifest/m4/compile.sh @@ -20,30 +20,12 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, targets Java 11 via maven.compiler.source/target)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - # Check if there's a custom MANIFEST.MF file for this module (via source symlink structure) - if [ -f "../../src/${MODDIR}/main/java/META-INF/MANIFEST.MF" ]; then - echo "jar $JAR_OPTIONS --create --manifest=../../src/${MODDIR}/main/java/META-INF/MANIFEST.MF --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --manifest="../../src/${MODDIR}/main/java/META-INF/MANIFEST.MF" --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 - else - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 - fi -done -popd >/dev/null 2>&1 +mvn clean package + diff --git a/jigsaw-examples/example_addExports_manifest/m4/pom.xml b/jigsaw-examples/example_addExports_manifest/m4/pom.xml index eeb35259..7bcad3ef 100644 --- a/jigsaw-examples/example_addExports_manifest/m4/pom.xml +++ b/jigsaw-examples/example_addExports_manifest/m4/pom.xml @@ -45,6 +45,44 @@ + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + moda + package + + jar + + + ${project.build.outputDirectory}/moda + moda + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + src/modmain/main/java/META-INF/MANIFEST.MF + + + + + diff --git a/jigsaw-examples/example_addExports_manifest/m4/run.sh b/jigsaw-examples/example_addExports_manifest/m4/run.sh index 32fa4e24..7698bdbb 100755 --- a/jigsaw-examples/example_addExports_manifest/m4/run.sh +++ b/jigsaw-examples/example_addExports_manifest/m4/run.sh @@ -23,11 +23,11 @@ mkdir -p run-result "${JAVA11_HOME}/bin/java" ${JAVA_OPTIONS} \ --add-exports java.base/jdk.internal.misc=modmain \ --add-exports moda/pkgainternal=modmain \ - --module-path mlib --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho + --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho # Second run: Allow access to moda with using the "Add-Exports" entry from MANIFEST.MF # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting "${JAVA11_HOME}/bin/java" ${JAVA_OPTIONS} \ --add-modules moda \ - --module-path mlib \ - -jar mlib/modmain.jar 2>&1 | normalize | tee -a run-result/run.txt | myecho + --module-path target \ + -jar target/example_addExports_manifest-m4-1.0-SNAPSHOT-modmain.jar 2>&1 | normalize | tee -a run-result/run.txt | myecho diff --git a/jigsaw-examples/example_addReads_addExports/m4/.gitignore b/jigsaw-examples/example_addReads_addExports/m4/.gitignore index 25275013..52aee332 100644 --- a/jigsaw-examples/example_addReads_addExports/m4/.gitignore +++ b/jigsaw-examples/example_addReads_addExports/m4/.gitignore @@ -1,3 +1,2 @@ target/ -mlib/ run-result/ diff --git a/jigsaw-examples/example_addReads_addExports/m4/clean.sh b/jigsaw-examples/example_addReads_addExports/m4/clean.sh index 94f380eb..d7faaade 100755 --- a/jigsaw-examples/example_addReads_addExports/m4/clean.sh +++ b/jigsaw-examples/example_addReads_addExports/m4/clean.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_addReads_addExports/m4/compile.sh b/jigsaw-examples/example_addReads_addExports/m4/compile.sh index f872668c..3d6b7cb8 100755 --- a/jigsaw-examples/example_addReads_addExports/m4/compile.sh +++ b/jigsaw-examples/example_addReads_addExports/m4/compile.sh @@ -20,23 +20,12 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +mvn clean package + diff --git a/jigsaw-examples/example_addReads_addExports/m4/pom.xml b/jigsaw-examples/example_addReads_addExports/m4/pom.xml index ba3f0258..f0f3e66c 100644 --- a/jigsaw-examples/example_addReads_addExports/m4/pom.xml +++ b/jigsaw-examples/example_addReads_addExports/m4/pom.xml @@ -49,6 +49,52 @@ + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modb + package + + jar + + + ${project.build.outputDirectory}/modb + modb + + + + modc + package + + jar + + + ${project.build.outputDirectory}/modc + modc + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_addReads_addExports/m4/run.sh b/jigsaw-examples/example_addReads_addExports/m4/run.sh index 70a05838..ee4db79e 100755 --- a/jigsaw-examples/example_addReads_addExports/m4/run.sh +++ b/jigsaw-examples/example_addReads_addExports/m4/run.sh @@ -14,7 +14,7 @@ mkdir -p run-result # Run the Java code, save output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib \ +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target \ --add-modules modb,modc \ --add-reads modmain=modb \ --add-reads modb=modc \ diff --git a/jigsaw-examples/example_addReads_addExports_reflection/m4/.gitignore b/jigsaw-examples/example_addReads_addExports_reflection/m4/.gitignore index 25275013..52aee332 100644 --- a/jigsaw-examples/example_addReads_addExports_reflection/m4/.gitignore +++ b/jigsaw-examples/example_addReads_addExports_reflection/m4/.gitignore @@ -1,3 +1,2 @@ target/ -mlib/ run-result/ diff --git a/jigsaw-examples/example_addReads_addExports_reflection/m4/clean.sh b/jigsaw-examples/example_addReads_addExports_reflection/m4/clean.sh index 94f380eb..d7faaade 100755 --- a/jigsaw-examples/example_addReads_addExports_reflection/m4/clean.sh +++ b/jigsaw-examples/example_addReads_addExports_reflection/m4/clean.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_addReads_addExports_reflection/m4/compile.sh b/jigsaw-examples/example_addReads_addExports_reflection/m4/compile.sh index f872668c..3d6b7cb8 100755 --- a/jigsaw-examples/example_addReads_addExports_reflection/m4/compile.sh +++ b/jigsaw-examples/example_addReads_addExports_reflection/m4/compile.sh @@ -20,23 +20,12 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +mvn clean package + diff --git a/jigsaw-examples/example_addReads_addExports_reflection/m4/pom.xml b/jigsaw-examples/example_addReads_addExports_reflection/m4/pom.xml index f094ffeb..47a999ed 100644 --- a/jigsaw-examples/example_addReads_addExports_reflection/m4/pom.xml +++ b/jigsaw-examples/example_addReads_addExports_reflection/m4/pom.xml @@ -41,6 +41,41 @@ + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modb + package + + jar + + + ${project.build.outputDirectory}/modb + modb + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_addReads_addExports_reflection/m4/run.sh b/jigsaw-examples/example_addReads_addExports_reflection/m4/run.sh index f2324c95..ab44bca6 100755 --- a/jigsaw-examples/example_addReads_addExports_reflection/m4/run.sh +++ b/jigsaw-examples/example_addReads_addExports_reflection/m4/run.sh @@ -16,7 +16,7 @@ mkdir -p run-result # note: not done here (but via api in modmain, see Main.java#26) as a replacement for --add-reads modmain=modb # note: not done here (but via api in modmain, see Main.java#30) as a replacement for --add-exports modb/pkgbinternal=modmain # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib \ +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target \ --add-modules modb \ --add-exports modb/pkgb=modmain \ --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_annotations/m4/compile.sh b/jigsaw-examples/example_annotations/m4/compile.sh index 49b39320..37682871 100755 --- a/jigsaw-examples/example_annotations/m4/compile.sh +++ b/jigsaw-examples/example_annotations/m4/compile.sh @@ -26,5 +26,4 @@ echo echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -echo "(JARs are created by maven-jar-plugin in target/ directory)" mvn clean package diff --git a/jigsaw-examples/example_annotations/m4/run.sh b/jigsaw-examples/example_annotations/m4/run.sh index 8b288067..fa508d91 100755 --- a/jigsaw-examples/example_annotations/m4/run.sh +++ b/jigsaw-examples/example_annotations/m4/run.sh @@ -13,6 +13,5 @@ echo mkdir -p run-result # Run the Java code, save output to run-result/run.txt, and display with highlighting -# JARs are now in target/ (created by maven-jar-plugin) # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_automatic-module-logging/m4/.gitignore b/jigsaw-examples/example_automatic-module-logging/m4/.gitignore index 1c45f36b..4b4fce97 100644 --- a/jigsaw-examples/example_automatic-module-logging/m4/.gitignore +++ b/jigsaw-examples/example_automatic-module-logging/m4/.gitignore @@ -1,4 +1,3 @@ target/ -mlib/ run-result/ amlib-api/ diff --git a/jigsaw-examples/example_automatic-module-logging/m4/clean.sh b/jigsaw-examples/example_automatic-module-logging/m4/clean.sh index f492f39b..31759580 100755 --- a/jigsaw-examples/example_automatic-module-logging/m4/clean.sh +++ b/jigsaw-examples/example_automatic-module-logging/m4/clean.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf amlib-api rm -rf run-result diff --git a/jigsaw-examples/example_automatic-module-logging/m4/compile.sh b/jigsaw-examples/example_automatic-module-logging/m4/compile.sh index f872668c..3d6b7cb8 100755 --- a/jigsaw-examples/example_automatic-module-logging/m4/compile.sh +++ b/jigsaw-examples/example_automatic-module-logging/m4/compile.sh @@ -20,23 +20,12 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +mvn clean package + diff --git a/jigsaw-examples/example_automatic-module-logging/m4/pom.xml b/jigsaw-examples/example_automatic-module-logging/m4/pom.xml index d9c0b2d7..31169183 100644 --- a/jigsaw-examples/example_automatic-module-logging/m4/pom.xml +++ b/jigsaw-examples/example_automatic-module-logging/m4/pom.xml @@ -62,6 +62,30 @@ + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_automatic-module-logging/m4/run.sh b/jigsaw-examples/example_automatic-module-logging/m4/run.sh index 855c7d71..a7493dcf 100755 --- a/jigsaw-examples/example_automatic-module-logging/m4/run.sh +++ b/jigsaw-examples/example_automatic-module-logging/m4/run.sh @@ -28,7 +28,7 @@ echo "Using slf4j.jdk14 as implementation for slf4j, see also #VersionsInModuleN # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} \ - --module-path mlib"${PATH_SEPARATOR}"amlib-api"${PATH_SEPARATOR}"../amlib-jdk14 \ + --module-path target"${PATH_SEPARATOR}"amlib-api"${PATH_SEPARATOR}"../amlib-jdk14 \ --add-modules slf4j.jdk14 \ --module modmain/pkgmain.Main 2>&1 | normalize | normalize_extra | tee -a run-result/run.txt | myecho @@ -38,7 +38,7 @@ echo "Using slf4j.simple as implementation for slf4j" # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} \ - --module-path mlib"${PATH_SEPARATOR}"amlib-api"${PATH_SEPARATOR}"../amlib-simple \ + --module-path target"${PATH_SEPARATOR}"amlib-api"${PATH_SEPARATOR}"../amlib-simple \ --add-modules slf4j.simple \ --module modmain/pkgmain.Main 2>&1 | normalize | normalize_extra | tee -a run-result/run.txt | myecho @@ -47,7 +47,7 @@ echo echo "Exception expected: java.lang.module.ResolutionException: Modules slf4j.jdk14 and slf4j.simple export package org.slf4j.impl to module slf4j.api" # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting if "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} \ - --module-path mlib"${PATH_SEPARATOR}"amlib-api"${PATH_SEPARATOR}"../amlib-simple"${PATH_SEPARATOR}"../amlib-jdk14 \ + --module-path target"${PATH_SEPARATOR}"amlib-api"${PATH_SEPARATOR}"../amlib-simple"${PATH_SEPARATOR}"../amlib-jdk14 \ --add-modules slf4j.simple\,slf4j.jdk14 \ --module modmain/pkgmain.Main 2>&1 | normalize | normalize_extra | sed -e 's,^java.lang.module.ResolutionException:.*,java.lang.module.ResolutionException: ...,g' | tee -a run-result/run.txt | myecho; then echo "An exception should occur here!" >&2 diff --git a/jigsaw-examples/example_derived_private-package-protected/m4/compile.sh b/jigsaw-examples/example_derived_private-package-protected/m4/compile.sh index 62fbc949..3d6b7cb8 100755 --- a/jigsaw-examples/example_derived_private-package-protected/m4/compile.sh +++ b/jigsaw-examples/example_derived_private-package-protected/m4/compile.sh @@ -26,6 +26,6 @@ mvn --version echo echo "mvn clean package" -echo "(JARs are created by maven-jar-plugin in target/ directory)"echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_derived_private-package-protected/m4/run.sh b/jigsaw-examples/example_derived_private-package-protected/m4/run.sh index d972ba45..fa508d91 100755 --- a/jigsaw-examples/example_derived_private-package-protected/m4/run.sh +++ b/jigsaw-examples/example_derived_private-package-protected/m4/run.sh @@ -14,5 +14,4 @@ mkdir -p run-result # Run the Java code, save output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -# JARs are now in target/ (created by maven-jar-plugin) "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_exceptions/m4/.gitignore b/jigsaw-examples/example_exceptions/m4/.gitignore index 25275013..52aee332 100644 --- a/jigsaw-examples/example_exceptions/m4/.gitignore +++ b/jigsaw-examples/example_exceptions/m4/.gitignore @@ -1,3 +1,2 @@ target/ -mlib/ run-result/ diff --git a/jigsaw-examples/example_exceptions/m4/clean.sh b/jigsaw-examples/example_exceptions/m4/clean.sh index 94f380eb..d7faaade 100755 --- a/jigsaw-examples/example_exceptions/m4/clean.sh +++ b/jigsaw-examples/example_exceptions/m4/clean.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_exceptions/m4/compile.sh b/jigsaw-examples/example_exceptions/m4/compile.sh index f872668c..3d6b7cb8 100755 --- a/jigsaw-examples/example_exceptions/m4/compile.sh +++ b/jigsaw-examples/example_exceptions/m4/compile.sh @@ -20,23 +20,12 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +mvn clean package + diff --git a/jigsaw-examples/example_exceptions/m4/pom.xml b/jigsaw-examples/example_exceptions/m4/pom.xml index 59bce923..8c6d6af2 100644 --- a/jigsaw-examples/example_exceptions/m4/pom.xml +++ b/jigsaw-examples/example_exceptions/m4/pom.xml @@ -32,6 +32,41 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modb + package + + jar + + + ${project.build.outputDirectory}/modb + modb + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_exceptions/m4/run.sh b/jigsaw-examples/example_exceptions/m4/run.sh index f17cda9b..fa508d91 100755 --- a/jigsaw-examples/example_exceptions/m4/run.sh +++ b/jigsaw-examples/example_exceptions/m4/run.sh @@ -14,4 +14,4 @@ mkdir -p run-result # Run the Java code, save output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_hiddenmain/m4/compile.sh b/jigsaw-examples/example_hiddenmain/m4/compile.sh index 49b39320..37682871 100755 --- a/jigsaw-examples/example_hiddenmain/m4/compile.sh +++ b/jigsaw-examples/example_hiddenmain/m4/compile.sh @@ -26,5 +26,4 @@ echo echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -echo "(JARs are created by maven-jar-plugin in target/ directory)" mvn clean package diff --git a/jigsaw-examples/example_hiddenmain/m4/run.sh b/jigsaw-examples/example_hiddenmain/m4/run.sh index 9afa043b..b76921b2 100755 --- a/jigsaw-examples/example_hiddenmain/m4/run.sh +++ b/jigsaw-examples/example_hiddenmain/m4/run.sh @@ -13,7 +13,6 @@ echo mkdir -p run-result # Run the first Java command, save output to run-result/run.txt, and display with highlighting -# JARs are now in target/ (created by maven-jar-plugin) # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_interface-callback/m4/.gitignore b/jigsaw-examples/example_interface-callback/m4/.gitignore index 25275013..52aee332 100644 --- a/jigsaw-examples/example_interface-callback/m4/.gitignore +++ b/jigsaw-examples/example_interface-callback/m4/.gitignore @@ -1,3 +1,2 @@ target/ -mlib/ run-result/ diff --git a/jigsaw-examples/example_interface-callback/m4/clean.sh b/jigsaw-examples/example_interface-callback/m4/clean.sh index 94f380eb..d7faaade 100755 --- a/jigsaw-examples/example_interface-callback/m4/clean.sh +++ b/jigsaw-examples/example_interface-callback/m4/clean.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_interface-callback/m4/compile.sh b/jigsaw-examples/example_interface-callback/m4/compile.sh index f872668c..3d6b7cb8 100755 --- a/jigsaw-examples/example_interface-callback/m4/compile.sh +++ b/jigsaw-examples/example_interface-callback/m4/compile.sh @@ -20,23 +20,12 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +mvn clean package + diff --git a/jigsaw-examples/example_interface-callback/m4/pom.xml b/jigsaw-examples/example_interface-callback/m4/pom.xml index fbc067a5..66e56e66 100644 --- a/jigsaw-examples/example_interface-callback/m4/pom.xml +++ b/jigsaw-examples/example_interface-callback/m4/pom.xml @@ -36,6 +36,52 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modcallbackhandler + package + + jar + + + ${project.build.outputDirectory}/modcallbackhandler + modcallbackhandler + + + + modcallee + package + + jar + + + ${project.build.outputDirectory}/modcallee + modcallee + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_interface-callback/m4/run.sh b/jigsaw-examples/example_interface-callback/m4/run.sh index f17cda9b..fa508d91 100755 --- a/jigsaw-examples/example_interface-callback/m4/run.sh +++ b/jigsaw-examples/example_interface-callback/m4/run.sh @@ -14,4 +14,4 @@ mkdir -p run-result # Run the Java code, save output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_jerrymouse/README.adoc b/jigsaw-examples/example_jerrymouse/README.adoc index 700d7b88..23dd273d 100644 --- a/jigsaw-examples/example_jerrymouse/README.adoc +++ b/jigsaw-examples/example_jerrymouse/README.adoc @@ -121,7 +121,7 @@ Created `m4/apps_copyallexamples2appdir.sh` script. + * Copies Maven 4 versions of example applications from whitelisted examples * Builds M4 versions of dependencies if they don't exist yet -* Sources from `../example_*/m4/target/` (Phase 2: JARs created by maven-jar-plugin) +* Sources from `../example_*/m4/target/` (JARs created by maven-jar-plugin) * Creates `app.json` descriptors for each application Runtime Configuration:: diff --git a/jigsaw-examples/example_jerrymouse/m4/compile.sh b/jigsaw-examples/example_jerrymouse/m4/compile.sh index 19bfe757..3d6b7cb8 100755 --- a/jigsaw-examples/example_jerrymouse/m4/compile.sh +++ b/jigsaw-examples/example_jerrymouse/m4/compile.sh @@ -26,7 +26,6 @@ mvn --version echo echo "mvn clean package" -echo "(JARs are created by maven-jar-plugin in target/ directory)" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_jerrymouse/m4/run.sh b/jigsaw-examples/example_jerrymouse/m4/run.sh index 2252b1fa..dc22011f 100755 --- a/jigsaw-examples/example_jerrymouse/m4/run.sh +++ b/jigsaw-examples/example_jerrymouse/m4/run.sh @@ -16,6 +16,5 @@ mkdir -p run-result # Run the app server (modstarter/pkgstarter.Starter) echo "" -# JARs are now in target/ (created by maven-jar-plugin) # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path "target${PATH_SEPARATOR}../amlib" --module modstarter/pkgstarter.Starter . run-result --sync 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_layer-hierarchy/README.adoc b/jigsaw-examples/example_layer-hierarchy/README.adoc index fef97b62..ca65c800 100644 --- a/jigsaw-examples/example_layer-hierarchy/README.adoc +++ b/jigsaw-examples/example_layer-hierarchy/README.adoc @@ -145,10 +145,19 @@ The `compile.sh` script manually compiles the three `mod.x_*` modules separately [source,bash] ---- # Compile mod.x_* modules separately (split package problem with automatic module) -for mod in mod.x_bottom mod.x_middle mod.x_top; do - javac -d mods/${mod} --module-path amlib --module-source-path "../src" -m ${mod} - jar --create --file=mlib/${mod}.jar -C mods/${mod}/${mod} . +for modx in mod.x_bottom mod.x_middle mod.x_top; do + javac --release 11 -d target/classes \ + --module-path target:amlib \ + --module-source-path "src/*/main/java" \ + $(find -L src/${modx}/main/java -name "*.java") done + +# Package as JARs in target/ (accessible via mlib symlink) +pushd target/classes > /dev/null +for modx in mod.x_bottom mod.x_middle mod.x_top; do + jar --create --file=../${modx}.jar -C ${modx} . +done +popd > /dev/null ---- *Phase 2 - Maven compilation of remaining modules:* @@ -212,6 +221,35 @@ The automatic module `javax.json` is downloaded via `maven-dependency-plugin` to ---- +*Dynamic module loading symlink:* + +The Java code in `mod.main/pkgmain/Main.java` uses the `ModuleLayer` API to dynamically load modules at runtime from a hardcoded path: + +[source,java] +---- +layerBuilder.createJigsawLayers(LayerHierarchy.root, LayerHierarchy.root.getLayer(), path + "/mlib"); +---- + +Since Maven (4) creates JARs in the `target/` directory (not `mlib/`), but the shared source code still references `mlib`, the migration uses a committed symbolic link: + +[source,bash] +---- +m4/mlib -> target +---- + +This symlink: + +* Redirects the hardcoded `mlib` path to `target/` at runtime +* Avoids modifying shared source code that is also used by the original (non-Maven) version +* Is committed to Git (like the source symlinks) +* Points to `target/` which Maven 4 populates with classifier-based JARs + +[NOTE] +==== +Both source symlinks (`m4/src/*/main/java β†’ ../../../../src/*`) and the runtime symlink (`m4/mlib β†’ target`) are committed to Git. +This allows the M4 migration to work seamlessly after checkout without manual symlink creation. +==== + ==== Running the Maven 4 Version [source,bash] diff --git a/jigsaw-examples/example_layer-hierarchy/m4/.gitignore b/jigsaw-examples/example_layer-hierarchy/m4/.gitignore index 2b7e3ffe..f779d7a3 100644 --- a/jigsaw-examples/example_layer-hierarchy/m4/.gitignore +++ b/jigsaw-examples/example_layer-hierarchy/m4/.gitignore @@ -2,7 +2,6 @@ target/ # Module JARs -mlib/ # Automatic module library (copied by maven-dependency-plugin) amlib/ diff --git a/jigsaw-examples/example_layer-hierarchy/m4/clean.sh b/jigsaw-examples/example_layer-hierarchy/m4/clean.sh index d38543e7..fc271c75 100755 --- a/jigsaw-examples/example_layer-hierarchy/m4/clean.sh +++ b/jigsaw-examples/example_layer-hierarchy/m4/clean.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf amlib rm -rf run-result diff --git a/jigsaw-examples/example_layer-hierarchy/m4/compile.sh b/jigsaw-examples/example_layer-hierarchy/m4/compile.sh index 7e9a82a3..8b4db4b3 100755 --- a/jigsaw-examples/example_layer-hierarchy/m4/compile.sh +++ b/jigsaw-examples/example_layer-hierarchy/m4/compile.sh @@ -17,9 +17,11 @@ MAVEN_JAVA_HOME="${JAVA17_HOME:-${JAVA_HOME}}" # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib mkdir -p target/classes +# Note: mlib β†’ target symlink is committed to Git for dynamic module loading +# (Java code uses path + "/mlib" to load modules at runtime) + # Step 1: Use Maven to download dependencies to amlib echo "=== Step 1: Download dependencies with Maven ===" echo @@ -34,30 +36,31 @@ echo echo "=== Step 2: Compile mod.x* modules (separate compilation with javac) ===" for modx in mod.x_bottom mod.x_middle mod.x_top do - echo "javac ${JAVAC_OPTIONS} --release 11 -d target/classes --module-path mlib${PATH_SEPARATOR}amlib --module-source-path \"src/*/main/java\" \$(find -L src/${modx}/main/java -name \"*.java\")" + echo "javac ${JAVAC_OPTIONS} --release 11 -d target/classes --module-path target${PATH_SEPARATOR}amlib --module-source-path \"src/*/main/java\" \$(find -L src/${modx}/main/java -name \"*.java\")" # shellcheck disable=SC2086 # JAVAC_OPTIONS is intentionally unquoted for word splitting # shellcheck disable=SC2046 # Word splitting intentional for multiple Java source files "${JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} --release 11 -d target/classes \ - --module-path mlib${PATH_SEPARATOR}amlib \ + --module-path target${PATH_SEPARATOR}amlib \ --module-source-path "src/*/main/java" \ $(find -L src/${modx}/main/java -name "*.java") 2>&1 done echo -# Step 3: Compile remaining 12 modules with Maven (pom.xml lists all non-mod.x_* modules) -echo "=== Step 3: Compile remaining 12 modules with Maven compiler plugin ===" -echo "mvn compile" -JAVA_HOME="${MAVEN_JAVA_HOME}" mvn compile +# Step 3: Compile remaining 12 modules with Maven and create JARs +echo "=== Step 3: Compile remaining 12 modules with Maven and create JARs ===" +echo "mvn package" +JAVA_HOME="${MAVEN_JAVA_HOME}" mvn package echo -# Step 4: Create JARs -echo "=== Step 4: Create module JARs ===" +# Step 4: Create JARs in target/ (for modules compiled with javac, Maven-compiled modules already have JARs) +echo "=== Step 4: Create module JARs for javac-compiled modules ===" pushd target/classes > /dev/null 2>&1 -for dir in */; +for modx in mod.x_bottom mod.x_middle mod.x_top do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 + if [ -d "${modx}" ]; then + echo "jar $JAR_OPTIONS --create --file=../${modx}.jar -C ${modx} ." + # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting + "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../${modx}.jar" -C "${modx}" . 2>&1 + fi done popd >/dev/null 2>&1 diff --git a/jigsaw-examples/example_layer-hierarchy/m4/mlib b/jigsaw-examples/example_layer-hierarchy/m4/mlib new file mode 120000 index 00000000..1de56593 --- /dev/null +++ b/jigsaw-examples/example_layer-hierarchy/m4/mlib @@ -0,0 +1 @@ +target \ No newline at end of file diff --git a/jigsaw-examples/example_layer-hierarchy/m4/pom.xml b/jigsaw-examples/example_layer-hierarchy/m4/pom.xml index adb00892..976e17cd 100644 --- a/jigsaw-examples/example_layer-hierarchy/m4/pom.xml +++ b/jigsaw-examples/example_layer-hierarchy/m4/pom.xml @@ -119,6 +119,151 @@ + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + mod.layer + package + + jar + + + ${project.build.outputDirectory}/mod.layer + mod.layer + + + + mod.main + package + + jar + + + ${project.build.outputDirectory}/mod.main + mod.main + + + + mod.u_bottom_middle_top + package + + jar + + + ${project.build.outputDirectory}/mod.u_bottom_middle_top + mod.u_bottom_middle_top + + + + mod.y_bottom + package + + jar + + + ${project.build.outputDirectory}/mod.y_bottom + mod.y_bottom + + + + mod.y_middle + package + + jar + + + ${project.build.outputDirectory}/mod.y_middle + mod.y_middle + + + + mod.y_top + package + + jar + + + ${project.build.outputDirectory}/mod.y_top + mod.y_top + + + + mod.z_bottom + package + + jar + + + ${project.build.outputDirectory}/mod.z_bottom + mod.z_bottom + + + + mod.z_middle + package + + jar + + + ${project.build.outputDirectory}/mod.z_middle + mod.z_middle + + + + mod.z_top + package + + jar + + + ${project.build.outputDirectory}/mod.z_top + mod.z_top + + + + mod.zreverse_bottom + package + + jar + + + ${project.build.outputDirectory}/mod.zreverse_bottom + mod.zreverse_bottom + + + + mod.zreverse_middle + package + + jar + + + ${project.build.outputDirectory}/mod.zreverse_middle + mod.zreverse_middle + + + + mod.zreverse_top + package + + jar + + + ${project.build.outputDirectory}/mod.zreverse_top + mod.zreverse_top + + + + diff --git a/jigsaw-examples/example_layer-hierarchy/m4/run.sh b/jigsaw-examples/example_layer-hierarchy/m4/run.sh index aff9a42f..8d4e31cb 100755 --- a/jigsaw-examples/example_layer-hierarchy/m4/run.sh +++ b/jigsaw-examples/example_layer-hierarchy/m4/run.sh @@ -20,4 +20,4 @@ echo # Run the Java code, save output to run-result/run.txt, and display with highlighting # The '.' argument specifies the JSON file (layers_triple_hierarchy.json) location # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA11_HOME}/bin/java" ${JAVA_OPTIONS} --module-path "mlib${PATH_SEPARATOR}amlib" --module mod.main/pkgmain.Main . 2>&1 | normalize | tee run-result/run.txt | myecho +"${JAVA11_HOME}/bin/java" ${JAVA_OPTIONS} --module-path "target${PATH_SEPARATOR}amlib" --module mod.main/pkgmain.Main . 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/clean.sh b/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/clean.sh index d0b6b774..964885ee 100755 --- a/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/clean.sh +++ b/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/clean.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf amlib1 rm -rf classes rm -rf run-result diff --git a/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/compile.sh b/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/compile.sh index 6667c4ff..95e283e5 100755 --- a/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/compile.sh +++ b/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/compile.sh @@ -20,7 +20,6 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib mkdir -p amlib1 mkdir -p classes @@ -56,17 +55,7 @@ echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile +mvn clean package -# Create JARs for explicit modules -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 diff --git a/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/pom.xml b/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/pom.xml index 4c401596..c67976f4 100644 --- a/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/pom.xml +++ b/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/pom.xml @@ -47,6 +47,63 @@ + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modbar + package + + jar + + + ${project.build.outputDirectory}/modbar + modbar + + + + modcommon + package + + jar + + + ${project.build.outputDirectory}/modcommon + modcommon + + + + modfoo + package + + jar + + + ${project.build.outputDirectory}/modfoo + modfoo + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/run.sh b/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/run.sh index db3d562d..4483dc8e 100755 --- a/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/run.sh +++ b/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/run.sh @@ -28,7 +28,7 @@ mkdir -p run-result # --add-modules ensures modbar and modfoo are resolved (otherwise they'd be unused) # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} \ - --module-path mlib"${PATH_SEPARATOR}"amlib1 \ + --module-path target"${PATH_SEPARATOR}"amlib1 \ --add-modules modbar,modfoo \ --module modmain/pkgmain.Main . \ 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/README.adoc b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/README.adoc index 8bb1faa7..ecebebcd 100644 --- a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/README.adoc +++ b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/README.adoc @@ -144,3 +144,43 @@ This hybrid approach is necessary because: * Split packages between automatic modules prevent compiling all modules together * Each module requiring an automatic module must be compiled separately with only the needed automatic module on path * This example demonstrates module layers where different modules use different automatic module versions + +=== Module-Path Symlink for Dynamic Module Loading + +The Java code in `modmain/pkgmain/Main.java` uses the `ModuleLayer` API to dynamically load modules at runtime from hardcoded paths: + +[source,java] +---- +// Dynamically creates layers and loads modules from ./foomlib and ./barmlib +Module fooModule = fooLayer.findModule("modfoo").get(); +Module barModule = barLayer.findModule("modbar").get(); +---- + +Maven (4) creates JARs in the `target/` directory with classifier-based names: + +[source] +---- +target/example_layer-modules-grouped-in-hierarchy-m4-1.0-SNAPSHOT-modcommon.jar +target/example_layer-modules-grouped-in-hierarchy-m4-1.0-SNAPSHOT-modmain.jar +... +---- + +To maintain compatibility with the shared Java source code that references `mlib`, the migration uses a committed symlink: + +[source,bash] +---- +m4/mlib -> target +---- + +This symlink: + +* Redirects the hardcoded `mlib` path to `target/` at runtime +* Avoids modifying shared source code that is also used by the original (non-Maven) version +* Is committed to Git (like the source symlinks) +* Points to `target/` which Maven 4 populates with classifier-based JARs + +[NOTE] +==== +Both source symlinks (`m4/src/modcommon/main/java` β†’ `../../../../src/modcommon`) and the runtime symlink (`m4/mlib β†’ target`) are committed to Git. +This allows the M4 migration to work seamlessly after checkout without manual symlink creation. +==== diff --git a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/clean.sh b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/clean.sh index 4936f184..d0eb0648 100755 --- a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/clean.sh +++ b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/clean.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf amlib1 rm -rf amlib2 rm -rf classes diff --git a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/compile.sh b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/compile.sh index 0341b157..dc6335b3 100755 --- a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/compile.sh +++ b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/compile.sh @@ -29,7 +29,9 @@ export PATH="${M4_HOME}/bin:${PATH}" mkdir -p amlib1 mkdir -p amlib2 mkdir -p classes -mkdir -p mlib + +# Note: mlib β†’ target symlink is committed to Git for dynamic module loading +# (Java code uses path + "/mlib" to load modules at runtime) echo "=== Hybrid Compilation for Maven 4 ===" echo @@ -66,53 +68,41 @@ echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile +mvn clean package -# Create JARs for Maven-compiled modules -echo -echo "Step 3: Package Maven-compiled modules as JARs in mlib/" -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar ${JAR_OPTIONS} --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 echo echo "Step 4: Manually compile modfoo (requires modauto1)" pushd ../src/modfoo > /dev/null 2>&1 mkdir -p ../../m4/mods/modfoo -echo "javac ${JAVAC_OPTIONS} -d ../../m4/mods/modfoo --module-path ../../m4/mlib${PATH_SEPARATOR}../../m4/amlib1 --release 11 \$(find . -name \"*.java\")" +echo "javac ${JAVAC_OPTIONS} -d ../../m4/mods/modfoo --module-path ../../m4/target${PATH_SEPARATOR}../../m4/amlib1 --release 11 \$(find . -name \"*.java\")" # shellcheck disable=SC2046,SC2086 # find output needs word splitting, JAVAC_OPTIONS intentionally unquoted "${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d ../../m4/mods/modfoo \ - --module-path ../../m4/mlib"${PATH_SEPARATOR}"../../m4/amlib1 \ + --module-path ../../m4/target"${PATH_SEPARATOR}"../../m4/amlib1 \ --release 11 \ $(find . -name "*.java") 2>&1 -echo "jar ${JAR_OPTIONS} --create --file=../../m4/mlib/modfoo.jar -C ../../m4/mods/modfoo ." +echo "jar ${JAR_OPTIONS} --create --file=../../m4/target/modfoo.jar -C ../../m4/mods/modfoo ." # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting -"${COMPILE_JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file=../../m4/mlib/modfoo.jar -C ../../m4/mods/modfoo . 2>&1 +"${COMPILE_JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file=../../m4/target/modfoo.jar -C ../../m4/mods/modfoo . 2>&1 popd >/dev/null 2>&1 echo echo "Step 5: Manually compile modbar (requires modauto2)" pushd ../src/modbar > /dev/null 2>&1 mkdir -p ../../m4/mods/modbar -echo "javac ${JAVAC_OPTIONS} -d ../../m4/mods/modbar --module-path ../../m4/mlib${PATH_SEPARATOR}../../m4/amlib2 --release 11 \$(find . -name \"*.java\")" +echo "javac ${JAVAC_OPTIONS} -d ../../m4/mods/modbar --module-path ../../m4/target${PATH_SEPARATOR}../../m4/amlib2 --release 11 \$(find . -name \"*.java\")" # shellcheck disable=SC2046,SC2086 # find output needs word splitting, JAVAC_OPTIONS intentionally unquoted "${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d ../../m4/mods/modbar \ - --module-path ../../m4/mlib"${PATH_SEPARATOR}"../../m4/amlib2 \ + --module-path ../../m4/target"${PATH_SEPARATOR}"../../m4/amlib2 \ --release 11 \ $(find . -name "*.java") 2>&1 -echo "jar ${JAR_OPTIONS} --create --file=../../m4/mlib/modbar.jar -C ../../m4/mods/modbar ." +echo "jar ${JAR_OPTIONS} --create --file=../../m4/target/modbar.jar -C ../../m4/mods/modbar ." # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting -"${COMPILE_JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file=../../m4/mlib/modbar.jar -C ../../m4/mods/modbar . 2>&1 +"${COMPILE_JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file=../../m4/target/modbar.jar -C ../../m4/mods/modbar . 2>&1 popd >/dev/null 2>&1 echo diff --git a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/mlib b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/mlib new file mode 120000 index 00000000..1de56593 --- /dev/null +++ b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/mlib @@ -0,0 +1 @@ +target \ No newline at end of file diff --git a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/pom.xml b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/pom.xml index 402b0fdd..1d1d0e6f 100644 --- a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/pom.xml +++ b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/pom.xml @@ -34,6 +34,41 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modcommon + package + + jar + + + ${project.build.outputDirectory}/modcommon + modcommon + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/run.sh b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/run.sh index 9da5f958..91c2255d 100755 --- a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/run.sh +++ b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/run.sh @@ -28,6 +28,6 @@ mkdir -p run-result # Note: Automatic modules are not needed at runtime for this example # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} \ - --module-path mlib \ + --module-path target \ --module modmain/pkgmain.Main . \ 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_layer-modules-module-resolution/README.adoc b/jigsaw-examples/example_layer-modules-module-resolution/README.adoc index 55ed604f..dd69e1ec 100644 --- a/jigsaw-examples/example_layer-modules-module-resolution/README.adoc +++ b/jigsaw-examples/example_layer-modules-module-resolution/README.adoc @@ -116,20 +116,38 @@ The `` element expects one source location per module name. Solution:: Hybrid compilation approach in `m4/compile.sh`: + -. Maven compiles the primary modules including modcommon v1.0 via the standard Module Source Hierarchy +. Maven compiles all primary modules (modbar, modcommon v1.0, modfoo, modmain, modversion1, modversion2) using Module Source Hierarchy +** Maven creates JARs in `target/` using maven-jar-plugin with classifiers +. The compile script copies layer-specific JARs to their respective directories for dynamic module loading: ++ +[source,bash] +---- +# Copy foo layer modules (modfoo, modversion1) to foomlib/ +for mod in modfoo modversion1; do + cp "target/example_layer-modules-module-resolution-m4-1.0-${mod}.jar" "foomlib/${mod}.jar" +done + +# Copy bar layer modules (modbar, modversion2) to barmlib/ +for mod in modbar modversion2; do + cp "target/example_layer-modules-module-resolution-m4-1.0-${mod}.jar" "barmlib/${mod}.jar" +done +---- ++ . Manual javac invocation compiles modcommon v2.0 from src2/: + [source,bash] ---- javac -d mods2 --release 11 --module-version=2.0 \ - --module-path mlib --module-source-path ../src2 \ + --module-path target --module-source-path ../src2 \ $(find ../src2/modcommon -name "*.java") + +jar --create --file=../barmlib/modcommon.jar -C modcommon . ---- + -. JAR placement follows the original structure: -** mlib/ - boot layer modules (modcommon v1.0, modmain) -** foomlib/ - foo layer modules (modfoo, modversion1) -** barmlib/ - bar layer modules (modbar, modversion2, modcommon v2.0) +. JAR placement for dynamic module loading: +** target/ - Maven-built JARs (with classifiers) +** foomlib/ - foo layer modules (modfoo, modversion1) copied from target/ +** barmlib/ - bar layer modules (modbar, modversion2) copied from target/, plus modcommon v2.0 compiled manually This hybrid approach is necessary because: diff --git a/jigsaw-examples/example_layer-modules-module-resolution/m4/clean.sh b/jigsaw-examples/example_layer-modules-module-resolution/m4/clean.sh index 25d409c6..838025da 100755 --- a/jigsaw-examples/example_layer-modules-module-resolution/m4/clean.sh +++ b/jigsaw-examples/example_layer-modules-module-resolution/m4/clean.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf foomlib rm -rf barmlib rm -rf mods2 diff --git a/jigsaw-examples/example_layer-modules-module-resolution/m4/compile.sh b/jigsaw-examples/example_layer-modules-module-resolution/m4/compile.sh index 667a9ff6..9082cfeb 100755 --- a/jigsaw-examples/example_layer-modules-module-resolution/m4/compile.sh +++ b/jigsaw-examples/example_layer-modules-module-resolution/m4/compile.sh @@ -20,7 +20,6 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib mkdir -p foomlib mkdir -p barmlib @@ -28,45 +27,26 @@ echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile +mvn clean package -# Create JARs in appropriate directories (matching original compile.sh structure) -pushd target/classes > /dev/null 2>&1 - -# Boot layer modules go to mlib -for mod in modcommon modmain; -do - if [ -d "${mod}" ]; then - echo "jar $JAR_OPTIONS --create --file=../../mlib/${mod}.jar -C ${mod} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${mod}.jar" -C "${mod}" . 2>&1 - fi -done +# Copy Maven-built JARs to layer-specific directories for dynamic module loading +echo +echo "Copying JARs to layer-specific directories..." -# Foo layer modules go to foomlib -for mod in modversion1 modfoo; -do - if [ -d "${mod}" ]; then - echo "jar $JAR_OPTIONS --create --file=../../foomlib/${mod}.jar -C ${mod} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../foomlib/${mod}.jar" -C "${mod}" . 2>&1 - fi +# Copy foo layer modules (modfoo, modversion1) to foomlib/ +for mod in modfoo modversion1; do + echo "cp target/example_layer-modules-module-resolution-m4-1.0-${mod}.jar foomlib/${mod}.jar" + cp "target/example_layer-modules-module-resolution-m4-1.0-${mod}.jar" "foomlib/${mod}.jar" done -# Bar layer modules go to barmlib -for mod in modversion2 modbar; -do - if [ -d "${mod}" ]; then - echo "jar $JAR_OPTIONS --create --file=../../barmlib/${mod}.jar -C ${mod} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../barmlib/${mod}.jar" -C "${mod}" . 2>&1 - fi +# Copy bar layer modules (modbar, modversion2) to barmlib/ +for mod in modbar modversion2; do + echo "cp target/example_layer-modules-module-resolution-m4-1.0-${mod}.jar barmlib/${mod}.jar" + cp "target/example_layer-modules-module-resolution-m4-1.0-${mod}.jar" "barmlib/${mod}.jar" done -popd >/dev/null 2>&1 - # Compile second version of modcommon from src2 (version 2.0) # Maven doesn't support multiple versions of the same module, so we compile manually echo @@ -79,9 +59,9 @@ if [ -n "${JAVA11_HOME:-}" ]; then COMPILE_JAVA_HOME="${JAVA11_HOME}" fi -echo "javac ${JAVAC_OPTIONS} -d mods2 --release 11 --module-version=2.0 --module-path mlib --module-source-path ../src2 \$(find ../src2/modcommon -name \"*.java\")" +echo "javac ${JAVAC_OPTIONS} -d mods2 --release 11 --module-version=2.0 --module-path target --module-source-path ../src2 \$(find ../src2/modcommon -name \"*.java\")" # shellcheck disable=SC2046,SC2086 # JAVAC_OPTIONS is intentionally unquoted for word splitting, the find command is intended to be expanded -"${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d mods2 --release 11 --module-version=2.0 --module-path mlib --module-source-path ../src2 $(find ../src2/modcommon -name "*.java") 2>&1 +"${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -d mods2 --release 11 --module-version=2.0 --module-path target --module-source-path ../src2 $(find ../src2/modcommon -name "*.java") 2>&1 # Package new modcommon v2.0 as jar in barmlib (overwrites v1.0) pushd mods2 > /dev/null 2>&1 diff --git a/jigsaw-examples/example_layer-modules-module-resolution/m4/mlib b/jigsaw-examples/example_layer-modules-module-resolution/m4/mlib new file mode 120000 index 00000000..1de56593 --- /dev/null +++ b/jigsaw-examples/example_layer-modules-module-resolution/m4/mlib @@ -0,0 +1 @@ +target \ No newline at end of file diff --git a/jigsaw-examples/example_layer-modules-module-resolution/m4/pom.xml b/jigsaw-examples/example_layer-modules-module-resolution/m4/pom.xml index d6b04780..1b129495 100644 --- a/jigsaw-examples/example_layer-modules-module-resolution/m4/pom.xml +++ b/jigsaw-examples/example_layer-modules-module-resolution/m4/pom.xml @@ -48,6 +48,85 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modbar + package + + jar + + + ${project.build.outputDirectory}/modbar + modbar + + + + modcommon + package + + jar + + + ${project.build.outputDirectory}/modcommon + modcommon + + + + modfoo + package + + jar + + + ${project.build.outputDirectory}/modfoo + modfoo + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + modversion1 + package + + jar + + + ${project.build.outputDirectory}/modversion1 + modversion1 + + + + modversion2 + package + + jar + + + ${project.build.outputDirectory}/modversion2 + modversion2 + + + + diff --git a/jigsaw-examples/example_layer-modules-module-resolution/m4/run.sh b/jigsaw-examples/example_layer-modules-module-resolution/m4/run.sh index c3662b74..e3a02a93 100755 --- a/jigsaw-examples/example_layer-modules-module-resolution/m4/run.sh +++ b/jigsaw-examples/example_layer-modules-module-resolution/m4/run.sh @@ -17,4 +17,4 @@ mkdir -p run-result # Run the Java code with "." argument for dynamic layer creation, save output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${RUNTIME_JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmain/pkgmain.Main . 2>&1 | normalize | tee run-result/run.txt | myecho +"${RUNTIME_JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main . 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_naming-modules/m4/clean.sh b/jigsaw-examples/example_naming-modules/m4/clean.sh index fb1bc068..f6185e1f 100755 --- a/jigsaw-examples/example_naming-modules/m4/clean.sh +++ b/jigsaw-examples/example_naming-modules/m4/clean.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result rm -rf classes rm -rf amlib1 diff --git a/jigsaw-examples/example_naming-modules/m4/compile.sh b/jigsaw-examples/example_naming-modules/m4/compile.sh index 38ac707a..b4e125ed 100755 --- a/jigsaw-examples/example_naming-modules/m4/compile.sh +++ b/jigsaw-examples/example_naming-modules/m4/compile.sh @@ -20,7 +20,6 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib mkdir -p amlib1 mkdir -p amlib2 mkdir -p amlib3 @@ -65,22 +64,10 @@ echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile +mvn clean package -# Create JARs for explicit modules -echo -echo "Step 3: Create modular JARs" -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar ${JAR_OPTIONS} --create --file=../../mlib/${MODDIR}.jar --module-version 0.1 -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" --module-version 0.1 -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 echo echo "βœ… Compilation complete" diff --git a/jigsaw-examples/example_naming-modules/m4/pom.xml b/jigsaw-examples/example_naming-modules/m4/pom.xml index 95432162..d00c9336 100644 --- a/jigsaw-examples/example_naming-modules/m4/pom.xml +++ b/jigsaw-examples/example_naming-modules/m4/pom.xml @@ -7,7 +7,7 @@ com.example.jigsaw example_naming-modules-m4 - 1.0-SNAPSHOT + 0.1 11 @@ -51,6 +51,85 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + java.whatever + package + + jar + + + ${project.build.outputDirectory}/java.whatever + java.whatever + + + + jdk.whatever + package + + jar + + + ${project.build.outputDirectory}/jdk.whatever + jdk.whatever + + + + mod.client + package + + jar + + + ${project.build.outputDirectory}/mod.client + mod.client + + + + mod_client + package + + jar + + + ${project.build.outputDirectory}/mod_client + mod_client + + + + modjava + package + + jar + + + ${project.build.outputDirectory}/modjava + modjava + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_naming-modules/m4/run.sh b/jigsaw-examples/example_naming-modules/m4/run.sh index 3482b571..60dc2368 100755 --- a/jigsaw-examples/example_naming-modules/m4/run.sh +++ b/jigsaw-examples/example_naming-modules/m4/run.sh @@ -16,7 +16,7 @@ echo "Using Java version:" echo # Iterate through all JAR directories (modular and automatic modules) -for dir in mlib amlib1 amlib2 amlib3 amlib4 +for dir in target amlib1 amlib2 amlib3 amlib4 do pushd "${dir}" > /dev/null 2>&1 # shellcheck disable=SC2012,SC2035 # JAR filenames are controlled, safe to use ls with glob @@ -25,7 +25,14 @@ do echo "JAR-file: ${JAR} in ${dir}" # get name of JAR-file - MOD="$(basename "${JAR}" | sed s/'.jar'//g | sed s/'-'/'.'/g | cut -d '.' -f 1-2)" + # For target/ JARs (Phase 2): extract classifier after last hyphen before .jar + # For amlib JARs: use the whole basename + if [[ "${dir}" == "target" ]]; then + # Extract classifier from pattern: artifactId-version-classifier.jar + MOD="$(basename "${JAR}" .jar | sed 's/.*-\([^-]*\)$/\1/')" + else + MOD="$(basename "${JAR}" | sed s/'.jar'//g | sed s/'-'/'.'/g | cut -d '.' -f 1-2)" + fi echo "java --module-path . --module ${MOD}/pkgmain.Main" if ! "${JAVA_HOME}/bin/java" --module-path . --module "${MOD}/pkgmain.Main" 2>&1 | normalize | tee -a "../${result_dir}/run.txt" | myecho; then diff --git a/jigsaw-examples/example_patch/README.adoc b/jigsaw-examples/example_patch/README.adoc index d1198a6c..187106fc 100644 --- a/jigsaw-examples/example_patch/README.adoc +++ b/jigsaw-examples/example_patch/README.adoc @@ -127,8 +127,38 @@ m4/src/modb/main/java -> ../../../../src/modb m4/src/modb-patch/main/java -> ../../../../src/modb-patch ---- + -These symbolic links are checked into Git and do not need to be created dynamically. +These source symlinks point to the original shared source directories and are checked into Git. + +Module-path symlink for JAR naming:: ++ +Maven (4) uses maven-jar-plugin with classifiers, creating JARs with names like: + +[source] +---- +target/example_patch-m4-1.0-SNAPSHOT-modmain.jar +target/example_patch-m4-1.0-SNAPSHOT-modb.jar +---- ++ +However, Java's `--module-path` works best with simple JAR names or explicit paths. To maintain compatibility with the module-path, the migration uses a committed symlink: ++ +[source,bash] +---- +m4/mlib -> target +---- ++ +This symlink: ++ +* Allows `--module-path mlib` to resolve to the actual JARs in `target/` +* Maintains consistency with the original example structure +* Is committed to Git (like the source symlinks) +* Enables running the example from IDE without executing `compile.sh` + +[NOTE] +==== +Both source symlinks (`m4/src/modmain/main/java` β†’ `../../../../src/modmain`) and the runtime symlink (`m4/mlib β†’ target`) are committed to Git. +This unified symlink handling allows the M4 migration to work seamlessly after checkout without manual symlink creation. +==== + [NOTE] ==== The patch compilation uses `--patch-module modb=src/modb-patch/main/java`, pointing directly to the symlinked patch sources. @@ -138,8 +168,9 @@ Dependencies from the original `modb` module (like the `Helper` class) are resol Build artifacts:: + +* `target/` - Maven-built JARs with classifiers (example_patch-m4-1.0-SNAPSHOT-modmain.jar, etc.) * `target/classes/` - Maven-compiled module classes -* `mlib/` - Module JARs (modmain.jar, modb.jar) +* `mlib/` - Symlink to `target/` for module-path compatibility * `patches/modb/` - Exploded patch classes * `patchlib/modb.jar` - Patch JAR diff --git a/jigsaw-examples/example_patch/m4/.gitignore b/jigsaw-examples/example_patch/m4/.gitignore index 3ca66262..e17f8e61 100644 --- a/jigsaw-examples/example_patch/m4/.gitignore +++ b/jigsaw-examples/example_patch/m4/.gitignore @@ -1,10 +1,6 @@ # Maven build output /target -# Module JARs -/mlib - -# Patch artifacts /patches /patchlib diff --git a/jigsaw-examples/example_patch/m4/clean.sh b/jigsaw-examples/example_patch/m4/clean.sh index 16944b56..d8375147 100755 --- a/jigsaw-examples/example_patch/m4/clean.sh +++ b/jigsaw-examples/example_patch/m4/clean.sh @@ -4,7 +4,6 @@ set -eu -o pipefail echo "Cleaning Maven 4 build artifacts..." rm -rf target -rm -rf mlib rm -rf patches rm -rf patchlib rm -rf run-result diff --git a/jigsaw-examples/example_patch/m4/compile.sh b/jigsaw-examples/example_patch/m4/compile.sh index b46af0fd..edc41c18 100755 --- a/jigsaw-examples/example_patch/m4/compile.sh +++ b/jigsaw-examples/example_patch/m4/compile.sh @@ -18,31 +18,23 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib mkdir -p patches mkdir -p patchlib +# Note: mlib β†’ target symlink is committed to Git for module-path compatibility +# (Allows running from IDE without executing compile.sh) + echo "=== Step 1: Compile modules modmain and modb with Maven 4 ====" echo echo "mvn --version" mvn --version echo -echo "mvn clean compile" -mvn clean compile +echo "mvn clean package" +echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +mvn clean package echo -# Create JARs from Maven-compiled classes -echo "=== Step 2: Create module JARs ====" -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar ${JAR_OPTIONS} --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 echo # Compile the patch as classes, create (non-modular) jar. diff --git a/jigsaw-examples/example_patch/m4/mlib b/jigsaw-examples/example_patch/m4/mlib new file mode 120000 index 00000000..1de56593 --- /dev/null +++ b/jigsaw-examples/example_patch/m4/mlib @@ -0,0 +1 @@ +target \ No newline at end of file diff --git a/jigsaw-examples/example_patch/m4/pom.xml b/jigsaw-examples/example_patch/m4/pom.xml index 2f493738..19d98cba 100644 --- a/jigsaw-examples/example_patch/m4/pom.xml +++ b/jigsaw-examples/example_patch/m4/pom.xml @@ -35,6 +35,41 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + modb + package + + jar + + + ${project.build.outputDirectory}/modb + modb + + + + diff --git a/jigsaw-examples/example_reflection/m4/.gitignore b/jigsaw-examples/example_reflection/m4/.gitignore index 25275013..52aee332 100644 --- a/jigsaw-examples/example_reflection/m4/.gitignore +++ b/jigsaw-examples/example_reflection/m4/.gitignore @@ -1,3 +1,2 @@ target/ -mlib/ run-result/ diff --git a/jigsaw-examples/example_reflection/m4/clean.sh b/jigsaw-examples/example_reflection/m4/clean.sh index 94f380eb..d7faaade 100755 --- a/jigsaw-examples/example_reflection/m4/clean.sh +++ b/jigsaw-examples/example_reflection/m4/clean.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_reflection/m4/compile.sh b/jigsaw-examples/example_reflection/m4/compile.sh index d8c08959..3d6b7cb8 100755 --- a/jigsaw-examples/example_reflection/m4/compile.sh +++ b/jigsaw-examples/example_reflection/m4/compile.sh @@ -20,23 +20,12 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar ${JAR_OPTIONS} --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +mvn clean package + diff --git a/jigsaw-examples/example_reflection/m4/pom.xml b/jigsaw-examples/example_reflection/m4/pom.xml index 24bcd59e..9cb19bd4 100644 --- a/jigsaw-examples/example_reflection/m4/pom.xml +++ b/jigsaw-examples/example_reflection/m4/pom.xml @@ -32,6 +32,41 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modb + package + + jar + + + ${project.build.outputDirectory}/modb + modb + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_reflection/m4/run.sh b/jigsaw-examples/example_reflection/m4/run.sh index f17cda9b..fa508d91 100755 --- a/jigsaw-examples/example_reflection/m4/run.sh +++ b/jigsaw-examples/example_reflection/m4/run.sh @@ -14,4 +14,4 @@ mkdir -p run-result # Run the Java code, save output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_requires-static/m4/.gitignore b/jigsaw-examples/example_requires-static/m4/.gitignore index 25275013..52aee332 100644 --- a/jigsaw-examples/example_requires-static/m4/.gitignore +++ b/jigsaw-examples/example_requires-static/m4/.gitignore @@ -1,3 +1,2 @@ target/ -mlib/ run-result/ diff --git a/jigsaw-examples/example_requires-static/m4/clean.sh b/jigsaw-examples/example_requires-static/m4/clean.sh index 94f380eb..d7faaade 100755 --- a/jigsaw-examples/example_requires-static/m4/clean.sh +++ b/jigsaw-examples/example_requires-static/m4/clean.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_requires-static/m4/compile.sh b/jigsaw-examples/example_requires-static/m4/compile.sh index f872668c..3d6b7cb8 100755 --- a/jigsaw-examples/example_requires-static/m4/compile.sh +++ b/jigsaw-examples/example_requires-static/m4/compile.sh @@ -20,23 +20,12 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +mvn clean package + diff --git a/jigsaw-examples/example_requires-static/m4/pom.xml b/jigsaw-examples/example_requires-static/m4/pom.xml index 5f56534d..f8ec7fb0 100644 --- a/jigsaw-examples/example_requires-static/m4/pom.xml +++ b/jigsaw-examples/example_requires-static/m4/pom.xml @@ -37,6 +37,52 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + modb + package + + jar + + + ${project.build.outputDirectory}/modb + modb + + + + modc + package + + jar + + + ${project.build.outputDirectory}/modc + modc + + + + diff --git a/jigsaw-examples/example_requires-static/m4/run.sh b/jigsaw-examples/example_requires-static/m4/run.sh index c93f6a53..897f5323 100755 --- a/jigsaw-examples/example_requires-static/m4/run.sh +++ b/jigsaw-examples/example_requires-static/m4/run.sh @@ -16,4 +16,4 @@ mkdir -p run-result # because of the 'requires static' dependencies from modb->modc and modmain->modb, # we need to add modb and modc explicitly to the runtime Configuration # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --add-modules modb,modc --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --add-modules modb,modc --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_requires_exports-to/m4/compile.sh b/jigsaw-examples/example_requires_exports-to/m4/compile.sh index 62fbc949..3d6b7cb8 100755 --- a/jigsaw-examples/example_requires_exports-to/m4/compile.sh +++ b/jigsaw-examples/example_requires_exports-to/m4/compile.sh @@ -26,6 +26,6 @@ mvn --version echo echo "mvn clean package" -echo "(JARs are created by maven-jar-plugin in target/ directory)"echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" +echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" mvn clean package diff --git a/jigsaw-examples/example_requires_exports-to/m4/run.sh b/jigsaw-examples/example_requires_exports-to/m4/run.sh index d972ba45..fa508d91 100755 --- a/jigsaw-examples/example_requires_exports-to/m4/run.sh +++ b/jigsaw-examples/example_requires_exports-to/m4/run.sh @@ -14,5 +14,4 @@ mkdir -p run-result # Run the Java code, save output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -# JARs are now in target/ (created by maven-jar-plugin) "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_requires_exports/m4/compile.sh b/jigsaw-examples/example_requires_exports/m4/compile.sh index 49b39320..37682871 100755 --- a/jigsaw-examples/example_requires_exports/m4/compile.sh +++ b/jigsaw-examples/example_requires_exports/m4/compile.sh @@ -26,5 +26,4 @@ echo echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -echo "(JARs are created by maven-jar-plugin in target/ directory)" mvn clean package diff --git a/jigsaw-examples/example_requires_exports/m4/run.sh b/jigsaw-examples/example_requires_exports/m4/run.sh index 8b288067..fa508d91 100755 --- a/jigsaw-examples/example_requires_exports/m4/run.sh +++ b/jigsaw-examples/example_requires_exports/m4/run.sh @@ -13,6 +13,5 @@ echo mkdir -p run-result # Run the Java code, save output to run-result/run.txt, and display with highlighting -# JARs are now in target/ (created by maven-jar-plugin) # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/.gitignore b/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/.gitignore index 25275013..52aee332 100644 --- a/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/.gitignore +++ b/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/.gitignore @@ -1,3 +1,2 @@ target/ -mlib/ run-result/ diff --git a/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/clean.sh b/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/clean.sh index 94f380eb..d7faaade 100755 --- a/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/clean.sh +++ b/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/clean.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/compile.sh b/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/compile.sh index f872668c..3d6b7cb8 100755 --- a/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/compile.sh +++ b/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/compile.sh @@ -20,23 +20,12 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +mvn clean package + diff --git a/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/pom.xml b/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/pom.xml index f4e251a9..76d27b61 100644 --- a/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/pom.xml +++ b/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/pom.xml @@ -48,6 +48,85 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + moda + package + + jar + + + ${project.build.outputDirectory}/moda + moda + + + + modb + package + + jar + + + ${project.build.outputDirectory}/modb + modb + + + + modc + package + + jar + + + ${project.build.outputDirectory}/modc + modc + + + + modfacade + package + + jar + + + ${project.build.outputDirectory}/modfacade + modfacade + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + modmainbehindfacade + package + + jar + + + ${project.build.outputDirectory}/modmainbehindfacade + modmainbehindfacade + + + + diff --git a/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/run.sh b/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/run.sh index ca09801b..6cf5bf8d 100755 --- a/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/run.sh +++ b/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/run.sh @@ -18,11 +18,11 @@ mkdir -p run-result # Run first main class, save output to run-result/run.txt # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt # Add separator echo " " | tee -a run-result/run.txt # Run second main class, append output to run-result/run.txt # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmainbehindfacade/pkgmainbehindfacade.MainBehindFacade 2>&1 | normalize | tee -a run-result/run.txt | myecho +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmainbehindfacade/pkgmainbehindfacade.MainBehindFacade 2>&1 | normalize | tee -a run-result/run.txt | myecho diff --git a/jigsaw-examples/example_resolved-modules/README.adoc b/jigsaw-examples/example_resolved-modules/README.adoc index 3ad8f93b..7d0d85b2 100644 --- a/jigsaw-examples/example_resolved-modules/README.adoc +++ b/jigsaw-examples/example_resolved-modules/README.adoc @@ -116,3 +116,38 @@ Scenario 8 demonstrates creating a custom runtime image using `jlink`. Automatic Module Reference:: The run script references `../amlib` for the `javax.json` automatic module in scenario 5, demonstrating that automatic modules are only loaded when explicitly required or added. + +=== JAR Naming for Module-Path and jlink + +Maven (4) uses maven-jar-plugin with classifiers, creating JARs with names like: + +[source] +---- +target/example_resolved-modules-m4-1.0-SNAPSHOT-moda.jar +target/example_resolved-modules-m4-1.0-SNAPSHOT-modb.jar +target/example_resolved-modules-m4-1.0-SNAPSHOT-modc.jar +---- + +However, when using `jlink`, it outputs the actual JAR filenames in its verbose output. The golden master test expects simple JAR names (e.g., `moda.jar`) for consistency with the original example. + +To solve this, `compile.sh` copies the JARs to `mlib/` with simple names: + +[source,bash] +---- +# Copy JARs to mlib with simple names for jlink +for mod in moda modb modc; do + cp "target/example_resolved-modules-m4-1.0-SNAPSHOT-${mod}.jar" "mlib/${mod}.jar" +done +---- + +The `run.sh` script then uses `--module-path mlib` instead of `--module-path target`, ensuring: + +* Simple JAR names in jlink output (matches golden master expectations) +* Consistent module-path references throughout all 8 test scenarios +* Compatibility with both direct Java execution and jlink-created runtime images + +[NOTE] +==== +While `--module-path target` would work for direct Java execution, jlink would output the full classifier-based names, breaking golden master verification. +The JAR copying approach maintains output consistency across all scenarios. +==== diff --git a/jigsaw-examples/example_resolved-modules/m4/clean.sh b/jigsaw-examples/example_resolved-modules/m4/clean.sh index f49447ad..19a940b1 100755 --- a/jigsaw-examples/example_resolved-modules/m4/clean.sh +++ b/jigsaw-examples/example_resolved-modules/m4/clean.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf jimage rm -rf run-result diff --git a/jigsaw-examples/example_resolved-modules/m4/compile.sh b/jigsaw-examples/example_resolved-modules/m4/compile.sh index f872668c..13ffd537 100755 --- a/jigsaw-examples/example_resolved-modules/m4/compile.sh +++ b/jigsaw-examples/example_resolved-modules/m4/compile.sh @@ -26,17 +26,16 @@ echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 +mvn clean package + +# Copy JARs to mlib with simple names for jlink +# (jlink outputs the JAR filename in its output, and we need simple names) +echo +echo "Copying JARs to mlib with simple names..." +for mod in moda modb modc; do + echo "cp target/example_resolved-modules-m4-1.0-SNAPSHOT-${mod}.jar mlib/${mod}.jar" + cp "target/example_resolved-modules-m4-1.0-SNAPSHOT-${mod}.jar" "mlib/${mod}.jar" done -popd >/dev/null 2>&1 + diff --git a/jigsaw-examples/example_resolved-modules/m4/pom.xml b/jigsaw-examples/example_resolved-modules/m4/pom.xml index 8cc9790d..1e25fd4b 100644 --- a/jigsaw-examples/example_resolved-modules/m4/pom.xml +++ b/jigsaw-examples/example_resolved-modules/m4/pom.xml @@ -36,6 +36,52 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + moda + package + + jar + + + ${project.build.outputDirectory}/moda + moda + + + + modb + package + + jar + + + ${project.build.outputDirectory}/modb + modb + + + + modc + package + + jar + + + ${project.build.outputDirectory}/modc + modc + + + + diff --git a/jigsaw-examples/example_resolved-modules/m4/run.sh b/jigsaw-examples/example_resolved-modules/m4/run.sh index b3a462c8..9b78e6c8 100755 --- a/jigsaw-examples/example_resolved-modules/m4/run.sh +++ b/jigsaw-examples/example_resolved-modules/m4/run.sh @@ -27,42 +27,42 @@ echo echo "1." echo "Running with root-module moda" -echo " java --module-path mlib --module moda/pkga.AMain" +echo " java --module-path target --module moda/pkga.AMain" "${JAVA_HOME}/bin/java" --module-path mlib --module moda/pkga.AMain 2>&1 | normalize | tee "${result_dir}/run.txt" | myecho echo ------------------------------------------------------------------ echo "2." echo "Running with root-module modb" -echo " java --module-path mlib --module modb/pkgb.BMain" +echo " java --module-path target --module modb/pkgb.BMain" "${JAVA_HOME}/bin/java" --module-path mlib --module modb/pkgb.BMain 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho echo ------------------------------------------------------------------ echo "3." echo "Running with root-module modc" -echo " java --module-path mlib --module modc/pkgc.CMain" +echo " java --module-path target --module modc/pkgc.CMain" "${JAVA_HOME}/bin/java" --module-path mlib --module modc/pkgc.CMain 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho echo ------------------------------------------------------------------ echo "4." echo "Running with root-module modb plus --add-modules modc" -echo " java --module-path mlib --add-modules modc --module modb/pkgb.BMain" +echo " java --module-path target --add-modules modc --module modb/pkgb.BMain" "${JAVA_HOME}/bin/java" --module-path mlib --add-modules modc --module modb/pkgb.BMain 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho echo ------------------------------------------------------------------ echo "5." echo "Running with root-module modb plus automatic module javax.json" -echo " java --module-path mlib${PATH_SEPARATOR}../amlib --module modb/pkgb.BMain" +echo " java --module-path target${PATH_SEPARATOR}../amlib --module modb/pkgb.BMain" "${JAVA_HOME}/bin/java" --module-path "mlib${PATH_SEPARATOR}../amlib" --module modb/pkgb.BMain 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho echo ------------------------------------------------------------------ echo "6." echo "Running with root-module modb plus limitmods" -echo " java --module-path mlib --limit-modules modb --module modb/pkgb.BMain" +echo " java --module-path target --limit-modules modb --module modb/pkgb.BMain" "${JAVA_HOME}/bin/java" --module-path mlib --limit-modules modb --module modb/pkgb.BMain 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho echo ------------------------------------------------------------------ @@ -72,7 +72,7 @@ echo "Running with root-module modb plus limitmods on module java.logging and ja echo "- Note that modb must be added to limitmods otherwise moda cannot be resolved" echo " (adding only moda would work too, but would be inconventient when modb has" echo " many requires)" -echo " java --module-path mlib -limitmods java.logging,java.scripting,modb --module modb/pkgb.BMain" +echo " java --module-path target -limitmods java.logging,java.scripting,modb --module modb/pkgb.BMain" "${JAVA_HOME}/bin/java" --module-path mlib --limit-modules java.logging,java.scripting,modb --module modb/pkgb.BMain 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho echo ------------------------------------------------------------------ @@ -86,7 +86,7 @@ echo "Linking with root module modb ..." JAVA_HOME_OS="${JAVA_HOME}" # /x/ doesn't work on module path on windows, replace with x: (echo "${OSTYPE}" | grep -i win >/dev/null) && JAVA_HOME_OS=$(echo "${JAVA_HOME}" | sed -r 's|^/([a-z])/|\1:/|') -echo " jlink --module-path mlib${PATH_SEPARATOR}${JAVA_HOME_OS}/jmods --add-modules modb --output jimage/modb" +echo " jlink --module-path target${PATH_SEPARATOR}${JAVA_HOME_OS}/jmods --add-modules modb --output jimage/modb" rm -rf ./jimage # TODO The following seems to work (on JDK 11) only with the `-v` option (otherwise `jlink` fails silently) "${JAVA_HOME}/bin/jlink" -v --module-path "mlib${PATH_SEPARATOR}${JAVA_HOME_OS}/jmods" --add-modules modb --output jimage/modb 2>&1 | normalize_jlink "${JAVA_HOME_OS}" | tee -a "${result_dir}/run.txt" | myecho diff --git a/jigsaw-examples/example_resources/m4/.gitignore b/jigsaw-examples/example_resources/m4/.gitignore index 25275013..52aee332 100644 --- a/jigsaw-examples/example_resources/m4/.gitignore +++ b/jigsaw-examples/example_resources/m4/.gitignore @@ -1,3 +1,2 @@ target/ -mlib/ run-result/ diff --git a/jigsaw-examples/example_resources/m4/clean.sh b/jigsaw-examples/example_resources/m4/clean.sh index 94f380eb..d7faaade 100755 --- a/jigsaw-examples/example_resources/m4/clean.sh +++ b/jigsaw-examples/example_resources/m4/clean.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_resources/m4/compile.sh b/jigsaw-examples/example_resources/m4/compile.sh index f872668c..3d6b7cb8 100755 --- a/jigsaw-examples/example_resources/m4/compile.sh +++ b/jigsaw-examples/example_resources/m4/compile.sh @@ -20,23 +20,12 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +mvn clean package + diff --git a/jigsaw-examples/example_resources/m4/pom.xml b/jigsaw-examples/example_resources/m4/pom.xml index 6352ab95..98c33956 100644 --- a/jigsaw-examples/example_resources/m4/pom.xml +++ b/jigsaw-examples/example_resources/m4/pom.xml @@ -110,6 +110,52 @@ + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modb + package + + jar + + + ${project.build.outputDirectory}/modb + modb + + + + modc + package + + jar + + + ${project.build.outputDirectory}/modc + modc + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_resources/m4/run.sh b/jigsaw-examples/example_resources/m4/run.sh index f17cda9b..fa508d91 100755 --- a/jigsaw-examples/example_resources/m4/run.sh +++ b/jigsaw-examples/example_resources/m4/run.sh @@ -14,4 +14,4 @@ mkdir -p run-result # Run the Java code, save output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_splitpackage/m4/.gitignore b/jigsaw-examples/example_splitpackage/m4/.gitignore index 25275013..52aee332 100644 --- a/jigsaw-examples/example_splitpackage/m4/.gitignore +++ b/jigsaw-examples/example_splitpackage/m4/.gitignore @@ -1,3 +1,2 @@ target/ -mlib/ run-result/ diff --git a/jigsaw-examples/example_splitpackage/m4/clean.sh b/jigsaw-examples/example_splitpackage/m4/clean.sh index 98d7b2fb..8206b8d3 100755 --- a/jigsaw-examples/example_splitpackage/m4/clean.sh +++ b/jigsaw-examples/example_splitpackage/m4/clean.sh @@ -2,5 +2,4 @@ set -eu -o pipefail rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_splitpackage/m4/compile.sh b/jigsaw-examples/example_splitpackage/m4/compile.sh index c17afba1..5a8ae38d 100755 --- a/jigsaw-examples/example_splitpackage/m4/compile.sh +++ b/jigsaw-examples/example_splitpackage/m4/compile.sh @@ -20,24 +20,13 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib echo echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +mvn clean package + diff --git a/jigsaw-examples/example_splitpackage/m4/pom.xml b/jigsaw-examples/example_splitpackage/m4/pom.xml index 6ccdcdb3..e05eb83f 100644 --- a/jigsaw-examples/example_splitpackage/m4/pom.xml +++ b/jigsaw-examples/example_splitpackage/m4/pom.xml @@ -37,6 +37,52 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modmainbar + package + + jar + + + ${project.build.outputDirectory}/modmainbar + modmainbar + + + + modsplitbar1 + package + + jar + + + ${project.build.outputDirectory}/modsplitbar1 + modsplitbar1 + + + + modsplitbar2 + package + + jar + + + ${project.build.outputDirectory}/modsplitbar2 + modsplitbar2 + + + + diff --git a/jigsaw-examples/example_splitpackage/m4/run.sh b/jigsaw-examples/example_splitpackage/m4/run.sh index 5fb80736..59a598ba 100755 --- a/jigsaw-examples/example_splitpackage/m4/run.sh +++ b/jigsaw-examples/example_splitpackage/m4/run.sh @@ -22,11 +22,11 @@ mkdir -p run-result # Bar modules: Demonstrate runtime split package problem # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmainbar/pkgmainbar.Main 2>&1 + "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmainbar/pkgmainbar.Main 2>&1 # This should fail with LayerInstantiationException because both modules have package pkgbar # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting - if "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --add-modules modsplitbar2 --module modmainbar/pkgmainbar.Main 2>&1; then + if "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --add-modules modsplitbar2 --module modmainbar/pkgmainbar.Main 2>&1; then echo "A runtime exception was expected here" >&2 exit 1 fi diff --git a/jigsaw-examples/example_splitpackage_automatic-modules/m4/clean.sh b/jigsaw-examples/example_splitpackage_automatic-modules/m4/clean.sh index e61aa703..388e1ae1 100755 --- a/jigsaw-examples/example_splitpackage_automatic-modules/m4/clean.sh +++ b/jigsaw-examples/example_splitpackage_automatic-modules/m4/clean.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf amlib1 rm -rf amlib2 rm -rf classes1 diff --git a/jigsaw-examples/example_splitpackage_automatic-modules/m4/compile.sh b/jigsaw-examples/example_splitpackage_automatic-modules/m4/compile.sh index 70fa354f..9d417352 100755 --- a/jigsaw-examples/example_splitpackage_automatic-modules/m4/compile.sh +++ b/jigsaw-examples/example_splitpackage_automatic-modules/m4/compile.sh @@ -30,7 +30,6 @@ mkdir -p amlib1 mkdir -p amlib2 mkdir -p classes1 mkdir -p classes2 -mkdir -p mlib echo "=== Hybrid Compilation for Maven 4 ===" echo @@ -69,23 +68,11 @@ echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" echo "(Compiler args: --module-path amlib1)" -mvn clean compile +mvn clean package -# Create JARs directly to mlib (similar to original compile.sh) -echo -echo "Step 3: Package module as JAR in mlib/" -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar ${JAR_OPTIONS} --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 echo echo "βœ… Hybrid compilation complete" diff --git a/jigsaw-examples/example_splitpackage_automatic-modules/m4/pom.xml b/jigsaw-examples/example_splitpackage_automatic-modules/m4/pom.xml index 56c6aadb..4314d156 100644 --- a/jigsaw-examples/example_splitpackage_automatic-modules/m4/pom.xml +++ b/jigsaw-examples/example_splitpackage_automatic-modules/m4/pom.xml @@ -35,6 +35,30 @@ + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_splitpackage_automatic-modules/m4/run.sh b/jigsaw-examples/example_splitpackage_automatic-modules/m4/run.sh index f418c765..4719ac32 100755 --- a/jigsaw-examples/example_splitpackage_automatic-modules/m4/run.sh +++ b/jigsaw-examples/example_splitpackage_automatic-modules/m4/run.sh @@ -31,6 +31,6 @@ echo # we do not see an error, all is fine # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} \ - --module-path mlib"${PATH_SEPARATOR}"amlib1 \ + --module-path target"${PATH_SEPARATOR}"amlib1 \ --module modmain/pkgmain.Main . \ 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/clean.sh b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/clean.sh index 267a2a8e..4a3cfa2f 100755 --- a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/clean.sh +++ b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/clean.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf classes rm -rf cplib rm -rf run-result diff --git a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/compile.sh b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/compile.sh index e51fbf63..8ea4aeb8 100755 --- a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/compile.sh +++ b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/compile.sh @@ -28,7 +28,6 @@ export PATH="${M4_HOME}/bin:${PATH}" mkdir -p cplib mkdir -p classes/cpmain -mkdir -p mlib echo "=== Hybrid Compilation for Maven 4 ===" echo @@ -37,22 +36,10 @@ echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile +mvn clean package -# Create JARs for modules -echo -echo "Step 2: Package modules as JARs in mlib/" -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar ${JAR_OPTIONS} --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 echo echo "Step 3: Manually compile classpath code (cpmain)" diff --git a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/pom.xml b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/pom.xml index f9ca035f..a0385647 100644 --- a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/pom.xml +++ b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/pom.xml @@ -33,6 +33,41 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modb + package + + jar + + + ${project.build.outputDirectory}/modb + modb + + + + modc + package + + jar + + + ${project.build.outputDirectory}/modc + modc + + + + diff --git a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/run.sh b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/run.sh index 510d6d11..ded6852c 100755 --- a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/run.sh +++ b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/run.sh @@ -38,35 +38,35 @@ echo "Checking variants of reflective access to java.base/jdk.internal.math.Doub echo echo "1 - reflective call without any options" echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseJDKInternal 2>&1 | normalize | tee "${result_dir}/run.txt" | myecho; then +if "${JAVA_HOME}/bin/java" --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseJDKInternal 2>&1 | normalize | tee "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 1 - Expected exception but command succeeded" exit 1 fi echo echo "2 - reflective call with --illegal-access=permit" echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=permit --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseJDKInternal 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if "${JAVA_HOME}/bin/java" --illegal-access=permit --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseJDKInternal 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 2 - Expected exception but command succeeded" exit 1 fi echo echo "3 - reflective call with --illegal-access=warn" echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=warn --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseJDKInternal 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if "${JAVA_HOME}/bin/java" --illegal-access=warn --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseJDKInternal 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 3 - Expected exception but command succeeded" exit 1 fi echo echo "4 - reflective call with --illegal-access=deny" echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=deny --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseJDKInternal 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if "${JAVA_HOME}/bin/java" --illegal-access=deny --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseJDKInternal 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 4 - Expected exception but command succeeded" exit 1 fi echo echo "5 - reflective call with explicit --add-opens" echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --add-opens=java.base/jdk.internal.math=ALL-UNNAMED --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseJDKInternal 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if ! "${JAVA_HOME}/bin/java" --add-opens=java.base/jdk.internal.math=ALL-UNNAMED --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseJDKInternal 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 5 - Expected success but got exception" exit 1 fi @@ -86,28 +86,28 @@ echo "Checking variants of reflective access to java.base/sun.net.PortConfig. It echo echo "6 - reflective call without any options" echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if ! "${JAVA_HOME}/bin/java" --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 6 - Expected success but got exception" exit 1 fi echo echo "7 - reflective call with --illegal-access=permit" echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --illegal-access=permit --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if ! "${JAVA_HOME}/bin/java" --illegal-access=permit --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 7 - Expected success but got exception" exit 1 fi echo echo "8 - reflective call with --illegal-access=warn" echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --illegal-access=warn --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if ! "${JAVA_HOME}/bin/java" --illegal-access=warn --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 8 - Expected success but got exception" exit 1 fi echo echo "9 - reflective call with --illegal-access=deny" echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=deny --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if "${JAVA_HOME}/bin/java" --illegal-access=deny --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 9 - Expected exception but command succeeded" exit 1 fi @@ -115,7 +115,7 @@ fi echo echo "10 - reflective call with explicit --add-opens" echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --add-opens=java.base/sun.net=ALL-UNNAMED --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if ! "${JAVA_HOME}/bin/java" --add-opens=java.base/sun.net=ALL-UNNAMED --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaBaseSunNet 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 10 - Expected success but got exception" exit 1 fi @@ -135,35 +135,35 @@ echo "Checking variants of reflective access to java.desktop/com.sun.java.swing. echo echo "11 - reflective call without any options" echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if ! "${JAVA_HOME}/bin/java" --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 11 - Expected success but got exception" exit 1 fi echo echo "12 - reflective call with --illegal-access=permit" echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --illegal-access=permit --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if ! "${JAVA_HOME}/bin/java" --illegal-access=permit --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 12 - Expected success but got exception" exit 1 fi echo echo "13 - reflective call with --illegal-access=warn" echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --illegal-access=warn --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if ! "${JAVA_HOME}/bin/java" --illegal-access=warn --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 13 - Expected success but got exception" exit 1 fi echo echo "14 - reflective call with --illegal-access=deny" echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=deny --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if "${JAVA_HOME}/bin/java" --illegal-access=deny --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 14 - Expected exception but command succeeded" exit 1 fi echo echo "15 - reflective call with explicit --add-opens" echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --add-opens=java.desktop/com.sun.java.swing.plaf.nimbus=ALL-UNNAMED --module-path mlib -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if ! "${JAVA_HOME}/bin/java" --add-opens=java.desktop/com.sun.java.swing.plaf.nimbus=ALL-UNNAMED --module-path target -cp cplib/cpmain.jar pkgcpmain.MainCallingJavaDesktop 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 15 - Expected success but got exception" exit 1 fi @@ -186,35 +186,35 @@ echo " class pkgbexportedqualified.BFromModuleButExportedQualified is exporte echo echo "16 - reflective call without any options" echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --module-path mlib -cp cplib/cpmain.jar --add-modules modb pkgcpmain.MainCallingModB 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if "${JAVA_HOME}/bin/java" --module-path target -cp cplib/cpmain.jar --add-modules modb pkgcpmain.MainCallingModB 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 16 - Expected exception but command succeeded" exit 1 fi echo echo "17 - reflective call with --illegal-access=permit" echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=permit --module-path mlib -cp cplib/cpmain.jar --add-modules modb pkgcpmain.MainCallingModB 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if "${JAVA_HOME}/bin/java" --illegal-access=permit --module-path target -cp cplib/cpmain.jar --add-modules modb pkgcpmain.MainCallingModB 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 17 - Expected exception but command succeeded" exit 1 fi echo echo "18 - reflective call with --illegal-access=warn" echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=warn --module-path mlib -cp cplib/cpmain.jar --add-modules modb pkgcpmain.MainCallingModB 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if "${JAVA_HOME}/bin/java" --illegal-access=warn --module-path target -cp cplib/cpmain.jar --add-modules modb pkgcpmain.MainCallingModB 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 18 - Expected exception but command succeeded" exit 1 fi echo echo "19 - reflective call with --illegal-access=deny" echo "Should throw InaccessibleObjectException" -if "${JAVA_HOME}/bin/java" --illegal-access=deny --module-path mlib -cp cplib/cpmain.jar --add-modules modb pkgcpmain.MainCallingModB 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if "${JAVA_HOME}/bin/java" --illegal-access=deny --module-path target -cp cplib/cpmain.jar --add-modules modb pkgcpmain.MainCallingModB 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 19 - Expected exception but command succeeded" exit 1 fi echo echo "20 - reflective call with explicit --add-opens" echo "Should work without problems" -if ! "${JAVA_HOME}/bin/java" --add-opens=modb/pkgbinternal=ALL-UNNAMED --add-opens modb/pkgbexportedqualified=ALL-UNNAMED --module-path mlib -cp cplib/cpmain.jar --add-modules modb pkgcpmain.MainCallingModB 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then +if ! "${JAVA_HOME}/bin/java" --add-opens=modb/pkgbinternal=ALL-UNNAMED --add-opens modb/pkgbexportedqualified=ALL-UNNAMED --module-path target -cp cplib/cpmain.jar --add-modules modb pkgcpmain.MainCallingModB 2>&1 | normalize | tee -a "${result_dir}/run.txt" | myecho; then echo "ERROR: Variant 20 - Expected success but got exception" exit 1 fi diff --git a/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/clean.sh b/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/clean.sh index 267a2a8e..4a3cfa2f 100755 --- a/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/clean.sh +++ b/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/clean.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf classes rm -rf cplib rm -rf run-result diff --git a/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/compile.sh b/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/compile.sh index d180b42c..0253fa35 100755 --- a/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/compile.sh +++ b/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/compile.sh @@ -28,7 +28,6 @@ export PATH="${M4_HOME}/bin:${PATH}" mkdir -p cplib mkdir -p classes/cpb -mkdir -p mlib echo "=== Hybrid Compilation for Maven 4 ===" echo @@ -52,23 +51,11 @@ echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" echo "(Compiler args: --add-reads modmain=ALL-UNNAMED --class-path cplib/cpb.jar)" -mvn clean compile +mvn clean package -# Create JARs directly to mlib (similar to original compile.sh) -echo -echo "Step 3: Package modules as JARs in mlib/" -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar ${JAR_OPTIONS} --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" ${JAR_OPTIONS} --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 echo echo "βœ… Hybrid compilation complete" diff --git a/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/pom.xml b/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/pom.xml index 4d56e297..d386e642 100644 --- a/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/pom.xml +++ b/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/pom.xml @@ -41,6 +41,41 @@ + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modb + package + + jar + + + ${project.build.outputDirectory}/modb + modb + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/run.sh b/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/run.sh index c46b0059..c7598989 100755 --- a/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/run.sh +++ b/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/run.sh @@ -15,7 +15,7 @@ mkdir -p run-result # Run the Java code with modules on module-path and classpath code on classpath # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} \ - --module-path mlib \ + --module-path target \ --class-path cplib/cpb.jar \ --module modmain/pkgmain.Main \ 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/clean.sh b/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/clean.sh index 267a2a8e..4a3cfa2f 100755 --- a/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/clean.sh +++ b/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/clean.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf classes rm -rf cplib rm -rf run-result diff --git a/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/compile.sh b/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/compile.sh index 00336bef..dc432336 100755 --- a/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/compile.sh +++ b/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/compile.sh @@ -20,7 +20,6 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib mkdir -p cplib mkdir -p classes @@ -56,18 +55,8 @@ echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" echo "(Modules can access cpb on classpath via --add-reads modmain=ALL-UNNAMED)" -mvn clean compile +mvn clean package -# Create JARs for modules -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 diff --git a/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/pom.xml b/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/pom.xml index abc04fe0..f4552dc9 100644 --- a/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/pom.xml +++ b/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/pom.xml @@ -40,6 +40,41 @@ + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modb + package + + jar + + + ${project.build.outputDirectory}/modb + modb + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/run.sh b/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/run.sh index a81eac60..e7a8c3b0 100755 --- a/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/run.sh +++ b/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/run.sh @@ -15,7 +15,7 @@ mkdir -p run-result # Run the Java code with cpb on classpath, save output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} \ - --module-path mlib \ + --module-path target \ --class-path cplib/cpb.jar \ --module modmain/pkgmain.Main \ 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/clean.sh b/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/clean.sh index 267a2a8e..4a3cfa2f 100755 --- a/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/clean.sh +++ b/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/clean.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf classes rm -rf cplib rm -rf run-result diff --git a/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/compile.sh b/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/compile.sh index b8d19d17..44525812 100755 --- a/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/compile.sh +++ b/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/compile.sh @@ -20,7 +20,6 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib mkdir -p cplib mkdir -p classes/cpb @@ -33,20 +32,9 @@ echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JAR for modb -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +mvn clean package # Step 2: Compile classpath code (cpb, cpmain) manually # Maven's Module Source Hierarchy cannot handle this, so we compile it manually @@ -64,9 +52,9 @@ fi pushd ../src > /dev/null 2>&1 for dir in cpb cpmain; do - echo "javac ${JAVAC_OPTIONS} -cp ../m4/mlib/*${PATH_SEPARATOR}../m4/classes/cpb -d ../m4/classes/${dir} --release 11 \$(find ${dir} -name \"*.java\")" + echo "javac ${JAVAC_OPTIONS} -cp ../m4/target/*${PATH_SEPARATOR}../m4/classes/cpb -d ../m4/classes/${dir} --release 11 \$(find ${dir} -name \"*.java\")" # shellcheck disable=SC2046,SC2086 # JAVAC_OPTIONS is intentionally unquoted for word splitting, the find command is intended to be expanded - "${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -cp ../m4/mlib/*"${PATH_SEPARATOR}"../m4/classes/cpb -d ../m4/classes/${dir} --release 11 $(find ${dir} -name "*.java") 2>&1 + "${COMPILE_JAVA_HOME}/bin/javac" ${JAVAC_OPTIONS} -cp ../m4/target/*"${PATH_SEPARATOR}"../m4/classes/cpb -d ../m4/classes/${dir} --release 11 $(find ${dir} -name "*.java") 2>&1 echo "jar $JAR_OPTIONS --create --file=../m4/cplib/${dir}.jar -C ../m4/classes/${dir} ." # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting diff --git a/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/pom.xml b/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/pom.xml index aae0b615..3f1d5dc1 100644 --- a/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/pom.xml +++ b/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/pom.xml @@ -29,6 +29,30 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modb + package + + jar + + + ${project.build.outputDirectory}/modb + modb + + + + diff --git a/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/run.sh b/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/run.sh index c7dba101..1d90ea82 100755 --- a/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/run.sh +++ b/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/run.sh @@ -16,7 +16,7 @@ mkdir -p run-result # --add-modules modb makes the module available even though not required # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting "${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} \ - --module-path mlib \ + --module-path target \ --class-path cplib/cpmain.jar"${PATH_SEPARATOR}"cplib/cpb.jar \ --add-modules modb pkgcpmain.Main \ 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_uses-provides/m4/.gitignore b/jigsaw-examples/example_uses-provides/m4/.gitignore index 25275013..52aee332 100644 --- a/jigsaw-examples/example_uses-provides/m4/.gitignore +++ b/jigsaw-examples/example_uses-provides/m4/.gitignore @@ -1,3 +1,2 @@ target/ -mlib/ run-result/ diff --git a/jigsaw-examples/example_uses-provides/m4/clean.sh b/jigsaw-examples/example_uses-provides/m4/clean.sh index 94f380eb..d7faaade 100755 --- a/jigsaw-examples/example_uses-provides/m4/clean.sh +++ b/jigsaw-examples/example_uses-provides/m4/clean.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_uses-provides/m4/compile.sh b/jigsaw-examples/example_uses-provides/m4/compile.sh index f872668c..3d6b7cb8 100755 --- a/jigsaw-examples/example_uses-provides/m4/compile.sh +++ b/jigsaw-examples/example_uses-provides/m4/compile.sh @@ -20,23 +20,12 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +mvn clean package + diff --git a/jigsaw-examples/example_uses-provides/m4/pom.xml b/jigsaw-examples/example_uses-provides/m4/pom.xml index bfb9e5d4..bfa89beb 100644 --- a/jigsaw-examples/example_uses-provides/m4/pom.xml +++ b/jigsaw-examples/example_uses-provides/m4/pom.xml @@ -40,6 +40,63 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + modservice.impl.com + package + + jar + + + ${project.build.outputDirectory}/modservice.impl.com + modservice.impl.com + + + + modservice.impl.net + package + + jar + + + ${project.build.outputDirectory}/modservice.impl.net + modservice.impl.net + + + + modservicedefinition + package + + jar + + + ${project.build.outputDirectory}/modservicedefinition + modservicedefinition + + + + diff --git a/jigsaw-examples/example_uses-provides/m4/run.sh b/jigsaw-examples/example_uses-provides/m4/run.sh index f17cda9b..fa508d91 100755 --- a/jigsaw-examples/example_uses-provides/m4/run.sh +++ b/jigsaw-examples/example_uses-provides/m4/run.sh @@ -14,4 +14,4 @@ mkdir -p run-result # Run the Java code, save output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_uses-provides_uses-in-client/m4/.gitignore b/jigsaw-examples/example_uses-provides_uses-in-client/m4/.gitignore index 25275013..52aee332 100644 --- a/jigsaw-examples/example_uses-provides_uses-in-client/m4/.gitignore +++ b/jigsaw-examples/example_uses-provides_uses-in-client/m4/.gitignore @@ -1,3 +1,2 @@ target/ -mlib/ run-result/ diff --git a/jigsaw-examples/example_uses-provides_uses-in-client/m4/clean.sh b/jigsaw-examples/example_uses-provides_uses-in-client/m4/clean.sh index 94f380eb..d7faaade 100755 --- a/jigsaw-examples/example_uses-provides_uses-in-client/m4/clean.sh +++ b/jigsaw-examples/example_uses-provides_uses-in-client/m4/clean.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_uses-provides_uses-in-client/m4/compile.sh b/jigsaw-examples/example_uses-provides_uses-in-client/m4/compile.sh index f872668c..3d6b7cb8 100755 --- a/jigsaw-examples/example_uses-provides_uses-in-client/m4/compile.sh +++ b/jigsaw-examples/example_uses-provides_uses-in-client/m4/compile.sh @@ -20,23 +20,12 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +mvn clean package + diff --git a/jigsaw-examples/example_uses-provides_uses-in-client/m4/pom.xml b/jigsaw-examples/example_uses-provides_uses-in-client/m4/pom.xml index d14d9182..b47191f8 100644 --- a/jigsaw-examples/example_uses-provides_uses-in-client/m4/pom.xml +++ b/jigsaw-examples/example_uses-provides_uses-in-client/m4/pom.xml @@ -40,6 +40,63 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + modservice.impl.com + package + + jar + + + ${project.build.outputDirectory}/modservice.impl.com + modservice.impl.com + + + + modservice.impl.net + package + + jar + + + ${project.build.outputDirectory}/modservice.impl.net + modservice.impl.net + + + + modservicedefinition + package + + jar + + + ${project.build.outputDirectory}/modservicedefinition + modservicedefinition + + + + diff --git a/jigsaw-examples/example_uses-provides_uses-in-client/m4/run.sh b/jigsaw-examples/example_uses-provides_uses-in-client/m4/run.sh index f17cda9b..fa508d91 100755 --- a/jigsaw-examples/example_uses-provides_uses-in-client/m4/run.sh +++ b/jigsaw-examples/example_uses-provides_uses-in-client/m4/run.sh @@ -14,4 +14,4 @@ mkdir -p run-result # Run the Java code, save output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho +"${JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_version/m4/.gitignore b/jigsaw-examples/example_version/m4/.gitignore index 25275013..52aee332 100644 --- a/jigsaw-examples/example_version/m4/.gitignore +++ b/jigsaw-examples/example_version/m4/.gitignore @@ -1,3 +1,2 @@ target/ -mlib/ run-result/ diff --git a/jigsaw-examples/example_version/m4/clean.sh b/jigsaw-examples/example_version/m4/clean.sh index 94f380eb..d7faaade 100755 --- a/jigsaw-examples/example_version/m4/clean.sh +++ b/jigsaw-examples/example_version/m4/clean.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash rm -rf target -rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_version/m4/compile.sh b/jigsaw-examples/example_version/m4/compile.sh index f872668c..3d6b7cb8 100755 --- a/jigsaw-examples/example_version/m4/compile.sh +++ b/jigsaw-examples/example_version/m4/compile.sh @@ -20,23 +20,12 @@ fi # Add Maven 4 to PATH export PATH="${M4_HOME}/bin:${PATH}" -mkdir -p mlib echo "mvn --version" mvn --version echo -echo "mvn clean compile" +echo "mvn clean package" echo "(Maven runs with JDK 17, compiles for Java 11 via maven.compiler.release)" -mvn clean compile - -# Create JARs directly to mlib (similar to original compile.sh) -pushd target/classes > /dev/null 2>&1 -for dir in */; -do - MODDIR=${dir%*/} - echo "jar $JAR_OPTIONS --create --file=../../mlib/${MODDIR}.jar -C ${MODDIR} ." - # shellcheck disable=SC2086 # JAR_OPTIONS is intentionally unquoted for word splitting - "${JAVA_HOME}/bin/jar" $JAR_OPTIONS --create --file="../../mlib/${MODDIR}.jar" -C "${MODDIR}" . 2>&1 -done -popd >/dev/null 2>&1 +mvn clean package + diff --git a/jigsaw-examples/example_version/m4/pom.xml b/jigsaw-examples/example_version/m4/pom.xml index a326c096..3ddecbc9 100644 --- a/jigsaw-examples/example_version/m4/pom.xml +++ b/jigsaw-examples/example_version/m4/pom.xml @@ -28,6 +28,30 @@ maven-compiler-plugin 4.0.0-beta-3 + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + default-jar + none + + + + modmain + package + + jar + + + ${project.build.outputDirectory}/modmain + modmain + + + + diff --git a/jigsaw-examples/example_version/m4/run.sh b/jigsaw-examples/example_version/m4/run.sh index ca62daff..f7f36bc5 100755 --- a/jigsaw-examples/example_version/m4/run.sh +++ b/jigsaw-examples/example_version/m4/run.sh @@ -17,4 +17,4 @@ mkdir -p run-result # Run the Java code, save output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting -"${RUNTIME_JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path mlib --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho +"${RUNTIME_JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main 2>&1 | normalize | tee run-result/run.txt | myecho From 4e5bf6eb36c22ff6aeb457fae1b30e4ff2b08a71 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Thu, 13 Nov 2025 16:22:39 +0100 Subject: [PATCH 04/15] Fix Windows symlinks for dynamic module loading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add two-part solution to handle mlibβ†’target symlinks on Windows: 1. Enable symlink checkout in GitHub Actions 2. Recreate symlinks in compile.sh after target/ exists The Problem: On Windows, Git stores symlinks differently than Unix, and Java's ModuleLayer API fails when loading modules through symlinks with: java.nio.file.AccessDeniedException: .../m4/mlib Root Cause: - Git on Windows checks out symlinks before target directory exists - Even with symlinks:true in actions/checkout@v4, Windows creates symlinks that Java cannot traverse when target doesn't exist yet - The target/ directory is only created during Maven compilation The Solution (two parts): Part 1 - GitHub Actions (.github/workflows/build.yml): Add symlinks:true parameter to actions/checkout@v4 in both build-legacy and build-m4 jobs to enable proper symlink checkout on Windows. Part 2 - Compile Scripts (*/m4/compile.sh): Recreate mlibβ†’target symlinks after ensuring target/ exists: mkdir -p target if [ -L mlib ] && [ ! -e mlib ]; then rm mlib # Remove broken symlink fi if [ ! -e mlib ]; then ln -s target mlib # Create valid symlink fi This ensures: - Unix systems use committed symlinks (work even if target missing) - Windows gets valid symlinks recreated after target/ exists - Both platforms can run Java code that uses ModuleLayer API Affected files: - .github/workflows/build.yml (checkout configuration) - example_layer-hierarchy/m4/compile.sh - example_layer-modules-grouped-in-hierarchy/m4/compile.sh - example_layer-modules-module-resolution/m4/compile.sh - example_patch/m4/compile.sh All four examples use ModuleLayer API to dynamically load modules from the mlib symlink at runtime. πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Introduced in the course of support-and-care/maven-support-and-care#137 --- .github/workflows/build.yml | 4 ++++ .../example_layer-hierarchy/m4/compile.sh | 12 ++++++++++-- .../m4/compile.sh | 13 +++++++++++-- .../m4/compile.sh | 12 ++++++++++++ jigsaw-examples/example_patch/m4/compile.sh | 13 +++++++++++-- 5 files changed, 48 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 08e08ea5..c6518dc9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,6 +39,8 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + with: + symlinks: true - name: Set up JDK 8 (non macOS) id: setup-jdk8 @@ -189,6 +191,8 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + with: + symlinks: true - name: Set up JDK 11 id: setup-jdk11 diff --git a/jigsaw-examples/example_layer-hierarchy/m4/compile.sh b/jigsaw-examples/example_layer-hierarchy/m4/compile.sh index 8b4db4b3..b05d6967 100755 --- a/jigsaw-examples/example_layer-hierarchy/m4/compile.sh +++ b/jigsaw-examples/example_layer-hierarchy/m4/compile.sh @@ -19,8 +19,16 @@ export PATH="${M4_HOME}/bin:${PATH}" mkdir -p target/classes -# Note: mlib β†’ target symlink is committed to Git for dynamic module loading -# (Java code uses path + "/mlib" to load modules at runtime) +# Ensure mlib β†’ target symlink exists and is valid +# (Committed symlink works on Unix, but Windows needs it recreated after target/ exists) +if [ -L mlib ] && [ ! -e mlib ]; then + # Broken symlink (target doesn't exist yet), remove it + rm mlib +fi +if [ ! -e mlib ]; then + # Create symlink (or recreate if it was broken) + ln -s target mlib +fi # Step 1: Use Maven to download dependencies to amlib echo "=== Step 1: Download dependencies with Maven ===" diff --git a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/compile.sh b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/compile.sh index dc6335b3..cc7a6165 100755 --- a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/compile.sh +++ b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/compile.sh @@ -30,8 +30,17 @@ mkdir -p amlib1 mkdir -p amlib2 mkdir -p classes -# Note: mlib β†’ target symlink is committed to Git for dynamic module loading -# (Java code uses path + "/mlib" to load modules at runtime) +# Ensure mlib β†’ target symlink exists and is valid +# (Committed symlink works on Unix, but Windows needs it recreated after target/ exists) +mkdir -p target +if [ -L mlib ] && [ ! -e mlib ]; then + # Broken symlink (target doesn't exist yet), remove it + rm mlib +fi +if [ ! -e mlib ]; then + # Create symlink (or recreate if it was broken) + ln -s target mlib +fi echo "=== Hybrid Compilation for Maven 4 ===" echo diff --git a/jigsaw-examples/example_layer-modules-module-resolution/m4/compile.sh b/jigsaw-examples/example_layer-modules-module-resolution/m4/compile.sh index 9082cfeb..d6929e78 100755 --- a/jigsaw-examples/example_layer-modules-module-resolution/m4/compile.sh +++ b/jigsaw-examples/example_layer-modules-module-resolution/m4/compile.sh @@ -23,6 +23,18 @@ export PATH="${M4_HOME}/bin:${PATH}" mkdir -p foomlib mkdir -p barmlib +# Ensure mlib β†’ target symlink exists and is valid +# (Committed symlink works on Unix, but Windows needs it recreated after target/ exists) +mkdir -p target +if [ -L mlib ] && [ ! -e mlib ]; then + # Broken symlink (target doesn't exist yet), remove it + rm mlib +fi +if [ ! -e mlib ]; then + # Create symlink (or recreate if it was broken) + ln -s target mlib +fi + echo "mvn --version" mvn --version echo diff --git a/jigsaw-examples/example_patch/m4/compile.sh b/jigsaw-examples/example_patch/m4/compile.sh index edc41c18..b50b6db8 100755 --- a/jigsaw-examples/example_patch/m4/compile.sh +++ b/jigsaw-examples/example_patch/m4/compile.sh @@ -21,8 +21,17 @@ export PATH="${M4_HOME}/bin:${PATH}" mkdir -p patches mkdir -p patchlib -# Note: mlib β†’ target symlink is committed to Git for module-path compatibility -# (Allows running from IDE without executing compile.sh) +# Ensure mlib β†’ target symlink exists and is valid +# (Committed symlink works on Unix, but Windows needs it recreated after target/ exists) +mkdir -p target +if [ -L mlib ] && [ ! -e mlib ]; then + # Broken symlink (target doesn't exist yet), remove it + rm mlib +fi +if [ ! -e mlib ]; then + # Create symlink (or recreate if it was broken) + ln -s target mlib +fi echo "=== Step 1: Compile modules modmain and modb with Maven 4 ====" echo From e02405c9cef91c7f3c7ed8d95c931beb4d9bb40a Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Thu, 13 Nov 2025 17:29:49 +0100 Subject: [PATCH 05/15] Move mlib symlink creation from compile.sh to run.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move symlink validation/creation from compile.sh to run.sh to ensure it happens after Maven compilation completes. The Problem: Previously, compile.sh created the mlibβ†’target symlink early, but then Maven's "mvn clean package" deleted target/, breaking the symlink on Windows. Even though we recreated it, Maven's clean goal invalidated it. The Solution: Move symlink creation to run.sh where it's actually needed: 1. compile.sh runs Maven compilation (which may delete/recreate target/) 2. run.sh validates and recreates mlibβ†’target symlink if needed 3. Java code then uses the symlink to load modules via ModuleLayer API This ensures the symlink points to a fully populated target/ directory. Changes in all four examples: - compile.sh: Remove symlink creation, add note that run.sh handles it - run.sh: Add symlink validation/recreation before running Java code Affected examples: - example_layer-hierarchy/m4 - example_layer-modules-grouped-in-hierarchy/m4 - example_layer-modules-module-resolution/m4 - example_patch/m4 πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Introduced in the course of support-and-care/maven-support-and-care#137 --- .../example_layer-hierarchy/m4/compile.sh | 12 ++---------- jigsaw-examples/example_layer-hierarchy/m4/run.sh | 11 +++++++++++ .../m4/compile.sh | 13 ++----------- .../m4/run.sh | 11 +++++++++++ .../m4/compile.sh | 13 ++----------- .../m4/run.sh | 11 +++++++++++ jigsaw-examples/example_patch/m4/compile.sh | 13 ++----------- jigsaw-examples/example_patch/m4/run.sh | 11 +++++++++++ 8 files changed, 52 insertions(+), 43 deletions(-) diff --git a/jigsaw-examples/example_layer-hierarchy/m4/compile.sh b/jigsaw-examples/example_layer-hierarchy/m4/compile.sh index b05d6967..e371f30b 100755 --- a/jigsaw-examples/example_layer-hierarchy/m4/compile.sh +++ b/jigsaw-examples/example_layer-hierarchy/m4/compile.sh @@ -19,16 +19,8 @@ export PATH="${M4_HOME}/bin:${PATH}" mkdir -p target/classes -# Ensure mlib β†’ target symlink exists and is valid -# (Committed symlink works on Unix, but Windows needs it recreated after target/ exists) -if [ -L mlib ] && [ ! -e mlib ]; then - # Broken symlink (target doesn't exist yet), remove it - rm mlib -fi -if [ ! -e mlib ]; then - # Create symlink (or recreate if it was broken) - ln -s target mlib -fi +# Note: mlib β†’ target symlink is committed to Git +# It will be validated/recreated in run.sh after Maven compilation completes # Step 1: Use Maven to download dependencies to amlib echo "=== Step 1: Download dependencies with Maven ===" diff --git a/jigsaw-examples/example_layer-hierarchy/m4/run.sh b/jigsaw-examples/example_layer-hierarchy/m4/run.sh index 8d4e31cb..62e00f60 100755 --- a/jigsaw-examples/example_layer-hierarchy/m4/run.sh +++ b/jigsaw-examples/example_layer-hierarchy/m4/run.sh @@ -13,6 +13,17 @@ fi # Create run-result directory if it doesn't exist mkdir -p run-result +# Ensure mlib β†’ target symlink exists and is valid +# (Java code uses ModuleLayer API to load modules from path + "/mlib") +if [ -L mlib ] && [ ! -e mlib ]; then + # Broken symlink, remove it + rm mlib +fi +if [ ! -e mlib ]; then + # Create symlink (target/ should exist from compile.sh) + ln -s target mlib +fi + echo "Using Java version:" "${JAVA11_HOME}/bin/java" -version echo diff --git a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/compile.sh b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/compile.sh index cc7a6165..c8b99f30 100755 --- a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/compile.sh +++ b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/compile.sh @@ -30,17 +30,8 @@ mkdir -p amlib1 mkdir -p amlib2 mkdir -p classes -# Ensure mlib β†’ target symlink exists and is valid -# (Committed symlink works on Unix, but Windows needs it recreated after target/ exists) -mkdir -p target -if [ -L mlib ] && [ ! -e mlib ]; then - # Broken symlink (target doesn't exist yet), remove it - rm mlib -fi -if [ ! -e mlib ]; then - # Create symlink (or recreate if it was broken) - ln -s target mlib -fi +# Note: mlib β†’ target symlink is committed to Git +# It will be validated/recreated in run.sh after Maven compilation completes echo "=== Hybrid Compilation for Maven 4 ===" echo diff --git a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/run.sh b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/run.sh index 91c2255d..0d469319 100755 --- a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/run.sh +++ b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/run.sh @@ -24,6 +24,17 @@ echo # Create run-result directory if it doesn't exist mkdir -p run-result +# Ensure mlib β†’ target symlink exists and is valid +# (Java code uses ModuleLayer API to load modules from mlib/) +if [ -L mlib ] && [ ! -e mlib ]; then + # Broken symlink, remove it + rm mlib +fi +if [ ! -e mlib ]; then + # Create symlink (target/ should exist from compile.sh) + ln -s target mlib +fi + # Run the Java code with mlib on module-path # Note: Automatic modules are not needed at runtime for this example # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting diff --git a/jigsaw-examples/example_layer-modules-module-resolution/m4/compile.sh b/jigsaw-examples/example_layer-modules-module-resolution/m4/compile.sh index d6929e78..17bf2665 100755 --- a/jigsaw-examples/example_layer-modules-module-resolution/m4/compile.sh +++ b/jigsaw-examples/example_layer-modules-module-resolution/m4/compile.sh @@ -23,17 +23,8 @@ export PATH="${M4_HOME}/bin:${PATH}" mkdir -p foomlib mkdir -p barmlib -# Ensure mlib β†’ target symlink exists and is valid -# (Committed symlink works on Unix, but Windows needs it recreated after target/ exists) -mkdir -p target -if [ -L mlib ] && [ ! -e mlib ]; then - # Broken symlink (target doesn't exist yet), remove it - rm mlib -fi -if [ ! -e mlib ]; then - # Create symlink (or recreate if it was broken) - ln -s target mlib -fi +# Note: mlib β†’ target symlink is committed to Git +# It will be validated/recreated in run.sh after Maven compilation completes echo "mvn --version" mvn --version diff --git a/jigsaw-examples/example_layer-modules-module-resolution/m4/run.sh b/jigsaw-examples/example_layer-modules-module-resolution/m4/run.sh index e3a02a93..d778fdf7 100755 --- a/jigsaw-examples/example_layer-modules-module-resolution/m4/run.sh +++ b/jigsaw-examples/example_layer-modules-module-resolution/m4/run.sh @@ -15,6 +15,17 @@ echo # Create run-result directory if it doesn't exist mkdir -p run-result +# Ensure mlib β†’ target symlink exists and is valid +# (Java code uses ModuleLayer API to load modules from mlib/) +if [ -L mlib ] && [ ! -e mlib ]; then + # Broken symlink, remove it + rm mlib +fi +if [ ! -e mlib ]; then + # Create symlink (target/ should exist from compile.sh) + ln -s target mlib +fi + # Run the Java code with "." argument for dynamic layer creation, save output to run-result/run.txt, and display with highlighting # shellcheck disable=SC2086 # JAVA_OPTIONS is intentionally unquoted for word splitting "${RUNTIME_JAVA_HOME}/bin/java" ${JAVA_OPTIONS} --module-path target --module modmain/pkgmain.Main . 2>&1 | normalize | tee run-result/run.txt | myecho diff --git a/jigsaw-examples/example_patch/m4/compile.sh b/jigsaw-examples/example_patch/m4/compile.sh index b50b6db8..51abae87 100755 --- a/jigsaw-examples/example_patch/m4/compile.sh +++ b/jigsaw-examples/example_patch/m4/compile.sh @@ -21,17 +21,8 @@ export PATH="${M4_HOME}/bin:${PATH}" mkdir -p patches mkdir -p patchlib -# Ensure mlib β†’ target symlink exists and is valid -# (Committed symlink works on Unix, but Windows needs it recreated after target/ exists) -mkdir -p target -if [ -L mlib ] && [ ! -e mlib ]; then - # Broken symlink (target doesn't exist yet), remove it - rm mlib -fi -if [ ! -e mlib ]; then - # Create symlink (or recreate if it was broken) - ln -s target mlib -fi +# Note: mlib β†’ target symlink is committed to Git +# It will be validated/recreated in run.sh after Maven compilation completes echo "=== Step 1: Compile modules modmain and modb with Maven 4 ====" echo diff --git a/jigsaw-examples/example_patch/m4/run.sh b/jigsaw-examples/example_patch/m4/run.sh index fc533c58..d8a72950 100755 --- a/jigsaw-examples/example_patch/m4/run.sh +++ b/jigsaw-examples/example_patch/m4/run.sh @@ -9,6 +9,17 @@ result_dir="${1:-run-result}" rm -rf "${result_dir}" mkdir -p "${result_dir}" +# Ensure mlib β†’ target symlink exists and is valid +# (Needed for --module-path mlib after Maven compilation) +if [ -L mlib ] && [ ! -e mlib ]; then + # Broken symlink, remove it + rm mlib +fi +if [ ! -e mlib ]; then + # Create symlink (target/ should exist from compile.sh) + ln -s target mlib +fi + # Show Java version for user information echo "Using Java version:" "${JAVA_HOME}/bin/java" -version From 1755e0e6dbd787ed86cc5ef75a473a7df6fb98f1 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Thu, 13 Nov 2025 17:58:48 +0100 Subject: [PATCH 06/15] Replace Windows symlinks with JAR copying for mlib MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement OS-conditional approach for mlib directory to avoid Windows symlink issues with Java's ModuleLayer API. The Problem: On Windows, Java's ModuleLayer API fails when traversing symlinks with AccessDeniedException. The root cause is Windows symlink semantics differ from Unix, particularly when Java traverses symlinks. The Solution: Use OS-conditional logic in run.sh (detected via ${OS:-$(uname)} = "Windows_NT"): Unix/macOS: - Keep committed mlibβ†’target symlink - test -h mlib || ln -sfn target mlib (only create if missing) - clean.sh preserves the symlink Windows: - Replace Git-checked-out symlink with directory - test -d mlib || rm -f mlib (remove symlink if present) - Copy JARs from target/ to mlib/ - clean.sh removes the directory This approach: - Preserves committed symlink on Unix (major development platform) - Provides directory with copied JARs on Windows (CI platform) - Minimal overhead (only copies on Windows) - Same functionality on both platforms Implementation: 1. Update run.sh: OS-conditional mlib creation 2. Update clean.sh: Only remove mlib on Windows 3. Update .gitignore: Add /mlib (ignored on Windows) 4. Update READMEs: Document OS-conditional approach using description lists Affected examples (all use ModuleLayer API for dynamic module loading): - example_layer-hierarchy/m4 - example_layer-modules-grouped-in-hierarchy/m4 - example_layer-modules-module-resolution/m4 - example_patch/m4 πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Introduced in the course of support-and-care/maven-support-and-care#137 --- .../example_layer-hierarchy/README.adoc | 22 ++++------ .../example_layer-hierarchy/m4/.gitignore | 3 +- .../example_layer-hierarchy/m4/clean.sh | 3 ++ .../example_layer-hierarchy/m4/run.sh | 23 ++++++---- .../README.adoc | 22 ++++------ .../m4/clean.sh | 3 ++ .../m4/run.sh | 23 ++++++---- .../README.adoc | 3 ++ .../m4/clean.sh | 3 ++ .../m4/run.sh | 23 ++++++---- jigsaw-examples/example_patch/README.adoc | 43 +++++++++---------- jigsaw-examples/example_patch/m4/.gitignore | 3 ++ jigsaw-examples/example_patch/m4/clean.sh | 3 ++ jigsaw-examples/example_patch/m4/run.sh | 23 ++++++---- 14 files changed, 113 insertions(+), 87 deletions(-) diff --git a/jigsaw-examples/example_layer-hierarchy/README.adoc b/jigsaw-examples/example_layer-hierarchy/README.adoc index ca65c800..d521f2f5 100644 --- a/jigsaw-examples/example_layer-hierarchy/README.adoc +++ b/jigsaw-examples/example_layer-hierarchy/README.adoc @@ -221,7 +221,7 @@ The automatic module `javax.json` is downloaded via `maven-dependency-plugin` to ---- -*Dynamic module loading symlink:* +*Dynamic module loading via mlib:* The Java code in `mod.main/pkgmain/Main.java` uses the `ModuleLayer` API to dynamically load modules at runtime from a hardcoded path: @@ -230,24 +230,18 @@ The Java code in `mod.main/pkgmain/Main.java` uses the `ModuleLayer` API to dyna layerBuilder.createJigsawLayers(LayerHierarchy.root, LayerHierarchy.root.getLayer(), path + "/mlib"); ---- -Since Maven (4) creates JARs in the `target/` directory (not `mlib/`), but the shared source code still references `mlib`, the migration uses a committed symbolic link: +Since Maven (4) creates JARs in the `target/` directory (not `mlib/`), but the shared source code still references `mlib`, the `run.sh` script creates `mlib` using OS-specific approaches: -[source,bash] ----- -m4/mlib -> target ----- - -This symlink: +Unix/macOS:: Creates symlink `mlib β†’ target` (using `ln -sfn`) +Windows:: Creates directory `mlib/` and copies JARs from `target/` -* Redirects the hardcoded `mlib` path to `target/` at runtime -* Avoids modifying shared source code that is also used by the original (non-Maven) version -* Is committed to Git (like the source symlinks) -* Points to `target/` which Maven 4 populates with classifier-based JARs +The Windows approach avoids `AccessDeniedException` issues when Java's `ModuleLayer` API traverses symlinks. [NOTE] ==== -Both source symlinks (`m4/src/*/main/java β†’ ../../../../src/*`) and the runtime symlink (`m4/mlib β†’ target`) are committed to Git. -This allows the M4 migration to work seamlessly after checkout without manual symlink creation. +A committed symlink `m4/mlib β†’ target` exists in Git for convenience on Unix systems. +On Windows, this symlink is replaced with a directory and copied JARs at runtime by `run.sh`. +Both approaches redirect the hardcoded `mlib` path to Maven-built JARs without modifying shared source code. ==== ==== Running the Maven 4 Version diff --git a/jigsaw-examples/example_layer-hierarchy/m4/.gitignore b/jigsaw-examples/example_layer-hierarchy/m4/.gitignore index f779d7a3..9a8f5418 100644 --- a/jigsaw-examples/example_layer-hierarchy/m4/.gitignore +++ b/jigsaw-examples/example_layer-hierarchy/m4/.gitignore @@ -1,7 +1,8 @@ # Maven build output target/ -# Module JARs +# Module library (symlink on Unix, directory on Windows) +mlib/ # Automatic module library (copied by maven-dependency-plugin) amlib/ diff --git a/jigsaw-examples/example_layer-hierarchy/m4/clean.sh b/jigsaw-examples/example_layer-hierarchy/m4/clean.sh index fc271c75..9ae0fc4b 100755 --- a/jigsaw-examples/example_layer-hierarchy/m4/clean.sh +++ b/jigsaw-examples/example_layer-hierarchy/m4/clean.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash rm -rf target rm -rf amlib +# Only remove mlib on Windows (where it's a directory with copied JARs) +# On Unix, mlib is a committed symlink and should remain +[ "${OS:-$(uname)}" = "Windows_NT" ] && rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_layer-hierarchy/m4/run.sh b/jigsaw-examples/example_layer-hierarchy/m4/run.sh index 62e00f60..4abd8a46 100755 --- a/jigsaw-examples/example_layer-hierarchy/m4/run.sh +++ b/jigsaw-examples/example_layer-hierarchy/m4/run.sh @@ -13,15 +13,20 @@ fi # Create run-result directory if it doesn't exist mkdir -p run-result -# Ensure mlib β†’ target symlink exists and is valid -# (Java code uses ModuleLayer API to load modules from path + "/mlib") -if [ -L mlib ] && [ ! -e mlib ]; then - # Broken symlink, remove it - rm mlib -fi -if [ ! -e mlib ]; then - # Create symlink (target/ should exist from compile.sh) - ln -s target mlib +# Setup mlib for module-path access +# Windows: Copy JARs to mlib/ directory (symlinks cause AccessDeniedException) +# Unix: Use symlink to target/ +if [ "${OS:-$(uname)}" = "Windows_NT" ]; then + # Windows: Ensure mlib is a directory, copy JARs + echo "We are on Windows, copying JARs to mlib/" + rm -rf mlib + mkdir -p mlib + cp -p target/*.jar mlib/ + ls -l mlib/ +else + # Unix: Ensure mlib is a symlink to target + echo "We are on Unix, using JARs from mlib/ as symlink" + test -h mlib || ln -sfn target mlib fi echo "Using Java version:" diff --git a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/README.adoc b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/README.adoc index ecebebcd..9407ee50 100644 --- a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/README.adoc +++ b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/README.adoc @@ -145,7 +145,7 @@ This hybrid approach is necessary because: * Each module requiring an automatic module must be compiled separately with only the needed automatic module on path * This example demonstrates module layers where different modules use different automatic module versions -=== Module-Path Symlink for Dynamic Module Loading +=== Module-Path Access via mlib for Dynamic Module Loading The Java code in `modmain/pkgmain/Main.java` uses the `ModuleLayer` API to dynamically load modules at runtime from hardcoded paths: @@ -165,22 +165,16 @@ target/example_layer-modules-grouped-in-hierarchy-m4-1.0-SNAPSHOT-modmain.jar ... ---- -To maintain compatibility with the shared Java source code that references `mlib`, the migration uses a committed symlink: +To maintain compatibility with the shared Java source code that references `mlib`, the `run.sh` script creates `mlib` using OS-specific approaches: -[source,bash] ----- -m4/mlib -> target ----- - -This symlink: +Unix/macOS:: Creates symlink `mlib β†’ target` (using `ln -sfn`) +Windows:: Creates directory `mlib/` and copies JARs from `target/` -* Redirects the hardcoded `mlib` path to `target/` at runtime -* Avoids modifying shared source code that is also used by the original (non-Maven) version -* Is committed to Git (like the source symlinks) -* Points to `target/` which Maven 4 populates with classifier-based JARs +The Windows approach avoids `AccessDeniedException` issues when Java's `ModuleLayer` API traverses symlinks. [NOTE] ==== -Both source symlinks (`m4/src/modcommon/main/java` β†’ `../../../../src/modcommon`) and the runtime symlink (`m4/mlib β†’ target`) are committed to Git. -This allows the M4 migration to work seamlessly after checkout without manual symlink creation. +A committed symlink `m4/mlib β†’ target` exists in Git for convenience on Unix systems. +On Windows, this symlink is replaced with a directory and copied JARs at runtime by `run.sh`. +Both approaches redirect the hardcoded `mlib` path to Maven-built JARs without modifying shared source code. ==== diff --git a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/clean.sh b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/clean.sh index d0eb0648..c4908846 100755 --- a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/clean.sh +++ b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/clean.sh @@ -4,4 +4,7 @@ rm -rf amlib1 rm -rf amlib2 rm -rf classes rm -rf mods +# Only remove mlib on Windows (where it's a directory with copied JARs) +# On Unix, mlib is a committed symlink and should remain +[ "${OS:-$(uname)}" = "Windows_NT" ] && rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/run.sh b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/run.sh index 0d469319..be073806 100755 --- a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/run.sh +++ b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/run.sh @@ -24,15 +24,20 @@ echo # Create run-result directory if it doesn't exist mkdir -p run-result -# Ensure mlib β†’ target symlink exists and is valid -# (Java code uses ModuleLayer API to load modules from mlib/) -if [ -L mlib ] && [ ! -e mlib ]; then - # Broken symlink, remove it - rm mlib -fi -if [ ! -e mlib ]; then - # Create symlink (target/ should exist from compile.sh) - ln -s target mlib +# Setup mlib for module-path access +# Windows: Copy JARs to mlib/ directory (symlinks cause AccessDeniedException) +# Unix: Use symlink to target/ +if [ "${OS:-$(uname)}" = "Windows_NT" ]; then + # Windows: Ensure mlib is a directory, copy JARs + echo "We are on Windows, copying JARs to mlib/" + rm -rf mlib + mkdir -p mlib + cp -p target/*.jar mlib/ + ls -l mlib/ +else + # Unix: Ensure mlib is a symlink to target + echo "We are on Unix, using JARs from mlib/ as symlink" + test -h mlib || ln -sfn target mlib fi # Run the Java code with mlib on module-path diff --git a/jigsaw-examples/example_layer-modules-module-resolution/README.adoc b/jigsaw-examples/example_layer-modules-module-resolution/README.adoc index dd69e1ec..75a9a431 100644 --- a/jigsaw-examples/example_layer-modules-module-resolution/README.adoc +++ b/jigsaw-examples/example_layer-modules-module-resolution/README.adoc @@ -146,8 +146,11 @@ jar --create --file=../barmlib/modcommon.jar -C modcommon . + . JAR placement for dynamic module loading: ** target/ - Maven-built JARs (with classifiers) +** mlib/ - Boot layer modules (OS-specific: Unix uses symlink to target/, Windows uses directory with copied JARs) ** foomlib/ - foo layer modules (modfoo, modversion1) copied from target/ ** barmlib/ - bar layer modules (modbar, modversion2) copied from target/, plus modcommon v2.0 compiled manually ++ +The `run.sh` script creates `mlib` using OS-specific approaches to avoid `AccessDeniedException` when Java's `ModuleLayer` API traverses symlinks on Windows. This hybrid approach is necessary because: diff --git a/jigsaw-examples/example_layer-modules-module-resolution/m4/clean.sh b/jigsaw-examples/example_layer-modules-module-resolution/m4/clean.sh index 838025da..e156016d 100755 --- a/jigsaw-examples/example_layer-modules-module-resolution/m4/clean.sh +++ b/jigsaw-examples/example_layer-modules-module-resolution/m4/clean.sh @@ -3,4 +3,7 @@ rm -rf target rm -rf foomlib rm -rf barmlib rm -rf mods2 +# Only remove mlib on Windows (where it's a directory with copied JARs) +# On Unix, mlib is a committed symlink and should remain +[ "${OS:-$(uname)}" = "Windows_NT" ] && rm -rf mlib rm -rf run-result diff --git a/jigsaw-examples/example_layer-modules-module-resolution/m4/run.sh b/jigsaw-examples/example_layer-modules-module-resolution/m4/run.sh index d778fdf7..bede3efe 100755 --- a/jigsaw-examples/example_layer-modules-module-resolution/m4/run.sh +++ b/jigsaw-examples/example_layer-modules-module-resolution/m4/run.sh @@ -15,15 +15,20 @@ echo # Create run-result directory if it doesn't exist mkdir -p run-result -# Ensure mlib β†’ target symlink exists and is valid -# (Java code uses ModuleLayer API to load modules from mlib/) -if [ -L mlib ] && [ ! -e mlib ]; then - # Broken symlink, remove it - rm mlib -fi -if [ ! -e mlib ]; then - # Create symlink (target/ should exist from compile.sh) - ln -s target mlib +# Setup mlib for module-path access +# Windows: Copy JARs to mlib/ directory (symlinks cause AccessDeniedException) +# Unix: Use symlink to target/ +if [ "${OS:-$(uname)}" = "Windows_NT" ]; then + # Windows: Ensure mlib is a directory, copy JARs + echo "We are on Windows, copying JARs to mlib/" + rm -rf mlib + mkdir -p mlib + cp -p target/*.jar mlib/ + ls -l mlib/ +else + # Unix: Ensure mlib is a symlink to target + echo "We are on Unix, using JARs from mlib/ as symlink" + test -h mlib || ln -sfn target mlib fi # Run the Java code with "." argument for dynamic layer creation, save output to run-result/run.txt, and display with highlighting diff --git a/jigsaw-examples/example_patch/README.adoc b/jigsaw-examples/example_patch/README.adoc index 187106fc..ce10e6bf 100644 --- a/jigsaw-examples/example_patch/README.adoc +++ b/jigsaw-examples/example_patch/README.adoc @@ -129,7 +129,16 @@ m4/src/modb-patch/main/java -> ../../../../src/modb-patch + These source symlinks point to the original shared source directories and are checked into Git. -Module-path symlink for JAR naming:: ++ +[NOTE] +==== +The patch compilation uses `--patch-module modb=src/modb-patch/main/java`, pointing directly to the symlinked patch sources. +This maintains full consistency with the `src//main/java` directory pattern throughout the `m4/` migration. +Dependencies from the original `modb` module (like the `Helper` class) are automatically resolved via `--module-path target/classes`. +==== + + +Module-path access via mlib:: + Maven (4) uses maven-jar-plugin with classifiers, creating JARs with names like: + @@ -139,31 +148,21 @@ target/example_patch-m4-1.0-SNAPSHOT-modmain.jar target/example_patch-m4-1.0-SNAPSHOT-modb.jar ---- + -However, Java's `--module-path` works best with simple JAR names or explicit paths. To maintain compatibility with the module-path, the migration uses a committed symlink: -+ -[source,bash] ----- -m4/mlib -> target ----- -+ -This symlink: -+ -* Allows `--module-path mlib` to resolve to the actual JARs in `target/` -* Maintains consistency with the original example structure -* Is committed to Git (like the source symlinks) -* Enables running the example from IDE without executing `compile.sh` +However, Java's `--module-path` works best with simple JAR names or explicit paths. +The `run.sh` script creates `mlib` to provide module-path access using OS-specific approaches: -[NOTE] -==== -Both source symlinks (`m4/src/modmain/main/java` β†’ `../../../../src/modmain`) and the runtime symlink (`m4/mlib β†’ target`) are committed to Git. -This unified symlink handling allows the M4 migration to work seamlessly after checkout without manual symlink creation. -==== +Unix/macOS:::: Creates symlink `mlib β†’ target` (using `ln -sfn`) +Windows:::: Creates directory `mlib/` and copies JARs from `target/` ++ +The Windows approach avoids `AccessDeniedException` issues when Java's module system traverses symlinks that were checked out before the `target/` directory existed. + ++ [NOTE] ==== -The patch compilation uses `--patch-module modb=src/modb-patch/main/java`, pointing directly to the symlinked patch sources. -This maintains full consistency with the `src//main/java` directory pattern throughout the `m4/` migration. -Dependencies from the original `modb` module (like the `Helper` class) are resolved via `--module-path target/classes`. +A committed symlink `m4/mlib β†’ target` exists in Git for convenience on Unix systems. +On Windows, this symlink is replaced with a directory and copied JARs at runtime by `run.sh`. +Both approaches provide the same functionality: `--module-path mlib` accesses the Maven-built JARs. ==== Build artifacts:: diff --git a/jigsaw-examples/example_patch/m4/.gitignore b/jigsaw-examples/example_patch/m4/.gitignore index e17f8e61..5d3dc5e3 100644 --- a/jigsaw-examples/example_patch/m4/.gitignore +++ b/jigsaw-examples/example_patch/m4/.gitignore @@ -4,5 +4,8 @@ /patches /patchlib +# Module library (symlink on Unix, directory on Windows) +/mlib + # Run results /run-result diff --git a/jigsaw-examples/example_patch/m4/clean.sh b/jigsaw-examples/example_patch/m4/clean.sh index d8375147..539aa915 100755 --- a/jigsaw-examples/example_patch/m4/clean.sh +++ b/jigsaw-examples/example_patch/m4/clean.sh @@ -6,6 +6,9 @@ echo "Cleaning Maven 4 build artifacts..." rm -rf target rm -rf patches rm -rf patchlib +# Only remove mlib on Windows (where it's a directory with copied JARs) +# On Unix, mlib is a committed symlink and should remain +[ "${OS:-$(uname)}" = "Windows_NT" ] && rm -rf mlib rm -rf run-result echo "βœ… Clean complete" diff --git a/jigsaw-examples/example_patch/m4/run.sh b/jigsaw-examples/example_patch/m4/run.sh index d8a72950..ce4d6b6d 100755 --- a/jigsaw-examples/example_patch/m4/run.sh +++ b/jigsaw-examples/example_patch/m4/run.sh @@ -9,15 +9,20 @@ result_dir="${1:-run-result}" rm -rf "${result_dir}" mkdir -p "${result_dir}" -# Ensure mlib β†’ target symlink exists and is valid -# (Needed for --module-path mlib after Maven compilation) -if [ -L mlib ] && [ ! -e mlib ]; then - # Broken symlink, remove it - rm mlib -fi -if [ ! -e mlib ]; then - # Create symlink (target/ should exist from compile.sh) - ln -s target mlib +# Setup mlib for module-path access +# Windows: Copy JARs to mlib/ directory (symlinks cause AccessDeniedException) +# Unix: Use symlink to target/ +if [ "${OS:-$(uname)}" = "Windows_NT" ]; then + # Windows: Ensure mlib is a directory, copy JARs + echo "We are on Windows, copying JARs to mlib/" + rm -rf mlib + mkdir -p mlib + cp -p target/*.jar mlib/ + ls -l mlib/ +else + # Unix: Ensure mlib is a symlink to target + echo "We are on Unix, using JARs from mlib/ as symlink" + test -h mlib || ln -sfn target mlib fi # Show Java version for user information From 933d68d7d8424d4bc78f858daf97d61b6e9361f1 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Tue, 18 Nov 2025 12:56:13 +0100 Subject: [PATCH 07/15] Add GitHub code links to m4 examples in docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add clickable code links to all 35 Maven 4 example implementations in the README.adoc table. Links point to the m4/ directory of each example. Changes: - README.adoc: Add 'code' links to all m4 migration status entries - README.adoc: Define :example-base: attribute (default for local viewing) - pom.xml: Add GitHub repository configuration properties - pom.xml: Configure example-base attribute for AsciiDoc processing - build.yml: Pass current branch name to Maven during doc generation The example-base attribute uses different values depending on context: - Local/GitHub viewing: 'jigsaw-examples' (relative paths) - CI/CD builds: Full GitHub URLs pointing to correct branch This ensures generated documentation always links to the correct source code on GitHub, whether built from main, feature branches, or PRs. Example link format: https://github.com/support-and-care/java9-jigsaw-examples/tree//jigsaw-examples/example_xyz/m4/ πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Introduced in the course of support-and-care/maven-support-and-care#137 --- .github/workflows/build.yml | 2 +- README.adoc | 71 +++++++++++++++++++------------------ pom.xml | 6 ++++ 3 files changed, 43 insertions(+), 36 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c6518dc9..4f3266f4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -372,7 +372,7 @@ jobs: continue-on-error: true - name: Generate documentation - run: ./mvnw verify + run: ./mvnw verify -Dgithub.branch=${{ github.head_ref || github.ref_name }} - name: Create index.html from README.html run: cp target/generated-docs/README.html target/generated-docs/index.html diff --git a/README.adoc b/README.adoc index ac6860cb..9e232cf2 100755 --- a/README.adoc +++ b/README.adoc @@ -7,6 +7,7 @@ ifdef::env-github[] :caution-caption: :fire: :warning-caption: :warning: endif::[] +:example-base: jigsaw-examples [IMPORTANT] .Authors @@ -444,12 +445,12 @@ Click the status icon to jump to the example's Maven 4 Migration section for det | xref:jigsaw-examples/example_naming-modules/README.adoc[naming-modules] | Which naming conventions exist for modules? Which names are not allowed? | -| xref:jigsaw-examples/example_naming-modules/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_naming-modules/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_naming-modules/m4/[code] | xref:jigsaw-examples/example_annotations/README.adoc[annotations] | How can one specify annotations and deprecation for modules? | image:jigsaw-examples/example_annotations/moduledependencies.png[width=200,link=jigsaw-examples/example_annotations/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_annotations/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] +| xref:jigsaw-examples/example_annotations/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] / link:{example-base}/example_annotations/m4/[code] 4+| *Examples on basic module reads and exports attributes* @@ -458,35 +459,35 @@ Click the status icon to jump to the example's Maven 4 Migration section for det Relates to all other examples in this section. | image:jigsaw-examples/example_requires_exports_requires-transitive_exports-to/moduledependencies.png[width=200,link=jigsaw-examples/example_requires_exports_requires-transitive_exports-to/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_requires_exports_requires-transitive_exports-to/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] +| xref:jigsaw-examples/example_requires_exports_requires-transitive_exports-to/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] / link:{example-base}/example_requires_exports_requires-transitive_exports-to/m4/[code] | xref:jigsaw-examples/example_requires-static/README.adoc[requires-static] | How does requires static look like? Relates to all other examples in this section. | image:jigsaw-examples/example_requires-static/moduledependencies.png[width=200,link=jigsaw-examples/example_requires-static/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_requires-static/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] +| xref:jigsaw-examples/example_requires-static/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] / link:{example-base}/example_requires-static/m4/[code] | xref:jigsaw-examples/example_requires_exports/README.adoc[requires_exports] | How does requires and exports look like? Relates to all other examples in this section. | image:jigsaw-examples/example_requires_exports/moduledependencies.png[width=200,link=jigsaw-examples/example_requires_exports/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_requires_exports/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] +| xref:jigsaw-examples/example_requires_exports/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] / link:{example-base}/example_requires_exports/m4/[code] | xref:jigsaw-examples/example_requires_exports-to/README.adoc[requires_exports-to] | How does requires and qualified exports look like? Relates to all other examples in this section. | image:jigsaw-examples/example_requires_exports-to/moduledependencies.png[width=200,link=jigsaw-examples/example_requires_exports-to/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_requires_exports-to/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] +| xref:jigsaw-examples/example_requires_exports-to/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] / link:{example-base}/example_requires_exports-to/m4/[code] | xref:jigsaw-examples/example_reflection/README.adoc[reflection] | How do reflection calls look like? Relates to all other examples in this section. | image:jigsaw-examples/example_reflection/moduledependencies.png[width=200,link=jigsaw-examples/example_reflection/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_reflection/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] +| xref:jigsaw-examples/example_reflection/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] / link:{example-base}/example_reflection/m4/[code] 4+| *Examples on dynamic binding with uses/provides* | xref:jigsaw-examples/example_uses-provides/README.adoc[uses-provides] @@ -494,14 +495,14 @@ Relates to all other examples in this section. Relates to all other examples in this section. | image:jigsaw-examples/example_uses-provides/moduledependencies.png[width=200,link=jigsaw-examples/example_uses-provides/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_uses-provides/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] +| xref:jigsaw-examples/example_uses-provides/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] / link:{example-base}/example_uses-provides/m4/[code] | xref:jigsaw-examples/example_uses-provides_uses-in-client/README.adoc[uses-provides_uses-in-client] | How does uses-provides look like, when uses is separated from the interface? Relates to all other examples in this section. | image:jigsaw-examples/example_uses-provides_uses-in-client/moduledependencies.png[width=200,link=jigsaw-examples/example_uses-provides_uses-in-client/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_uses-provides_uses-in-client/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] +| xref:jigsaw-examples/example_uses-provides_uses-in-client/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] / link:{example-base}/example_uses-provides_uses-in-client/m4/[code] 4+| *Examples on accessibility and (non) exported packages* @@ -510,21 +511,21 @@ Relates to all other examples in this section. Relates to all other examples in this section. | image:jigsaw-examples/example_derived_private-package-protected/moduledependencies.png[width=200,link=jigsaw-examples/example_derived_private-package-protected/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_derived_private-package-protected/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] +| xref:jigsaw-examples/example_derived_private-package-protected/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] / link:{example-base}/example_derived_private-package-protected/m4/[code] | xref:jigsaw-examples/example_exceptions/README.adoc[exceptions] | What happens, when exceptions are thrown to classes outside the module but their package is not exported? Relates to all other examples in this section. | image:jigsaw-examples/example_exceptions/moduledependencies.png[width=200,link=jigsaw-examples/example_exceptions/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_exceptions/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] +| xref:jigsaw-examples/example_exceptions/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] / link:{example-base}/example_exceptions/m4/[code] | xref:jigsaw-examples/example_interface-callback/README.adoc[interface-callback] | What happens, when outside the module a callback implementation is called which package is not exported? Relates to all other examples in this section. | image:jigsaw-examples/example_interface-callback/moduledependencies.png[width=200,link=jigsaw-examples/example_interface-callback/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_interface-callback/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] +| xref:jigsaw-examples/example_interface-callback/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] / link:{example-base}/example_interface-callback/m4/[code] 4+| *Examples on specificing add options* @@ -533,21 +534,21 @@ Relates to all other examples in this section. Relates to all other examples in this section. | image:jigsaw-examples/example_addExports_manifest/moduledependencies.png[width=200,link=jigsaw-examples/example_addExports_manifest/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_addExports_manifest/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_addExports_manifest/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_addExports_manifest/m4/[code] | xref:jigsaw-examples/example_addReads_addExports/README.adoc[addReads_addExports] | How can we use --add-reads and --add-exports for Javac compiler and Java launcher Relates to all other examples in this section. | image:jigsaw-examples/example_addReads_addExports/moduledependencies.png[width=200,link=jigsaw-examples/example_addReads_addExports/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_addReads_addExports/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_addReads_addExports/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_addReads_addExports/m4/[code] | xref:jigsaw-examples/example_addReads_addExports_reflection/README.adoc[addReads_addExports_reflection] | How can we use --add-reads and --add-exports for reflection calls? Relates to all other examples in this section. | image:jigsaw-examples/example_addReads_addExports_reflection/moduledependencies.png[width=200,link=jigsaw-examples/example_addReads_addExports_reflection/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_addReads_addExports_reflection/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_addReads_addExports_reflection/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_addReads_addExports_reflection/m4/[code] 4+| *Examples on automatic modules* @@ -556,14 +557,14 @@ Relates to all other examples in this section. Related example: xref:jigsaw-examples/example_splitpackage_automatic-modules/README.adoc[splitpackage_automatic-modules] | image:jigsaw-examples/example_automatic-module-logging/moduledependencies.png[width=200,link=jigsaw-examples/example_automatic-module-logging/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_automatic-module-logging/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_automatic-module-logging/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_automatic-module-logging/m4/[code] 4+| *Examples on restricting the access to resources in other modules* | xref:jigsaw-examples/example_resources/README.adoc[resources] | Which resources in modules are accessible, which are not? | image:jigsaw-examples/example_resources/moduledependencies.png[width=200,link=jigsaw-examples/example_resources/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_resources/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_resources/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_resources/m4/[code] 4+| *Examples on the split package problem* @@ -572,14 +573,14 @@ Related example: xref:jigsaw-examples/example_splitpackage_automatic-modules/REA Relates to all other examples in this section. | image:jigsaw-examples/example_splitpackage/moduledependencies.png[width=200,link=jigsaw-examples/example_splitpackage/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_splitpackage/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_splitpackage/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_splitpackage/m4/[code] | xref:jigsaw-examples/example_splitpackage_automatic-modules/README.adoc[splitpackage_automatic-modules] | What happens when one Automatic Module automatically reads all other Automatic Modules on the module path and hence creates an unwanted split package problem? Related examples: xref:jigsaw-examples/example_automatic-module-logging/README.adoc[automatic-module-logging] and all other examples in this section. | image:jigsaw-examples/example_splitpackage_automatic-modules/moduledependencies.png[width=200,link=jigsaw-examples/example_splitpackage_automatic-modules/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_splitpackage_automatic-modules/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_splitpackage_automatic-modules/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_splitpackage_automatic-modules/m4/[code] 4+| *Examples on resolution of modules, layers and visibility of modules between layers* @@ -588,42 +589,42 @@ Related examples: xref:jigsaw-examples/example_automatic-module-logging/README.a Relates to all other examples in this section. | -| xref:jigsaw-examples/example_jerrymouse/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_jerrymouse/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_jerrymouse/m4/[code] | xref:jigsaw-examples/example_resolved-modules/README.adoc[resolved-modules] | Which modules are resolved? Usage of jlink Relates to all other examples in this section. | image:jigsaw-examples/example_resolved-modules/moduledependencies.png[width=200,link=jigsaw-examples/example_resolved-modules/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_resolved-modules/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] +| xref:jigsaw-examples/example_resolved-modules/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] / link:{example-base}/example_resolved-modules/m4/[code] | xref:jigsaw-examples/example_layer-hierarchy/README.adoc[layer-hierarchy] | How can one create a hierarchy of layers automatically and add modules (naming conventions)? Relates to all other examples in this section. | image:jigsaw-examples/example_layer-hierarchy/layer-hierarchy.drawio.svg[width=200,link=jigsaw-examples/example_layer-hierarchy/layer-hierarchy.drawio.svg] -| xref:jigsaw-examples/example_layer-hierarchy/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_layer-hierarchy/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_layer-hierarchy/m4/[code] | xref:jigsaw-examples/example_layer-modules-all-in-boot-layer/README.adoc[layer-modules-all-in-boot-layer] | How does the boot layer look like containing a bunch of modules? Relates to all other examples in this section. | image:jigsaw-examples/example_layer-modules-all-in-boot-layer/moduledependencies.png[width=200,link=jigsaw-examples/example_layer-modules-all-in-boot-layer/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_layer-modules-all-in-boot-layer/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_layer-modules-all-in-boot-layer/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_layer-modules-all-in-boot-layer/m4/[code] | xref:jigsaw-examples/example_layer-modules-grouped-in-hierarchy/README.adoc[layer-modules-grouped-in-hierarchy] | How does a small hiearchy of layers look like when one explicitely distributes a bunch of modules to these layers? Relates to all other examples in this section. | image:jigsaw-examples/example_layer-modules-grouped-in-hierarchy/moduledependencies.png[width=200,link=jigsaw-examples/example_layer-modules-grouped-in-hierarchy/moduledependencies.png] -| xref:jigsaw-examples/example_layer-modules-grouped-in-hierarchy/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_layer-modules-grouped-in-hierarchy/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_layer-modules-grouped-in-hierarchy/m4/[code] | xref:jigsaw-examples/example_layer-modules-module-resolution/README.adoc[layer-modules-module-resolution] | How are different versions of a module resolved depending on the setup of the layer? Relates to all other examples in this section. | -| xref:jigsaw-examples/example_layer-modules-module-resolution/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_layer-modules-module-resolution/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_layer-modules-module-resolution/m4/[code] 4+| *Examples on testing* @@ -632,7 +633,7 @@ Relates to all other examples in this section. Relates to all other examples in this section. | image:jigsaw-examples/example_test/moduledependencies.png[width=200,link=jigsaw-examples/example_test/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_test/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_test/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_test/m4/[code] | xref:jigsaw-examples/example_maven-test-blackbox/README.adoc[maven-test-blackbox] | How can one achieve blackbox testing with Maven? @@ -653,14 +654,14 @@ Relates to all other examples in this section. Relates to all other examples in this section. | image:jigsaw-examples/example_patch/moduledependencies.png[width=200,link=jigsaw-examples/example_patch/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_patch/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_patch/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_patch/m4/[code] 4+| *Examples on Main classes* | xref:jigsaw-examples/example_hiddenmain/README.adoc[hiddenmain] | Is it possible that one can call a Main class which is in a non-exported package? | image:jigsaw-examples/example_hiddenmain/moduledependencies.png[width=200,link=jigsaw-examples/example_hiddenmain/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_hiddenmain/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] +| xref:jigsaw-examples/example_hiddenmain/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] / link:{example-base}/example_hiddenmain/m4/[code] 4+| *Examples on access from and to the classpath (i.e. the unnamed module)* | xref:jigsaw-examples/example_unnamed-module_access-from-automatic-module/README.adoc[unnamed-module_access-from-automatic-module] @@ -668,35 +669,35 @@ Relates to all other examples in this section. Relates to all other examples in this section. | -| xref:jigsaw-examples/example_unnamed-module_access-from-automatic-module/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_unnamed-module_access-from-automatic-module/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_unnamed-module_access-from-automatic-module/m4/[code] | xref:jigsaw-examples/example_unnamed-module_access-from-explicit-module/README.adoc[unnamed-module_access-from-explicit-module] | Can a Explicit Module access the classpath (i.e. the unnamed module)? Relates to all other examples in this section. | image:jigsaw-examples/example_unnamed-module_access-from-explicit-module/moduledependencies.png[width=200,link=jigsaw-examples/example_unnamed-module_access-from-explicit-module/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_unnamed-module_access-from-explicit-module/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_unnamed-module_access-from-explicit-module/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_unnamed-module_access-from-explicit-module/m4/[code] | xref:jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/README.adoc[unnamed-module_access-from-explicit-module-reflection] | Can a Explicit Module access the classpath (i.e. the unnamed module) via reflection? Relates to all other examples in this section. | image:jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/moduledependencies.png[width=200,link=jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_unnamed-module_access-from-explicit-module-reflection/m4/[code] | xref:jigsaw-examples/example_unnamed-module-reflection-illegal-access/README.adoc[unnamed-module-reflection-illegal-access] | Can the classpath (i.e. the unnamed module) access concealed packages in the JDK and what happens when the JDK "kill switch" is activated? Relates to all other examples in this section. | image:jigsaw-examples/example_unnamed-module-reflection-illegal-access/moduledependencies.png[width=200,link=jigsaw-examples/example_unnamed-module-reflection-illegal-access/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_unnamed-module-reflection-illegal-access/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_unnamed-module-reflection-illegal-access/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_unnamed-module-reflection-illegal-access/m4/[code] | xref:jigsaw-examples/example_unnamed-module_accessing-module-path/README.adoc[unnamed-module_accessing-module-path] | Can the classpath (i.e. the unnamed module) access modules on the module path? Relates to all other examples in this section. | image:jigsaw-examples/example_unnamed-module_accessing-module-path/moduledependencies.png[width=200,link=jigsaw-examples/example_unnamed-module_accessing-module-path/moduledependencies-withlegend.png] -| xref:jigsaw-examples/example_unnamed-module_accessing-module-path/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_unnamed-module_accessing-module-path/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_unnamed-module_accessing-module-path/m4/[code] 4+| *Examples on build systems* @@ -723,14 +724,14 @@ Relates to all other examples in this section. | xref:jigsaw-examples/example_compile-target-jdk8/README.adoc[compile-target-jdk8] | What happens when one compiles with a modern JDK while targeting Java release 8 for backwards compatibility? | -| xref:jigsaw-examples/example_compile-target-jdk8/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] +| xref:jigsaw-examples/example_compile-target-jdk8/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_compile-target-jdk8/m4/[code] 4+| *Examples on non-Jigsaw topics* | xref:jigsaw-examples/example_version/README.adoc[version] | How does the new Java 9 version string (cf JEP 223) look like? | -| xref:jigsaw-examples/example_version/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] +| xref:jigsaw-examples/example_version/README.adoc#sec:maven-4-migration[icon:check-circle[role=green]] / link:{example-base}/example_version/m4/[code] |=== diff --git a/pom.xml b/pom.xml index c87e33f5..6ff8d6fd 100644 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,11 @@ 11 11 3.2.0 + + + support-and-care + java9-jigsaw-examples + main @@ -49,6 +54,7 @@ true false . + https://github.com/${github.repo.owner}/${github.repo.name}/tree/${github.branch}/jigsaw-examples From 8181adb9e9cfd4d36619221415b9ab2f46b3bf29 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Tue, 18 Nov 2025 13:22:51 +0100 Subject: [PATCH 08/15] Improve Netlify deployment with aliases and URL display MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consolidate and enhance Netlify deployment workflow following the pattern from maven-simple-reports project. Changes: - Add "Set Netlify alias" step to generate sanitized aliases - PRs: pr-{number} (e.g., pr-4) - Branches: sanitized branch name (e.g., feature-maven-4-migration) - Consolidate two separate deployment steps into one - Add "Display Netlify URL" step showing deployment info in summary - Use commit message or PR title for deploy message Benefits: - Consistent, predictable aliases for all deployments - Full Netlify URL prominently displayed in workflow summary - Cleaner workflow with single deployment step - Better traceability with descriptive deploy messages Example summary output: ### πŸš€ Netlify Deployment βœ… Deployed successfully! πŸ”— URL: https://feature-maven-4-migration--java9-jigsaw-samples.netlify.app πŸ“ Alias: feature-maven-4-migration πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Introduced in the course of support-and-care/maven-support-and-care#137 --- .github/workflows/build.yml | 43 ++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4f3266f4..cd2179e4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -384,33 +384,46 @@ jobs: path: target/generated-docs retention-days: 30 - - name: Deploy to Netlify (Preview) - if: github.event_name == 'pull_request' + - name: Set Netlify alias + if: github.ref != 'refs/heads/main' + id: netlify-alias + run: | + if [ "${{ github.event_name }}" = "pull_request" ]; then + echo "alias=pr-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT + else + # Use branch name, sanitize it for Netlify (replace / with -) + BRANCH_NAME="${{ github.ref_name }}" + SANITIZED_BRANCH=$(echo "$BRANCH_NAME" | sed 's/\//-/g') + echo "alias=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT + fi + + - name: Deploy to Netlify (branches and PRs) + if: github.ref != 'refs/heads/main' + id: netlify-deploy uses: nwtgck/actions-netlify@v3 with: publish-dir: './target/generated-docs' production-deploy: false github-token: ${{ secrets.GITHUB_TOKEN }} - deploy-message: "Deploy from GitHub Actions - PR #${{ github.event.pull_request.number }}" + deploy-message: "Deploy from GitHub Actions - ${{ github.event.head_commit.message || github.event.pull_request.title }}" enable-pull-request-comment: true enable-commit-comment: false overwrites-pull-request-comment: true + alias: ${{ steps.netlify-alias.outputs.alias }} env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} - - name: Deploy to Netlify (Branch Preview) - if: github.event_name == 'push' && github.ref != 'refs/heads/main' - uses: nwtgck/actions-netlify@v3 - with: - publish-dir: './target/generated-docs' - production-deploy: false - github-token: ${{ secrets.GITHUB_TOKEN }} - deploy-message: "Deploy from GitHub Actions - branch ${{ github.ref_name }}" - alias: ${{ github.ref_name }} - env: - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + - name: Display Netlify URL + if: github.ref != 'refs/heads/main' + run: | + echo "### πŸš€ Netlify Deployment" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "βœ… **Deployed successfully!**" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "πŸ”— **URL:** ${{ steps.netlify-deploy.outputs.deploy-url }}" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "πŸ“ **Alias:** \`${{ steps.netlify-alias.outputs.alias }}\`" >> $GITHUB_STEP_SUMMARY - name: Upload to GitHub Pages if: github.event_name == 'push' From d090527edf82faf5f4ecd52e166273853a8f3148 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Tue, 18 Nov 2025 13:41:47 +0100 Subject: [PATCH 09/15] Bump to GH checkout action v5 and drop unknown checkout option (symlinks) --- .github/workflows/build.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cd2179e4..c1d7f20d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Install shellcheck run: | @@ -38,9 +38,7 @@ jobs: run: git config --global core.autocrlf false - name: Checkout repository - uses: actions/checkout@v4 - with: - symlinks: true + uses: actions/checkout@v5 - name: Set up JDK 8 (non macOS) id: setup-jdk8 @@ -190,9 +188,7 @@ jobs: run: git config --global core.autocrlf false - name: Checkout repository - uses: actions/checkout@v4 - with: - symlinks: true + uses: actions/checkout@v5 - name: Set up JDK 11 id: setup-jdk11 @@ -349,7 +345,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Set up JDK 17 uses: actions/setup-java@v4 From 3d85f341105eac38978531ba22e66d4730d05374 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Fri, 21 Nov 2025 12:08:39 +0100 Subject: [PATCH 10/15] Consequently use "Java Modules" instead of JPMS --- README.adoc | 29 ++++++------------- .../example_addExports_manifest/README.adoc | 2 +- .../example_addReads_addExports/README.adoc | 2 +- .../README.adoc | 2 +- jigsaw-examples/example_agent/README.adoc | 2 +- .../example_annotations/README.adoc | 2 +- .../README.adoc | 2 +- .../example_compile-target-jdk8/README.adoc | 6 ++-- .../README.adoc | 2 +- .../example_exceptions/README.adoc | 2 +- .../example_gradle-project/README.adoc | 2 +- .../example_hiddenmain/README.adoc | 2 +- .../example_interface-callback/README.adoc | 2 +- .../example_jerrymouse/README.adoc | 2 +- .../example_layer-hierarchy/README.adoc | 10 +++---- .../README.adoc | 2 +- .../README.adoc | 2 +- .../README.adoc | 2 +- .../example_maven-project/README.adoc | 2 +- .../example_maven-test-blackbox/README.adoc | 2 +- .../example_maven-test-whitebox/README.adoc | 2 +- .../example_naming-modules/README.adoc | 2 +- jigsaw-examples/example_patch/README.adoc | 2 +- .../example_reflection/README.adoc | 2 +- .../example_requires-static/README.adoc | 2 +- .../example_requires_exports-to/README.adoc | 2 +- .../example_requires_exports/README.adoc | 2 +- .../README.adoc | 2 +- .../example_resolved-modules/README.adoc | 2 +- jigsaw-examples/example_resources/README.adoc | 2 +- .../example_splitpackage/README.adoc | 4 +-- .../README.adoc | 2 +- .../example_spring-hibernate/README.adoc | 4 +-- jigsaw-examples/example_test/README.adoc | 2 +- .../README.adoc | 2 +- .../README.adoc | 2 +- .../README.adoc | 2 +- .../README.adoc | 2 +- .../README.adoc | 2 +- .../example_uses-provides/README.adoc | 2 +- .../README.adoc | 2 +- jigsaw-examples/example_version/README.adoc | 5 ++-- 42 files changed, 60 insertions(+), 70 deletions(-) diff --git a/README.adoc b/README.adoc index 9e232cf2..d2854a09 100755 --- a/README.adoc +++ b/README.adoc @@ -14,33 +14,22 @@ endif::[] ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ (Maven for short) in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as a https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== == What is this about? -This is a example suite for Java 9 jigsaw modules. -Many aspects of the new Java 9 Jigsaw modules as defined in https://openjdk.java.net/projects/jigsaw/[Project Jigsaw] by https://www.jcp.org/en/jsr/detail?id=376[JSR 376] and https://openjdk.java.net/jeps/261[JEP 261]. +This is an example suite for Java Modules. +It initially demonstrates many aspects of Java Modules as defined in https://openjdk.java.net/projects/jigsaw/[Project Jigsaw] by https://www.jcp.org/en/jsr/detail?id=376[JSR 376] and https://openjdk.java.net/jeps/261[JEP 261]. -All the examples have been successfully tested with Windows (64bit), Linux and MacOSX - running the <>. -Originally developed for Java 9 (which introduced JPMS), the examples are continuously updated for current Java versions. - -*Build Tool Wrappers:* All Maven and Gradle examples now include build tool wrappers, so manual installation of Maven or Gradle is no longer required: - -* Maven examples include *Maven Wrapper 3.9.11* (mvnw/mvnw.cmd) -* Gradle example includes *Gradle Wrapper 9.1.0* (gradlew/gradlew.cmd) - requires *JDK 17 or later* - -[TIP] +[NOTE] +.Jigsaw / JPMS have become Java Modules ==== -Use a local Maven repository to avoid polluting your global one, set a repository location in the top level directory: - -[source,bash] ----- -export MAVEN_OPTS="-Dmaven.repo.local=${PWD}/.m2/repository" ----- - -Note that this overrides any other settings, e.g., by `mvn_settings.xml`. +Java Modules were introduced in Java 9 as part of Project Jigsaw. +The term "Jigsaw" was commonly used during the development phase and early adoption. +However, the official terminology has since shifted to "Java Modules" or "Java Platform Module System (JPMS)". +In this documentation, both terms may be used interchangeably, but "Java Modules" is the preferred term in current contexts. ==== == Setup diff --git a/jigsaw-examples/example_addExports_manifest/README.adoc b/jigsaw-examples/example_addExports_manifest/README.adoc index 440bc5a7..798f4447 100644 --- a/jigsaw-examples/example_addExports_manifest/README.adoc +++ b/jigsaw-examples/example_addExports_manifest/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_addReads_addExports/README.adoc b/jigsaw-examples/example_addReads_addExports/README.adoc index 53b26cb8..fc661bf8 100644 --- a/jigsaw-examples/example_addReads_addExports/README.adoc +++ b/jigsaw-examples/example_addReads_addExports/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_addReads_addExports_reflection/README.adoc b/jigsaw-examples/example_addReads_addExports_reflection/README.adoc index adc85751..32d2bdde 100644 --- a/jigsaw-examples/example_addReads_addExports_reflection/README.adoc +++ b/jigsaw-examples/example_addReads_addExports_reflection/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_agent/README.adoc b/jigsaw-examples/example_agent/README.adoc index 8e23a3cd..0533410b 100644 --- a/jigsaw-examples/example_agent/README.adoc +++ b/jigsaw-examples/example_agent/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_annotations/README.adoc b/jigsaw-examples/example_annotations/README.adoc index c8f5eba4..ddcfbaa3 100644 --- a/jigsaw-examples/example_annotations/README.adoc +++ b/jigsaw-examples/example_annotations/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_automatic-module-logging/README.adoc b/jigsaw-examples/example_automatic-module-logging/README.adoc index f1d9b6f8..1d494c17 100644 --- a/jigsaw-examples/example_automatic-module-logging/README.adoc +++ b/jigsaw-examples/example_automatic-module-logging/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_compile-target-jdk8/README.adoc b/jigsaw-examples/example_compile-target-jdk8/README.adoc index dceca4eb..e784d224 100644 --- a/jigsaw-examples/example_compile-target-jdk8/README.adoc +++ b/jigsaw-examples/example_compile-target-jdk8/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== @@ -58,7 +58,7 @@ include::run-result/run.txt[] [[sec:maven-4-migration]] === Maven 4 Migration -This example does not include a Maven 4 migration variant (`m4/` directory) because it is primarily about demonstrating compatibility with older JDK 8 code, not about the Java Platform Module System (JPMS). +This example does not include a Maven 4 migration variant (`m4/` directory) because it is primarily about demonstrating compatibility with older JDK 8 code, not about Java Modules. The example focuses on cross-compilation targeting JDK 8, which is independent of Maven version. -Since the migration to Maven 4 in this repository focuses on JPMS-related module system features, and this example doesn't rely on JPMS, there is no need for a separate Maven 4 migration demonstration here. +Since the migration to Maven 4 in this repository focuses on Java Modules-related features, and this example doesn't rely on Java Modules, there is no need for a separate Maven 4 migration demonstration here. diff --git a/jigsaw-examples/example_derived_private-package-protected/README.adoc b/jigsaw-examples/example_derived_private-package-protected/README.adoc index 88c3b8b6..6ebdec15 100644 --- a/jigsaw-examples/example_derived_private-package-protected/README.adoc +++ b/jigsaw-examples/example_derived_private-package-protected/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_exceptions/README.adoc b/jigsaw-examples/example_exceptions/README.adoc index 91a13b9c..ca828503 100644 --- a/jigsaw-examples/example_exceptions/README.adoc +++ b/jigsaw-examples/example_exceptions/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_gradle-project/README.adoc b/jigsaw-examples/example_gradle-project/README.adoc index 037094bc..aa8559fa 100644 --- a/jigsaw-examples/example_gradle-project/README.adoc +++ b/jigsaw-examples/example_gradle-project/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_hiddenmain/README.adoc b/jigsaw-examples/example_hiddenmain/README.adoc index 3cf5d574..b388232a 100644 --- a/jigsaw-examples/example_hiddenmain/README.adoc +++ b/jigsaw-examples/example_hiddenmain/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_interface-callback/README.adoc b/jigsaw-examples/example_interface-callback/README.adoc index 13522c7c..603eda98 100644 --- a/jigsaw-examples/example_interface-callback/README.adoc +++ b/jigsaw-examples/example_interface-callback/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_jerrymouse/README.adoc b/jigsaw-examples/example_jerrymouse/README.adoc index 23dd273d..447ca4ff 100644 --- a/jigsaw-examples/example_jerrymouse/README.adoc +++ b/jigsaw-examples/example_jerrymouse/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_layer-hierarchy/README.adoc b/jigsaw-examples/example_layer-hierarchy/README.adoc index d521f2f5..40cbcfbb 100644 --- a/jigsaw-examples/example_layer-hierarchy/README.adoc +++ b/jigsaw-examples/example_layer-hierarchy/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== @@ -59,9 +59,9 @@ Because of that, _all_ modules already end up in the top layer, because top requ === Understanding the "Reads" Relationship and Split Package Problem -==== JPMS "Reads" Semantics +==== Java Modules "Reads" Semantics -In the Java Platform Module System (JPMS), when module A "reads" module B, it means: +In Java Modules, when module A "reads" module B, it means: * Module A has access to all packages that module B _exports_ * This is established via `requires` declarations in `module-info.java` for explicit modules @@ -86,7 +86,7 @@ In this example: * All modules are on the `--module-path`: `mlib` (application modules) + `amlib` (javax.json) * The compiler sees that `javax.json` reads three modules that all export the same package `pkgx` -* This violates the JPMS rule: "A module cannot read two modules that export the same package" +* This violates the Java Modules rule: "A module cannot read two modules that export the same package" * *Result:* Compilation fails with a split package error *Workaround:* The `mod.x_*` modules must be compiled _separately_ (see compile.sh lines 7-14), so they are never all on the module-path simultaneously when `javax.json` is present. @@ -101,7 +101,7 @@ In this example: [NOTE] ==== -This demonstrates an important aspect of JPMS: _layer isolation at runtime_ provides stronger encapsulation than what's possible at compile time with automatic modules. +This demonstrates an important aspect of Java Modules: _layer isolation at runtime_ provides stronger encapsulation than what's possible at compile time with automatic modules. The compile-time restriction is necessary because automatic modules have automatic reads to all modules, but at runtime, layers provide the isolation needed to avoid conflicts. For more details, see this https://mail.openjdk.java.net/pipermail/jigsaw-dev/2016-September/009290.html[discussion in the jigsaw-dev mailing list]. diff --git a/jigsaw-examples/example_layer-modules-all-in-boot-layer/README.adoc b/jigsaw-examples/example_layer-modules-all-in-boot-layer/README.adoc index 2432ab3e..44806ea0 100644 --- a/jigsaw-examples/example_layer-modules-all-in-boot-layer/README.adoc +++ b/jigsaw-examples/example_layer-modules-all-in-boot-layer/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/README.adoc b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/README.adoc index 9407ee50..87f6b95e 100644 --- a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/README.adoc +++ b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_layer-modules-module-resolution/README.adoc b/jigsaw-examples/example_layer-modules-module-resolution/README.adoc index 75a9a431..9a9935eb 100644 --- a/jigsaw-examples/example_layer-modules-module-resolution/README.adoc +++ b/jigsaw-examples/example_layer-modules-module-resolution/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_maven-project/README.adoc b/jigsaw-examples/example_maven-project/README.adoc index b78e0601..9151729e 100644 --- a/jigsaw-examples/example_maven-project/README.adoc +++ b/jigsaw-examples/example_maven-project/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_maven-test-blackbox/README.adoc b/jigsaw-examples/example_maven-test-blackbox/README.adoc index bce858f7..0bd8d883 100644 --- a/jigsaw-examples/example_maven-test-blackbox/README.adoc +++ b/jigsaw-examples/example_maven-test-blackbox/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_maven-test-whitebox/README.adoc b/jigsaw-examples/example_maven-test-whitebox/README.adoc index 5a2b4393..8384b252 100644 --- a/jigsaw-examples/example_maven-test-whitebox/README.adoc +++ b/jigsaw-examples/example_maven-test-whitebox/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_naming-modules/README.adoc b/jigsaw-examples/example_naming-modules/README.adoc index cbdf44f5..52e0bff9 100644 --- a/jigsaw-examples/example_naming-modules/README.adoc +++ b/jigsaw-examples/example_naming-modules/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_patch/README.adoc b/jigsaw-examples/example_patch/README.adoc index ce10e6bf..82050292 100644 --- a/jigsaw-examples/example_patch/README.adoc +++ b/jigsaw-examples/example_patch/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_reflection/README.adoc b/jigsaw-examples/example_reflection/README.adoc index a929b2ea..8ed6bafc 100644 --- a/jigsaw-examples/example_reflection/README.adoc +++ b/jigsaw-examples/example_reflection/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_requires-static/README.adoc b/jigsaw-examples/example_requires-static/README.adoc index 2c0c115c..ac4abca8 100644 --- a/jigsaw-examples/example_requires-static/README.adoc +++ b/jigsaw-examples/example_requires-static/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_requires_exports-to/README.adoc b/jigsaw-examples/example_requires_exports-to/README.adoc index 43917993..aa7afdf3 100644 --- a/jigsaw-examples/example_requires_exports-to/README.adoc +++ b/jigsaw-examples/example_requires_exports-to/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_requires_exports/README.adoc b/jigsaw-examples/example_requires_exports/README.adoc index 21209de9..04943315 100644 --- a/jigsaw-examples/example_requires_exports/README.adoc +++ b/jigsaw-examples/example_requires_exports/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/README.adoc b/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/README.adoc index 970e2eef..11efcac6 100644 --- a/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/README.adoc +++ b/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_resolved-modules/README.adoc b/jigsaw-examples/example_resolved-modules/README.adoc index 7d0d85b2..f2f33f7b 100644 --- a/jigsaw-examples/example_resolved-modules/README.adoc +++ b/jigsaw-examples/example_resolved-modules/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_resources/README.adoc b/jigsaw-examples/example_resources/README.adoc index 00f8b153..aa1c3e77 100644 --- a/jigsaw-examples/example_resources/README.adoc +++ b/jigsaw-examples/example_resources/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_splitpackage/README.adoc b/jigsaw-examples/example_splitpackage/README.adoc index 1275e16f..bab45b55 100644 --- a/jigsaw-examples/example_splitpackage/README.adoc +++ b/jigsaw-examples/example_splitpackage/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== @@ -66,7 +66,7 @@ The migration demonstrates an important constraint of the split package problem. * `modsplitbar2` - Second module with package `pkgbar` The foo modules (`modmainfoo`, `modsplitfoo1`, `modsplitfoo2`) _cannot_ be compiled because `modmainfoo` requires both `modsplitfoo1` and `modsplitfoo2`, which both export package `pkgfoo`. -This violates JPMS rules at compile time. +This violates Java Module rules at compile time. ==== Golden Master Testing diff --git a/jigsaw-examples/example_splitpackage_automatic-modules/README.adoc b/jigsaw-examples/example_splitpackage_automatic-modules/README.adoc index 61fe1a86..57429f10 100644 --- a/jigsaw-examples/example_splitpackage_automatic-modules/README.adoc +++ b/jigsaw-examples/example_splitpackage_automatic-modules/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_spring-hibernate/README.adoc b/jigsaw-examples/example_spring-hibernate/README.adoc index fd5fe976..aa9b6361 100644 --- a/jigsaw-examples/example_spring-hibernate/README.adoc +++ b/jigsaw-examples/example_spring-hibernate/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== @@ -71,7 +71,7 @@ So we had to exclude the `asm` version from `plexus-java` (which wants `asm-6.0- The application now compiles, tests and runs with Java 9. -==== Step C: Introducing a JPMS / Jigsaw module +==== Step C: Introducing a Java Module [start=8] . We converted `mod.app`into a module by adding a `module-info`. diff --git a/jigsaw-examples/example_test/README.adoc b/jigsaw-examples/example_test/README.adoc index 1335b3fc..b9d06072 100644 --- a/jigsaw-examples/example_test/README.adoc +++ b/jigsaw-examples/example_test/README.adoc @@ -8,7 +8,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/README.adoc b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/README.adoc index 1825074c..147561a0 100644 --- a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/README.adoc +++ b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_unnamed-module_access-from-automatic-module/README.adoc b/jigsaw-examples/example_unnamed-module_access-from-automatic-module/README.adoc index ee6782d0..1f220108 100644 --- a/jigsaw-examples/example_unnamed-module_access-from-automatic-module/README.adoc +++ b/jigsaw-examples/example_unnamed-module_access-from-automatic-module/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/README.adoc b/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/README.adoc index cdbbd15c..ab730327 100644 --- a/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/README.adoc +++ b/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_unnamed-module_access-from-explicit-module/README.adoc b/jigsaw-examples/example_unnamed-module_access-from-explicit-module/README.adoc index 9db09e5d..b05a06aa 100644 --- a/jigsaw-examples/example_unnamed-module_access-from-explicit-module/README.adoc +++ b/jigsaw-examples/example_unnamed-module_access-from-explicit-module/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_unnamed-module_accessing-module-path/README.adoc b/jigsaw-examples/example_unnamed-module_accessing-module-path/README.adoc index 91223212..7adb88f5 100644 --- a/jigsaw-examples/example_unnamed-module_accessing-module-path/README.adoc +++ b/jigsaw-examples/example_unnamed-module_accessing-module-path/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_uses-provides/README.adoc b/jigsaw-examples/example_uses-provides/README.adoc index 5231624f..d6b7fcd5 100644 --- a/jigsaw-examples/example_uses-provides/README.adoc +++ b/jigsaw-examples/example_uses-provides/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_uses-provides_uses-in-client/README.adoc b/jigsaw-examples/example_uses-provides_uses-in-client/README.adoc index 68c8226b..489fef62 100644 --- a/jigsaw-examples/example_uses-provides_uses-in-client/README.adoc +++ b/jigsaw-examples/example_uses-provides_uses-in-client/README.adoc @@ -15,7 +15,7 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== diff --git a/jigsaw-examples/example_version/README.adoc b/jigsaw-examples/example_version/README.adoc index 5c0c4a62..5a523384 100644 --- a/jigsaw-examples/example_version/README.adoc +++ b/jigsaw-examples/example_version/README.adoc @@ -15,13 +15,14 @@ Part of the full xref:../../README.adoc[Java 9 Jigsaw modules example] suite. ==== Originally written by https://github.com/mrtnlhmnn[Martin Lehmann], https://github.com/kristines[Kristine Schaal] and https://github.com/rgrammes[RΓΌdiger Grammes] (cf. https://github.com/accso/java9-jigsaw-examples[original repository]). -Migrated for JPMS support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. +Migrated for Java Modules support documentation of Apache Maven^TM^ in the course of the https://open-elements.com/support-care-maven/[Maven Support & Care] program by https://github.com/ascheman[Gerd Aschemann] (and other team members) as https://github.com/support-and-care/java9-jigsaw-examples[forked repository]. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. ==== == What is this example about? -This example is not really about the Jigsaw/JPMS module system. Instead it shows that usage of the new versioning scheme. +This example is not really about Java Modules. +Instead, it shows that usage of the new versioning scheme. For more background information, refer to https://openjdk.java.net/jeps/223[JEP 223]. From 37182a3506e52dc498153851732121d8cb4ec640 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Fri, 21 Nov 2025 12:09:00 +0100 Subject: [PATCH 11/15] Fix/streamline base documentation --- README.adoc | 68 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 23 deletions(-) diff --git a/README.adoc b/README.adoc index d2854a09..f7e47d31 100755 --- a/README.adoc +++ b/README.adoc @@ -32,20 +32,24 @@ However, the official terminology has since shifted to "Java Modules" or "Java P In this documentation, both terms may be used interchangeably, but "Java Modules" is the preferred term in current contexts. ==== +Meanwhile, we extended many examples to work (currently) with Maven 4 to demonstrate the current state of the art in terms of Maven support for Java Modules. + == Setup . Clone this repository . Ensure you meet the _Minimal Requirements_ . Then either follow the _Quick Setup_ or the _Full Setup_ -. Finally _Run Examples_ +. Finally, _Run Examples_ +[[sec:minimal-requirements]] === Minimal Requirements -. If running on Windows, install a bash, like for example https://babun.github.io/[Babun] or https://gitforwindows.org/[git bash] +. If running on Windows, install a bash, like, for example, https://babun.github.io/[Babun] or https://gitforwindows.org/[git bash] . Install Java JDKs: -** See <> for the recommended version for full CI (automated testing) compatibility -** For xref:jigsaw-examples/example_gradle-project/README.adoc[Gradle example]: Java 17 or later (required by Gradle 9.x) -** For xref:jigsaw-examples/example_compile-target-jdk8/README.adoc[cross-compilation example]: Java 8 +** See <> for the recommended version for full CI (automated testing) compatibility. +** For Maven 4 and xref:jigsaw-examples/example_gradle-project/README.adoc[Gradle example]: Java 17 or later is required. +** For the xref:jigsaw-examples/example_compile-target-jdk8/README.adoc[cross-compilation example]: Java 8. +. Install Maven 4 if you want to run the Maven 4 migrated examples (cf. <>). [[recommended-jdk]] [NOTE] @@ -53,7 +57,7 @@ In this documentation, both terms may be used interchangeably, but "Java Modules ==== The following JDK version is *strongly recommended* for full compatibility with CI and automated testing: -[source,yaml] +[source,yaml,indent=0] ---- include::.github/workflows/build.yml[tag=java-version-minimal] ---- @@ -85,7 +89,7 @@ cp .envrc-template .envrc Then either: * *Option 1:* Source it manually before running examples: `source .envrc` -* *Option 2:* Use https://direnv.net/[direnv] to automatically load environment when entering this directory +* *Option 2:* Use https://direnv.net/[direnv] to automatically load the environment when entering this directory [NOTE] .SDKMAN Users @@ -101,8 +105,8 @@ If you experience version conflicts, either disable `sdkman_auto_env` or ensure . Edit file `env.sh` to configure `JAVA_HOME`, `JAVA_HOME_JDK8`, `GRAPHVIZ_HOME`, and `DEPVIS_HOME` (see TODO markers in the file) ** See <> for the recommended `JAVA_HOME` value . Also edit file `env.sh` to configure the path separator. -If run on Windows, use \; (a blackslash quoting a ;). -If you run all stuff on *nix, use a colon : . +If run on Windows, use `\;` (a blackslash quoting a `;`). +If you run all stuff on *nix, use a colon `:` . === Running Examples @@ -147,16 +151,15 @@ cd jigsaw-examples [[golden-master-testing]] === Golden Master Testing -Most examples in this repository use golden master testing (also known as characterization testing or approval testing) to ensure output consistency. +Most examples in this repository use golden master testing, also known as characterization testing or approval testing, to ensure output consistency. This technique captures the expected output of a program and compares it against actual output during subsequent runs. -*How it works in this repository:* - +How it works in this repository:: * Each example with golden master testing has an `expected-result/run.txt` file containing the captured expected output * When you run `./verify.sh` in an example directory, it executes the example and compares the actual output (saved to `run-result/run.txt`) with the expected output * The test passes if both outputs match exactly -*Why some examples don't have golden master testing:* +Why some examples don't have a golden master testing:: Examples that use build tools (Maven, Gradle) or frameworks (Spring Boot) typically produce output that varies between runs. This includes timestamps, absolute file paths, download progress messages, port numbers, and environment-specific information. @@ -164,20 +167,39 @@ For these examples, manual verification or integration tests are more appropriat === Additional information -All examples have been tested with the <> on Windows, Linux, and macOS. -The examples were originally developed with Java 9 (which introduced JPMS) and have been continuously updated to work with current LTS versions. +==== Shell based Build + Excution + +Originally, the examples were using shell scripts to compile, execute and create additional artifacts, e.g., Java Docs. +All examples run with scripts which have been tested with bash only. + +==== Operating Systems -*Using Build Tool Wrappers:* +All the examples have been successfully tested with Windows (64bit), Linux and macOS - running the <>. +Originally developed for Java 9, which introduced Java Modules, the examples are frequently updated for current Java versions. +==== Build tool usage + +For convenience and automatic testing, other (migrated) examples come with build scripts which call the respective build tool. + +_Important_: Set `JAVA_HOME` (or `JAVA17_HOME` separately) to JDK 17+ before running Maven 4 or Gradle (Wrapper): `export JAVA_HOME=/path/to/jdk17` (or use `JAVA_HOME=... ./gradlew ...`). Maven Wrapper examples only require JDK 11+ as they use Mavne 3. + +Build Tool Wrappers:: +All original Maven and Gradle examples now include build tool wrappers, so manual installation of Maven or Gradle is no longer required (to execute then): * For Maven examples: Use `./mvnw` (Unix/Mac) or `mvnw.cmd` (Windows) instead of `mvn` * For Gradle example: Use `./gradlew` (Unix/Mac) or `gradlew.cmd` (Windows) instead of `gradle` -** *Important*: Set `JAVA_HOME` to JDK 17+ before running: `export JAVA_HOME=/path/to/jdk17` (or use `JAVA_HOME=... ./gradlew ...`) -[NOTE] +Maven 4 Builds:: As we simply want to use Maven 4 and to switch (minor) versions, a local installation of Maven 4 is required (cf. <>). + +[TIP] ==== -All scripts have been tested with bash only. -There might be minor issues with the *.sh scripts whenever they call each other. -To be sure, you should use all of these clean, compile, run, test etc. scripts in a bash. +Use a local Maven repository to avoid polluting your global one, set a repository location in the top level directory: + +[source,bash] +---- +export MAVEN_OPTS="-Dmaven.repo.local=${PWD}/.m2/repository" +---- + +Note that this overrides any other settings, e.g., by `mvn_settings.xml`. ==== == Overall conventions @@ -421,7 +443,7 @@ Migration attempted but not yet complete. *N/A*:: Not applicable. -Example uses Maven/Gradle directly, or migration is not relevant to JPMS features. +Example uses Maven/Gradle directly, or migration is not relevant to Java Modules features. Click the status icon to jump to the example's Maven 4 Migration section for details. **** @@ -713,7 +735,7 @@ Relates to all other examples in this section. | xref:jigsaw-examples/example_compile-target-jdk8/README.adoc[compile-target-jdk8] | What happens when one compiles with a modern JDK while targeting Java release 8 for backwards compatibility? | -| xref:jigsaw-examples/example_compile-target-jdk8/README.adoc#sec:maven-4-migration[icon:exclamation-triangle[role=yellow]] / link:{example-base}/example_compile-target-jdk8/m4/[code] +| N/A 4+| *Examples on non-Jigsaw topics* From 52b06ad7e56c05cb12a1055f100f697dab148a28 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Tue, 25 Nov 2025 10:08:32 +0100 Subject: [PATCH 12/15] Restructure example_resources m4 src layout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reorganize m4/src directory to follow proper Maven directory structure with separate java/ and resources/ subdirectories for each module. This change addresses Java compiler limitations with symlinked source files. Changes: - Restructure m4/src with Maven-standard layout: - src/{module}/main/java/ for Java source files - src/{module}/main/resources/ for resource files - Copy all source files (symlinks don't work with javac) - Update pom.xml to read resources from new structure - Add verify-sources.sh to ensure consistency with ../src - Update verify.sh to call verify-sources.sh as Step 0 - Document structure and symlink limitation in README.adoc Technical limitation: The Java compiler cannot resolve module structure when source files are symlinked from outside the module source path (--module-source-path). When javac encounters such symlinks, it fails with "module not found on module source path" errors. Therefore, m4/src/ contains full copies of all files from ../src/, reorganized into Maven's standard directory layout. The verify-sources.sh script validates that all files remain identical between ../src and m4/src despite different layouts, running automatically as part of the verification workflow. πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Introduced in the course of support-and-care/maven-support-and-care#137 --- jigsaw-examples/example_resources/README.adoc | 51 +++++- jigsaw-examples/example_resources/m4/pom.xml | 40 +---- .../example_resources/m4/src/modb/main/java | 1 - .../m4/src/modb/main/java/module-info.java | 6 + .../m4/src/modb/main/java/pkgb/B.java | 46 ++++++ .../main/java/pkgbinternal/BInternal.java | 5 + .../src/modb/main/resources/pkgb/b.properties | 2 + .../pkgbinternal/binternal.properties | 2 + .../resources.modb/resources.properties | 2 + .../example_resources/m4/src/modc/main/java | 1 - .../m4/src/modc/main/java/module-info.java | 4 + .../m4/src/modc/main/java/pkgc/C.java | 21 +++ .../main/java/pkgcinternal/CInternal.java | 5 + .../modc/main/resources/cnopackage.properties | 2 + .../src/modc/main/resources/pkgc/c.properties | 2 + .../pkgcinternal/cinternal.properties | 2 + .../resources.modc/resources.properties | 2 + .../example_resources/m4/verify-sources.sh | 84 ++++++++++ .../example_resources/m4/verify.sh | 5 + .../src/modb/module-info.java | 12 +- .../example_resources/src/modb/pkgb/B.java | 92 +++++------ .../src/modb/pkgb/b.properties | 4 +- .../src/modb/pkgbinternal/BInternal.java | 10 +- .../modb/pkgbinternal/binternal.properties | 2 +- .../modb/resources.modb/resources.properties | 2 +- .../src/modc/cnopackage.properties | 2 +- .../src/modc/module-info.java | 8 +- .../example_resources/src/modc/pkgc/C.java | 42 ++--- .../src/modc/pkgc/c.properties | 2 +- .../src/modc/pkgcinternal/CInternal.java | 10 +- .../modc/pkgcinternal/cinternal.properties | 2 +- .../modc/resources.modc/resources.properties | 2 +- .../src/modmain/module-info.java | 6 +- .../src/modmain/pkgmain/Main.java | 148 +++++++++--------- 34 files changed, 412 insertions(+), 215 deletions(-) delete mode 120000 jigsaw-examples/example_resources/m4/src/modb/main/java create mode 100644 jigsaw-examples/example_resources/m4/src/modb/main/java/module-info.java create mode 100644 jigsaw-examples/example_resources/m4/src/modb/main/java/pkgb/B.java create mode 100644 jigsaw-examples/example_resources/m4/src/modb/main/java/pkgbinternal/BInternal.java create mode 100644 jigsaw-examples/example_resources/m4/src/modb/main/resources/pkgb/b.properties create mode 100644 jigsaw-examples/example_resources/m4/src/modb/main/resources/pkgbinternal/binternal.properties create mode 100644 jigsaw-examples/example_resources/m4/src/modb/main/resources/resources.modb/resources.properties delete mode 120000 jigsaw-examples/example_resources/m4/src/modc/main/java create mode 100644 jigsaw-examples/example_resources/m4/src/modc/main/java/module-info.java create mode 100644 jigsaw-examples/example_resources/m4/src/modc/main/java/pkgc/C.java create mode 100644 jigsaw-examples/example_resources/m4/src/modc/main/java/pkgcinternal/CInternal.java create mode 100644 jigsaw-examples/example_resources/m4/src/modc/main/resources/cnopackage.properties create mode 100644 jigsaw-examples/example_resources/m4/src/modc/main/resources/pkgc/c.properties create mode 100644 jigsaw-examples/example_resources/m4/src/modc/main/resources/pkgcinternal/cinternal.properties create mode 100644 jigsaw-examples/example_resources/m4/src/modc/main/resources/resources.modc/resources.properties create mode 100755 jigsaw-examples/example_resources/m4/verify-sources.sh diff --git a/jigsaw-examples/example_resources/README.adoc b/jigsaw-examples/example_resources/README.adoc index aa1c3e77..9b8e3a59 100644 --- a/jigsaw-examples/example_resources/README.adoc +++ b/jigsaw-examples/example_resources/README.adoc @@ -67,7 +67,52 @@ include::m4/run-result/run.txt[] [[sec:maven-4-migration]] == Maven 4 Migration -This example was migrated to Maven 4 using the standard approach documented in the xref:../../README.adoc#maven-4-migration[central Maven 4 Migration guide]. +This example was migrated to Maven 4 with a special source tree structure to properly separate Java source files from resources, following Maven conventions. -The source files follow the standard Module Source Hierarchy setup. -Resource handling required explicit configuration of `maven-resources-plugin` to copy `.properties` files from the modular source directories to the target classes directories, as the hybrid compilation approach only packages compiled `.class` files by default. \ No newline at end of file +The `m4/src` directory follows proper Maven directory conventions with separate `java/` and `resources/` subdirectories: + +[source] +---- +m4/src/ +β”œβ”€β”€ modb/main/ +β”‚ β”œβ”€β”€ java/ # Java source files only +β”‚ β”‚ β”œβ”€β”€ module-info.java +β”‚ β”‚ β”œβ”€β”€ pkgb/B.java +β”‚ β”‚ └── pkgbinternal/BInternal.java +β”‚ └── resources/ # Resource files only +β”‚ β”œβ”€β”€ pkgb/b.properties +β”‚ β”œβ”€β”€ pkgbinternal/binternal.properties +β”‚ └── resources.modb/resources.properties +β”œβ”€β”€ modc/main/ +β”‚ β”œβ”€β”€ java/ # Java source files only +β”‚ β”‚ β”œβ”€β”€ module-info.java +β”‚ β”‚ β”œβ”€β”€ pkgc/C.java +β”‚ β”‚ └── pkgcinternal/CInternal.java +β”‚ └── resources/ # Resource files only +β”‚ β”œβ”€β”€ cnopackage.properties +β”‚ β”œβ”€β”€ pkgc/c.properties +β”‚ β”œβ”€β”€ pkgcinternal/cinternal.properties +β”‚ └── resources.modc/resources.properties +└── modmain/main/ + └── java/ # Java source files only (no resources) + β”œβ”€β”€ module-info.java + β”œβ”€β”€ pkgmain/Main.java + └── pkgmaininternal/IdGen.java +---- + +This structure differs from the original `src/` directory where Java and resource files coexist in the same package directories. +The Maven build properly handles resources through explicit `maven-resources-plugin` configuration that copies resource files from `src//main/resources` to `target/classes/`. + +[CAUTION] +.Why Source Files Are Copied, Not Symlinked +==== +Unlike other examples where we use symbolic links to reference the original `src/` directory, this example requires _full copies_ of all source files in `m4/src/`. + +The Java compiler cannot properly resolve module structure when individual source files are symlinked from locations outside the module source path. +When using `--module-source-path`, `javac` expects all files of a module to reside within a single directory tree and fails with "module not found on module source path" errors when encountering symlinks pointing outside that tree. + +Therefore, `m4/src/` contains actual file copies of all Java sources and resources from the original `src/` directory, reorganized into Maven's standard directory structure. + +To ensure consistency between the original sources and the Maven 4 copies, the `m4/verify-sources.sh` script validates that all files are identical despite the different directory layouts. +This script runs automatically as part of `m4/verify.sh`. +==== \ No newline at end of file diff --git a/jigsaw-examples/example_resources/m4/pom.xml b/jigsaw-examples/example_resources/m4/pom.xml index 98c33956..437f402b 100644 --- a/jigsaw-examples/example_resources/m4/pom.xml +++ b/jigsaw-examples/example_resources/m4/pom.xml @@ -52,14 +52,7 @@ ${project.build.directory}/classes/modb - src/modb/main/java - - **/*.properties - **/*.txt - - - **/*.java - + src/modb/main/resources @@ -74,36 +67,7 @@ ${project.build.directory}/classes/modc - src/modc/main/java - - **/*.properties - **/*.txt - - - **/*.java - - - - - - - copy-modmain-resources - process-resources - - copy-resources - - - ${project.build.directory}/classes/modmain - - - src/modmain/main/java - - **/*.properties - **/*.txt - - - **/*.java - + src/modc/main/resources diff --git a/jigsaw-examples/example_resources/m4/src/modb/main/java b/jigsaw-examples/example_resources/m4/src/modb/main/java deleted file mode 120000 index 7eb53275..00000000 --- a/jigsaw-examples/example_resources/m4/src/modb/main/java +++ /dev/null @@ -1 +0,0 @@ -../../../../src/modb \ No newline at end of file diff --git a/jigsaw-examples/example_resources/m4/src/modb/main/java/module-info.java b/jigsaw-examples/example_resources/m4/src/modb/main/java/module-info.java new file mode 100644 index 00000000..16115023 --- /dev/null +++ b/jigsaw-examples/example_resources/m4/src/modb/main/java/module-info.java @@ -0,0 +1,6 @@ +module modb { + requires transitive modc; + + exports pkgb; + opens pkgb; +} diff --git a/jigsaw-examples/example_resources/m4/src/modb/main/java/pkgb/B.java b/jigsaw-examples/example_resources/m4/src/modb/main/java/pkgb/B.java new file mode 100644 index 00000000..c8a06fbe --- /dev/null +++ b/jigsaw-examples/example_resources/m4/src/modb/main/java/pkgb/B.java @@ -0,0 +1,46 @@ +package pkgb; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import pkgc.*; + +public class B { + public String doIt() { + return "from B"; + } + + public C getMyC() { + return new C(); + } + + // access resources in modb + public String getTextFromProperties() throws IOException { + String resourceFileName = "/resources.modb/resources.properties"; // now we get modb's resources.properties + + final Properties properties = new Properties(); + try (final InputStream stream = B.class.getModule().getResourceAsStream(resourceFileName)) { + properties.load(stream); + } + return properties.getProperty("text", "modb's resources properties not found in modb"); + } + + // access resources in modc (from modb) + public String getTextFromMODCsProperties() throws IOException { + String resourceFileName = "/pkgc/c.properties"; // The resource path must be resolveable as a package name *and* this package has to be open (see modc's module-info.java) + // Note that just an export on this package name is not sufficient for access! + + final Properties properties = new Properties(); + try (final InputStream stream = C.class.getModule().getResourceAsStream(resourceFileName)) { + properties.load(stream); + } + String propertyFromMODC = properties.getProperty("text"); + if (propertyFromMODC == null) { + return "modc's resources properties not found via modb"; + } + else { + return propertyFromMODC + " - but retrieved via modb!"; + } + } +} diff --git a/jigsaw-examples/example_resources/m4/src/modb/main/java/pkgbinternal/BInternal.java b/jigsaw-examples/example_resources/m4/src/modb/main/java/pkgbinternal/BInternal.java new file mode 100644 index 00000000..e6fbc0b4 --- /dev/null +++ b/jigsaw-examples/example_resources/m4/src/modb/main/java/pkgbinternal/BInternal.java @@ -0,0 +1,5 @@ +package pkgbinternal; + +public class BInternal { +// does not do anything - just there to ensure that there is an package pkgbinternal +} diff --git a/jigsaw-examples/example_resources/m4/src/modb/main/resources/pkgb/b.properties b/jigsaw-examples/example_resources/m4/src/modb/main/resources/pkgb/b.properties new file mode 100644 index 00000000..8f9a497f --- /dev/null +++ b/jigsaw-examples/example_resources/m4/src/modb/main/resources/pkgb/b.properties @@ -0,0 +1,2 @@ +# Can only be accessed from outside modb, if package pkgb is open'ed in modb's module-info +text=Hello World, from modb's b.properties (whose package is opened) diff --git a/jigsaw-examples/example_resources/m4/src/modb/main/resources/pkgbinternal/binternal.properties b/jigsaw-examples/example_resources/m4/src/modb/main/resources/pkgbinternal/binternal.properties new file mode 100644 index 00000000..0a18c4a9 --- /dev/null +++ b/jigsaw-examples/example_resources/m4/src/modb/main/resources/pkgbinternal/binternal.properties @@ -0,0 +1,2 @@ +# Can only be accessed from outside modb, if package pkgbinternal would be open'ed in modb's module-info +text=Hello World, from modb's binternal.properties (whose package is not opened) \ No newline at end of file diff --git a/jigsaw-examples/example_resources/m4/src/modb/main/resources/resources.modb/resources.properties b/jigsaw-examples/example_resources/m4/src/modb/main/resources/resources.modb/resources.properties new file mode 100644 index 00000000..eb42fd66 --- /dev/null +++ b/jigsaw-examples/example_resources/m4/src/modb/main/resources/resources.modb/resources.properties @@ -0,0 +1,2 @@ +# Can only be accessed from outside modb, if package resources.modb would be open'ed in modb's module-info +text=Hello World, from modb's resources.properties \ No newline at end of file diff --git a/jigsaw-examples/example_resources/m4/src/modc/main/java b/jigsaw-examples/example_resources/m4/src/modc/main/java deleted file mode 120000 index 0acd5eeb..00000000 --- a/jigsaw-examples/example_resources/m4/src/modc/main/java +++ /dev/null @@ -1 +0,0 @@ -../../../../src/modc \ No newline at end of file diff --git a/jigsaw-examples/example_resources/m4/src/modc/main/java/module-info.java b/jigsaw-examples/example_resources/m4/src/modc/main/java/module-info.java new file mode 100644 index 00000000..424f99db --- /dev/null +++ b/jigsaw-examples/example_resources/m4/src/modc/main/java/module-info.java @@ -0,0 +1,4 @@ +module modc { + exports pkgc; + opens pkgc; +} diff --git a/jigsaw-examples/example_resources/m4/src/modc/main/java/pkgc/C.java b/jigsaw-examples/example_resources/m4/src/modc/main/java/pkgc/C.java new file mode 100644 index 00000000..7da97484 --- /dev/null +++ b/jigsaw-examples/example_resources/m4/src/modc/main/java/pkgc/C.java @@ -0,0 +1,21 @@ +package pkgc; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +public class C { + public String doIt() { + return "from C"; + } + + // access resources in modc! + public String getTextFromProperties() throws IOException { + final Properties properties = new Properties(); + try (final InputStream stream = this.getClass().getResourceAsStream("/resources.modc/resources.properties")) { + properties.load(stream); + } + + return properties.getProperty("text", "not found"); + } +} diff --git a/jigsaw-examples/example_resources/m4/src/modc/main/java/pkgcinternal/CInternal.java b/jigsaw-examples/example_resources/m4/src/modc/main/java/pkgcinternal/CInternal.java new file mode 100644 index 00000000..06c1020b --- /dev/null +++ b/jigsaw-examples/example_resources/m4/src/modc/main/java/pkgcinternal/CInternal.java @@ -0,0 +1,5 @@ +package pkgcinternal; + +public class CInternal { +// does not do anything - just there to ensure that there is an package pkgcinternal +} diff --git a/jigsaw-examples/example_resources/m4/src/modc/main/resources/cnopackage.properties b/jigsaw-examples/example_resources/m4/src/modc/main/resources/cnopackage.properties new file mode 100644 index 00000000..3358415e --- /dev/null +++ b/jigsaw-examples/example_resources/m4/src/modc/main/resources/cnopackage.properties @@ -0,0 +1,2 @@ +# Can always be accessed from outside modc, because this resource file is in the unnamed package +text=Hello World, from modc's cnopackage.properties (whose unnamed package is always not encapsulated) \ No newline at end of file diff --git a/jigsaw-examples/example_resources/m4/src/modc/main/resources/pkgc/c.properties b/jigsaw-examples/example_resources/m4/src/modc/main/resources/pkgc/c.properties new file mode 100644 index 00000000..12e3c333 --- /dev/null +++ b/jigsaw-examples/example_resources/m4/src/modc/main/resources/pkgc/c.properties @@ -0,0 +1,2 @@ +# Can only be accessed from outside modc, if package pkgc is open'ed in modb's module-info +text=Hello World, from modc's c.properties (whose package is opened) \ No newline at end of file diff --git a/jigsaw-examples/example_resources/m4/src/modc/main/resources/pkgcinternal/cinternal.properties b/jigsaw-examples/example_resources/m4/src/modc/main/resources/pkgcinternal/cinternal.properties new file mode 100644 index 00000000..733aa360 --- /dev/null +++ b/jigsaw-examples/example_resources/m4/src/modc/main/resources/pkgcinternal/cinternal.properties @@ -0,0 +1,2 @@ +# Can only be accessed from outside modc, if package pkgcinternal would be open'ed in modb's module-info +text=Hello World, from modc's cinternal.properties (whose package is not opened) \ No newline at end of file diff --git a/jigsaw-examples/example_resources/m4/src/modc/main/resources/resources.modc/resources.properties b/jigsaw-examples/example_resources/m4/src/modc/main/resources/resources.modc/resources.properties new file mode 100644 index 00000000..6a5400da --- /dev/null +++ b/jigsaw-examples/example_resources/m4/src/modc/main/resources/resources.modc/resources.properties @@ -0,0 +1,2 @@ +# Can only be accessed from outside modc, if package resources.modc would be open'ed in modb's module-info +text=Hello World, from modc's resources.properties \ No newline at end of file diff --git a/jigsaw-examples/example_resources/m4/verify-sources.sh b/jigsaw-examples/example_resources/m4/verify-sources.sh new file mode 100755 index 00000000..f4b97f2a --- /dev/null +++ b/jigsaw-examples/example_resources/m4/verify-sources.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +set -eu -o pipefail + +echo "=== Verifying source file consistency between ../src and m4/src ===" +echo + +# Track if any differences found +DIFFERENCES_FOUND=0 + +# Find all files in ../src (excluding .gitignore) +while IFS= read -r -d '' srcfile; do + # Get relative path from ../src + relpath="${srcfile#../src/}" + + # Extract module name (first directory component) + module="${relpath%%/*}" + + # Get path after module name + pathInModule="${relpath#*/}" + + # Determine if it's a Java file or resource file + if [[ "${pathInModule}" == *.java ]]; then + # Java file: should be in src/{module}/main/java/{path} + m4file="src/${module}/main/java/${pathInModule}" + else + # Resource file: should be in src/{module}/main/resources/{path} + m4file="src/${module}/main/resources/${pathInModule}" + fi + + # Check if m4 file exists + if [[ ! -f "${m4file}" ]]; then + echo "ERROR: Missing file in m4/src: ${m4file}" + echo " Expected from: ${srcfile}" + DIFFERENCES_FOUND=1 + continue + fi + + # Compare file contents + if ! diff -q "${srcfile}" "${m4file}" > /dev/null 2>&1; then + echo "ERROR: File content differs:" + echo " Source: ${srcfile}" + echo " M4: ${m4file}" + echo " Diff:" + diff -u "${srcfile}" "${m4file}" | head -20 + DIFFERENCES_FOUND=1 + fi +done < <(find ../src -type f ! -name '.gitignore' -print0) + +# Check for extra files in m4/src that don't exist in ../src +while IFS= read -r -d '' m4file; do + # Get relative path from src/ + relpath="${m4file#src/}" + + # Extract module name and determine original structure + if [[ "${relpath}" =~ ^([^/]+)/main/java/(.+)$ ]]; then + module="${BASH_REMATCH[1]}" + pathInModule="${BASH_REMATCH[2]}" + srcfile="../src/${module}/${pathInModule}" + elif [[ "${relpath}" =~ ^([^/]+)/main/resources/(.+)$ ]]; then + module="${BASH_REMATCH[1]}" + pathInModule="${BASH_REMATCH[2]}" + srcfile="../src/${module}/${pathInModule}" + else + echo "WARNING: Unexpected file structure: ${m4file}" + continue + fi + + # Check if source file exists + if [[ ! -f "${srcfile}" ]]; then + echo "ERROR: Extra file in m4/src not present in ../src:" + echo " M4: ${m4file}" + echo " Source: ${srcfile} (expected but not found)" + DIFFERENCES_FOUND=1 + fi +done < <(find src -type f ! -name '.gitignore' -print0) + +echo +if [[ ${DIFFERENCES_FOUND} -eq 0 ]]; then + echo "βœ… All source files are consistent between ../src and m4/src" + exit 0 +else + echo "❌ Differences found between ../src and m4/src" + exit 1 +fi diff --git a/jigsaw-examples/example_resources/m4/verify.sh b/jigsaw-examples/example_resources/m4/verify.sh index 9ab32b47..361bf764 100755 --- a/jigsaw-examples/example_resources/m4/verify.sh +++ b/jigsaw-examples/example_resources/m4/verify.sh @@ -14,6 +14,11 @@ fi echo "=== Verifying ${EXAMPLE_NAME} (Maven 4) ===" echo +# Step 0: Verify source file consistency +echo "Step 0: Verify source file consistency" +./verify-sources.sh +echo + # Check if expected result exists if [ ! -f "${EXPECTED}" ]; then echo "❌ ERROR: Expected result not found at ${EXPECTED}" diff --git a/jigsaw-examples/example_resources/src/modb/module-info.java b/jigsaw-examples/example_resources/src/modb/module-info.java index a5fde7db..16115023 100644 --- a/jigsaw-examples/example_resources/src/modb/module-info.java +++ b/jigsaw-examples/example_resources/src/modb/module-info.java @@ -1,6 +1,6 @@ -module modb { - requires transitive modc; - - exports pkgb; - opens pkgb; -} +module modb { + requires transitive modc; + + exports pkgb; + opens pkgb; +} diff --git a/jigsaw-examples/example_resources/src/modb/pkgb/B.java b/jigsaw-examples/example_resources/src/modb/pkgb/B.java index 98f532e1..c8a06fbe 100644 --- a/jigsaw-examples/example_resources/src/modb/pkgb/B.java +++ b/jigsaw-examples/example_resources/src/modb/pkgb/B.java @@ -1,46 +1,46 @@ -package pkgb; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -import pkgc.*; - -public class B { - public String doIt() { - return "from B"; - } - - public C getMyC() { - return new C(); - } - - // access resources in modb - public String getTextFromProperties() throws IOException { - String resourceFileName = "/resources.modb/resources.properties"; // now we get modb's resources.properties - - final Properties properties = new Properties(); - try (final InputStream stream = B.class.getModule().getResourceAsStream(resourceFileName)) { - properties.load(stream); - } - return properties.getProperty("text", "modb's resources properties not found in modb"); - } - - // access resources in modc (from modb) - public String getTextFromMODCsProperties() throws IOException { - String resourceFileName = "/pkgc/c.properties"; // The resource path must be resolveable as a package name *and* this package has to be open (see modc's module-info.java) - // Note that just an export on this package name is not sufficient for access! - - final Properties properties = new Properties(); - try (final InputStream stream = C.class.getModule().getResourceAsStream(resourceFileName)) { - properties.load(stream); - } - String propertyFromMODC = properties.getProperty("text"); - if (propertyFromMODC == null) { - return "modc's resources properties not found via modb"; - } - else { - return propertyFromMODC + " - but retrieved via modb!"; - } - } -} +package pkgb; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import pkgc.*; + +public class B { + public String doIt() { + return "from B"; + } + + public C getMyC() { + return new C(); + } + + // access resources in modb + public String getTextFromProperties() throws IOException { + String resourceFileName = "/resources.modb/resources.properties"; // now we get modb's resources.properties + + final Properties properties = new Properties(); + try (final InputStream stream = B.class.getModule().getResourceAsStream(resourceFileName)) { + properties.load(stream); + } + return properties.getProperty("text", "modb's resources properties not found in modb"); + } + + // access resources in modc (from modb) + public String getTextFromMODCsProperties() throws IOException { + String resourceFileName = "/pkgc/c.properties"; // The resource path must be resolveable as a package name *and* this package has to be open (see modc's module-info.java) + // Note that just an export on this package name is not sufficient for access! + + final Properties properties = new Properties(); + try (final InputStream stream = C.class.getModule().getResourceAsStream(resourceFileName)) { + properties.load(stream); + } + String propertyFromMODC = properties.getProperty("text"); + if (propertyFromMODC == null) { + return "modc's resources properties not found via modb"; + } + else { + return propertyFromMODC + " - but retrieved via modb!"; + } + } +} diff --git a/jigsaw-examples/example_resources/src/modb/pkgb/b.properties b/jigsaw-examples/example_resources/src/modb/pkgb/b.properties index c0e3d3fd..8f9a497f 100644 --- a/jigsaw-examples/example_resources/src/modb/pkgb/b.properties +++ b/jigsaw-examples/example_resources/src/modb/pkgb/b.properties @@ -1,2 +1,2 @@ -# Can only be accessed from outside modb, if package pkgb is open'ed in modb's module-info -text=Hello World, from modb's b.properties (whose package is opened) +# Can only be accessed from outside modb, if package pkgb is open'ed in modb's module-info +text=Hello World, from modb's b.properties (whose package is opened) diff --git a/jigsaw-examples/example_resources/src/modb/pkgbinternal/BInternal.java b/jigsaw-examples/example_resources/src/modb/pkgbinternal/BInternal.java index 7fc2a83e..e6fbc0b4 100644 --- a/jigsaw-examples/example_resources/src/modb/pkgbinternal/BInternal.java +++ b/jigsaw-examples/example_resources/src/modb/pkgbinternal/BInternal.java @@ -1,5 +1,5 @@ -package pkgbinternal; - -public class BInternal { -// does not do anything - just there to ensure that there is an package pkgbinternal -} +package pkgbinternal; + +public class BInternal { +// does not do anything - just there to ensure that there is an package pkgbinternal +} diff --git a/jigsaw-examples/example_resources/src/modb/pkgbinternal/binternal.properties b/jigsaw-examples/example_resources/src/modb/pkgbinternal/binternal.properties index 4d0be75d..0a18c4a9 100644 --- a/jigsaw-examples/example_resources/src/modb/pkgbinternal/binternal.properties +++ b/jigsaw-examples/example_resources/src/modb/pkgbinternal/binternal.properties @@ -1,2 +1,2 @@ -# Can only be accessed from outside modb, if package pkgbinternal would be open'ed in modb's module-info +# Can only be accessed from outside modb, if package pkgbinternal would be open'ed in modb's module-info text=Hello World, from modb's binternal.properties (whose package is not opened) \ No newline at end of file diff --git a/jigsaw-examples/example_resources/src/modb/resources.modb/resources.properties b/jigsaw-examples/example_resources/src/modb/resources.modb/resources.properties index f888bcbe..eb42fd66 100644 --- a/jigsaw-examples/example_resources/src/modb/resources.modb/resources.properties +++ b/jigsaw-examples/example_resources/src/modb/resources.modb/resources.properties @@ -1,2 +1,2 @@ -# Can only be accessed from outside modb, if package resources.modb would be open'ed in modb's module-info +# Can only be accessed from outside modb, if package resources.modb would be open'ed in modb's module-info text=Hello World, from modb's resources.properties \ No newline at end of file diff --git a/jigsaw-examples/example_resources/src/modc/cnopackage.properties b/jigsaw-examples/example_resources/src/modc/cnopackage.properties index 5565149f..3358415e 100644 --- a/jigsaw-examples/example_resources/src/modc/cnopackage.properties +++ b/jigsaw-examples/example_resources/src/modc/cnopackage.properties @@ -1,2 +1,2 @@ -# Can always be accessed from outside modc, because this resource file is in the unnamed package +# Can always be accessed from outside modc, because this resource file is in the unnamed package text=Hello World, from modc's cnopackage.properties (whose unnamed package is always not encapsulated) \ No newline at end of file diff --git a/jigsaw-examples/example_resources/src/modc/module-info.java b/jigsaw-examples/example_resources/src/modc/module-info.java index 894d278f..424f99db 100644 --- a/jigsaw-examples/example_resources/src/modc/module-info.java +++ b/jigsaw-examples/example_resources/src/modc/module-info.java @@ -1,4 +1,4 @@ -module modc { - exports pkgc; - opens pkgc; -} +module modc { + exports pkgc; + opens pkgc; +} diff --git a/jigsaw-examples/example_resources/src/modc/pkgc/C.java b/jigsaw-examples/example_resources/src/modc/pkgc/C.java index ace3ac31..7da97484 100644 --- a/jigsaw-examples/example_resources/src/modc/pkgc/C.java +++ b/jigsaw-examples/example_resources/src/modc/pkgc/C.java @@ -1,21 +1,21 @@ -package pkgc; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -public class C { - public String doIt() { - return "from C"; - } - - // access resources in modc! - public String getTextFromProperties() throws IOException { - final Properties properties = new Properties(); - try (final InputStream stream = this.getClass().getResourceAsStream("/resources.modc/resources.properties")) { - properties.load(stream); - } - - return properties.getProperty("text", "not found"); - } -} +package pkgc; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +public class C { + public String doIt() { + return "from C"; + } + + // access resources in modc! + public String getTextFromProperties() throws IOException { + final Properties properties = new Properties(); + try (final InputStream stream = this.getClass().getResourceAsStream("/resources.modc/resources.properties")) { + properties.load(stream); + } + + return properties.getProperty("text", "not found"); + } +} diff --git a/jigsaw-examples/example_resources/src/modc/pkgc/c.properties b/jigsaw-examples/example_resources/src/modc/pkgc/c.properties index be0b8ccf..12e3c333 100644 --- a/jigsaw-examples/example_resources/src/modc/pkgc/c.properties +++ b/jigsaw-examples/example_resources/src/modc/pkgc/c.properties @@ -1,2 +1,2 @@ -# Can only be accessed from outside modc, if package pkgc is open'ed in modb's module-info +# Can only be accessed from outside modc, if package pkgc is open'ed in modb's module-info text=Hello World, from modc's c.properties (whose package is opened) \ No newline at end of file diff --git a/jigsaw-examples/example_resources/src/modc/pkgcinternal/CInternal.java b/jigsaw-examples/example_resources/src/modc/pkgcinternal/CInternal.java index 51535b0a..06c1020b 100644 --- a/jigsaw-examples/example_resources/src/modc/pkgcinternal/CInternal.java +++ b/jigsaw-examples/example_resources/src/modc/pkgcinternal/CInternal.java @@ -1,5 +1,5 @@ -package pkgcinternal; - -public class CInternal { -// does not do anything - just there to ensure that there is an package pkgcinternal -} +package pkgcinternal; + +public class CInternal { +// does not do anything - just there to ensure that there is an package pkgcinternal +} diff --git a/jigsaw-examples/example_resources/src/modc/pkgcinternal/cinternal.properties b/jigsaw-examples/example_resources/src/modc/pkgcinternal/cinternal.properties index e4aa68d9..733aa360 100644 --- a/jigsaw-examples/example_resources/src/modc/pkgcinternal/cinternal.properties +++ b/jigsaw-examples/example_resources/src/modc/pkgcinternal/cinternal.properties @@ -1,2 +1,2 @@ -# Can only be accessed from outside modc, if package pkgcinternal would be open'ed in modb's module-info +# Can only be accessed from outside modc, if package pkgcinternal would be open'ed in modb's module-info text=Hello World, from modc's cinternal.properties (whose package is not opened) \ No newline at end of file diff --git a/jigsaw-examples/example_resources/src/modc/resources.modc/resources.properties b/jigsaw-examples/example_resources/src/modc/resources.modc/resources.properties index cc337758..6a5400da 100644 --- a/jigsaw-examples/example_resources/src/modc/resources.modc/resources.properties +++ b/jigsaw-examples/example_resources/src/modc/resources.modc/resources.properties @@ -1,2 +1,2 @@ -# Can only be accessed from outside modc, if package resources.modc would be open'ed in modb's module-info +# Can only be accessed from outside modc, if package resources.modc would be open'ed in modb's module-info text=Hello World, from modc's resources.properties \ No newline at end of file diff --git a/jigsaw-examples/example_resources/src/modmain/module-info.java b/jigsaw-examples/example_resources/src/modmain/module-info.java index 082e392f..9628224f 100644 --- a/jigsaw-examples/example_resources/src/modmain/module-info.java +++ b/jigsaw-examples/example_resources/src/modmain/module-info.java @@ -1,3 +1,3 @@ -open module modmain { // allow reflective access, currently used in the example_jerry-mouse - requires modb; -} +open module modmain { // allow reflective access, currently used in the example_jerry-mouse + requires modb; +} diff --git a/jigsaw-examples/example_resources/src/modmain/pkgmain/Main.java b/jigsaw-examples/example_resources/src/modmain/pkgmain/Main.java index 8b0867ee..fbb548dd 100644 --- a/jigsaw-examples/example_resources/src/modmain/pkgmain/Main.java +++ b/jigsaw-examples/example_resources/src/modmain/pkgmain/Main.java @@ -1,74 +1,74 @@ -package pkgmain; - -import java.io.InputStream; -import java.util.Properties; -import java.io.IOException; - -import pkgb.B; -import pkgc.C; -import pkgmaininternal.IdGen; - -public class Main { - private String id; - - public Main() { - id = IdGen.createID(); - } - - public static void main(String[] args) throws IOException { - Main mymain = new Main(); - B myb = new B(); - - C myc = myb.getMyC(); - System.out.println("Main: " + mymain.toString() + ", B: " + myb.doIt() + ", C: " + myc.doIt()); - - System.out.println("B: Get text from modb's properties: " + myb.getTextFromProperties()); - System.out.println("C: Get text from modc's properties: " + myc.getTextFromProperties()); - - // ------------------------------------------------------------------------------------------------------------ - - // works, as resources.properties in modc is not encapsulated (because its location is not a package) - - System.out.println("B: Get text from modc's properties: " + myb.getTextFromMODCsProperties()); - - // ------------------------------------------------------------------------------------------------------------ - - System.out.println("Main: Get text from modb's /pkgb/b.properties , whose package is opened: " + getTextFromMODBProperties("/pkgb/b.properties")); - System.out.println("Main: Get text from modb's /pkgbinternal/binternal.properties , whose package is not opened: " + getTextFromMODBProperties("/pkgbinternal/pbinternal.properties")); - - System.out.println("Main: Get text from modc's /pkgc/c.properties , whose package is opened: " + getTextFromMODCProperties("/pkgc/c.properties")); - System.out.println("Main: Get text from modc's /pkgcinternal/cinternal.properties , whose package is not opened: " + getTextFromMODCProperties("/pkgcinternal/cinternal.properties")); - System.out.println("Main: Get text from modc's /cnopackage.properties , whose package is in the unnamed package: " + getTextFromMODCProperties("/cnopackage.properties")); - } - - public static String getTextFromMODBProperties(String resourceFileName) throws IOException { - final Properties properties = new Properties(); - try (final InputStream stream = B.class.getModule().getResourceAsStream(resourceFileName)) { - try { - properties.load(stream); - return properties.getProperty("text", "modb's " + resourceFileName + " not found in modmain"); - } - catch (NullPointerException npex) { - return "ERROR: Cannot be loaded"; - } - } - } - - public static String getTextFromMODCProperties(String resourceFileName) throws IOException { - final Properties properties = new Properties(); - try (final InputStream stream = C.class.getModule().getResourceAsStream(resourceFileName)) { - try { - properties.load(stream); - return properties.getProperty("text", "modc's " + resourceFileName + " not found in modmain"); - } - catch (NullPointerException npex) { - return "ERROR: Cannot be loaded"; - } - } - } - - @Override - public String toString() { - return this.getClass().getName() + ", id=" + id; - } -} +package pkgmain; + +import java.io.InputStream; +import java.util.Properties; +import java.io.IOException; + +import pkgb.B; +import pkgc.C; +import pkgmaininternal.IdGen; + +public class Main { + private String id; + + public Main() { + id = IdGen.createID(); + } + + public static void main(String[] args) throws IOException { + Main mymain = new Main(); + B myb = new B(); + + C myc = myb.getMyC(); + System.out.println("Main: " + mymain.toString() + ", B: " + myb.doIt() + ", C: " + myc.doIt()); + + System.out.println("B: Get text from modb's properties: " + myb.getTextFromProperties()); + System.out.println("C: Get text from modc's properties: " + myc.getTextFromProperties()); + + // ------------------------------------------------------------------------------------------------------------ + + // works, as resources.properties in modc is not encapsulated (because its location is not a package) + + System.out.println("B: Get text from modc's properties: " + myb.getTextFromMODCsProperties()); + + // ------------------------------------------------------------------------------------------------------------ + + System.out.println("Main: Get text from modb's /pkgb/b.properties , whose package is opened: " + getTextFromMODBProperties("/pkgb/b.properties")); + System.out.println("Main: Get text from modb's /pkgbinternal/binternal.properties , whose package is not opened: " + getTextFromMODBProperties("/pkgbinternal/pbinternal.properties")); + + System.out.println("Main: Get text from modc's /pkgc/c.properties , whose package is opened: " + getTextFromMODCProperties("/pkgc/c.properties")); + System.out.println("Main: Get text from modc's /pkgcinternal/cinternal.properties , whose package is not opened: " + getTextFromMODCProperties("/pkgcinternal/cinternal.properties")); + System.out.println("Main: Get text from modc's /cnopackage.properties , whose package is in the unnamed package: " + getTextFromMODCProperties("/cnopackage.properties")); + } + + public static String getTextFromMODBProperties(String resourceFileName) throws IOException { + final Properties properties = new Properties(); + try (final InputStream stream = B.class.getModule().getResourceAsStream(resourceFileName)) { + try { + properties.load(stream); + return properties.getProperty("text", "modb's " + resourceFileName + " not found in modmain"); + } + catch (NullPointerException npex) { + return "ERROR: Cannot be loaded"; + } + } + } + + public static String getTextFromMODCProperties(String resourceFileName) throws IOException { + final Properties properties = new Properties(); + try (final InputStream stream = C.class.getModule().getResourceAsStream(resourceFileName)) { + try { + properties.load(stream); + return properties.getProperty("text", "modc's " + resourceFileName + " not found in modmain"); + } + catch (NullPointerException npex) { + return "ERROR: Cannot be loaded"; + } + } + } + + @Override + public String toString() { + return this.getClass().getName() + ", id=" + id; + } +} From b7b5491efd2732bbca948dfbeb8d4fc6c6b6cedd Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Wed, 26 Nov 2025 16:47:00 +0100 Subject: [PATCH 13/15] Drop superfluous M4 src directory configs Compilation of Java Modules with Maven 4 / M4 Compiler Plugin follows convention-over-configuration approach by using src/// directories by default. Introduced in the course of support-and-care/maven-support-and-care#137 --- .../example_addExports_manifest/m4/pom.xml | 2 -- .../example_addReads_addExports/m4/pom.xml | 3 --- .../m4/pom.xml | 2 -- jigsaw-examples/example_annotations/m4/pom.xml | 3 --- .../example_automatic-module-logging/m4/pom.xml | 1 - .../m4/pom.xml | 2 -- jigsaw-examples/example_exceptions/m4/pom.xml | 2 -- jigsaw-examples/example_hiddenmain/m4/pom.xml | 1 - .../example_interface-callback/m4/pom.xml | 3 --- jigsaw-examples/example_jerrymouse/m4/pom.xml | 1 - jigsaw-examples/example_layer-hierarchy/m4/pom.xml | 12 ------------ .../m4/pom.xml | 4 ---- .../m4/pom.xml | 2 -- .../m4/pom.xml | 6 ------ jigsaw-examples/example_naming-modules/m4/pom.xml | 4 ---- jigsaw-examples/example_patch/m4/pom.xml | 2 -- jigsaw-examples/example_reflection/m4/pom.xml | 2 -- jigsaw-examples/example_requires-static/m4/pom.xml | 3 --- .../example_requires_exports-to/m4/pom.xml | 4 ---- jigsaw-examples/example_requires_exports/m4/pom.xml | 3 --- .../m4/pom.xml | 6 ------ jigsaw-examples/example_resolved-modules/m4/pom.xml | 3 --- jigsaw-examples/example_resources/m4/pom.xml | 3 --- jigsaw-examples/example_splitpackage/m4/pom.xml | 3 --- .../m4/pom.xml | 1 - jigsaw-examples/example_test/m4/pom.xml | 2 -- .../m4/pom.xml | 2 -- .../m4/pom.xml | 2 -- .../m4/pom.xml | 2 -- .../m4/pom.xml | 1 - jigsaw-examples/example_uses-provides/m4/pom.xml | 4 ---- .../example_uses-provides_uses-in-client/m4/pom.xml | 4 ---- jigsaw-examples/example_version/m4/pom.xml | 1 - 33 files changed, 96 deletions(-) diff --git a/jigsaw-examples/example_addExports_manifest/m4/pom.xml b/jigsaw-examples/example_addExports_manifest/m4/pom.xml index 7bcad3ef..7d7ebe77 100644 --- a/jigsaw-examples/example_addExports_manifest/m4/pom.xml +++ b/jigsaw-examples/example_addExports_manifest/m4/pom.xml @@ -19,11 +19,9 @@ moda - src/moda/main/java modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_addReads_addExports/m4/pom.xml b/jigsaw-examples/example_addReads_addExports/m4/pom.xml index f0f3e66c..3354f696 100644 --- a/jigsaw-examples/example_addReads_addExports/m4/pom.xml +++ b/jigsaw-examples/example_addReads_addExports/m4/pom.xml @@ -18,15 +18,12 @@ modb - src/modb/main/java modc - src/modc/main/java modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_addReads_addExports_reflection/m4/pom.xml b/jigsaw-examples/example_addReads_addExports_reflection/m4/pom.xml index 47a999ed..2ca8cfd0 100644 --- a/jigsaw-examples/example_addReads_addExports_reflection/m4/pom.xml +++ b/jigsaw-examples/example_addReads_addExports_reflection/m4/pom.xml @@ -18,11 +18,9 @@ modb - src/modb/main/java modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_annotations/m4/pom.xml b/jigsaw-examples/example_annotations/m4/pom.xml index 099555e2..e93ccb15 100644 --- a/jigsaw-examples/example_annotations/m4/pom.xml +++ b/jigsaw-examples/example_annotations/m4/pom.xml @@ -18,15 +18,12 @@ mod.annotations - src/mod.annotations/main/java modb - src/modb/main/java modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_automatic-module-logging/m4/pom.xml b/jigsaw-examples/example_automatic-module-logging/m4/pom.xml index 31169183..e1557968 100644 --- a/jigsaw-examples/example_automatic-module-logging/m4/pom.xml +++ b/jigsaw-examples/example_automatic-module-logging/m4/pom.xml @@ -26,7 +26,6 @@ modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_derived_private-package-protected/m4/pom.xml b/jigsaw-examples/example_derived_private-package-protected/m4/pom.xml index 3bb1fe25..41cfd0ea 100644 --- a/jigsaw-examples/example_derived_private-package-protected/m4/pom.xml +++ b/jigsaw-examples/example_derived_private-package-protected/m4/pom.xml @@ -18,11 +18,9 @@ modb - src/modb/main/java modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_exceptions/m4/pom.xml b/jigsaw-examples/example_exceptions/m4/pom.xml index 8c6d6af2..cdf26390 100644 --- a/jigsaw-examples/example_exceptions/m4/pom.xml +++ b/jigsaw-examples/example_exceptions/m4/pom.xml @@ -18,11 +18,9 @@ modb - src/modb/main/java modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_hiddenmain/m4/pom.xml b/jigsaw-examples/example_hiddenmain/m4/pom.xml index 60d61c5e..d9b9f804 100644 --- a/jigsaw-examples/example_hiddenmain/m4/pom.xml +++ b/jigsaw-examples/example_hiddenmain/m4/pom.xml @@ -18,7 +18,6 @@ modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_interface-callback/m4/pom.xml b/jigsaw-examples/example_interface-callback/m4/pom.xml index 66e56e66..568dc640 100644 --- a/jigsaw-examples/example_interface-callback/m4/pom.xml +++ b/jigsaw-examples/example_interface-callback/m4/pom.xml @@ -18,15 +18,12 @@ modcallbackhandler - src/modcallbackhandler/main/java modcallee - src/modcallee/main/java modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_jerrymouse/m4/pom.xml b/jigsaw-examples/example_jerrymouse/m4/pom.xml index 495329bc..e7a2f449 100644 --- a/jigsaw-examples/example_jerrymouse/m4/pom.xml +++ b/jigsaw-examples/example_jerrymouse/m4/pom.xml @@ -26,7 +26,6 @@ modstarter - src/modstarter/main/java diff --git a/jigsaw-examples/example_layer-hierarchy/m4/pom.xml b/jigsaw-examples/example_layer-hierarchy/m4/pom.xml index 976e17cd..c8d515b6 100644 --- a/jigsaw-examples/example_layer-hierarchy/m4/pom.xml +++ b/jigsaw-examples/example_layer-hierarchy/m4/pom.xml @@ -35,52 +35,40 @@ mod.layer - src/mod.layer/main/java mod.main - src/mod.main/main/java mod.u_bottom_middle_top - src/mod.u_bottom_middle_top/main/java mod.y_bottom - src/mod.y_bottom/main/java mod.y_middle - src/mod.y_middle/main/java mod.y_top - src/mod.y_top/main/java mod.z_bottom - src/mod.z_bottom/main/java mod.z_middle - src/mod.z_middle/main/java mod.z_top - src/mod.z_top/main/java mod.zreverse_bottom - src/mod.zreverse_bottom/main/java mod.zreverse_middle - src/mod.zreverse_middle/main/java mod.zreverse_top - src/mod.zreverse_top/main/java diff --git a/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/pom.xml b/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/pom.xml index c67976f4..8316aba6 100644 --- a/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/pom.xml +++ b/jigsaw-examples/example_layer-modules-all-in-boot-layer/m4/pom.xml @@ -19,19 +19,15 @@ modbar - src/modbar/main/java modcommon - src/modcommon/main/java modfoo - src/modfoo/main/java modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/pom.xml b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/pom.xml index 1d1d0e6f..6ed82a1a 100644 --- a/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/pom.xml +++ b/jigsaw-examples/example_layer-modules-grouped-in-hierarchy/m4/pom.xml @@ -20,11 +20,9 @@ modcommon - src/modcommon/main/java modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_layer-modules-module-resolution/m4/pom.xml b/jigsaw-examples/example_layer-modules-module-resolution/m4/pom.xml index 1b129495..38f735af 100644 --- a/jigsaw-examples/example_layer-modules-module-resolution/m4/pom.xml +++ b/jigsaw-examples/example_layer-modules-module-resolution/m4/pom.xml @@ -18,27 +18,21 @@ modbar - src/modbar/main/java modcommon - src/modcommon/main/java modfoo - src/modfoo/main/java modmain - src/modmain/main/java modversion1 - src/modversion1/main/java modversion2 - src/modversion2/main/java diff --git a/jigsaw-examples/example_naming-modules/m4/pom.xml b/jigsaw-examples/example_naming-modules/m4/pom.xml index d00c9336..5e7d8cda 100644 --- a/jigsaw-examples/example_naming-modules/m4/pom.xml +++ b/jigsaw-examples/example_naming-modules/m4/pom.xml @@ -29,19 +29,15 @@ mod.client - src/mod.client/main/java mod_client - src/mod_client/main/java modjava - src/modjava/main/java modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_patch/m4/pom.xml b/jigsaw-examples/example_patch/m4/pom.xml index 19d98cba..250f6437 100644 --- a/jigsaw-examples/example_patch/m4/pom.xml +++ b/jigsaw-examples/example_patch/m4/pom.xml @@ -21,11 +21,9 @@ modmain - src/modmain/main/java modb - src/modb/main/java diff --git a/jigsaw-examples/example_reflection/m4/pom.xml b/jigsaw-examples/example_reflection/m4/pom.xml index 9cb19bd4..ff15d978 100644 --- a/jigsaw-examples/example_reflection/m4/pom.xml +++ b/jigsaw-examples/example_reflection/m4/pom.xml @@ -18,11 +18,9 @@ modb - src/modb/main/java modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_requires-static/m4/pom.xml b/jigsaw-examples/example_requires-static/m4/pom.xml index f8ec7fb0..ecfb5173 100644 --- a/jigsaw-examples/example_requires-static/m4/pom.xml +++ b/jigsaw-examples/example_requires-static/m4/pom.xml @@ -19,15 +19,12 @@ modmain - src/modmain/main/java modb - src/modb/main/java modc - src/modc/main/java diff --git a/jigsaw-examples/example_requires_exports-to/m4/pom.xml b/jigsaw-examples/example_requires_exports-to/m4/pom.xml index eb99eb99..349aa072 100644 --- a/jigsaw-examples/example_requires_exports-to/m4/pom.xml +++ b/jigsaw-examples/example_requires_exports-to/m4/pom.xml @@ -18,19 +18,15 @@ modb1 - src/modb1/main/java modb2 - src/modb2/main/java modc - src/modc/main/java modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_requires_exports/m4/pom.xml b/jigsaw-examples/example_requires_exports/m4/pom.xml index 81b3c19b..d1392389 100644 --- a/jigsaw-examples/example_requires_exports/m4/pom.xml +++ b/jigsaw-examples/example_requires_exports/m4/pom.xml @@ -18,15 +18,12 @@ modmain - src/modmain/main/java modb - src/modb/main/java modc - src/modc/main/java diff --git a/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/pom.xml b/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/pom.xml index 76d27b61..a5e09781 100644 --- a/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/pom.xml +++ b/jigsaw-examples/example_requires_exports_requires-transitive_exports-to/m4/pom.xml @@ -18,27 +18,21 @@ moda - src/moda/main/java modb - src/modb/main/java modc - src/modc/main/java modfacade - src/modfacade/main/java modmain - src/modmain/main/java modmainbehindfacade - src/modmainbehindfacade/main/java diff --git a/jigsaw-examples/example_resolved-modules/m4/pom.xml b/jigsaw-examples/example_resolved-modules/m4/pom.xml index 1e25fd4b..81bda7ce 100644 --- a/jigsaw-examples/example_resolved-modules/m4/pom.xml +++ b/jigsaw-examples/example_resolved-modules/m4/pom.xml @@ -18,15 +18,12 @@ moda - src/moda/main/java modb - src/modb/main/java modc - src/modc/main/java diff --git a/jigsaw-examples/example_resources/m4/pom.xml b/jigsaw-examples/example_resources/m4/pom.xml index 437f402b..23b4567a 100644 --- a/jigsaw-examples/example_resources/m4/pom.xml +++ b/jigsaw-examples/example_resources/m4/pom.xml @@ -18,15 +18,12 @@ modb - src/modb/main/java modc - src/modc/main/java modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_splitpackage/m4/pom.xml b/jigsaw-examples/example_splitpackage/m4/pom.xml index e05eb83f..f6a12faa 100644 --- a/jigsaw-examples/example_splitpackage/m4/pom.xml +++ b/jigsaw-examples/example_splitpackage/m4/pom.xml @@ -19,15 +19,12 @@ modmainbar - src/modmainbar/main/java modsplitbar1 - src/modsplitbar1/main/java modsplitbar2 - src/modsplitbar2/main/java diff --git a/jigsaw-examples/example_splitpackage_automatic-modules/m4/pom.xml b/jigsaw-examples/example_splitpackage_automatic-modules/m4/pom.xml index 4314d156..a98c7ad8 100644 --- a/jigsaw-examples/example_splitpackage_automatic-modules/m4/pom.xml +++ b/jigsaw-examples/example_splitpackage_automatic-modules/m4/pom.xml @@ -19,7 +19,6 @@ modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_test/m4/pom.xml b/jigsaw-examples/example_test/m4/pom.xml index 81bd55d7..f76bdb9e 100644 --- a/jigsaw-examples/example_test/m4/pom.xml +++ b/jigsaw-examples/example_test/m4/pom.xml @@ -36,12 +36,10 @@ modfib - src/modfib/main/java modfib - src/modfib/test/java test diff --git a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/pom.xml b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/pom.xml index a0385647..d82d78cd 100644 --- a/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/pom.xml +++ b/jigsaw-examples/example_unnamed-module-reflection-illegal-access/m4/pom.xml @@ -19,11 +19,9 @@ modb - src/modb/main/java modc - src/modc/main/java diff --git a/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/pom.xml b/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/pom.xml index d386e642..f3cfea58 100644 --- a/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/pom.xml +++ b/jigsaw-examples/example_unnamed-module_access-from-explicit-module-reflection/m4/pom.xml @@ -19,11 +19,9 @@ modb - src/modb/main/java modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/pom.xml b/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/pom.xml index f4552dc9..0b77fc67 100644 --- a/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/pom.xml +++ b/jigsaw-examples/example_unnamed-module_access-from-explicit-module/m4/pom.xml @@ -18,11 +18,9 @@ modb - src/modb/main/java modmain - src/modmain/main/java diff --git a/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/pom.xml b/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/pom.xml index 3f1d5dc1..a2424b7b 100644 --- a/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/pom.xml +++ b/jigsaw-examples/example_unnamed-module_accessing-module-path/m4/pom.xml @@ -19,7 +19,6 @@ modb - src/modb/main/java diff --git a/jigsaw-examples/example_uses-provides/m4/pom.xml b/jigsaw-examples/example_uses-provides/m4/pom.xml index bfa89beb..9a9151d4 100644 --- a/jigsaw-examples/example_uses-provides/m4/pom.xml +++ b/jigsaw-examples/example_uses-provides/m4/pom.xml @@ -18,19 +18,15 @@ modmain - src/modmain/main/java modservice.impl.com - src/modservice.impl.com/main/java modservice.impl.net - src/modservice.impl.net/main/java modservicedefinition - src/modservicedefinition/main/java diff --git a/jigsaw-examples/example_uses-provides_uses-in-client/m4/pom.xml b/jigsaw-examples/example_uses-provides_uses-in-client/m4/pom.xml index b47191f8..bad3ec84 100644 --- a/jigsaw-examples/example_uses-provides_uses-in-client/m4/pom.xml +++ b/jigsaw-examples/example_uses-provides_uses-in-client/m4/pom.xml @@ -18,19 +18,15 @@ modmain - src/modmain/main/java modservice.impl.com - src/modservice.impl.com/main/java modservice.impl.net - src/modservice.impl.net/main/java modservicedefinition - src/modservicedefinition/main/java diff --git a/jigsaw-examples/example_version/m4/pom.xml b/jigsaw-examples/example_version/m4/pom.xml index 3ddecbc9..c50331dd 100644 --- a/jigsaw-examples/example_version/m4/pom.xml +++ b/jigsaw-examples/example_version/m4/pom.xml @@ -18,7 +18,6 @@ modmain - src/modmain/main/java From 252f7d6b2392341a377fd5db9254efbe3174ca87 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Mon, 15 Dec 2025 06:14:28 +0100 Subject: [PATCH 14/15] Ignore log files and (intermediate) IntelliJ confs Introduced in the course of support-and-care/maven-support-and-care#137 --- .gitignore | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 78a593c0..348acef0 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,8 @@ # IDE configuration .idea/ +*.iml +.vscode/ # Downloaded files .m2/ @@ -21,4 +23,7 @@ *.html # Maven artifacts -target/ \ No newline at end of file +target/ + +# Log files +*.log \ No newline at end of file From c3a0f6d9e775f25a54e1201fc1f27f2feff61923 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Tue, 16 Dec 2025 07:59:14 +0100 Subject: [PATCH 15/15] Update to Maven 4.0.0-rc-5 and add version recommendation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Maven 4.0.0-rc-5 includes the fix for the DefaultSourceRoot bug (apache/maven#10912, backported in #10917) that allows omitting elements from declarations when using the default directory convention src///. Changes: - Update CI workflow to use Maven 4.0.0-rc-5 - Add AsciiDoc include tags for Maven version (single source of truth) - Add [[recommended-maven4]] admonition in README.adoc - Add cross-reference to Maven 4 version recommendation πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Introduced in the course of support-and-care/maven-support-and-care#137 --- .github/workflows/build.yml | 4 +++- README.adoc | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c1d7f20d..2f306ad8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -207,7 +207,9 @@ jobs: - name: Set up Maven 4 uses: stCarolas/setup-maven@v5 with: - maven-version: '4.0.0-rc-4' + # tag::maven-4-version[] + maven-version: '4.0.0-rc-5' + # end::maven-4-version[] - name: Create .envrc with Java and Maven paths shell: bash diff --git a/README.adoc b/README.adoc index f7e47d31..c13dbbc5 100755 --- a/README.adoc +++ b/README.adoc @@ -49,7 +49,7 @@ Meanwhile, we extended many examples to work (currently) with Maven 4 to demonst ** See <> for the recommended version for full CI (automated testing) compatibility. ** For Maven 4 and xref:jigsaw-examples/example_gradle-project/README.adoc[Gradle example]: Java 17 or later is required. ** For the xref:jigsaw-examples/example_compile-target-jdk8/README.adoc[cross-compilation example]: Java 8. -. Install Maven 4 if you want to run the Maven 4 migrated examples (cf. <>). +. Install Maven 4 if you want to run the Maven 4 migrated examples (cf. <> and <>). [[recommended-jdk]] [NOTE] @@ -225,6 +225,21 @@ Corresponding JAR files are in `example_.../patchlib`. Many examples have been migrated to Maven 4 using the new https://maven.apache.org/plugins-archives/maven-compiler-plugin-LATEST-4.x/modules.html[Module Source Hierarchy] layout. The Maven 4 builds are located in `m4/` subdirectories within each example. +[[recommended-maven4]] +[NOTE] +.Recommended Maven 4 Version +==== +The following Maven 4 version is used for CI and automated testing: + +[source,yaml,indent=0] +---- +include::.github/workflows/build.yml[tag=maven-4-version] +---- + +Set `M4_HOME` to point to this version. +For SDKMAN users: `sdk install maven 4...` (use the version shown above). +==== + === Standard Migration Approach and Defaults For most examples, the Maven 4 migration follows a straightforward pattern.