mirror of
https://github.com/rife2/bld
synced 2026-05-02 03:54:10 +02:00
Compare commits
33 commits
e93b9ae974
...
aa5a739d9a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa5a739d9a | ||
|
|
737927da26 | ||
|
|
6fd3948f04 | ||
|
|
c537b584f2 | ||
|
|
7a419ed197 | ||
|
|
9c5928f9b1 | ||
|
|
26ff495b79 | ||
|
|
585325dd46 | ||
|
|
793fde47dc | ||
|
|
fea026a9c6 | ||
|
|
c71a98c6ee | ||
|
|
8ad5414d67 | ||
|
|
684c697896 | ||
|
|
affa9e1dac | ||
|
|
1c70337afb | ||
|
|
25bf0d3595 | ||
|
|
0ec366e90b | ||
|
|
8559696a6a | ||
|
|
6f54789dd9 | ||
|
|
82fe6a3aa4 | ||
|
|
52e8a6ce6a | ||
|
|
f33108a3f0 | ||
|
|
f4db05581b | ||
|
|
ba1dad4eb3 | ||
|
|
82705b952b | ||
|
|
5efbc8c064 | ||
|
|
22752668b7 | ||
|
|
9bea6d47c7 | ||
|
|
b0596911ed | ||
|
|
e9906c0df7 | ||
|
|
d3d7614e7c | ||
|
|
91a621dfea | ||
|
|
5af8ca7b2e |
51
.github/workflows/bld.yml
vendored
51
.github/workflows/bld.yml
vendored
|
|
@ -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
|
||||||
|
|
@ -104,19 +107,31 @@ jobs:
|
||||||
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
|
||||||
|
|
@ -133,16 +148,26 @@ jobs:
|
||||||
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
|
||||||
|
|
@ -162,6 +187,16 @@ jobs:
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -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.2.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.2.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!/" />
|
||||||
|
|
|
||||||
20
CONTRIBUTING.md
Normal file
20
CONTRIBUTING.md
Normal 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.
|
||||||
26
README.md
26
README.md
|
|
@ -1,9 +1,9 @@
|
||||||
[](https://opensource.org/licenses/Apache-2.0)
|
[](https://opensource.org/licenses/Apache-2.0)
|
||||||
[](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
|
[](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
|
||||||
[](https://rife2.com/bld)
|
[](https://rife2.com/bld)
|
||||||
[](https://github.com/rife2/bld/releases/latest)
|
[](https://github.com/rife2/bld/releases/latest)
|
||||||
[](https://maven-badges.herokuapp.com/maven-central/com.uwyn.rife2/bld)
|
[](https://maven-badges.herokuapp.com/maven-central/com.uwyn.rife2/bld)
|
||||||
[](https://s01.oss.sonatype.org/content/repositories/snapshots/com/uwyn/rife2/bld/)
|
[](https://github.com/rife2/bld/packages/2214741/versions)
|
||||||
[](https://github.com/rife2/bld/actions/workflows/bld.yml)
|
[](https://github.com/rife2/bld/actions/workflows/bld.yml)
|
||||||
[](https://libs.tech/project/638725478/bld)
|
[](https://libs.tech/project/638725478/bld)
|
||||||
[](https://github.com/rife2/rife2/actions/workflows/bld.yml)
|
[](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/).
|
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
2
core
|
|
@ -1 +1 @@
|
||||||
Subproject commit f8bde83ca806403dd8f37294239ac77dba8ad010
|
Subproject commit fa567721c00d99626ed439db4f0340eadff0ec03
|
||||||
Binary file not shown.
|
|
@ -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.4.2
|
bld.extension-antlr=com.uwyn.rife2:bld-antlr4:1.4.3
|
||||||
bld.extension-archive=com.uwyn.rife2:bld-archive:0.6.2
|
bld.extension-archive=com.uwyn.rife2:bld-archive:0.6.3
|
||||||
bld.extension-tests=com.uwyn.rife2:bld-tests-badge:1.6.2
|
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.2.1
|
bld.version=2.3.0
|
||||||
|
|
@ -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,7 +34,7 @@ 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(20250107)));
|
.include(dependency("org.json", "json", version(20250517)));
|
||||||
|
|
||||||
var core_dir = new File(workDirectory(), "core");
|
var core_dir = new File(workDirectory(), "core");
|
||||||
var core_src_dir = new File(core_dir, "src");
|
var core_src_dir = new File(core_dir, "src");
|
||||||
|
|
@ -86,7 +87,7 @@ public class BldBuild extends AbstractRife2Build {
|
||||||
|
|
||||||
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")
|
||||||
|
|
@ -161,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();
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,10 +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.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -233,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>
|
||||||
|
|
@ -247,6 +256,20 @@ 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.
|
* Provides module path entries to use for the operation.
|
||||||
*
|
*
|
||||||
|
|
@ -259,6 +282,17 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
|
||||||
return (T) this;
|
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.
|
* Provides a list of module path entries to use for the operation.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -273,6 +307,20 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
|
||||||
return (T) this;
|
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.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -87,11 +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()) {
|
||||||
compileMainModulePath(),
|
if (!silent()) {
|
||||||
sources,
|
System.err.println("No main source files found.");
|
||||||
buildMainDirectory());
|
}
|
||||||
|
} else {
|
||||||
|
executeBuildSources(
|
||||||
|
compileMainClasspath(),
|
||||||
|
compileMainModulePath(),
|
||||||
|
sources,
|
||||||
|
buildMainDirectory());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -105,11 +112,18 @@ 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()) {
|
||||||
compileTestModulePath(),
|
if (!silent()) {
|
||||||
sources,
|
System.err.println("No test source files found.");
|
||||||
buildTestDirectory());
|
}
|
||||||
|
} else {
|
||||||
|
executeBuildSources(
|
||||||
|
compileTestClasspath(),
|
||||||
|
compileTestModulePath(),
|
||||||
|
sources,
|
||||||
|
buildTestDirectory());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ 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;
|
||||||
|
|
||||||
import static rife.bld.operations.CompileOperation.COMPILE_OPTION_MODULE_PATH;
|
import static rife.bld.operations.CompileOperation.COMPILE_OPTION_MODULE_PATH;
|
||||||
|
|
||||||
|
|
@ -35,6 +36,49 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
FULL, NONE, ONLY
|
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
|
* Option to pass to annotation processors
|
||||||
*
|
*
|
||||||
|
|
@ -46,10 +90,57 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
return this;
|
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,
|
* Root modules to resolve in addition to the initial modules,
|
||||||
* or all modules on the module path if a module is
|
* or all modules on the module path if a module is ALL-MODULE-PATH
|
||||||
* ALL-MODULE-PATH.
|
|
||||||
*
|
*
|
||||||
* @return this list of options
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
|
|
@ -60,8 +151,7 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Root modules to resolve in addition to the initial modules,
|
* Root modules to resolve in addition to the initial modules,
|
||||||
* or all modules on the module path if a module is
|
* or all modules on the module path if a module is ALL-MODULE-PATH
|
||||||
* ALL-MODULE-PATH.
|
|
||||||
*
|
*
|
||||||
* @return this list of options
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
|
|
@ -84,6 +174,19 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
return this;
|
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
|
* 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
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @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
|
* @return {@code true} if the release was set; or
|
||||||
* {@code false} otherwise
|
* {@code false} otherwise
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public boolean containsRelease() {
|
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
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
|
|
@ -253,6 +368,30 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
return this;
|
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
|
* 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
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
|
|
@ -681,4 +820,69 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
add("-Werror");
|
add("-Werror");
|
||||||
return this;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -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,6 +28,7 @@ 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.dependencies.Dependency.*;
|
||||||
import static rife.bld.publish.MetadataBuilder.SNAPSHOT_TIMESTAMP_FORMATTER;
|
import static rife.bld.publish.MetadataBuilder.SNAPSHOT_TIMESTAMP_FORMATTER;
|
||||||
|
|
@ -40,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;
|
||||||
|
|
@ -87,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.");
|
||||||
|
|
@ -133,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);
|
||||||
|
|
||||||
|
|
@ -161,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -181,7 +195,7 @@ 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 || 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;
|
type = TYPE_JAR;
|
||||||
}
|
}
|
||||||
artifact_name.append('.').append(type);
|
artifact_name.append('.').append(type);
|
||||||
|
|
@ -470,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;
|
||||||
|
|
@ -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}.
|
* Configures a publish operation from a {@link BaseProject}.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,9 @@ public class RunOperation extends AbstractProcessOperation<RunOperation> {
|
||||||
else if (mainClass() != null && !mainClass().isEmpty()){
|
else if (mainClass() != null && !mainClass().isEmpty()){
|
||||||
args.add(mainClass());
|
args.add(mainClass());
|
||||||
}
|
}
|
||||||
|
else if (!silent()) {
|
||||||
|
System.err.println("No main class or module specified.");
|
||||||
|
}
|
||||||
|
|
||||||
args.addAll(runOptions());
|
args.addAll(runOptions());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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";
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
2.2.2-SNAPSHOT
|
2.3.1-SNAPSHOT
|
||||||
|
|
@ -331,15 +331,17 @@ public class TestDependencyResolver {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGetCompileRuntimeDependenciesBitly() {
|
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);
|
var dependencies = resolver.getDirectDependencies(compile, runtime);
|
||||||
assertNotNull(dependencies);
|
assertNotNull(dependencies);
|
||||||
assertEquals(4, dependencies.size());
|
assertEquals(6, dependencies.size());
|
||||||
assertEquals("""
|
assertEquals("""
|
||||||
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22
|
org.jetbrains.kotlin:kotlin-stdlib:2.1.10
|
||||||
com.squareup.okhttp3:okhttp:4.11.0
|
org.jetbrains.kotlin:kotlin-stdlib-common:2.1.10
|
||||||
com.squareup.okhttp3:logging-interceptor:4.11.0
|
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.10
|
||||||
org.json:json:20230618""", StringUtils.join(dependencies, "\n"));
|
com.squareup.okhttp3:okhttp:4.12.0
|
||||||
|
com.squareup.okhttp3:logging-interceptor:4.12.0
|
||||||
|
org.json:json:20250107""", StringUtils.join(dependencies, "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -702,22 +704,22 @@ public class TestDependencyResolver {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGetCompileRuntimeTransitiveDependenciesBitly() {
|
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);
|
var dependencies = resolver.getAllDependencies(compile, runtime);
|
||||||
assertNotNull(dependencies);
|
assertNotNull(dependencies);
|
||||||
assertEquals(11, dependencies.size());
|
assertEquals(11, dependencies.size());
|
||||||
assertEquals("""
|
assertEquals("""
|
||||||
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
|
||||||
com.squareup.okhttp3:okhttp:4.11.0
|
org.jetbrains.kotlin:kotlin-stdlib-common:2.1.10
|
||||||
com.squareup.okhttp3:logging-interceptor:4.11.0
|
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.10
|
||||||
org.json:json:20230618
|
com.squareup.okhttp3:okhttp:4.12.0
|
||||||
org.jetbrains.kotlin:kotlin-stdlib:1.8.22
|
com.squareup.okhttp3:logging-interceptor:4.12.0
|
||||||
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.22
|
org.json:json:20250107
|
||||||
com.squareup.okio:okio:3.2.0
|
|
||||||
org.jetbrains.kotlin:kotlin-stdlib-common:1.8.22
|
|
||||||
org.jetbrains:annotations:13.0
|
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
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
963
src/test/java/rife/bld/operations/TestJavacOptions.java
Normal file
963
src/test/java/rife/bld/operations/TestJavacOptions.java
Normal 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue