Compare commits

...

33 commits

Author SHA1 Message Date
libs.tech aa5a739d9a
Merge fb4505edd1 into 737927da26 2026-02-27 06:01:09 +00: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
20 changed files with 1541 additions and 104 deletions

View file

@ -2,6 +2,9 @@ name: bld-ci
on: [push, pull_request, workflow_dispatch]
env:
REPORTS_DIR: "build/test-results/test/"
jobs:
build-linux:
runs-on: ubuntu-latest
@ -87,7 +90,7 @@ jobs:
strategy:
matrix:
java-version: [ 17, 20, 21, 22 ]
java-version: [ 17, 20, 21, 22, 23, 24, 25 ]
steps:
- name: Checkout source repository
@ -104,19 +107,31 @@ jobs:
java-version: ${{ matrix.java-version }}
check-latest: true
- name: Download dependencies
run: ./bld clean download
- name: Compile source
run: ./bld compile
- name: Run tests
id: tests
run: >-
./bld clean download compile test
./bld test
-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
-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:
runs-on: macos-latest
strategy:
matrix:
java-version: [ 17, 20, 21, 22 ]
java-version: [ 17, 20, 21, 22, 23, 24, 25 ]
steps:
- name: Checkout source repository
@ -133,16 +148,26 @@ jobs:
java-version: ${{ matrix.java-version }}
check-latest: true
- name: Download dependencies
run: ./bld clean download
- name: Compile source
run: ./bld compile
- name: Run tests
run: >-
./bld clean download compile test
id: tests
run: ./bld test --reports-dir=${{ env.REPORTS_DIR }}
- name: Run reporter
if: always() && steps.tests.outcome == 'failure'
run: ./bld reporter --all
build-windows:
runs-on: windows-latest
strategy:
matrix:
java-version: [ 17, 20, 21, 22 ]
java-version: [ 17, 20, 21, 22, 23, 24, 25 ]
steps:
- name: Configure git line endings
@ -162,6 +187,16 @@ jobs:
java-version: ${{ matrix.java-version }}
check-latest: true
- name: Download dependencies
run: .\bld.bat clean download
- name: Compile source
run: .\bld.bat compile
- name: Run tests
run: >-
.\bld.bat clean download compile test
id: tests
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

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

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)
[![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.2.1-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)
[![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)
[![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)
[![libs.tech recommends](https://libs.tech/project/638725478/badge.svg)](https://libs.tech/project/638725478/bld)
[![Tests](https://rife2.com/tests-badge/badge/com.uwyn.rife2/bld)](https://github.com/rife2/rife2/actions/workflows/bld.yml)
@ -132,23 +132,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/).
# Building `bld`
# 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.
See [CONTIBUTING.md](https://github.com/rife2/bld?tab=contributing-ov-file#readme) for information about
contributing to this project.

2
core

@ -1 +1 @@
Subproject commit f8bde83ca806403dd8f37294239ac77dba8ad010
Subproject commit fa567721c00d99626ed439db4f0340eadff0ec03

Binary file not shown.

View file

@ -1,11 +1,12 @@
bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true
bld.downloadLocation=
bld.extension-antlr=com.uwyn.rife2:bld-antlr4:1.4.2
bld.extension-archive=com.uwyn.rife2:bld-archive:0.6.2
bld.extension-tests=com.uwyn.rife2:bld-tests-badge:1.6.2
bld.extension-antlr=com.uwyn.rife2:bld-antlr4:1.4.3
bld.extension-archive=com.uwyn.rife2:bld-archive:0.6.3
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.javacOptions=
bld.repositories=MAVEN_CENTRAL,RIFE2_RELEASES
bld.sourceDirectories=core/src/bld/java
bld.version=2.2.1
bld.version=2.3.0

View file

@ -7,6 +7,7 @@ package rife;
import rife.bld.BuildCommand;
import rife.bld.Cli;
import rife.bld.dependencies.VersionNumber;
import rife.bld.extension.JUnitReporterOperation;
import rife.bld.extension.ZipOperation;
import rife.bld.operations.*;
import rife.bld.publish.*;
@ -33,7 +34,7 @@ public class BldBuild extends AbstractRife2Build {
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
scope(test)
.include(dependency("org.json", "json", version(20250107)));
.include(dependency("org.json", "json", version(20250517)));
var core_dir = new File(workDirectory(), "core");
var core_src_dir = new File(core_dir, "src");
@ -86,7 +87,7 @@ public class BldBuild extends AbstractRife2Build {
publishOperation()
.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"))
.info(new PublishInfo()
.groupId("com.uwyn.rife2")
@ -161,6 +162,14 @@ public class BldBuild extends AbstractRife2Build {
zipBld();
}
@BuildCommand(summary = "Runs the JUnit reporter")
public void reporter() throws Exception {
new JUnitReporterOperation()
.fromProject(this)
.failOnSummary(true)
.execute();
}
public void publish()
throws Exception {
all();

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_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 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_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_SNAPSHOTS" -> Repository.SONATYPE_SNAPSHOTS;
case "SONATYPE_SNAPSHOTS_LEGACY" -> Repository.SONATYPE_SNAPSHOTS_LEGACY;
case "CENTRAL_RELEASES" -> Repository.CENTRAL_RELEASES;
case "CENTRAL_SNAPSHOTS" -> Repository.CENTRAL_SNAPSHOTS;
default -> new Repository(locationOrName);
};
}

View file

@ -10,10 +10,7 @@ import rife.bld.operations.exceptions.OperationOptionException;
import rife.tools.exceptions.FileUtilsErrorException;
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
/**
@ -233,6 +230,18 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
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.
* <p>
@ -247,6 +256,20 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
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.
*
@ -259,6 +282,17 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
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>
@ -273,6 +307,20 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
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.
*

View file

@ -87,11 +87,18 @@ public class CompileOperation extends AbstractOperation<CompileOperation> {
for (var directory : mainSourceDirectories()) {
sources.addAll(FileUtils.getJavaFileList(directory));
}
executeBuildSources(
compileMainClasspath(),
compileMainModulePath(),
sources,
buildMainDirectory());
if (sources.isEmpty()) {
if (!silent()) {
System.err.println("No main source files found.");
}
} else {
executeBuildSources(
compileMainClasspath(),
compileMainModulePath(),
sources,
buildMainDirectory());
}
}
/**
@ -105,11 +112,18 @@ public class CompileOperation extends AbstractOperation<CompileOperation> {
for (var directory : testSourceDirectories()) {
sources.addAll(FileUtils.getJavaFileList(directory));
}
executeBuildSources(
compileTestClasspath(),
compileTestModulePath(),
sources,
buildTestDirectory());
if (sources.isEmpty()) {
if (!silent()) {
System.err.println("No test source files found.");
}
} else {
executeBuildSources(
compileTestClasspath(),
compileTestModulePath(),
sources,
buildTestDirectory());
}
}
/**

View file

@ -13,6 +13,7 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static rife.bld.operations.CompileOperation.COMPILE_OPTION_MODULE_PATH;
@ -35,6 +36,49 @@ public class JavacOptions extends ArrayList<String> {
FULL, NONE, ONLY
}
public enum XLintKey {
ALL,
AUXILIARYCLASS,
CAST,
CLASSFILE,
DANGLING_DOC_COMMENTS,
DEP_ANN,
DEPRECATION,
DIVZERO,
EMPTY,
EXPORTS,
FALLTHROUGH,
FINALLY,
IDENTITY,
INCUBATING,
LOSSY_CONVERSIONS,
MISSING_EXPLICIT_CTOR,
MODULE,
NONE,
OPENS,
OPTIONS,
OUTPUT_FILE_CLASH,
OVERLOADS,
OVERRIDES,
PATH,
PREVIEW,
PROCESSING,
RAWTYPES,
REMOVAL,
REQUIRES_AUTOMATIC,
REQUIRES_TRANSITIVE_AUTOMATIC,
RESTRICTED,
SERIAL,
STATIC,
STRICTFP,
SYNCHRONIZATION,
TEXT_BLOCKS,
THIS_ESCAPE,
TRY,
UNCHECKED,
VARARGS
}
/**
* Option to pass to annotation processors
*
@ -46,10 +90,57 @@ public class JavacOptions extends ArrayList<String> {
return this;
}
/**
* Specifies a package to be considered as exported from its defining
* module to additional modules or to all unnamed modules when the value
* of other-module is ALL-UNNAMED
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions addExports(String... modules) {
return addExports(Arrays.asList(modules));
}
/**
* Specifies a package to be considered as exported from its defining
* module to additional modules or to all unnamed modules when the value
* of other-module is ALL-UNNAMED
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions addExports(List<String> modules) {
add("--add-exports");
add(StringUtils.join(modules, ","));
return this;
}
/**
* Specifies additional modules to be considered as required by a given module
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions addReads(String... modules) {
return addReads(Arrays.asList(modules));
}
/**
* Specifies additional modules to be considered as required by a given module
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions addReads(List<String> modules) {
add("--add-reads");
add(StringUtils.join(modules, ","));
return this;
}
/**
* Root modules to resolve in addition to the initial modules,
* or all modules on the module path if a module is
* ALL-MODULE-PATH.
* or all modules on the module path if a module is ALL-MODULE-PATH
*
* @return this list of options
* @since 1.5.18
@ -60,8 +151,7 @@ public class JavacOptions extends ArrayList<String> {
/**
* Root modules to resolve in addition to the initial modules,
* or all modules on the module path if a module is
* ALL-MODULE-PATH.
* or all modules on the module path if a module is ALL-MODULE-PATH
*
* @return this list of options
* @since 1.5.18
@ -84,6 +174,19 @@ public class JavacOptions extends ArrayList<String> {
return this;
}
/**
* Fallback target module for files created by annotation processors,
* if none specified or inferred
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions defaultModuleForCreatedFiles(String module) {
add("--default-module-for-created-files");
add(module);
return this;
}
/**
* Output source locations where deprecated APIs are used
*
@ -96,7 +199,7 @@ public class JavacOptions extends ArrayList<String> {
}
/**
* Enable preview language features. To be used in conjunction with {@link #release}.
* Enable preview language features. To be used in conjunction with {@link #release}
*
* @return this list of options
* @since 1.5.18
@ -231,18 +334,30 @@ public class JavacOptions extends ArrayList<String> {
}
/**
* Indicates whether the Java SE release was set.
* Indicates whether the Java SE release was set
*
* @return {@code true} if the release was set; or
* {@code false} otherwise
* @since 1.5.18
*/
public boolean containsRelease() {
return contains("-release");
return contains("--release");
}
/**
* Compile for the specified Java SE release.
* Overrides or augments a module with classes and resources in JAR files or directories
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions patchModule(String module) {
add("--patch-module");
add(module);
return this;
}
/**
* Compile for the specified Java SE release
*
* @return this list of options
* @since 1.5.18
@ -253,6 +368,30 @@ public class JavacOptions extends ArrayList<String> {
return this;
}
/**
* Provide source compatibility with the specified Java SE release
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions source(int version) {
add("--source");
add(Convert.toString(version));
return this;
}
/**
* Generate class files suitable for the specified Java SE release
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions target(int version) {
add("--target");
add(Convert.toString(version));
return this;
}
/**
* Generate debugging info
*
@ -484,7 +623,7 @@ public class JavacOptions extends ArrayList<String> {
}
/**
* Control whether annotation processing and/or compilation is done.
* Control whether annotation processing and/or compilation is done
*
* @return this list of options
* @since 1.5.18
@ -681,4 +820,69 @@ public class JavacOptions extends ArrayList<String> {
add("-Werror");
return this;
}
/**
* Enable recommended warning categories
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions xLint() {
add("-Xlint");
return this;
}
/**
* Warning categories to enable
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions xLint(XLintKey... keys) {
return xLint(Arrays.asList(keys));
}
/**
* Warning categories to enable
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions xLint(List<XLintKey> keys) {
return addXLintOption(keys, "");
}
/**
* Warning categories to disable
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions xLintDisable(XLintKey... keys) {
return xLintDisable(Arrays.asList(keys));
}
/**
* Warning categories to disable
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions xLintDisable(List<XLintKey> keys) {
return addXLintOption(keys, "-");
}
private JavacOptions addXLintOption(List<XLintKey> keys, String prefix) {
if (keys == null || keys.isEmpty()) {
return this;
}
var formattedKeys = keys.stream()
.map(key -> prefix + key.name().replace('_', '-').toLowerCase())
.collect(Collectors.joining(",", "-Xlint:", ""));
add(formattedKeys);
return this;
}
}

View file

@ -9,6 +9,7 @@ import rife.bld.BldVersion;
import rife.bld.dependencies.*;
import rife.bld.dependencies.exceptions.DependencyException;
import rife.bld.operations.exceptions.OperationOptionException;
import rife.bld.operations.exceptions.RestApiException;
import rife.bld.operations.exceptions.SignException;
import rife.bld.operations.exceptions.UploadException;
import rife.bld.publish.*;
@ -27,6 +28,7 @@ import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import static rife.bld.dependencies.Dependency.*;
import static rife.bld.publish.MetadataBuilder.SNAPSHOT_TIMESTAMP_FORMATTER;
@ -40,6 +42,9 @@ import static rife.tools.StringUtils.encodeHexLower;
* @since 1.5.7
*/
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 HierarchicalProperties properties_ = null;
private ArtifactRetriever retriever_ = null;
@ -87,6 +92,11 @@ public class PublishOperation extends AbstractOperation<PublishOperation> {
executePublishArtifacts(repository, actual_version);
executePublishPom(repository, actual_version);
executePublishMetadata(repository, moment);
if (!info().version().isSnapshot() &&
repository.location().contains(Repository.OSSRH_STAGING_API_DOMAIN)) {
executeCloseOSSRHStagingRepository(repository);
}
}
if (!silent()) {
System.out.println("Publishing finished successfully.");
@ -133,14 +143,18 @@ public class PublishOperation extends AbstractOperation<PublishOperation> {
var resolution = new VersionResolution(properties());
var resolver = new DependencyResolver(resolution, artifactRetriever(), List.of(repository), new Dependency(info().groupId(), info().artifactId(), info().version()));
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) {
// start the build number from the beginning
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.");
}
// 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;
actual_version = info().version().withQualifier(snapshot_qualifier);
@ -161,7 +175,7 @@ public class PublishOperation extends AbstractOperation<PublishOperation> {
.info(info())
.updated(moment)
.build(),
info().version() + "/" + repository.getMetadataName(), true);
info().version() + "/" + repository.getMetadataName(), false);
return actual_version;
}
@ -181,7 +195,7 @@ public class PublishOperation extends AbstractOperation<PublishOperation> {
artifact_name.append('-').append(artifact.classifier());
}
var type = artifact.type();
if (type == null || TYPE_JAR.equals(type) || TYPE_MODULAR_JAR.equals(type) || TYPE_CLASSPATH_JAR.equals(type)) {
if (TYPE_JAR.equals(type) || TYPE_MODULAR_JAR.equals(type) || TYPE_CLASSPATH_JAR.equals(type)) {
type = TYPE_JAR;
}
artifact_name.append('.').append(type);
@ -470,12 +484,8 @@ public class PublishOperation extends AbstractOperation<PublishOperation> {
var builder = HttpRequest.newBuilder()
.PUT(body)
.uri(URI.create(url))
.header(HEADER_USER_AGENT, "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") + ")");
if (repository.username() != null && repository.password() != null) {
builder.header(HEADER_AUTHORIZATION, basicAuthorizationHeader(repository.username(), repository.password()));
}
.header(HEADER_USER_AGENT, constructBldUserAgent());
applyAuthorization(repository, builder);
var request = builder.build();
HttpResponse<String> response;
@ -501,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}.
*

View file

@ -49,6 +49,9 @@ public class RunOperation extends AbstractProcessOperation<RunOperation> {
else if (mainClass() != null && !mainClass().isEmpty()){
args.add(mainClass());
}
else if (!silent()) {
System.err.println("No main class or module specified.");
}
args.addAll(runOptions());

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

@ -45,9 +45,9 @@ public class Wrapper {
public static final String WRAPPER_PROPERTIES = WRAPPER_PREFIX + ".properties";
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_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_FILENAME = "bld-${version}.jar";
static final String BLD_SOURCES_FILENAME = "bld-${version}-sources.jar";

View file

@ -1 +1 @@
2.2.2-SNAPSHOT
2.3.1-SNAPSHOT

View file

@ -331,15 +331,17 @@ public class TestDependencyResolver {
@Test
void testGetCompileRuntimeDependenciesBitly() {
var resolver = new DependencyResolver(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY), new Dependency("net.thauvin.erik", "bitly-shorten", new VersionNumber(0, 9, 4, "SNAPSHOT")));
var resolver = new DependencyResolver(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS), new Dependency("net.thauvin.erik", "bitly-shorten", new VersionNumber(2, 0, 0)));
var dependencies = resolver.getDirectDependencies(compile, runtime);
assertNotNull(dependencies);
assertEquals(4, dependencies.size());
assertEquals(6, dependencies.size());
assertEquals("""
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22
com.squareup.okhttp3:okhttp:4.11.0
com.squareup.okhttp3:logging-interceptor:4.11.0
org.json:json:20230618""", StringUtils.join(dependencies, "\n"));
org.jetbrains.kotlin:kotlin-stdlib:2.1.10
org.jetbrains.kotlin:kotlin-stdlib-common:2.1.10
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.10
com.squareup.okhttp3:okhttp:4.12.0
com.squareup.okhttp3:logging-interceptor:4.12.0
org.json:json:20250107""", StringUtils.join(dependencies, "\n"));
}
@Test
@ -702,22 +704,22 @@ public class TestDependencyResolver {
@Test
void testGetCompileRuntimeTransitiveDependenciesBitly() {
var resolver = new DependencyResolver(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY), new Dependency("net.thauvin.erik", "bitly-shorten", new VersionNumber(0, 9, 4, "SNAPSHOT")));
var resolver = new DependencyResolver(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS), new Dependency("net.thauvin.erik", "bitly-shorten", new VersionNumber(2, 0, 0)));
var dependencies = resolver.getAllDependencies(compile, runtime);
assertNotNull(dependencies);
assertEquals(11, dependencies.size());
assertEquals("""
net.thauvin.erik:bitly-shorten:0.9.4-SNAPSHOT
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22
com.squareup.okhttp3:okhttp:4.11.0
com.squareup.okhttp3:logging-interceptor:4.11.0
org.json:json:20230618
org.jetbrains.kotlin:kotlin-stdlib:1.8.22
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.22
com.squareup.okio:okio:3.2.0
org.jetbrains.kotlin:kotlin-stdlib-common:1.8.22
net.thauvin.erik:bitly-shorten:2.0.0
org.jetbrains.kotlin:kotlin-stdlib:2.1.10
org.jetbrains.kotlin:kotlin-stdlib-common:2.1.10
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.10
com.squareup.okhttp3:okhttp:4.12.0
com.squareup.okhttp3:logging-interceptor:4.12.0
org.json:json:20250107
org.jetbrains:annotations:13.0
com.squareup.okio:okio-jvm:3.2.0""", StringUtils.join(dependencies, "\n"));
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.1.10
com.squareup.okio:okio:3.6.0
com.squareup.okio:okio-jvm:3.6.0""", StringUtils.join(dependencies, "\n"));
}
@Test

View file

@ -359,19 +359,19 @@ public class TestDependencySet {
@Test
void testGenerateDependencyTreeCompileRuntime() {
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("""
net.thauvin.erik:bitly-shorten:0.9.4-SNAPSHOT
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22
org.jetbrains.kotlin:kotlin-stdlib:1.8.22
org.jetbrains.kotlin:kotlin-stdlib-common:1.8.22
org.jetbrains:annotations:13.0
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.22
com.squareup.okhttp3:okhttp:4.11.0
com.squareup.okio:okio:3.2.0
com.squareup.okio:okio-jvm:3.2.0
com.squareup.okhttp3:logging-interceptor:4.11.0
org.json:json:20230618
"""), dependencies.generateTransitiveDependencyTree(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY), compile, runtime));
net.thauvin.erik:bitly-shorten:2.0.0
org.jetbrains.kotlin:kotlin-stdlib:2.1.10
org.jetbrains:annotations:13.0
org.jetbrains.kotlin:kotlin-stdlib-common:2.1.10
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.10
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.1.10
com.squareup.okhttp3:okhttp:4.12.0
com.squareup.okio:okio:3.6.0
com.squareup.okio:okio-jvm:3.6.0
com.squareup.okhttp3:logging-interceptor:4.12.0
org.json:json:20250107
"""), dependencies.generateTransitiveDependencyTree(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS), compile, runtime));
}
}

View file

@ -0,0 +1,963 @@
/*
* Copyright 2025 Erik C. Thauvin (https://erik.thauvin.net/)
* Licensed under the Apache License, Version 2.0 (the "License")
*/
package rife.bld.operations;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import rife.bld.operations.JavacOptions.XLintKey;
import java.util.Arrays;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
import static rife.bld.operations.JavacOptions.XLintKey.*;
/**
* Unit tests for JavacOptions class
*/
class TestJavacOptions {
private JavacOptions options;
@BeforeEach
void setUp() {
options = new JavacOptions();
}
@Nested
class AddExportsTests {
@Test
void testAddExportsMethodChaining() {
options.addExports("mod1/pkg1=mod2")
.addExports("mod3/pkg3=ALL-UNNAMED")
.parameters();
assertEquals(5, options.size());
assertTrue(options.contains("--add-exports"));
assertTrue(options.contains("-parameters"));
}
@Test
void testAddExportsMultipleCalls() {
options.addExports("module1/package1=module2")
.addExports("module3/package3=ALL-UNNAMED");
assertEquals(4, options.size());
assertEquals("--add-exports", options.get(0));
assertEquals("module1/package1=module2", options.get(1));
assertEquals("--add-exports", options.get(2));
assertEquals("module3/package3=ALL-UNNAMED", options.get(3));
}
@Test
void testAddExportsReturnsThis() {
var result = options.addExports("module1/package1=module2");
assertSame(options, result);
}
@Test
void testAddExportsWithComplexModulePaths() {
options.addExports(
"jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"jdk.compiler/com.sun.tools.javac.tree=mymodule"
);
assertEquals(2, options.size());
assertTrue(options.get(1).contains("jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"));
assertTrue(options.get(1).contains("jdk.compiler/com.sun.tools.javac.tree=mymodule"));
}
@Test
void testAddExportsWithEmptyList() {
options.addExports(List.of());
assertEquals(2, options.size());
assertEquals("--add-exports", options.get(0));
assertEquals("", options.get(1));
}
@Test
void testAddExportsWithEmptyVarargs() {
options.addExports();
assertEquals(2, options.size());
assertEquals("--add-exports", options.get(0));
assertEquals("", options.get(1));
}
@Test
void testAddExportsWithList() {
var modules = Arrays.asList(
"mod1/pkg1=mod2",
"mod3/pkg3=ALL-UNNAMED",
"mod4/pkg4=mod5"
);
options.addExports(modules);
assertEquals(2, options.size());
assertEquals("--add-exports", options.get(0));
assertEquals("mod1/pkg1=mod2,mod3/pkg3=ALL-UNNAMED,mod4/pkg4=mod5", options.get(1));
}
@Test
void testAddExportsWithSingleModule() {
options.addExports("java.base/sun.security.util=ALL-UNNAMED");
assertEquals(2, options.size());
assertEquals("--add-exports", options.get(0));
assertEquals("java.base/sun.security.util=ALL-UNNAMED", options.get(1));
}
@Test
void testAddExportsWithVarargs() {
options.addExports("module1/package1=module2", "module3/package3=ALL-UNNAMED");
assertEquals(2, options.size());
assertEquals("--add-exports", options.get(0));
assertEquals("module1/package1=module2,module3/package3=ALL-UNNAMED", options.get(1));
}
}
@Nested
class AddReadsTests {
@Test
void testAddReadsMethodChaining() {
options.addReads("mod1=mod2")
.addReads("mod3=mod4")
.deprecation();
assertEquals(5, options.size());
assertTrue(options.contains("--add-reads"));
assertTrue(options.contains("-deprecation"));
}
@Test
void testAddReadsMultipleCalls() {
options.addReads("module1=module2")
.addReads("module3=module4");
assertEquals(4, options.size());
assertEquals("--add-reads", options.get(0));
assertEquals("module1=module2", options.get(1));
assertEquals("--add-reads", options.get(2));
assertEquals("module3=module4", options.get(3));
}
@Test
void testAddReadsReturnsThis() {
var result = options.addReads("module1=module2");
assertSame(options, result);
}
@Test
void testAddReadsWithEmptyList() {
options.addReads(List.of());
assertEquals(2, options.size());
assertEquals("--add-reads", options.get(0));
assertEquals("", options.get(1));
}
@Test
void testAddReadsWithEmptyVarargs() {
options.addReads();
assertEquals(2, options.size());
assertEquals("--add-reads", options.get(0));
assertEquals("", options.get(1));
}
@Test
void testAddReadsWithList() {
List<String> modules = Arrays.asList("mod1=mod2", "mod3=mod4", "mod5=mod6");
options.addReads(modules);
assertEquals(2, options.size());
assertEquals("--add-reads", options.get(0));
assertEquals("mod1=mod2,mod3=mod4,mod5=mod6", options.get(1));
}
@Test
void testAddReadsWithSingleModule() {
options.addReads("mymodule=java.base");
assertEquals(2, options.size());
assertEquals("--add-reads", options.get(0));
assertEquals("mymodule=java.base", options.get(1));
}
@Test
void testAddReadsWithVarargs() {
options.addReads("module1=module2", "module3=module4");
assertEquals(2, options.size());
assertEquals("--add-reads", options.get(0));
assertEquals("module1=module2,module3=module4", options.get(1));
}
}
@Nested
class CombinedModuleOptionsTests {
@Test
void testAddReadsAndAddExportsTogether() {
options.addReads("module1=module2")
.addExports("module3/package3=ALL-UNNAMED");
assertEquals(4, options.size());
assertTrue(options.contains("--add-reads"));
assertTrue(options.contains("--add-exports"));
}
@Test
void testAllModuleOptionsWithRelease() {
options.release(17)
.addReads("mod1=mod2")
.addExports("mod3/pkg3=ALL-UNNAMED")
.addModules("java.sql", "java.xml");
assertTrue(options.containsRelease());
assertTrue(options.contains("--add-reads"));
assertTrue(options.contains("--add-exports"));
assertTrue(options.contains("--add-modules"));
}
@Test
void testModuleOptionsMethodChaining() {
var result = options
.addReads("mod1=mod2")
.addExports("mod3/pkg3=mod4")
.release(11)
.deprecation();
assertSame(options, result);
assertEquals(7, options.size());
}
}
@Nested
class DefaultModuleForCreatedFilesTests {
@Test
void testDefaultModuleForCreatedFilesMethodChaining() {
options.defaultModuleForCreatedFiles("mymodule")
.parameters()
.deprecation();
assertEquals(4, options.size());
assertTrue(options.contains("--default-module-for-created-files"));
assertTrue(options.contains("-parameters"));
assertTrue(options.contains("-deprecation"));
}
@Test
void testDefaultModuleForCreatedFilesReturnsThis() {
var result = options.defaultModuleForCreatedFiles("mymodule");
assertSame(options, result);
}
@Test
void testDefaultModuleForCreatedFilesWithAnnotationProcessing() {
options.defaultModuleForCreatedFiles("annotations.generated")
.sourceOutput("generated/sources")
.processorPath("lib/processors.jar");
assertEquals(6, options.size());
assertTrue(options.contains("--default-module-for-created-files"));
assertTrue(options.contains("-s"));
assertTrue(options.contains("--processor-path"));
}
@Test
void testDefaultModuleForCreatedFilesWithModulePath() {
options.defaultModuleForCreatedFiles("mymodule")
.modulePath("lib/modules")
.release(17);
assertEquals(6, options.size());
assertTrue(options.contains("--default-module-for-created-files"));
assertTrue(options.contains("--module-path"));
assertTrue(options.containsRelease());
}
@Test
void testDefaultModuleForCreatedFilesWithProcessing() {
options.defaultModuleForCreatedFiles("mymodule")
.process(JavacOptions.Processing.ONLY)
.processors("com.example.MyProcessor");
assertEquals(5, options.size());
assertTrue(options.contains("--default-module-for-created-files"));
assertTrue(options.contains("-proc:only"));
assertTrue(options.contains("-processor"));
}
@Test
void testDefaultModuleForCreatedFilesWithQualifiedName() {
options.defaultModuleForCreatedFiles("com.example.mymodule");
assertEquals(2, options.size());
assertEquals("--default-module-for-created-files", options.get(0));
assertEquals("com.example.mymodule", options.get(1));
}
@Test
void testDefaultModuleForCreatedFilesWithSingleModule() {
options.defaultModuleForCreatedFiles("mymodule");
assertEquals(2, options.size());
assertEquals("--default-module-for-created-files", options.get(0));
assertEquals("mymodule", options.get(1));
}
@Test
void testMultipleDefaultModuleForCreatedFilesCalls() {
options.defaultModuleForCreatedFiles("module1")
.defaultModuleForCreatedFiles("module2");
assertEquals(4, options.size());
assertEquals("--default-module-for-created-files", options.get(0));
assertEquals("module1", options.get(1));
assertEquals("--default-module-for-created-files", options.get(2));
assertEquals("module2", options.get(3));
}
}
@Nested
class PatchModuleTests {
@Test
void testMultiplePatchModuleCalls() {
options.patchModule("module1=path1")
.patchModule("module2=path2");
assertEquals(4, options.size());
assertEquals("--patch-module", options.get(0));
assertEquals("module1=path1", options.get(1));
assertEquals("--patch-module", options.get(2));
assertEquals("module2=path2", options.get(3));
}
@Test
void testPatchModuleMethodChaining() {
options.patchModule("module1=path1")
.patchModule("module2=path2")
.deprecation();
assertEquals(5, options.size());
assertTrue(options.contains("--patch-module"));
assertTrue(options.contains("-deprecation"));
}
@Test
void testPatchModuleReturnsThis() {
var result = options.patchModule("mymodule=path/to/classes");
assertSame(options, result);
}
@Test
void testPatchModuleWithDirectoryPath() {
options.patchModule("com.example.module=build/classes");
assertEquals(2, options.size());
assertEquals("--patch-module", options.get(0));
assertEquals("com.example.module=build/classes", options.get(1));
}
@Test
void testPatchModuleWithJarPath() {
options.patchModule("java.base=mylib.jar");
assertEquals(2, options.size());
assertEquals("--patch-module", options.get(0));
assertEquals("java.base=mylib.jar", options.get(1));
}
@Test
void testPatchModuleWithMultiplePaths() {
options.patchModule("mymodule=path1:path2:path3");
assertEquals(2, options.size());
assertEquals("--patch-module", options.get(0));
assertEquals("mymodule=path1:path2:path3", options.get(1));
}
@Test
void testPatchModuleWithOtherModuleOptions() {
options.patchModule("mymodule=classes")
.addModules("java.sql")
.release(17);
assertEquals(6, options.size());
assertTrue(options.contains("--patch-module"));
assertTrue(options.contains("--add-modules"));
assertTrue(options.containsRelease());
}
@Test
void testPatchModuleWithSingleModule() {
options.patchModule("mymodule=path/to/classes");
assertEquals(2, options.size());
assertEquals("--patch-module", options.get(0));
assertEquals("mymodule=path/to/classes", options.get(1));
}
}
@Nested
class ReleaseTests {
@Test
void testContainsReleaseAfterClear() {
options.release(11);
assertTrue(options.containsRelease());
options.clear();
assertFalse(options.containsRelease());
}
@Test
void testContainsReleaseAfterMultipleOptions() {
options.deprecation()
.parameters()
.release(17)
.warningError();
assertTrue(options.containsRelease());
}
@Test
void testContainsReleaseWhenNotSet() {
assertFalse(options.containsRelease());
}
@Test
void testContainsReleaseWhenSet() {
options.release(11);
assertTrue(options.containsRelease());
}
@Test
void testContainsReleaseWithOnlyReleaseOption() {
options.add("--release");
assertTrue(options.containsRelease());
}
@Test
void testContainsReleaseWithOtherOptions() {
options.deprecation()
.parameters()
.warningError();
assertFalse(options.containsRelease());
}
@Test
void testMultipleReleaseCalls() {
options.release(11)
.release(17);
assertEquals(4, options.size());
assertEquals("--release", options.get(0));
assertEquals("11", options.get(1));
assertEquals("--release", options.get(2));
assertEquals("17", options.get(3));
assertTrue(options.containsRelease());
}
@Test
void testReleaseMethodChaining() {
options.release(17)
.enablePreview()
.deprecation();
assertEquals(4, options.size());
assertTrue(options.contains("--release"));
assertTrue(options.contains("--enable-preview"));
assertTrue(options.contains("-deprecation"));
}
@Test
void testReleaseReturnsThis() {
var result = options.release(11);
assertSame(options, result);
}
@Test
void testReleaseWithEnablePreview() {
options.release(21)
.enablePreview();
assertTrue(options.containsRelease());
assertTrue(options.contains("--enable-preview"));
assertEquals(3, options.size());
}
@Test
void testReleaseWithVersion11() {
options.release(11);
assertEquals(2, options.size());
assertEquals("--release", options.get(0));
assertEquals("11", options.get(1));
}
@Test
void testReleaseWithVersion17() {
options.release(17);
assertEquals(2, options.size());
assertEquals("--release", options.get(0));
assertEquals("17", options.get(1));
}
@Test
void testReleaseWithVersion21() {
options.release(21);
assertEquals(2, options.size());
assertEquals("--release", options.get(0));
assertEquals("21", options.get(1));
}
@Test
void testReleaseWithVersion8() {
options.release(8);
assertEquals(2, options.size());
assertEquals("--release", options.get(0));
assertEquals("8", options.get(1));
}
}
@Nested
class SourceTests {
@Test
void testMultipleSourceCalls() {
options.source(11)
.source(17);
assertEquals(4, options.size());
assertEquals("--source", options.get(0));
assertEquals("11", options.get(1));
assertEquals("--source", options.get(2));
assertEquals("17", options.get(3));
}
@Test
void testSourceMethodChaining() {
options.source(17)
.deprecation()
.parameters();
assertEquals(4, options.size());
assertTrue(options.contains("--source"));
assertTrue(options.contains("-deprecation"));
assertTrue(options.contains("-parameters"));
}
@Test
void testSourceReturnsThis() {
var result = options.source(11);
assertSame(options, result);
}
@Test
void testSourceWithTarget() {
options.source(11)
.target(11);
assertEquals(4, options.size());
assertTrue(options.contains("--source"));
assertTrue(options.contains("--target"));
}
@Test
void testSourceWithVersion11() {
options.source(11);
assertEquals(2, options.size());
assertEquals("--source", options.get(0));
assertEquals("11", options.get(1));
}
@Test
void testSourceWithVersion17() {
options.source(17);
assertEquals(2, options.size());
assertEquals("--source", options.get(0));
assertEquals("17", options.get(1));
}
@Test
void testSourceWithVersion21() {
options.source(21);
assertEquals(2, options.size());
assertEquals("--source", options.get(0));
assertEquals("21", options.get(1));
}
@Test
void testSourceWithVersion8() {
options.source(8);
assertEquals(2, options.size());
assertEquals("--source", options.get(0));
assertEquals("8", options.get(1));
}
}
@Nested
class TargetTests {
@Test
void testMultipleTargetCalls() {
options.target(11)
.target(17);
assertEquals(4, options.size());
assertEquals("--target", options.get(0));
assertEquals("11", options.get(1));
assertEquals("--target", options.get(2));
assertEquals("17", options.get(3));
}
@Test
void testTargetMethodChaining() {
options.target(17)
.deprecation()
.parameters();
assertEquals(4, options.size());
assertTrue(options.contains("--target"));
assertTrue(options.contains("-deprecation"));
assertTrue(options.contains("-parameters"));
}
@Test
void testTargetReturnsThis() {
var result = options.target(11);
assertSame(options, result);
}
@Test
void testTargetWithRelease() {
options.target(17)
.release(17)
.enablePreview();
assertEquals(5, options.size());
assertTrue(options.contains("--target"));
assertTrue(options.contains("--release"));
assertTrue(options.contains("--enable-preview"));
}
@Test
void testTargetWithSource() {
options.target(17)
.source(17);
assertEquals(4, options.size());
assertTrue(options.contains("--target"));
assertTrue(options.contains("--source"));
}
@Test
void testTargetWithVersion11() {
options.target(11);
assertEquals(2, options.size());
assertEquals("--target", options.get(0));
assertEquals("11", options.get(1));
}
@Test
void testTargetWithVersion17() {
options.target(17);
assertEquals(2, options.size());
assertEquals("--target", options.get(0));
assertEquals("17", options.get(1));
}
@Test
void testTargetWithVersion21() {
options.target(21);
assertEquals(2, options.size());
assertEquals("--target", options.get(0));
assertEquals("21", options.get(1));
}
@Test
void testTargetWithVersion8() {
options.target(8);
assertEquals(2, options.size());
assertEquals("--target", options.get(0));
assertEquals("8", options.get(1));
}
}
@Nested
class XLintTests {
@Test
void testMultipleXLintCalls() {
options.xLint(DEPRECATION)
.xLint(UNCHECKED);
assertEquals(2, options.size());
assertTrue(options.contains("-Xlint:deprecation"));
assertTrue(options.contains("-Xlint:unchecked"));
}
@Test
void testMultipleXLintDisableCalls() {
options.xLintDisable(RAWTYPES)
.xLintDisable(SERIAL);
assertEquals(2, options.size());
assertTrue(options.contains("-Xlint:-rawtypes"));
assertTrue(options.contains("-Xlint:-serial"));
}
@Test
void testXLintAllKey() {
options.xLint(ALL);
assertTrue(options.contains("-Xlint:all"));
}
@Test
void testXLintBasic() {
options.xLint();
assertTrue(options.contains("-Xlint"));
assertEquals(1, options.size());
}
@Test
void testXLintCaseSensitivity() {
options.xLint(DEPRECATION, UNCHECKED);
var result = options.get(0);
assertEquals("-Xlint:deprecation,unchecked", result);
assertFalse(result.contains("DEPRECATION"));
assertFalse(result.contains("UNCHECKED"));
}
@Test
void testXLintCombinedWithOtherOptions() {
options.deprecation()
.xLint(UNCHECKED, RAWTYPES)
.warningError();
assertEquals(3, options.size());
assertTrue(options.contains("-deprecation"));
assertTrue(options.contains("-Xlint:unchecked,rawtypes"));
assertTrue(options.contains("-Werror"));
}
@Test
void testXLintDisableAllKey() {
options.xLintDisable(ALL);
assertTrue(options.contains("-Xlint:-all"));
}
@Test
void testXLintDisableCombinedWithOtherOptions() {
options.xLint()
.xLintDisable(DEPRECATION)
.parameters();
assertEquals(3, options.size());
assertTrue(options.contains("-Xlint"));
assertTrue(options.contains("-Xlint:-deprecation"));
assertTrue(options.contains("-parameters"));
}
@Test
void testXLintDisableEmptyList() {
List<XLintKey> emptyList = List.of();
options.xLintDisable(emptyList);
assertEquals(0, options.size());
}
@Test
void testXLintDisableNullList() {
options.xLintDisable((List<XLintKey>) null);
assertEquals(0, options.size());
}
@Test
void testXLintDisableReturnsThis() {
var result = options.xLintDisable(UNCHECKED);
assertSame(options, result);
}
@Test
void testXLintDisableWithList() {
var keys = Arrays.asList(SERIAL, STATIC, STRICTFP);
options.xLintDisable(keys);
assertTrue(options.contains("-Xlint:-serial,-static,-strictfp"));
assertEquals(1, options.size());
}
@Test
void testXLintDisableWithMultipleKeys() {
options.xLintDisable(UNCHECKED, RAWTYPES, FALLTHROUGH);
assertTrue(options.contains("-Xlint:-unchecked,-rawtypes,-fallthrough"));
assertEquals(1, options.size());
}
@Test
void testXLintDisableWithSingleKey() {
options.xLintDisable(DEPRECATION);
assertTrue(options.contains("-Xlint:-deprecation"));
assertEquals(1, options.size());
}
@Test
void testXLintDisableWithUnderscoreConversion() {
options.xLintDisable(DEP_ANN, MISSING_EXPLICIT_CTOR);
assertTrue(options.contains("-Xlint:-dep-ann,-missing-explicit-ctor"));
assertEquals(1, options.size());
}
@Test
void testXLintEmptyList() {
List<XLintKey> emptyList = List.of();
options.xLint(emptyList);
assertEquals(0, options.size());
}
@Test
void testXLintMethodChaining() {
var result = options
.xLint()
.xLint(DEPRECATION)
.xLintDisable(RAWTYPES)
.deprecation();
assertSame(options, result);
assertEquals(4, options.size());
}
@Test
void testXLintNoneKey() {
options.xLint(NONE);
assertTrue(options.contains("-Xlint:none"));
}
@Test
void testXLintNullList() {
options.xLint((List<XLintKey>) null);
assertEquals(0, options.size());
}
@Test
void testXLintReturnsThis() {
var result = options.xLint();
assertSame(options, result);
}
@Test
void testXLintWithAllAvailableKeys() {
options.xLint(
ALL, AUXILIARYCLASS, CAST, CLASSFILE, DANGLING_DOC_COMMENTS,
DEP_ANN, DEPRECATION, DIVZERO, EMPTY, EXPORTS, FALLTHROUGH,
FINALLY, IDENTITY, INCUBATING, LOSSY_CONVERSIONS,
MISSING_EXPLICIT_CTOR, MODULE, NONE, OPENS, OPTIONS,
OUTPUT_FILE_CLASH, OVERLOADS, OVERRIDES, PATH, PREVIEW,
PROCESSING, RAWTYPES, REMOVAL, REQUIRES_AUTOMATIC,
REQUIRES_TRANSITIVE_AUTOMATIC, RESTRICTED, SERIAL, STATIC,
STRICTFP, SYNCHRONIZATION, TEXT_BLOCKS, THIS_ESCAPE,
TRY, UNCHECKED, VARARGS
);
String[] keys = {
"all", "auxiliaryclass", "cast", "classfile", "dangling-doc-comments",
"dep-ann", "deprecation", "divzero", "empty", "exports", "fallthrough",
"finally", "identity", "incubating", "lossy-conversions",
"missing-explicit-ctor", "module", "none", "opens", "options",
"output-file-clash", "overloads", "overrides", "path", "preview",
"processing", "rawtypes", "removal", "requires-automatic",
"requires-transitive-automatic", "restricted", "serial", "static",
"strictfp", "synchronization", "text-blocks", "this-escape",
"try", "unchecked", "varargs"
};
assertEquals(1, options.size());
var result = options.get(0);
assertTrue(result.startsWith("-Xlint:"));
for (var key : keys) {
assertTrue(result.contains(key));
}
}
@Test
void testXLintWithAllUnderscoreKeys() {
options.xLint(
DANGLING_DOC_COMMENTS,
LOSSY_CONVERSIONS,
REQUIRES_AUTOMATIC,
REQUIRES_TRANSITIVE_AUTOMATIC,
TEXT_BLOCKS,
THIS_ESCAPE
);
var expected = "-Xlint:dangling-doc-comments,lossy-conversions,requires-automatic," +
"requires-transitive-automatic,text-blocks,this-escape";
assertTrue(options.contains(expected));
assertEquals(1, options.size());
}
@Test
void testXLintWithKeysReturnsThis() {
var result = options.xLint(DEPRECATION);
assertSame(options, result);
}
@Test
void testXLintWithList() {
var keys = Arrays.asList(CAST, DIVZERO, EMPTY);
options.xLint(keys);
assertTrue(options.contains("-Xlint:cast,divzero,empty"));
assertEquals(1, options.size());
}
@Test
void testXLintWithMultipleKeys() {
options.xLint(DEPRECATION, UNCHECKED, RAWTYPES);
assertTrue(options.contains("-Xlint:deprecation,unchecked,rawtypes"));
assertEquals(1, options.size());
}
@Test
void testXLintWithSingleKey() {
options.xLint(ALL);
assertTrue(options.contains("-Xlint:all"));
assertEquals(1, options.size());
}
@Test
void testXLintWithUnderscoreConversion() {
options.xLint(DEP_ANN, OUTPUT_FILE_CLASH, MISSING_EXPLICIT_CTOR);
assertTrue(options.contains("-Xlint:dep-ann,output-file-clash,missing-explicit-ctor"));
assertEquals(1, options.size());
}
}
}