Compare commits

...

141 commits
2.0.1 ... main

Author SHA1 Message Date
Geert Bevin 45c86e7efa Updated readme badge
Some checks failed
bld-ci / build-linux (17) (push) Has been cancelled
bld-ci / build-linux (20) (push) Has been cancelled
bld-ci / build-linux (21) (push) Has been cancelled
bld-ci / build-linux (22) (push) Has been cancelled
bld-ci / build-linux (23) (push) Has been cancelled
bld-ci / build-linux (24) (push) Has been cancelled
bld-ci / build-linux (25) (push) Has been cancelled
bld-ci / build-macos (17) (push) Has been cancelled
bld-ci / build-macos (20) (push) Has been cancelled
bld-ci / build-macos (21) (push) Has been cancelled
bld-ci / build-macos (22) (push) Has been cancelled
bld-ci / build-macos (23) (push) Has been cancelled
bld-ci / build-macos (24) (push) Has been cancelled
bld-ci / build-macos (25) (push) Has been cancelled
bld-ci / build-windows (17) (push) Has been cancelled
bld-ci / build-windows (20) (push) Has been cancelled
bld-ci / build-windows (21) (push) Has been cancelled
bld-ci / build-windows (22) (push) Has been cancelled
bld-ci / build-windows (23) (push) Has been cancelled
bld-ci / build-windows (24) (push) Has been cancelled
bld-ci / build-windows (25) (push) Has been cancelled
javadocs-pages / deploy (push) Has been cancelled
2026-04-28 19:56:30 -04:00
Geert Bevin 400dca63d7 Test fixes for new sonatype retention rules 2026-04-28 19:50:18 -04:00
Geert Bevin 7b542ac5d0
Merge pull request #76 from ethauvin/main
Some checks failed
bld-ci / build-linux (17) (push) Has been cancelled
bld-ci / build-linux (20) (push) Has been cancelled
bld-ci / build-linux (21) (push) Has been cancelled
bld-ci / build-linux (22) (push) Has been cancelled
bld-ci / build-linux (23) (push) Has been cancelled
bld-ci / build-linux (24) (push) Has been cancelled
bld-ci / build-linux (25) (push) Has been cancelled
bld-ci / build-macos (17) (push) Has been cancelled
bld-ci / build-macos (20) (push) Has been cancelled
bld-ci / build-macos (21) (push) Has been cancelled
bld-ci / build-macos (22) (push) Has been cancelled
bld-ci / build-macos (23) (push) Has been cancelled
bld-ci / build-macos (24) (push) Has been cancelled
bld-ci / build-macos (25) (push) Has been cancelled
bld-ci / build-windows (17) (push) Has been cancelled
bld-ci / build-windows (20) (push) Has been cancelled
bld-ci / build-windows (21) (push) Has been cancelled
bld-ci / build-windows (22) (push) Has been cancelled
bld-ci / build-windows (23) (push) Has been cancelled
bld-ci / build-windows (24) (push) Has been cancelled
bld-ci / build-windows (25) (push) Has been cancelled
javadocs-pages / deploy (push) Has been cancelled
Add support for multiple input types in path-related javac options
2026-03-05 19:02:46 -05:00
Erik C. Thauvin aa10006ce2
Remove redundant null/empty checks 2026-01-25 18:28:39 -08:00
Erik C. Thauvin 4de8d3c629
Handle null values in path and comma-separated options via stream filters 2026-01-25 11:37:35 -08:00
Erik C. Thauvin 44144ce095
Add missing null/empty checks 2026-01-25 11:20:24 -08:00
Erik C. Thauvin 3160161299
Update copyright 2026-01-22 00:19:36 -08:00
Erik C. Thauvin b22257ed43
Refactor javac options to improve consistency and handle null/empty parameters 2026-01-22 00:16:50 -08:00
Erik C. Thauvin 25c77ed5df
Improve method consistency 2026-01-21 15:01:17 -08:00
Erik C. Thauvin 21ed5912f0
Add support for multiple input types (Collection, Varargs, File, Path) in JavacOptions path-related methods. 2026-01-21 11:37:20 -08:00
Erik C. Thauvin 737927da26
Refactor XLint options for better handling of null/empty lists.
Some checks failed
bld-ci / build-linux (17) (push) Has been cancelled
bld-ci / build-linux (20) (push) Has been cancelled
bld-ci / build-linux (21) (push) Has been cancelled
bld-ci / build-linux (22) (push) Has been cancelled
bld-ci / build-linux (23) (push) Has been cancelled
bld-ci / build-linux (24) (push) Has been cancelled
bld-ci / build-linux (25) (push) Has been cancelled
bld-ci / build-macos (17) (push) Has been cancelled
bld-ci / build-macos (20) (push) Has been cancelled
bld-ci / build-macos (21) (push) Has been cancelled
bld-ci / build-macos (22) (push) Has been cancelled
bld-ci / build-macos (23) (push) Has been cancelled
bld-ci / build-macos (24) (push) Has been cancelled
bld-ci / build-macos (25) (push) Has been cancelled
bld-ci / build-windows (17) (push) Has been cancelled
bld-ci / build-windows (20) (push) Has been cancelled
bld-ci / build-windows (21) (push) Has been cancelled
bld-ci / build-windows (22) (push) Has been cancelled
bld-ci / build-windows (23) (push) Has been cancelled
bld-ci / build-windows (24) (push) Has been cancelled
bld-ci / build-windows (25) (push) Has been cancelled
javadocs-pages / deploy (push) Has been cancelled
2026-01-11 11:33:00 -08:00
Erik C. Thauvin 6fd3948f04
Add JUnit reporter integration and update workflow steps 2026-01-11 11:17:15 -08:00
Erik C. Thauvin c537b584f2
Add unit tests for JavacOptions class 2026-01-11 11:17:15 -08:00
Erik C. Thauvin 7a419ed197
Add support for -Xlint options in JavacOptions 2026-01-11 11:17:15 -08:00
Erik C. Thauvin 9c5928f9b1
Cleanup Javadocs 2026-01-11 11:17:15 -08:00
Erik C. Thauvin 26ff495b79
Fix containsRelease method to check for --release instead of -release in JavacOptions 2026-01-11 11:17:15 -08:00
Erik C. Thauvin 585325dd46
Add support for --add-reads, --default-module-for-created-files and --patch-module in JavacOptions 2026-01-11 11:17:15 -08:00
Erik C. Thauvin 793fde47dc
Add support for --add-exports in JavacOptions 2026-01-11 11:17:15 -08:00
Erik C. Thauvin fea026a9c6
Add support for --source and --target in JavacOptions 2026-01-11 11:17:14 -08:00
Erik C. Thauvin c71a98c6ee
Allow for modulePath and classPath specification using a File array or collection 2026-01-11 11:17:14 -08:00
Erik C. Thauvin 8ad5414d67
Revise README to focus on contributing guidelines
Some checks failed
bld-ci / build-linux (17) (push) Has been cancelled
bld-ci / build-linux (20) (push) Has been cancelled
bld-ci / build-linux (21) (push) Has been cancelled
bld-ci / build-linux (22) (push) Has been cancelled
bld-ci / build-linux (23) (push) Has been cancelled
bld-ci / build-linux (24) (push) Has been cancelled
bld-ci / build-linux (25) (push) Has been cancelled
bld-ci / build-macos (17) (push) Has been cancelled
bld-ci / build-macos (20) (push) Has been cancelled
bld-ci / build-macos (21) (push) Has been cancelled
bld-ci / build-macos (22) (push) Has been cancelled
bld-ci / build-macos (23) (push) Has been cancelled
bld-ci / build-macos (24) (push) Has been cancelled
bld-ci / build-macos (25) (push) Has been cancelled
bld-ci / build-windows (17) (push) Has been cancelled
bld-ci / build-windows (20) (push) Has been cancelled
bld-ci / build-windows (21) (push) Has been cancelled
bld-ci / build-windows (22) (push) Has been cancelled
bld-ci / build-windows (23) (push) Has been cancelled
bld-ci / build-windows (24) (push) Has been cancelled
bld-ci / build-windows (25) (push) Has been cancelled
javadocs-pages / deploy (push) Has been cancelled
Updated the README to replace the 'Building bld' section with a link to the 'CONTRIBUTING.md' file.
2025-12-30 12:45:43 -08:00
Erik C. Thauvin 684c697896
Create CONTRIBUTING.md with contribution instructions
Added contributing guidelines for the project.
2025-12-30 12:39:52 -08:00
Geert Bevin affa9e1dac Updated RIFE2/core
Some checks failed
bld-ci / build-linux (17) (push) Has been cancelled
bld-ci / build-linux (20) (push) Has been cancelled
bld-ci / build-linux (21) (push) Has been cancelled
bld-ci / build-linux (22) (push) Has been cancelled
bld-ci / build-linux (23) (push) Has been cancelled
bld-ci / build-linux (24) (push) Has been cancelled
bld-ci / build-linux (25) (push) Has been cancelled
bld-ci / build-macos (17) (push) Has been cancelled
bld-ci / build-macos (20) (push) Has been cancelled
bld-ci / build-macos (21) (push) Has been cancelled
bld-ci / build-macos (22) (push) Has been cancelled
bld-ci / build-macos (23) (push) Has been cancelled
bld-ci / build-macos (24) (push) Has been cancelled
bld-ci / build-macos (25) (push) Has been cancelled
bld-ci / build-windows (17) (push) Has been cancelled
bld-ci / build-windows (20) (push) Has been cancelled
bld-ci / build-windows (21) (push) Has been cancelled
bld-ci / build-windows (22) (push) Has been cancelled
bld-ci / build-windows (23) (push) Has been cancelled
bld-ci / build-windows (24) (push) Has been cancelled
bld-ci / build-windows (25) (push) Has been cancelled
javadocs-pages / deploy (push) Has been cancelled
2025-11-17 21:52:04 -05:00
Geert Bevin 1c70337afb Added Java 23 and 24 to CI tests 2025-11-17 21:45:32 -05:00
Geert Bevin 25bf0d3595 Added Java 25 to CI tests 2025-11-17 21:28:50 -05:00
Geert Bevin 0ec366e90b Updated RIFE2/core to version 1.9.3 2025-11-17 21:26:52 -05:00
Geert Bevin 8559696a6a Revert "Fixed missing main-class when running a modular application."
Some checks failed
bld-ci / build-linux (17) (push) Has been cancelled
bld-ci / build-linux (20) (push) Has been cancelled
bld-ci / build-linux (21) (push) Has been cancelled
bld-ci / build-linux (22) (push) Has been cancelled
bld-ci / build-macos (17) (push) Has been cancelled
bld-ci / build-macos (20) (push) Has been cancelled
bld-ci / build-macos (21) (push) Has been cancelled
bld-ci / build-macos (22) (push) Has been cancelled
bld-ci / build-windows (17) (push) Has been cancelled
bld-ci / build-windows (20) (push) Has been cancelled
bld-ci / build-windows (21) (push) Has been cancelled
bld-ci / build-windows (22) (push) Has been cancelled
javadocs-pages / deploy (push) Has been cancelled
This reverts commit 82705b952b.
2025-11-16 20:07:04 -05:00
Geert Bevin 6f54789dd9
Merge pull request #65 from Xasmedy/main
Some checks are pending
bld-ci / build-linux (17) (push) Waiting to run
bld-ci / build-linux (20) (push) Waiting to run
bld-ci / build-linux (21) (push) Waiting to run
bld-ci / build-linux (22) (push) Waiting to run
bld-ci / build-macos (17) (push) Waiting to run
bld-ci / build-macos (20) (push) Waiting to run
bld-ci / build-macos (21) (push) Waiting to run
bld-ci / build-macos (22) (push) Waiting to run
bld-ci / build-windows (17) (push) Waiting to run
bld-ci / build-windows (20) (push) Waiting to run
bld-ci / build-windows (21) (push) Waiting to run
bld-ci / build-windows (22) (push) Waiting to run
javadocs-pages / deploy (push) Waiting to run
Fixed missing main-class when running a modular application.
2025-11-16 11:17:30 -05:00
Geert Bevin 82fe6a3aa4
Merge pull request #71 from ethauvin/main
Log missing files when compiling or running
2025-11-16 11:16:54 -05:00
Geert Bevin 52e8a6ce6a Test fixes 2025-11-16 11:16:05 -05:00
Erik C. Thauvin f33108a3f0
Log missing main class or module when running. Closes #69 2025-11-14 20:52:59 -08:00
Erik C. Thauvin f4db05581b
Log missing source files when compiling. Closes #66 2025-11-14 20:49:00 -08:00
Erik C. Thauvin ba1dad4eb3
2.3.1-SNAPSHOT 2025-11-14 20:48:53 -08:00
xasmedy 82705b952b Fixed missing main-class when running a modular application.
The `RunOperation` is using the java `-m` flag to run the modular application, but it did not provide the required main-class as of documentation `-m <module>[/<mainclass>] [args...]`.
2025-11-13 00:13:20 +01:00
Geert Bevin 5efbc8c064 Updated readme
Some checks failed
bld-ci / build-linux (17) (push) Has been cancelled
bld-ci / build-linux (20) (push) Has been cancelled
bld-ci / build-linux (21) (push) Has been cancelled
bld-ci / build-linux (22) (push) Has been cancelled
bld-ci / build-macos (17) (push) Has been cancelled
bld-ci / build-macos (20) (push) Has been cancelled
bld-ci / build-macos (21) (push) Has been cancelled
bld-ci / build-macos (22) (push) Has been cancelled
bld-ci / build-windows (17) (push) Has been cancelled
bld-ci / build-windows (20) (push) Has been cancelled
bld-ci / build-windows (21) (push) Has been cancelled
bld-ci / build-windows (22) (push) Has been cancelled
javadocs-pages / deploy (push) Has been cancelled
2025-07-06 21:42:38 -04:00
Geert Bevin 22752668b7 Updated version to 2.3.0.
Some checks are pending
bld-ci / build-linux (17) (push) Waiting to run
bld-ci / build-linux (20) (push) Waiting to run
bld-ci / build-linux (21) (push) Waiting to run
bld-ci / build-linux (22) (push) Waiting to run
bld-ci / build-macos (17) (push) Waiting to run
bld-ci / build-macos (20) (push) Waiting to run
bld-ci / build-macos (21) (push) Waiting to run
bld-ci / build-macos (22) (push) Waiting to run
bld-ci / build-windows (17) (push) Waiting to run
bld-ci / build-windows (20) (push) Waiting to run
bld-ci / build-windows (21) (push) Waiting to run
bld-ci / build-windows (22) (push) Waiting to run
javadocs-pages / deploy (push) Waiting to run
Upgraded to bld 2.3.0.
Updated RIFE2/core.
2025-07-05 23:18:31 -04:00
Geert Bevin 9bea6d47c7 Updated version to 2.3.0-SNAPSHOT 2025-07-05 22:20:00 -04:00
Geert Bevin b0596911ed Updated readme with snapshot shield
Some checks failed
bld-ci / build-linux (17) (push) Has been cancelled
bld-ci / build-linux (20) (push) Has been cancelled
bld-ci / build-linux (21) (push) Has been cancelled
bld-ci / build-linux (22) (push) Has been cancelled
bld-ci / build-macos (17) (push) Has been cancelled
bld-ci / build-macos (20) (push) Has been cancelled
bld-ci / build-macos (21) (push) Has been cancelled
bld-ci / build-macos (22) (push) Has been cancelled
bld-ci / build-windows (17) (push) Has been cancelled
bld-ci / build-windows (20) (push) Has been cancelled
bld-ci / build-windows (21) (push) Has been cancelled
bld-ci / build-windows (22) (push) Has been cancelled
javadocs-pages / deploy (push) Has been cancelled
2025-07-04 19:20:34 -04:00
Geert Bevin e9906c0df7 Display error message when staging repository fails to be closed. 2025-07-04 18:13:08 -04:00
Geert Bevin d3d7614e7c Added support for automatically closing staging repositories with the new central staging API. 2025-07-04 14:31:30 -04:00
Geert Bevin 91a621dfea Added new sonatype central publishing repositories that replace the OOSRH repositories, called CENTRAL_RELEASED and CENTRAL_SNAPSHOTS.
Some checks are pending
bld-ci / build-linux (17) (push) Waiting to run
bld-ci / build-linux (20) (push) Waiting to run
bld-ci / build-linux (21) (push) Waiting to run
bld-ci / build-linux (22) (push) Waiting to run
bld-ci / build-macos (17) (push) Waiting to run
bld-ci / build-macos (20) (push) Waiting to run
bld-ci / build-macos (21) (push) Waiting to run
bld-ci / build-macos (22) (push) Waiting to run
bld-ci / build-windows (17) (push) Waiting to run
bld-ci / build-windows (20) (push) Waiting to run
bld-ci / build-windows (21) (push) Waiting to run
bld-ci / build-windows (22) (push) Waiting to run
javadocs-pages / deploy (push) Waiting to run
Updated bld to use the new snapshot repository instead.
Worked around new sonatype publishing repositories not allowing signed Maven metadata files.
2025-07-03 13:08:26 -04:00
Geert Bevin 5af8ca7b2e WIP additional debugging information when publishing upload fails
Some checks are pending
bld-ci / build-linux (17) (push) Waiting to run
bld-ci / build-linux (20) (push) Waiting to run
bld-ci / build-linux (21) (push) Waiting to run
bld-ci / build-linux (22) (push) Waiting to run
bld-ci / build-macos (17) (push) Waiting to run
bld-ci / build-macos (20) (push) Waiting to run
bld-ci / build-macos (21) (push) Waiting to run
bld-ci / build-macos (22) (push) Waiting to run
bld-ci / build-windows (17) (push) Waiting to run
bld-ci / build-windows (20) (push) Waiting to run
bld-ci / build-windows (21) (push) Waiting to run
bld-ci / build-windows (22) (push) Waiting to run
javadocs-pages / deploy (push) Waiting to run
2025-07-02 22:41:24 -04:00
Geert Bevin d6d3c0fc1d Updated version to 2.2.2-SNAPSHOT
Some checks failed
bld-ci / build-linux (17) (push) Has been cancelled
bld-ci / build-linux (20) (push) Has been cancelled
bld-ci / build-linux (21) (push) Has been cancelled
bld-ci / build-linux (22) (push) Has been cancelled
bld-ci / build-macos (17) (push) Has been cancelled
bld-ci / build-macos (20) (push) Has been cancelled
bld-ci / build-macos (21) (push) Has been cancelled
bld-ci / build-macos (22) (push) Has been cancelled
bld-ci / build-windows (17) (push) Has been cancelled
bld-ci / build-windows (20) (push) Has been cancelled
bld-ci / build-windows (21) (push) Has been cancelled
bld-ci / build-windows (22) (push) Has been cancelled
javadocs-pages / deploy (push) Has been cancelled
2025-02-24 21:02:58 -05:00
Geert Bevin 9158e7296f Upgraded GitHub actions 2025-02-24 20:39:56 -05:00
Geert Bevin b1b5c89c78 Updated version to 2.2.1 2025-02-24 20:29:27 -05:00
Geert Bevin 4b6cac6ace Improvement to environment API for process operation. 2025-01-22 19:14:13 -05:00
Geert Bevin 9362a60c52 More tests 2025-01-22 18:51:05 -05:00
Geert Bevin ca7fa0c4b8 Fixed #58 : Add an option to set environment variables before spawining a process 2025-01-22 18:30:07 -05:00
Geert Bevin f9f20e62ef Fixed #57 : Add an option to check if project required settins have been set 2025-01-21 21:19:45 -05:00
Geert Bevin 4b762796e0 Updated version to 2.2.1-SNAPSHOT 2025-01-21 21:08:31 -05:00
Geert Bevin 03a15433ff Updated version to 2.2.0.
Updated versions for RIFE2 project creation.
Updated RIFE2/core.
2025-01-11 12:08:10 -05:00
Geert Bevin 625055bbb6 RIFE2 project creation fix 2025-01-11 10:07:19 -05:00
Geert Bevin 72d214b3b6 Dependency update 2025-01-11 10:06:52 -05:00
Geert Bevin f753f87a79 Updated RIFE2/core 2025-01-10 18:53:25 -05:00
Geert Bevin fec4f68027 Added support for Maven project.parent properties 2025-01-10 18:45:02 -05:00
Geert Bevin 92c8cd3033 Updated RIFE2/core 2024-12-27 12:54:13 -05:00
Geert Bevin da0b92fb8e Updated RIFE2/core 2024-12-27 12:29:01 -05:00
Geert Bevin 2dd53ace3d More improvements to create operation 2024-12-27 10:33:38 -05:00
Geert Bevin 3d86aa8c8d Unify command line use of create operations 2024-12-26 20:06:59 -05:00
Geert Bevin 32052deaa3 Interrupt creation operation when a blank package or project name is provided 2024-12-26 18:47:14 -05:00
Geert Bevin b27cc78fb7 Don't add Lib suffix for lib project creation 2024-12-26 18:42:01 -05:00
Geert Bevin a7efd01697 Updated RIFE2/core 2024-12-26 17:13:43 -05:00
Geert Bevin 92fc85bd9c Updated blueprint dependencies 2024-12-26 17:09:33 -05:00
Geert Bevin 34667b5402 Improvements to create operations 2024-12-26 16:51:46 -05:00
Geert Bevin 66f7d180b9 Implements #52 : command line enhancements for project creation 2024-11-16 18:23:10 -05:00
Geert Bevin 6c2a9acf1c
Merge pull request #56 from ethauvin/main
Added javac options to specify the directory used to place generated source files.
2024-10-14 16:01:04 -04:00
Geert Bevin c6c9d32c35 Added support for automatically consolidating compile options that are named differently but serve the same purpose 2024-10-14 09:07:24 -04:00
Geert Bevin 3e9b252c51 Updated RIFE2/core 2024-10-10 10:11:04 -04:00
Erik C. Thauvin 3f60ed78ef
Removed extra empty line 2024-10-04 10:34:55 -07:00
Erik C. Thauvin 762e099988
Added javac options to specify the directory used to place generated source files. 2024-10-02 00:16:05 -07:00
Erik C. Thauvin 9941fc0d10
Merge pull request #55 from ethauvin/main
Added support for explicitly requesting annotation processing
2024-10-01 16:05:25 -07:00
Erik C. Thauvin f51add49f0
Added support for explicitly requesting annotation processing, as needed by Java 23 (and backported to 17 and 11) 2024-10-01 15:51:37 -07:00
Geert Bevin 3dce798d52 Updated version to 2.1.1-SNAPSHOT 2024-09-07 10:22:13 -04:00
Erik C. Thauvin d5e65ec9e8
Updated bld badge version to 2.1.0 2024-08-29 23:08:39 -07:00
Geert Bevin 4083f95bc8 Upgraded to bld-2.1.0.
Updated version to 2.1.0.
2024-08-29 19:19:13 -04:00
Geert Bevin 622ca99c7b Updated RIFE2/core submodule 2024-08-29 08:02:36 -04:00
Geert Bevin a8f43864bf Upgraded wrapper to latest version 2024-08-29 08:01:28 -04:00
Geert Bevin df173c4cfc Added ability to individually exclude sources and javadocs downloads for dependencies 2024-08-29 07:59:33 -04:00
Geert Bevin a07db3f94e
Merge pull request #50 from ethauvin/main
More cleanups to jlink, jmod & jpackage operations, options and tests
2024-08-29 07:33:28 -04:00
Erik C. Thauvin 5da9e4b3a5
More cleanups to jlink, jmod & jpackage operations, options and tests 2024-08-28 21:53:42 -07:00
Geert Bevin c7ca0e263d Updated to latest bld snapshot 2024-08-27 21:51:59 -04:00
Geert Bevin 22952cf189 Added missing IDEA lib dir upgrade 2024-08-27 21:49:35 -04:00
Geert Bevin 4fe40dadd7 Use recursive jar directory in IDEA project libraries so that modules can be picked up.
Updated wrapper so that old IDEA projects get updated for recursive scanning.
2024-08-27 21:45:28 -04:00
Geert Bevin 47d463e6aa Updated project dependencies and blueprint dependencies 2024-08-27 12:47:59 -04:00
Geert Bevin 5ab77194e0 Updated wrapper to latest 2.1.0-SNAPSHOT 2024-08-27 08:23:58 -04:00
Erik C. Thauvin df680a4846
Merge pull request #49 from ethauvin/main
Moved command files specification to the tool provider abstract operation
2024-08-26 14:41:27 -07:00
Erik C. Thauvin 406b83bd82
Moved command files specification to the tool provider abstract operation 2024-08-26 14:25:15 -07:00
Geert Bevin b4801b5b07 Upgraded to latest bld wrapper 2024-08-26 14:22:46 -04:00
Geert Bevin 28e548954f Javadoc improvements 2024-08-26 14:19:43 -04:00
Geert Bevin f15a8d2df2 Minor Javadoc tweaks. 2024-08-26 10:13:56 -04:00
Geert Bevin d68905b944
Merge pull request #48 from ethauvin/main
More cleanups to jlink, jmod & jpackage operations and options
2024-08-26 10:09:29 -04:00
Erik C. Thauvin c15a8d3bcf
Minor plural cleanups 2024-08-26 02:31:15 -07:00
Erik C. Thauvin 9deb570bf4
More cleanups to jlink, jmod & jpackage operations and options 2024-08-26 01:40:17 -07:00
Geert Bevin b8a63dd79c Cleanups to JlinkOptions, JmodOptions and JpackageOptions 2024-08-25 22:55:40 -04:00
Geert Bevin 22add235e3
Merge pull request #47 from ethauvin/main
Added JlinkOptions, JmodOptions and JpackageOptions File argument alt…
2024-08-25 22:27:23 -04:00
Erik C. Thauvin 0b9581cf12
Made paths specifications absolute 2024-08-25 18:46:15 -07:00
Geert Bevin 2b827a9a6f Added run operation test 2024-08-25 20:11:48 -04:00
Geert Bevin fd1429f2d3 Added support for automatically setting a module main class if module-info.java is part of the compilation operation and a main class was provided by the project. 2024-08-25 19:52:26 -04:00
Erik C. Thauvin 5821022fee
Fixed Jpackage main module specification 2024-08-25 16:09:30 -07:00
Geert Bevin a4300b37d1
Added JlinkOptions, JmodOptions and JpackageOptions File argument alternatives with Path and String.
Moved launches configurations from JPackage options to operation.
2024-08-25 15:47:51 -07:00
Geert Bevin 9f9e8a95db Added JavacOptions, JavadocOptions and JavaOptions File argument alternatives with Path and String.
Relaxed the requirement to specify mainClass in a project and added support for module.
2024-08-25 14:07:36 -04:00
Geert Bevin 126daecd21 Updated javadoc versioning for 2.1.0 2024-08-23 15:37:46 -04:00
Geert Bevin c70b4f1c43
Merge pull request #45 from ethauvin/main
implementations of JpackageOperation, JmodOperation and JlinkOperation
2024-08-23 15:36:30 -04:00
Geert Bevin 673ebbdeb0 Updated to latest bld wrapper 2024-08-23 10:58:37 -04:00
Geert Bevin a7c29080f5 Fix to the bld wrapper to take java.home into account for the java executable, otherwise there can be a mismatch between the javac version and the java version 2024-08-23 10:47:40 -04:00
Geert Bevin a616a8a8f6 Upgraded bld to 2.1.0-SNAPSHOT 2024-08-22 19:23:18 -04:00
Geert Bevin 0797e39dd6 Added native support for Java modules 2024-08-22 19:04:56 -04:00
Erik C. Thauvin 3bd17e224b
Improved command line tokenizer 2024-08-09 14:16:10 -07:00
Geert Bevin 7cd547f8b6 Implemented Java module for bld.
Updated version to 2.1.0-SNAPSHOT.
Updated RIFE2/core.
2024-08-05 21:10:59 -04:00
Erik C. Thauvin c59d61f8c1
Added command file and test for Windows 2024-08-05 14:52:18 -07:00
Erik C. Thauvin 0382444c0c
Added more command files tests 2024-08-05 10:40:42 -07:00
Erik C. Thauvin d72e6ebc2e
Truncate jmod ISO date to seconds 2024-08-05 10:25:41 -07:00
Erik C. Thauvin d42d2d6fa0
Added a command line tokenizer 2024-08-04 21:06:34 -07:00
Erik C. Thauvin a06ce8eaaa
Renamed fileOptions to cmdFiles 2024-08-04 20:16:55 -07:00
Geert Bevin 7f8120e3e3 Revert "Updated version to 2.1.0-SNAPSHOT."
This reverts commit 67c727e062.
2024-08-04 19:49:29 -04:00
Geert Bevin 67c727e062 Updated version to 2.1.0-SNAPSHOT.
Added Java module info.
Renamed IDEA module to be in-line with the Java module.
2024-08-04 19:29:08 -04:00
Erik C. Thauvin 62a324068f
Cleanups 2024-08-04 09:06:41 -07:00
Erik C. Thauvin e32e17403f
Added support for Java 20-21 specific options 2024-08-04 00:39:12 -07:00
Erik C. Thauvin 750758993d
Tests cleanup 2024-08-03 10:15:21 -07:00
Erik C. Thauvin 1d615a501c
More operation options cleanups 2024-08-03 09:51:09 -07:00
Erik C. Thauvin 91640e68ce
Fixed copyright 2024-08-03 08:01:28 -07:00
Erik C. Thauvin d029bb9b87
Fixed version parsing in tests 2024-08-03 07:47:12 -07:00
Erik C. Thauvin 7a946b17d8
Capture and check stdout in tests 2024-08-03 07:37:11 -07:00
Erik C. Thauvin f6aa5258ef
Normalized tool arguments setup and processing 2024-08-03 07:36:35 -07:00
Erik C. Thauvin 94225dfb7a
Improved @filename support 2024-08-02 21:33:33 -07:00
Erik C. Thauvin 8118f42285
Use System.out and System.out instead of StringWriter 2024-08-02 21:30:08 -07:00
Erik C. Thauvin c38594a173
Foce added jlink build directory 2024-08-02 18:37:28 -07:00
Erik C. Thauvin 0204cdff19
Added functional tests for jlink and jmod 2024-08-02 18:27:03 -07:00
Erik C. Thauvin b94b23af56
Clear command line arguments on execution 2024-08-02 18:26:00 -07:00
Erik C. Thauvin e2cc7a6782
Improved @filename options parsing 2024-08-02 18:25:39 -07:00
Erik C. Thauvin 002844861b
Fixed handling of @filename in all tools 2024-08-02 14:23:30 -07:00
Erik C. Thauvin 0ad964ea4d
Cleaned up and improved tests 2024-08-02 02:54:46 -07:00
Erik C. Thauvin d69956cf91
Revert install limbd0 on Ubuntu 2024-08-01 14:19:59 -07:00
Erik C. Thauvin 0aa93b708a
Install limbd0 on Ubuntu with sudo 2024-08-01 14:02:24 -07:00
Erik C. Thauvin 7fcbccd565
Install limbd0 on Ubuntu 2024-08-01 13:42:55 -07:00
Erik C. Thauvin 683f5dfb3a
Fixed test imports 2024-08-01 12:14:09 -07:00
Erik C. Thauvin 547b20a242
Draft implementations of JpackageOperation, JmodOperation and JlinkOperation 2024-08-01 11:41:29 -07:00
Geert Bevin aeecd957c6 Cleanups 2024-07-30 09:48:29 -04:00
Geert Bevin a3a753f70a Cleanup 2024-07-30 08:51:17 -04:00
Geert Bevin cec3d4ebbf
Update README.md 2024-07-29 21:15:12 -04:00
Geert Bevin bd93c6659b Updated readme 2024-07-28 21:04:26 -04:00
129 changed files with 13916 additions and 2104 deletions

View file

@ -2,6 +2,9 @@ name: bld-ci
on: [push, pull_request, workflow_dispatch] on: [push, pull_request, workflow_dispatch]
env:
REPORTS_DIR: "build/test-results/test/"
jobs: jobs:
build-linux: build-linux:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -87,7 +90,7 @@ jobs:
strategy: strategy:
matrix: matrix:
java-version: [ 17, 20, 21, 22 ] java-version: [ 17, 20, 21, 22, 23, 24, 25 ]
steps: steps:
- name: Checkout source repository - name: Checkout source repository
@ -98,25 +101,37 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Set up JDK ${{ matrix.java-version }} - name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3 uses: actions/setup-java@v4
with: with:
distribution: 'corretto' distribution: 'corretto'
java-version: ${{ matrix.java-version }} java-version: ${{ matrix.java-version }}
check-latest: true check-latest: true
- name: Download dependencies
run: ./bld clean download
- name: Compile source
run: ./bld compile
- name: Run tests - name: Run tests
id: tests
run: >- run: >-
./bld clean download compile test ./bld test
-Dtest.postgres=true -Dtest.mysql=true -Dtest.mariadb=true -Dtest.oracle=true -Dtest.oracle-free=true -Dtest.postgres=true -Dtest.mysql=true -Dtest.mariadb=true -Dtest.oracle=true -Dtest.oracle-free=true
-DtestsBadgeUrl=https://rife2.com/tests-badge/update/com.uwyn.rife2/bld -DtestsBadgeUrl=https://rife2.com/tests-badge/update/com.uwyn.rife2/bld
-DtestsBadgeApiKey=${{ secrets.TESTS_BADGE_API_KEY }} -DtestsBadgeApiKey=${{ secrets.TESTS_BADGE_API_KEY }}
--reports-dir=${{ env.REPORTS_DIR }}
- name: Run reporter
if: always() && steps.tests.outcome == 'failure'
run: ./bld reporter --all
build-macos: build-macos:
runs-on: macos-latest runs-on: macos-latest
strategy: strategy:
matrix: matrix:
java-version: [ 17, 20, 21, 22 ] java-version: [ 17, 20, 21, 22, 23, 24, 25 ]
steps: steps:
- name: Checkout source repository - name: Checkout source repository
@ -127,22 +142,32 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Set up JDK ${{ matrix.java-version }} - name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3 uses: actions/setup-java@v4
with: with:
distribution: 'corretto' distribution: 'corretto'
java-version: ${{ matrix.java-version }} java-version: ${{ matrix.java-version }}
check-latest: true check-latest: true
- name: Download dependencies
run: ./bld clean download
- name: Compile source
run: ./bld compile
- name: Run tests - name: Run tests
run: >- id: tests
./bld clean download compile test run: ./bld test --reports-dir=${{ env.REPORTS_DIR }}
- name: Run reporter
if: always() && steps.tests.outcome == 'failure'
run: ./bld reporter --all
build-windows: build-windows:
runs-on: windows-latest runs-on: windows-latest
strategy: strategy:
matrix: matrix:
java-version: [ 17, 20, 21, 22 ] java-version: [ 17, 20, 21, 22, 23, 24, 25 ]
steps: steps:
- name: Configure git line endings - name: Configure git line endings
@ -156,12 +181,22 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Set up JDK ${{ matrix.java-version }} - name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3 uses: actions/setup-java@v4
with: with:
distribution: 'corretto' distribution: 'corretto'
java-version: ${{ matrix.java-version }} java-version: ${{ matrix.java-version }}
check-latest: true check-latest: true
- name: Download dependencies
run: .\bld.bat clean download
- name: Compile source
run: .\bld.bat compile
- name: Run tests - name: Run tests
run: >- id: tests
.\bld.bat clean download compile test run: .\bld.bat test --reports-dir=${{ env.REPORTS_DIR }}
- name: Run reporter
if: always() && steps.tests.outcome == 'failure'
run: .\bld.bat reporter --all

View file

@ -37,7 +37,7 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Set up JDK 17 - name: Set up JDK 17
uses: actions/setup-java@v3 uses: actions/setup-java@v4
with: with:
distribution: 'corretto' distribution: 'corretto'
java-version: 17 java-version: 17
@ -46,14 +46,14 @@ jobs:
run: ./bld clean download clean compile javadoc run: ./bld clean download clean compile javadoc
- name: Setup Pages - name: Setup Pages
uses: actions/configure-pages@v3 uses: actions/configure-pages@v5
- name: Upload artifact - name: Upload artifact
uses: actions/upload-pages-artifact@v2 uses: actions/upload-pages-artifact@v3
with: with:
# Upload generated Javadocs repository # Upload generated Javadocs repository
path: 'build/javadoc/' path: 'build/javadoc/'
- name: Deploy to GitHub Pages - name: Deploy to GitHub Pages
id: deployment id: deployment
uses: actions/deploy-pages@v2 uses: actions/deploy-pages@v4

View file

@ -27,6 +27,5 @@
<orderEntry type="library" name="compile" level="project" /> <orderEntry type="library" name="compile" level="project" />
<orderEntry type="library" scope="RUNTIME" name="runtime" level="project" /> <orderEntry type="library" scope="RUNTIME" name="runtime" level="project" />
<orderEntry type="library" scope="TEST" name="test" level="project" /> <orderEntry type="library" scope="TEST" name="test" level="project" />
<orderEntry type="module" module-name="bld" />
</component> </component>
</module> </module>

View file

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="OctalLiteral" enabled="false" level="WARNING" enabled_by_default="false" />
</profile>
</component>

View file

@ -2,12 +2,12 @@
<library name="bld"> <library name="bld">
<CLASSES> <CLASSES>
<root url="file://$PROJECT_DIR$/lib/bld" /> <root url="file://$PROJECT_DIR$/lib/bld" />
<root url="jar://$USER_HOME$/.bld/dist/bld-2.0.1.jar!/" /> <root url="jar://$USER_HOME$/.bld/dist/bld-2.3.0.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES> <SOURCES>
<root url="file://$PROJECT_DIR$/lib/bld" /> <root url="file://$PROJECT_DIR$/lib/bld" />
<root url="jar://$USER_HOME$/.bld/dist/bld-2.0.1-sources.jar!/" /> <root url="jar://$USER_HOME$/.bld/dist/bld-2.3.0-sources.jar!/" />
</SOURCES> </SOURCES>
<excluded> <excluded>
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" /> <root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />

View file

@ -9,9 +9,9 @@
<root url="file://$PROJECT_DIR$/lib/compile" /> <root url="file://$PROJECT_DIR$/lib/compile" />
<root url="file://$PROJECT_DIR$/lib/provided" /> <root url="file://$PROJECT_DIR$/lib/provided" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" type="SOURCES" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -3,12 +3,13 @@
<CLASSES> <CLASSES>
<root url="file://$PROJECT_DIR$/lib/runtime" /> <root url="file://$PROJECT_DIR$/lib/runtime" />
<root url="file://$PROJECT_DIR$/src/main/resources" /> <root url="file://$PROJECT_DIR$/src/main/resources" />
<root url="file://$PROJECT_DIR$/core/src/main/resources" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES> <SOURCES>
<root url="file://$PROJECT_DIR$/lib/runtime" /> <root url="file://$PROJECT_DIR$/lib/runtime" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -11,9 +11,9 @@
<root url="file://$PROJECT_DIR$/lib/test" /> <root url="file://$PROJECT_DIR$/lib/test" />
<root url="file://$PROJECT_DIR$/lib/provided" /> <root url="file://$PROJECT_DIR$/lib/provided" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" type="SOURCES" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -1,5 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0">
<entry_point TYPE="field" FQNAME="rife.bld.operations.JpackageOptions.PackageType APP_IMAGE" />
<entry_point TYPE="field" FQNAME="rife.bld.operations.JpackageOptions.PackageType DMG" />
<entry_point TYPE="field" FQNAME="rife.bld.operations.JpackageOptions.PackageType MSI" />
<entry_point TYPE="field" FQNAME="rife.bld.operations.JpackageOptions.PackageType PKG" />
<entry_point TYPE="field" FQNAME="rife.bld.operations.JpackageOptions.PackageType RPM" />
<entry_point TYPE="field" FQNAME="rife.bld.operations.JlinkOptions.CompressionLevel CONSTANT_STRING_SHARING" />
<entry_point TYPE="field" FQNAME="rife.bld.operations.JlinkOptions.CompressionLevel NO_COMPRESSION" />
<entry_point TYPE="field" FQNAME="rife.bld.operations.JlinkOptions.Endian LITTLE" />
<entry_point TYPE="field" FQNAME="rife.bld.operations.JmodOperation.OperationMode EXTRACT" />
<entry_point TYPE="field" FQNAME="rife.bld.operations.JmodOperation.OperationMode HASH" />
<entry_point TYPE="field" FQNAME="rife.bld.operations.JmodOptions.ResolvedReason DEPRECATED_FOR_REMOVAL" />
<entry_point TYPE="field" FQNAME="rife.bld.operations.JmodOptions.ResolvedReason INCUBATING" />
</entry_points>
<pattern value="rife.bld.operations.JpackageOptions.PackageType" />
<pattern value="rife.bld.operations.JlinkOptions.CompressionLevel" />
<pattern value="rife.bld.operations.JlinkOptions.Endian" />
<pattern value="rife.bld.operations.JmodOperation.OperationMode" />
<pattern value="rife.bld.operations.JmodOptions.ResolvedReason" />
</component>
<component name="PDMPlugin"> <component name="PDMPlugin">
<option name="skipTestSources" value="false" /> <option name="skipTestSources" value="false" />
</component> </component>

View file

@ -1,6 +1,7 @@
<component name="ProjectRunConfigurationManager"> <component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Tests" type="JUnit" factoryName="JUnit"> <configuration default="false" name="Run all tests" type="JUnit" factoryName="JUnit">
<module name="app" /> <module name="app" />
<useClassPathOnly />
<option name="PACKAGE_NAME" value="rife" /> <option name="PACKAGE_NAME" value="rife" />
<option name="MAIN_CLASS_NAME" value="" /> <option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" /> <option name="METHOD_NAME" value="" />

View file

@ -0,0 +1,20 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run bld tests" type="JUnit" factoryName="JUnit">
<module name="app" />
<useClassPathOnly />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="rife.bld.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="rife.bld" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<dir value="$PROJECT_DIR$/src/test/java" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

6
.idea/scala_compiler.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ScalaCompilerConfiguration">
<option name="separateProdTestSources" value="false" />
</component>
</project>

20
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,20 @@
# Contributing
If you want to contribute to `bld` or customize it, all you have to do is clone the GitHub
repository and update the [RIFE2/core](https://github.com/rife2/rife2-core) submodule:
```console
git clone git@github.com:rife2/bld.git
cd bld
git submodule init
git submodule update
```
Then use `bld` to build itself:
```console
./bld compile
```
The project has an IntelliJ IDEA project structure. You can just open it after all
the dependencies were downloaded and peruse the code.

View file

@ -1,9 +1,9 @@
[![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Java](https://img.shields.io/badge/java-17%2B-blue)](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) [![Java](https://img.shields.io/badge/java-17%2B-blue)](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
[![bld](https://img.shields.io/badge/2.0.0-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld) [![bld](https://img.shields.io/badge/2.3.0-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld)
[![Release](https://img.shields.io/github/release/rife2/bld.svg)](https://github.com/rife2/bld/releases/latest) [![Release](https://img.shields.io/github/release/rife2/bld.svg)](https://github.com/rife2/bld/releases/latest)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.uwyn.rife2/bld/badge.svg?color=blue)](https://maven-badges.herokuapp.com/maven-central/com.uwyn.rife2/bld) [![Maven Central](https://img.shields.io/maven-central/v/com.uwyn.rife2/bld)](https://central.sonatype.com/artifact/com.uwyn.rife2/bld)
[![Nexus Snapshot](https://img.shields.io/nexus/s/com.uwyn.rife2/bld?server=https%3A%2F%2Fs01.oss.sonatype.org%2F)](https://s01.oss.sonatype.org/content/repositories/snapshots/com/uwyn/rife2/bld/) [![GitHub Snapshot](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fcentral.sonatype.com%2Frepository%2Fmaven-snapshots%2Fcom%2Fuwyn%2Frife2%2Fbld%2Fmaven-metadata.xml)](https://github.com/rife2/bld/packages/2214741/versions)
[![gradle-ci](https://github.com/rife2/bld/actions/workflows/bld.yml/badge.svg)](https://github.com/rife2/bld/actions/workflows/bld.yml) [![gradle-ci](https://github.com/rife2/bld/actions/workflows/bld.yml/badge.svg)](https://github.com/rife2/bld/actions/workflows/bld.yml)
[![Tests](https://rife2.com/tests-badge/badge/com.uwyn.rife2/bld)](https://github.com/rife2/rife2/actions/workflows/bld.yml) [![Tests](https://rife2.com/tests-badge/badge/com.uwyn.rife2/bld)](https://github.com/rife2/rife2/actions/workflows/bld.yml)
@ -48,33 +48,29 @@ import java.util.List;
import static rife.bld.dependencies.Repository.*; import static rife.bld.dependencies.Repository.*;
import static rife.bld.dependencies.Scope.*; import static rife.bld.dependencies.Scope.*;
public class MyappBuild extends Project { public class MyAppBuild extends Project {
public MyappBuild() { public MyAppBuild() {
pkg = "com.example"; pkg = "com.example";
name = "Myapp"; name = "my-app";
mainClass = "com.example.MyappMain"; mainClass = "com.example.MyApp";
version = version(0,1,0); version = version(0,1,0);
downloadSources = true; downloadSources = true;
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES); repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
scope(test) scope(test)
.include(dependency("org.junit.jupiter", .include(dependency("org.junit.jupiter", "junit-jupiter", version(5,11,4)))
"junit-jupiter", .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,11,4)));
version(5,10,3)))
.include(dependency("org.junit.platform",
"junit-platform-console-standalone",
version(1,10,3)));
} }
public static void main(String[] args) { public static void main(String[] args) {
new MyappBuild().start(args); new MyAppBuild().start(args);
} }
} }
``` ```
> **NOTE:** `bld` supports different ways to describe dependencies, > **NOTE:** `bld` supports different ways to describe dependencies,
> `dependency("org.junit.jupiter", "junit-jupiter", version(5,10,3))` can for instance also > `dependency("org.junit.jupiter", "junit-jupiter", version(5,11,4))` can for instance also
> be written as `dependency("org.junit.jupiter:junit-jupiter:5.10.3")`. Which format you use, > be written as `dependency("org.junit.jupiter:junit-jupiter:5.11.4")`. Which format you use,
> is a matter of personal taste. > is a matter of personal taste.
# Where does `bld` fit? # Where does `bld` fit?
@ -95,6 +91,27 @@ significantly reduces the cognitive load, and taking actions immediately
without having to mentally construct a described plan, makes it easier to without having to mentally construct a described plan, makes it easier to
reason about your build. reason about your build.
# IDE support
<img src="https://rife2.com/images/bld-idea.png" style="width: 100%">
Since version 2.0, bld comes with its own [IntelliJ IDEA plugin](https://github.com/rife2/bld-idea):
* detect `bld` projects and find their main Java class
* quick access to open and edit the main Java class and wrapper properties of `bld` projects
* list all the commands in `bld` projects in a side panel
* execute one or multiple commands in the order they were selected
* reload the commands in the `bld` project
* terminate currently running `bld` commands
* `bld` console panel for command output with source code hyperlinking
* display the `bld` dependency tree
* toggle to run `bld` in offline or online mode
* auto-save all open files before executing a `bld` command
* convenient `bld` one-click cache invalidation
* set `bld` commands to run before or after IDEA compilation
* create custom `bld` command run configuration with options, JVM arguments, and before launch tasks
* assign keyboard shortcuts to `bld` commands
# Find out more # Find out more
`bld` lets your build logic get out of the way so that you can focus on writing `bld` lets your build logic get out of the way so that you can focus on writing
@ -114,23 +131,7 @@ to post on the [forums](https://forum.uwyn.com) or to join us on [Discord](http
Read more in the [full documentation](https://github.com/rife2/bld/wiki) and [bld Javadocs](https://rife2.github.io/bld/). Read more in the [full documentation](https://github.com/rife2/bld/wiki) and [bld Javadocs](https://rife2.github.io/bld/).
# Building `bld` # Contributing
If you want to contribute to `bld` or customize it, all you have to do is clone the GitHub See [CONTIBUTING.md](https://github.com/rife2/bld?tab=contributing-ov-file#readme) for information about
repository and update the [RIFE2/core](https://github.com/rife2/rife2-core) submodule: contributing to this project.
```console
git clone git@github.com:rife2/bld.git
cd bld
git submodule init
git submodule update
```
Then use `bld` to build itself:
```console
./bld compile
```
The project has an IntelliJ IDEA project structure. You can just open it after all
the dependencies were downloaded and peruse the code.

2
core

@ -1 +1 @@
Subproject commit a45001aa3926f57d9d457e7c12800b264010b5dd Subproject commit fa567721c00d99626ed439db4f0340eadff0ec03

Binary file not shown.

View file

@ -1,11 +1,12 @@
bld.downloadExtensionJavadoc=false bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true bld.downloadExtensionSources=true
bld.downloadLocation= bld.downloadLocation=
bld.extension-antlr=com.uwyn.rife2:bld-antlr4:1.3.0 bld.extension-antlr=com.uwyn.rife2:bld-antlr4:1.4.3
bld.extension-archive=com.uwyn.rife2:bld-archive:0.5.0 bld.extension-archive=com.uwyn.rife2:bld-archive:0.6.3
bld.extension-tests=com.uwyn.rife2:bld-tests-badge:1.5.0 bld.extension-reporter=com.uwyn.rife2:bld-junit-reporter:0.9.2
bld.extension-tests=com.uwyn.rife2:bld-tests-badge:1.6.3
bld.javaOptions= bld.javaOptions=
bld.javacOptions= bld.javacOptions=
bld.repositories=MAVEN_CENTRAL,RIFE2_RELEASES bld.repositories=MAVEN_CENTRAL,RIFE2_RELEASES
bld.sourceDirectories=core/src/bld/java bld.sourceDirectories=core/src/bld/java
bld.version=2.0.1 bld.version=2.3.0

View file

@ -7,6 +7,7 @@ package rife;
import rife.bld.BuildCommand; import rife.bld.BuildCommand;
import rife.bld.Cli; import rife.bld.Cli;
import rife.bld.dependencies.VersionNumber; import rife.bld.dependencies.VersionNumber;
import rife.bld.extension.JUnitReporterOperation;
import rife.bld.extension.ZipOperation; import rife.bld.extension.ZipOperation;
import rife.bld.operations.*; import rife.bld.operations.*;
import rife.bld.publish.*; import rife.bld.publish.*;
@ -33,36 +34,38 @@ public class BldBuild extends AbstractRife2Build {
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES); repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
scope(test) scope(test)
.include(dependency("org.json", "json", version(20240303))); .include(dependency("org.json", "json", version(20250517)));
var core_directory = new File(workDirectory(), "core"); var core_dir = new File(workDirectory(), "core");
var core_src_directory = new File(core_directory, "src"); var core_src_dir = new File(core_dir, "src");
var core_src_main_directory = new File(core_src_directory, "main"); var core_src_main_dir = new File(core_src_dir, "main");
var core_src_main_java_directory = new File(core_src_main_directory, "java");
var core_src_main_resources_directory = new File(core_src_main_directory, "resources");
var core_src_test_directory = new File(core_src_directory, "test");
var core_src_test_java_directory = new File(core_src_test_directory, "java");
var core_src_test_resources_directory = new File(core_src_test_directory, "resources");
var core_src_main_resources_templates_directory = new File(core_src_main_resources_directory, "templates");
antlr4Operation antlr4Operation
.sourceDirectories(List.of(new File(core_src_main_directory, "antlr"))) .sourceDirectories(List.of(new File(core_src_main_dir, "antlr")));
.outputDirectory(new File(buildDirectory(), "generated/rife/template/antlr"));
precompileOperation() var core_src_test_dir = new File(core_src_dir, "test");
.sourceDirectories(core_src_main_resources_templates_directory) var core_src_test_java_dir = new File(core_src_test_dir, "java");
.templateTypes(HTML, XML, SQL, TXT, JSON); var core_src_main_java_dir = new File(core_src_main_dir, "java");
compileOperation() compileOperation()
.mainSourceDirectories(antlr4Operation.outputDirectory(), core_src_main_java_directory) .mainSourceDirectories(antlr4Operation.outputDirectory(), core_src_main_java_dir)
.testSourceDirectories(core_src_test_java_directory) .testSourceDirectories(core_src_test_java_dir)
.compileOptions() .compileOptions()
.debuggingInfo(JavacOptions.DebuggingInfo.ALL) .debuggingInfo(JavacOptions.DebuggingInfo.ALL)
.addAll(List.of("-encoding", "UTF-8")); .addAll(List.of("-encoding", "UTF-8"));
var core_src_main_resources_dir = new File(core_src_main_dir, "resources");
var core_src_main_resources_templates_dir = new File(core_src_main_resources_dir, "templates");
precompileOperation()
.sourceDirectories(core_src_main_resources_templates_dir)
.templateTypes(HTML, XML, SQL, TXT, JSON);
var core_src_test_resources_dir = new File(core_src_test_dir, "resources");
jarOperation() jarOperation()
.sourceDirectories(core_src_main_resources_directory) .sourceDirectories(core_src_main_resources_dir)
.excluded(Pattern.compile("^\\Q" + core_src_main_resources_templates_directory.getAbsolutePath() + "\\E.*")) .excluded(Pattern.compile("^\\Q" + core_src_main_resources_templates_dir.getAbsolutePath() + "\\E.*"))
.manifestAttribute(Attributes.Name.MAIN_CLASS, mainClass()); .manifestAttribute(Attributes.Name.MAIN_CLASS, mainClass());
zipBldOperation zipBldOperation
@ -70,18 +73,21 @@ public class BldBuild extends AbstractRife2Build {
.destinationFileName("bld-" + version() + ".zip"); .destinationFileName("bld-" + version() + ".zip");
testsBadgeOperation testsBadgeOperation
.classpath(core_src_main_resources_directory.getAbsolutePath()) .classpath(core_src_main_resources_dir.getAbsolutePath())
.classpath(core_src_test_resources_directory.getAbsolutePath()); .classpath(core_src_test_resources_dir.getAbsolutePath());
javadocOperation() javadocOperation()
.sourceFiles(FileUtils.getJavaFileList(core_src_main_java_directory)) .sourceFiles(FileUtils.getJavaFileList(core_src_main_java_dir))
.javadocOptions() .javadocOptions()
.docTitle("<a href=\"https://rife2.com/bld\">bld</a> " + version()) .docTitle("<a href=\"https://rife2.com/bld\">bld</a> " + version())
.overview(new File(srcMainJavaDirectory(), "overview.html")); .overview(new File(srcMainJavaDirectory(), "overview.html"))
.addAll(List.of("--allow-script-in-comments",
"-group", "bld", "rife.bld*",
"-group", "RIFE2/core", "rife:rife.cmf*:rife.config*:rife.database*:rife.datastructures*:rife.engine*:rife.forms*:rife.instrument*:rife.ioc*:rife.resources*:rife.selector*:rife.template*:rife.tools*:rife.validation*:rife.xml*"));
publishOperation() publishOperation()
.repository(version.isSnapshot() ? repository("rife2-snapshots") : repository("rife2-releases")) .repository(version.isSnapshot() ? repository("rife2-snapshots") : repository("rife2-releases"))
.repository(version.isSnapshot() ? repository("sonatype-snapshots") : repository("sonatype-releases")) .repository(version.isSnapshot() ? repository("central-snapshots") : repository("central-releases"))
.repository(repository("github")) .repository(repository("github"))
.info(new PublishInfo() .info(new PublishInfo()
.groupId("com.uwyn.rife2") .groupId("com.uwyn.rife2")
@ -134,11 +140,9 @@ public class BldBuild extends AbstractRife2Build {
f.perms(0755); f.perms(0755);
}); });
}); });
b.dir("lib", l -> { b.dir("lib", l -> l.file("bld-wrapper.jar", f -> f.move(path(tmp, "lib", "bld", "bld-wrapper.jar"))));
l.file("bld-wrapper.jar", f -> f.move(path(tmp, "lib", "bld", "bld-wrapper.jar")));
});
}); });
t.dir("lib", l -> l.delete()); t.dir("lib", DirBuilder::delete);
}); });
zipBldOperation zipBldOperation
@ -158,6 +162,14 @@ public class BldBuild extends AbstractRife2Build {
zipBld(); zipBld();
} }
@BuildCommand(summary = "Runs the JUnit reporter")
public void reporter() throws Exception {
new JUnitReporterOperation()
.fromProject(this)
.failOnSummary(true)
.execute();
}
public void publish() public void publish()
throws Exception { throws Exception {
all(); all();

View file

@ -0,0 +1,58 @@
/**
* bld is a new build system that allows you to write your build logic in pure Java.
* <p>
* More information can be found on the <a href="https://rife2.com/bld"><code>bld</code> website</a>.
* <p>
* Note that bld builds on top of the foundation that RIFE2 provides and includes the features
* of <a href="https://github.com/rife2/rife2-core">RIFE2/core</a>.
*
* @since 2.1.0
*/
module rife.bld {
requires java.compiler;
requires java.desktop;
requires java.logging;
requires java.net.http;
requires java.prefs;
requires static java.sql;
requires java.xml;
exports rife.bld;
exports rife.bld.blueprints;
exports rife.bld.dependencies;
exports rife.bld.dependencies.exceptions;
exports rife.bld.help;
exports rife.bld.instrument;
exports rife.bld.operations;
exports rife.bld.operations.exceptions;
exports rife.bld.publish;
exports rife;
exports rife.cmf;
exports rife.cmf.transform;
exports rife.config;
exports rife.config.exceptions;
exports rife.database;
exports rife.database.exceptions;
exports rife.database.queries;
exports rife.database.querymanagers.generic;
exports rife.database.querymanagers.generic.exceptions;
exports rife.database.types;
exports rife.datastructures;
exports rife.engine;
exports rife.forms;
exports rife.ioc;
exports rife.ioc.exceptions;
exports rife.resources;
exports rife.resources.exceptions;
exports rife.selector;
exports rife.template;
exports rife.template.exceptions;
exports rife.tools;
exports rife.tools.exceptions;
exports rife.validation;
exports rife.validation.annotations;
exports rife.validation.exceptions;
exports rife.xml;
exports rife.xml.exceptions;
}

View file

@ -0,0 +1,24 @@
<html>
<body>
<p><code>bld</code> is a new build system that allows you to write your build logic in pure Java.</p>
<p><code>bld</code>'s website is <a href="https://rife2.com/bld">https://rife2.com/bld</a>.</p>
<p>The GitHub project is at <a href="https://github.com/rife2/bld">https://github.com/rife2/bld</a></p>
<p>The documentation is available at <a href="https://github.com/rife2/bld/wiki">https://github.com/rife2/bld/wiki</a></p>
<p>Note that bld builds on top of the foundation that RIFE2 provides and includes the features of
<a href="https://github.com/rife2/rife2-core">RIFE2/core</a>.</p>
<script type="text/javascript">
window.onload = function () {
show('all-packages-table', 'all-packages-table-tab1', 2);
};
</script>
<style>
#all-packages-table-tab0 {
display: none;
}
</style>
</body>
</html>

View file

@ -5,6 +5,7 @@
package rife.bld; package rife.bld;
import rife.bld.dependencies.*; import rife.bld.dependencies.*;
import rife.bld.dependencies.Module;
import rife.bld.help.*; import rife.bld.help.*;
import rife.bld.operations.*; import rife.bld.operations.*;
import rife.tools.FileUtils; import rife.tools.FileUtils;
@ -54,12 +55,19 @@ public class BaseProject extends BuildExecutor {
*/ */
protected VersionNumber version = null; protected VersionNumber version = null;
/** /**
* The project's main class. * The project's main class to execute.
* *
* @see #mainClass() * @see #mainClass()
* @since 1.5 * @since 1.5
*/ */
protected String mainClass = null; protected String mainClass = null;
/**
* The project's module to execute.
*
* @see #module()
* @since 2.1
*/
protected String module = null;
/** /**
* The project's repositories for dependency resolution. * The project's repositories for dependency resolution.
@ -245,6 +253,13 @@ public class BaseProject extends BuildExecutor {
* @since 1.5 * @since 1.5
*/ */
protected File libCompileDirectory = null; protected File libCompileDirectory = null;
/**
* The modules compile scope lib directory.
*
* @see #libCompileModulesDirectory()
* @since 2.1
*/
protected File libCompileModulesDirectory = null;
/** /**
* The provided scope lib directory. * The provided scope lib directory.
* *
@ -252,6 +267,13 @@ public class BaseProject extends BuildExecutor {
* @since 1.8 * @since 1.8
*/ */
protected File libProvidedDirectory = null; protected File libProvidedDirectory = null;
/**
* The modules provided scope lib directory.
*
* @see #libProvidedModulesDirectory()
* @since 2.1
*/
protected File libProvidedModulesDirectory = null;
/** /**
* The runtime scope lib directory. * The runtime scope lib directory.
* *
@ -259,6 +281,13 @@ public class BaseProject extends BuildExecutor {
* @since 1.5 * @since 1.5
*/ */
protected File libRuntimeDirectory = null; protected File libRuntimeDirectory = null;
/**
* The modules runtime scope lib directory.
*
* @see #libRuntimeModulesDirectory()
* @since 2.1
*/
protected File libRuntimeModulesDirectory = null;
/** /**
* The standalone scope lib directory. * The standalone scope lib directory.
* *
@ -267,12 +296,26 @@ public class BaseProject extends BuildExecutor {
*/ */
protected File libStandaloneDirectory = null; protected File libStandaloneDirectory = null;
/** /**
* The standalone scope lib directory. * The modules standalone scope lib directory.
*
* @see #libStandaloneModulesDirectory()
* @since 2.1
*/
protected File libStandaloneModulesDirectory = null;
/**
* The test scope lib directory.
* *
* @see #libTestDirectory() * @see #libTestDirectory()
* @since 1.5 * @since 1.5
*/ */
protected File libTestDirectory = null; protected File libTestDirectory = null;
/**
* The modules test scope lib directory.
*
* @see #libTestModulesDirectory()
* @since 2.1
*/
protected File libTestModulesDirectory = null;
/** /**
* The build directory. * The build directory.
* *
@ -860,6 +903,101 @@ public class BaseProject extends BuildExecutor {
return new LocalDependency(path); return new LocalDependency(path);
} }
/**
* Creates a new module instance.
*
* @param groupId the module group identifier
* @param artifactId the module artifact identifier
* @return a newly created {@code Module} instance
* @since 2.1
*/
public Module module(String groupId, String artifactId) {
return new Module(groupId, artifactId);
}
/**
* Creates a new module instance.
*
* @param groupId the module group identifier
* @param artifactId the module artifact identifier
* @param version the module version
* @return a newly created {@code Module} instance
* @since 2.1
*/
public Module module(String groupId, String artifactId, String version) {
return new Module(groupId, artifactId, version(version));
}
/**
* Creates a new module instance.
*
* @param groupId the module group identifier
* @param artifactId the module artifact identifier
* @param version the module version
* @param classifier the module classifier
* @return a newly created {@code Module} instance
* @since 2.1
*/
public Module module(String groupId, String artifactId, String version, String classifier) {
return new Module(groupId, artifactId, version(version), classifier);
}
/**
* Creates a new module instance.
*
* @param groupId the module group identifier
* @param artifactId the module artifact identifier
* @param version the module version
* @return a newly created {@code Module} instance
* @since 2.1
*/
public Module module(String groupId, String artifactId, Version version) {
return new Module(groupId, artifactId, version);
}
/**
* Creates a new module instance.
*
* @param groupId the module group identifier
* @param artifactId the module artifact identifier
* @param version the module version
* @param classifier the module classifier
* @return a newly created {@code Module} instance
* @since 2.1
*/
public Module module(String groupId, String artifactId, Version version, String classifier) {
return new Module(groupId, artifactId, version, classifier);
}
/**
* Creates a new module instance from a string representation.
* The format is {@code groupId:artifactId:version:classifier}.
* The {@code version} and {@code classifier} are optional.
* <p>
* If the string can't be successfully parsed, {@code null} will be returned.
*
* @param description the module string to parse
* @return a parsed instance of {@code Module}; or
* {@code null} when the string couldn't be parsed
* @since 2.1
*/
public Module module(String description) {
return Module.parse(description);
}
/**
* Creates a local module instance.
* <p>
* If the local module points to a directory, it will be scanned for jar files.
*
* @param path the file system path of the local module
* @since 2.1
*/
public LocalModule localModule(String path) {
return new LocalModule(path);
}
/* /*
* Project directories * Project directories
*/ */
@ -1012,6 +1150,16 @@ public class BaseProject extends BuildExecutor {
return Objects.requireNonNullElseGet(libCompileDirectory, () -> new File(libDirectory(), "compile")); return Objects.requireNonNullElseGet(libCompileDirectory, () -> new File(libDirectory(), "compile"));
} }
/**
* Returns the project modules compile scope lib directory.
* Defaults to {@code "modules"} relative to {@link #libCompileDirectory()}.
*
* @since 2.1
*/
public File libCompileModulesDirectory() {
return Objects.requireNonNullElseGet(libCompileModulesDirectory, () -> new File(libCompileDirectory(), "modules"));
}
/** /**
* Returns the project provided scope lib directory. * Returns the project provided scope lib directory.
* Defaults to {@code "provided"} relative to {@link #libDirectory()}. * Defaults to {@code "provided"} relative to {@link #libDirectory()}.
@ -1022,6 +1170,16 @@ public class BaseProject extends BuildExecutor {
return Objects.requireNonNullElseGet(libProvidedDirectory, () -> new File(libDirectory(), "provided")); return Objects.requireNonNullElseGet(libProvidedDirectory, () -> new File(libDirectory(), "provided"));
} }
/**
* Returns the project modules provided scope lib directory.
* Defaults to {@code "modules"} relative to {@link #libProvidedDirectory()}.
*
* @since 2.1
*/
public File libProvidedModulesDirectory() {
return Objects.requireNonNullElseGet(libProvidedModulesDirectory, () -> new File(libProvidedDirectory(), "modules"));
}
/** /**
* Returns the project runtime scope lib directory. * Returns the project runtime scope lib directory.
* Defaults to {@code "runtime"} relative to {@link #libDirectory()}. * Defaults to {@code "runtime"} relative to {@link #libDirectory()}.
@ -1032,6 +1190,16 @@ public class BaseProject extends BuildExecutor {
return Objects.requireNonNullElseGet(libRuntimeDirectory, () -> new File(libDirectory(), "runtime")); return Objects.requireNonNullElseGet(libRuntimeDirectory, () -> new File(libDirectory(), "runtime"));
} }
/**
* Returns the project modules runtime scope lib directory.
* Defaults to {@code "modules"} relative to {@link #libRuntimeDirectory()}.
*
* @since 1.5
*/
public File libRuntimeModulesDirectory() {
return Objects.requireNonNullElseGet(libRuntimeModulesDirectory, () -> new File(libRuntimeDirectory(), "modules"));
}
/** /**
* Returns the project standalone scope lib directory. * Returns the project standalone scope lib directory.
* Defaults to {@code null}. * Defaults to {@code null}.
@ -1039,7 +1207,17 @@ public class BaseProject extends BuildExecutor {
* @since 1.5 * @since 1.5
*/ */
public File libStandaloneDirectory() { public File libStandaloneDirectory() {
return null; return libStandaloneDirectory;
}
/**
* Returns the project standalone scope lib directory.
* Defaults to {@code null}.
*
* @since 2.1
*/
public File libStandaloneModulesDirectory() {
return libStandaloneModulesDirectory;
} }
/** /**
@ -1052,6 +1230,16 @@ public class BaseProject extends BuildExecutor {
return Objects.requireNonNullElseGet(libTestDirectory, () -> new File(libDirectory(), "test")); return Objects.requireNonNullElseGet(libTestDirectory, () -> new File(libDirectory(), "test"));
} }
/**
* Returns the project modules test scope lib directory.
* Defaults to {@code "modules"} relative to {@link #libTestDirectory()}.
*
* @since 2.1
*/
public File libTestModulesDirectory() {
return Objects.requireNonNullElseGet(libTestModulesDirectory, () -> new File(libTestDirectory(), "modules"));
}
/** /**
* Returns the project build directory. * Returns the project build directory.
* Defaults to {@code "build"} relative to {@link #workDirectory()}. * Defaults to {@code "build"} relative to {@link #workDirectory()}.
@ -1142,12 +1330,19 @@ public class BaseProject extends BuildExecutor {
libDirectory().mkdirs(); libDirectory().mkdirs();
libBldDirectory().mkdirs(); libBldDirectory().mkdirs();
libCompileDirectory().mkdirs(); libCompileDirectory().mkdirs();
libCompileModulesDirectory().mkdirs();
libProvidedDirectory().mkdirs(); libProvidedDirectory().mkdirs();
libProvidedModulesDirectory().mkdirs();
libRuntimeDirectory().mkdirs(); libRuntimeDirectory().mkdirs();
libRuntimeModulesDirectory().mkdirs();
if (libStandaloneDirectory() != null) { if (libStandaloneDirectory() != null) {
libStandaloneDirectory().mkdirs(); libStandaloneDirectory().mkdirs();
} }
if (libStandaloneModulesDirectory() != null) {
libStandaloneModulesDirectory().mkdirs();
}
libTestDirectory().mkdirs(); libTestDirectory().mkdirs();
libTestModulesDirectory().mkdirs();
} }
/** /**
@ -1181,6 +1376,17 @@ public class BaseProject extends BuildExecutor {
return pkg; return pkg;
} }
/**
* Returns whether this project's package was set.
*
* @return {@code true} if the package was set; or
* {@code false} otherwise
* @since 2.2.1
*/
public boolean hasPkg() {
return pkg != null;
}
/** /**
* Returns the project's name. * Returns the project's name.
* *
@ -1193,6 +1399,17 @@ public class BaseProject extends BuildExecutor {
return name; return name;
} }
/**
* Returns whether this project's name was set.
*
* @return {@code true} if the name was set; or
* {@code false} otherwise
* @since 2.2.1
*/
public boolean hasName() {
return name != null;
}
/** /**
* Returns the project's version. * Returns the project's version.
* *
@ -1206,17 +1423,34 @@ public class BaseProject extends BuildExecutor {
} }
/** /**
* Returns the project's main class. * Returns whether this project's version was set.
*
* @return {@code true} if the version was set; or
* {@code false} otherwise
* @since 2.2.1
*/
public boolean hasVersion() {
return version != null;
}
/**
* Returns the project's main class to execute.
* *
* @since 1.5 * @since 1.5
*/ */
public String mainClass() { public String mainClass() {
if (mainClass == null) {
throw new IllegalStateException("The mainClass variable has to be set.");
}
return mainClass; return mainClass;
} }
/**
* Returns the project's module to execute.
*
* @since 2.1
*/
public String module() {
return module;
}
/** /**
* Returns the list of repositories for this project. * Returns the list of repositories for this project.
* <p> * <p>
@ -1332,7 +1566,14 @@ public class BaseProject extends BuildExecutor {
* @since 1.5 * @since 1.5
*/ */
public String uberJarMainClass() { public String uberJarMainClass() {
return Objects.requireNonNullElseGet(uberJarMainClass, this::mainClass); if (uberJarMainClass != null) {
return uberJarMainClass;
}
if (mainClass() != null) {
return mainClass();
}
throw new IllegalStateException("The mainClass variable has to be set.");
} }
/** /**
@ -1415,6 +1656,25 @@ public class BaseProject extends BuildExecutor {
return classpath; return classpath;
} }
/**
* Returns all the jar files that are in the compile scope module path.
* <p>
* By default, this collects all the jar files in the {@link #libCompileModulesDirectory()}
* and adds all the jar files from the compile scope local modules.
*
* @since 2.1
*/
public List<File> compileModulePathJars() {
// detect the jar files in the modules compile lib directory
var dir_abs = libCompileModulesDirectory().getAbsoluteFile();
var jar_files = FileUtils.getFileList(dir_abs, INCLUDED_JARS, EXCLUDED_JARS);
// build the compilation module path
var module_path = new ArrayList<>(jar_files.stream().map(file -> new File(dir_abs, file)).toList());
addLocalModules(module_path, Scope.compile);
return module_path;
}
/** /**
* Returns all the jar files that are in the provided scope classpath. * Returns all the jar files that are in the provided scope classpath.
* <p> * <p>
@ -1434,6 +1694,25 @@ public class BaseProject extends BuildExecutor {
return classpath; return classpath;
} }
/**
* Returns all the jar files that are in the provided scope module path.
* <p>
* By default, this collects all the jar files in the {@link #libProvidedModulesDirectory()}
* and adds all the jar files from the provided scope local modules.
*
* @since 2.1
*/
public List<File> providedModulePathJars() {
// detect the jar files in the modules provided lib directory
var dir_abs = libProvidedModulesDirectory().getAbsoluteFile();
var jar_files = FileUtils.getFileList(dir_abs, INCLUDED_JARS, EXCLUDED_JARS);
// build the provided module path
var module_path = new ArrayList<>(jar_files.stream().map(file -> new File(dir_abs, file)).toList());
addLocalModules(module_path, Scope.provided);
return module_path;
}
/** /**
* Returns all the jar files that are in the runtime scope classpath. * Returns all the jar files that are in the runtime scope classpath.
* <p> * <p>
@ -1453,6 +1732,25 @@ public class BaseProject extends BuildExecutor {
return classpath; return classpath;
} }
/**
* Returns all the jar files that are in the runtime scope module path.
* <p>
* By default, this collects all the jar files in the {@link #libRuntimeModulesDirectory()}
* and adds all the jar files from the runtime scope local modules.
*
* @since 2.1
*/
public List<File> runtimeModulePathJars() {
// detect the jar files in the modules runtime lib directory
var dir_abs = libRuntimeModulesDirectory().getAbsoluteFile();
var jar_files = FileUtils.getFileList(dir_abs, INCLUDED_JARS, EXCLUDED_JARS);
// build the runtime module path
var module_path = new ArrayList<>(jar_files.stream().map(file -> new File(dir_abs, file)).toList());
addLocalModules(module_path, Scope.runtime);
return module_path;
}
/** /**
* Returns all the jar files that are in the standalone scope classpath. * Returns all the jar files that are in the standalone scope classpath.
* <p> * <p>
@ -1477,6 +1775,30 @@ public class BaseProject extends BuildExecutor {
return classpath; return classpath;
} }
/**
* Returns all the jar files that are in the standalone scope module path.
* <p>
* By default, this collects all the jar files in the {@link #libStandaloneModulesDirectory()}
* and adds all the jar files from the standalone scope local modules.
*
* @since 2.1
*/
public List<File> standaloneModulePathJars() {
// build the standalone classpath
List<File> module_path;
if (libStandaloneModulesDirectory() == null) {
module_path = new ArrayList<>();
} else {
// detect the jar files in the modules standalone lib directory
var dir_abs = libStandaloneModulesDirectory().getAbsoluteFile();
var jar_files = FileUtils.getFileList(dir_abs, INCLUDED_JARS, EXCLUDED_JARS);
module_path = new ArrayList<>(jar_files.stream().map(file -> new File(dir_abs, file)).toList());
}
addLocalModules(module_path, Scope.standalone);
return module_path;
}
/** /**
* Returns all the jar files that are in the test scope classpath. * Returns all the jar files that are in the test scope classpath.
* <p> * <p>
@ -1496,20 +1818,51 @@ public class BaseProject extends BuildExecutor {
return classpath; return classpath;
} }
/**
* Returns all the jar files that are in the test scope module path.
* <p>
* By default, this collects all the jar files in the {@link #libTestModulesDirectory()}
* and adds all the jar files from the test scope local modules.
*
* @since 2.1
*/
public List<File> testModulePathJars() {
// detect the jar files in the test lib directory
var dir_abs = libTestModulesDirectory().getAbsoluteFile();
var jar_files = FileUtils.getFileList(dir_abs, INCLUDED_JARS, EXCLUDED_JARS);
// build the test module path
var module_path = new ArrayList<>(jar_files.stream().map(file -> new File(dir_abs, file)).toList());
addLocalModules(module_path, Scope.test);
return module_path;
}
private void addLocalDependencies(List<File> classpath, Scope scope) { private void addLocalDependencies(List<File> classpath, Scope scope) {
if (dependencies.get(scope) == null) { if (dependencies.get(scope) == null) {
return; return;
} }
for (var dependency : dependencies.get(scope).localDependencies()) { for (var dependency : dependencies.get(scope).localDependencies()) {
var local_file = new File(workDirectory(), dependency.path()); addLocalJars(classpath, dependency.path());
if (local_file.exists()) { }
if (local_file.isDirectory()) { }
var local_jar_files = FileUtils.getFileList(local_file.getAbsoluteFile(), INCLUDED_JARS, EXCLUDED_JARS);
classpath.addAll(new ArrayList<>(local_jar_files.stream().map(file -> new File(local_file, file)).toList())); private void addLocalModules(List<File> classpath, Scope scope) {
} else { if (dependencies.get(scope) == null) {
classpath.add(local_file); return;
} }
for (var module : dependencies.get(scope).localModules()) {
addLocalJars(classpath, module.path());
}
}
private void addLocalJars(List<File> jars, String path) {
var local_file = new File(workDirectory(), path);
if (local_file.exists()) {
if (local_file.isDirectory()) {
var local_jar_files = FileUtils.getFileList(local_file.getAbsoluteFile(), INCLUDED_JARS, EXCLUDED_JARS);
jars.addAll(new ArrayList<>(local_jar_files.stream().map(file -> new File(local_file, file)).toList()));
} else {
jars.add(local_file);
} }
} }
} }
@ -1517,7 +1870,7 @@ public class BaseProject extends BuildExecutor {
/** /**
* Returns all the classpath entries for compiling the main sources. * Returns all the classpath entries for compiling the main sources.
* <p> * <p>
* By default, this converts the files from {@link #compileClasspathJars()} to absolute paths. * By default, this converts the files from {@link #compileClasspathJars()} and {@link #providedClasspathJars()} to absolute paths.
* *
* @since 1.5 * @since 1.5
*/ */
@ -1525,10 +1878,21 @@ public class BaseProject extends BuildExecutor {
return FileUtils.combineToAbsolutePaths(compileClasspathJars(), providedClasspathJars()); return FileUtils.combineToAbsolutePaths(compileClasspathJars(), providedClasspathJars());
} }
/**
* Returns all the module path entries for compiling the main sources.
* <p>
* By default, this converts the files from {@link #compileModulePathJars()} and {@link #providedModulePathJars()} to absolute paths.
*
* @since 2.1
*/
public List<String> compileMainModulePath() {
return FileUtils.combineToAbsolutePaths(compileModulePathJars(), providedModulePathJars());
}
/** /**
* Returns all the classpath entries for compiling the test sources. * Returns all the classpath entries for compiling the test sources.
* <p> * <p>
* By default, this converts the files from {@link #compileClasspathJars()} and * By default, this converts the files from {@link #compileClasspathJars()}, {@link #providedClasspathJars()} and
* {@link #testClasspathJars()} to absolute paths, as well as the {@link #buildMainDirectory()} * {@link #testClasspathJars()} to absolute paths, as well as the {@link #buildMainDirectory()}
* *
* @since 1.5 * @since 1.5
@ -1540,6 +1904,18 @@ public class BaseProject extends BuildExecutor {
return paths; return paths;
} }
/**
* Returns all the module path entries for compiling the test sources.
* <p>
* By default, this converts the files from {@link #compileModulePathJars()}, {@link #providedModulePathJars()} and
* {@link #testModulePathJars()} to absolute paths.
*
* @since 2.1
*/
public List<String> compileTestModulePath() {
return FileUtils.combineToAbsolutePaths(compileModulePathJars(), providedModulePathJars(), testModulePathJars());
}
/** /**
* Returns all the classpath entries for running the application. * Returns all the classpath entries for running the application.
* <p> * <p>
@ -1557,10 +1933,22 @@ public class BaseProject extends BuildExecutor {
return paths; return paths;
} }
/**
* Returns all the module path entries for running the application.
* <p>
* By default, this converts the files from {@link #compileModulePathJars()},
* {@link #runtimeModulePathJars()} and {@link #standaloneModulePathJars()} to absolute paths.
*
* @since 2.1
*/
public List<String> runModulePath() {
return FileUtils.combineToAbsolutePaths(compileModulePathJars(), runtimeModulePathJars(), standaloneModulePathJars());
}
/** /**
* Returns all the classpath entries for testing the application. * Returns all the classpath entries for testing the application.
* <p> * <p>
* By default, this converts the files from {@link #compileClasspathJars()}, * By default, this converts the files from {@link #compileClasspathJars()}, {@link #providedClasspathJars()},
* {@link #runtimeClasspathJars()} and {@link #testClasspathJars()} * {@link #runtimeClasspathJars()} and {@link #testClasspathJars()}
* to absolute paths, as well as the {@link #srcMainResourcesDirectory()}, * to absolute paths, as well as the {@link #srcMainResourcesDirectory()},
* {@link #buildMainDirectory()} and {@link #buildTestDirectory()} * {@link #buildMainDirectory()} and {@link #buildTestDirectory()}
@ -1577,6 +1965,19 @@ public class BaseProject extends BuildExecutor {
return paths; return paths;
} }
/**
* Returns all the module path entries for testing the application.
* <p>
* By default, this converts the files from {@link #compileModulePathJars()}, {@link #providedModulePathJars()},
* {@link #runtimeModulePathJars()} and {@link #testModulePathJars()}
* to absolute paths.
*
* @since 2.1
*/
public List<String> testModulePath() {
return FileUtils.combineToAbsolutePaths(compileModulePathJars(), providedModulePathJars(), runtimeModulePathJars(), standaloneModulePathJars(), testModulePathJars());
}
/** /**
* Executes download and purge commands automatically when the * Executes download and purge commands automatically when the
* {@code autoDownloadPurge} flag is set and changes have been detected. * {@code autoDownloadPurge} flag is set and changes have been detected.

View file

@ -108,6 +108,11 @@ public class WebProject extends Project {
return Objects.requireNonNullElseGet(libStandaloneDirectory, () -> new File(libDirectory(), "standalone")); return Objects.requireNonNullElseGet(libStandaloneDirectory, () -> new File(libDirectory(), "standalone"));
} }
@Override
public File libStandaloneModulesDirectory() {
return Objects.requireNonNullElseGet(libStandaloneModulesDirectory, () -> new File(libStandaloneDirectory(), "modules"));
}
/** /**
* Returns the project main webapp directory. * Returns the project main webapp directory.
* Defaults to {@code "webapp"} relative to {@link #srcMainDirectory()}. * Defaults to {@code "webapp"} relative to {@link #srcMainDirectory()}.

View file

@ -22,22 +22,22 @@ import static rife.bld.dependencies.Scope.test;
* @since 1.9 * @since 1.9
*/ */
public class AppProjectBlueprint extends Project { public class AppProjectBlueprint extends Project {
public AppProjectBlueprint(File work, String packageName, String projectName) { public AppProjectBlueprint(File work, String packageName, String projectName, String baseName) {
this(work, packageName, projectName, new VersionNumber(0,0,1)); this(work, packageName, projectName, baseName, new VersionNumber(0,0,1));
} }
public AppProjectBlueprint(File work, String packageName, String projectName, VersionNumber versionNumber) { public AppProjectBlueprint(File work, String packageName, String projectName, String baseName, VersionNumber versionNumber) {
workDirectory = work; workDirectory = work;
pkg = packageName; pkg = packageName;
name = projectName; name = projectName;
mainClass = packageName + "." + StringUtils.capitalize(projectName) + "Main"; mainClass = packageName + "." + baseName;
version = versionNumber; version = versionNumber;
downloadSources = true; downloadSources = true;
repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS); repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS);
scope(test) scope(test)
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5,10,3))) .include(dependency("org.junit.jupiter", "junit-jupiter", version(5,11,4)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,10,3))); .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,11,4)));
} }
} }

View file

@ -21,16 +21,16 @@ import static rife.bld.dependencies.Repository.SONATYPE_SNAPSHOTS;
* @since 1.5.20 * @since 1.5.20
*/ */
public class BaseProjectBlueprint extends Project { public class BaseProjectBlueprint extends Project {
public BaseProjectBlueprint(File work, String packageName, String projectName) { public BaseProjectBlueprint(File work, String packageName, String projectName, String baseName) {
this(work, packageName, projectName, new VersionNumber(0,0,1)); this(work, packageName, projectName, baseName, new VersionNumber(0,0,1));
} }
public BaseProjectBlueprint(File work, String packageName, String projectName, VersionNumber versionNumber) { public BaseProjectBlueprint(File work, String packageName, String projectName, String baseName, VersionNumber versionNumber) {
workDirectory = work; workDirectory = work;
pkg = packageName; pkg = packageName;
name = projectName; name = projectName;
mainClass = packageName + "." + StringUtils.capitalize(projectName) + "Main"; mainClass = packageName + "." + baseName;
version = versionNumber; version = versionNumber;
downloadSources = true; downloadSources = true;

View file

@ -22,22 +22,22 @@ import static rife.bld.dependencies.Scope.test;
* @since 1.6 * @since 1.6
*/ */
public class LibProjectBlueprint extends Project { public class LibProjectBlueprint extends Project {
public LibProjectBlueprint(File work, String packageName, String projectName) { public LibProjectBlueprint(File work, String packageName, String projectName, String baseName) {
this(work, packageName, projectName, new VersionNumber(0,0,1)); this(work, packageName, projectName, baseName, new VersionNumber(0,0,1));
} }
public LibProjectBlueprint(File work, String packageName, String projectName, VersionNumber versionNumber) { public LibProjectBlueprint(File work, String packageName, String projectName, String baseName, VersionNumber versionNumber) {
workDirectory = work; workDirectory = work;
pkg = packageName; pkg = packageName;
name = projectName; name = projectName;
mainClass = packageName + "." + StringUtils.capitalize(projectName) + "Lib"; mainClass = packageName + "." + baseName;
version = versionNumber; version = versionNumber;
downloadSources = true; downloadSources = true;
repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS); repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS);
scope(test) scope(test)
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5,10,3))) .include(dependency("org.junit.jupiter", "junit-jupiter", version(5,11,4)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,10,3))); .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,11,4)));
} }
} }

View file

@ -23,31 +23,31 @@ import static rife.bld.dependencies.Scope.*;
* @since 1.5 * @since 1.5
*/ */
public class Rife2ProjectBlueprint extends WebProject { public class Rife2ProjectBlueprint extends WebProject {
public Rife2ProjectBlueprint(File work, String packageName, String projectName) { public Rife2ProjectBlueprint(File work, String packageName, String projectName, String baseName) {
this(work, packageName, projectName, new VersionNumber(0,0,1)); this(work, packageName, projectName, baseName, new VersionNumber(0,0,1));
} }
public Rife2ProjectBlueprint(File work, String packageName, String projectName, VersionNumber versionNumber) { public Rife2ProjectBlueprint(File work, String packageName, String projectName, String baseName, VersionNumber versionNumber) {
workDirectory = work; workDirectory = work;
pkg = packageName; pkg = packageName;
name = projectName; name = projectName;
mainClass = packageName + "." + StringUtils.capitalize(projectName) + "Site"; mainClass = packageName + "." + baseName + "Site";
uberJarMainClass = mainClass + "Uber"; uberJarMainClass = mainClass + "Uber";
version = versionNumber; version = versionNumber;
downloadSources = true; downloadSources = true;
repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS); repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS);
scope(compile) scope(compile)
.include(dependency("com.uwyn.rife2", "rife2", version(1,8,0))); .include(dependency("com.uwyn.rife2", "rife2", version(1,9,1)));
scope(test) scope(test)
.include(dependency("org.jsoup", "jsoup", version(1,18,1))) .include(dependency("org.jsoup", "jsoup", version(1,18,3)))
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5,10,3))) .include(dependency("org.junit.jupiter", "junit-jupiter", version(5,11,4)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,10,3))); .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,11,4)));
scope(standalone) scope(standalone)
.include(dependency("org.eclipse.jetty.ee10", "jetty-ee10", version(12,0,11))) .include(dependency("org.eclipse.jetty.ee10", "jetty-ee10", version(12,0,16)))
.include(dependency("org.eclipse.jetty.ee10", "jetty-ee10-servlet", version(12,0,11))) .include(dependency("org.eclipse.jetty.ee10", "jetty-ee10-servlet", version(12,0,16)))
.include(dependency("org.slf4j", "slf4j-simple", version(2,0,13))); .include(dependency("org.slf4j", "slf4j-simple", version(2,0,16)));
precompileOperation().templateTypes(TemplateType.HTML); precompileOperation().templateTypes(TemplateType.HTML);
} }

View file

@ -4,26 +4,51 @@
*/ */
package rife.bld.dependencies; package rife.bld.dependencies;
import java.util.HashSet;
import java.util.Objects; import java.util.Objects;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/** /**
* Contains the information required to describe an url dependency in the build system. * Contains the information required to describe a dependency in the build system.
* *
* @param groupId the dependency group identifier
* @param artifactId the dependency url identifier
* @param version the dependency version
* @param classifier the dependency classier
* @param type the dependency type
* @param exclusions the dependency exclusions for transitive resolution
* @param parent the parent dependency that created this dependency (only for information purposes)
* @author Geert Bevin (gbevin[remove] at uwyn dot com) * @author Geert Bevin (gbevin[remove] at uwyn dot com)
* @since 1.5 * @since 1.5
*/ */
public record Dependency(String groupId, String artifactId, Version version, String classifier, String type, ExclusionSet exclusions, Dependency parent) { public class Dependency {
public static final String CLASSIFIER_SOURCES = "sources"; public static final String CLASSIFIER_SOURCES = "sources";
public static final String CLASSIFIER_JAVADOC = "javadoc"; public static final String CLASSIFIER_JAVADOC = "javadoc";
/**
* The dependency type name for a JAR file that can be placed either on the class-path or on the module-path.
*
* @since 2.1
*/
public static final String TYPE_JAR = "jar";
/**
* The dependency type name for a JAR file to unconditionally place on the class-path.
*
* @since 2.1
*/
public static final String TYPE_CLASSPATH_JAR = "classpath-jar";
/**
* The dependency type name for a JAR file to unconditionally place on the module-path.
*
* @since 2.1
*/
// see https://github.com/apache/maven/blob/maven-4.0.0-beta-3/api/maven-api-core/src/main/java/org/apache/maven/api/Type.java
public static final String TYPE_MODULAR_JAR = "modular-jar";
private final String groupId_;
private final String artifactId_;
private final Version version_;
private final String classifier_;
private final String type_;
private final ExclusionSet exclusions_;
private final Dependency parent_;
private final HashSet<String> excludedClassifiers_;
public Dependency(String groupId, String artifactId) { public Dependency(String groupId, String artifactId) {
this(groupId, artifactId, null, null, null); this(groupId, artifactId, null, null, null);
} }
@ -45,13 +70,21 @@ public record Dependency(String groupId, String artifactId, Version version, Str
} }
public Dependency(String groupId, String artifactId, Version version, String classifier, String type, ExclusionSet exclusions, Dependency parent) { public Dependency(String groupId, String artifactId, Version version, String classifier, String type, ExclusionSet exclusions, Dependency parent) {
this.groupId = groupId; if (type == null) {
this.artifactId = artifactId; type = TYPE_JAR;
this.version = (version == null ? VersionNumber.UNKNOWN : version); }
this.classifier = (classifier == null ? "" : classifier); if (parent != null && parent.isModularJar() && TYPE_JAR.equals(type)) {
this.type = (type == null ? "jar" : type); type = TYPE_MODULAR_JAR;
this.exclusions = (exclusions == null ? new ExclusionSet() : exclusions); }
this.parent = parent;
this.groupId_ = groupId;
this.artifactId_ = artifactId;
this.version_ = (version == null ? VersionNumber.UNKNOWN : version);
this.classifier_ = (classifier == null ? "" : classifier);
this.type_ = type;
this.exclusions_ = (exclusions == null ? new ExclusionSet() : exclusions);
this.parent_ = parent;
this.excludedClassifiers_ = new HashSet<>();
} }
private static final Pattern DEPENDENCY_PATTERN = Pattern.compile("^(?<groupId>[^:@]+):(?<artifactId>[^:@]+)(?::(?<version>[^:@]+)(?::(?<classifier>[^:@]+))?)?(?:@(?<type>[^:@]+))?$"); private static final Pattern DEPENDENCY_PATTERN = Pattern.compile("^(?<groupId>[^:@]+):(?<artifactId>[^:@]+)(?::(?<version>[^:@]+)(?::(?<classifier>[^:@]+))?)?(?:@(?<type>[^:@]+))?$");
@ -95,7 +128,7 @@ public record Dependency(String groupId, String artifactId, Version version, Str
* @since 1.5 * @since 1.5
*/ */
public Dependency baseDependency() { public Dependency baseDependency() {
return new Dependency(groupId, artifactId, VersionNumber.UNKNOWN, classifier, type); return new Dependency(groupId_, artifactId_, VersionNumber.UNKNOWN, classifier_, type_);
} }
/** /**
@ -107,7 +140,7 @@ public record Dependency(String groupId, String artifactId, Version version, Str
* @since 1.5 * @since 1.5
*/ */
public Dependency exclude(String groupId, String artifactId) { public Dependency exclude(String groupId, String artifactId) {
exclusions.add(new DependencyExclusion(groupId, artifactId)); exclusions_.add(new DependencyExclusion(groupId, artifactId));
return this; return this;
} }
@ -119,7 +152,29 @@ public record Dependency(String groupId, String artifactId, Version version, Str
* @since 1.5.6 * @since 1.5.6
*/ */
public Dependency withClassifier(String classifier) { public Dependency withClassifier(String classifier) {
return new Dependency(groupId, artifactId, version, classifier, type); return new Dependency(groupId_, artifactId_, version_, classifier, type_);
}
/**
* Exclude the sources artifact from download operations.
*
* @return this dependency instance
* @since 2.1
*/
public Dependency excludeSources() {
excludedClassifiers_.add(CLASSIFIER_SOURCES);
return this;
}
/**
* Exclude the javadoc artifact from download operations.
*
* @return this dependency instance
* @since 2.1
*/
public Dependency excludeJavadoc() {
excludedClassifiers_.add(CLASSIFIER_JAVADOC);
return this;
} }
/** /**
@ -146,34 +201,134 @@ public record Dependency(String groupId, String artifactId, Version version, Str
* @since 2.0 * @since 2.0
*/ */
public String toArtifactString() { public String toArtifactString() {
return groupId + ':' + artifactId; return groupId_ + ':' + artifactId_;
} }
public String toString() { public String toString() {
var result = new StringBuilder(groupId).append(':').append(artifactId); var result = new StringBuilder(groupId_).append(':').append(artifactId_);
if (!version.equals(VersionNumber.UNKNOWN)) { if (!version_.equals(VersionNumber.UNKNOWN)) {
result.append(':').append(version); result.append(':').append(version_);
} }
if (!classifier.isEmpty()) { if (!classifier_.isEmpty()) {
result.append(':').append(classifier); result.append(':').append(classifier_);
} }
if (!type.isEmpty() && !"jar".equals(type)) { if (!type_.isEmpty() && !TYPE_JAR.equals(type_)) {
result.append('@').append(type); result.append('@').append(type_);
} }
return result.toString(); return result.toString();
} }
/**
* Returns this dependency's {@code groupId}.
*
* @return the {@code groupId} of this dependency
* @since 1.5
*/
public String groupId() {
return groupId_;
}
/**
* Returns this dependency's {@code artifactId}.
*
* @return the {@code artifactId} of this dependency
* @since 1.5
*/
public String artifactId() {
return artifactId_;
}
/**
* Returns this dependency's {@code version}.
*
* @return the {@code version} of this dependency
* @since 1.5
*/
public Version version() {
return version_;
}
/**
* Returns this dependency's {@code classifier}.
*
* @return the {@code classifier} of this dependency
* @since 1.5
*/
public String classifier() {
return classifier_;
}
/**
* Returns this dependency's {@code type}.
*
* @return the {@code type} of this dependency
* @since 1.5
*/
public String type() {
return type_;
}
/**
* Returns this dependency's {@code exclusions} for transitive resolution.
*
* @return the {@code exclusions} of this dependency
* @since 1.5
*/
public ExclusionSet exclusions() {
return exclusions_;
}
public HashSet<String> excludedClassifiers() {
return excludedClassifiers_;
}
/**
* Returns this dependency's {@code parent} dependency that created this
* dependency (only for information purposes).
*
* @return the {@code parent} of this dependency
* @since 1.5
*/
public Dependency parent() {
return parent_;
}
/**
* Indicates whether this dependency specifically is a classpath jar or not.
*
* @return {@code true} when this dependency specifically is a classpath jar; or {@code false} otherwise
* @since 2.1
*/
public boolean isClasspathJar() {
return Module.TYPE_CLASSPATH_JAR.equals(type_);
}
/**
* Indicates whether this dependency is a modular jar or not.
*
* @return {@code true} when this dependency is a modular jar; or {@code false} otherwise
* @since 2.1
*/
public boolean isModularJar() {
return Module.TYPE_MODULAR_JAR.equals(type_);
}
private static String normalizedJarType(String type) {
if (TYPE_JAR.equals(type) || TYPE_MODULAR_JAR.equals(type) || TYPE_CLASSPATH_JAR.equals(type)) {
return TYPE_JAR;
}
return type;
}
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (!(o instanceof Dependency that)) return false;
var that = (Dependency) o; return groupId_.equals(that.groupId_) &&
return groupId.equals(that.groupId) && artifactId_.equals(that.artifactId_) &&
artifactId.equals(that.artifactId) && classifier_.equals(that.classifier_) &&
classifier.equals(that.classifier) && normalizedJarType(type_).equals(normalizedJarType(that.type_));
type.equals(that.type);
} }
public int hashCode() { public int hashCode() {
return Objects.hash(groupId, artifactId, classifier, type); return Objects.hash(groupId_, artifactId_, classifier_, normalizedJarType(type_));
} }
} }

View file

@ -11,6 +11,8 @@ import java.io.*;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static rife.bld.dependencies.Dependency.*;
/** /**
* Resolves a dependency within a list of Maven-compatible repositories. * Resolves a dependency within a list of Maven-compatible repositories.
* *
@ -333,7 +335,7 @@ public class DependencyResolver {
result.append('-').append(dependency_.classifier()); result.append('-').append(dependency_.classifier());
} }
var type = dependency_.type(); var type = dependency_.type();
if (type == null) { if (type == null || TYPE_JAR.equals(type) || TYPE_MODULAR_JAR.equals(type) || TYPE_CLASSPATH_JAR.equals(type)) {
type = "jar"; type = "jar";
} }
result.append('.').append(type); result.append('.').append(type);

View file

@ -23,6 +23,7 @@ import java.util.*;
public class DependencySet extends AbstractSet<Dependency> implements Set<Dependency> { public class DependencySet extends AbstractSet<Dependency> implements Set<Dependency> {
private final Map<Dependency, Dependency> dependencies_ = new LinkedHashMap<>(); private final Map<Dependency, Dependency> dependencies_ = new LinkedHashMap<>();
private final Set<LocalDependency> localDependencies_ = new LinkedHashSet<>(); private final Set<LocalDependency> localDependencies_ = new LinkedHashSet<>();
private final Set<LocalModule> localModules_ = new LinkedHashSet<>();
/** /**
* Creates an empty dependency set. * Creates an empty dependency set.
@ -79,50 +80,94 @@ public class DependencySet extends AbstractSet<Dependency> implements Set<Depend
return localDependencies_; return localDependencies_;
} }
/**
* Includes a local module into the dependency set.
* <p>
* Local modules aren't resolved and point to a location on
* the file system.
*
* @param module the module to include
* @return this dependency set instance
* @since 2.1
*/
public DependencySet include(LocalModule module) {
localModules_.add(module);
return this;
}
/**
* Retrieves the local modules.
*
* @return the set of local modules
* @since 2.1
*/
public Set<LocalModule> localModules() {
return localModules_;
}
/** /**
* Transfers the artifacts for the dependencies into the provided directory. * Transfers the artifacts for the dependencies into the provided directory.
* <p> * <p>
* The destination directory must exist and be writable. * The destination directory must exist and be writable.
* *
* @param resolution the version resolution state that can be cached * @param resolution the version resolution state that can be cached
* @param retriever the retriever to use to get artifacts * @param retriever the retriever to use to get artifacts
* @param repositories the repositories to use for the transfer * @param repositories the repositories to use for the transfer
* @param directory the directory to transfer the artifacts into * @param directory the directory to transfer the artifacts into
* @param modulesDirectory the directory to download the modules into
* @return the list of artifacts that were transferred successfully * @return the list of artifacts that were transferred successfully
* @throws DependencyTransferException when an error occurred during the transfer * @throws DependencyTransferException when an error occurred during the transfer
* @since 2.0 * @since 2.1
*/ */
public List<RepositoryArtifact> transferIntoDirectory(VersionResolution resolution, ArtifactRetriever retriever, List<Repository> repositories, File directory) { public List<RepositoryArtifact> transferIntoDirectory(VersionResolution resolution, ArtifactRetriever retriever, List<Repository> repositories, File directory, File modulesDirectory) {
return transferIntoDirectory(resolution, retriever, repositories, directory, (String[]) null); return transferIntoDirectory(resolution, retriever, repositories, directory, modulesDirectory, (String[]) null);
} }
/** /**
* Transfers the artifacts for the dependencies into the provided directory, * Transfers the artifacts for the dependencies into the provided directories,
* including other classifiers. * including other classifiers.
* <p> * <p>
* The destination directory must exist and be writable. * The destination directory must exist and be writable.
* *
* @param resolution the version resolution state that can be cached * @param resolution the version resolution state that can be cached
* @param retriever the retriever to use to get artifacts * @param retriever the retriever to use to get artifacts
* @param repositories the repositories to use for the download * @param repositories the repositories to use for the download
* @param directory the directory to download the artifacts into * @param directory the directory to download the artifacts into
* @param classifiers the additional classifiers to transfer * @param modulesDirectory the directory to download the modules into
* @param classifiers the additional classifiers to transfer
* @return the list of artifacts that were transferred successfully * @return the list of artifacts that were transferred successfully
* @throws DependencyTransferException when an error occurred during the transfer * @throws DependencyTransferException when an error occurred during the transfer
* @since 2.0 * @since 2.1
*/ */
public List<RepositoryArtifact> transferIntoDirectory(VersionResolution resolution, ArtifactRetriever retriever, List<Repository> repositories, File directory, String... classifiers) { public List<RepositoryArtifact> transferIntoDirectory(VersionResolution resolution, ArtifactRetriever retriever, List<Repository> repositories, File directory, File modulesDirectory, String... classifiers) {
var result = new ArrayList<RepositoryArtifact>(); var result = new ArrayList<RepositoryArtifact>();
for (var dependency : this) { for (var dependency : this) {
var artifact = new DependencyResolver(resolution, retriever, repositories, dependency).transferIntoDirectory(directory); var transfer_directory = directory;
if (dependency.isModularJar()) {
if (modulesDirectory == null) {
throw new DependencyTransferException(dependency, "modules directory is not provided");
}
transfer_directory = modulesDirectory;
}
else if (directory == null) {
throw new DependencyTransferException(dependency, "artifacts directory is not provided");
}
if (!transfer_directory.exists()) {
if (!transfer_directory.mkdirs()) {
throw new DependencyTransferException(dependency, transfer_directory, "couldn't create directory");
}
}
var artifact = new DependencyResolver(resolution, retriever, repositories, dependency).transferIntoDirectory(transfer_directory);
if (artifact != null) { if (artifact != null) {
result.add(artifact); result.add(artifact);
} }
if (classifiers != null) { if (classifiers != null) {
for (var classifier : classifiers) { for (var classifier : classifiers) {
if (classifier != null) { if (classifier != null && !dependency.excludedClassifiers().contains(classifier)) {
var classifier_artifact = new DependencyResolver(resolution, retriever, repositories, dependency.withClassifier(classifier)).transferIntoDirectory(directory); var classifier_artifact = new DependencyResolver(resolution, retriever, repositories, dependency.withClassifier(classifier)).transferIntoDirectory(transfer_directory);
if (classifier_artifact != null) { if (classifier_artifact != null) {
result.add(classifier_artifact); result.add(classifier_artifact);
} }

View file

@ -0,0 +1,17 @@
/*
* Copyright 2001-2024 Geert Bevin (gbevin[remove] at uwyn dot com)
* Licensed under the Apache License, Version 2.0 (the "License")
*/
package rife.bld.dependencies;
/**
* Contains the information required to describe a local module for the build system.
* <p>
* If the local module points to a directory, it will be scanned for jar files.
*
* @param path the file system path of the local module
* @author Geert Bevin (gbevin[remove] at uwyn dot com)
* @since 2.1
*/
public record LocalModule(String path) {
}

View file

@ -0,0 +1,67 @@
/*
* Copyright 2001-2024 Geert Bevin (gbevin[remove] at uwyn dot com)
* Licensed under the Apache License, Version 2.0 (the "License")
*/
package rife.bld.dependencies;
import java.util.regex.Pattern;
/**
* Contains the information required to describe a Java module dependency in the build system.
*
* @author Geert Bevin (gbevin[remove] at uwyn dot com)
* @since 2.1
*/
public class Module extends Dependency {
public Module(String groupId, String artifactId) {
this(groupId, artifactId, null, null, null, null);
}
public Module(String groupId, String artifactId, Version version) {
this(groupId, artifactId, version, null, null, null);
}
public Module(String groupId, String artifactId, Version version, String classifier) {
this(groupId, artifactId, version, classifier, null, null);
}
public Module(String groupId, String artifactId, Version version, String classifier, ExclusionSet exclusions) {
this(groupId, artifactId, version, classifier, exclusions, null);
}
public Module(String groupId, String artifactId, Version version, String classifier, ExclusionSet exclusions, Dependency parent) {
super(groupId, artifactId, version, classifier, TYPE_MODULAR_JAR, exclusions, parent);
}
private static final Pattern MODULE_PATTERN = Pattern.compile("^(?<groupId>[^:@]+):(?<artifactId>[^:@]+)(?::(?<version>[^:@]+)(?::(?<classifier>[^:@]+))?)?(?:@modular-jar)?$");
/**
* Parses a module from a string representation.
* The format is {@code groupId:artifactId:version:classifier}.
* The {@code version} and {@code classifier} are optional.
* <p>
* If the string can't be successfully parsed, {@code null} will be returned.
*
* @param module the module string to parse
* @return a parsed instance of {@code Module}; or
* {@code null} when the string couldn't be parsed
* @since 2.1
*/
public static Module parse(String module) {
if (module == null || module.isEmpty()) {
return null;
}
var matcher = MODULE_PATTERN.matcher(module);
if (!matcher.matches()) {
return null;
}
var groupId = matcher.group("groupId");
var artifactId = matcher.group("artifactId");
var version = Version.parse(matcher.group("version"));
var classifier = matcher.group("classifier");
return new Module(groupId, artifactId, version, classifier);
}
}

View file

@ -32,6 +32,9 @@ public record Repository(String location, String username, String password) {
public static final Repository SONATYPE_RELEASES_LEGACY = new Repository("https://oss.sonatype.org/service/local/staging/deploy/maven2/"); public static final Repository SONATYPE_RELEASES_LEGACY = new Repository("https://oss.sonatype.org/service/local/staging/deploy/maven2/");
public static final Repository SONATYPE_SNAPSHOTS = new Repository("https://s01.oss.sonatype.org/content/repositories/snapshots/"); public static final Repository SONATYPE_SNAPSHOTS = new Repository("https://s01.oss.sonatype.org/content/repositories/snapshots/");
public static final Repository SONATYPE_SNAPSHOTS_LEGACY = new Repository("https://oss.sonatype.org/content/repositories/snapshots/"); public static final Repository SONATYPE_SNAPSHOTS_LEGACY = new Repository("https://oss.sonatype.org/content/repositories/snapshots/");
public static final String OSSRH_STAGING_API_DOMAIN = "ossrh-staging-api.central.sonatype.com";
public static final Repository CENTRAL_RELEASES = new Repository("https://" + OSSRH_STAGING_API_DOMAIN + "/service/local/staging/deploy/maven2/");
public static final Repository CENTRAL_SNAPSHOTS = new Repository("https://central.sonatype.com/repository/maven-snapshots/");
public static final Repository RIFE2_RELEASES = new Repository("https://repo.rife2.com/releases/"); public static final Repository RIFE2_RELEASES = new Repository("https://repo.rife2.com/releases/");
public static final Repository RIFE2_SNAPSHOTS = new Repository("https://repo.rife2.com/snapshots/"); public static final Repository RIFE2_SNAPSHOTS = new Repository("https://repo.rife2.com/snapshots/");
@ -98,6 +101,8 @@ public record Repository(String location, String username, String password) {
case "SONATYPE_RELEASES_LEGACY" -> Repository.SONATYPE_RELEASES_LEGACY; case "SONATYPE_RELEASES_LEGACY" -> Repository.SONATYPE_RELEASES_LEGACY;
case "SONATYPE_SNAPSHOTS" -> Repository.SONATYPE_SNAPSHOTS; case "SONATYPE_SNAPSHOTS" -> Repository.SONATYPE_SNAPSHOTS;
case "SONATYPE_SNAPSHOTS_LEGACY" -> Repository.SONATYPE_SNAPSHOTS_LEGACY; case "SONATYPE_SNAPSHOTS_LEGACY" -> Repository.SONATYPE_SNAPSHOTS_LEGACY;
case "CENTRAL_RELEASES" -> Repository.CENTRAL_RELEASES;
case "CENTRAL_SNAPSHOTS" -> Repository.CENTRAL_SNAPSHOTS;
default -> new Repository(locationOrName); default -> new Repository(locationOrName);
}; };
} }

View file

@ -10,6 +10,8 @@ import rife.xml.Xml2Data;
import java.util.*; import java.util.*;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static rife.bld.dependencies.Dependency.TYPE_JAR;
/** /**
* Parses an XML document to retrieve POM information, this is an internal class. * Parses an XML document to retrieve POM information, this is an internal class.
* *
@ -103,7 +105,7 @@ class Xml2MavenPom extends Xml2Data {
"false", "false",
exclusions, exclusions,
dependency.parent()); dependency.parent());
if (resolved_dependency.type() == null || resolved_dependency.type().equals("jar")) { if (resolved_dependency.type() == null || TYPE_JAR.equals(resolved_dependency.type())) {
var scope = Scope.valueOf(resolved_dependency.scope()); var scope = Scope.valueOf(resolved_dependency.scope());
if (scopes_list.contains(scope)) { if (scopes_list.contains(scope)) {
var resolved_dependency_set = resolved_dependencies.computeIfAbsent(scope, k -> new LinkedHashSet<>()); var resolved_dependency_set = resolved_dependencies.computeIfAbsent(scope, k -> new LinkedHashSet<>());
@ -248,6 +250,9 @@ class Xml2MavenPom extends Xml2Data {
if (isChildOfProject()) { if (isChildOfProject()) {
addProjectProperty(qName); addProjectProperty(qName);
} else if (isChildOfParent() || isChildOfDependency()) { } else if (isChildOfParent() || isChildOfDependency()) {
if (isChildOfProjectParent()) {
addProjectParentProperty(qName);
}
lastGroupId_ = getCharacterData(); lastGroupId_ = getCharacterData();
} else if (collectExclusions_ && isChildOfExclusion()) { } else if (collectExclusions_ && isChildOfExclusion()) {
lastExclusionGroupId_ = getCharacterData(); lastExclusionGroupId_ = getCharacterData();
@ -257,6 +262,9 @@ class Xml2MavenPom extends Xml2Data {
if (isChildOfProject()) { if (isChildOfProject()) {
addProjectProperty(qName); addProjectProperty(qName);
} else if (isChildOfParent() || isChildOfDependency()) { } else if (isChildOfParent() || isChildOfDependency()) {
if (isChildOfProjectParent()) {
addProjectParentProperty(qName);
}
lastArtifactId_ = getCharacterData(); lastArtifactId_ = getCharacterData();
} else if (collectExclusions_ && isChildOfExclusion()) { } else if (collectExclusions_ && isChildOfExclusion()) {
lastExclusionArtifactId_ = getCharacterData(); lastExclusionArtifactId_ = getCharacterData();
@ -267,6 +275,9 @@ class Xml2MavenPom extends Xml2Data {
addProjectProperty(qName); addProjectProperty(qName);
} else if (isChildOfParent() || isChildOfDependency()) { } else if (isChildOfParent() || isChildOfDependency()) {
lastVersion_ = getCharacterData(); lastVersion_ = getCharacterData();
if (isChildOfProjectParent()) {
addProjectParentProperty(qName);
}
} }
} }
case "type" -> { case "type" -> {
@ -304,6 +315,13 @@ class Xml2MavenPom extends Xml2Data {
return "project".equals(elementStack_.peek()); return "project".equals(elementStack_.peek());
} }
private boolean isChildOfProjectParent() {
if (elementStack_.size() < 2) {
return false;
}
return "parent".equals(elementStack_.peek()) && "project".equals(elementStack_.elementAt(elementStack_.size() - 2));
}
private boolean isChildOfParent() { private boolean isChildOfParent() {
return "parent".equals(elementStack_.peek()); return "parent".equals(elementStack_.peek());
} }
@ -320,6 +338,10 @@ class Xml2MavenPom extends Xml2Data {
mavenProperties_.put("project." + name, getCharacterData()); mavenProperties_.put("project." + name, getCharacterData());
} }
private void addProjectParentProperty(String name) {
mavenProperties_.put("project.parent." + name, getCharacterData());
}
private String getCharacterData() { private String getCharacterData() {
if (characterData_ == null) { if (characterData_ == null) {
return null; return null;

View file

@ -24,6 +24,22 @@ public class DependencyTransferException extends DependencyException {
destination_ = destination; destination_ = destination;
} }
public DependencyTransferException(Dependency dependency, File destination, String message) {
super("Unable to transfer dependency '" + dependency + "' into '" + destination + "': " + message);
dependency_ = dependency;
location_ = null;
destination_ = destination;
}
public DependencyTransferException(Dependency dependency, String message) {
super("Unable to transfer dependency '" + dependency + "': " + message);
dependency_ = dependency;
location_ = null;
destination_ = null;
}
public Dependency getDependency() { public Dependency getDependency() {
return dependency_; return dependency_;
} }

View file

@ -21,9 +21,10 @@ public class CreateAppHelp implements CommandHelp {
public String getDescription(String topic) { public String getDescription(String topic) {
return StringUtils.replace(""" return StringUtils.replace("""
Creates a new Java application project. Creates a new Java application project.
Usage : ${topic} <package> <name> Usage : ${topic} <package> <name> <base>
package The package of the project to create package The package of the project to create
name The name of the project to create""", "${topic}", topic); name The name of the project to create
base The base name for generated project classes""", "${topic}", topic);
} }
} }

View file

@ -21,9 +21,10 @@ public class CreateBaseHelp implements CommandHelp {
public String getDescription(String topic) { public String getDescription(String topic) {
return StringUtils.replace(""" return StringUtils.replace("""
Creates a new Java baseline project. Creates a new Java baseline project.
Usage : ${topic} <package> <name> Usage : ${topic} <package> <name> <base>
package The package of the project to create package The package of the project to create
name The name of the project to create""", "${topic}", topic); name The name of the project to create
base The base name for generated project classes""", "${topic}", topic);
} }
} }

View file

@ -21,10 +21,11 @@ public class CreateHelp implements CommandHelp {
public String getDescription(String topic) { public String getDescription(String topic) {
return StringUtils.replace(""" return StringUtils.replace("""
Creates a new project from multiple choice. Creates a new project from multiple choice.
Usage : ${topic} <type> <package> <name> Usage : ${topic} <type> <package> <name> <base>
type The type of project to create (app, base, lib, rife2) type The type of project to create (app, base, lib, rife2)
package The package of the project to create package The package of the project to create
name The name of the project to create""", "${topic}", topic); name The name of the project to create
base The base name for generated project classes""", "${topic}", topic);
} }
} }

View file

@ -21,9 +21,10 @@ public class CreateLibHelp implements CommandHelp {
public String getDescription(String topic) { public String getDescription(String topic) {
return StringUtils.replace(""" return StringUtils.replace("""
Creates a new Java library project. Creates a new Java library project.
Usage : ${topic} <package> <name> Usage : ${topic} <package> <name> <base>
package The package of the project to create package The package of the project to create
name The name of the project to create""", "${topic}", topic); name The name of the project to create
base The base name for generated project classes""", "${topic}", topic);
} }
} }

View file

@ -21,9 +21,10 @@ public class CreateRife2Help implements CommandHelp {
public String getDescription(String topic) { public String getDescription(String topic) {
return StringUtils.replace(""" return StringUtils.replace("""
Creates a new RIFE2 web application project. Creates a new RIFE2 web application project.
Usage : ${topic} <package> <name> Usage : ${topic} <package> <name> <base>
package The package of the project to create package The package of the project to create
name The name of the project to create""", "${topic}", topic); name The name of the project to create
base The base name for generated project classes""", "${topic}", topic);
} }
} }

View file

@ -0,0 +1,44 @@
/*
* Copyright 2001-2024 Geert Bevin (gbevin[remove] at uwyn dot com)
* Licensed under the Apache License, Version 2.0 (the "License")
*/
package rife.bld.instrument;
import rife.asm.*;
/**
* This utility class will modify a Java module {@code module-info.class} to add
* a module main class to its attributes.
*
* @author Geert Bevin (gbevin[remove] at uwyn dot com)
* @since 2.1
*/
public class ModuleMainClassAdapter extends ClassVisitor implements Opcodes {
private final String mainClass_;
/**
* Performs the actual modification of the module info class's bytecode.
*
* @param origBytes the bytes of the module class that should be modified
* @param mainClass the main class of the module
* @return the modified bytes
* @since 2.1
*/
public static byte[] addModuleMainClassToBytes(byte[] origBytes, String mainClass) {
var cw = new ClassWriter(0);
new ClassReader(origBytes).accept(new ModuleMainClassAdapter(mainClass, cw), 0);
return cw.toByteArray();
}
private ModuleMainClassAdapter(String mainClass, ClassVisitor writer) {
super(ASM9, writer);
mainClass_ = mainClass.replace('.', '/');
}
@Override
public ModuleVisitor visitModule(String name, int access, String version) {
var module_visitor = super.visitModule(name, access, version);
module_visitor.visitMainClass(mainClass_);
return module_visitor;
}
}

View file

@ -0,0 +1,10 @@
/*
* Copyright 2001-2024 Geert Bevin (gbevin[remove] at uwyn dot com)
* Licensed under the Apache License, Version 2.0 (the "License")
*/
/**
* Provides functionalities for bytecode instrumentation.
* @since 2.1
*/
package rife.bld.instrument;

View file

@ -26,16 +26,17 @@ import java.util.List;
* @since 1.5 * @since 1.5
*/ */
public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<T, P>, P extends Project> extends AbstractOperation<AbstractCreateOperation<T, P>> { public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<T, P>, P extends Project> extends AbstractOperation<AbstractCreateOperation<T, P>> {
private String packageName_;
private String projectName_;
private String baseName_;
final String templateBase_; final String templateBase_;
File workDirectory_ = new File(System.getProperty("user.dir")); File workDirectory_ = new File(System.getProperty("user.dir"));
String packageName_;
String projectName_;
boolean downloadDependencies_; boolean downloadDependencies_;
P project_; P project_;
String projectClassName_;
String projectBuildName_; String projectBuildName_;
String projectMainName_; String projectMainName_;
String projectMainUberName_; String projectMainUberName_;
@ -97,11 +98,11 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
project_ = createProjectBlueprint(); project_ = createProjectBlueprint();
// standard names // standard names
projectClassName_ = StringUtils.capitalize(project_.name()); var base_name = baseName();
projectBuildName_ = projectBuildClassName(projectClassName_); projectBuildName_ = projectBuildClassName(base_name);
projectMainName_ = projectMainClassName(projectClassName_); projectMainName_ = projectMainClassName(base_name);
projectMainUberName_ = projectMainUberClassName(projectClassName_); projectMainUberName_ = projectMainUberClassName(base_name);
projectTestName_ = projectTestClassName(projectClassName_); projectTestName_ = projectTestClassName(base_name);
// create the main project structure // create the main project structure
ideaDirectory_ = new File(project_.workDirectory(), ".idea"); ideaDirectory_ = new File(project_.workDirectory(), ".idea");
@ -132,7 +133,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
* @since 1.6 * @since 1.6
*/ */
protected String projectMainClassName(String projectClassName) { protected String projectMainClassName(String projectClassName) {
return projectClassName + "Main"; return projectClassName;
} }
/** /**
@ -142,7 +143,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
* @since 1.6 * @since 1.6
*/ */
protected String projectMainUberClassName(String projectClassName) { protected String projectMainUberClassName(String projectClassName) {
return projectClassName + "Main"; return projectClassName;
} }
/** /**
@ -199,7 +200,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
test_template.setValue("projectTest", projectTestName_); test_template.setValue("projectTest", projectTestName_);
test_template.setValue("projectMain", projectMainName_); test_template.setValue("projectMain", projectMainName_);
if (test_template.hasValueId("project")) { if (test_template.hasValueId("project")) {
test_template.setValue("project", projectClassName_); test_template.setValue("project", project_.name());
} }
var project_test_file = new File(testPackageDirectory_, projectTestName_ + ".java"); var project_test_file = new File(testPackageDirectory_, projectTestName_ + ".java");
FileUtils.writeString(test_template.getContent(), project_test_file); FileUtils.writeString(test_template.getContent(), project_test_file);
@ -211,7 +212,7 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
build_template.setValue("package", project_.pkg()); build_template.setValue("package", project_.pkg());
} }
if (build_template.hasValueId("project")) { if (build_template.hasValueId("project")) {
build_template.setValue("project", projectClassName_); build_template.setValue("project", project_.name());
} }
if (build_template.hasValueId("projectMain")) { if (build_template.hasValueId("projectMain")) {
build_template.setValue("projectMain", projectMainName_); build_template.setValue("projectMain", projectMainName_);
@ -375,32 +376,62 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
public T fromArguments(List<String> arguments) { public T fromArguments(List<String> arguments) {
String package_name = null; String package_name = null;
String project_name = null; String project_name = null;
String base_name = null;
if (!arguments.isEmpty()) { if (!arguments.isEmpty()) {
package_name = arguments.remove(0); package_name = arguments.remove(0);
} }
if (!arguments.isEmpty()) { if (!arguments.isEmpty()) {
project_name = arguments.remove(0); project_name = arguments.remove(0);
} }
if ((package_name == null || project_name == null) && System.console() == null) { if (!arguments.isEmpty()) {
throw new OperationOptionException("ERROR: Expecting the package and project names as the arguments."); base_name = arguments.remove(0);
}
if ((package_name == null || project_name == null || base_name == null) && System.console() == null) {
throw new OperationOptionException("ERROR: Expecting the package, project and base names as the arguments.");
} }
if (package_name == null || package_name.isEmpty()) { if (package_name == null || package_name.isBlank()) {
System.out.println("Please enter a package name (for instance: com.example):"); System.out.println("Please enter a package name (for instance: com.example):");
package_name = System.console().readLine(); package_name = System.console().readLine();
if (package_name == null || package_name.isBlank()) {
throw new OperationOptionException("ERROR: package name is required.");
}
} else { } else {
System.out.println("Using package name: " + package_name); System.out.println("Using package name: " + package_name);
} }
if (project_name == null || project_name.isEmpty()) { if (!ValidityChecks.checkJavaPackage(package_name)) {
System.out.println("Please enter a project name (for instance: myapp):"); throw new OperationOptionException("ERROR: package name is invalid.");
}
if (project_name == null || project_name.isBlank()) {
System.out.println("Please enter a project name (for instance: my-app):");
project_name = System.console().readLine(); project_name = System.console().readLine();
if (project_name == null || project_name.isBlank()) {
throw new OperationOptionException("ERROR: project name is required.");
}
} else { } else {
System.out.println("Using project name: " + project_name); System.out.println("Using project name: " + project_name);
} }
if (base_name == null || base_name.isBlank()) {
var default_base_name = generateBaseName(project_name);
System.out.println("Please enter the base name for generated project classes (default: " + default_base_name + "):");
base_name = System.console().readLine();
if (base_name == null || base_name.isBlank()) {
base_name = default_base_name;
System.out.println("Using base name: " + base_name);
}
} else {
System.out.println("Using base name: " + base_name);
}
if (!ValidityChecks.checkJavaIdentifier(base_name)) {
throw new OperationOptionException("ERROR: base name is invalid.");
}
return workDirectory(new File(System.getProperty("user.dir"))) return workDirectory(new File(System.getProperty("user.dir")))
.packageName(package_name) .packageName(package_name)
.projectName(project_name) .projectName(project_name)
.baseName(base_name)
.downloadDependencies(true); .downloadDependencies(true);
} }
@ -445,7 +476,6 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
throw new OperationOptionException("ERROR: The package name is invalid."); throw new OperationOptionException("ERROR: The package name is invalid.");
} }
packageName_ = name;
return (T) this; return (T) this;
} }
@ -462,10 +492,26 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
throw new OperationOptionException("ERROR: The project name should not be blank."); throw new OperationOptionException("ERROR: The project name should not be blank.");
} }
if (!ValidityChecks.checkJavaIdentifier(projectName_)) { return (T) this;
throw new OperationOptionException("ERROR: The project name is invalid."); }
/**
* Provides the base name for the project classes to generate.
*
* @param name the base name
* @return this operation instance
* @since 2.2
*/
public T baseName(String name) {
baseName_ = StringUtils.trim(name);
if (baseName_.isEmpty()) {
throw new OperationOptionException("ERROR: The base name should not be blank.");
} }
projectName_ = name;
if (!ValidityChecks.checkJavaIdentifier(baseName_)) {
throw new OperationOptionException("ERROR: The base name is invalid.");
}
return (T) this; return (T) this;
} }
@ -513,6 +559,30 @@ public abstract class AbstractCreateOperation<T extends AbstractCreateOperation<
return projectName_; return projectName_;
} }
static String generateBaseName(String projectName) {
if (projectName != null) {
return StringUtils.filterAsIdentifier(projectName.trim(), true);
}
return null;
}
/**
* Retrieves the base name for the project classes to generate.
* <p>
* If no base name was provided, one will be generated from the project name.
*
* @return the base name
* @since 2.2
*/
public String baseName() {
if (baseName_ == null || baseName_.isEmpty()) {
return generateBaseName(projectName());
}
return baseName_;
}
/** /**
* Retrieves whether dependencies will be downloaded at project creation. * Retrieves whether dependencies will be downloaded at project creation.
* *

View file

@ -10,8 +10,7 @@ import rife.bld.operations.exceptions.OperationOptionException;
import rife.tools.exceptions.FileUtilsErrorException; import rife.tools.exceptions.FileUtilsErrorException;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.function.Function; import java.util.function.Function;
/** /**
@ -24,10 +23,13 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
public static final String DEFAULT_JAVA_TOOL = "java"; public static final String DEFAULT_JAVA_TOOL = "java";
protected File workDirectory_ = new File(System.getProperty("user.dir")); protected File workDirectory_ = new File(System.getProperty("user.dir"));
protected final Map<String, String> environment_ = new HashMap<>();
protected String javaTool_ = DEFAULT_JAVA_TOOL; protected String javaTool_ = DEFAULT_JAVA_TOOL;
protected final JavaOptions javaOptions_ = new JavaOptions(); protected final JavaOptions javaOptions_ = new JavaOptions();
protected final List<String> classpath_ = new ArrayList<>(); protected final List<String> classpath_ = new ArrayList<>();
protected final List<String> modulePath_ = new ArrayList<>();
protected String mainClass_; protected String mainClass_;
protected String module_;
protected Function<String, Boolean> outputProcessor_; protected Function<String, Boolean> outputProcessor_;
protected Function<String, Boolean> errorProcessor_; protected Function<String, Boolean> errorProcessor_;
protected Process process_; protected Process process_;
@ -85,6 +87,10 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
var builder = new ProcessBuilder(executeConstructProcessCommandList()); var builder = new ProcessBuilder(executeConstructProcessCommandList());
builder.directory(workDirectory()); builder.directory(workDirectory());
if (!environment_.isEmpty()) {
builder.environment().putAll(environment_);
}
builder.redirectInput(ProcessBuilder.Redirect.INHERIT); builder.redirectInput(ProcessBuilder.Redirect.INHERIT);
final var output_processor = outputProcessor(); final var output_processor = outputProcessor();
@ -161,6 +167,31 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
return (T) this; return (T) this;
} }
/**
* Provides an environment variable to use for the operation.
*
* @param name the name of the environment variable
* @param value the value of the environment variable
* @return this operation instance
* @since 2.2.1
*/
public T environment(String name, String value) {
environment_.put(name, value);
return (T) this;
}
/**
* Provides environment variable entries to use for the operation.
*
* @param environment environment entries for the operation
* @return this operation instance
* @since 2.2.1
*/
public T environment(Map<String, String> environment) {
environment_.putAll(environment);
return (T) this;
}
/** /**
* Provides the name of the tool to use for {@code java} execution. * Provides the name of the tool to use for {@code java} execution.
* <p> * <p>
@ -199,6 +230,18 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
return (T) this; return (T) this;
} }
/**
* Provides classpath entries to use for the operation.
*
* @param classpath classpath entries for the operation
* @return this operation instance
* @since 2.3.1
*
*/
public T classpath(File... classpath) {
return classpath(List.of(classpath));
}
/** /**
* Provides a list of classpath entries to use for the operation. * Provides a list of classpath entries to use for the operation.
* <p> * <p>
@ -213,6 +256,71 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
return (T) this; return (T) this;
} }
/**
* Provides a list of classpath entries to use for the operation.
* <p>
* A copy will be created to allow this list to be independently modifiable.
*
* @param classpath a list of classpath entries for the operation
* @return this operation instance
* @since 2.3.1
*/
public T classpath(Collection<File> classpath) {
classpath_.addAll(classpath.stream().map(File::getAbsolutePath).toList());
return (T) this;
}
/**
* Provides module path entries to use for the operation.
*
* @param modulePath module path entries for the operation
* @return this operation instance
* @since 2.1
*/
public T modulePath(String... modulePath) {
modulePath_.addAll(List.of(modulePath));
return (T) this;
}
/**
* Provides module path entries to use for the operation.
*
* @param modulePath module path entries for the operation
* @return this operation instance
* @since 2.3.1
*/
public T modulePath(File... modulePath) {
return modulePath(List.of(modulePath));
}
/**
* Provides a list of module path entries to use for the operation.
* <p>
* A copy will be created to allow this list to be independently modifiable.
*
* @param modulePath a list of module path entries for the operation
* @return this operation instance
* @since 2.1
*/
public T modulePath(List<String> modulePath) {
modulePath_.addAll(modulePath);
return (T) this;
}
/**
* Provides a list of module path entries to use for the operation.
* <p>
* A copy will be created to allow this list to be independently modifiable.
*
* @param modulePath a list of module path entries for the operation
* @return this operation instance
* @since 2.3.1
*/
public T modulePath(Collection<File> modulePath) {
modulePath_.addAll(modulePath.stream().map(File::getAbsolutePath).toList());
return (T) this;
}
/** /**
* Provides the main class to launch with the java tool. * Provides the main class to launch with the java tool.
* *
@ -225,6 +333,18 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
return (T) this; return (T) this;
} }
/**
* Provides the module to launch with the java tool.
*
* @param name the module to launch
* @return this operation instance
* @since 2.1
*/
public T module(String name) {
module_ = name;
return (T) this;
}
/** /**
* Provides the processor that will be used to handle the process output. * Provides the processor that will be used to handle the process output.
* <p> * <p>
@ -263,6 +383,18 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
return workDirectory_; return workDirectory_;
} }
/**
* Retrieves the environment to use for the operation.
* <p>
* This is a modifiable map that can be retrieved and changed.
*
* @return the operation's environment
* @since 2.2.1
*/
public Map<String, String> environment() {
return environment_;
}
/** /**
* retrieves the name of the tool to use for {@code java} execution. * retrieves the name of the tool to use for {@code java} execution.
* *
@ -297,6 +429,18 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
return classpath_; return classpath_;
} }
/**
* Retrieves the module path to use for the operation.
* <p>
* This is a modifiable list that can be retrieved and changed.
*
* @return the operation's module path
* @since 2.1
*/
public List<String> modulePath() {
return modulePath_;
}
/** /**
* Retrieves the main class to launch with the java tool. * Retrieves the main class to launch with the java tool.
* *
@ -307,6 +451,16 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
return mainClass_; return mainClass_;
} }
/**
* Retrieves the module to launch with the java tool.
*
* @return the module to launch
* @since 2.1
*/
public String module() {
return module_;
}
/** /**
* Retrieves the processor that is used to handle the process output. * Retrieves the processor that is used to handle the process output.
* *

View file

@ -0,0 +1,283 @@
/*
* Copyright 2024 Erik C. Thauvin (https://erik.thauvin.net/)
* Licensed under the Apache License, Version 2.0 (the "License")
*/
package rife.bld.operations;
import rife.bld.operations.exceptions.ExitStatusException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.spi.ToolProvider;
/**
* Provides common features for tool providers.
*
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @since 2.1.0
*/
public abstract class AbstractToolProviderOperation<T extends AbstractToolProviderOperation<T>>
extends AbstractOperation<AbstractToolProviderOperation<T>> {
private final List<String> cmdFiles_ = new ArrayList<>();
private final List<String> toolArgs_ = new ArrayList<>();
private final String toolName_;
/**
* Provides the name of the tool.
*
* @param toolName the tool name
*/
public AbstractToolProviderOperation(String toolName) {
toolName_ = toolName;
}
/**
* Read options and/or mode from file(s).
*
* @param files one or more files
* @return this operation instance
*/
public T cmdFiles(String... files) {
return cmdFilesStrings(List.of(files));
}
/**
* Read options and/or mode from file(s).
*
* @param files one or more files
* @return this operation instance
*/
@SuppressWarnings({"unchecked"})
public T cmdFiles(List<File> files) {
cmdFiles_.addAll(files.stream().map(File::getAbsolutePath).toList());
return (T) this;
}
/**
* Read options and/or mode from file(s).
*
* @param files one or more files
* @return this operation instance
*/
public T cmdFiles(File... files) {
return cmdFiles(List.of(files));
}
/**
* Read options and/or mode from file(s).
*
* @param files one or more files
* @return this operation instance
*/
public T cmdFiles(Path... files) {
return cmdFilesPaths(List.of(files));
}
/**
* Retrieves the list of files containing options or mode.
*
* @return the list of files
*/
public List<String> cmdFiles() {
return cmdFiles_;
}
/**
* Read options and/or mode from file(s).
*
* @param files one or more files
* @return this operation instance
*/
public T cmdFilesPaths(List<Path> files) {
return cmdFilesStrings(files.stream().map(Path::toFile).map(File::getAbsolutePath).toList());
}
/**
* Read options and/or mode from file(s).
*
* @param files one or more files
* @return this operation instance
*/
@SuppressWarnings({"unchecked"})
public T cmdFilesStrings(List<String> files) {
cmdFiles_.addAll(files);
return (T) this;
}
/**
* Runs an instance of the tool.
* <p>
* On success, command line arguments are automatically cleared.
*
* @throws Exception if an error occurred
*/
@Override
public void execute() throws Exception {
if (toolArgs_.isEmpty()) {
System.err.println("No " + toolName_ + " command line arguments specified.");
throw new ExitStatusException(ExitStatusException.EXIT_FAILURE);
}
var tool = ToolProvider.findFirst(toolName_).orElseThrow(() ->
new IllegalStateException("No " + toolName_ + " tool found."));
var status = tool.run(System.out, System.err, toolArgs_.toArray(new String[0]));
if (status != 0) {
System.out.println(tool.name() + ' ' + String.join(" ", toolArgs_));
}
ExitStatusException.throwOnFailure(status);
toolArgs_.clear();
}
/**
* Adds arguments to pass to the tool.
*
* @param args tbe list of arguments
* @return this operation
*/
@SuppressWarnings({"unchecked"})
public T toolArgs(List<String> args) {
toolArgs_.addAll(args);
return (T) this;
}
/**
* Adds arguments to pass to the tool.
*
* @param args one or more arguments
* @return this operation
*/
public T toolArgs(String... args) {
return toolArgs(List.of(args));
}
/**
* Returns the tool's arguments.
*
* @return the arguments
*/
public List<String> toolArgs() {
return toolArgs_;
}
/**
* Parses arguments to pass to the tool from the {@link #cmdFiles() command files}.
*
* @throws FileNotFoundException if a file cannot be found
*/
protected void toolArgsFromFiles() throws IOException {
for (var file : cmdFiles_) {
try (var reader = Files.newBufferedReader(Paths.get(file), Charset.defaultCharset())) {
var tokenizer = new CommandLineTokenizer(reader);
String token;
while ((token = tokenizer.nextToken()) != null) {
toolArgs_.add(token);
}
}
}
}
/**
* Adds arguments to pass to the tool.
*
* @param args the argument-value pairs to add
* @return this operation
*/
@SuppressWarnings({"unchecked", "UnusedReturnValue"})
protected T toolArgs(Map<String, String> args) {
args.forEach((k, v) -> {
toolArgs_.add(k);
if (v != null && !v.isEmpty()) {
toolArgs_.add(v);
}
});
return (T) this;
}
/**
* Tokenize command line arguments.
*
* <ul>
* <li>Arguments containing spaces should be quoted</li>
* <li>Escape sequences and comments are supported</li>
* </ul>
*/
public static class CommandLineTokenizer {
private final StringBuilder buf_ = new StringBuilder();
private final Reader input_;
private int ch_;
public CommandLineTokenizer(Reader input) throws IOException {
input_ = input;
ch_ = input.read();
}
public String nextToken() throws IOException {
trimWhitespaceOrComments();
if (ch_ == -1) {
return null;
}
buf_.setLength(0); // reset buffer
char quote = 0;
while (ch_ != -1) {
if (ch_ == '\'' || ch_ == '"') { // quotes
if (quote == 0) { // begin quote
quote = (char) ch_;
} else if (quote == ch_) { // end quote
quote = 0;
} else {
buf_.append((char) ch_);
}
} else if (ch_ == '\\') { // escaped
ch_ = input_.read();
buf_.append(handleEscapeSequence());
} else if (quote == 0 && Character.isWhitespace(ch_)) { // whitespaces
break;
} else {
buf_.append((char) ch_);
}
ch_ = input_.read();
}
return buf_.toString();
}
private char handleEscapeSequence() {
return switch (ch_) {
case -1 -> '\\';
case 'n' -> '\n';
case 'r' -> '\r';
case 't' -> '\t';
case 'f' -> '\f';
default -> (char) ch_;
};
}
private void trimWhitespaceOrComments() throws IOException {
while (ch_ != -1) {
if (Character.isWhitespace(ch_)) { // Skip whitespaces
ch_ = input_.read();
} else if (ch_ == '#') {
// Skip the entire comment until a new line or end of input
do {
ch_ = input_.read();
} while (ch_ != -1 && ch_ != '\n' && ch_ != '\r');
} else {
break;
}
}
}
}
}

View file

@ -5,6 +5,7 @@
package rife.bld.operations; package rife.bld.operations;
import rife.bld.BaseProject; import rife.bld.BaseProject;
import rife.bld.instrument.ModuleMainClassAdapter;
import rife.bld.operations.exceptions.ExitStatusException; import rife.bld.operations.exceptions.ExitStatusException;
import rife.tools.FileUtils; import rife.tools.FileUtils;
@ -22,16 +23,26 @@ import java.util.List;
* @since 1.5 * @since 1.5
*/ */
public class CompileOperation extends AbstractOperation<CompileOperation> { public class CompileOperation extends AbstractOperation<CompileOperation> {
static final String COMPILE_OPTION_D = "-d";
static final String COMPILE_OPTION_CP = "-cp";
static final String COMPILE_OPTION_CLASS_PATH = "--class-path";
static final String COMPILE_OPTION_CLASSPATH = "--classpath";
static final String COMPILE_OPTION_P = "-p";
static final String COMPILE_OPTION_MODULE_PATH = "--module-path";
private File buildMainDirectory_; private File buildMainDirectory_;
private File buildTestDirectory_; private File buildTestDirectory_;
private final List<String> compileMainClasspath_ = new ArrayList<>(); private final List<String> compileMainClasspath_ = new ArrayList<>();
private final List<String> compileTestClasspath_ = new ArrayList<>(); private final List<String> compileTestClasspath_ = new ArrayList<>();
private final List<String> compileMainModulePath_ = new ArrayList<>();
private final List<String> compileTestModulePath_ = new ArrayList<>();
private final List<File> mainSourceFiles_ = new ArrayList<>(); private final List<File> mainSourceFiles_ = new ArrayList<>();
private final List<File> testSourceFiles_ = new ArrayList<>(); private final List<File> testSourceFiles_ = new ArrayList<>();
private final List<File> mainSourceDirectories_ = new ArrayList<>(); private final List<File> mainSourceDirectories_ = new ArrayList<>();
private final List<File> testSourceDirectories_ = new ArrayList<>(); private final List<File> testSourceDirectories_ = new ArrayList<>();
private final JavacOptions compileOptions_ = new JavacOptions(); private final JavacOptions compileOptions_ = new JavacOptions();
private final List<Diagnostic<? extends JavaFileObject>> diagnostics_ = new ArrayList<>(); private final List<Diagnostic<? extends JavaFileObject>> diagnostics_ = new ArrayList<>();
private String moduleMainClass_;
/** /**
* Performs the compile operation. * Performs the compile operation.
@ -76,10 +87,18 @@ public class CompileOperation extends AbstractOperation<CompileOperation> {
for (var directory : mainSourceDirectories()) { for (var directory : mainSourceDirectories()) {
sources.addAll(FileUtils.getJavaFileList(directory)); sources.addAll(FileUtils.getJavaFileList(directory));
} }
executeBuildSources(
compileMainClasspath(), if (sources.isEmpty()) {
sources, if (!silent()) {
buildMainDirectory()); System.err.println("No main source files found.");
}
} else {
executeBuildSources(
compileMainClasspath(),
compileMainModulePath(),
sources,
buildMainDirectory());
}
} }
/** /**
@ -93,21 +112,30 @@ public class CompileOperation extends AbstractOperation<CompileOperation> {
for (var directory : testSourceDirectories()) { for (var directory : testSourceDirectories()) {
sources.addAll(FileUtils.getJavaFileList(directory)); sources.addAll(FileUtils.getJavaFileList(directory));
} }
executeBuildSources(
compileTestClasspath(), if (sources.isEmpty()) {
sources, if (!silent()) {
buildTestDirectory()); System.err.println("No test source files found.");
}
} else {
executeBuildSources(
compileTestClasspath(),
compileTestModulePath(),
sources,
buildTestDirectory());
}
} }
/** /**
* Part of the {@link #execute} operation, build sources to a destination. * Part of the {@link #execute} operation, build sources to a destination.
* *
* @param classpath the classpath list used for the compilation * @param classpath the classpath list used for the compilation
* @param modulePath the module path list used for the compilation
* @param sources the source files to compile * @param sources the source files to compile
* @param destination the destination directory * @param destination the destination directory
* @since 1.5 * @since 2.1
*/ */
protected void executeBuildSources(List<String> classpath, List<File> sources, File destination) protected void executeBuildSources(List<String> classpath, List<String> modulePath, List<File> sources, File destination)
throws IOException { throws IOException {
if (sources.isEmpty() || destination == null) { if (sources.isEmpty() || destination == null) {
return; return;
@ -117,16 +145,52 @@ public class CompileOperation extends AbstractOperation<CompileOperation> {
try (var file_manager = compiler.getStandardFileManager(null, null, null)) { try (var file_manager = compiler.getStandardFileManager(null, null, null)) {
var compilation_units = file_manager.getJavaFileObjectsFromFiles(sources); var compilation_units = file_manager.getJavaFileObjectsFromFiles(sources);
var diagnostics = new DiagnosticCollector<JavaFileObject>(); var diagnostics = new DiagnosticCollector<JavaFileObject>();
var options = new ArrayList<>(List.of("-d", destination.getAbsolutePath(), "-cp", FileUtils.joinPaths(classpath))); var options = new ArrayList<>(List.of(COMPILE_OPTION_D, destination.getAbsolutePath()));
if (!classpath.isEmpty()) {
var class_path = FileUtils.joinPaths(classpath);
class_path = removeAndAppendCompileOptionPath(class_path, COMPILE_OPTION_CP);
class_path = removeAndAppendCompileOptionPath(class_path, COMPILE_OPTION_CLASS_PATH);
class_path = removeAndAppendCompileOptionPath(class_path, COMPILE_OPTION_CLASSPATH);
options.addAll(List.of(COMPILE_OPTION_CP, class_path));
}
if (!modulePath.isEmpty()) {
var module_path = FileUtils.joinPaths(modulePath);
module_path = removeAndAppendCompileOptionPath(module_path, COMPILE_OPTION_P);
module_path = removeAndAppendCompileOptionPath(module_path, COMPILE_OPTION_MODULE_PATH);
options.addAll(List.of(COMPILE_OPTION_P, module_path));
}
options.addAll(compileOptions()); options.addAll(compileOptions());
var compilation_task = compiler.getTask(null, file_manager, diagnostics, options, null, compilation_units); var compilation_task = compiler.getTask(null, file_manager, diagnostics, options, null, compilation_units);
if (!compilation_task.call()) { if (!compilation_task.call()) {
diagnostics_.addAll(diagnostics.getDiagnostics()); diagnostics_.addAll(diagnostics.getDiagnostics());
executeProcessDiagnostics(diagnostics); executeProcessDiagnostics(diagnostics);
} }
var module_info_class = new File(destination, "module-info.class");
if (module_info_class.exists() && moduleMainClass() != null) {
var orig_bytes = FileUtils.readBytes(module_info_class);
var transformed_bytes = ModuleMainClassAdapter.addModuleMainClassToBytes(orig_bytes, moduleMainClass());
FileUtils.writeBytes(transformed_bytes, module_info_class);
}
} }
} }
private String removeAndAppendCompileOptionPath(String basePath, String option) {
var index = compileOptions_.indexOf(option);
if (index != -1 && index + 1 < compileOptions_.size() - 1) {
compileOptions_.remove(index);
return basePath + File.pathSeparator + compileOptions_.remove(index);
}
return basePath;
}
/** /**
* Part of the {@link #execute} operation, processes the compilation diagnostics. * Part of the {@link #execute} operation, processes the compilation diagnostics.
* *
@ -161,8 +225,11 @@ public class CompileOperation extends AbstractOperation<CompileOperation> {
.buildTestDirectory(project.buildTestDirectory()) .buildTestDirectory(project.buildTestDirectory())
.compileMainClasspath(project.compileMainClasspath()) .compileMainClasspath(project.compileMainClasspath())
.compileTestClasspath(project.compileTestClasspath()) .compileTestClasspath(project.compileTestClasspath())
.compileMainModulePath(project.compileMainModulePath())
.compileTestModulePath(project.compileTestModulePath())
.mainSourceFiles(project.mainSourceFiles()) .mainSourceFiles(project.mainSourceFiles())
.testSourceFiles(project.testSourceFiles()); .testSourceFiles(project.testSourceFiles())
.moduleMainClass(project.mainClass());
if (project.javaRelease() != null && !compileOptions().containsRelease()) { if (project.javaRelease() != null && !compileOptions().containsRelease()) {
compileOptions().release(project.javaRelease()); compileOptions().release(project.javaRelease());
} }
@ -245,6 +312,58 @@ public class CompileOperation extends AbstractOperation<CompileOperation> {
return this; return this;
} }
/**
* Provides entries for the main compilation module path.
*
* @param modulePath module path entries
* @return this operation instance
* @since 2.1
*/
public CompileOperation compileMainModulePath(String... modulePath) {
compileMainModulePath_.addAll(Arrays.asList(modulePath));
return this;
}
/**
* Provides a list of entries for the main compilation module path.
* <p>
* A copy will be created to allow this list to be independently modifiable.
*
* @param modulePath a list of module path entries
* @return this operation instance
* @since 2.1
*/
public CompileOperation compileMainModulePath(List<String> modulePath) {
compileMainModulePath_.addAll(modulePath);
return this;
}
/**
* Provides entries for the test compilation module path.
*
* @param modulePath module path entries
* @return this operation instance
* @since 2.1
*/
public CompileOperation compileTestModulePath(String... modulePath) {
compileTestModulePath_.addAll(Arrays.asList(modulePath));
return this;
}
/**
* Provides a list of entries for the test compilation module path.
* <p>
* A copy will be created to allow this list to be independently modifiable.
*
* @param modulePath a list of module path entries
* @return this operation instance
* @since 2.1
*/
public CompileOperation compileTestModulePath(List<String> modulePath) {
compileTestModulePath_.addAll(modulePath);
return this;
}
/** /**
* Provides main files that should be compiled. * Provides main files that should be compiled.
* *
@ -363,6 +482,18 @@ public class CompileOperation extends AbstractOperation<CompileOperation> {
return this; return this;
} }
/**
* Provides the main class to use if this compilation includes @{code module-info.java}.
*
* @param name the main class of the module
* @return this operation instance
* @since 2.1
*/
public CompileOperation moduleMainClass(String name) {
moduleMainClass_ = name;
return this;
}
/** /**
* Retrieves the main build destination directory. * Retrieves the main build destination directory.
* *
@ -407,6 +538,30 @@ public class CompileOperation extends AbstractOperation<CompileOperation> {
return compileTestClasspath_; return compileTestClasspath_;
} }
/**
* Retrieves the list of entries for the main compilation module path.
* <p>
* This is a modifiable list that can be retrieved and changed.
*
* @return the main compilation module path list
* @since 2.1
*/
public List<String> compileMainModulePath() {
return compileMainModulePath_;
}
/**
* Retrieves the list of entries for the test compilation module path.
* <p>
* This is a modifiable list that can be retrieved and changed.
*
* @return the test compilation module path list
* @since 2.1
*/
public List<String> compileTestModulePath() {
return compileTestModulePath_;
}
/** /**
* Retrieves the list of main files that should be compiled. * Retrieves the list of main files that should be compiled.
* <p> * <p>
@ -476,4 +631,15 @@ public class CompileOperation extends AbstractOperation<CompileOperation> {
public List<Diagnostic<? extends JavaFileObject>> diagnostics() { public List<Diagnostic<? extends JavaFileObject>> diagnostics() {
return diagnostics_; return diagnostics_;
} }
/**
* Retrieves the main class to use if this compilation includes @{code module-info.java}.
*
* @return the main class to use for the module
* @since 2.1
*/
public String moduleMainClass() {
return moduleMainClass_;
}
} }

View file

@ -21,6 +21,6 @@ public class CreateAppOperation extends AbstractCreateOperation<CreateAppOperati
} }
protected Project createProjectBlueprint() { protected Project createProjectBlueprint() {
return new AppProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName()); return new AppProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), baseName());
} }
} }

View file

@ -21,6 +21,6 @@ public class CreateBaseOperation extends AbstractCreateOperation<CreateBaseOpera
} }
protected Project createProjectBlueprint() { protected Project createProjectBlueprint() {
return new BaseProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName()); return new BaseProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), baseName());
} }
} }

View file

@ -21,11 +21,7 @@ public class CreateLibOperation extends AbstractCreateOperation<CreateLibOperati
} }
protected Project createProjectBlueprint() { protected Project createProjectBlueprint() {
return new LibProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName()); return new LibProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), baseName());
}
protected String projectMainClassName(String projectClassName) {
return projectClassName + "Lib";
} }
protected boolean createIdeaRunMain() { protected boolean createIdeaRunMain() {

View file

@ -7,6 +7,7 @@ package rife.bld.operations;
import rife.bld.operations.exceptions.OperationOptionException; import rife.bld.operations.exceptions.OperationOptionException;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -33,20 +34,29 @@ public class CreateOperation {
String type = null; String type = null;
String package_name = null; String package_name = null;
String project_name = null; String project_name = null;
String base_name = null;
if (!arguments.isEmpty()) { if (!arguments.isEmpty()) {
type = arguments.remove(0); type = arguments.remove(0);
} }
var create_operation_args = new ArrayList<String>();
if (!arguments.isEmpty()) { if (!arguments.isEmpty()) {
package_name = arguments.remove(0); package_name = arguments.remove(0);
create_operation_args.add(package_name);
} }
if (!arguments.isEmpty()) { if (!arguments.isEmpty()) {
project_name = arguments.remove(0); project_name = arguments.remove(0);
create_operation_args.add(project_name);
} }
if ((type == null || package_name == null || project_name == null) && System.console() == null) { if (!arguments.isEmpty()) {
throw new OperationOptionException("ERROR: Expecting the type, package and project names as the arguments."); base_name = arguments.remove(0);
create_operation_args.add(base_name);
}
if ((package_name == null || project_name == null || base_name == null) && System.console() == null) {
throw new OperationOptionException("ERROR: Expecting the package, project and base names as the arguments.");
} }
if (type == null || type.isEmpty()) { if (type == null || type.isBlank()) {
System.out.println("Please enter a number for the project type:"); System.out.println("Please enter a number for the project type:");
System.out.printf(" 1: %s (Java baseline project)%n", BASE); System.out.printf(" 1: %s (Java baseline project)%n", BASE);
System.out.printf(" 2: %s (Java application project)%n", APP); System.out.printf(" 2: %s (Java application project)%n", APP);
@ -77,31 +87,6 @@ public class CreateOperation {
throw new OperationOptionException("ERROR: Unsupported project type."); throw new OperationOptionException("ERROR: Unsupported project type.");
} }
if (package_name == null || package_name.isEmpty()) { return create_operation.fromArguments(create_operation_args);
System.out.println("Please enter a package name (for instance: com.example):");
package_name = System.console().readLine();
} else {
System.out.println("Using package name: " + package_name);
}
if (project_name == null || project_name.isEmpty()) {
String name_example;
if (LIB.equals(type)) {
name_example = "mylib";
} else if (RIFE2.equals(type)) {
name_example = "mywebapp";
} else {
name_example = "myapp";
}
System.out.printf("Please enter a project name (for instance: %s):%n", name_example);
project_name = System.console().readLine();
} else {
System.out.println("Using project name: " + project_name);
}
return create_operation.workDirectory(new File(System.getProperty("user.dir")))
.packageName(package_name)
.projectName(project_name)
.downloadDependencies(true);
} }
} }

View file

@ -7,6 +7,7 @@ package rife.bld.operations;
import rife.bld.blueprints.Rife2ProjectBlueprint; import rife.bld.blueprints.Rife2ProjectBlueprint;
import rife.template.TemplateFactory; import rife.template.TemplateFactory;
import rife.tools.FileUtils; import rife.tools.FileUtils;
import rife.tools.StringUtils;
import rife.tools.exceptions.FileUtilsErrorException; import rife.tools.exceptions.FileUtilsErrorException;
import java.io.File; import java.io.File;
@ -27,14 +28,14 @@ public class CreateRife2Operation extends AbstractCreateOperation<CreateRife2Ope
} }
protected Rife2ProjectBlueprint createProjectBlueprint() { protected Rife2ProjectBlueprint createProjectBlueprint() {
return new Rife2ProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName()); return new Rife2ProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), baseName());
} }
@Override @Override
protected void executeConfigure() { protected void executeConfigure() {
super.executeConfigure(); super.executeConfigure();
projectMainName_ = projectClassName_ + "Site"; projectMainName_ = baseName() + "Site";
projectMainUberName_ = projectMainName_ + "Uber"; projectMainUberName_ = projectMainName_ + "Uber";
srcMainWebappCssDirectory_ = new File(project_.srcMainWebappDirectory(), "css"); srcMainWebappCssDirectory_ = new File(project_.srcMainWebappDirectory(), "css");
srcMainWebappWebInfDirectory_ = new File(project_.srcMainWebappDirectory(), "WEB-INF"); srcMainWebappWebInfDirectory_ = new File(project_.srcMainWebappDirectory(), "WEB-INF");
@ -63,7 +64,7 @@ public class CreateRife2Operation extends AbstractCreateOperation<CreateRife2Ope
// project template // project template
var template_template = TemplateFactory.HTML.get(templateBase_ + "project_template"); var template_template = TemplateFactory.HTML.get(templateBase_ + "project_template");
template_template.setValue("project", projectClassName_); template_template.setValue("project", project_.name());
var project_template_file = new File(project_.srcMainResourcesTemplatesDirectory(), "hello.html"); var project_template_file = new File(project_.srcMainResourcesTemplatesDirectory(), "hello.html");
FileUtils.writeString(template_template.getContent(), project_template_file); FileUtils.writeString(template_template.getContent(), project_template_file);

View file

@ -31,10 +31,15 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
private final List<Repository> repositories_ = new ArrayList<>(); private final List<Repository> repositories_ = new ArrayList<>();
private final DependencyScopes dependencies_ = new DependencyScopes(); private final DependencyScopes dependencies_ = new DependencyScopes();
private File libCompileDirectory_; private File libCompileDirectory_;
private File libCompileModulesDirectory_;
private File libProvidedDirectory_; private File libProvidedDirectory_;
private File libProvidedModulesDirectory_;
private File libRuntimeDirectory_; private File libRuntimeDirectory_;
private File libRuntimeModulesDirectory_;
private File libStandaloneDirectory_; private File libStandaloneDirectory_;
private File libStandaloneModulesDirectory_;
private File libTestDirectory_; private File libTestDirectory_;
private File libTestModulesDirectory_;
private boolean downloadSources_ = false; private boolean downloadSources_ = false;
private boolean downloadJavadoc_ = false; private boolean downloadJavadoc_ = false;
@ -65,7 +70,7 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
* @since 1.5 * @since 1.5
*/ */
protected void executeDownloadCompileDependencies() { protected void executeDownloadCompileDependencies() {
executeDownloadDependencies(libCompileDirectory(), dependencies().resolveCompileDependencies(properties(), artifactRetriever(), repositories())); executeDownloadDependencies(libCompileDirectory(), libCompileModulesDirectory(), dependencies().resolveCompileDependencies(properties(), artifactRetriever(), repositories()));
} }
/** /**
@ -74,7 +79,7 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
* @since 1.8 * @since 1.8
*/ */
protected void executeDownloadProvidedDependencies() { protected void executeDownloadProvidedDependencies() {
executeDownloadDependencies(libProvidedDirectory(), dependencies().resolveProvidedDependencies(properties(), artifactRetriever(), repositories())); executeDownloadDependencies(libProvidedDirectory(), libProvidedModulesDirectory(), dependencies().resolveProvidedDependencies(properties(), artifactRetriever(), repositories()));
} }
/** /**
@ -83,7 +88,7 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
* @since 1.5 * @since 1.5
*/ */
protected void executeDownloadRuntimeDependencies() { protected void executeDownloadRuntimeDependencies() {
executeDownloadDependencies(libRuntimeDirectory(), dependencies().resolveRuntimeDependencies(properties(), artifactRetriever(), repositories())); executeDownloadDependencies(libRuntimeDirectory(), libRuntimeModulesDirectory(), dependencies().resolveRuntimeDependencies(properties(), artifactRetriever(), repositories()));
} }
/** /**
@ -92,7 +97,7 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
* @since 1.5 * @since 1.5
*/ */
protected void executeDownloadStandaloneDependencies() { protected void executeDownloadStandaloneDependencies() {
executeDownloadDependencies(libStandaloneDirectory(), dependencies().resolveStandaloneDependencies(properties(), artifactRetriever(), repositories())); executeDownloadDependencies(libStandaloneDirectory(), libStandaloneModulesDirectory(), dependencies().resolveStandaloneDependencies(properties(), artifactRetriever(), repositories()));
} }
/** /**
@ -101,23 +106,18 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
* @since 1.5 * @since 1.5
*/ */
protected void executeDownloadTestDependencies() { protected void executeDownloadTestDependencies() {
executeDownloadDependencies(libTestDirectory(), dependencies().resolveTestDependencies(properties(), artifactRetriever(), repositories())); executeDownloadDependencies(libTestDirectory(), libTestModulesDirectory(), dependencies().resolveTestDependencies(properties(), artifactRetriever(), repositories()));
} }
/** /**
* Part of the {@link #execute} operation, download the artifacts for a particular dependency scope. * Part of the {@link #execute} operation, download the artifacts for a particular dependency scope.
* *
* @param destinationDirectory the directory in which the artifacts should be downloaded * @param destinationDirectory the directory in which the artifacts should be downloaded
* @param modulesDirectory the directory in which the modules should be downloaded
* @param dependencies the dependencies to download * @param dependencies the dependencies to download
* @since 1.6 * @since 2.1
*/ */
protected void executeDownloadDependencies(File destinationDirectory, DependencySet dependencies) { protected void executeDownloadDependencies(File destinationDirectory, File modulesDirectory, DependencySet dependencies) {
if (destinationDirectory == null) {
return;
}
destinationDirectory.mkdirs();
var additional_classifiers = new String[0]; var additional_classifiers = new String[0];
if (downloadSources_ || downloadJavadoc_) { if (downloadSources_ || downloadJavadoc_) {
@ -128,7 +128,7 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
additional_classifiers = classifiers.toArray(new String[0]); additional_classifiers = classifiers.toArray(new String[0]);
} }
dependencies.transferIntoDirectory(new VersionResolution(properties()), artifactRetriever(), repositories(), destinationDirectory, additional_classifiers); dependencies.transferIntoDirectory(new VersionResolution(properties()), artifactRetriever(), repositories(), destinationDirectory, modulesDirectory, additional_classifiers);
} }
/** /**
@ -145,10 +145,15 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
.repositories(project.repositories()) .repositories(project.repositories())
.dependencies(project.dependencies()) .dependencies(project.dependencies())
.libCompileDirectory(project.libCompileDirectory()) .libCompileDirectory(project.libCompileDirectory())
.libCompileModulesDirectory(project.libCompileModulesDirectory())
.libProvidedDirectory(project.libProvidedDirectory()) .libProvidedDirectory(project.libProvidedDirectory())
.libProvidedModulesDirectory(project.libProvidedModulesDirectory())
.libRuntimeDirectory(project.libRuntimeDirectory()) .libRuntimeDirectory(project.libRuntimeDirectory())
.libRuntimeModulesDirectory(project.libRuntimeModulesDirectory())
.libStandaloneDirectory(project.libStandaloneDirectory()) .libStandaloneDirectory(project.libStandaloneDirectory())
.libStandaloneModulesDirectory(project.libStandaloneModulesDirectory())
.libTestDirectory(project.libTestDirectory()) .libTestDirectory(project.libTestDirectory())
.libTestModulesDirectory(project.libTestModulesDirectory())
.downloadSources(project.downloadSources()) .downloadSources(project.downloadSources())
.downloadJavadoc(project.downloadJavadoc()); .downloadJavadoc(project.downloadJavadoc());
} }
@ -227,6 +232,18 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
return this; return this;
} }
/**
* Provides the {@code compile} scope modules download directory.
*
* @param directory the directory to download the {@code compile} scope modules into
* @return this operation instance
* @since 2.1
*/
public DownloadOperation libCompileModulesDirectory(File directory) {
libCompileModulesDirectory_ = directory;
return this;
}
/** /**
* Provides the {@code provided} scope download directory. * Provides the {@code provided} scope download directory.
* *
@ -239,6 +256,18 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
return this; return this;
} }
/**
* Provides the {@code provided} scope modules download directory.
*
* @param directory the directory to download the {@code provided} scope modules into
* @return this operation instance
* @since 2.1
*/
public DownloadOperation libProvidedModulesDirectory(File directory) {
libProvidedModulesDirectory_ = directory;
return this;
}
/** /**
* Provides the {@code runtime} scope download directory. * Provides the {@code runtime} scope download directory.
* *
@ -251,6 +280,18 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
return this; return this;
} }
/**
* Provides the {@code runtime} scope modules download directory.
*
* @param directory the directory to download the {@code runtime} scope modules into
* @return this operation instance
* @since 2.1
*/
public DownloadOperation libRuntimeModulesDirectory(File directory) {
libRuntimeModulesDirectory_ = directory;
return this;
}
/** /**
* Provides the {@code standalone} scope download directory. * Provides the {@code standalone} scope download directory.
* *
@ -263,6 +304,18 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
return this; return this;
} }
/**
* Provides the {@code standalone} scope modules download directory.
*
* @param directory the directory to download the {@code standalone} scope modules into
* @return this operation instance
* @since 2.1
*/
public DownloadOperation libStandaloneModulesDirectory(File directory) {
libStandaloneModulesDirectory_ = directory;
return this;
}
/** /**
* Provides the {@code test} scope download directory. * Provides the {@code test} scope download directory.
* *
@ -275,6 +328,18 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
return this; return this;
} }
/**
* Provides the {@code test} scope modules download directory.
*
* @param directory the directory to download the {@code test} scope modules into
* @return this operation instance
* @since 2.1
*/
public DownloadOperation libTestModulesDirectory(File directory) {
libTestModulesDirectory_ = directory;
return this;
}
/** /**
* Indicates whether the sources classifier should also be downloaded. * Indicates whether the sources classifier should also be downloaded.
* *
@ -359,6 +424,16 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
return libCompileDirectory_; return libCompileDirectory_;
} }
/**
* Retrieves the {@code compile} scope modules download directory.
*
* @return the {@code compile} scope modules download directory
* @since 2.1
*/
public File libCompileModulesDirectory() {
return libCompileModulesDirectory_;
}
/** /**
* Retrieves the {@code provided} scope download directory. * Retrieves the {@code provided} scope download directory.
* *
@ -369,6 +444,16 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
return libProvidedDirectory_; return libProvidedDirectory_;
} }
/**
* Retrieves the {@code provided} scope modules download directory.
*
* @return the {@code provided} scope modules download directory
* @since 2.1
*/
public File libProvidedModulesDirectory() {
return libProvidedModulesDirectory_;
}
/** /**
* Retrieves the {@code runtime} scope download directory. * Retrieves the {@code runtime} scope download directory.
* *
@ -379,6 +464,16 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
return libRuntimeDirectory_; return libRuntimeDirectory_;
} }
/**
* Retrieves the {@code runtime} scope modules download directory.
*
* @return the {@code runtime} scope modules download directory
* @since 2.1
*/
public File libRuntimeModulesDirectory() {
return libRuntimeModulesDirectory_;
}
/** /**
* Retrieves the {@code standalone} scope download directory. * Retrieves the {@code standalone} scope download directory.
* *
@ -389,6 +484,16 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
return libStandaloneDirectory_; return libStandaloneDirectory_;
} }
/**
* Retrieves the {@code standalone} scope modules download directory.
*
* @return the {@code standalone} scope modules download directory
* @since 2.1
*/
public File libStandaloneModulesDirectory() {
return libStandaloneModulesDirectory_;
}
/** /**
* Retrieves the {@code test} scope download directory. * Retrieves the {@code test} scope download directory.
* *
@ -399,6 +504,16 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
return libTestDirectory_; return libTestDirectory_;
} }
/**
* Retrieves the {@code test} scope modules download directory.
*
* @return the {@code test} scope modules download directory
* @since 2.1
*/
public File libTestModulesDirectory() {
return libTestModulesDirectory_;
}
/** /**
* Retrieves whether the sources classifier should also be downloaded. * Retrieves whether the sources classifier should also be downloaded.
* *

View file

@ -4,9 +4,11 @@
*/ */
package rife.bld.operations; package rife.bld.operations;
import rife.tools.FileUtils;
import rife.tools.StringUtils; import rife.tools.StringUtils;
import java.io.File; import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -38,8 +40,8 @@ public class JavaOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.18 * @since 1.5.18
*/ */
public JavaOptions modulePath(File... modules) { public JavaOptions modulePath(File... paths) {
return modulePath(List.of(modules)); return modulePath(List.of(paths));
} }
/** /**
@ -48,9 +50,49 @@ public class JavaOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.18 * @since 1.5.18
*/ */
public JavaOptions modulePath(List<File> modules) { public JavaOptions modulePath(List<File> paths) {
return modulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
}
/**
* A list of directories, each directory is a directory of modules.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions modulePath(Path... paths) {
return modulePathPaths(List.of(paths));
}
/**
* A list of directories, each directory is a directory of modules.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions modulePathPaths(List<Path> paths) {
return modulePath(paths.stream().map(Path::toFile).toList());
}
/**
* A list of directories, each directory is a directory of modules.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions modulePath(String... paths) {
return modulePathStrings(List.of(paths));
}
/**
* A list of directories, each directory is a directory of modules.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions modulePathStrings(List<String> paths) {
add("--module-path"); add("--module-path");
add(StringUtils.join(modules, ":")); add(FileUtils.joinPaths(paths));
return this; return this;
} }
@ -61,8 +103,8 @@ public class JavaOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.18 * @since 1.5.18
*/ */
public JavaOptions upgradeModulePath(File... modulePath) { public JavaOptions upgradeModulePath(File... paths) {
return upgradeModulePath(List.of(modulePath)); return upgradeModulePath(List.of(paths));
} }
/** /**
@ -72,9 +114,53 @@ public class JavaOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.18 * @since 1.5.18
*/ */
public JavaOptions upgradeModulePath(List<File> modulePath) { public JavaOptions upgradeModulePath(List<File> paths) {
return upgradeModulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
}
/**
* List of directories, each directory is a directory of modules
* that replace upgradeable modules in the runtime image
*
* @return this list of options
* @since 2.1
*/
public JavaOptions upgradeModulePath(Path... paths) {
return upgradeModulePathPaths(List.of(paths));
}
/**
* List of directories, each directory is a directory of modules
* that replace upgradeable modules in the runtime image
*
* @return this list of options
* @since 2.1
*/
public JavaOptions upgradeModulePathPaths(List<Path> paths) {
return upgradeModulePath(paths.stream().map(Path::toFile).toList());
}
/**
* List of directories, each directory is a directory of modules
* that replace upgradeable modules in the runtime image
*
* @return this list of options
* @since 2.1
*/
public JavaOptions upgradeModulePath(String... paths) {
return upgradeModulePathStrings(List.of(paths));
}
/**
* List of directories, each directory is a directory of modules
* that replace upgradeable modules in the runtime image
*
* @return this list of options
* @since 2.1
*/
public JavaOptions upgradeModulePathStrings(List<String> paths) {
add("--upgrade-module-path"); add("--upgrade-module-path");
add(StringUtils.join(modulePath, ":")); add(FileUtils.joinPaths(paths));
return this; return this;
} }
@ -256,7 +342,7 @@ public class JavaOptions extends ArrayList<String> {
* @since 1.5.18 * @since 1.5.18
*/ */
public JavaOptions agentPath(File pathName) { public JavaOptions agentPath(File pathName) {
return agentPath(pathName, (String)null); return agentPath(pathName.getAbsolutePath(), (String)null);
} }
/** /**
@ -266,8 +352,7 @@ public class JavaOptions extends ArrayList<String> {
* @since 1.5.18 * @since 1.5.18
*/ */
public JavaOptions agentPath(File pathName, String options) { public JavaOptions agentPath(File pathName, String options) {
add("-agentpath:" + pathName + (options == null ? "" : "=" + options)); return agentPath(pathName.getAbsolutePath(), options);
return this;
} }
/** /**
@ -277,7 +362,7 @@ public class JavaOptions extends ArrayList<String> {
* @since 1.7.1 * @since 1.7.1
*/ */
public JavaOptions agentPath(File pathName, String... options) { public JavaOptions agentPath(File pathName, String... options) {
return agentPath(pathName, List.of(options)); return agentPath(pathName.getAbsolutePath(), List.of(options));
} }
/** /**
@ -287,6 +372,87 @@ public class JavaOptions extends ArrayList<String> {
* @since 1.7.1 * @since 1.7.1
*/ */
public JavaOptions agentPath(File pathName, List<String> options) { public JavaOptions agentPath(File pathName, List<String> options) {
return agentPath(pathName.getAbsolutePath(), options);
}
/**
* Load native agent library by full pathname.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions agentPath(Path pathName) {
return agentPath(pathName.toFile(), (String)null);
}
/**
* Load native agent library by full pathname.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions agentPath(Path pathName, String options) {
return agentPath(pathName.toFile(), options);
}
/**
* Load native agent library by full pathname.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions agentPath(Path pathName, String... options) {
return agentPath(pathName.toFile(), List.of(options));
}
/**
* Load native agent library by full pathname.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions agentPath(Path pathName, List<String> options) {
return agentPath(pathName.toFile(), options);
}
/**
* Load native agent library by full pathname.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions agentPath(String pathName) {
return agentPath(pathName, (String)null);
}
/**
* Load native agent library by full pathname.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions agentPath(String pathName, String options) {
add("-agentpath:" + pathName + (options == null ? "" : "=" + options));
return this;
}
/**
* Load native agent library by full pathname.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions agentPath(String pathName, String... options) {
return agentPath(pathName, List.of(options));
}
/**
* Load native agent library by full pathname.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions agentPath(String pathName, List<String> options) {
add("-agentpath:" + pathName + (options == null || options.isEmpty() ? "" : "=" + StringUtils.join(options, ","))); add("-agentpath:" + pathName + (options == null || options.isEmpty() ? "" : "=" + StringUtils.join(options, ",")));
return this; return this;
} }
@ -298,7 +464,7 @@ public class JavaOptions extends ArrayList<String> {
* @since 1.5.18 * @since 1.5.18
*/ */
public JavaOptions javaAgent(File jarPath) { public JavaOptions javaAgent(File jarPath) {
return javaAgent(jarPath, (String)null); return javaAgent(jarPath.getAbsolutePath(), (String)null);
} }
/** /**
@ -308,8 +474,7 @@ public class JavaOptions extends ArrayList<String> {
* @since 1.5.18 * @since 1.5.18
*/ */
public JavaOptions javaAgent(File jarPath, String options) { public JavaOptions javaAgent(File jarPath, String options) {
add("-javaagent:" + jarPath + (options == null ? "" : "=" + options)); return javaAgent(jarPath.getAbsolutePath(), options);
return this;
} }
/** /**
@ -319,7 +484,7 @@ public class JavaOptions extends ArrayList<String> {
* @since 1.7.1 * @since 1.7.1
*/ */
public JavaOptions javaAgent(File jarPath, String... options) { public JavaOptions javaAgent(File jarPath, String... options) {
return javaAgent(jarPath, List.of(options)); return javaAgent(jarPath.getAbsolutePath(), List.of(options));
} }
/** /**
@ -329,6 +494,87 @@ public class JavaOptions extends ArrayList<String> {
* @since 1.7.1 * @since 1.7.1
*/ */
public JavaOptions javaAgent(File jarPath, List<String> options) { public JavaOptions javaAgent(File jarPath, List<String> options) {
return javaAgent(jarPath.getAbsolutePath(), options);
}
/**
* Load Java programming language agent.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions javaAgent(Path jarPath) {
return javaAgent(jarPath.toFile(), (String)null);
}
/**
* Load Java programming language agent.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions javaAgent(Path jarPath, String options) {
return javaAgent(jarPath.toFile(), options);
}
/**
* Load Java programming language agent.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions javaAgent(Path jarPath, String... options) {
return javaAgent(jarPath.toFile(), List.of(options));
}
/**
* Load Java programming language agent.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions javaAgent(Path jarPath, List<String> options) {
return javaAgent(jarPath.toFile(), options);
}
/**
* Load Java programming language agent.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions javaAgent(String jarPath) {
return javaAgent(jarPath, (String)null);
}
/**
* Load Java programming language agent.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions javaAgent(String jarPath, String options) {
add("-javaagent:" + jarPath + (options == null ? "" : "=" + options));
return this;
}
/**
* Load Java programming language agent.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions javaAgent(String jarPath, String... options) {
return javaAgent(jarPath, List.of(options));
}
/**
* Load Java programming language agent.
*
* @return this list of options
* @since 2.1
*/
public JavaOptions javaAgent(String jarPath, List<String> options) {
add("-javaagent:" + jarPath + (options == null || options.isEmpty() ? "" : "=" + StringUtils.join(options, ","))); add("-javaagent:" + jarPath + (options == null || options.isEmpty() ? "" : "=" + StringUtils.join(options, ",")));
return this; return this;
} }

File diff suppressed because it is too large Load diff

View file

@ -26,6 +26,7 @@ import java.util.regex.Pattern;
public class JavadocOperation extends AbstractOperation<JavadocOperation> { public class JavadocOperation extends AbstractOperation<JavadocOperation> {
private File buildDirectory_; private File buildDirectory_;
private final List<String> classpath_ = new ArrayList<>(); private final List<String> classpath_ = new ArrayList<>();
private final List<String> modulePath_ = new ArrayList<>();
private final List<File> sourceFiles_ = new ArrayList<>(); private final List<File> sourceFiles_ = new ArrayList<>();
private final List<File> sourceDirectories_ = new ArrayList<>(); private final List<File> sourceDirectories_ = new ArrayList<>();
private final JavadocOptions javadocOptions_ = new JavadocOptions(); private final JavadocOptions javadocOptions_ = new JavadocOptions();
@ -74,6 +75,7 @@ public class JavadocOperation extends AbstractOperation<JavadocOperation> {
} }
executeBuildSources( executeBuildSources(
classpath(), classpath(),
modulePath(),
sources, sources,
buildDirectory()); buildDirectory());
} }
@ -81,12 +83,13 @@ public class JavadocOperation extends AbstractOperation<JavadocOperation> {
/** /**
* Part of the {@link #execute} operation, build sources to a destination. * Part of the {@link #execute} operation, build sources to a destination.
* *
* @param classpath the classpath list used for the compilation * @param classpath the classpath list used for the javadoc generation
* @param modulePath the module path list used for the javadoc generation
* @param sources the source files to compile * @param sources the source files to compile
* @param destination the destination directory * @param destination the destination directory
* @since 1.5.10 * @since 2.1
*/ */
protected void executeBuildSources(List<String> classpath, List<File> sources, File destination) protected void executeBuildSources(List<String> classpath, List<String> modulePath, List<File> sources, File destination)
throws IOException { throws IOException {
if (sources.isEmpty() || destination == null) { if (sources.isEmpty() || destination == null) {
return; return;
@ -103,7 +106,13 @@ public class JavadocOperation extends AbstractOperation<JavadocOperation> {
try (var file_manager = documentation.getStandardFileManager(null, null, null)) { try (var file_manager = documentation.getStandardFileManager(null, null, null)) {
var compilation_units = file_manager.getJavaFileObjectsFromFiles(filtered_sources); var compilation_units = file_manager.getJavaFileObjectsFromFiles(filtered_sources);
var diagnostics = new DiagnosticCollector<JavaFileObject>(); var diagnostics = new DiagnosticCollector<JavaFileObject>();
var options = new ArrayList<>(List.of("-d", destination.getAbsolutePath(), "-cp", FileUtils.joinPaths(classpath))); var options = new ArrayList<>(List.of("-d", destination.getAbsolutePath()));
if (!classpath.isEmpty()) {
options.addAll(List.of("-cp", FileUtils.joinPaths(classpath)));
}
if (!modulePath.isEmpty()) {
options.addAll(List.of("-p", FileUtils.joinPaths(modulePath)));
}
options.addAll(javadocOptions()); options.addAll(javadocOptions());
var documentation_task = documentation.getTask(null, file_manager, diagnostics, null, options, compilation_units); var documentation_task = documentation.getTask(null, file_manager, diagnostics, null, options, compilation_units);
if (!documentation_task.call()) { if (!documentation_task.call()) {
@ -146,6 +155,7 @@ public class JavadocOperation extends AbstractOperation<JavadocOperation> {
var operation = buildDirectory(project.buildJavadocDirectory()) var operation = buildDirectory(project.buildJavadocDirectory())
.classpath(project.compileMainClasspath()) .classpath(project.compileMainClasspath())
.classpath(project.buildMainDirectory().getAbsolutePath()) .classpath(project.buildMainDirectory().getAbsolutePath())
.modulePath(project.compileMainModulePath())
.sourceFiles(project.mainSourceFiles()); .sourceFiles(project.mainSourceFiles());
if (project.javaRelease() != null && !javadocOptions().containsRelease()) { if (project.javaRelease() != null && !javadocOptions().containsRelease()) {
javadocOptions().release(project.javaRelease()); javadocOptions().release(project.javaRelease());
@ -191,6 +201,32 @@ public class JavadocOperation extends AbstractOperation<JavadocOperation> {
return this; return this;
} }
/**
* Provides entries for the javadoc module path.
*
* @param modulePath module path entries
* @return this operation instance
* @since 2.1
*/
public JavadocOperation modulePath(String... modulePath) {
modulePath_.addAll(Arrays.asList(modulePath));
return this;
}
/**
* Provides a list of entries for the javadoc moduel path.
* <p>
* A copy will be created to allow this list to be independently modifiable.
*
* @param modulePath a list of module path entries
* @return this operation instance
* @since 2.1
*/
public JavadocOperation modulePath(List<String> modulePath) {
modulePath_.addAll(modulePath);
return this;
}
/** /**
* Provides files for which documentation should be generated. * Provides files for which documentation should be generated.
* *
@ -361,6 +397,18 @@ public class JavadocOperation extends AbstractOperation<JavadocOperation> {
return classpath_; return classpath_;
} }
/**
* Retrieves the list of entries for the javadoc module path.
* <p>
* This is a modifiable list that can be retrieved and changed.
*
* @return the javadoc module path list
* @since 2.1
*/
public List<String> modulePath() {
return modulePath_;
}
/** /**
* Retrieves the list of files for which documentation should be generation. * Retrieves the list of files for which documentation should be generation.
* <p> * <p>

View file

@ -9,10 +9,10 @@ import rife.tools.FileUtils;
import rife.tools.StringUtils; import rife.tools.StringUtils;
import java.io.File; import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* Options for the standard javadoc tool. * Options for the standard javadoc tool.
@ -178,8 +178,48 @@ public class JavadocOptions extends ArrayList<String> {
* @since 1.5.18 * @since 1.5.18
*/ */
public JavadocOptions extDirs(List<File> dirs) { public JavadocOptions extDirs(List<File> dirs) {
return extDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
}
/**
* Override location of installed extensions
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions extDirs(Path... dirs) {
return extDirsPaths(Arrays.asList(dirs));
}
/**
* Override location of installed extensions
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions extDirsPaths(List<Path> dirs) {
return extDirs(dirs.stream().map(Path::toFile).toList());
}
/**
* Override location of installed extensions
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions extDirs(String... dirs) {
return extDirsStrings(Arrays.asList(dirs));
}
/**
* Override location of installed extensions
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions extDirsStrings(List<String> dirs) {
add("-extdirs"); add("-extdirs");
add(dirs.stream().map(File::getAbsolutePath).collect(Collectors.joining(","))); add(String.join(",", dirs));
return this; return this;
} }
@ -256,8 +296,48 @@ public class JavadocOptions extends ArrayList<String> {
* @since 1.6.3 * @since 1.6.3
*/ */
public JavadocOptions modulePath(List<File> paths) { public JavadocOptions modulePath(List<File> paths) {
return modulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
}
/**
* Specify where to find application modules
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions modulePath(Path... paths) {
return modulePathPaths(Arrays.asList(paths));
}
/**
* Specify where to find application modules
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions modulePathPaths(List<Path> paths) {
return modulePath(paths.stream().map(Path::toFile).toList());
}
/**
* Specify where to find application modules
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions modulePath(String... paths) {
return modulePathStrings(Arrays.asList(paths));
}
/**
* Specify where to find application modules
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions modulePathStrings(List<String> paths) {
add("--module-path"); add("--module-path");
add(FileUtils.joinPaths(paths.stream().map(File::getAbsolutePath).toList())); add(FileUtils.joinPaths(paths));
return this; return this;
} }
@ -268,8 +348,28 @@ public class JavadocOptions extends ArrayList<String> {
* @since 1.6.3 * @since 1.6.3
*/ */
public JavadocOptions moduleSourcePath(File path) { public JavadocOptions moduleSourcePath(File path) {
return moduleSourcePath(path.getAbsolutePath());
}
/**
* Specify where to find input source files for multiple modules
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions moduleSourcePath(Path path) {
return moduleSourcePath(path.toFile());
}
/**
* Specify where to find input source files for multiple modules
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions moduleSourcePath(String path) {
add("--module-source-path"); add("--module-source-path");
add(path.getAbsolutePath()); add(path);
return this; return this;
} }
@ -425,9 +525,29 @@ public class JavadocOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.12 * @since 1.5.12
*/ */
public JavadocOptions addScript(File file) { public JavadocOptions addScript(File path) {
return addScript(path.getAbsolutePath());
}
/**
* Add a script file to the generated documentation
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions addScript(Path path) {
return addScript(path.toFile());
}
/**
* Add a script file to the generated documentation
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions addScript(String path) {
add("--add-script"); add("--add-script");
add(file.getAbsolutePath()); add(path);
return this; return this;
} }
@ -437,9 +557,29 @@ public class JavadocOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.12 * @since 1.5.12
*/ */
public JavadocOptions addStylesheet(File file) { public JavadocOptions addStylesheet(File path) {
return addStylesheet(path.getAbsolutePath());
}
/**
* Add a stylesheet file to the generated documentation
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions addStylesheet(Path path) {
return addStylesheet(path.toFile());
}
/**
* Add a stylesheet file to the generated documentation
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions addStylesheet(String path) {
add("--add-stylesheet"); add("--add-stylesheet");
add(file.getAbsolutePath()); add(path);
return this; return this;
} }
@ -578,9 +718,29 @@ public class JavadocOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.12 * @since 1.5.12
*/ */
public JavadocOptions stylesheet(File file) { public JavadocOptions stylesheet(File path) {
return stylesheet(path.getAbsolutePath());
}
/**
* File to change style of the generated documentation
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions stylesheet(Path path) {
return stylesheet(path.toFile());
}
/**
* File to change style of the generated documentation
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions stylesheet(String path) {
add("--main-stylesheet"); add("--main-stylesheet");
add(file.getAbsolutePath()); add(path);
return this; return this;
} }
@ -735,9 +895,29 @@ public class JavadocOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.18 * @since 1.5.18
*/ */
public JavadocOptions overview(File htmlFile) { public JavadocOptions overview(File path) {
return overview(path.getAbsolutePath());
}
/**
* Read overview documentation from HTML file
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions overview(Path path) {
return overview(path.toFile());
}
/**
* Read overview documentation from HTML file
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions overview(String path) {
add("-overview"); add("-overview");
add(htmlFile.getAbsolutePath()); add(path);
return this; return this;
} }
@ -793,8 +973,28 @@ public class JavadocOptions extends ArrayList<String> {
* @since 1.5.12 * @since 1.5.12
*/ */
public JavadocOptions snippetPath(File path) { public JavadocOptions snippetPath(File path) {
return snippetPath(path.getAbsolutePath());
}
/**
* The path for external snippets
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions snippetPath(Path path) {
return snippetPath(path.toFile());
}
/**
* The path for external snippets
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions snippetPath(String path) {
add("--snippet-path"); add("--snippet-path");
add(path.getAbsolutePath()); add(path);
return this; return this;
} }
@ -852,8 +1052,28 @@ public class JavadocOptions extends ArrayList<String> {
* @since 1.5.12 * @since 1.5.12
*/ */
public JavadocOptions tagletPath(File path) { public JavadocOptions tagletPath(File path) {
return tagletPath(path.getAbsolutePath());
}
/**
* The path to Taglets
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions tagletPath(Path path) {
return tagletPath(path.toFile());
}
/**
* The path to Taglets
*
* @return this list of options
* @since 2.1
*/
public JavadocOptions tagletPath(String path) {
add("-tagletpath"); add("-tagletpath");
add(path.getAbsolutePath()); add(path);
return this; return this;
} }

View file

@ -0,0 +1,77 @@
/*
* Copyright 2024 Erik C. Thauvin (https://erik.thauvin.net/)
* Licensed under the Apache License, Version 2.0 (the "License")
*/
package rife.bld.operations;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Create run-time images using the jlink tool.
*
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @since 2.1.0
*/
public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation> {
private final List<String> disabledPlugins_ = new ArrayList<>();
private final JlinkOptions jlinkOptions_ = new JlinkOptions();
public JlinkOperation() {
super("jlink");
}
/**
* Disable the plugin(s) mentioned.
*
* @param plugins the plugin name(s)
* @return this map of options
*/
public JlinkOperation disablePlugin(List<String> plugins) {
disabledPlugins_.addAll(plugins);
return this;
}
/**
* Disable the plugin(s) mentioned.
*
* @param plugins the plugin name(s)
* @return this map of options
*/
public JlinkOperation disablePlugin(String... plugins) {
return disablePlugin(List.of(plugins));
}
@Override
public void execute() throws Exception {
toolArgsFromFiles();
disabledPlugins_.forEach(plugin -> toolArgs("--disable-plugin", plugin));
toolArgs(jlinkOptions_);
super.execute();
}
/**
* Provides a list of options to provide to the jlink tool.
* <p>
* A copy will be created to allow this list to be independently modifiable.
*
* @param options the argument-value pairs
* @return this operation instance
*/
public JlinkOperation jlinkOptions(Map<String, String> options) {
jlinkOptions_.putAll(options);
return this;
}
/**
* Retrieves the list of options for the jlink tool.
* <p>
* This is a modifiable list that can be retrieved and changed.
*
* @return the map of jlink options
*/
public JlinkOptions jlinkOptions() {
return jlinkOptions_;
}
}

View file

@ -0,0 +1,408 @@
/*
* Copyright 2024 Erik C. Thauvin (https://erik.thauvin.net/)
* Licensed under the Apache License, Version 2.0 (the "License")
*/
package rife.bld.operations;
import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
/**
* Options for jlink tool.
*
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @since 2.1.0
*/
public class JlinkOptions extends LinkedHashMap<String, String> {
/**
* All Modules Path.
*/
@SuppressWarnings("unused")
public final static String ALL_MODULE_PATH = "ALL-MODULE-PATH";
/**
* Root modules to resolve in addition to the initial modules.
* <p>
* Module can also be {@link #ALL_MODULE_PATH}
*
* @param modules one or more modules
* @return this map of options
*/
public JlinkOptions addModules(List<String> modules) {
put("--add-modules", String.join(",", modules));
return this;
}
/**
* Root modules to resolve in addition to the initial modules.
* <p>
* Module can also be {@link #ALL_MODULE_PATH}
*
* @param modules one or more modules
* @return this map of options
*/
public JlinkOptions addModules(String... modules) {
return addModules(List.of(modules));
}
/**
* Link in service provider modules and their dependencies.
*
* @param bindServices {@code true} to bind services, {@code false} otherwise
* @return this map of options
*/
public JlinkOptions bindServices(boolean bindServices) {
if (bindServices) {
put("--bind-services");
} else {
remove("--bind-services");
}
return this;
}
/**
* Compression to use in compressing resources.
* <p>
* <b>Requires Java 21 or higher</b>. Use {@link #compress(CompressionLevel)} for lower versions.
* <p>
* Where {@link ZipCompression#ZIP_0 ZIP_0} provides no compression and {@link ZipCompression#ZIP_9 ZIP_9} provides
* the best compression.
* <p>Default is {@link ZipCompression#ZIP_6 ZIP_6}
*
* @param compression the {@link ZipCompression compression} level
* @return this map of options
* @see #compress(ZipCompression)
*/
public JlinkOptions compress(ZipCompression compression) {
put("--compress", compression.level);
return this;
}
/**
* Enable compression of resources.
* <p>
* Use {@link #compress(ZipCompression)} on Java 21 or higher.
*
* @param compression the {@link CompressionLevel compression} level
* @return this map of options
* @see #compress(CompressionLevel)
*/
public JlinkOptions compress(CompressionLevel compression) {
put("--compress", compression.level);
return this;
}
/**
* Byte order of generated jimage.
* <p>
* Default: native
*
* @param endian the byte order
* @return this map of options
*/
public JlinkOptions endian(Endian endian) {
put("--endian", endian.byteOrder);
return this;
}
/**
* Suppress a fatal error when signed modular JARs are linked in the image.
*
* @param ignoreSigningInformation {@code true} to ignore signing information, {@code false} otherwise
* @return this map of options
*/
public JlinkOptions ignoreSigningInformation(boolean ignoreSigningInformation) {
if (ignoreSigningInformation) {
put("--ignore-signing-information");
} else {
remove("--ignore-signing-information");
}
return this;
}
/**
* Add a launcher command of the given name for the module.
*
* @param name the name
* @param module the module
* @return this map of options
*/
@SuppressWarnings("UnusedReturnValue")
public JlinkOptions launcher(String name, String module) {
put("--launcher", name + "=" + module);
return this;
}
/**
* Add a launcher command of the given name for the module and the main class.
*
* @param name the name
* @param module the module
* @param mainClass the main class
* @return this map of options
*/
public JlinkOptions launcher(String name, String module, String mainClass) {
put("--launcher", name + "=" + module + "/" + mainClass);
return this;
}
/**
* Limit the universe of observable modules.
*
* @param modules one or more modules
* @return this map of options
*/
public JlinkOptions limitModule(List<String> modules) {
put("--limit-modules", String.join(",", modules));
return this;
}
/**
* Limit the universe of observable modules.
*
* @param modules one or more modules
* @return this map of options
*/
public JlinkOptions limitModule(String... modules) {
return limitModule(List.of(modules));
}
/**
* Module path.
* <p>
* If not specified, the JDKs jmods directory will be used, if it exists. If specified, but it does not contain the
* {@code java.base} module, the JDKs jmods directory will be added, if it exists.
*
* @param path the module path
* @return this map of options
*/
public JlinkOptions modulePath(String path) {
put("--module-path", path);
return this;
}
/**
* Module path.
* <p>
* If not specified, the JDKs jmods directory will be used, if it exists. If specified, but it does not contain the
* {@code java.base} module, the JDKs jmods directory will be added, if it exists.
*
* @param path the module path
* @return this map of options
*/
public JlinkOptions modulePath(File path) {
return modulePath(path.getAbsolutePath());
}
/**
* Module path.
* <p>
* If not specified, the JDKs jmods directory will be used, if it exists. If specified, but it does not contain the
* {@code java.base} module, the JDKs jmods directory will be added, if it exists.
*
* @param path the module path
* @return this map of options
*/
public JlinkOptions modulePath(Path path) {
return modulePath(path.toFile().getAbsolutePath());
}
/**
* Exclude include header files.
*
* @param noHeaderFiles {@code true} to exclude header files, {@code false} otherwise
* @return this map of options
*/
public JlinkOptions noHeaderFiles(boolean noHeaderFiles) {
if (noHeaderFiles) {
put("--no-header-files");
} else {
remove("--no-header-files");
}
return this;
}
/**
* Exclude man pages.
*
* @param noManPages {@code true} to exclude man pages, {@code false} otherwise
* @return this map of options
*/
public JlinkOptions noManPages(boolean noManPages) {
if (noManPages) {
put("--no-man-pages");
} else {
remove("--no-man-pages");
}
return this;
}
/**
* Location of output path.
*
* @param path the output path
* @return this map of options
*/
public JlinkOptions output(String path) {
put("--output", path);
return this;
}
/**
* Location of output path.
*
* @param path the output path
* @return this map of options
*/
public JlinkOptions output(File path) {
return output(path.getAbsolutePath());
}
/**
* Location of output path.
*
* @param path the output path
* @return this map of options
*/
public JlinkOptions output(Path path) {
return output(path.toFile().getAbsolutePath());
}
/**
* Associates {@code null} with the specified key in this map. If the map previously contained a mapping for the
* key, the old value is replaced.
*
* @param key key with which the specified value is to be associated
*/
public void put(String key) {
put(key, null);
}
/**
* Suggest providers that implement the given service types from the module path.
*
* @param filename the filename
* @return this map of options
*/
public JlinkOptions saveOpts(String filename) {
put("--save-opts", filename);
return this;
}
/**
* Strip debug information.
*
* @param stripDebug {@code true} to strip debug info, {@code false} otherwise
* @return this map of options
*/
public JlinkOptions stripDebug(boolean stripDebug) {
if (stripDebug) {
put("--strip-debug");
} else {
remove("--strip-debug");
}
return this;
}
/**
* Strip native commands.
*
* @param stripNativeCommands {@code true} to strip, {@code false} otherwise
* @return this map of options
*/
public JlinkOptions stripNativeCommands(boolean stripNativeCommands) {
if (stripNativeCommands) {
put("--strip-native-commands");
} else {
remove("--strip-native-commands");
}
return this;
}
/**
* Suggest providers that implement the given service types from the module path.
*
* @param names one or more provider names
* @return this map of options
*/
public JlinkOptions suggestProviders(List<String> names) {
put("--suggest-providers", String.join(",", names));
return this;
}
/**
* Suggest providers that implement the given service types from the module path.
*
* @param names one or more provider names
* @return this map of options
*/
public JlinkOptions suggestProviders(String... names) {
return suggestProviders(List.of(names));
}
public List<String> toList() {
var list = new ArrayList<String>();
forEach((k, v) -> {
list.add(k);
if (v != null && !v.isEmpty()) {
list.add(v);
}
});
return list;
}
/**
* Enable verbose tracing.
*
* @param verbose {@code true} to enable verbose tracing, {@code false} otherwise.
* @return this map of options
*/
public JlinkOptions verbose(boolean verbose) {
if (verbose) {
put("--verbose");
} else {
remove("--verbose");
}
return this;
}
/**
* The byte orders.
*/
public enum Endian {
BIG("big"), LITTLE("little");
public final String byteOrder;
Endian(String byteOrder) {
this.byteOrder = byteOrder;
}
}
/**
* Resources compression levels.
*/
public enum CompressionLevel {
/**
* Level 0: No compression
*/
NO_COMPRESSION("0"),
/**
* Level 1: Constant string sharing
*/
CONSTANT_STRING_SHARING("1"),
/**
* Level 2: ZIP
*/
ZIP("2");
public final String level;
CompressionLevel(String level) {
this.level = level;
}
}
}

View file

@ -0,0 +1,156 @@
/*
* Copyright 2024 Erik C. Thauvin (https://erik.thauvin.net/)
* Licensed under the Apache License, Version 2.0 (the "License")
*/
package rife.bld.operations;
import java.io.File;
import java.nio.file.Path;
import java.util.Map;
/**
* Create JMOD files with the jmod tool.
*
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @since 2.1.0
*/
public class JmodOperation extends AbstractToolProviderOperation<JmodOperation> {
private final JmodOptions jmodOptions_ = new JmodOptions();
private String jmodFile_;
private OperationMode operationMode_;
public JmodOperation() {
super("jmod");
}
@Override
public void execute() throws Exception {
if (operationMode_ != null) {
toolArgs(operationMode_.mode);
}
toolArgsFromFiles();
toolArgs(jmodOptions_);
if (jmodFile_ != null) {
toolArgs(jmodFile_);
}
super.execute();
}
/**
* Retrieves the name of the JMOD file to create or from which to retrieve information.
*
* @return the JMOD file
*/
public String jmodFile() {
return jmodFile_;
}
/**
* Specifies name of the JMOD file to create or from which to retrieve information.
* <p>
* The JMOD file is <b>required</b>.
*
* @param file the JMOD file
* @return this operation instance
*/
public JmodOperation jmodFile(String file) {
jmodFile_ = file;
return this;
}
/**
* Specifies name of the JMOD file to create or from which to retrieve information.
* <p>
* The JMOD file is <b>required</b>.
*
* @param file the JMOD file
* @return this operation instance
*/
public JmodOperation jmodFile(File file) {
return jmodFile(file.getAbsolutePath());
}
/**
* Specifies name of the JMOD file to create or from which to retrieve information.
* <p>
* The JMOD file is <b>required</b>.
*
* @param file the JMOD file
* @return this operation instance
*/
public JmodOperation jmodFile(Path file) {
return jmodFile(file.toFile().getAbsolutePath());
}
/**
* Retrieves the list of options for the jmod tool.
* <p>
* This is a modifiable list that can be retrieved and changed.
*
* @return the map of jmod options
*/
public JmodOptions jmodOptions() {
return jmodOptions_;
}
/**
* Provides a list of options to provide to the jmod tool.
* <p>
* A copy will be created to allow this list to be independently modifiable.
*
* @param options the list of jmod options
* @return this operation instance
*/
public JmodOperation jmodOptions(Map<String, String> options) {
jmodOptions_.putAll(options);
return this;
}
/**
* Provides the {@link OperationMode operation mode}.
* <p>
* The operation mode is <b>required</b>.
*
* @param mode the mode
* @return this operation instance
*/
public JmodOperation operationMode(OperationMode mode) {
operationMode_ = mode;
return this;
}
/**
* The operation modes.
*/
public enum OperationMode {
/**
* Creates a new JMOD archive file.
*/
CREATE("create"),
/**
* Prints the module details.
*/
DESCRIBE("describe"),
/**
* Extracts all the files from the JMOD archive file.
*/
EXTRACT("extract"),
/**
* Determines leaf modules and records the hashes of the dependencies that directly and indirectly require them.
*/
HASH("hash"),
/**
* Prints the names of all the entries.
*/
LIST("list");
final String mode;
OperationMode(String mode) {
this.mode = mode;
}
}
}

View file

@ -0,0 +1,473 @@
/*
* Copyright 2024 Erik C. Thauvin (https://erik.thauvin.net/)
* Licensed under the Apache License, Version 2.0 (the "License")
*/
package rife.bld.operations;
import java.io.File;
import java.nio.file.Path;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
/**
* Options for jmod tool.
*
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @since 2.1.0
*/
public class JmodOptions extends LinkedHashMap<String, String> {
/**
* Application jar files|dir containing classes.
*
* @param classpath the classpath
* @return this map of options
*/
public JmodOptions classpath(String classpath) {
put("--class-path", classpath);
return this;
}
/**
* Location of native commands.
*
* @param path the location
* @return this map of options
*/
public JmodOptions cmds(String path) {
put("--cmds", path);
return this;
}
/**
* Location of native commands.
*
* @param path the location
* @return this map of options
*/
@SuppressWarnings("UnusedReturnValue")
public JmodOptions cmds(File path) {
return cmds(path.getAbsolutePath());
}
/**
* Location of native commands.
*
* @param path the location
* @return this map of options
*/
public JmodOptions cmds(Path path) {
return cmds(path.toFile().getAbsolutePath());
}
/**
* Compression to use when creating the JMOD archive.
* <p>
* <b>Requires Java 20 or higher</b>.
* <p>
* Where {@link ZipCompression#ZIP_0 ZIP_0} provides no compression and {@link ZipCompression#ZIP_9 ZIP_9} provides the
* best compression.
* <p>
* Default is {@link ZipCompression#ZIP_6 ZIP_6}
*
* @param compression the {@link ZipCompression compression} level
* @return this map of options
*/
@SuppressWarnings("UnusedReturnValue")
public JmodOptions compress(ZipCompression compression) {
put("--compress", compression.level);
return this;
}
/**
* Location of user-editable config files
*
* @param path the path to the config files
* @return this map of options
*/
public JmodOptions config(String path) {
put("--config", path);
return this;
}
/**
* Location of user-editable config files
*
* @param path the path to the config files
* @return this map of options
*/
public JmodOptions config(File path) {
return config(path.getAbsolutePath());
}
/**
* Location of user-editable config files
*
* @param path the path to the config files
* @return this map of options
*/
public JmodOptions config(Path path) {
return config(path.toFile().getAbsolutePath());
}
/**
* Date and time for the timestamps of entries.
*
* @param date the date
* @return this map of options
*/
public JmodOptions date(ZonedDateTime date) {
put("--date", date.truncatedTo(ChronoUnit.SECONDS).format(DateTimeFormatter.ISO_INSTANT));
return this;
}
/**
* Target directory for extract
*
* @param path the directory path
* @return this map of options
*/
public JmodOptions dir(String path) {
put("--dir", path);
return this;
}
/**
* Target directory for extract
*
* @param path the directory path
* @return this map of options
*/
public JmodOptions dir(File path) {
return dir(path.getAbsolutePath());
}
/**
* Target directory for extract
*
* @param path the directory path
* @return this map of options
*/
public JmodOptions dir(Path path) {
return dir(path.toFile().getAbsolutePath());
}
/**
* Exclude from the default root set of modules.
*
* @param doNotResolveByDefault {@code true} to not resolve, {@code false} otherwise
* @return this map of options
*/
public JmodOptions doNotResolveByDefault(boolean doNotResolveByDefault) {
if (doNotResolveByDefault) {
put("--do-not-resolve-by-default");
} else {
remove("--do-not-resolve-by-default");
}
return this;
}
/**
* Dry run of hash mode.
*
* @param dryRun {@code true} for dry run, {@code false} otherwise
* @return this list of operation
*/
public JmodOptions dryRun(boolean dryRun) {
if (dryRun) {
put("--dry-run");
} else {
remove("--dry-run");
}
return this;
}
/**
* Exclude files matching the supplied pattern list.
*
* @param patterns one or more patterns
* @return the map of options
*/
public JmodOptions exclude(List<FilePattern> patterns) {
var args = new ArrayList<String>();
for (var p : patterns) {
if (p.type == FilePatternType.GLOB) {
args.add("glob:" + p.pattern);
} else if (p.type == FilePatternType.REGEX) {
args.add("regex:" + p.pattern);
}
}
put("--exclude", String.join(",", args));
return this;
}
/**
* Exclude files matching the supplied pattern list.
*
* @param patterns one or more patterns
* @return the map of options
*/
public JmodOptions exclude(FilePattern... patterns) {
return exclude(List.of(patterns));
}
/**
* Compute and record hashes to tie a packaged module with modules matching the given regular expression pattern and
* depending upon it directly or indirectly. The hashes are recorded in the JMOD file being created, or a JMOD file
* or modular JAR on the module path specified the jmod hash command.
*
* @param regexPattern the regular expression pattern
* @return this map of options
*/
public JmodOptions hashModules(String regexPattern) {
put("--hash-modules", regexPattern);
return this;
}
/**
* Location of header files.
*
* @param path the location
* @return this map of options
*/
public JmodOptions headerFiles(String path) {
put("--header-files", path);
return this;
}
/**
* Location of header files.
*
* @param path the location
* @return this map of options
*/
@SuppressWarnings("UnusedReturnValue")
public JmodOptions headerFiles(File path) {
return headerFiles(path.getAbsolutePath());
}
/**
* Location of header files.
*
* @param path the location
* @return this map of options
*/
public JmodOptions headerFiles(Path path) {
return headerFiles(path.toFile().getAbsolutePath());
}
/**
* Location of legal notices.
*
* @param path the location
* @return this map of options
*/
public JmodOptions legalNotices(String path) {
put("--legal-notices", path);
return this;
}
/**
* Location of legal notices.
*
* @param path the location
* @return this map of options
*/
@SuppressWarnings("UnusedReturnValue")
public JmodOptions legalNotices(File path) {
return legalNotices(path.getAbsolutePath());
}
/**
* Location of legal notices.
*
* @param path the location
* @return this map of options
*/
public JmodOptions legalNotices(Path path) {
return legalNotices(path.toFile().getAbsolutePath());
}
/**
* Location of native libraries.
*
* @param path the location
* @return this map of options
*/
public JmodOptions libs(String path) {
put("--libs", path);
return this;
}
/**
* Location of native libraries.
*
* @param path the location
* @return this map of options
*/
@SuppressWarnings("UnusedReturnValue")
public JmodOptions libs(File path) {
return libs(path.getAbsolutePath());
}
/**
* Location of native libraries.
*
* @param path the location
* @return this map of options
*/
public JmodOptions libs(Path path) {
return libs(path.toFile().getAbsolutePath());
}
/**
* Main class.
*
* @param name the class name
* @return this list of operation
*/
public JmodOptions mainClass(String name) {
put("--main-class", name);
return this;
}
/**
* Location of man pages.
*
* @param path the location
* @return this map of options
*/
public JmodOptions manPages(String path) {
put("--man-pages", path);
return this;
}
/**
* Location of man pages.
*
* @param path the location
* @return this map of options
*/
@SuppressWarnings("UnusedReturnValue")
public JmodOptions manPages(File path) {
return manPages(path.getAbsolutePath());
}
/**
* Location of man pages.
*
* @param path the location
* @return this map of options
*/
public JmodOptions manPages(Path path) {
return manPages(path.toFile().getAbsolutePath());
}
/**
* Module path.
*
* @param path the module path
* @return this map of options
*/
public JmodOptions modulePath(String path) {
put("--module-path", path);
return this;
}
/**
* Module path.
*
* @param path the module path
* @return this map of options
*/
public JmodOptions modulePath(File path) {
return modulePath(path.getAbsolutePath());
}
/**
* Module path.
*
* @param path the module path
* @return this map of options
*/
public JmodOptions modulePath(Path path) {
return modulePath(path.toFile().getAbsolutePath());
}
/**
* Module version.
*
* @param version the module version.
* @return this map of options
*/
public JmodOptions moduleVersion(String version) {
put("--module-version", version);
return this;
}
/**
* Associates {@code null} with the specified key in this map. If the map previously contained a mapping for the
* key, the old value is replaced.
*
* @param key key with which the specified value is to be associated
*/
public void put(String key) {
put(key, null);
}
/**
* Target platform.
*
* @param platform the platform
* @return this list of operation
*/
public JmodOptions targetPlatform(String platform) {
put("--target-platform", platform);
return this;
}
/**
* Hint for a tool to issue a warning if the module is resolved.
*
* @param reason the reason
* @return this map of options
*/
public JmodOptions warnIfResolved(ResolvedReason reason) {
put("--warn-if-resolved", reason.reason);
return this;
}
/**
* The resolved reasons.
*/
public enum ResolvedReason {
DEPRECATED("deprecated"),
DEPRECATED_FOR_REMOVAL("deprecated-for-removal"),
INCUBATING("incubating");
final String reason;
ResolvedReason(String reason) {
this.reason = reason;
}
}
/**
* The file pattern types.
*/
public enum FilePatternType {
GLOB, REGEX
}
/**
* Defines a file pattern and pattern type.
*
* @param type the pattern type
* @param pattern the pattern
*/
public record FilePattern(FilePatternType type, String pattern) {
}
}

View file

@ -0,0 +1,124 @@
/*
* Copyright 2024 Erik C. Thauvin (https://erik.thauvin.net/)
* Licensed under the Apache License, Version 2.0 (the "License")
*/
package rife.bld.operations;
import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Package self-contained Java applications with the jpackage tool.
*
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @since 2.1.0
*/
public class JpackageOperation extends AbstractToolProviderOperation<JpackageOperation> {
private final JpackageOptions jpackageOptions_ = new JpackageOptions();
private final List<Launcher> launchers_ = new ArrayList<>();
public JpackageOperation() {
super("jpackage");
}
/**
* List of application launchers.
* <p>
* The main application launcher will be built from the command line options.
* <p>
* Additional alternative launchers can be built using this option, and this option can be used to build multiple
* additional launchers.
*
* @param launchers one or more {@link Launcher launchers}
* @return this operation instance
*/
public JpackageOperation addLauncher(List<Launcher> launchers) {
launchers_.addAll(launchers);
return this;
}
/**
* List of application launchers.
* <p>
* The main application launcher will be built from the command line options.
* <p>
* Additional alternative launchers can be built using this option, and this option can be used to build multiple
* additional launchers.
*
* @param launchers one or more {@link Launcher launchers}
* @return this operation instance
*/
public JpackageOperation addLauncher(Launcher... launchers) {
return addLauncher(List.of(launchers));
}
@Override
public void execute() throws Exception {
toolArgs(cmdFiles().stream().map(opt -> '@' + opt).toList());
for (var l : launchers_) {
toolArgs("--add-launcher", l.name + '=' + l.path);
}
toolArgs(jpackageOptions_);
super.execute();
}
/**
* Retrieves the list of options for the jpackage tool.
* <p>
* This is a modifiable list that can be retrieved and changed.
*
* @return the map of jpackage options
*/
public JpackageOptions jpackageOptions() {
return jpackageOptions_;
}
/**
* Provides a list of options to provide to the jpackage tool.
* <p>
* A copy will be created to allow this list to be independently modifiable.
*
* @param options the map of jpackage options
* @return this operation instance
*/
public JpackageOperation jpackageOptions(Map<String, String> options) {
jpackageOptions_.putAll(options);
return this;
}
/**
* Retrieves the list of application launchers.
*
* @return the list of launchers
*/
public List<Launcher> launchers() {
return launchers_;
}
/**
* Name of launcher, and a path to a Properties file that contains a list of key, value pairs.
* <p>
* The keys {@code module}, {@code main-jar}, {@code main-class}, {@code description},
* {@code arguments}, {@code java-options}, {@code app-version}, {@code icon},
* {@code launcher-as-service}, {@code win-console}, {@code win-shortcut}, {@code win-menu},
* {@code linux-app-category}, and {@code linux-shortcut} can be used.
* <p>
* These options are added to, or used to overwrite, the original command line options to build an additional
* alternative launcher.
*
* @param name the name
* @param path absolute path or relative to the current directory
*/
public record Launcher(String name, String path) {
public Launcher(String name, File path) {
this(name, path.getAbsolutePath());
}
public Launcher(String name, Path path) {
this(name, path.toFile().getAbsolutePath());
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -9,6 +9,7 @@ import rife.bld.BldVersion;
import rife.bld.dependencies.*; import rife.bld.dependencies.*;
import rife.bld.dependencies.exceptions.DependencyException; import rife.bld.dependencies.exceptions.DependencyException;
import rife.bld.operations.exceptions.OperationOptionException; import rife.bld.operations.exceptions.OperationOptionException;
import rife.bld.operations.exceptions.RestApiException;
import rife.bld.operations.exceptions.SignException; import rife.bld.operations.exceptions.SignException;
import rife.bld.operations.exceptions.UploadException; import rife.bld.operations.exceptions.UploadException;
import rife.bld.publish.*; import rife.bld.publish.*;
@ -27,7 +28,9 @@ import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Pattern;
import static rife.bld.dependencies.Dependency.*;
import static rife.bld.publish.MetadataBuilder.SNAPSHOT_TIMESTAMP_FORMATTER; import static rife.bld.publish.MetadataBuilder.SNAPSHOT_TIMESTAMP_FORMATTER;
import static rife.tools.HttpUtils.*; import static rife.tools.HttpUtils.*;
import static rife.tools.StringUtils.encodeHexLower; import static rife.tools.StringUtils.encodeHexLower;
@ -39,6 +42,9 @@ import static rife.tools.StringUtils.encodeHexLower;
* @since 1.5.7 * @since 1.5.7
*/ */
public class PublishOperation extends AbstractOperation<PublishOperation> { public class PublishOperation extends AbstractOperation<PublishOperation> {
private static final String OSSRH_STAGING_MANUAL_SEARCH = "https://" + Repository.OSSRH_STAGING_API_DOMAIN + "/manual/search/repositories";
private static final String OSSRH_STAGING_MANUAL_UPLOAD = "https://" + Repository.OSSRH_STAGING_API_DOMAIN + "/manual/upload/repository/";
private boolean offline_ = false; private boolean offline_ = false;
private HierarchicalProperties properties_ = null; private HierarchicalProperties properties_ = null;
private ArtifactRetriever retriever_ = null; private ArtifactRetriever retriever_ = null;
@ -86,6 +92,11 @@ public class PublishOperation extends AbstractOperation<PublishOperation> {
executePublishArtifacts(repository, actual_version); executePublishArtifacts(repository, actual_version);
executePublishPom(repository, actual_version); executePublishPom(repository, actual_version);
executePublishMetadata(repository, moment); executePublishMetadata(repository, moment);
if (!info().version().isSnapshot() &&
repository.location().contains(Repository.OSSRH_STAGING_API_DOMAIN)) {
executeCloseOSSRHStagingRepository(repository);
}
} }
if (!silent()) { if (!silent()) {
System.out.println("Publishing finished successfully."); System.out.println("Publishing finished successfully.");
@ -132,14 +143,18 @@ public class PublishOperation extends AbstractOperation<PublishOperation> {
var resolution = new VersionResolution(properties()); var resolution = new VersionResolution(properties());
var resolver = new DependencyResolver(resolution, artifactRetriever(), List.of(repository), new Dependency(info().groupId(), info().artifactId(), info().version())); var resolver = new DependencyResolver(resolution, artifactRetriever(), List.of(repository), new Dependency(info().groupId(), info().artifactId(), info().version()));
var snapshot_meta = resolver.getSnapshotMavenMetadata(); var snapshot_meta = resolver.getSnapshotMavenMetadata();
snapshot_build_number = snapshot_meta.getSnapshotBuildNumber() + 1; var build_number_meta = snapshot_meta.getSnapshotBuildNumber();
if (build_number_meta == null) {
throw new DependencyException("Snapshot metadata build number doesn't exist.");
}
snapshot_build_number = build_number_meta + 1;
} catch (DependencyException e) { } catch (DependencyException e) {
// start the build number from the beginning // start the build number from the beginning
System.out.println("Unable to retrieve previous snapshot metadata, using first build number."); System.out.println("Unable to retrieve previous snapshot metadata, using first build number.");
System.out.println("This is expected for a first publication or for publication to a staging repository."); System.out.println("This is expected for a first publication or for publication to a staging repository.");
} }
// adapt the actual version that's use by the artifacts // adapt the actual version used by the artifacts
var snapshot_qualifier = snapshot_timestamp + "-" + snapshot_build_number; var snapshot_qualifier = snapshot_timestamp + "-" + snapshot_build_number;
actual_version = info().version().withQualifier(snapshot_qualifier); actual_version = info().version().withQualifier(snapshot_qualifier);
@ -160,7 +175,7 @@ public class PublishOperation extends AbstractOperation<PublishOperation> {
.info(info()) .info(info())
.updated(moment) .updated(moment)
.build(), .build(),
info().version() + "/" + repository.getMetadataName(), true); info().version() + "/" + repository.getMetadataName(), false);
return actual_version; return actual_version;
} }
@ -180,8 +195,8 @@ public class PublishOperation extends AbstractOperation<PublishOperation> {
artifact_name.append('-').append(artifact.classifier()); artifact_name.append('-').append(artifact.classifier());
} }
var type = artifact.type(); var type = artifact.type();
if (type == null) { if (TYPE_JAR.equals(type) || TYPE_MODULAR_JAR.equals(type) || TYPE_CLASSPATH_JAR.equals(type)) {
type = "jar"; type = TYPE_JAR;
} }
artifact_name.append('.').append(type); artifact_name.append('.').append(type);
@ -469,12 +484,8 @@ public class PublishOperation extends AbstractOperation<PublishOperation> {
var builder = HttpRequest.newBuilder() var builder = HttpRequest.newBuilder()
.PUT(body) .PUT(body)
.uri(URI.create(url)) .uri(URI.create(url))
.header(HEADER_USER_AGENT, "bld/" + BldVersion.getVersion() + .header(HEADER_USER_AGENT, constructBldUserAgent());
" (" + System.getProperty("os.name") + "; " + System.getProperty("os.version") + "; " + System.getProperty("os.arch") + ") " + applyAuthorization(repository, builder);
"(" + System.getProperty("java.vendor") + " " + System.getProperty("java.vm.name") + "; " + System.getProperty("java.version") + "; " + System.getProperty("java.vm.version") + ")");
if (repository.username() != null && repository.password() != null) {
builder.header(HEADER_AUTHORIZATION, basicAuthorizationHeader(repository.username(), repository.password()));
}
var request = builder.build(); var request = builder.build();
HttpResponse<String> response; HttpResponse<String> response;
@ -500,6 +511,105 @@ public class PublishOperation extends AbstractOperation<PublishOperation> {
} }
} }
private static String constructBldUserAgent() {
return "bld/" + BldVersion.getVersion() +
" (" + System.getProperty("os.name") + "; " + System.getProperty("os.version") + "; " + System.getProperty("os.arch") + ") " +
"(" + System.getProperty("java.vendor") + " " + System.getProperty("java.vm.name") + "; " + System.getProperty("java.version") + "; " + System.getProperty("java.vm.version") + ")";
}
private static void applyAuthorization(Repository repository, HttpRequest.Builder builder) {
if (repository.username() != null && repository.password() != null) {
builder.header(HEADER_AUTHORIZATION, basicAuthorizationHeader(repository.username(), repository.password()));
}
}
/**
* Part of the {@link #execute} operation, closes the OSSRH staging API repository.
*
* @param repository the repository to close a staging repository in
* @since 2.2.2
*/
protected void executeCloseOSSRHStagingRepository(Repository repository) {
var url_search = OSSRH_STAGING_MANUAL_SEARCH;
System.out.print("Finding open staging repositories at: " + url_search + " ... ");
System.out.flush();
try {
var builder_search = HttpRequest.newBuilder()
.GET()
.uri(URI.create(url_search))
.header(HEADER_USER_AGENT, constructBldUserAgent());
applyAuthorization(repository, builder_search);
var request_list = builder_search.build();
HttpResponse<String> response_search;
try {
response_search = client_.send(request_list, HttpResponse.BodyHandlers.ofString());
} catch (IOException e) {
System.out.print("I/O error");
throw new RestApiException(url_search, e);
} catch (InterruptedException e) {
System.out.print("interrupted");
throw new RestApiException(url_search, e);
}
if (response_search.statusCode() >= 200 &&
response_search.statusCode() < 300) {
System.out.println("done");
var pattern_key = Pattern.compile("\\{\\s*\"key\"\\s*:\\s*\"([^\"]+)\"\\s*,\\s*\"state\"\\s*:\\s*\"open\"");
var matcher_key = pattern_key.matcher(response_search.body());
if (matcher_key.find()) {
var key = matcher_key.group(1);
System.out.println("Found open staging repository with key: " + key);
var url_close = OSSRH_STAGING_MANUAL_UPLOAD + key;
System.out.print("Closing the staging repository at: " + url_close + " ... ");
System.out.flush();
var builder_close = HttpRequest.newBuilder()
.POST(BodyPublishers.ofString(""))
.uri(URI.create(url_close))
.header(HEADER_USER_AGENT, constructBldUserAgent());
applyAuthorization(repository, builder_close);
var request_close = builder_close.build();
HttpResponse<String> response_close;
try {
response_close = client_.send(request_close, HttpResponse.BodyHandlers.ofString());
} catch (IOException e) {
System.out.print("I/O error");
throw new RestApiException(url_close, e);
} catch (InterruptedException e) {
System.out.print("interrupted");
throw new RestApiException(url_close, e);
}
if (response_close.statusCode() >= 200 &&
response_close.statusCode() < 300) {
System.out.print("done");
} else {
System.out.println("failed");
var pattern_error = Pattern.compile("\\s*\"error\"\\s*:\\s*\"([^\"]*)\"");
var matcher_error = pattern_error.matcher(response_close.body());
if (matcher_error.find()) {
var error = matcher_error.group(1);
System.out.print(error.translateEscapes());
}
throw new RestApiException(url_close, response_close.statusCode());
}
}
else {
System.out.print("No open staging repository found.");
throw new RestApiException(url_search);
}
} else {
System.out.print("failed");
throw new RestApiException(url_search, response_search.statusCode());
}
} finally {
System.out.println();
}
}
/** /**
* Configures a publish operation from a {@link BaseProject}. * Configures a publish operation from a {@link BaseProject}.
* *
@ -517,9 +627,9 @@ public class PublishOperation extends AbstractOperation<PublishOperation> {
artifactRetriever(project.artifactRetriever()); artifactRetriever(project.artifactRetriever());
dependencies().include(project.dependencies()); dependencies().include(project.dependencies());
artifacts(List.of( artifacts(List.of(
new PublishArtifact(new File(project.buildDistDirectory(), project.jarFileName()), "", "jar"), new PublishArtifact(new File(project.buildDistDirectory(), project.jarFileName()), "", TYPE_JAR),
new PublishArtifact(new File(project.buildDistDirectory(), project.sourcesJarFileName()), "sources", "jar"), new PublishArtifact(new File(project.buildDistDirectory(), project.sourcesJarFileName()), CLASSIFIER_SOURCES, TYPE_JAR),
new PublishArtifact(new File(project.buildDistDirectory(), project.javadocJarFileName()), "javadoc", "jar"))); new PublishArtifact(new File(project.buildDistDirectory(), project.javadocJarFileName()), CLASSIFIER_JAVADOC, TYPE_JAR)));
if (info().groupId() == null) { if (info().groupId() == null) {
info().groupId(project.pkg()); info().groupId(project.pkg());
} }

View file

@ -31,10 +31,15 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
private final List<Repository> repositories_ = new ArrayList<>(); private final List<Repository> repositories_ = new ArrayList<>();
private final DependencyScopes dependencies_ = new DependencyScopes(); private final DependencyScopes dependencies_ = new DependencyScopes();
private File libCompileDirectory_; private File libCompileDirectory_;
private File libCompileModulesDirectory_;
private File libProvidedDirectory_; private File libProvidedDirectory_;
private File libProvidedModulesDirectory_;
private File libRuntimeDirectory_; private File libRuntimeDirectory_;
private File libRuntimeModulesDirectory_;
private File libStandaloneDirectory_; private File libStandaloneDirectory_;
private File libStandaloneModulesDirectory_;
private File libTestDirectory_; private File libTestDirectory_;
private File libTestModulesDirectory_;
private boolean preserveSources_ = false; private boolean preserveSources_ = false;
private boolean preserveJavadoc_ = false; private boolean preserveJavadoc_ = false;
@ -65,7 +70,7 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
* @since 1.5 * @since 1.5
*/ */
protected void executePurgeCompileDependencies() { protected void executePurgeCompileDependencies() {
executePurgeDependencies(libCompileDirectory(), dependencies().resolveCompileDependencies(properties(), artifactRetriever(), repositories())); executePurgeDependencies(libCompileDirectory(), libCompileModulesDirectory(), dependencies().resolveCompileDependencies(properties(), artifactRetriever(), repositories()));
} }
/** /**
@ -74,7 +79,7 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
* @since 1.8 * @since 1.8
*/ */
protected void executePurgeProvidedDependencies() { protected void executePurgeProvidedDependencies() {
executePurgeDependencies(libProvidedDirectory(), dependencies().resolveProvidedDependencies(properties(), artifactRetriever(), repositories())); executePurgeDependencies(libProvidedDirectory(), libProvidedModulesDirectory(), dependencies().resolveProvidedDependencies(properties(), artifactRetriever(), repositories()));
} }
/** /**
@ -83,7 +88,7 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
* @since 1.5 * @since 1.5
*/ */
protected void executePurgeRuntimeDependencies() { protected void executePurgeRuntimeDependencies() {
executePurgeDependencies(libRuntimeDirectory(), dependencies().resolveRuntimeDependencies(properties(), artifactRetriever(), repositories())); executePurgeDependencies(libRuntimeDirectory(), libRuntimeModulesDirectory(), dependencies().resolveRuntimeDependencies(properties(), artifactRetriever(), repositories()));
} }
/** /**
@ -92,7 +97,7 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
* @since 1.5 * @since 1.5
*/ */
protected void executePurgeStandaloneDependencies() { protected void executePurgeStandaloneDependencies() {
executePurgeDependencies(libStandaloneDirectory(), dependencies().resolveStandaloneDependencies(properties(), artifactRetriever(), repositories())); executePurgeDependencies(libStandaloneDirectory(), libStandaloneModulesDirectory(), dependencies().resolveStandaloneDependencies(properties(), artifactRetriever(), repositories()));
} }
/** /**
@ -101,40 +106,59 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
* @since 1.5 * @since 1.5
*/ */
protected void executePurgeTestDependencies() { protected void executePurgeTestDependencies() {
executePurgeDependencies(libTestDirectory(), dependencies().resolveTestDependencies(properties(), artifactRetriever(), repositories())); executePurgeDependencies(libTestDirectory(), libTestModulesDirectory(), dependencies().resolveTestDependencies(properties(), artifactRetriever(), repositories()));
} }
/** /**
* Part of the {@link #execute} operation, purge the artifacts for a particular dependency scope. * Part of the {@link #execute} operation, purge the artifacts for a particular dependency scope.
* *
* @param destinationDirectory the directory from which the artifacts should be purged * @param classpathDirectory the directory from which the artifacts should be purged
* @param dependencies the dependencies to purge * @param modulesDirectory the directory from which the modules should be purged
* @since 1.6 * @param dependencies the dependencies to purge
* @since 2.1
*/ */
protected void executePurgeDependencies(File destinationDirectory, DependencySet dependencies) { protected void executePurgeDependencies(File classpathDirectory, File modulesDirectory, DependencySet dependencies) {
if (destinationDirectory == null) { if (classpathDirectory == null && modulesDirectory == null) {
return; return;
} }
var filenames = new HashSet<String>();
var classpath_names = new HashSet<String>();
var modules_names = new HashSet<String>();
for (var dependency : dependencies) { for (var dependency : dependencies) {
var filenames = classpath_names;
if (dependency.isModularJar()) {
filenames = modules_names;
}
addTransferLocations(filenames, dependency); addTransferLocations(filenames, dependency);
if (preserveSources_) { if (preserveSources_ && !dependency.excludedClassifiers().contains(CLASSIFIER_SOURCES)) {
addTransferLocations(filenames, dependency.withClassifier(CLASSIFIER_SOURCES)); addTransferLocations(filenames, dependency.withClassifier(CLASSIFIER_SOURCES));
} }
if (preserveJavadoc_) { if (preserveJavadoc_ && !dependency.excludedClassifiers().contains(CLASSIFIER_JAVADOC)) {
addTransferLocations(filenames, dependency.withClassifier(CLASSIFIER_JAVADOC)); addTransferLocations(filenames, dependency.withClassifier(CLASSIFIER_JAVADOC));
} }
} }
purgeFromDirectory(classpathDirectory, modulesDirectory, classpath_names);
purgeFromDirectory(modulesDirectory, classpathDirectory, modules_names);
}
private static void purgeFromDirectory(File directory, File preserveDirectory, HashSet<String> preservedFileNames) {
if (directory == null) {
return;
}
boolean printed_header = false; boolean printed_header = false;
for (var file : destinationDirectory.listFiles()) { var classpath_files = directory.listFiles();
if (!filenames.contains(file.getName())) { if (classpath_files != null) {
if (!printed_header) { for (var file : classpath_files) {
printed_header = true; if (!preservedFileNames.contains(file.getName()) && !file.equals(preserveDirectory)) {
System.out.println("Deleting from " + destinationDirectory.getName() + ":"); if (!printed_header) {
printed_header = true;
System.out.println("Deleting from " + directory.getName() + ":");
}
System.out.println(" " + file.getName());
file.delete();
} }
System.out.println(" " + file.getName());
file.delete();
} }
} }
} }
@ -159,10 +183,15 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
.repositories(project.repositories()) .repositories(project.repositories())
.dependencies(project.dependencies()) .dependencies(project.dependencies())
.libCompileDirectory(project.libCompileDirectory()) .libCompileDirectory(project.libCompileDirectory())
.libCompileModulesDirectory(project.libCompileModulesDirectory())
.libProvidedDirectory(project.libProvidedDirectory()) .libProvidedDirectory(project.libProvidedDirectory())
.libProvidedModulesDirectory(project.libProvidedModulesDirectory())
.libRuntimeDirectory(project.libRuntimeDirectory()) .libRuntimeDirectory(project.libRuntimeDirectory())
.libRuntimeModulesDirectory(project.libRuntimeModulesDirectory())
.libStandaloneDirectory(project.libStandaloneDirectory()) .libStandaloneDirectory(project.libStandaloneDirectory())
.libStandaloneModulesDirectory(project.libStandaloneModulesDirectory())
.libTestDirectory(project.libTestDirectory()) .libTestDirectory(project.libTestDirectory())
.libTestModulesDirectory(project.libTestModulesDirectory())
.preserveSources(project.downloadSources()) .preserveSources(project.downloadSources())
.preserveJavadoc(project.downloadJavadoc()); .preserveJavadoc(project.downloadJavadoc());
} }
@ -267,6 +296,18 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
return this; return this;
} }
/**
* Provides the {@code compile} scope modules purge directory.
*
* @param directory the directory to purge the {@code compile} scope modules from
* @return this operation instance
* @since 2.1
*/
public PurgeOperation libCompileModulesDirectory(File directory) {
libCompileModulesDirectory_ = directory;
return this;
}
/** /**
* Provides the {@code provided} scope purge directory. * Provides the {@code provided} scope purge directory.
* *
@ -279,6 +320,18 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
return this; return this;
} }
/**
* Provides the {@code provided} scope modules purge directory.
*
* @param directory the directory to purge the {@code provided} scope modules from
* @return this operation instance
* @since 2.1
*/
public PurgeOperation libProvidedModulesDirectory(File directory) {
libProvidedModulesDirectory_ = directory;
return this;
}
/** /**
* Provides the {@code runtime} scope purge directory. * Provides the {@code runtime} scope purge directory.
* *
@ -291,6 +344,18 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
return this; return this;
} }
/**
* Provides the {@code runtime} scope modules purge directory.
*
* @param directory the directory to purge the {@code runtime} scope modules from
* @return this operation instance
* @since 2.1
*/
public PurgeOperation libRuntimeModulesDirectory(File directory) {
libRuntimeModulesDirectory_ = directory;
return this;
}
/** /**
* Provides the {@code standalone} scope purge directory. * Provides the {@code standalone} scope purge directory.
* *
@ -303,6 +368,18 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
return this; return this;
} }
/**
* Provides the {@code standalone} scope modules purge directory.
*
* @param directory the directory to purge the {@code standalone} scope modules from
* @return this operation instance
* @since 2.1
*/
public PurgeOperation libStandaloneModulesDirectory(File directory) {
libStandaloneModulesDirectory_ = directory;
return this;
}
/** /**
* Provides the {@code test} scope purge directory. * Provides the {@code test} scope purge directory.
* *
@ -315,6 +392,18 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
return this; return this;
} }
/**
* Provides the {@code test} scope modules purge directory.
*
* @param directory the directory to purge the {@code test} scope modules from
* @return this operation instance
* @since 2.1
*/
public PurgeOperation libTestModulesDirectory(File directory) {
libTestModulesDirectory_ = directory;
return this;
}
/** /**
* Provides the artifact retriever to use. * Provides the artifact retriever to use.
* *
@ -373,6 +462,16 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
return libCompileDirectory_; return libCompileDirectory_;
} }
/**
* Retrieves the {@code compile} scope modules purge directory.
*
* @return the {@code compile} scope modules purge directory
* @since 2.1
*/
public File libCompileModulesDirectory() {
return libCompileModulesDirectory_;
}
/** /**
* Retrieves the {@code provided} scope purge directory. * Retrieves the {@code provided} scope purge directory.
* *
@ -383,6 +482,16 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
return libProvidedDirectory_; return libProvidedDirectory_;
} }
/**
* Retrieves the {@code provided} scope modules purge directory.
*
* @return the {@code provided} scope modules purge directory
* @since 2.1
*/
public File libProvidedModulesDirectory() {
return libProvidedModulesDirectory_;
}
/** /**
* Retrieves the {@code runtime} scope purge directory. * Retrieves the {@code runtime} scope purge directory.
* *
@ -393,6 +502,16 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
return libRuntimeDirectory_; return libRuntimeDirectory_;
} }
/**
* Retrieves the {@code runtime} scope modules purge directory.
*
* @return the {@code runtime} scope modules purge directory
* @since 2.1
*/
public File libRuntimeModulesDirectory() {
return libRuntimeModulesDirectory_;
}
/** /**
* Retrieves the {@code standalone} scope purge directory. * Retrieves the {@code standalone} scope purge directory.
* *
@ -403,6 +522,16 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
return libStandaloneDirectory_; return libStandaloneDirectory_;
} }
/**
* Retrieves the {@code standalone} scope modules purge directory.
*
* @return the {@code standalone} scope modules purge directory
* @since 2.1
*/
public File libStandaloneModulesDirectory() {
return libStandaloneModulesDirectory_;
}
/** /**
* Retrieves the {@code test} scope purge directory. * Retrieves the {@code test} scope purge directory.
* *
@ -413,6 +542,16 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
return libTestDirectory_; return libTestDirectory_;
} }
/**
* Retrieves the {@code test} scope modules purge directory.
*
* @return the {@code test} scope modules purge directory
* @since 2.1
*/
public File libTestModulesDirectory() {
return libTestModulesDirectory_;
}
/** /**
* Retrieves whether the sources classifier files should be preserved. * Retrieves whether the sources classifier files should be preserved.
* *

View file

@ -31,12 +31,30 @@ public class RunOperation extends AbstractProcessOperation<RunOperation> {
var args = new ArrayList<String>(); var args = new ArrayList<String>();
args.add(javaTool()); args.add(javaTool());
args.addAll(javaOptions()); args.addAll(javaOptions());
if (!classpath().isEmpty()) { if (!classpath().isEmpty()) {
args.add("-cp"); args.add("-cp");
args.add(FileUtils.joinPaths(classpath())); args.add(FileUtils.joinPaths(classpath()));
} }
args.add(mainClass());
if (!modulePath().isEmpty()) {
args.add("-p");
args.add(FileUtils.joinPaths(modulePath()));
}
if (module() != null && !module().isEmpty()) {
args.add("-m");
args.add(module());
}
else if (mainClass() != null && !mainClass().isEmpty()){
args.add(mainClass());
}
else if (!silent()) {
System.err.println("No main class or module specified.");
}
args.addAll(runOptions()); args.addAll(runOptions());
return args; return args;
} }
@ -50,7 +68,9 @@ public class RunOperation extends AbstractProcessOperation<RunOperation> {
var operation = workDirectory(project.workDirectory()) var operation = workDirectory(project.workDirectory())
.javaTool(project.javaTool()) .javaTool(project.javaTool())
.classpath(project.runClasspath()) .classpath(project.runClasspath())
.mainClass(project.mainClass()); .modulePath(project.runModulePath())
.mainClass(project.mainClass())
.module(project.module());
if (project.usesRife2Agent()) { if (project.usesRife2Agent()) {
operation.javaOptions().javaAgent(project.getRife2AgentFile()); operation.javaOptions().javaAgent(project.getRife2AgentFile());
} }

View file

@ -51,8 +51,14 @@ public class TestOperation<T extends TestOperation<T, O>, O extends List<String>
var args = new ArrayList<String>(); var args = new ArrayList<String>();
args.add(javaTool()); args.add(javaTool());
args.addAll(javaOptions()); args.addAll(javaOptions());
args.add("-cp"); if (!classpath().isEmpty()) {
args.add(FileUtils.joinPaths(classpath())); args.add("-cp");
args.add(FileUtils.joinPaths(classpath()));
}
if (!modulePath().isEmpty()) {
args.add("-p");
args.add(FileUtils.joinPaths(modulePath()));
}
args.add(mainClass()); args.add(mainClass());
args.addAll(testToolOptions()); args.addAll(testToolOptions());
@ -68,7 +74,8 @@ public class TestOperation<T extends TestOperation<T, O>, O extends List<String>
public T fromProject(BaseProject project) { public T fromProject(BaseProject project) {
var operation = workDirectory(project.workDirectory()) var operation = workDirectory(project.workDirectory())
.javaTool(project.javaTool()) .javaTool(project.javaTool())
.classpath(project.testClasspath()); .classpath(project.testClasspath())
.modulePath(project.testModulePath());
if (project.usesRife2Agent()) { if (project.usesRife2Agent()) {
operation.javaOptions().javaAgent(project.getRife2AgentFile()); operation.javaOptions().javaAgent(project.getRife2AgentFile());
} }

View file

@ -0,0 +1,30 @@
/**
* Copyright 2024 Erik C. Thauvin (https://erik.thauvin.net/)
* Licensed under the Apache License, Version 2.0 (the "License")
*/
package rife.bld.operations;
/**
* The zip compression levels for jlink and jmod.
*
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @since 2.1.0
*/
public enum ZipCompression {
ZIP_0("zip-0"),
ZIP_1("zip-1"),
ZIP_2("zip-2"),
ZIP_3("zip-3"),
ZIP_4("zip-4"),
ZIP_5("zip-5"),
ZIP_6("zip-6"),
ZIP_7("zip-7"),
ZIP_8("zip-8"),
ZIP_9("zip-9");
public final String level;
ZipCompression(String level) {
this.level = level;
}
}

View file

@ -0,0 +1,40 @@
/*
* Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
* Licensed under the Apache License, Version 2.0 (the "License")
*/
package rife.bld.operations.exceptions;
import rife.tools.HttpUtils;
import java.io.Serial;
/**
* When thrown, indicates that something went wrong during the use of a rest API call.
*
* @author Geert Bevin (gbevin[remove] at uwyn dot com)
* @since 2.2.2
*/
public class RestApiException extends RuntimeException {
@Serial private static final long serialVersionUID = -6753423938407177328L;
private final String url_;
public RestApiException(String url, int status) {
super("An error occurred while using rest API at '" + url + "'\nHTTP status code " + status + " : " + HttpUtils.statusReason(status));
url_ = url;
}
public RestApiException(String url, Throwable cause) {
super("An error occurred while using rest API at '" + url + "'", cause);
url_ = url;
}
public RestApiException(String url) {
super("An error occurred while using rest API at '" + url + "'");
url_ = url;
}
public String getUrl() {
return url_;
}
}

View file

@ -14,6 +14,8 @@ import rife.tools.exceptions.FileUtilsErrorException;
import java.io.File; import java.io.File;
import java.util.Objects; import java.util.Objects;
import static rife.bld.dependencies.Dependency.TYPE_JAR;
/** /**
* Provides the functionalities to build a Maven POM xml file. * Provides the functionalities to build a Maven POM xml file.
* *
@ -186,7 +188,7 @@ public class PomBuilder {
t.blankValue("dependency-type"); t.blankValue("dependency-type");
t.blankValue("dependency-type-tag"); t.blankValue("dependency-type-tag");
if (!"jar".equals(dependency.type())) { if (!TYPE_JAR.equals(dependency.type())) {
t.setValueEncoded("dependency-type", dependency.type()); t.setValueEncoded("dependency-type", dependency.type());
t.setBlock("dependency-type-tag"); t.setBlock("dependency-type-tag");
} }

View file

@ -6,6 +6,8 @@ package rife.bld.publish;
import java.io.File; import java.io.File;
import static rife.bld.dependencies.Dependency.TYPE_JAR;
/** /**
* Contains the information about an artifact that will be published. * Contains the information about an artifact that will be published.
* *
@ -19,6 +21,6 @@ public record PublishArtifact(File file, String classifier, String type) {
public PublishArtifact(File file, String classifier, String type) { public PublishArtifact(File file, String classifier, String type) {
this.file = file; this.file = file;
this.classifier = (classifier == null ? "" : classifier); this.classifier = (classifier == null ? "" : classifier);
this.type = (type == null ? "jar" : type); this.type = (type == null ? TYPE_JAR : type);
} }
} }

View file

@ -45,9 +45,9 @@ public class Wrapper {
public static final String WRAPPER_PROPERTIES = WRAPPER_PREFIX + ".properties"; public static final String WRAPPER_PROPERTIES = WRAPPER_PREFIX + ".properties";
static final String MAVEN_CENTRAL = "https://repo1.maven.org/maven2/"; static final String MAVEN_CENTRAL = "https://repo1.maven.org/maven2/";
static final String SONATYPE_SNAPSHOTS = "https://s01.oss.sonatype.org/content/repositories/snapshots/"; static final String CENTRAL_SNAPSHOTS = "https://central.sonatype.com/repository/maven-snapshots/";
static final String DOWNLOAD_LOCATION = MAVEN_CENTRAL + "com/uwyn/rife2/bld/${version}/"; static final String DOWNLOAD_LOCATION = MAVEN_CENTRAL + "com/uwyn/rife2/bld/${version}/";
static final String DOWNLOAD_LOCATION_SNAPSHOT = SONATYPE_SNAPSHOTS + "com/uwyn/rife2/bld/${version}/"; static final String DOWNLOAD_LOCATION_SNAPSHOT = CENTRAL_SNAPSHOTS + "com/uwyn/rife2/bld/${version}/";
static final String BLD_CACHE = "bld.cache"; static final String BLD_CACHE = "bld.cache";
static final String BLD_FILENAME = "bld-${version}.jar"; static final String BLD_FILENAME = "bld-${version}.jar";
static final String BLD_SOURCES_FILENAME = "bld-${version}-sources.jar"; static final String BLD_SOURCES_FILENAME = "bld-${version}-sources.jar";
@ -120,6 +120,10 @@ public class Wrapper {
private static final Pattern BLD_JAR_PATTERN = Pattern.compile("/\\.bld/dist/bld-[^\"/!]+(?<!sources)\\.jar"); private static final Pattern BLD_JAR_PATTERN = Pattern.compile("/\\.bld/dist/bld-[^\"/!]+(?<!sources)\\.jar");
private static final Pattern BLD_SOURCES_JAR_PATTERN = Pattern.compile("/\\.bld/dist/bld-[^\"/!]+-sources\\.jar"); private static final Pattern BLD_SOURCES_JAR_PATTERN = Pattern.compile("/\\.bld/dist/bld-[^\"/!]+-sources\\.jar");
private static final Pattern BLD_PROPERTY_VERSION_PATTERN = Pattern.compile(".*bld\\.version.*"); private static final Pattern BLD_PROPERTY_VERSION_PATTERN = Pattern.compile(".*bld\\.version.*");
private static final Pattern JAR_DIRECTORY_LIB_COMPILE_RECURSIVE_PATTERN = Pattern.compile("<jarDirectory\\s+url=\"file://\\$PROJECT_DIR\\$/lib/compile\"\\s+recursive=\"false\"");
private static final Pattern JAR_DIRECTORY_LIB_PROVIDED_RECURSIVE_PATTERN = Pattern.compile("<jarDirectory\\s+url=\"file://\\$PROJECT_DIR\\$/lib/provided\"\\s+recursive=\"false\"");
private static final Pattern JAR_DIRECTORY_LIB_RUNTIME_RECURSIVE_PATTERN = Pattern.compile("<jarDirectory\\s+url=\"file://\\$PROJECT_DIR\\$/lib/runtime\"\\s+recursive=\"false\"");
private static final Pattern JAR_DIRECTORY_LIB_TEST_RECURSIVE_PATTERN = Pattern.compile("<jarDirectory\\s+url=\"file://\\$PROJECT_DIR\\$/lib/test\"\\s+recursive=\"false\"");
/** /**
* Upgraded the IDEA bld files that were generated with a previous version. * Upgraded the IDEA bld files that were generated with a previous version.
@ -131,15 +135,50 @@ public class Wrapper {
*/ */
public void upgradeIdeaBldLibrary(File destinationDirectory, String version) public void upgradeIdeaBldLibrary(File destinationDirectory, String version)
throws IOException { throws IOException {
var file = new File(destinationDirectory, Path.of("libraries", "bld.xml").toString()); var libraries_bld = new File(destinationDirectory, Path.of("libraries", "bld.xml").toString());
if (file.exists()) { if (libraries_bld.exists()) {
try { try {
var content = FileUtils.readString(file); var content = FileUtils.readString(libraries_bld);
content = BLD_JAR_PATTERN.matcher(content).replaceAll("/.bld/dist/bld-" + version + ".jar"); content = BLD_JAR_PATTERN.matcher(content).replaceAll("/.bld/dist/bld-" + version + ".jar");
content = BLD_SOURCES_JAR_PATTERN.matcher(content).replaceAll("/.bld/dist/bld-" + version + "-sources.jar"); content = BLD_SOURCES_JAR_PATTERN.matcher(content).replaceAll("/.bld/dist/bld-" + version + "-sources.jar");
content = RIFE2_JAR_PATTERN.matcher(content).replaceAll("/.bld/dist/bld-" + version + ".jar"); content = RIFE2_JAR_PATTERN.matcher(content).replaceAll("/.bld/dist/bld-" + version + ".jar");
content = RIFE2_SOURCES_JAR_PATTERN.matcher(content).replaceAll("/.bld/dist/bld-" + version + "-sources.jar"); content = RIFE2_SOURCES_JAR_PATTERN.matcher(content).replaceAll("/.bld/dist/bld-" + version + "-sources.jar");
FileUtils.writeString(content, file); FileUtils.writeString(content, libraries_bld);
} catch (FileUtilsErrorException e) {
throw new IOException(e);
}
}
var libraries_compile = new File(destinationDirectory, Path.of("libraries", "compile.xml").toString());
if (libraries_compile.exists()) {
try {
var content = FileUtils.readString(libraries_compile);
content = JAR_DIRECTORY_LIB_COMPILE_RECURSIVE_PATTERN.matcher(content).replaceAll("<jarDirectory url=\"file://\\$PROJECT_DIR\\$/lib/compile\" recursive=\"true\"");
content = JAR_DIRECTORY_LIB_PROVIDED_RECURSIVE_PATTERN.matcher(content).replaceAll("<jarDirectory url=\"file://\\$PROJECT_DIR\\$/lib/provided\" recursive=\"true\"");
FileUtils.writeString(content, libraries_compile);
} catch (FileUtilsErrorException e) {
throw new IOException(e);
}
}
var libraries_runtime = new File(destinationDirectory, Path.of("libraries", "runtime.xml").toString());
if (libraries_runtime.exists()) {
try {
var content = FileUtils.readString(libraries_runtime);
content = JAR_DIRECTORY_LIB_RUNTIME_RECURSIVE_PATTERN.matcher(content).replaceAll("<jarDirectory url=\"file://\\$PROJECT_DIR\\$/lib/runtime\" recursive=\"true\"");
FileUtils.writeString(content, libraries_runtime);
} catch (FileUtilsErrorException e) {
throw new IOException(e);
}
}
var libraries_test = new File(destinationDirectory, Path.of("libraries", "test.xml").toString());
if (libraries_test.exists()) {
try {
var content = FileUtils.readString(libraries_test);
content = JAR_DIRECTORY_LIB_PROVIDED_RECURSIVE_PATTERN.matcher(content).replaceAll("<jarDirectory url=\"file://\\$PROJECT_DIR\\$/lib/provided\" recursive=\"true\"");
content = JAR_DIRECTORY_LIB_TEST_RECURSIVE_PATTERN.matcher(content).replaceAll("<jarDirectory url=\"file://\\$PROJECT_DIR\\$/lib/test\" recursive=\"true\"");
FileUtils.writeString(content, libraries_test);
} catch (FileUtilsErrorException e) { } catch (FileUtilsErrorException e) {
throw new IOException(e); throw new IOException(e);
} }
@ -642,7 +681,7 @@ public class Wrapper {
private int launchMainCli(File jarFile, List<String> arguments) private int launchMainCli(File jarFile, List<String> arguments)
throws IOException, InterruptedException { throws IOException, InterruptedException {
var args = new ArrayList<String>(); var args = new ArrayList<String>();
args.add("java"); args.add(findJavaExecutable());
includeJvmProperties(arguments, args); includeJvmProperties(arguments, args);
args.add("-cp"); args.add("-cp");
@ -695,7 +734,7 @@ public class Wrapper {
} }
var java_args = new ArrayList<String>(); var java_args = new ArrayList<String>();
java_args.add("java"); java_args.add(findJavaExecutable());
includeJvmProperties(arguments, java_args); includeJvmProperties(arguments, java_args);
java_args.add("-cp"); java_args.add("-cp");
@ -712,6 +751,15 @@ public class Wrapper {
return process.waitFor(); return process.waitFor();
} }
private static String findJavaExecutable() {
var executable = System.getProperty("os.name").toLowerCase().contains("win") ? "java.exe" : "java";
var java_home = System.getProperty("java.home");
if (null == java_home) {
return executable;
}
return java_home + File.separator + "bin" + File.separator + executable;
}
private static void includeJvmProperties(List<String> arguments, List<String> javaArgs) { private static void includeJvmProperties(List<String> arguments, List<String> javaArgs) {
var i = arguments.iterator(); var i = arguments.iterator();
while (i.hasNext()) { while (i.hasNext()) {

View file

@ -109,7 +109,7 @@ public class WrapperExtensionResolver {
additional_classifiers = classifiers.toArray(new String[0]); additional_classifiers = classifiers.toArray(new String[0]);
} }
var artifacts = dependencies.transferIntoDirectory(resolution_, retriever_, repositories_, destinationDirectory_, additional_classifiers); var artifacts = dependencies.transferIntoDirectory(resolution_, retriever_, repositories_, destinationDirectory_, destinationDirectory_, additional_classifiers);
for (var artifact : artifacts) { for (var artifact : artifacts) {
var location = artifact.location(); var location = artifact.location();

View file

@ -1 +1 @@
2.0.1 2.3.1-SNAPSHOT

View file

@ -9,9 +9,9 @@
<root url="file://$PROJECT_DIR$/lib/compile" /> <root url="file://$PROJECT_DIR$/lib/compile" />
<root url="file://$PROJECT_DIR$/lib/provided" /> <root url="file://$PROJECT_DIR$/lib/provided" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" type="SOURCES" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -8,7 +8,7 @@
<SOURCES> <SOURCES>
<root url="file://$PROJECT_DIR$/lib/runtime" /> <root url="file://$PROJECT_DIR$/lib/runtime" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -10,9 +10,9 @@
<root url="file://$PROJECT_DIR$/lib/test" /> <root url="file://$PROJECT_DIR$/lib/test" />
<root url="file://$PROJECT_DIR$/lib/provided" /> <root url="file://$PROJECT_DIR$/lib/provided" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" type="SOURCES" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -9,9 +9,9 @@
<root url="file://$PROJECT_DIR$/lib/compile" /> <root url="file://$PROJECT_DIR$/lib/compile" />
<root url="file://$PROJECT_DIR$/lib/provided" /> <root url="file://$PROJECT_DIR$/lib/provided" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" type="SOURCES" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -8,7 +8,7 @@
<SOURCES> <SOURCES>
<root url="file://$PROJECT_DIR$/lib/runtime" /> <root url="file://$PROJECT_DIR$/lib/runtime" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -10,9 +10,9 @@
<root url="file://$PROJECT_DIR$/lib/test" /> <root url="file://$PROJECT_DIR$/lib/test" />
<root url="file://$PROJECT_DIR$/lib/provided" /> <root url="file://$PROJECT_DIR$/lib/provided" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" type="SOURCES" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -9,9 +9,9 @@
<root url="file://$PROJECT_DIR$/lib/compile" /> <root url="file://$PROJECT_DIR$/lib/compile" />
<root url="file://$PROJECT_DIR$/lib/provided" /> <root url="file://$PROJECT_DIR$/lib/provided" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" type="SOURCES" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -8,7 +8,7 @@
<SOURCES> <SOURCES>
<root url="file://$PROJECT_DIR$/lib/runtime" /> <root url="file://$PROJECT_DIR$/lib/runtime" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -10,9 +10,9 @@
<root url="file://$PROJECT_DIR$/lib/test" /> <root url="file://$PROJECT_DIR$/lib/test" />
<root url="file://$PROJECT_DIR$/lib/provided" /> <root url="file://$PROJECT_DIR$/lib/provided" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" type="SOURCES" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -9,9 +9,9 @@
<root url="file://$PROJECT_DIR$/lib/compile" /> <root url="file://$PROJECT_DIR$/lib/compile" />
<root url="file://$PROJECT_DIR$/lib/provided" /> <root url="file://$PROJECT_DIR$/lib/provided" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" type="SOURCES" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -8,7 +8,7 @@
<SOURCES> <SOURCES>
<root url="file://$PROJECT_DIR$/lib/runtime" /> <root url="file://$PROJECT_DIR$/lib/runtime" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -7,7 +7,7 @@
<SOURCES> <SOURCES>
<root url="file://$PROJECT_DIR$/lib/standalone" /> <root url="file://$PROJECT_DIR$/lib/standalone" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/standalone" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/standalone" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/standalone" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/standalone" recursive="true" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -10,9 +10,9 @@
<root url="file://$PROJECT_DIR$/lib/test" /> <root url="file://$PROJECT_DIR$/lib/test" />
<root url="file://$PROJECT_DIR$/lib/provided" /> <root url="file://$PROJECT_DIR$/lib/provided" />
</SOURCES> </SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" type="SOURCES" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" />
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" /> <jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="true" type="SOURCES" />
</library> </library>
</component> </component>

View file

@ -29,13 +29,16 @@ public class TestProject {
assertTrue(project.workDirectory().exists()); assertTrue(project.workDirectory().exists());
assertTrue(project.workDirectory().isDirectory()); assertTrue(project.workDirectory().isDirectory());
assertNull(project.pkg); assertNull(project.pkg);
assertFalse(project.hasPkg());
assertThrows(IllegalStateException.class, project::pkg); assertThrows(IllegalStateException.class, project::pkg);
assertNull(project.name); assertNull(project.name);
assertFalse(project.hasName());
assertThrows(IllegalStateException.class, project::name); assertThrows(IllegalStateException.class, project::name);
assertNull(project.version); assertNull(project.version);
assertFalse(project.hasVersion());
assertThrows(IllegalStateException.class, project::version); assertThrows(IllegalStateException.class, project::version);
assertNull(project.mainClass); assertNull(project.mainClass);
assertThrows(IllegalStateException.class, project::mainClass); assertNull(project.module);
assertNotNull(project.repositories); assertNotNull(project.repositories);
assertTrue(project.repositories.isEmpty()); assertTrue(project.repositories.isEmpty());
@ -114,6 +117,11 @@ public class TestProject {
assertNotNull(project.compileTestClasspath()); assertNotNull(project.compileTestClasspath());
assertNotNull(project.runClasspath()); assertNotNull(project.runClasspath());
assertNotNull(project.testClasspath()); assertNotNull(project.testClasspath());
assertNotNull(project.compileMainModulePath());
assertNotNull(project.compileTestModulePath());
assertNotNull(project.runModulePath());
assertNotNull(project.testModulePath());
} }
static class CustomProject extends Project { static class CustomProject extends Project {
@ -135,6 +143,22 @@ public class TestProject {
} }
} }
@Test
void testCustomProject()
throws Exception {
var tmp = Files.createTempDirectory("test").toFile();
try {
var result = new StringBuilder();
var project = new CustomProject(tmp, result);
assertTrue(project.hasPkg());
assertTrue(project.hasName());
assertTrue(project.hasVersion());
} finally {
FileUtils.deleteDirectory(tmp);
}
}
@Test @Test
void testCustomCommand() void testCustomCommand()
throws Exception { throws Exception {
@ -321,10 +345,6 @@ public class TestProject {
.include(dependency("org.jsoup", "jsoup", version(1, 15, 4))) .include(dependency("org.jsoup", "jsoup", version(1, 15, 4)))
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 9, 2))) .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 9, 2)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 9, 2))); .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 9, 2)));
scope(standalone)
.include(dependency("org.eclipse.jetty", "jetty-server", version(11, 0, 14)))
.include(dependency("org.eclipse.jetty", "jetty-servlet", version(11, 0, 14)))
.include(dependency("org.slf4j", "slf4j-simple", version(2, 0, 7)));
} }
public void enableAutoDownloadPurge() { public void enableAutoDownloadPurge() {
@ -364,8 +384,6 @@ public class TestProject {
/lib/bld/bld.cache /lib/bld/bld.cache
/lib/compile /lib/compile
/lib/compile/rife2-1.5.11.jar /lib/compile/rife2-1.5.11.jar
/lib/provided
/lib/runtime
/lib/test /lib/test
/lib/test/apiguardian-api-1.1.2.jar /lib/test/apiguardian-api-1.1.2.jar
/lib/test/jsoup-1.15.4.jar /lib/test/jsoup-1.15.4.jar
@ -379,8 +397,6 @@ public class TestProject {
/lib/test/opentest4j-1.2.0.jar""", FileUtils.generateDirectoryListing(tmp)); /lib/test/opentest4j-1.2.0.jar""", FileUtils.generateDirectoryListing(tmp));
FileUtils.deleteDirectory(new File(tmp, "lib/compile")); FileUtils.deleteDirectory(new File(tmp, "lib/compile"));
FileUtils.deleteDirectory(new File(tmp, "lib/provided"));
FileUtils.deleteDirectory(new File(tmp, "lib/runtime"));
FileUtils.deleteDirectory(new File(tmp, "lib/test")); FileUtils.deleteDirectory(new File(tmp, "lib/test"));
assertEquals(""" assertEquals("""
/lib /lib
@ -405,8 +421,6 @@ public class TestProject {
/lib/bld/bld.cache /lib/bld/bld.cache
/lib/compile /lib/compile
/lib/compile/rife2-1.5.12.jar /lib/compile/rife2-1.5.12.jar
/lib/provided
/lib/runtime
/lib/test /lib/test
/lib/test/apiguardian-api-1.1.2.jar /lib/test/apiguardian-api-1.1.2.jar
/lib/test/jsoup-1.15.4.jar /lib/test/jsoup-1.15.4.jar
@ -429,8 +443,6 @@ public class TestProject {
/lib/bld/bld.cache /lib/bld/bld.cache
/lib/compile /lib/compile
/lib/compile/rife2-1.5.15.jar /lib/compile/rife2-1.5.15.jar
/lib/provided
/lib/runtime
/lib/test /lib/test
/lib/test/apiguardian-api-1.1.2.jar /lib/test/apiguardian-api-1.1.2.jar
/lib/test/jsoup-1.15.4.jar /lib/test/jsoup-1.15.4.jar

View file

@ -8,9 +8,14 @@ import org.junit.jupiter.api.Test;
import rife.bld.dependencies.VersionNumber; import rife.bld.dependencies.VersionNumber;
import rife.tools.FileUtils; import rife.tools.FileUtils;
import java.io.File;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
import static rife.bld.dependencies.Repository.MAVEN_CENTRAL;
import static rife.bld.dependencies.Scope.*;
import static rife.bld.dependencies.Scope.compile;
public class TestWebProject { public class TestWebProject {
@Test @Test
@ -28,7 +33,7 @@ public class TestWebProject {
assertNull(project.version); assertNull(project.version);
assertThrows(IllegalStateException.class, project::version); assertThrows(IllegalStateException.class, project::version);
assertNull(project.mainClass); assertNull(project.mainClass);
assertThrows(IllegalStateException.class, project::mainClass); assertNull(project.module);
assertNotNull(project.repositories); assertNotNull(project.repositories);
assertTrue(project.repositories.isEmpty()); assertTrue(project.repositories.isEmpty());
@ -149,4 +154,167 @@ public class TestWebProject {
FileUtils.deleteDirectory(tmp); FileUtils.deleteDirectory(tmp);
} }
} }
static class CustomWebProjectAutoPurge extends WebProject {
CustomWebProjectAutoPurge(File tmp) {
workDirectory = tmp;
pkg = "test.pkg";
name = "my_project";
version = new VersionNumber(0, 0, 1);
repositories = List.of(MAVEN_CENTRAL);
scope(compile)
.include(dependency("com.uwyn.rife2", "rife2", version(1, 5, 11)));
scope(test)
.include(dependency("org.jsoup", "jsoup", version(1, 15, 4)))
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 9, 2)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 9, 2)));
scope(standalone)
.include(dependency("org.eclipse.jetty", "jetty-server", version(11, 0, 14)))
.include(dependency("org.eclipse.jetty", "jetty-servlet", version(11, 0, 14)))
.include(dependency("org.slf4j", "slf4j-simple", version(2, 0, 7)));
}
public void enableAutoDownloadPurge() {
autoDownloadPurge = true;
}
public void increaseRife2Version() {
scope(compile).clear();
scope(compile)
.include(dependency("com.uwyn.rife2", "rife2", version(1, 5, 12)));
}
public void increaseRife2VersionMore() {
scope(compile).clear();
scope(compile)
.include(dependency("com.uwyn.rife2", "rife2", version(1, 5, 15)));
}
}
@Test
void testAutoDownloadPurge()
throws Exception {
var tmp = Files.createTempDirectory("test").toFile();
try {
var project = new CustomWebProjectAutoPurge(tmp);
project.execute(new String[]{"version"});
assertEquals("", FileUtils.generateDirectoryListing(tmp));
project = new CustomWebProjectAutoPurge(tmp);
project.enableAutoDownloadPurge();
project.execute(new String[]{"version"});
assertEquals("""
/lib
/lib/bld
/lib/bld/bld.cache
/lib/compile
/lib/compile/rife2-1.5.11.jar
/lib/standalone
/lib/standalone/jetty-http-11.0.14.jar
/lib/standalone/jetty-io-11.0.14.jar
/lib/standalone/jetty-jakarta-servlet-api-5.0.2.jar
/lib/standalone/jetty-security-11.0.14.jar
/lib/standalone/jetty-server-11.0.14.jar
/lib/standalone/jetty-servlet-11.0.14.jar
/lib/standalone/jetty-util-11.0.14.jar
/lib/standalone/slf4j-api-2.0.7.jar
/lib/standalone/slf4j-simple-2.0.7.jar
/lib/test
/lib/test/apiguardian-api-1.1.2.jar
/lib/test/jsoup-1.15.4.jar
/lib/test/junit-jupiter-5.9.2.jar
/lib/test/junit-jupiter-api-5.9.2.jar
/lib/test/junit-jupiter-engine-5.9.2.jar
/lib/test/junit-jupiter-params-5.9.2.jar
/lib/test/junit-platform-commons-1.9.2.jar
/lib/test/junit-platform-console-standalone-1.9.2.jar
/lib/test/junit-platform-engine-1.9.2.jar
/lib/test/opentest4j-1.2.0.jar""", FileUtils.generateDirectoryListing(tmp));
FileUtils.deleteDirectory(new File(tmp, "lib/compile"));
FileUtils.deleteDirectory(new File(tmp, "lib/standalone"));
FileUtils.deleteDirectory(new File(tmp, "lib/test"));
assertEquals("""
/lib
/lib/bld
/lib/bld/bld.cache""", FileUtils.generateDirectoryListing(tmp));
project = new CustomWebProjectAutoPurge(tmp);
project.enableAutoDownloadPurge();
project.execute(new String[]{"version"});
assertEquals("""
/lib
/lib/bld
/lib/bld/bld.cache""", FileUtils.generateDirectoryListing(tmp));
project = new CustomWebProjectAutoPurge(tmp);
project.enableAutoDownloadPurge();
project.increaseRife2Version();
project.execute(new String[]{"version"});
assertEquals("""
/lib
/lib/bld
/lib/bld/bld.cache
/lib/compile
/lib/compile/rife2-1.5.12.jar
/lib/standalone
/lib/standalone/jetty-http-11.0.14.jar
/lib/standalone/jetty-io-11.0.14.jar
/lib/standalone/jetty-jakarta-servlet-api-5.0.2.jar
/lib/standalone/jetty-security-11.0.14.jar
/lib/standalone/jetty-server-11.0.14.jar
/lib/standalone/jetty-servlet-11.0.14.jar
/lib/standalone/jetty-util-11.0.14.jar
/lib/standalone/slf4j-api-2.0.7.jar
/lib/standalone/slf4j-simple-2.0.7.jar
/lib/test
/lib/test/apiguardian-api-1.1.2.jar
/lib/test/jsoup-1.15.4.jar
/lib/test/junit-jupiter-5.9.2.jar
/lib/test/junit-jupiter-api-5.9.2.jar
/lib/test/junit-jupiter-engine-5.9.2.jar
/lib/test/junit-jupiter-params-5.9.2.jar
/lib/test/junit-platform-commons-1.9.2.jar
/lib/test/junit-platform-console-standalone-1.9.2.jar
/lib/test/junit-platform-engine-1.9.2.jar
/lib/test/opentest4j-1.2.0.jar""", FileUtils.generateDirectoryListing(tmp));
project = new CustomWebProjectAutoPurge(tmp);
project.enableAutoDownloadPurge();
project.increaseRife2VersionMore();
project.execute(new String[]{"version"});
assertEquals("""
/lib
/lib/bld
/lib/bld/bld.cache
/lib/compile
/lib/compile/rife2-1.5.15.jar
/lib/standalone
/lib/standalone/jetty-http-11.0.14.jar
/lib/standalone/jetty-io-11.0.14.jar
/lib/standalone/jetty-jakarta-servlet-api-5.0.2.jar
/lib/standalone/jetty-security-11.0.14.jar
/lib/standalone/jetty-server-11.0.14.jar
/lib/standalone/jetty-servlet-11.0.14.jar
/lib/standalone/jetty-util-11.0.14.jar
/lib/standalone/slf4j-api-2.0.7.jar
/lib/standalone/slf4j-simple-2.0.7.jar
/lib/test
/lib/test/apiguardian-api-1.1.2.jar
/lib/test/jsoup-1.15.4.jar
/lib/test/junit-jupiter-5.9.2.jar
/lib/test/junit-jupiter-api-5.9.2.jar
/lib/test/junit-jupiter-engine-5.9.2.jar
/lib/test/junit-jupiter-params-5.9.2.jar
/lib/test/junit-platform-commons-1.9.2.jar
/lib/test/junit-platform-console-standalone-1.9.2.jar
/lib/test/junit-platform-engine-1.9.2.jar
/lib/test/opentest4j-1.2.0.jar""", FileUtils.generateDirectoryListing(tmp));
} finally {
FileUtils.deleteDirectory(tmp);
}
}
} }

View file

@ -18,6 +18,8 @@ public class TestDependency {
assertEquals(VersionNumber.UNKNOWN, dependency1.version()); assertEquals(VersionNumber.UNKNOWN, dependency1.version());
assertEquals("", dependency1.classifier()); assertEquals("", dependency1.classifier());
assertEquals("jar", dependency1.type()); assertEquals("jar", dependency1.type());
assertFalse(dependency1.isModularJar());
assertFalse(dependency1.isClasspathJar());
var dependency2 = new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0)); var dependency2 = new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0));
assertNotNull(dependency2); assertNotNull(dependency2);
@ -26,6 +28,8 @@ public class TestDependency {
assertEquals(new VersionNumber(1, 4, 0), dependency2.version()); assertEquals(new VersionNumber(1, 4, 0), dependency2.version());
assertEquals("", dependency2.classifier()); assertEquals("", dependency2.classifier());
assertEquals("jar", dependency2.type()); assertEquals("jar", dependency2.type());
assertFalse(dependency2.isModularJar());
assertFalse(dependency2.isClasspathJar());
var dependency3 = new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0), "agent"); var dependency3 = new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0), "agent");
assertNotNull(dependency3); assertNotNull(dependency3);
@ -34,6 +38,8 @@ public class TestDependency {
assertEquals(new VersionNumber(1, 4, 0), dependency3.version()); assertEquals(new VersionNumber(1, 4, 0), dependency3.version());
assertEquals("agent", dependency3.classifier()); assertEquals("agent", dependency3.classifier());
assertEquals("jar", dependency3.type()); assertEquals("jar", dependency3.type());
assertFalse(dependency3.isModularJar());
assertFalse(dependency3.isClasspathJar());
var dependency4 = new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0), "bld", "zip"); var dependency4 = new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0), "bld", "zip");
assertNotNull(dependency4); assertNotNull(dependency4);
@ -42,6 +48,65 @@ public class TestDependency {
assertEquals(new VersionNumber(1, 4, 0), dependency4.version()); assertEquals(new VersionNumber(1, 4, 0), dependency4.version());
assertEquals("bld", dependency4.classifier()); assertEquals("bld", dependency4.classifier());
assertEquals("zip", dependency4.type()); assertEquals("zip", dependency4.type());
assertFalse(dependency4.isModularJar());
assertFalse(dependency4.isClasspathJar());
var dependency5 = new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0), null, "modular-jar");
assertNotNull(dependency5);
assertEquals("com.uwyn.rife2", dependency5.groupId());
assertEquals("rife2", dependency5.artifactId());
assertEquals(new VersionNumber(1, 4, 0), dependency5.version());
assertEquals("", dependency5.classifier());
assertEquals("modular-jar", dependency5.type());
assertTrue(dependency5.isModularJar());
assertFalse(dependency5.isClasspathJar());
var dependency6 = new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0), null, "classpath-jar");
assertNotNull(dependency6);
assertEquals("com.uwyn.rife2", dependency6.groupId());
assertEquals("rife2", dependency6.artifactId());
assertEquals(new VersionNumber(1, 4, 0), dependency6.version());
assertEquals("", dependency6.classifier());
assertEquals("classpath-jar", dependency6.type());
assertFalse(dependency6.isModularJar());
assertTrue(dependency6.isClasspathJar());
}
@Test
void testParent() {
var parent1 = new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0));
var parent2 = new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0), null, "modular-jar");
var parent3 = new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0), null, "classpath-jar");
var child1a = new Dependency("com.uwyn.rife2", "bld", new VersionNumber(1, 5, 0), null, null, null, parent1);
assertFalse(child1a.isModularJar());
assertFalse(child1a.isClasspathJar());
var child1b = new Dependency("com.uwyn.rife2", "bld", new VersionNumber(1, 5, 0), null, null, null, parent2);
assertTrue(child1b.isModularJar());
assertFalse(child1b.isClasspathJar());
var child1c = new Dependency("com.uwyn.rife2", "bld", new VersionNumber(1, 5, 0), null, null, null, parent3);
assertFalse(child1c.isModularJar());
assertFalse(child1c.isClasspathJar());
var child2a = new Dependency("com.uwyn.rife2", "bld", new VersionNumber(1, 5, 0), null, "modular-jar", null, parent1);
assertTrue(child2a.isModularJar());
assertFalse(child2a.isClasspathJar());
var child2b = new Dependency("com.uwyn.rife2", "bld", new VersionNumber(1, 5, 0), null, "modular-jar", null, parent2);
assertTrue(child2b.isModularJar());
assertFalse(child2b.isClasspathJar());
var child2c = new Dependency("com.uwyn.rife2", "bld", new VersionNumber(1, 5, 0), null, "modular-jar", null, parent3);
assertTrue(child2c.isModularJar());
assertFalse(child2c.isClasspathJar());
var child3a = new Dependency("com.uwyn.rife2", "bld", new VersionNumber(1, 5, 0), null, "classpath-jar", null, parent1);
assertFalse(child3a.isModularJar());
assertTrue(child3a.isClasspathJar());
var child3b = new Dependency("com.uwyn.rife2", "bld", new VersionNumber(1, 5, 0), null, "classpath-jar", null, parent2);
assertFalse(child3b.isModularJar());
assertTrue(child3b.isClasspathJar());
var child3c = new Dependency("com.uwyn.rife2", "bld", new VersionNumber(1, 5, 0), null, "classpath-jar", null, parent3);
assertFalse(child3c.isModularJar());
assertTrue(child3c.isClasspathJar());
} }
@Test @Test
@ -99,7 +164,7 @@ public class TestDependency {
} }
@Test @Test
void testToParse() { void testParse() {
assertEquals("com.uwyn.rife2:rife2", Dependency.parse("com.uwyn.rife2:rife2").toString()); assertEquals("com.uwyn.rife2:rife2", Dependency.parse("com.uwyn.rife2:rife2").toString());
assertEquals("com.uwyn.rife2:rife2:1.4.0", Dependency.parse("com.uwyn.rife2:rife2:1.4.0").toString()); assertEquals("com.uwyn.rife2:rife2:1.4.0", Dependency.parse("com.uwyn.rife2:rife2:1.4.0").toString());
assertEquals("com.uwyn.rife2:rife2:1.4.0:agent", Dependency.parse("com.uwyn.rife2:rife2:1.4.0:agent").toString()); assertEquals("com.uwyn.rife2:rife2:1.4.0:agent", Dependency.parse("com.uwyn.rife2:rife2:1.4.0:agent").toString());
@ -114,4 +179,102 @@ public class TestDependency {
assertEquals(new Dependency("com.uwyn.rife2", "rife2", null, null, "zip").toString(), Dependency.parse("com.uwyn.rife2:rife2@zip").toString()); assertEquals(new Dependency("com.uwyn.rife2", "rife2", null, null, "zip").toString(), Dependency.parse("com.uwyn.rife2:rife2@zip").toString());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0), null, "zip").toString(), Dependency.parse("com.uwyn.rife2:rife2:1.4.0@zip").toString()); assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0), null, "zip").toString(), Dependency.parse("com.uwyn.rife2:rife2:1.4.0@zip").toString());
} }
@Test
void testEquals() {
assertEquals(new Dependency("com.uwyn.rife2", "rife2"), new Dependency("com.uwyn.rife2", "rife2"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2"), new Dependency("com.uwyn.rife2", "rife1"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2"), new Dependency("com.uwyn.rife1", "rife2"));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1)));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)), new Dependency("com.uwyn.rife2", "rife2", null));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)), new Dependency("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0)));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)), new Dependency("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0)));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1)));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", null));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0)));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0)));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1), null, "jar"));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", null, null, "jar"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0), null, "jar"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0), null, "jar"));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "modular-jar"));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1), null, "modular-jar"));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", null, null, "modular-jar"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0), null, "modular-jar"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0), null, "modular-jar"));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "classpath-jar"));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1), null, "classpath-jar"));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", null, null, "classpath-jar"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0), null, "classpath-jar"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0), null, "classpath-jar"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "zip"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1), null, "zip"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", null, null, "zip"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0), null, "zip"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0), null, "zip"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), "agent", "jar"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1), "agent", "jar"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife2", null, "agent", "jar"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0), "agent", "jar"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Dependency("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0), "agent", "jar"));
}
@Test
void testHashcode() {
assertEquals(new Dependency("com.uwyn.rife2", "rife2").hashCode(), new Dependency("com.uwyn.rife2", "rife2").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2").hashCode(), new Dependency("com.uwyn.rife2", "rife1").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2").hashCode(), new Dependency("com.uwyn.rife1", "rife2").hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)).hashCode(), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)).hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)).hashCode(), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1)).hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)).hashCode(), new Dependency("com.uwyn.rife2", "rife2", null).hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)).hashCode(), new Dependency("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0)).hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)).hashCode(), new Dependency("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0)).hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)).hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1)).hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", null).hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0)).hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0)).hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1), null, "jar").hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", null, null, "jar").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0), null, "jar").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "modular-jar").hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1), null, "modular-jar").hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", null, null, "modular-jar").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0), null, "modular-jar").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0), null, "modular-jar").hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "classpath-jar").hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1), null, "classpath-jar").hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", null, null, "classpath-jar").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0), null, "classpath-jar").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0), null, "classpath-jar").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "zip").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1), null, "zip").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", null, null, "zip").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0), null, "zip").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0), null, "zip").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), "agent", "jar").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1), "agent", "jar").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife2", null, "agent", "jar").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0), "agent", "jar").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Dependency("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0), "agent", "jar").hashCode());
}
} }

View file

@ -359,19 +359,19 @@ public class TestDependencySet {
@Test @Test
void testGenerateDependencyTreeCompileRuntime() { void testGenerateDependencyTreeCompileRuntime() {
var dependencies = new DependencySet() var dependencies = new DependencySet()
.include(new Dependency("net.thauvin.erik", "bitly-shorten", new VersionNumber(0, 9, 4, "SNAPSHOT"))); .include(new Dependency("net.thauvin.erik", "bitly-shorten", new VersionNumber(2, 0, 0)));
assertEquals(StringUtils.convertLineSeparator(""" assertEquals(StringUtils.convertLineSeparator("""
net.thauvin.erik:bitly-shorten:0.9.4-SNAPSHOT net.thauvin.erik:bitly-shorten:2.0.0
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22 org.jetbrains.kotlin:kotlin-stdlib:2.1.10
org.jetbrains.kotlin:kotlin-stdlib:1.8.22 org.jetbrains:annotations:13.0
org.jetbrains.kotlin:kotlin-stdlib-common:1.8.22 org.jetbrains.kotlin:kotlin-stdlib-common:2.1.10
org.jetbrains:annotations:13.0 org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.10
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.22 org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.1.10
com.squareup.okhttp3:okhttp:4.11.0 com.squareup.okhttp3:okhttp:4.12.0
com.squareup.okio:okio:3.2.0 com.squareup.okio:okio:3.6.0
com.squareup.okio:okio-jvm:3.2.0 com.squareup.okio:okio-jvm:3.6.0
com.squareup.okhttp3:logging-interceptor:4.11.0 com.squareup.okhttp3:logging-interceptor:4.12.0
org.json:json:20230618 org.json:json:20250107
"""), dependencies.generateTransitiveDependencyTree(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY), compile, runtime)); """), dependencies.generateTransitiveDependencyTree(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS), compile, runtime));
} }
} }

View file

@ -0,0 +1,111 @@
/*
* Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
* Licensed under the Apache License, Version 2.0 (the "License")
*/
package rife.bld.dependencies;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class TestModule {
@Test
void testModule() {
var module1 = new Module("com.uwyn.rife2", "rife2");
assertNotNull(module1);
assertEquals("com.uwyn.rife2", module1.groupId());
assertEquals("rife2", module1.artifactId());
assertEquals(VersionNumber.UNKNOWN, module1.version());
assertEquals("", module1.classifier());
assertEquals("modular-jar", module1.type());
assertTrue(module1.isModularJar());
assertFalse(module1.isClasspathJar());
var module2 = new Module("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0));
assertNotNull(module2);
assertEquals("com.uwyn.rife2", module2.groupId());
assertEquals("rife2", module2.artifactId());
assertEquals(new VersionNumber(1, 4, 0), module2.version());
assertEquals("", module2.classifier());
assertEquals("modular-jar", module2.type());
assertTrue(module2.isModularJar());
assertFalse(module2.isClasspathJar());
var module3 = new Module("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0), "agent");
assertNotNull(module3);
assertEquals("com.uwyn.rife2", module3.groupId());
assertEquals("rife2", module3.artifactId());
assertEquals(new VersionNumber(1, 4, 0), module3.version());
assertEquals("agent", module3.classifier());
assertEquals("modular-jar", module3.type());
assertTrue(module3.isModularJar());
assertFalse(module3.isClasspathJar());
}
@Test
void testParse() {
assertEquals("com.uwyn.rife2:rife2@modular-jar", Module.parse("com.uwyn.rife2:rife2").toString());
assertEquals("com.uwyn.rife2:rife2:1.4.0@modular-jar", Module.parse("com.uwyn.rife2:rife2:1.4.0").toString());
assertEquals("com.uwyn.rife2:rife2:1.4.0:agent@modular-jar", Module.parse("com.uwyn.rife2:rife2:1.4.0:agent").toString());
assertEquals("com.uwyn.rife2:rife2@modular-jar", Module.parse("com.uwyn.rife2:rife2@modular-jar").toString());
assertEquals("com.uwyn.rife2:rife2:1.4.0@modular-jar", Module.parse("com.uwyn.rife2:rife2:1.4.0@modular-jar").toString());
assertEquals("com.uwyn.rife2:rife2:1.4.0:agent@modular-jar", Module.parse("com.uwyn.rife2:rife2:1.4.0:agent@modular-jar").toString());
assertEquals(new Module("com.uwyn.rife2", "rife2").toString(), Module.parse("com.uwyn.rife2:rife2").toString());
assertEquals(new Module("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0)).toString(), Module.parse("com.uwyn.rife2:rife2:1.4.0").toString());
assertEquals(new Module("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0), "agent").toString(), Module.parse("com.uwyn.rife2:rife2:1.4.0:agent").toString());
assertEquals(new Module("com.uwyn.rife2", "rife2").toString(), Module.parse("com.uwyn.rife2:rife2@modular-jar").toString());
assertEquals(new Module("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0)).toString(), Module.parse("com.uwyn.rife2:rife2:1.4.0@modular-jar").toString());
assertEquals(new Module("com.uwyn.rife2", "rife2", new VersionNumber(1, 4, 0), "agent").toString(), Module.parse("com.uwyn.rife2:rife2:1.4.0:agent@modular-jar").toString());
}
@Test
void testEquals() {
assertEquals(new Dependency("com.uwyn.rife2", "rife2"), new Module("com.uwyn.rife2", "rife2"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2"), new Module("com.uwyn.rife2", "rife1"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2"), new Module("com.uwyn.rife1", "rife2"));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)), new Module("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)), new Module("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1)));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)), new Module("com.uwyn.rife2", "rife2", null));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)), new Module("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0)));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)), new Module("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0)));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Module("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Module("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1)));
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Module("com.uwyn.rife2", "rife2", null));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Module("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0)));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Module("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0)));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Module("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), "agent"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Module("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1), "agent"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Module("com.uwyn.rife2", "rife2", null, "agent"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Module("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0), "agent"));
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar"), new Module("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0), "agent"));
}
@Test
void testHashcode() {
assertEquals(new Dependency("com.uwyn.rife2", "rife2").hashCode(), new Module("com.uwyn.rife2", "rife2").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2").hashCode(), new Module("com.uwyn.rife2", "rife1").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2").hashCode(), new Module("com.uwyn.rife1", "rife2").hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)).hashCode(), new Module("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)).hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)).hashCode(), new Module("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1)).hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)).hashCode(), new Module("com.uwyn.rife2", "rife2", null).hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)).hashCode(), new Module("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0)).hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)).hashCode(), new Module("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0)).hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Module("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0)).hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Module("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1)).hashCode());
assertEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Module("com.uwyn.rife2", "rife2", null).hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Module("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0)).hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Module("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0)).hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Module("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), "agent").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Module("com.uwyn.rife2", "rife2", new VersionNumber(1,4,1), "agent").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Module("com.uwyn.rife2", "rife2", null, "agent").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Module("com.uwyn.rife2", "rife1", new VersionNumber(1,4,0), "agent").hashCode());
assertNotEquals(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,4,0), null, "jar").hashCode(), new Module("com.uwyn.rife1", "rife2", new VersionNumber(1,4,0), "agent").hashCode());
}
}

View file

@ -116,10 +116,15 @@ public class TestCleanOperation {
/lib /lib
/lib/bld /lib/bld
/lib/compile /lib/compile
/lib/compile/modules
/lib/provided /lib/provided
/lib/provided/modules
/lib/runtime /lib/runtime
/lib/runtime/modules
/lib/standalone /lib/standalone
/lib/standalone/modules
/lib/test /lib/test
/lib/test/modules
/src /src
/src/bld /src/bld
/src/bld/java /src/bld/java
@ -140,10 +145,15 @@ public class TestCleanOperation {
/lib /lib
/lib/bld /lib/bld
/lib/compile /lib/compile
/lib/compile/modules
/lib/provided /lib/provided
/lib/provided/modules
/lib/runtime /lib/runtime
/lib/runtime/modules
/lib/standalone /lib/standalone
/lib/standalone/modules
/lib/test /lib/test
/lib/test/modules
/src /src
/src/bld /src/bld
/src/bld/java /src/bld/java

View file

@ -223,7 +223,7 @@ public class TestCompileOperation {
var compile_operation = new CompileOperation() var compile_operation = new CompileOperation()
.fromProject(create_operation.project()); .fromProject(create_operation.project());
var main_app_class = new File(new File(compile_operation.buildMainDirectory(), "tst"), "AppMain.class"); var main_app_class = new File(new File(compile_operation.buildMainDirectory(), "tst"), "App.class");
var test_app_class = new File(new File(compile_operation.buildTestDirectory(), "tst"), "AppTest.class"); var test_app_class = new File(new File(compile_operation.buildTestDirectory(), "tst"), "AppTest.class");
assertFalse(main_app_class.exists()); assertFalse(main_app_class.exists());
assertFalse(test_app_class.exists()); assertFalse(test_app_class.exists());

View file

@ -65,157 +65,166 @@ public class TestCreateAppOperation {
var create_operation = new CreateAppOperation() var create_operation = new CreateAppOperation()
.workDirectory(tmp) .workDirectory(tmp)
.packageName("com.example") .packageName("com.example")
.projectName("myapp") .projectName("my-app")
.baseName("MyApp")
.downloadDependencies(true); .downloadDependencies(true);
create_operation.execute(); create_operation.execute();
assertTrue(Pattern.compile(""" assertTrue(Pattern.compile("""
/myapp /my-app
/myapp/\\.gitignore /my-app/\\.gitignore
/myapp/\\.idea /my-app/\\.idea
/myapp/\\.idea/app\\.iml /my-app/\\.idea/app\\.iml
/myapp/\\.idea/bld\\.iml /my-app/\\.idea/bld\\.iml
/myapp/\\.idea/libraries /my-app/\\.idea/libraries
/myapp/\\.idea/libraries/bld\\.xml /my-app/\\.idea/libraries/bld\\.xml
/myapp/\\.idea/libraries/compile\\.xml /my-app/\\.idea/libraries/compile\\.xml
/myapp/\\.idea/libraries/runtime\\.xml /my-app/\\.idea/libraries/runtime\\.xml
/myapp/\\.idea/libraries/test\\.xml /my-app/\\.idea/libraries/test\\.xml
/myapp/\\.idea/misc\\.xml /my-app/\\.idea/misc\\.xml
/myapp/\\.idea/modules\\.xml /my-app/\\.idea/modules\\.xml
/myapp/\\.idea/runConfigurations /my-app/\\.idea/runConfigurations
/myapp/\\.idea/runConfigurations/Run Main\\.xml /my-app/\\.idea/runConfigurations/Run Main\\.xml
/myapp/\\.idea/runConfigurations/Run Tests\\.xml /my-app/\\.idea/runConfigurations/Run Tests\\.xml
/myapp/\\.vscode /my-app/\\.vscode
/myapp/\\.vscode/launch\\.json /my-app/\\.vscode/launch\\.json
/myapp/\\.vscode/settings\\.json /my-app/\\.vscode/settings\\.json
/myapp/bld /my-app/bld
/myapp/bld\\.bat /my-app/bld\\.bat
/myapp/lib /my-app/lib
/myapp/lib/bld /my-app/lib/bld
/myapp/lib/bld/bld-wrapper\\.jar /my-app/lib/bld/bld-wrapper\\.jar
/myapp/lib/bld/bld-wrapper\\.properties /my-app/lib/bld/bld-wrapper\\.properties
/myapp/lib/compile /my-app/lib/compile
/myapp/lib/provided /my-app/lib/compile/modules
/myapp/lib/runtime /my-app/lib/provided
/myapp/lib/test /my-app/lib/provided/modules
/myapp/lib/test/apiguardian-api-1\\.1\\.2-sources\\.jar /my-app/lib/runtime
/myapp/lib/test/apiguardian-api-1\\.1\\.2\\.jar /my-app/lib/runtime/modules
/myapp/lib/test/junit-jupiter-5\\.10\\.3-sources\\.jar /my-app/lib/test
/myapp/lib/test/junit-jupiter-5\\.10\\.3\\.jar /my-app/lib/test/apiguardian-api-1\\.1\\.2-sources\\.jar
/myapp/lib/test/junit-jupiter-api-5\\.10\\.3-sources\\.jar /my-app/lib/test/apiguardian-api-1\\.1\\.2\\.jar
/myapp/lib/test/junit-jupiter-api-5\\.10\\.3\\.jar /my-app/lib/test/junit-jupiter-5\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-jupiter-engine-5\\.10\\.3-sources\\.jar /my-app/lib/test/junit-jupiter-5\\.11\\.4\\.jar
/myapp/lib/test/junit-jupiter-engine-5\\.10\\.3\\.jar /my-app/lib/test/junit-jupiter-api-5\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-jupiter-params-5\\.10\\.3-sources\\.jar /my-app/lib/test/junit-jupiter-api-5\\.11\\.4\\.jar
/myapp/lib/test/junit-jupiter-params-5\\.10\\.3\\.jar /my-app/lib/test/junit-jupiter-engine-5\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-platform-commons-1\\.10\\.3-sources\\.jar /my-app/lib/test/junit-jupiter-engine-5\\.11\\.4\\.jar
/myapp/lib/test/junit-platform-commons-1\\.10\\.3\\.jar /my-app/lib/test/junit-jupiter-params-5\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-platform-console-standalone-1\\.10\\.3-sources\\.jar /my-app/lib/test/junit-jupiter-params-5\\.11\\.4\\.jar
/myapp/lib/test/junit-platform-console-standalone-1\\.10\\.3\\.jar /my-app/lib/test/junit-platform-commons-1\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-platform-engine-1\\.10\\.3-sources\\.jar /my-app/lib/test/junit-platform-commons-1\\.11\\.4\\.jar
/myapp/lib/test/junit-platform-engine-1\\.10\\.3\\.jar /my-app/lib/test/junit-platform-console-standalone-1\\.11\\.4-sources\\.jar
/myapp/lib/test/opentest4j-1\\.3\\.0-sources\\.jar /my-app/lib/test/junit-platform-console-standalone-1\\.11\\.4\\.jar
/myapp/lib/test/opentest4j-1\\.3\\.0\\.jar /my-app/lib/test/junit-platform-engine-1\\.11\\.4-sources\\.jar
/myapp/src /my-app/lib/test/junit-platform-engine-1\\.11\\.4\\.jar
/myapp/src/bld /my-app/lib/test/modules
/myapp/src/bld/java /my-app/lib/test/opentest4j-1\\.3\\.0-sources\\.jar
/myapp/src/bld/java/com /my-app/lib/test/opentest4j-1\\.3\\.0\\.jar
/myapp/src/bld/java/com/example /my-app/src
/myapp/src/bld/java/com/example/MyappBuild\\.java /my-app/src/bld
/myapp/src/bld/resources /my-app/src/bld/java
/myapp/src/main /my-app/src/bld/java/com
/myapp/src/main/java /my-app/src/bld/java/com/example
/myapp/src/main/java/com /my-app/src/bld/java/com/example/MyAppBuild\\.java
/myapp/src/main/java/com/example /my-app/src/bld/resources
/myapp/src/main/java/com/example/MyappMain\\.java /my-app/src/main
/myapp/src/main/resources /my-app/src/main/java
/myapp/src/main/resources/templates /my-app/src/main/java/com
/myapp/src/test /my-app/src/main/java/com/example
/myapp/src/test/java /my-app/src/main/java/com/example/MyApp\\.java
/myapp/src/test/java/com /my-app/src/main/resources
/myapp/src/test/java/com/example /my-app/src/main/resources/templates
/myapp/src/test/java/com/example/MyappTest\\.java /my-app/src/test
/myapp/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches()); /my-app/src/test/java
/my-app/src/test/java/com
/my-app/src/test/java/com/example
/my-app/src/test/java/com/example/MyAppTest\\.java
/my-app/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches());
var compile_operation = new CompileOperation().fromProject(create_operation.project()); var compile_operation = new CompileOperation().fromProject(create_operation.project());
compile_operation.execute(); compile_operation.execute();
assertTrue(compile_operation.diagnostics().isEmpty()); assertTrue(compile_operation.diagnostics().isEmpty());
assertTrue(Pattern.compile(""" assertTrue(Pattern.compile("""
/myapp /my-app
/myapp/\\.gitignore /my-app/\\.gitignore
/myapp/\\.idea /my-app/\\.idea
/myapp/\\.idea/app\\.iml /my-app/\\.idea/app\\.iml
/myapp/\\.idea/bld\\.iml /my-app/\\.idea/bld\\.iml
/myapp/\\.idea/libraries /my-app/\\.idea/libraries
/myapp/\\.idea/libraries/bld\\.xml /my-app/\\.idea/libraries/bld\\.xml
/myapp/\\.idea/libraries/compile\\.xml /my-app/\\.idea/libraries/compile\\.xml
/myapp/\\.idea/libraries/runtime\\.xml /my-app/\\.idea/libraries/runtime\\.xml
/myapp/\\.idea/libraries/test\\.xml /my-app/\\.idea/libraries/test\\.xml
/myapp/\\.idea/misc\\.xml /my-app/\\.idea/misc\\.xml
/myapp/\\.idea/modules\\.xml /my-app/\\.idea/modules\\.xml
/myapp/\\.idea/runConfigurations /my-app/\\.idea/runConfigurations
/myapp/\\.idea/runConfigurations/Run Main\\.xml /my-app/\\.idea/runConfigurations/Run Main\\.xml
/myapp/\\.idea/runConfigurations/Run Tests\\.xml /my-app/\\.idea/runConfigurations/Run Tests\\.xml
/myapp/\\.vscode /my-app/\\.vscode
/myapp/\\.vscode/launch\\.json /my-app/\\.vscode/launch\\.json
/myapp/\\.vscode/settings\\.json /my-app/\\.vscode/settings\\.json
/myapp/bld /my-app/bld
/myapp/bld\\.bat /my-app/bld\\.bat
/myapp/build /my-app/build
/myapp/build/main /my-app/build/main
/myapp/build/main/com /my-app/build/main/com
/myapp/build/main/com/example /my-app/build/main/com/example
/myapp/build/main/com/example/MyappMain\\.class /my-app/build/main/com/example/MyApp\\.class
/myapp/build/test /my-app/build/test
/myapp/build/test/com /my-app/build/test/com
/myapp/build/test/com/example /my-app/build/test/com/example
/myapp/build/test/com/example/MyappTest\\.class /my-app/build/test/com/example/MyAppTest\\.class
/myapp/lib /my-app/lib
/myapp/lib/bld /my-app/lib/bld
/myapp/lib/bld/bld-wrapper\\.jar /my-app/lib/bld/bld-wrapper\\.jar
/myapp/lib/bld/bld-wrapper\\.properties /my-app/lib/bld/bld-wrapper\\.properties
/myapp/lib/compile /my-app/lib/compile
/myapp/lib/provided /my-app/lib/compile/modules
/myapp/lib/runtime /my-app/lib/provided
/myapp/lib/test /my-app/lib/provided/modules
/myapp/lib/test/apiguardian-api-1\\.1\\.2-sources\\.jar /my-app/lib/runtime
/myapp/lib/test/apiguardian-api-1\\.1\\.2\\.jar /my-app/lib/runtime/modules
/myapp/lib/test/junit-jupiter-5\\.10\\.3-sources\\.jar /my-app/lib/test
/myapp/lib/test/junit-jupiter-5\\.10\\.3\\.jar /my-app/lib/test/apiguardian-api-1\\.1\\.2-sources\\.jar
/myapp/lib/test/junit-jupiter-api-5\\.10\\.3-sources\\.jar /my-app/lib/test/apiguardian-api-1\\.1\\.2\\.jar
/myapp/lib/test/junit-jupiter-api-5\\.10\\.3\\.jar /my-app/lib/test/junit-jupiter-5\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-jupiter-engine-5\\.10\\.3-sources\\.jar /my-app/lib/test/junit-jupiter-5\\.11\\.4\\.jar
/myapp/lib/test/junit-jupiter-engine-5\\.10\\.3\\.jar /my-app/lib/test/junit-jupiter-api-5\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-jupiter-params-5\\.10\\.3-sources\\.jar /my-app/lib/test/junit-jupiter-api-5\\.11\\.4\\.jar
/myapp/lib/test/junit-jupiter-params-5\\.10\\.3\\.jar /my-app/lib/test/junit-jupiter-engine-5\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-platform-commons-1\\.10\\.3-sources\\.jar /my-app/lib/test/junit-jupiter-engine-5\\.11\\.4\\.jar
/myapp/lib/test/junit-platform-commons-1\\.10\\.3\\.jar /my-app/lib/test/junit-jupiter-params-5\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-platform-console-standalone-1\\.10\\.3-sources\\.jar /my-app/lib/test/junit-jupiter-params-5\\.11\\.4\\.jar
/myapp/lib/test/junit-platform-console-standalone-1\\.10\\.3\\.jar /my-app/lib/test/junit-platform-commons-1\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-platform-engine-1\\.10\\.3-sources\\.jar /my-app/lib/test/junit-platform-commons-1\\.11\\.4\\.jar
/myapp/lib/test/junit-platform-engine-1\\.10\\.3\\.jar /my-app/lib/test/junit-platform-console-standalone-1\\.11\\.4-sources\\.jar
/myapp/lib/test/opentest4j-1\\.3\\.0-sources\\.jar /my-app/lib/test/junit-platform-console-standalone-1\\.11\\.4\\.jar
/myapp/lib/test/opentest4j-1\\.3\\.0\\.jar /my-app/lib/test/junit-platform-engine-1\\.11\\.4-sources\\.jar
/myapp/src /my-app/lib/test/junit-platform-engine-1\\.11\\.4\\.jar
/myapp/src/bld /my-app/lib/test/modules
/myapp/src/bld/java /my-app/lib/test/opentest4j-1\\.3\\.0-sources\\.jar
/myapp/src/bld/java/com /my-app/lib/test/opentest4j-1\\.3\\.0\\.jar
/myapp/src/bld/java/com/example /my-app/src
/myapp/src/bld/java/com/example/MyappBuild\\.java /my-app/src/bld
/myapp/src/bld/resources /my-app/src/bld/java
/myapp/src/main /my-app/src/bld/java/com
/myapp/src/main/java /my-app/src/bld/java/com/example
/myapp/src/main/java/com /my-app/src/bld/java/com/example/MyAppBuild\\.java
/myapp/src/main/java/com/example /my-app/src/bld/resources
/myapp/src/main/java/com/example/MyappMain\\.java /my-app/src/main
/myapp/src/main/resources /my-app/src/main/java
/myapp/src/main/resources/templates /my-app/src/main/java/com
/myapp/src/test /my-app/src/main/java/com/example
/myapp/src/test/java /my-app/src/main/java/com/example/MyApp\\.java
/myapp/src/test/java/com /my-app/src/main/resources
/myapp/src/test/java/com/example /my-app/src/main/resources/templates
/myapp/src/test/java/com/example/MyappTest\\.java /my-app/src/test
/myapp/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches()); /my-app/src/test/java
/my-app/src/test/java/com
/my-app/src/test/java/com/example
/my-app/src/test/java/com/example/MyAppTest\\.java
/my-app/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches());
var check_result = new StringBuilder(); var check_result = new StringBuilder();
new RunOperation() new RunOperation()
@ -239,58 +248,63 @@ public class TestCreateAppOperation {
var create_operation = new CreateAppOperation() var create_operation = new CreateAppOperation()
.workDirectory(tmp) .workDirectory(tmp)
.packageName("org.stuff") .packageName("org.stuff")
.projectName("yourthing"); .projectName("your-thing")
.baseName("YourThing");
create_operation.execute(); create_operation.execute();
assertEquals(""" assertEquals("""
/yourthing /your-thing
/yourthing/.gitignore /your-thing/.gitignore
/yourthing/.idea /your-thing/.idea
/yourthing/.idea/app.iml /your-thing/.idea/app.iml
/yourthing/.idea/bld.iml /your-thing/.idea/bld.iml
/yourthing/.idea/libraries /your-thing/.idea/libraries
/yourthing/.idea/libraries/bld.xml /your-thing/.idea/libraries/bld.xml
/yourthing/.idea/libraries/compile.xml /your-thing/.idea/libraries/compile.xml
/yourthing/.idea/libraries/runtime.xml /your-thing/.idea/libraries/runtime.xml
/yourthing/.idea/libraries/test.xml /your-thing/.idea/libraries/test.xml
/yourthing/.idea/misc.xml /your-thing/.idea/misc.xml
/yourthing/.idea/modules.xml /your-thing/.idea/modules.xml
/yourthing/.idea/runConfigurations /your-thing/.idea/runConfigurations
/yourthing/.idea/runConfigurations/Run Main.xml /your-thing/.idea/runConfigurations/Run Main.xml
/yourthing/.idea/runConfigurations/Run Tests.xml /your-thing/.idea/runConfigurations/Run Tests.xml
/yourthing/.vscode /your-thing/.vscode
/yourthing/.vscode/launch.json /your-thing/.vscode/launch.json
/yourthing/.vscode/settings.json /your-thing/.vscode/settings.json
/yourthing/bld /your-thing/bld
/yourthing/bld.bat /your-thing/bld.bat
/yourthing/lib /your-thing/lib
/yourthing/lib/bld /your-thing/lib/bld
/yourthing/lib/bld/bld-wrapper.jar /your-thing/lib/bld/bld-wrapper.jar
/yourthing/lib/bld/bld-wrapper.properties /your-thing/lib/bld/bld-wrapper.properties
/yourthing/lib/compile /your-thing/lib/compile
/yourthing/lib/provided /your-thing/lib/compile/modules
/yourthing/lib/runtime /your-thing/lib/provided
/yourthing/lib/test /your-thing/lib/provided/modules
/yourthing/src /your-thing/lib/runtime
/yourthing/src/bld /your-thing/lib/runtime/modules
/yourthing/src/bld/java /your-thing/lib/test
/yourthing/src/bld/java/org /your-thing/lib/test/modules
/yourthing/src/bld/java/org/stuff /your-thing/src
/yourthing/src/bld/java/org/stuff/YourthingBuild.java /your-thing/src/bld
/yourthing/src/bld/resources /your-thing/src/bld/java
/yourthing/src/main /your-thing/src/bld/java/org
/yourthing/src/main/java /your-thing/src/bld/java/org/stuff
/yourthing/src/main/java/org /your-thing/src/bld/java/org/stuff/YourThingBuild.java
/yourthing/src/main/java/org/stuff /your-thing/src/bld/resources
/yourthing/src/main/java/org/stuff/YourthingMain.java /your-thing/src/main
/yourthing/src/main/resources /your-thing/src/main/java
/yourthing/src/main/resources/templates /your-thing/src/main/java/org
/yourthing/src/test /your-thing/src/main/java/org/stuff
/yourthing/src/test/java /your-thing/src/main/java/org/stuff/YourThing.java
/yourthing/src/test/java/org /your-thing/src/main/resources
/yourthing/src/test/java/org/stuff /your-thing/src/main/resources/templates
/yourthing/src/test/java/org/stuff/YourthingTest.java /your-thing/src/test
/yourthing/src/test/resources""", /your-thing/src/test/java
/your-thing/src/test/java/org
/your-thing/src/test/java/org/stuff
/your-thing/src/test/java/org/stuff/YourThingTest.java
/your-thing/src/test/resources""",
FileUtils.generateDirectoryListing(tmp)); FileUtils.generateDirectoryListing(tmp));
var compile_operation = new CompileOperation() { var compile_operation = new CompileOperation() {
@ -315,7 +329,8 @@ public class TestCreateAppOperation {
var create_operation = new CreateAppOperation() var create_operation = new CreateAppOperation()
.workDirectory(tmp) .workDirectory(tmp)
.packageName("com.example") .packageName("com.example")
.projectName("myapp") .projectName("my-app")
.baseName("MyApp")
.downloadDependencies(true); .downloadDependencies(true);
create_operation.execute(); create_operation.execute();
@ -338,84 +353,87 @@ public class TestCreateAppOperation {
var compile_operation = new CompileOperation().fromProject(create_operation.project()); var compile_operation = new CompileOperation().fromProject(create_operation.project());
compile_operation.execute(); compile_operation.execute();
assertTrue(compile_operation.diagnostics().isEmpty()); assertTrue(compile_operation.diagnostics().isEmpty());
System.out.println(FileUtils.generateDirectoryListing(tmp));
assertTrue(Pattern.compile(""" assertTrue(Pattern.compile("""
/myapp /my-app
/myapp/\\.gitignore /my-app/\\.gitignore
/myapp/\\.idea /my-app/\\.idea
/myapp/\\.idea/app\\.iml /my-app/\\.idea/app\\.iml
/myapp/\\.idea/bld\\.iml /my-app/\\.idea/bld\\.iml
/myapp/\\.idea/libraries /my-app/\\.idea/libraries
/myapp/\\.idea/libraries/bld\\.xml /my-app/\\.idea/libraries/bld\\.xml
/myapp/\\.idea/libraries/compile\\.xml /my-app/\\.idea/libraries/compile\\.xml
/myapp/\\.idea/libraries/runtime\\.xml /my-app/\\.idea/libraries/runtime\\.xml
/myapp/\\.idea/libraries/test\\.xml /my-app/\\.idea/libraries/test\\.xml
/myapp/\\.idea/misc\\.xml /my-app/\\.idea/misc\\.xml
/myapp/\\.idea/modules\\.xml /my-app/\\.idea/modules\\.xml
/myapp/\\.idea/runConfigurations /my-app/\\.idea/runConfigurations
/myapp/\\.idea/runConfigurations/Run Main\\.xml /my-app/\\.idea/runConfigurations/Run Main\\.xml
/myapp/\\.idea/runConfigurations/Run Tests\\.xml /my-app/\\.idea/runConfigurations/Run Tests\\.xml
/myapp/\\.vscode /my-app/\\.vscode
/myapp/\\.vscode/launch\\.json /my-app/\\.vscode/launch\\.json
/myapp/\\.vscode/settings\\.json /my-app/\\.vscode/settings\\.json
/myapp/bld /my-app/bld
/myapp/bld\\.bat /my-app/bld\\.bat
/myapp/build /my-app/build
/myapp/build/main /my-app/build/main
/myapp/build/main/com /my-app/build/main/com
/myapp/build/main/com/example /my-app/build/main/com/example
/myapp/build/main/com/example/MyappMain\\.class /my-app/build/main/com/example/MyApp\\.class
/myapp/build/test /my-app/build/test
/myapp/build/test/com /my-app/build/test/com
/myapp/build/test/com/example /my-app/build/test/com/example
/myapp/build/test/com/example/MyappTest\\.class /my-app/build/test/com/example/MyAppTest\\.class
/myapp/lib /my-app/lib
/myapp/lib/bld /my-app/lib/bld
/myapp/lib/bld/bld-wrapper\\.jar /my-app/lib/bld/bld-wrapper\\.jar
/myapp/lib/bld/bld-wrapper\\.properties /my-app/lib/bld/bld-wrapper\\.properties
/myapp/lib/compile /my-app/lib/compile
/myapp/lib/local /my-app/lib/compile/modules
/myapp/lib/local/apiguardian-api-1\\.1\\.2-sources\\.jar /my-app/lib/local
/myapp/lib/local/apiguardian-api-1\\.1\\.2\\.jar /my-app/lib/local/apiguardian-api-1\\.1\\.2-sources\\.jar
/myapp/lib/local/junit-jupiter-5\\.10\\.3-sources\\.jar /my-app/lib/local/apiguardian-api-1\\.1\\.2\\.jar
/myapp/lib/local/junit-jupiter-5\\.10\\.3\\.jar /my-app/lib/local/junit-jupiter-5\\.11\\.4-sources\\.jar
/myapp/lib/local/junit-jupiter-api-5\\.10\\.3-sources\\.jar /my-app/lib/local/junit-jupiter-5\\.11\\.4\\.jar
/myapp/lib/local/junit-jupiter-api-5\\.10\\.3\\.jar /my-app/lib/local/junit-jupiter-api-5\\.11\\.4-sources\\.jar
/myapp/lib/local/junit-jupiter-engine-5\\.10\\.3-sources\\.jar /my-app/lib/local/junit-jupiter-api-5\\.11\\.4\\.jar
/myapp/lib/local/junit-jupiter-engine-5\\.10\\.3\\.jar /my-app/lib/local/junit-jupiter-engine-5\\.11\\.4-sources\\.jar
/myapp/lib/local/junit-jupiter-params-5\\.10\\.3-sources\\.jar /my-app/lib/local/junit-jupiter-engine-5\\.11\\.4\\.jar
/myapp/lib/local/junit-jupiter-params-5\\.10\\.3\\.jar /my-app/lib/local/junit-jupiter-params-5\\.11\\.4-sources\\.jar
/myapp/lib/local/junit-platform-commons-1\\.10\\.3-sources\\.jar /my-app/lib/local/junit-jupiter-params-5\\.11\\.4\\.jar
/myapp/lib/local/junit-platform-commons-1\\.10\\.3\\.jar /my-app/lib/local/junit-platform-commons-1\\.11\\.4-sources\\.jar
/myapp/lib/local/junit-platform-console-standalone-1\\.10\\.3-sources\\.jar /my-app/lib/local/junit-platform-commons-1\\.11\\.4\\.jar
/myapp/lib/local/junit-platform-console-standalone-1\\.10\\.3\\.jar /my-app/lib/local/junit-platform-console-standalone-1\\.11\\.4-sources\\.jar
/myapp/lib/local/junit-platform-engine-1\\.10\\.3-sources\\.jar /my-app/lib/local/junit-platform-console-standalone-1\\.11\\.4\\.jar
/myapp/lib/local/junit-platform-engine-1\\.10\\.3\\.jar /my-app/lib/local/junit-platform-engine-1\\.11\\.4-sources\\.jar
/myapp/lib/local/opentest4j-1\\.3\\.0-sources\\.jar /my-app/lib/local/junit-platform-engine-1\\.11\\.4\\.jar
/myapp/lib/local/opentest4j-1\\.3\\.0\\.jar /my-app/lib/local/opentest4j-1\\.3\\.0-sources\\.jar
/myapp/lib/provided /my-app/lib/local/opentest4j-1\\.3\\.0\\.jar
/myapp/lib/runtime /my-app/lib/provided
/myapp/lib/test /my-app/lib/provided/modules
/myapp/src /my-app/lib/runtime
/myapp/src/bld /my-app/lib/runtime/modules
/myapp/src/bld/java /my-app/lib/test
/myapp/src/bld/java/com /my-app/lib/test/modules
/myapp/src/bld/java/com/example /my-app/src
/myapp/src/bld/java/com/example/MyappBuild\\.java /my-app/src/bld
/myapp/src/bld/resources /my-app/src/bld/java
/myapp/src/main /my-app/src/bld/java/com
/myapp/src/main/java /my-app/src/bld/java/com/example
/myapp/src/main/java/com /my-app/src/bld/java/com/example/MyAppBuild\\.java
/myapp/src/main/java/com/example /my-app/src/bld/resources
/myapp/src/main/java/com/example/MyappMain\\.java /my-app/src/main
/myapp/src/main/resources /my-app/src/main/java
/myapp/src/main/resources/templates /my-app/src/main/java/com
/myapp/src/test /my-app/src/main/java/com/example
/myapp/src/test/java /my-app/src/main/java/com/example/MyApp\\.java
/myapp/src/test/java/com /my-app/src/main/resources
/myapp/src/test/java/com/example /my-app/src/main/resources/templates
/myapp/src/test/java/com/example/MyappTest\\.java /my-app/src/test
/myapp/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches()); /my-app/src/test/java
/my-app/src/test/java/com
/my-app/src/test/java/com/example
/my-app/src/test/java/com/example/MyAppTest\\.java
/my-app/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches());
var check_result = new StringBuilder(); var check_result = new StringBuilder();
new RunOperation() new RunOperation()
@ -439,7 +457,8 @@ public class TestCreateAppOperation {
var create_operation = new CreateAppOperation() var create_operation = new CreateAppOperation()
.workDirectory(tmp) .workDirectory(tmp)
.packageName("com.example") .packageName("com.example")
.projectName("myapp") .projectName("my-app")
.baseName("MyApp")
.downloadDependencies(true); .downloadDependencies(true);
create_operation.execute(); create_operation.execute();
@ -461,83 +480,87 @@ public class TestCreateAppOperation {
compile_operation.execute(); compile_operation.execute();
assertTrue(compile_operation.diagnostics().isEmpty()); assertTrue(compile_operation.diagnostics().isEmpty());
assertTrue(Pattern.compile(""" assertTrue(Pattern.compile("""
/myapp /my-app
/myapp/\\.gitignore /my-app/\\.gitignore
/myapp/\\.idea /my-app/\\.idea
/myapp/\\.idea/app\\.iml /my-app/\\.idea/app\\.iml
/myapp/\\.idea/bld\\.iml /my-app/\\.idea/bld\\.iml
/myapp/\\.idea/libraries /my-app/\\.idea/libraries
/myapp/\\.idea/libraries/bld\\.xml /my-app/\\.idea/libraries/bld\\.xml
/myapp/\\.idea/libraries/compile\\.xml /my-app/\\.idea/libraries/compile\\.xml
/myapp/\\.idea/libraries/runtime\\.xml /my-app/\\.idea/libraries/runtime\\.xml
/myapp/\\.idea/libraries/test\\.xml /my-app/\\.idea/libraries/test\\.xml
/myapp/\\.idea/misc\\.xml /my-app/\\.idea/misc\\.xml
/myapp/\\.idea/modules\\.xml /my-app/\\.idea/modules\\.xml
/myapp/\\.idea/runConfigurations /my-app/\\.idea/runConfigurations
/myapp/\\.idea/runConfigurations/Run Main\\.xml /my-app/\\.idea/runConfigurations/Run Main\\.xml
/myapp/\\.idea/runConfigurations/Run Tests\\.xml /my-app/\\.idea/runConfigurations/Run Tests\\.xml
/myapp/\\.vscode /my-app/\\.vscode
/myapp/\\.vscode/launch\\.json /my-app/\\.vscode/launch\\.json
/myapp/\\.vscode/settings\\.json /my-app/\\.vscode/settings\\.json
/myapp/bld /my-app/bld
/myapp/bld\\.bat /my-app/bld\\.bat
/myapp/build /my-app/build
/myapp/build/main /my-app/build/main
/myapp/build/main/com /my-app/build/main/com
/myapp/build/main/com/example /my-app/build/main/com/example
/myapp/build/main/com/example/MyappMain\\.class /my-app/build/main/com/example/MyApp\\.class
/myapp/build/test /my-app/build/test
/myapp/build/test/com /my-app/build/test/com
/myapp/build/test/com/example /my-app/build/test/com/example
/myapp/build/test/com/example/MyappTest\\.class /my-app/build/test/com/example/MyAppTest\\.class
/myapp/lib /my-app/lib
/myapp/lib/bld /my-app/lib/bld
/myapp/lib/bld/bld-wrapper\\.jar /my-app/lib/bld/bld-wrapper\\.jar
/myapp/lib/bld/bld-wrapper\\.properties /my-app/lib/bld/bld-wrapper\\.properties
/myapp/lib/compile /my-app/lib/compile
/myapp/lib/local_compile /my-app/lib/compile/modules
/myapp/lib/local_test /my-app/lib/local_compile
/myapp/lib/local_test/apiguardian-api-1\\.1\\.2-sources\\.jar /my-app/lib/local_test
/myapp/lib/local_test/apiguardian-api-1\\.1\\.2\\.jar /my-app/lib/local_test/apiguardian-api-1\\.1\\.2-sources\\.jar
/myapp/lib/local_test/junit-jupiter-5\\.10\\.3-sources\\.jar /my-app/lib/local_test/apiguardian-api-1\\.1\\.2\\.jar
/myapp/lib/local_test/junit-jupiter-5\\.10\\.3\\.jar /my-app/lib/local_test/junit-jupiter-5\\.11\\.4-sources\\.jar
/myapp/lib/local_test/junit-jupiter-api-5\\.10\\.3-sources\\.jar /my-app/lib/local_test/junit-jupiter-5\\.11\\.4\\.jar
/myapp/lib/local_test/junit-jupiter-api-5\\.10\\.3\\.jar /my-app/lib/local_test/junit-jupiter-api-5\\.11\\.4-sources\\.jar
/myapp/lib/local_test/junit-jupiter-engine-5\\.10\\.3-sources\\.jar /my-app/lib/local_test/junit-jupiter-api-5\\.11\\.4\\.jar
/myapp/lib/local_test/junit-jupiter-engine-5\\.10\\.3\\.jar /my-app/lib/local_test/junit-jupiter-engine-5\\.11\\.4-sources\\.jar
/myapp/lib/local_test/junit-jupiter-params-5\\.10\\.3-sources\\.jar /my-app/lib/local_test/junit-jupiter-engine-5\\.11\\.4\\.jar
/myapp/lib/local_test/junit-jupiter-params-5\\.10\\.3\\.jar /my-app/lib/local_test/junit-jupiter-params-5\\.11\\.4-sources\\.jar
/myapp/lib/local_test/junit-platform-commons-1\\.10\\.3-sources\\.jar /my-app/lib/local_test/junit-jupiter-params-5\\.11\\.4\\.jar
/myapp/lib/local_test/junit-platform-commons-1\\.10\\.3\\.jar /my-app/lib/local_test/junit-platform-commons-1\\.11\\.4-sources\\.jar
/myapp/lib/local_test/junit-platform-console-standalone-1\\.10\\.3-sources\\.jar /my-app/lib/local_test/junit-platform-commons-1\\.11\\.4\\.jar
/myapp/lib/local_test/junit-platform-console-standalone-1\\.10\\.3\\.jar /my-app/lib/local_test/junit-platform-console-standalone-1\\.11\\.4-sources\\.jar
/myapp/lib/local_test/junit-platform-engine-1\\.10\\.3-sources\\.jar /my-app/lib/local_test/junit-platform-console-standalone-1\\.11\\.4\\.jar
/myapp/lib/local_test/junit-platform-engine-1\\.10\\.3\\.jar /my-app/lib/local_test/junit-platform-engine-1\\.11\\.4-sources\\.jar
/myapp/lib/local_test/opentest4j-1\\.3\\.0-sources\\.jar /my-app/lib/local_test/junit-platform-engine-1\\.11\\.4\\.jar
/myapp/lib/local_test/opentest4j-1\\.3\\.0\\.jar /my-app/lib/local_test/opentest4j-1\\.3\\.0-sources\\.jar
/myapp/lib/provided /my-app/lib/local_test/opentest4j-1\\.3\\.0\\.jar
/myapp/lib/runtime /my-app/lib/provided
/myapp/lib/test /my-app/lib/provided/modules
/myapp/src /my-app/lib/runtime
/myapp/src/bld /my-app/lib/runtime/modules
/myapp/src/bld/java /my-app/lib/test
/myapp/src/bld/java/com /my-app/lib/test/modules
/myapp/src/bld/java/com/example /my-app/src
/myapp/src/bld/java/com/example/MyappBuild\\.java /my-app/src/bld
/myapp/src/bld/resources /my-app/src/bld/java
/myapp/src/main /my-app/src/bld/java/com
/myapp/src/main/java /my-app/src/bld/java/com/example
/myapp/src/main/java/com /my-app/src/bld/java/com/example/MyAppBuild\\.java
/myapp/src/main/java/com/example /my-app/src/bld/resources
/myapp/src/main/java/com/example/MyappMain\\.java /my-app/src/main
/myapp/src/main/resources /my-app/src/main/java
/myapp/src/main/resources/templates /my-app/src/main/java/com
/myapp/src/test /my-app/src/main/java/com/example
/myapp/src/test/java /my-app/src/main/java/com/example/MyApp\\.java
/myapp/src/test/java/com /my-app/src/main/resources
/myapp/src/test/java/com/example /my-app/src/main/resources/templates
/myapp/src/test/java/com/example/MyappTest\\.java /my-app/src/test
/myapp/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches()); /my-app/src/test/java
/my-app/src/test/java/com
/my-app/src/test/java/com/example
/my-app/src/test/java/com/example/MyAppTest\\.java
/my-app/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches());
var check_result = new StringBuilder(); var check_result = new StringBuilder();
new RunOperation() new RunOperation()

View file

@ -58,121 +58,130 @@ public class TestCreateBaseOperation {
var create_operation = new CreateBaseOperation() var create_operation = new CreateBaseOperation()
.workDirectory(tmp) .workDirectory(tmp)
.packageName("com.example") .packageName("com.example")
.projectName("myapp") .projectName("my-app")
.baseName("MyApp")
.downloadDependencies(true); .downloadDependencies(true);
create_operation.execute(); create_operation.execute();
assertTrue(Pattern.compile(""" assertTrue(Pattern.compile("""
/myapp /my-app
/myapp/\\.gitignore /my-app/\\.gitignore
/myapp/\\.idea /my-app/\\.idea
/myapp/\\.idea/app\\.iml /my-app/\\.idea/app\\.iml
/myapp/\\.idea/bld\\.iml /my-app/\\.idea/bld\\.iml
/myapp/\\.idea/libraries /my-app/\\.idea/libraries
/myapp/\\.idea/libraries/bld\\.xml /my-app/\\.idea/libraries/bld\\.xml
/myapp/\\.idea/libraries/compile\\.xml /my-app/\\.idea/libraries/compile\\.xml
/myapp/\\.idea/libraries/runtime\\.xml /my-app/\\.idea/libraries/runtime\\.xml
/myapp/\\.idea/libraries/test\\.xml /my-app/\\.idea/libraries/test\\.xml
/myapp/\\.idea/misc\\.xml /my-app/\\.idea/misc\\.xml
/myapp/\\.idea/modules\\.xml /my-app/\\.idea/modules\\.xml
/myapp/\\.idea/runConfigurations /my-app/\\.idea/runConfigurations
/myapp/\\.idea/runConfigurations/Run Main\\.xml /my-app/\\.idea/runConfigurations/Run Main\\.xml
/myapp/\\.idea/runConfigurations/Run Tests\\.xml /my-app/\\.idea/runConfigurations/Run Tests\\.xml
/myapp/\\.vscode /my-app/\\.vscode
/myapp/\\.vscode/launch\\.json /my-app/\\.vscode/launch\\.json
/myapp/\\.vscode/settings\\.json /my-app/\\.vscode/settings\\.json
/myapp/bld /my-app/bld
/myapp/bld\\.bat /my-app/bld\\.bat
/myapp/lib /my-app/lib
/myapp/lib/bld /my-app/lib/bld
/myapp/lib/bld/bld-wrapper\\.jar /my-app/lib/bld/bld-wrapper\\.jar
/myapp/lib/bld/bld-wrapper\\.properties /my-app/lib/bld/bld-wrapper\\.properties
/myapp/lib/compile /my-app/lib/compile
/myapp/lib/provided /my-app/lib/compile/modules
/myapp/lib/runtime /my-app/lib/provided
/myapp/lib/test /my-app/lib/provided/modules
/myapp/src /my-app/lib/runtime
/myapp/src/bld /my-app/lib/runtime/modules
/myapp/src/bld/java /my-app/lib/test
/myapp/src/bld/java/com /my-app/lib/test/modules
/myapp/src/bld/java/com/example /my-app/src
/myapp/src/bld/java/com/example/MyappBuild\\.java /my-app/src/bld
/myapp/src/bld/resources /my-app/src/bld/java
/myapp/src/main /my-app/src/bld/java/com
/myapp/src/main/java /my-app/src/bld/java/com/example
/myapp/src/main/java/com /my-app/src/bld/java/com/example/MyAppBuild\\.java
/myapp/src/main/java/com/example /my-app/src/bld/resources
/myapp/src/main/java/com/example/MyappMain\\.java /my-app/src/main
/myapp/src/main/resources /my-app/src/main/java
/myapp/src/main/resources/templates /my-app/src/main/java/com
/myapp/src/test /my-app/src/main/java/com/example
/myapp/src/test/java /my-app/src/main/java/com/example/MyApp\\.java
/myapp/src/test/java/com /my-app/src/main/resources
/myapp/src/test/java/com/example /my-app/src/main/resources/templates
/myapp/src/test/java/com/example/MyappTest\\.java /my-app/src/test
/myapp/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches()); /my-app/src/test/java
/my-app/src/test/java/com
/my-app/src/test/java/com/example
/my-app/src/test/java/com/example/MyAppTest\\.java
/my-app/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches());
var compile_operation = new CompileOperation().fromProject(create_operation.project()); var compile_operation = new CompileOperation().fromProject(create_operation.project());
compile_operation.execute(); compile_operation.execute();
assertTrue(compile_operation.diagnostics().isEmpty()); assertTrue(compile_operation.diagnostics().isEmpty());
assertTrue(Pattern.compile(""" assertTrue(Pattern.compile("""
/myapp /my-app
/myapp/\\.gitignore /my-app/\\.gitignore
/myapp/\\.idea /my-app/\\.idea
/myapp/\\.idea/app\\.iml /my-app/\\.idea/app\\.iml
/myapp/\\.idea/bld\\.iml /my-app/\\.idea/bld\\.iml
/myapp/\\.idea/libraries /my-app/\\.idea/libraries
/myapp/\\.idea/libraries/bld\\.xml /my-app/\\.idea/libraries/bld\\.xml
/myapp/\\.idea/libraries/compile\\.xml /my-app/\\.idea/libraries/compile\\.xml
/myapp/\\.idea/libraries/runtime\\.xml /my-app/\\.idea/libraries/runtime\\.xml
/myapp/\\.idea/libraries/test\\.xml /my-app/\\.idea/libraries/test\\.xml
/myapp/\\.idea/misc\\.xml /my-app/\\.idea/misc\\.xml
/myapp/\\.idea/modules\\.xml /my-app/\\.idea/modules\\.xml
/myapp/\\.idea/runConfigurations /my-app/\\.idea/runConfigurations
/myapp/\\.idea/runConfigurations/Run Main\\.xml /my-app/\\.idea/runConfigurations/Run Main\\.xml
/myapp/\\.idea/runConfigurations/Run Tests\\.xml /my-app/\\.idea/runConfigurations/Run Tests\\.xml
/myapp/\\.vscode /my-app/\\.vscode
/myapp/\\.vscode/launch\\.json /my-app/\\.vscode/launch\\.json
/myapp/\\.vscode/settings\\.json /my-app/\\.vscode/settings\\.json
/myapp/bld /my-app/bld
/myapp/bld\\.bat /my-app/bld\\.bat
/myapp/build /my-app/build
/myapp/build/main /my-app/build/main
/myapp/build/main/com /my-app/build/main/com
/myapp/build/main/com/example /my-app/build/main/com/example
/myapp/build/main/com/example/MyappMain\\.class /my-app/build/main/com/example/MyApp\\.class
/myapp/build/test /my-app/build/test
/myapp/build/test/com /my-app/build/test/com
/myapp/build/test/com/example /my-app/build/test/com/example
/myapp/build/test/com/example/MyappTest\\.class /my-app/build/test/com/example/MyAppTest\\.class
/myapp/lib /my-app/lib
/myapp/lib/bld /my-app/lib/bld
/myapp/lib/bld/bld-wrapper\\.jar /my-app/lib/bld/bld-wrapper\\.jar
/myapp/lib/bld/bld-wrapper\\.properties /my-app/lib/bld/bld-wrapper\\.properties
/myapp/lib/compile /my-app/lib/compile
/myapp/lib/provided /my-app/lib/compile/modules
/myapp/lib/runtime /my-app/lib/provided
/myapp/lib/test /my-app/lib/provided/modules
/myapp/src /my-app/lib/runtime
/myapp/src/bld /my-app/lib/runtime/modules
/myapp/src/bld/java /my-app/lib/test
/myapp/src/bld/java/com /my-app/lib/test/modules
/myapp/src/bld/java/com/example /my-app/src
/myapp/src/bld/java/com/example/MyappBuild\\.java /my-app/src/bld
/myapp/src/bld/resources /my-app/src/bld/java
/myapp/src/main /my-app/src/bld/java/com
/myapp/src/main/java /my-app/src/bld/java/com/example
/myapp/src/main/java/com /my-app/src/bld/java/com/example/MyAppBuild\\.java
/myapp/src/main/java/com/example /my-app/src/bld/resources
/myapp/src/main/java/com/example/MyappMain\\.java /my-app/src/main
/myapp/src/main/resources /my-app/src/main/java
/myapp/src/main/resources/templates /my-app/src/main/java/com
/myapp/src/test /my-app/src/main/java/com/example
/myapp/src/test/java /my-app/src/main/java/com/example/MyApp\\.java
/myapp/src/test/java/com /my-app/src/main/resources
/myapp/src/test/java/com/example /my-app/src/main/resources/templates
/myapp/src/test/java/com/example/MyappTest\\.java /my-app/src/test
/myapp/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches()); /my-app/src/test/java
/my-app/src/test/java/com
/my-app/src/test/java/com/example
/my-app/src/test/java/com/example/MyAppTest\\.java
/my-app/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches());
var check_result = new StringBuilder(); var check_result = new StringBuilder();
new RunOperation() new RunOperation()
@ -196,121 +205,130 @@ public class TestCreateBaseOperation {
var create_operation = new CreateBaseOperation() var create_operation = new CreateBaseOperation()
.workDirectory(tmp) .workDirectory(tmp)
.packageName("org.stuff") .packageName("org.stuff")
.projectName("yourthing"); .projectName("your-thing")
.baseName("YourThing");
create_operation.execute(); create_operation.execute();
assertEquals(""" assertEquals("""
/yourthing /your-thing
/yourthing/.gitignore /your-thing/.gitignore
/yourthing/.idea /your-thing/.idea
/yourthing/.idea/app.iml /your-thing/.idea/app.iml
/yourthing/.idea/bld.iml /your-thing/.idea/bld.iml
/yourthing/.idea/libraries /your-thing/.idea/libraries
/yourthing/.idea/libraries/bld.xml /your-thing/.idea/libraries/bld.xml
/yourthing/.idea/libraries/compile.xml /your-thing/.idea/libraries/compile.xml
/yourthing/.idea/libraries/runtime.xml /your-thing/.idea/libraries/runtime.xml
/yourthing/.idea/libraries/test.xml /your-thing/.idea/libraries/test.xml
/yourthing/.idea/misc.xml /your-thing/.idea/misc.xml
/yourthing/.idea/modules.xml /your-thing/.idea/modules.xml
/yourthing/.idea/runConfigurations /your-thing/.idea/runConfigurations
/yourthing/.idea/runConfigurations/Run Main.xml /your-thing/.idea/runConfigurations/Run Main.xml
/yourthing/.idea/runConfigurations/Run Tests.xml /your-thing/.idea/runConfigurations/Run Tests.xml
/yourthing/.vscode /your-thing/.vscode
/yourthing/.vscode/launch.json /your-thing/.vscode/launch.json
/yourthing/.vscode/settings.json /your-thing/.vscode/settings.json
/yourthing/bld /your-thing/bld
/yourthing/bld.bat /your-thing/bld.bat
/yourthing/lib /your-thing/lib
/yourthing/lib/bld /your-thing/lib/bld
/yourthing/lib/bld/bld-wrapper.jar /your-thing/lib/bld/bld-wrapper.jar
/yourthing/lib/bld/bld-wrapper.properties /your-thing/lib/bld/bld-wrapper.properties
/yourthing/lib/compile /your-thing/lib/compile
/yourthing/lib/provided /your-thing/lib/compile/modules
/yourthing/lib/runtime /your-thing/lib/provided
/yourthing/lib/test /your-thing/lib/provided/modules
/yourthing/src /your-thing/lib/runtime
/yourthing/src/bld /your-thing/lib/runtime/modules
/yourthing/src/bld/java /your-thing/lib/test
/yourthing/src/bld/java/org /your-thing/lib/test/modules
/yourthing/src/bld/java/org/stuff /your-thing/src
/yourthing/src/bld/java/org/stuff/YourthingBuild.java /your-thing/src/bld
/yourthing/src/bld/resources /your-thing/src/bld/java
/yourthing/src/main /your-thing/src/bld/java/org
/yourthing/src/main/java /your-thing/src/bld/java/org/stuff
/yourthing/src/main/java/org /your-thing/src/bld/java/org/stuff/YourThingBuild.java
/yourthing/src/main/java/org/stuff /your-thing/src/bld/resources
/yourthing/src/main/java/org/stuff/YourthingMain.java /your-thing/src/main
/yourthing/src/main/resources /your-thing/src/main/java
/yourthing/src/main/resources/templates /your-thing/src/main/java/org
/yourthing/src/test /your-thing/src/main/java/org/stuff
/yourthing/src/test/java /your-thing/src/main/java/org/stuff/YourThing.java
/yourthing/src/test/java/org /your-thing/src/main/resources
/yourthing/src/test/java/org/stuff /your-thing/src/main/resources/templates
/yourthing/src/test/java/org/stuff/YourthingTest.java /your-thing/src/test
/yourthing/src/test/resources""", /your-thing/src/test/java
/your-thing/src/test/java/org
/your-thing/src/test/java/org/stuff
/your-thing/src/test/java/org/stuff/YourThingTest.java
/your-thing/src/test/resources""",
FileUtils.generateDirectoryListing(tmp)); FileUtils.generateDirectoryListing(tmp));
var compile_operation = new CompileOperation().fromProject(create_operation.project()); var compile_operation = new CompileOperation().fromProject(create_operation.project());
compile_operation.execute(); compile_operation.execute();
assertTrue(compile_operation.diagnostics().isEmpty()); assertTrue(compile_operation.diagnostics().isEmpty());
assertEquals(""" assertEquals("""
/yourthing /your-thing
/yourthing/.gitignore /your-thing/.gitignore
/yourthing/.idea /your-thing/.idea
/yourthing/.idea/app.iml /your-thing/.idea/app.iml
/yourthing/.idea/bld.iml /your-thing/.idea/bld.iml
/yourthing/.idea/libraries /your-thing/.idea/libraries
/yourthing/.idea/libraries/bld.xml /your-thing/.idea/libraries/bld.xml
/yourthing/.idea/libraries/compile.xml /your-thing/.idea/libraries/compile.xml
/yourthing/.idea/libraries/runtime.xml /your-thing/.idea/libraries/runtime.xml
/yourthing/.idea/libraries/test.xml /your-thing/.idea/libraries/test.xml
/yourthing/.idea/misc.xml /your-thing/.idea/misc.xml
/yourthing/.idea/modules.xml /your-thing/.idea/modules.xml
/yourthing/.idea/runConfigurations /your-thing/.idea/runConfigurations
/yourthing/.idea/runConfigurations/Run Main.xml /your-thing/.idea/runConfigurations/Run Main.xml
/yourthing/.idea/runConfigurations/Run Tests.xml /your-thing/.idea/runConfigurations/Run Tests.xml
/yourthing/.vscode /your-thing/.vscode
/yourthing/.vscode/launch.json /your-thing/.vscode/launch.json
/yourthing/.vscode/settings.json /your-thing/.vscode/settings.json
/yourthing/bld /your-thing/bld
/yourthing/bld.bat /your-thing/bld.bat
/yourthing/build /your-thing/build
/yourthing/build/main /your-thing/build/main
/yourthing/build/main/org /your-thing/build/main/org
/yourthing/build/main/org/stuff /your-thing/build/main/org/stuff
/yourthing/build/main/org/stuff/YourthingMain.class /your-thing/build/main/org/stuff/YourThing.class
/yourthing/build/test /your-thing/build/test
/yourthing/build/test/org /your-thing/build/test/org
/yourthing/build/test/org/stuff /your-thing/build/test/org/stuff
/yourthing/build/test/org/stuff/YourthingTest.class /your-thing/build/test/org/stuff/YourThingTest.class
/yourthing/lib /your-thing/lib
/yourthing/lib/bld /your-thing/lib/bld
/yourthing/lib/bld/bld-wrapper.jar /your-thing/lib/bld/bld-wrapper.jar
/yourthing/lib/bld/bld-wrapper.properties /your-thing/lib/bld/bld-wrapper.properties
/yourthing/lib/compile /your-thing/lib/compile
/yourthing/lib/provided /your-thing/lib/compile/modules
/yourthing/lib/runtime /your-thing/lib/provided
/yourthing/lib/test /your-thing/lib/provided/modules
/yourthing/src /your-thing/lib/runtime
/yourthing/src/bld /your-thing/lib/runtime/modules
/yourthing/src/bld/java /your-thing/lib/test
/yourthing/src/bld/java/org /your-thing/lib/test/modules
/yourthing/src/bld/java/org/stuff /your-thing/src
/yourthing/src/bld/java/org/stuff/YourthingBuild.java /your-thing/src/bld
/yourthing/src/bld/resources /your-thing/src/bld/java
/yourthing/src/main /your-thing/src/bld/java/org
/yourthing/src/main/java /your-thing/src/bld/java/org/stuff
/yourthing/src/main/java/org /your-thing/src/bld/java/org/stuff/YourThingBuild.java
/yourthing/src/main/java/org/stuff /your-thing/src/bld/resources
/yourthing/src/main/java/org/stuff/YourthingMain.java /your-thing/src/main
/yourthing/src/main/resources /your-thing/src/main/java
/yourthing/src/main/resources/templates /your-thing/src/main/java/org
/yourthing/src/test /your-thing/src/main/java/org/stuff
/yourthing/src/test/java /your-thing/src/main/java/org/stuff/YourThing.java
/yourthing/src/test/java/org /your-thing/src/main/resources
/yourthing/src/test/java/org/stuff /your-thing/src/main/resources/templates
/yourthing/src/test/java/org/stuff/YourthingTest.java /your-thing/src/test
/yourthing/src/test/resources""", /your-thing/src/test/java
/your-thing/src/test/java/org
/your-thing/src/test/java/org/stuff
/your-thing/src/test/java/org/stuff/YourThingTest.java
/your-thing/src/test/resources""",
FileUtils.generateDirectoryListing(tmp)); FileUtils.generateDirectoryListing(tmp));
var check_result = new StringBuilder(); var check_result = new StringBuilder();

View file

@ -58,155 +58,164 @@ public class TestCreateLibOperation {
var create_operation = new CreateLibOperation() var create_operation = new CreateLibOperation()
.workDirectory(tmp) .workDirectory(tmp)
.packageName("com.example") .packageName("com.example")
.projectName("myapp") .projectName("my-app")
.baseName("MyApp")
.downloadDependencies(true); .downloadDependencies(true);
create_operation.execute(); create_operation.execute();
assertTrue(Pattern.compile(""" assertTrue(Pattern.compile("""
/myapp /my-app
/myapp/\\.gitignore /my-app/\\.gitignore
/myapp/\\.idea /my-app/\\.idea
/myapp/\\.idea/app\\.iml /my-app/\\.idea/app\\.iml
/myapp/\\.idea/bld\\.iml /my-app/\\.idea/bld\\.iml
/myapp/\\.idea/libraries /my-app/\\.idea/libraries
/myapp/\\.idea/libraries/bld\\.xml /my-app/\\.idea/libraries/bld\\.xml
/myapp/\\.idea/libraries/compile\\.xml /my-app/\\.idea/libraries/compile\\.xml
/myapp/\\.idea/libraries/runtime\\.xml /my-app/\\.idea/libraries/runtime\\.xml
/myapp/\\.idea/libraries/test\\.xml /my-app/\\.idea/libraries/test\\.xml
/myapp/\\.idea/misc\\.xml /my-app/\\.idea/misc\\.xml
/myapp/\\.idea/modules\\.xml /my-app/\\.idea/modules\\.xml
/myapp/\\.idea/runConfigurations /my-app/\\.idea/runConfigurations
/myapp/\\.idea/runConfigurations/Run Tests\\.xml /my-app/\\.idea/runConfigurations/Run Tests\\.xml
/myapp/\\.vscode /my-app/\\.vscode
/myapp/\\.vscode/launch\\.json /my-app/\\.vscode/launch\\.json
/myapp/\\.vscode/settings\\.json /my-app/\\.vscode/settings\\.json
/myapp/bld /my-app/bld
/myapp/bld\\.bat /my-app/bld\\.bat
/myapp/lib /my-app/lib
/myapp/lib/bld /my-app/lib/bld
/myapp/lib/bld/bld-wrapper\\.jar /my-app/lib/bld/bld-wrapper\\.jar
/myapp/lib/bld/bld-wrapper\\.properties /my-app/lib/bld/bld-wrapper\\.properties
/myapp/lib/compile /my-app/lib/compile
/myapp/lib/provided /my-app/lib/compile/modules
/myapp/lib/runtime /my-app/lib/provided
/myapp/lib/test /my-app/lib/provided/modules
/myapp/lib/test/apiguardian-api-1\\.1\\.2-sources\\.jar /my-app/lib/runtime
/myapp/lib/test/apiguardian-api-1\\.1\\.2\\.jar /my-app/lib/runtime/modules
/myapp/lib/test/junit-jupiter-5\\.10\\.3-sources\\.jar /my-app/lib/test
/myapp/lib/test/junit-jupiter-5\\.10\\.3\\.jar /my-app/lib/test/apiguardian-api-1\\.1\\.2-sources\\.jar
/myapp/lib/test/junit-jupiter-api-5\\.10\\.3-sources\\.jar /my-app/lib/test/apiguardian-api-1\\.1\\.2\\.jar
/myapp/lib/test/junit-jupiter-api-5\\.10\\.3\\.jar /my-app/lib/test/junit-jupiter-5\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-jupiter-engine-5\\.10\\.3-sources\\.jar /my-app/lib/test/junit-jupiter-5\\.11\\.4\\.jar
/myapp/lib/test/junit-jupiter-engine-5\\.10\\.3\\.jar /my-app/lib/test/junit-jupiter-api-5\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-jupiter-params-5\\.10\\.3-sources\\.jar /my-app/lib/test/junit-jupiter-api-5\\.11\\.4\\.jar
/myapp/lib/test/junit-jupiter-params-5\\.10\\.3\\.jar /my-app/lib/test/junit-jupiter-engine-5\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-platform-commons-1\\.10\\.3-sources\\.jar /my-app/lib/test/junit-jupiter-engine-5\\.11\\.4\\.jar
/myapp/lib/test/junit-platform-commons-1\\.10\\.3\\.jar /my-app/lib/test/junit-jupiter-params-5\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-platform-console-standalone-1\\.10\\.3-sources\\.jar /my-app/lib/test/junit-jupiter-params-5\\.11\\.4\\.jar
/myapp/lib/test/junit-platform-console-standalone-1\\.10\\.3\\.jar /my-app/lib/test/junit-platform-commons-1\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-platform-engine-1\\.10\\.3-sources\\.jar /my-app/lib/test/junit-platform-commons-1\\.11\\.4\\.jar
/myapp/lib/test/junit-platform-engine-1\\.10\\.3\\.jar /my-app/lib/test/junit-platform-console-standalone-1\\.11\\.4-sources\\.jar
/myapp/lib/test/opentest4j-1\\.3\\.0-sources\\.jar /my-app/lib/test/junit-platform-console-standalone-1\\.11\\.4\\.jar
/myapp/lib/test/opentest4j-1\\.3\\.0\\.jar /my-app/lib/test/junit-platform-engine-1\\.11\\.4-sources\\.jar
/myapp/src /my-app/lib/test/junit-platform-engine-1\\.11\\.4\\.jar
/myapp/src/bld /my-app/lib/test/modules
/myapp/src/bld/java /my-app/lib/test/opentest4j-1\\.3\\.0-sources\\.jar
/myapp/src/bld/java/com /my-app/lib/test/opentest4j-1\\.3\\.0\\.jar
/myapp/src/bld/java/com/example /my-app/src
/myapp/src/bld/java/com/example/MyappBuild\\.java /my-app/src/bld
/myapp/src/bld/resources /my-app/src/bld/java
/myapp/src/main /my-app/src/bld/java/com
/myapp/src/main/java /my-app/src/bld/java/com/example
/myapp/src/main/java/com /my-app/src/bld/java/com/example/MyAppBuild\\.java
/myapp/src/main/java/com/example /my-app/src/bld/resources
/myapp/src/main/java/com/example/MyappLib\\.java /my-app/src/main
/myapp/src/main/resources /my-app/src/main/java
/myapp/src/main/resources/templates /my-app/src/main/java/com
/myapp/src/test /my-app/src/main/java/com/example
/myapp/src/test/java /my-app/src/main/java/com/example/MyApp\\.java
/myapp/src/test/java/com /my-app/src/main/resources
/myapp/src/test/java/com/example /my-app/src/main/resources/templates
/myapp/src/test/java/com/example/MyappTest\\.java /my-app/src/test
/myapp/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches()); /my-app/src/test/java
/my-app/src/test/java/com
/my-app/src/test/java/com/example
/my-app/src/test/java/com/example/MyAppTest\\.java
/my-app/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches());
var compile_operation = new CompileOperation().fromProject(create_operation.project()); var compile_operation = new CompileOperation().fromProject(create_operation.project());
compile_operation.execute(); compile_operation.execute();
assertTrue(compile_operation.diagnostics().isEmpty()); assertTrue(compile_operation.diagnostics().isEmpty());
assertTrue(Pattern.compile(""" assertTrue(Pattern.compile("""
/myapp /my-app
/myapp/\\.gitignore /my-app/\\.gitignore
/myapp/\\.idea /my-app/\\.idea
/myapp/\\.idea/app\\.iml /my-app/\\.idea/app\\.iml
/myapp/\\.idea/bld\\.iml /my-app/\\.idea/bld\\.iml
/myapp/\\.idea/libraries /my-app/\\.idea/libraries
/myapp/\\.idea/libraries/bld\\.xml /my-app/\\.idea/libraries/bld\\.xml
/myapp/\\.idea/libraries/compile\\.xml /my-app/\\.idea/libraries/compile\\.xml
/myapp/\\.idea/libraries/runtime\\.xml /my-app/\\.idea/libraries/runtime\\.xml
/myapp/\\.idea/libraries/test\\.xml /my-app/\\.idea/libraries/test\\.xml
/myapp/\\.idea/misc\\.xml /my-app/\\.idea/misc\\.xml
/myapp/\\.idea/modules\\.xml /my-app/\\.idea/modules\\.xml
/myapp/\\.idea/runConfigurations /my-app/\\.idea/runConfigurations
/myapp/\\.idea/runConfigurations/Run Tests\\.xml /my-app/\\.idea/runConfigurations/Run Tests\\.xml
/myapp/\\.vscode /my-app/\\.vscode
/myapp/\\.vscode/launch\\.json /my-app/\\.vscode/launch\\.json
/myapp/\\.vscode/settings\\.json /my-app/\\.vscode/settings\\.json
/myapp/bld /my-app/bld
/myapp/bld\\.bat /my-app/bld\\.bat
/myapp/build /my-app/build
/myapp/build/main /my-app/build/main
/myapp/build/main/com /my-app/build/main/com
/myapp/build/main/com/example /my-app/build/main/com/example
/myapp/build/main/com/example/MyappLib\\.class /my-app/build/main/com/example/MyApp\\.class
/myapp/build/test /my-app/build/test
/myapp/build/test/com /my-app/build/test/com
/myapp/build/test/com/example /my-app/build/test/com/example
/myapp/build/test/com/example/MyappTest\\.class /my-app/build/test/com/example/MyAppTest\\.class
/myapp/lib /my-app/lib
/myapp/lib/bld /my-app/lib/bld
/myapp/lib/bld/bld-wrapper\\.jar /my-app/lib/bld/bld-wrapper\\.jar
/myapp/lib/bld/bld-wrapper\\.properties /my-app/lib/bld/bld-wrapper\\.properties
/myapp/lib/compile /my-app/lib/compile
/myapp/lib/provided /my-app/lib/compile/modules
/myapp/lib/runtime /my-app/lib/provided
/myapp/lib/test /my-app/lib/provided/modules
/myapp/lib/test/apiguardian-api-1\\.1\\.2-sources\\.jar /my-app/lib/runtime
/myapp/lib/test/apiguardian-api-1\\.1\\.2\\.jar /my-app/lib/runtime/modules
/myapp/lib/test/junit-jupiter-5\\.10\\.3-sources\\.jar /my-app/lib/test
/myapp/lib/test/junit-jupiter-5\\.10\\.3\\.jar /my-app/lib/test/apiguardian-api-1\\.1\\.2-sources\\.jar
/myapp/lib/test/junit-jupiter-api-5\\.10\\.3-sources\\.jar /my-app/lib/test/apiguardian-api-1\\.1\\.2\\.jar
/myapp/lib/test/junit-jupiter-api-5\\.10\\.3\\.jar /my-app/lib/test/junit-jupiter-5\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-jupiter-engine-5\\.10\\.3-sources\\.jar /my-app/lib/test/junit-jupiter-5\\.11\\.4\\.jar
/myapp/lib/test/junit-jupiter-engine-5\\.10\\.3\\.jar /my-app/lib/test/junit-jupiter-api-5\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-jupiter-params-5\\.10\\.3-sources\\.jar /my-app/lib/test/junit-jupiter-api-5\\.11\\.4\\.jar
/myapp/lib/test/junit-jupiter-params-5\\.10\\.3\\.jar /my-app/lib/test/junit-jupiter-engine-5\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-platform-commons-1\\.10\\.3-sources\\.jar /my-app/lib/test/junit-jupiter-engine-5\\.11\\.4\\.jar
/myapp/lib/test/junit-platform-commons-1\\.10\\.3\\.jar /my-app/lib/test/junit-jupiter-params-5\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-platform-console-standalone-1\\.10\\.3-sources\\.jar /my-app/lib/test/junit-jupiter-params-5\\.11\\.4\\.jar
/myapp/lib/test/junit-platform-console-standalone-1\\.10\\.3\\.jar /my-app/lib/test/junit-platform-commons-1\\.11\\.4-sources\\.jar
/myapp/lib/test/junit-platform-engine-1\\.10\\.3-sources\\.jar /my-app/lib/test/junit-platform-commons-1\\.11\\.4\\.jar
/myapp/lib/test/junit-platform-engine-1\\.10\\.3\\.jar /my-app/lib/test/junit-platform-console-standalone-1\\.11\\.4-sources\\.jar
/myapp/lib/test/opentest4j-1\\.3\\.0-sources\\.jar /my-app/lib/test/junit-platform-console-standalone-1\\.11\\.4\\.jar
/myapp/lib/test/opentest4j-1\\.3\\.0\\.jar /my-app/lib/test/junit-platform-engine-1\\.11\\.4-sources\\.jar
/myapp/src /my-app/lib/test/junit-platform-engine-1\\.11\\.4\\.jar
/myapp/src/bld /my-app/lib/test/modules
/myapp/src/bld/java /my-app/lib/test/opentest4j-1\\.3\\.0-sources\\.jar
/myapp/src/bld/java/com /my-app/lib/test/opentest4j-1\\.3\\.0\\.jar
/myapp/src/bld/java/com/example /my-app/src
/myapp/src/bld/java/com/example/MyappBuild\\.java /my-app/src/bld
/myapp/src/bld/resources /my-app/src/bld/java
/myapp/src/main /my-app/src/bld/java/com
/myapp/src/main/java /my-app/src/bld/java/com/example
/myapp/src/main/java/com /my-app/src/bld/java/com/example/MyAppBuild\\.java
/myapp/src/main/java/com/example /my-app/src/bld/resources
/myapp/src/main/java/com/example/MyappLib\\.java /my-app/src/main
/myapp/src/main/resources /my-app/src/main/java
/myapp/src/main/resources/templates /my-app/src/main/java/com
/myapp/src/test /my-app/src/main/java/com/example
/myapp/src/test/java /my-app/src/main/java/com/example/MyApp\\.java
/myapp/src/test/java/com /my-app/src/main/resources
/myapp/src/test/java/com/example /my-app/src/main/resources/templates
/myapp/src/test/java/com/example/MyappTest\\.java /my-app/src/test
/myapp/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches()); /my-app/src/test/java
/my-app/src/test/java/com
/my-app/src/test/java/com/example
/my-app/src/test/java/com/example/MyAppTest\\.java
/my-app/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches());
var check_result = new StringBuilder(); var check_result = new StringBuilder();
new JUnitOperation() new JUnitOperation()

File diff suppressed because it is too large Load diff

View file

@ -8,6 +8,7 @@ import org.junit.jupiter.api.Test;
import rife.bld.BldVersion; import rife.bld.BldVersion;
import rife.bld.WebProject; import rife.bld.WebProject;
import rife.bld.dependencies.*; import rife.bld.dependencies.*;
import rife.bld.dependencies.Module;
import rife.bld.wrapper.Wrapper; import rife.bld.wrapper.Wrapper;
import rife.tools.FileUtils; import rife.tools.FileUtils;
import rife.tools.StringUtils; import rife.tools.StringUtils;
@ -72,7 +73,7 @@ public class TestDependencyTreeOperation {
.repositories(List.of(Repository.MAVEN_CENTRAL)); .repositories(List.of(Repository.MAVEN_CENTRAL));
operation.dependencies().scope(Scope.compile) operation.dependencies().scope(Scope.compile)
.include(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,5,20))) .include(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,5,20)))
.include(new Dependency("com.stripe", "stripe-java", new VersionNumber(20,136,0))) .include(new Module("com.stripe", "stripe-java", new VersionNumber(20,136,0)))
.include(new Dependency("org.json", "json", new VersionNumber(20230227))) .include(new Dependency("org.json", "json", new VersionNumber(20230227)))
.include(new Dependency("com.itextpdf", "itext7-core", new VersionNumber(7,2,5))) .include(new Dependency("com.itextpdf", "itext7-core", new VersionNumber(7,2,5)))
.include(new Dependency("org.slf4j", "slf4j-simple", new VersionNumber(2,0,7))) .include(new Dependency("org.slf4j", "slf4j-simple", new VersionNumber(2,0,7)))
@ -93,7 +94,7 @@ public class TestDependencyTreeOperation {
compile: compile:
com.uwyn.rife2:rife2:1.5.20 com.uwyn.rife2:rife2:1.5.20
com.stripe:stripe-java:20.136.0 com.stripe:stripe-java:20.136.0@modular-jar
org.json:json:20230227 org.json:json:20230227
com.itextpdf:itext7-core:7.2.5 com.itextpdf:itext7-core:7.2.5
com.itextpdf:barcodes:7.2.5 com.itextpdf:barcodes:7.2.5
@ -150,12 +151,12 @@ public class TestDependencyTreeOperation {
.include(new Dependency("org.eclipse.jetty", "jetty-servlet", new VersionNumber(11,0,15)).exclude("*", "jetty-jakarta-servlet-api")) .include(new Dependency("org.eclipse.jetty", "jetty-servlet", new VersionNumber(11,0,15)).exclude("*", "jetty-jakarta-servlet-api"))
.include(new Dependency("org.apache.tomcat.embed", "tomcat-embed-core", new VersionNumber(10,1,12))) .include(new Dependency("org.apache.tomcat.embed", "tomcat-embed-core", new VersionNumber(10,1,12)))
.include(new Dependency("org.apache.tomcat.embed", "tomcat-embed-jasper", new VersionNumber(10,1,12))) .include(new Dependency("org.apache.tomcat.embed", "tomcat-embed-jasper", new VersionNumber(10,1,12)))
.include(new Dependency("net.imagej", "ij", Version.parse("1.54d"))); .include(new Module("net.imagej", "ij", Version.parse("1.54d")));
operation.dependencies().scope(Scope.test) operation.dependencies().scope(Scope.test)
.include(new Dependency("org.jsoup", "jsoup", new VersionNumber(1,16,1))) .include(new Dependency("org.jsoup", "jsoup", new VersionNumber(1,16,1)))
.include(new Dependency("jakarta.servlet", "jakarta.servlet-api", new VersionNumber(5,0,0))) .include(new Dependency("jakarta.servlet", "jakarta.servlet-api", new VersionNumber(5,0,0)))
.include(new Dependency("org.eclipse.jetty", "jetty-server", new VersionNumber(11,0,15)).exclude("*", "jetty-jakarta-servlet-api")) .include(new Dependency("org.eclipse.jetty", "jetty-server", new VersionNumber(11,0,15)).exclude("*", "jetty-jakarta-servlet-api"))
.include(new Dependency("org.eclipse.jetty", "jetty-servlet", new VersionNumber(11,0,15)).exclude("*", "jetty-jakarta-servlet-api")) .include(new Module("org.eclipse.jetty", "jetty-servlet", new VersionNumber(11,0,15)).exclude("*", "jetty-jakarta-servlet-api"))
.include(new Dependency("net.imagej", "ij", Version.parse("1.54d"))); .include(new Dependency("net.imagej", "ij", Version.parse("1.54d")));
operation.execute(); operation.execute();
@ -184,7 +185,7 @@ public class TestDependencyTreeOperation {
org.apache.tomcat.embed:tomcat-embed-jasper:10.1.12 org.apache.tomcat.embed:tomcat-embed-jasper:10.1.12
org.apache.tomcat.embed:tomcat-embed-el:10.1.12 org.apache.tomcat.embed:tomcat-embed-el:10.1.12
org.eclipse.jdt:ecj:3.33.0 org.eclipse.jdt:ecj:3.33.0
net.imagej:ij:1.54d net.imagej:ij:1.54d@modular-jar
runtime: runtime:
no dependencies no dependencies
@ -197,8 +198,8 @@ public class TestDependencyTreeOperation {
org.eclipse.jetty:jetty-util:11.0.15 org.eclipse.jetty:jetty-util:11.0.15
org.eclipse.jetty:jetty-io:11.0.15 org.eclipse.jetty:jetty-io:11.0.15
org.slf4j:slf4j-api:2.0.5 org.slf4j:slf4j-api:2.0.5
org.eclipse.jetty:jetty-servlet:11.0.15 org.eclipse.jetty:jetty-servlet:11.0.15@modular-jar
org.eclipse.jetty:jetty-security:11.0.15 org.eclipse.jetty:jetty-security:11.0.15@modular-jar
net.imagej:ij:1.54d net.imagej:ij:1.54d
"""), tree); """), tree);
@ -390,7 +391,7 @@ public class TestDependencyTreeOperation {
.include(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,5,20))) .include(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1,5,20)))
.include(new Dependency("com.stripe", "stripe-java", new VersionNumber(20,136,0))) .include(new Dependency("com.stripe", "stripe-java", new VersionNumber(20,136,0)))
.include(new Dependency("org.json", "json", new VersionNumber(20230227))) .include(new Dependency("org.json", "json", new VersionNumber(20230227)))
.include(new Dependency("com.itextpdf", "itext7-core", new VersionNumber(7,2,5))) .include(new Module("com.itextpdf", "itext7-core", new VersionNumber(7,2,5)))
.include(new Dependency("org.slf4j", "slf4j-simple", new VersionNumber(2,0,7))) .include(new Dependency("org.slf4j", "slf4j-simple", new VersionNumber(2,0,7)))
.include(new Dependency("org.apache.thrift", "libthrift", new VersionNumber(0,17,0))) .include(new Dependency("org.apache.thrift", "libthrift", new VersionNumber(0,17,0)))
.include(new Dependency("commons-codec", "commons-codec", new VersionNumber(1,15))) .include(new Dependency("commons-codec", "commons-codec", new VersionNumber(1,15)))
@ -411,7 +412,7 @@ public class TestDependencyTreeOperation {
.include(new Dependency("jakarta.servlet", "jakarta.servlet-api", new VersionNumber(5,0,0))) .include(new Dependency("jakarta.servlet", "jakarta.servlet-api", new VersionNumber(5,0,0)))
.include(new Dependency("org.eclipse.jetty", "jetty-server", new VersionNumber(11,0,15)).exclude("*", "jetty-jakarta-servlet-api")) .include(new Dependency("org.eclipse.jetty", "jetty-server", new VersionNumber(11,0,15)).exclude("*", "jetty-jakarta-servlet-api"))
.include(new Dependency("org.eclipse.jetty", "jetty-servlet", new VersionNumber(11,0,15)).exclude("*", "jetty-jakarta-servlet-api")) .include(new Dependency("org.eclipse.jetty", "jetty-servlet", new VersionNumber(11,0,15)).exclude("*", "jetty-jakarta-servlet-api"))
.include(new Dependency("net.imagej", "ij", Version.parse("1.54d"))); .include(new Module("net.imagej", "ij", Version.parse("1.54d")));
var operation = new DependencyTreeOperation() var operation = new DependencyTreeOperation()
.fromProject(project); .fromProject(project);
@ -442,22 +443,22 @@ public class TestDependencyTreeOperation {
com.uwyn.rife2:rife2:1.5.20 com.uwyn.rife2:rife2:1.5.20
com.stripe:stripe-java:20.136.0 com.stripe:stripe-java:20.136.0
org.json:json:20230227 org.json:json:20230227
com.itextpdf:itext7-core:7.2.5 com.itextpdf:itext7-core:7.2.5@modular-jar
com.itextpdf:barcodes:7.2.5 com.itextpdf:barcodes:7.2.5@modular-jar
com.itextpdf:font-asian:7.2.5 com.itextpdf:font-asian:7.2.5@modular-jar
com.itextpdf:forms:7.2.5 com.itextpdf:forms:7.2.5@modular-jar
com.itextpdf:hyph:7.2.5 com.itextpdf:hyph:7.2.5@modular-jar
com.itextpdf:io:7.2.5 com.itextpdf:io:7.2.5@modular-jar
com.itextpdf:commons:7.2.5 com.itextpdf:commons:7.2.5@modular-jar
com.itextpdf:kernel:7.2.5 com.itextpdf:kernel:7.2.5@modular-jar
org.bouncycastle:bcpkix-jdk15on:1.70 org.bouncycastle:bcpkix-jdk15on:1.70@modular-jar
org.bouncycastle:bcutil-jdk15on:1.70 org.bouncycastle:bcutil-jdk15on:1.70@modular-jar
org.bouncycastle:bcprov-jdk15on:1.70 org.bouncycastle:bcprov-jdk15on:1.70@modular-jar
com.itextpdf:layout:7.2.5 com.itextpdf:layout:7.2.5@modular-jar
com.itextpdf:pdfa:7.2.5 com.itextpdf:pdfa:7.2.5@modular-jar
com.itextpdf:sign:7.2.5 com.itextpdf:sign:7.2.5@modular-jar
com.itextpdf:styled-xml-parser:7.2.5 com.itextpdf:styled-xml-parser:7.2.5@modular-jar
com.itextpdf:svg:7.2.5 com.itextpdf:svg:7.2.5@modular-jar
org.slf4j:slf4j-simple:2.0.7 org.slf4j:slf4j-simple:2.0.7
org.slf4j:slf4j-api:2.0.7 org.slf4j:slf4j-api:2.0.7
org.apache.thrift:libthrift:0.17.0 org.apache.thrift:libthrift:0.17.0
@ -498,7 +499,7 @@ public class TestDependencyTreeOperation {
org.slf4j:slf4j-api:2.0.5 org.slf4j:slf4j-api:2.0.5
org.eclipse.jetty:jetty-servlet:11.0.15 org.eclipse.jetty:jetty-servlet:11.0.15
org.eclipse.jetty:jetty-security:11.0.15 org.eclipse.jetty:jetty-security:11.0.15
net.imagej:ij:1.54d net.imagej:ij:1.54d@modular-jar
"""), tree); """), tree);
} finally { } finally {

View file

@ -7,6 +7,7 @@ package rife.bld.operations;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import rife.bld.WebProject; import rife.bld.WebProject;
import rife.bld.dependencies.*; import rife.bld.dependencies.*;
import rife.bld.dependencies.Module;
import rife.tools.FileUtils; import rife.tools.FileUtils;
import java.io.File; import java.io.File;
@ -23,10 +24,15 @@ public class TestDownloadOperation {
assertTrue(operation.dependencies().isEmpty()); assertTrue(operation.dependencies().isEmpty());
assertTrue(operation.repositories().isEmpty()); assertTrue(operation.repositories().isEmpty());
assertNull(operation.libCompileDirectory()); assertNull(operation.libCompileDirectory());
assertNull(operation.libCompileModulesDirectory());
assertNull(operation.libProvidedDirectory()); assertNull(operation.libProvidedDirectory());
assertNull(operation.libProvidedModulesDirectory());
assertNull(operation.libRuntimeDirectory()); assertNull(operation.libRuntimeDirectory());
assertNull(operation.libRuntimeModulesDirectory());
assertNull(operation.libStandaloneDirectory()); assertNull(operation.libStandaloneDirectory());
assertNull(operation.libStandaloneModulesDirectory());
assertNull(operation.libTestDirectory()); assertNull(operation.libTestDirectory());
assertNull(operation.libTestModulesDirectory());
} }
@Test @Test
@ -40,6 +46,11 @@ public class TestDownloadOperation {
var dir3 = new File("dir3"); var dir3 = new File("dir3");
var dir4 = new File("dir4"); var dir4 = new File("dir4");
var dir5 = new File("dir5"); var dir5 = new File("dir5");
var dir6 = new File("dir6");
var dir7 = new File("dir7");
var dir8 = new File("dir8");
var dir9 = new File("dir9");
var dir10 = new File("dir10");
var operation1 = new DownloadOperation() var operation1 = new DownloadOperation()
.repositories(List.of(repository1, repository2)) .repositories(List.of(repository1, repository2))
@ -47,7 +58,12 @@ public class TestDownloadOperation {
.libProvidedDirectory(dir2) .libProvidedDirectory(dir2)
.libRuntimeDirectory(dir3) .libRuntimeDirectory(dir3)
.libStandaloneDirectory(dir4) .libStandaloneDirectory(dir4)
.libTestDirectory(dir5); .libTestDirectory(dir5)
.libCompileModulesDirectory(dir6)
.libProvidedModulesDirectory(dir7)
.libRuntimeModulesDirectory(dir8)
.libStandaloneModulesDirectory(dir9)
.libTestModulesDirectory(dir10);
var dependency_scopes = new DependencyScopes(); var dependency_scopes = new DependencyScopes();
dependency_scopes.scope(Scope.compile).include(dependency1).include(dependency2); dependency_scopes.scope(Scope.compile).include(dependency1).include(dependency2);
operation1.dependencies(dependency_scopes); operation1.dependencies(dependency_scopes);
@ -60,13 +76,23 @@ public class TestDownloadOperation {
assertEquals(dir3, operation1.libRuntimeDirectory()); assertEquals(dir3, operation1.libRuntimeDirectory());
assertEquals(dir4, operation1.libStandaloneDirectory()); assertEquals(dir4, operation1.libStandaloneDirectory());
assertEquals(dir5, operation1.libTestDirectory()); assertEquals(dir5, operation1.libTestDirectory());
assertEquals(dir6, operation1.libCompileModulesDirectory());
assertEquals(dir7, operation1.libProvidedModulesDirectory());
assertEquals(dir8, operation1.libRuntimeModulesDirectory());
assertEquals(dir9, operation1.libStandaloneModulesDirectory());
assertEquals(dir10, operation1.libTestModulesDirectory());
var operation2 = new DownloadOperation() var operation2 = new DownloadOperation()
.libCompileDirectory(dir1) .libCompileDirectory(dir1)
.libProvidedDirectory(dir2) .libProvidedDirectory(dir2)
.libRuntimeDirectory(dir3) .libRuntimeDirectory(dir3)
.libStandaloneDirectory(dir4) .libStandaloneDirectory(dir4)
.libTestDirectory(dir5); .libTestDirectory(dir5)
.libCompileModulesDirectory(dir6)
.libProvidedModulesDirectory(dir7)
.libRuntimeModulesDirectory(dir8)
.libStandaloneModulesDirectory(dir9)
.libTestModulesDirectory(dir10);
operation2.repositories().add(repository1); operation2.repositories().add(repository1);
operation2.repositories().add(repository2); operation2.repositories().add(repository2);
operation2.dependencies().scope(Scope.compile).include(dependency1).include(dependency2); operation2.dependencies().scope(Scope.compile).include(dependency1).include(dependency2);
@ -80,6 +106,11 @@ public class TestDownloadOperation {
assertEquals(dir3, operation2.libRuntimeDirectory()); assertEquals(dir3, operation2.libRuntimeDirectory());
assertEquals(dir4, operation2.libStandaloneDirectory()); assertEquals(dir4, operation2.libStandaloneDirectory());
assertEquals(dir5, operation2.libTestDirectory()); assertEquals(dir5, operation2.libTestDirectory());
assertEquals(dir6, operation2.libCompileModulesDirectory());
assertEquals(dir7, operation2.libProvidedModulesDirectory());
assertEquals(dir8, operation2.libRuntimeModulesDirectory());
assertEquals(dir9, operation2.libStandaloneModulesDirectory());
assertEquals(dir10, operation2.libTestModulesDirectory());
var operation3 = new DownloadOperation() var operation3 = new DownloadOperation()
.offline(true) .offline(true)
@ -96,14 +127,14 @@ public class TestDownloadOperation {
try { try {
var dir1 = new File(tmp, "dir1"); var dir1 = new File(tmp, "dir1");
var dir2 = new File(tmp, "dir2"); var dir2 = new File(tmp, "dir2");
var dir3 = new File(tmp, "dir3"); var dir8 = new File(tmp, "dir8");
var dir3 = new File(dir8, "dir3");
var dir4 = new File(tmp, "dir4"); var dir4 = new File(tmp, "dir4");
var dir5 = new File(tmp, "dir5"); var dir5 = new File(tmp, "dir5");
dir1.mkdirs(); var dir6 = new File(tmp, "dir6");
dir2.mkdirs(); var dir7 = new File(tmp, "dir7");
dir3.mkdirs(); var dir9 = new File(dir4, "dir9");
dir4.mkdirs(); var dir10 = new File(dir5, "dir10");
dir5.mkdirs();
var operation = new DownloadOperation() var operation = new DownloadOperation()
.repositories(List.of(Repository.MAVEN_CENTRAL)) .repositories(List.of(Repository.MAVEN_CENTRAL))
@ -111,17 +142,27 @@ public class TestDownloadOperation {
.libProvidedDirectory(dir2) .libProvidedDirectory(dir2)
.libRuntimeDirectory(dir3) .libRuntimeDirectory(dir3)
.libStandaloneDirectory(dir4) .libStandaloneDirectory(dir4)
.libTestDirectory(dir5); .libTestDirectory(dir5)
.libCompileModulesDirectory(dir6)
.libProvidedModulesDirectory(dir7)
.libRuntimeModulesDirectory(dir8)
.libStandaloneModulesDirectory(dir9)
.libTestModulesDirectory(dir10);
operation.dependencies().scope(Scope.compile) operation.dependencies().scope(Scope.compile)
.include(new Dependency("org.apache.commons", "commons-lang3", new VersionNumber(3, 12, 0))); .include(new Dependency("org.apache.commons", "commons-lang3", new VersionNumber(3,12,0)))
.include(new Module("org.json", "json", new VersionNumber(20240303)));
operation.dependencies().scope(Scope.provided) operation.dependencies().scope(Scope.provided)
.include(new Dependency("jakarta.servlet", "jakarta.servlet-api", new VersionNumber(6, 0, 0))); .include(new Dependency("commons-codec", "commons-codec", new VersionNumber(1,17,0)))
.include(new Module("com.google.zxing", "javase", new VersionNumber(3,5,3)));
operation.dependencies().scope(Scope.runtime) operation.dependencies().scope(Scope.runtime)
.include(new Dependency("org.apache.commons", "commons-collections4", new VersionNumber(4, 4))); .include(new Dependency("org.apache.commons", "commons-collections4", new VersionNumber(4,4)))
.include(new Module("org.postgresql", "postgresql", new VersionNumber(42,7,3)));
operation.dependencies().scope(Scope.standalone) operation.dependencies().scope(Scope.standalone)
.include(new Dependency("org.slf4j", "slf4j-simple", new VersionNumber(2, 0, 6))); .include(new Dependency("org.slf4j", "slf4j-simple", new VersionNumber(2,0,6)))
.include(new Module("org.eclipse.jetty.ee10", "jetty-ee10-servlet", new VersionNumber(12,0,16)));
operation.dependencies().scope(Scope.test) operation.dependencies().scope(Scope.test)
.include(new Dependency("org.apache.httpcomponents.client5", "httpclient5", new VersionNumber(5, 2, 1))); .include(new Dependency("org.apache.httpcomponents.client5", "httpclient5", new VersionNumber(5,2,1)))
.include(new Module("org.jsoup", "jsoup", new VersionNumber(1,18,1)));
operation.execute(); operation.execute();
@ -129,17 +170,38 @@ public class TestDownloadOperation {
/dir1 /dir1
/dir1/commons-lang3-3.12.0.jar /dir1/commons-lang3-3.12.0.jar
/dir2 /dir2
/dir2/jakarta.servlet-api-6.0.0.jar /dir2/commons-codec-1.17.0.jar
/dir3
/dir3/commons-collections4-4.4.jar
/dir4 /dir4
/dir4/slf4j-api-2.0.6.jar /dir4/dir9
/dir4/dir9/jakarta.servlet-api-6.0.0.jar
/dir4/dir9/jetty-ee10-servlet-12.0.16.jar
/dir4/dir9/jetty-http-12.0.16.jar
/dir4/dir9/jetty-io-12.0.16.jar
/dir4/dir9/jetty-security-12.0.16.jar
/dir4/dir9/jetty-server-12.0.16.jar
/dir4/dir9/jetty-session-12.0.16.jar
/dir4/dir9/jetty-util-12.0.16.jar
/dir4/dir9/slf4j-api-2.0.16.jar
/dir4/slf4j-simple-2.0.6.jar /dir4/slf4j-simple-2.0.6.jar
/dir5 /dir5
/dir5/dir10
/dir5/dir10/jsoup-1.18.1.jar
/dir5/httpclient5-5.2.1.jar /dir5/httpclient5-5.2.1.jar
/dir5/httpcore5-5.2.jar /dir5/httpcore5-5.2.jar
/dir5/httpcore5-h2-5.2.jar /dir5/httpcore5-h2-5.2.jar
/dir5/slf4j-api-1.7.36.jar""", /dir5/slf4j-api-1.7.36.jar
/dir6
/dir6/json-20240303.jar
/dir7
/dir7/core-3.5.3.jar
/dir7/jai-imageio-core-1.4.0.jar
/dir7/javase-3.5.3.jar
/dir7/jcommander-1.82.jar
/dir8
/dir8/checker-qual-3.42.0.jar
/dir8/dir3
/dir8/dir3/commons-collections4-4.4.jar
/dir8/postgresql-42.7.3.jar""",
FileUtils.generateDirectoryListing(tmp)); FileUtils.generateDirectoryListing(tmp));
} finally { } finally {
FileUtils.deleteDirectory(tmp); FileUtils.deleteDirectory(tmp);
@ -153,14 +215,14 @@ public class TestDownloadOperation {
try { try {
var dir1 = new File(tmp, "dir1"); var dir1 = new File(tmp, "dir1");
var dir2 = new File(tmp, "dir2"); var dir2 = new File(tmp, "dir2");
var dir3 = new File(tmp, "dir3"); var dir8 = new File(tmp, "dir8");
var dir3 = new File(dir8, "dir3");
var dir4 = new File(tmp, "dir4"); var dir4 = new File(tmp, "dir4");
var dir5 = new File(tmp, "dir5"); var dir5 = new File(tmp, "dir5");
dir1.mkdirs(); var dir6 = new File(tmp, "dir6");
dir2.mkdirs(); var dir7 = new File(tmp, "dir7");
dir3.mkdirs(); var dir9 = new File(dir4, "dir9");
dir4.mkdirs(); var dir10 = new File(dir5, "dir10");
dir5.mkdirs();
var operation = new DownloadOperation() var operation = new DownloadOperation()
.repositories(List.of(Repository.MAVEN_CENTRAL)) .repositories(List.of(Repository.MAVEN_CENTRAL))
@ -169,18 +231,28 @@ public class TestDownloadOperation {
.libRuntimeDirectory(dir3) .libRuntimeDirectory(dir3)
.libStandaloneDirectory(dir4) .libStandaloneDirectory(dir4)
.libTestDirectory(dir5) .libTestDirectory(dir5)
.libCompileModulesDirectory(dir6)
.libProvidedModulesDirectory(dir7)
.libRuntimeModulesDirectory(dir8)
.libStandaloneModulesDirectory(dir9)
.libTestModulesDirectory(dir10)
.downloadJavadoc(true) .downloadJavadoc(true)
.downloadSources(true); .downloadSources(true);
operation.dependencies().scope(Scope.compile) operation.dependencies().scope(Scope.compile)
.include(new Dependency("org.apache.commons", "commons-lang3", new VersionNumber(3, 12, 0))); .include(new Dependency("org.apache.commons", "commons-lang3", new VersionNumber(3,12,0)))
.include(new Module("org.json", "json", new VersionNumber(20240303)).excludeSources());
operation.dependencies().scope(Scope.provided) operation.dependencies().scope(Scope.provided)
.include(new Dependency("jakarta.servlet", "jakarta.servlet-api", new VersionNumber(6, 0, 0))); .include(new Dependency("commons-codec", "commons-codec", new VersionNumber(1,17,0)))
.include(new Module("com.google.zxing", "javase", new VersionNumber(3,5,3)).excludeJavadoc());
operation.dependencies().scope(Scope.runtime) operation.dependencies().scope(Scope.runtime)
.include(new Dependency("org.apache.commons", "commons-collections4", new VersionNumber(4, 4))); .include(new Dependency("org.apache.commons", "commons-collections4", new VersionNumber(4,4)))
.include(new Module("org.postgresql", "postgresql", new VersionNumber(42,7,3)));
operation.dependencies().scope(Scope.standalone) operation.dependencies().scope(Scope.standalone)
.include(new Dependency("org.slf4j", "slf4j-simple", new VersionNumber(2, 0, 6))); .include(new Dependency("org.slf4j", "slf4j-simple", new VersionNumber(2,0,6)))
.include(new Module("org.eclipse.jetty.ee10", "jetty-ee10-servlet", new VersionNumber(12,0,16)));
operation.dependencies().scope(Scope.test) operation.dependencies().scope(Scope.test)
.include(new Dependency("org.apache.httpcomponents.client5", "httpclient5", new VersionNumber(5, 2, 1))); .include(new Dependency("org.apache.httpcomponents.client5", "httpclient5", new VersionNumber(5,2,1)))
.include(new Module("org.jsoup", "jsoup", new VersionNumber(1,18,1)).excludeSources().excludeJavadoc());
operation.execute(); operation.execute();
@ -190,21 +262,44 @@ public class TestDownloadOperation {
/dir1/commons-lang3-3.12.0-sources.jar /dir1/commons-lang3-3.12.0-sources.jar
/dir1/commons-lang3-3.12.0.jar /dir1/commons-lang3-3.12.0.jar
/dir2 /dir2
/dir2/jakarta.servlet-api-6.0.0-javadoc.jar /dir2/commons-codec-1.17.0-javadoc.jar
/dir2/jakarta.servlet-api-6.0.0-sources.jar /dir2/commons-codec-1.17.0-sources.jar
/dir2/jakarta.servlet-api-6.0.0.jar /dir2/commons-codec-1.17.0.jar
/dir3
/dir3/commons-collections4-4.4-javadoc.jar
/dir3/commons-collections4-4.4-sources.jar
/dir3/commons-collections4-4.4.jar
/dir4 /dir4
/dir4/slf4j-api-2.0.6-javadoc.jar /dir4/dir9
/dir4/slf4j-api-2.0.6-sources.jar /dir4/dir9/jakarta.servlet-api-6.0.0-javadoc.jar
/dir4/slf4j-api-2.0.6.jar /dir4/dir9/jakarta.servlet-api-6.0.0-sources.jar
/dir4/dir9/jakarta.servlet-api-6.0.0.jar
/dir4/dir9/jetty-ee10-servlet-12.0.16-javadoc.jar
/dir4/dir9/jetty-ee10-servlet-12.0.16-sources.jar
/dir4/dir9/jetty-ee10-servlet-12.0.16.jar
/dir4/dir9/jetty-http-12.0.16-javadoc.jar
/dir4/dir9/jetty-http-12.0.16-sources.jar
/dir4/dir9/jetty-http-12.0.16.jar
/dir4/dir9/jetty-io-12.0.16-javadoc.jar
/dir4/dir9/jetty-io-12.0.16-sources.jar
/dir4/dir9/jetty-io-12.0.16.jar
/dir4/dir9/jetty-security-12.0.16-javadoc.jar
/dir4/dir9/jetty-security-12.0.16-sources.jar
/dir4/dir9/jetty-security-12.0.16.jar
/dir4/dir9/jetty-server-12.0.16-javadoc.jar
/dir4/dir9/jetty-server-12.0.16-sources.jar
/dir4/dir9/jetty-server-12.0.16.jar
/dir4/dir9/jetty-session-12.0.16-javadoc.jar
/dir4/dir9/jetty-session-12.0.16-sources.jar
/dir4/dir9/jetty-session-12.0.16.jar
/dir4/dir9/jetty-util-12.0.16-javadoc.jar
/dir4/dir9/jetty-util-12.0.16-sources.jar
/dir4/dir9/jetty-util-12.0.16.jar
/dir4/dir9/slf4j-api-2.0.16-javadoc.jar
/dir4/dir9/slf4j-api-2.0.16-sources.jar
/dir4/dir9/slf4j-api-2.0.16.jar
/dir4/slf4j-simple-2.0.6-javadoc.jar /dir4/slf4j-simple-2.0.6-javadoc.jar
/dir4/slf4j-simple-2.0.6-sources.jar /dir4/slf4j-simple-2.0.6-sources.jar
/dir4/slf4j-simple-2.0.6.jar /dir4/slf4j-simple-2.0.6.jar
/dir5 /dir5
/dir5/dir10
/dir5/dir10/jsoup-1.18.1.jar
/dir5/httpclient5-5.2.1-javadoc.jar /dir5/httpclient5-5.2.1-javadoc.jar
/dir5/httpclient5-5.2.1-sources.jar /dir5/httpclient5-5.2.1-sources.jar
/dir5/httpclient5-5.2.1.jar /dir5/httpclient5-5.2.1.jar
@ -216,7 +311,33 @@ public class TestDownloadOperation {
/dir5/httpcore5-h2-5.2.jar /dir5/httpcore5-h2-5.2.jar
/dir5/slf4j-api-1.7.36-javadoc.jar /dir5/slf4j-api-1.7.36-javadoc.jar
/dir5/slf4j-api-1.7.36-sources.jar /dir5/slf4j-api-1.7.36-sources.jar
/dir5/slf4j-api-1.7.36.jar""", /dir5/slf4j-api-1.7.36.jar
/dir6
/dir6/json-20240303-javadoc.jar
/dir6/json-20240303.jar
/dir7
/dir7/core-3.5.3-javadoc.jar
/dir7/core-3.5.3-sources.jar
/dir7/core-3.5.3.jar
/dir7/jai-imageio-core-1.4.0-javadoc.jar
/dir7/jai-imageio-core-1.4.0-sources.jar
/dir7/jai-imageio-core-1.4.0.jar
/dir7/javase-3.5.3-sources.jar
/dir7/javase-3.5.3.jar
/dir7/jcommander-1.82-javadoc.jar
/dir7/jcommander-1.82-sources.jar
/dir7/jcommander-1.82.jar
/dir8
/dir8/checker-qual-3.42.0-javadoc.jar
/dir8/checker-qual-3.42.0-sources.jar
/dir8/checker-qual-3.42.0.jar
/dir8/dir3
/dir8/dir3/commons-collections4-4.4-javadoc.jar
/dir8/dir3/commons-collections4-4.4-sources.jar
/dir8/dir3/commons-collections4-4.4.jar
/dir8/postgresql-42.7.3-javadoc.jar
/dir8/postgresql-42.7.3-sources.jar
/dir8/postgresql-42.7.3.jar""",
FileUtils.generateDirectoryListing(tmp)); FileUtils.generateDirectoryListing(tmp));
} finally { } finally {
FileUtils.deleteDirectory(tmp); FileUtils.deleteDirectory(tmp);
@ -240,15 +361,20 @@ public class TestDownloadOperation {
project.createProjectStructure(); project.createProjectStructure();
project.repositories().add(Repository.MAVEN_CENTRAL); project.repositories().add(Repository.MAVEN_CENTRAL);
project.dependencies().scope(Scope.compile) project.dependencies().scope(Scope.compile)
.include(new Dependency("org.apache.commons", "commons-lang3", new VersionNumber(3, 12, 0))); .include(new Dependency("org.apache.commons", "commons-lang3", new VersionNumber(3,12,0)))
.include(new Module("org.json", "json", new VersionNumber(20240303)).excludeSources());
project.dependencies().scope(Scope.provided) project.dependencies().scope(Scope.provided)
.include(new Dependency("jakarta.servlet", "jakarta.servlet-api", new VersionNumber(6, 0, 0))); .include(new Dependency("commons-codec", "commons-codec", new VersionNumber(1,17,0)))
.include(new Module("com.google.zxing", "javase", new VersionNumber(3,5,3)));
project.dependencies().scope(Scope.runtime) project.dependencies().scope(Scope.runtime)
.include(new Dependency("org.apache.commons", "commons-collections4", new VersionNumber(4, 4))); .include(new Dependency("org.apache.commons", "commons-collections4", new VersionNumber(4,4)))
.include(new Module("org.postgresql", "postgresql", new VersionNumber(42,7,3)));
project.dependencies().scope(Scope.standalone) project.dependencies().scope(Scope.standalone)
.include(new Dependency("org.slf4j", "slf4j-simple", new VersionNumber(2, 0, 6))); .include(new Dependency("org.slf4j", "slf4j-simple", new VersionNumber(2,0,6)))
.include(new Module("org.eclipse.jetty.ee10", "jetty-ee10-servlet", new VersionNumber(12,0,16)));
project.dependencies().scope(Scope.test) project.dependencies().scope(Scope.test)
.include(new Dependency("org.apache.httpcomponents.client5", "httpclient5", new VersionNumber(5, 2, 1))); .include(new Dependency("org.apache.httpcomponents.client5", "httpclient5", new VersionNumber(5,2,1)))
.include(new Module("org.jsoup", "jsoup", new VersionNumber(1,18,1)));
var operation = new DownloadOperation() var operation = new DownloadOperation()
.fromProject(project); .fromProject(project);
@ -261,15 +387,48 @@ public class TestDownloadOperation {
/lib/compile /lib/compile
/lib/compile/commons-lang3-3.12.0-sources.jar /lib/compile/commons-lang3-3.12.0-sources.jar
/lib/compile/commons-lang3-3.12.0.jar /lib/compile/commons-lang3-3.12.0.jar
/lib/compile/modules
/lib/compile/modules/json-20240303.jar
/lib/provided /lib/provided
/lib/provided/jakarta.servlet-api-6.0.0-sources.jar /lib/provided/commons-codec-1.17.0-sources.jar
/lib/provided/jakarta.servlet-api-6.0.0.jar /lib/provided/commons-codec-1.17.0.jar
/lib/provided/modules
/lib/provided/modules/core-3.5.3-sources.jar
/lib/provided/modules/core-3.5.3.jar
/lib/provided/modules/jai-imageio-core-1.4.0-sources.jar
/lib/provided/modules/jai-imageio-core-1.4.0.jar
/lib/provided/modules/javase-3.5.3-sources.jar
/lib/provided/modules/javase-3.5.3.jar
/lib/provided/modules/jcommander-1.82-sources.jar
/lib/provided/modules/jcommander-1.82.jar
/lib/runtime /lib/runtime
/lib/runtime/commons-collections4-4.4-sources.jar /lib/runtime/commons-collections4-4.4-sources.jar
/lib/runtime/commons-collections4-4.4.jar /lib/runtime/commons-collections4-4.4.jar
/lib/runtime/modules
/lib/runtime/modules/checker-qual-3.42.0-sources.jar
/lib/runtime/modules/checker-qual-3.42.0.jar
/lib/runtime/modules/postgresql-42.7.3-sources.jar
/lib/runtime/modules/postgresql-42.7.3.jar
/lib/standalone /lib/standalone
/lib/standalone/slf4j-api-2.0.6-sources.jar /lib/standalone/modules
/lib/standalone/slf4j-api-2.0.6.jar /lib/standalone/modules/jakarta.servlet-api-6.0.0-sources.jar
/lib/standalone/modules/jakarta.servlet-api-6.0.0.jar
/lib/standalone/modules/jetty-ee10-servlet-12.0.16-sources.jar
/lib/standalone/modules/jetty-ee10-servlet-12.0.16.jar
/lib/standalone/modules/jetty-http-12.0.16-sources.jar
/lib/standalone/modules/jetty-http-12.0.16.jar
/lib/standalone/modules/jetty-io-12.0.16-sources.jar
/lib/standalone/modules/jetty-io-12.0.16.jar
/lib/standalone/modules/jetty-security-12.0.16-sources.jar
/lib/standalone/modules/jetty-security-12.0.16.jar
/lib/standalone/modules/jetty-server-12.0.16-sources.jar
/lib/standalone/modules/jetty-server-12.0.16.jar
/lib/standalone/modules/jetty-session-12.0.16-sources.jar
/lib/standalone/modules/jetty-session-12.0.16.jar
/lib/standalone/modules/jetty-util-12.0.16-sources.jar
/lib/standalone/modules/jetty-util-12.0.16.jar
/lib/standalone/modules/slf4j-api-2.0.16-sources.jar
/lib/standalone/modules/slf4j-api-2.0.16.jar
/lib/standalone/slf4j-simple-2.0.6-sources.jar /lib/standalone/slf4j-simple-2.0.6-sources.jar
/lib/standalone/slf4j-simple-2.0.6.jar /lib/standalone/slf4j-simple-2.0.6.jar
/lib/test /lib/test
@ -279,6 +438,9 @@ public class TestDownloadOperation {
/lib/test/httpcore5-5.2.jar /lib/test/httpcore5-5.2.jar
/lib/test/httpcore5-h2-5.2-sources.jar /lib/test/httpcore5-h2-5.2-sources.jar
/lib/test/httpcore5-h2-5.2.jar /lib/test/httpcore5-h2-5.2.jar
/lib/test/modules
/lib/test/modules/jsoup-1.18.1-sources.jar
/lib/test/modules/jsoup-1.18.1.jar
/lib/test/slf4j-api-1.7.36-sources.jar /lib/test/slf4j-api-1.7.36-sources.jar
/lib/test/slf4j-api-1.7.36.jar /lib/test/slf4j-api-1.7.36.jar
/src /src
@ -308,6 +470,8 @@ public class TestDownloadOperation {
project.repositories().add(Repository.MAVEN_CENTRAL); project.repositories().add(Repository.MAVEN_CENTRAL);
project.dependencies().scope(Scope.compile) project.dependencies().scope(Scope.compile)
.include(new Dependency("com.stripe", "stripe-java", new VersionNumber(20,136,0))); .include(new Dependency("com.stripe", "stripe-java", new VersionNumber(20,136,0)));
project.dependencies().scope(Scope.runtime)
.include(new Module("org.json", "json", new VersionNumber(20240303)));
var operation = new DownloadOperation() var operation = new DownloadOperation()
.fromProject(project); .fromProject(project);
@ -318,14 +482,21 @@ public class TestDownloadOperation {
/lib /lib
/lib/bld /lib/bld
/lib/compile /lib/compile
/lib/compile/modules
/lib/compile/stripe-java-20.136.0-sources.jar /lib/compile/stripe-java-20.136.0-sources.jar
/lib/compile/stripe-java-20.136.0.jar /lib/compile/stripe-java-20.136.0.jar
/lib/provided /lib/provided
/lib/provided/modules
/lib/runtime /lib/runtime
/lib/runtime/gson-2.9.0-sources.jar /lib/runtime/gson-2.9.0-sources.jar
/lib/runtime/gson-2.9.0.jar /lib/runtime/gson-2.9.0.jar
/lib/runtime/modules
/lib/runtime/modules/json-20240303-sources.jar
/lib/runtime/modules/json-20240303.jar
/lib/standalone /lib/standalone
/lib/standalone/modules
/lib/test /lib/test
/lib/test/modules
/src /src
/src/bld /src/bld
/src/bld/java /src/bld/java

View file

@ -13,6 +13,7 @@ import rife.tools.StringUtils;
import java.io.File; import java.io.File;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@ -25,6 +26,7 @@ public class TestJUnitOperation {
assertTrue(operation.workDirectory().exists()); assertTrue(operation.workDirectory().exists());
assertTrue(operation.workDirectory().isDirectory()); assertTrue(operation.workDirectory().isDirectory());
assertTrue(operation.workDirectory().canWrite()); assertTrue(operation.workDirectory().canWrite());
assertTrue(operation.environment().isEmpty());
assertEquals("java", operation.javaTool()); assertEquals("java", operation.javaTool());
assertTrue(operation.javaOptions().isEmpty()); assertTrue(operation.javaOptions().isEmpty());
assertTrue(operation.classpath().isEmpty()); assertTrue(operation.classpath().isEmpty());
@ -37,6 +39,8 @@ public class TestJUnitOperation {
@Test @Test
void testPopulation() void testPopulation()
throws Exception { throws Exception {
var environment = Map.of("env1", "val1", "env2", "val2", "env3", "val3");
var environment_full = Map.of("env1", "val1", "env2", "val2", "env3", "val3", "env4", "val4");
var work_directory = Files.createTempDirectory("test").toFile(); var work_directory = Files.createTempDirectory("test").toFile();
try { try {
var java_tool = "javatool"; var java_tool = "javatool";
@ -53,6 +57,8 @@ public class TestJUnitOperation {
var operation1 = new JUnitOperation(); var operation1 = new JUnitOperation();
operation1 operation1
.workDirectory(work_directory) .workDirectory(work_directory)
.environment(environment)
.environment("env4", "val4")
.javaTool(java_tool) .javaTool(java_tool)
.javaOptions(List.of(test_java_option1, test_java_option2)) .javaOptions(List.of(test_java_option1, test_java_option2))
.testToolOptions(List.of(test_tool_option1, test_tool_option2)) .testToolOptions(List.of(test_tool_option1, test_tool_option2))
@ -62,6 +68,7 @@ public class TestJUnitOperation {
.errorProcessor(test_error_consumer); .errorProcessor(test_error_consumer);
assertEquals(work_directory, operation1.workDirectory()); assertEquals(work_directory, operation1.workDirectory());
assertEquals(environment_full, operation1.environment());
assertEquals(java_tool, operation1.javaTool()); assertEquals(java_tool, operation1.javaTool());
assertTrue(operation1.javaOptions().contains(test_java_option1)); assertTrue(operation1.javaOptions().contains(test_java_option1));
assertTrue(operation1.javaOptions().contains(test_java_option2)); assertTrue(operation1.javaOptions().contains(test_java_option2));
@ -75,6 +82,8 @@ public class TestJUnitOperation {
var operation2 = new JUnitOperation(); var operation2 = new JUnitOperation();
operation2.workDirectory(work_directory); operation2.workDirectory(work_directory);
operation2.environment(environment);
operation2.environment("env4", "val4");
operation2.javaTool(java_tool); operation2.javaTool(java_tool);
operation2.javaOptions().add(test_java_option1); operation2.javaOptions().add(test_java_option1);
operation2.javaOptions().add(test_java_option2); operation2.javaOptions().add(test_java_option2);
@ -87,6 +96,7 @@ public class TestJUnitOperation {
operation2.errorProcessor(test_error_consumer); operation2.errorProcessor(test_error_consumer);
assertEquals(work_directory, operation2.workDirectory()); assertEquals(work_directory, operation2.workDirectory());
assertEquals(environment_full, operation2.environment());
assertEquals(java_tool, operation2.javaTool()); assertEquals(java_tool, operation2.javaTool());
assertTrue(operation2.javaOptions().contains(test_java_option1)); assertTrue(operation2.javaOptions().contains(test_java_option1));
assertTrue(operation2.javaOptions().contains(test_java_option2)); assertTrue(operation2.javaOptions().contains(test_java_option2));
@ -124,7 +134,7 @@ public class TestJUnitOperation {
public class Source1 { public class Source1 {
public final String name_; public final String name_;
public Source1() { public Source1() {
name_ = "source1"; name_ = System.getenv("execute_name") + System.getenv("execute_number");
} }
public static void main(String[] arguments) public static void main(String[] arguments)
@ -156,6 +166,8 @@ public class TestJUnitOperation {
var output = new StringBuilder(); var output = new StringBuilder();
var test_operation = new JUnitOperation() var test_operation = new JUnitOperation()
.environment(Map.of("execute_name", "source"))
.environment("execute_number", "1")
.mainClass("Source2") .mainClass("Source2")
.classpath(List.of(build_main.getAbsolutePath(), build_test.getAbsolutePath())) .classpath(List.of(build_main.getAbsolutePath(), build_test.getAbsolutePath()))
.outputProcessor(s -> { .outputProcessor(s -> {

Some files were not shown because too many files have changed in this diff Show more