Skip to content

Commit

Permalink
* Added extra checks to ensure that context names are unique.
Browse files Browse the repository at this point in the history
* Added asBoxed() to all primitive validators.
* Removed dependency on maven-nexus-plugin.
  • Loading branch information
cowwoc committed May 23, 2024
1 parent d291936 commit 9cf4bfb
Show file tree
Hide file tree
Showing 71 changed files with 1,012 additions and 830 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ concurrency:

jobs:
build:
name: Build
name: Build (${{ matrix.runtime }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -25,12 +25,13 @@ jobs:
path: |
~/.m2/repository/*
!~/.m2/repository/com/github/cowwoc/requirements
key: ${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}
key: "${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}"

# Maven command-line options:
# --batch-mode: recommended in CI to inform maven to not run in interactive mode (less logs)
# -V: strongly recommended in CI, will display the JDK and Maven versions in use.
# Very useful to be quickly sure the selected versions were the ones you think.
# -Dsurefire.useFile=false: useful in CI. Displays test errors in the logs directly (instead of
# having to crawl the workspace files to see the cause).
# -e: Display stack-traces on failure
- name: Build
run: ./mvnw install --batch-mode -V -e
run: ./mvnw install --batch-mode -V "-Dsurefire.useFile=false" -e
120 changes: 80 additions & 40 deletions .github/workflows/deploy_to_maven_central.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
# Source: https://docs.github.com/en/actions/publishing-packages/publishing-java-packages-with-maven
# Based on https://docs.github.com/en/actions/publishing-packages/publishing-java-packages-with-maven
# https://gist.github.com/cstamas/69e6365bbb70521923020d68369bf8e5 and
# https://oss.sonatype.org/nexus-staging-plugin/default/docs/rest.html
name: Deploy to Maven Central
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
env:
# One can look up a project's profileId by running:
# mvn nexus-staging:rc-list-profiles -DserverId=maven-central-releases -DnexusUrl=https://oss.sonatype.org/
STAGING_PROFILE_ID: "3799bb102c7f24"
STAGING_HOST: "oss.sonatype.org"
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
jobs:
open-release:
runs-on: ubuntu-latest
outputs:
INITIAL_REF_POSITION: ${{ steps.open-staging.outputs.INITIAL_REF_POSITION }}
TAG: ${{ steps.open-staging.outputs.TAG }}
STAGING_REPOSITORY_ID: ${{ steps.open-staging.outputs.STAGING_REPOSITORY_ID }}
INITIAL_REF_POSITION: ${{ steps.create-tag.outputs.INITIAL_REF_POSITION }}
TAG: ${{ steps.create-tag.outputs.TAG }}
VERSION: ${{ steps.create-tag.outputs.VERSION }}
STAGING_PROFILE_ID: ${{ steps.parse-profile-id.outputs.STAGING_PROFILE_ID }}
STAGING_REPOSITORY_ID: ${{ steps.parse-repository-id.outputs.STAGING_REPOSITORY_ID }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0
token: ${{ secrets.WORKFLOW_TOKEN }}
- uses: actions/setup-java@v4
with:
distribution: zulu
Expand All @@ -33,14 +37,15 @@ jobs:
server-password: OSSRH_TOKEN
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Cache Dependencies
uses: actions/cache@v4
with:
# Avoid caching generated artifacts
path: |
~/.m2/repository/*
!~/.m2/repository/com/github/cowwoc/requirements
key: ${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}
key: "${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}"

- name: Configure Git User
run: |
Expand All @@ -57,26 +62,53 @@ jobs:
#
# Setting a GitHub Action output parameter:
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter
- name: Open staging repository
id: open-staging
# Extracting the release version number: https://stackoverflow.com/a/16623897/14731
- name: Create tag
id: create-tag
run: |
echo "INITIAL_REF_POSITION=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "INITIAL_REF_POSITION=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
./mvnw release:prepare --batch-mode -V -e -Darguments="-Ddeploy -Dinvoker.skip=true"
echo "TAG=$(git describe --tag --abbrev=0)" >> $GITHUB_OUTPUT
output=$(./mvnw --batch-mode -e -DstagingProfileId=${{ env.STAGING_PROFILE_ID }} nexus-staging:rc-open)
[[ "$output" =~ Opened\ (comgithubcowwoc-[[:digit:]]+) ]]
stagingRepositoryId="${BASH_REMATCH[1]}"
echo "STAGING_REPOSITORY_ID=$stagingRepositoryId" >> $GITHUB_OUTPUT
TAG=$(git describe --tag --abbrev=0)
echo "TAG=${TAG}" >> "$GITHUB_OUTPUT"
echo "VERSION=${TAG#"release-"}" >> "$GITHUB_OUTPUT"
- name: Look up staging profile id
id: request-profile-id
run: >
echo "STAGING_PROFILE_ID=$(curl -u '${{ secrets.OSSRH_USERNAME}}:${{ secrets.OSSRH_TOKEN }}'
-H 'Accept:application/json'
'https://${{ env.STAGING_HOST }}/service/local/staging/profile_evaluate?t=maven2&g=com.github.cowwoc.requirements&a=anything&v=anything')"
>> "$GITHUB_OUTPUT"
- name: Parse the staging profile id
id: parse-profile-id
run: >
echo "STAGING_PROFILE_ID=$(echo '${{ steps.request-profile-id.outputs.STAGING_PROFILE_ID }}' | jq -r '.data[0].id')" >> "$GITHUB_OUTPUT"
- name: Open staging repository
id: open-repository
run: >
echo "STAGING_REPOSITORY_ID=$(curl -u '${{ secrets.OSSRH_USERNAME}}:${{ secrets.OSSRH_TOKEN }}'
-H 'Accept: application/json'
-H 'Content-type: application/json'
-X POST -d '{"data": {"description": "com.googlecode.cmake-maven-project:${{ steps.create-tag.outputs.VERSION }}"}}'
'https://${{ env.STAGING_HOST }}/service/local/staging/profiles/${{ steps.parse-profile-id.outputs.STAGING_PROFILE_ID }}/start')"
>> "$GITHUB_OUTPUT"
- name: Parse the staging repository id
id: parse-repository-id
run: >
echo "STAGING_REPOSITORY_ID=$(echo '${{ steps.open-repository.outputs.STAGING_REPOSITORY_ID }}' | jq -r '.data.stagedRepositoryId')" >> "$GITHUB_OUTPUT"
deploy:
name: Deploy
name: Deploy (${{ matrix.runtime }})
needs: open-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.open-release.outputs.TAG }}
token: ${{ secrets.WORKFLOW_TOKEN }}
- uses: actions/setup-java@v4
with:
distribution: zulu
Expand All @@ -87,19 +119,21 @@ jobs:
server-password: OSSRH_TOKEN
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Cache Dependencies
uses: actions/cache@v4
with:
# Avoid caching generated artifacts
path: |
~/.m2/repository/*
!~/.m2/repository/com/github/cowwoc/requirements
key: ${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}
key: "${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}"

- name: Deploy to Maven Central
run: >
./mvnw --batch-mode -V -e -Ddeploy -DstagingProfileId=${{ env.STAGING_PROFILE_ID }}
-DstagingRepositoryId=${{ needs.open-release.outputs.STAGING_REPOSITORY_ID }}
./mvnw --batch-mode -V -e -Ddeploy
-Dstaging_repository_id=${{ needs.open-release.outputs.STAGING_REPOSITORY_ID }}
-Dstaging_host="${{ env.STAGING_HOST }}"
deploy
close-release:
Expand All @@ -109,6 +143,7 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ needs.open-release.outputs.TAG }}
token: ${{ secrets.WORKFLOW_TOKEN }}
- uses: actions/setup-java@v4
with:
distribution: zulu
Expand All @@ -119,31 +154,34 @@ jobs:
server-password: OSSRH_TOKEN
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Cache Dependencies
uses: actions/cache@v4
with:
# Avoid caching generated artifacts
path: |
~/.m2/repository/*
!~/.m2/repository/com/github/cowwoc/requirements
key: ${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}
key: "${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}"

- name: Close staging repository
run: >
./mvnw --batch-mode -V -e -DstagingProfileId=${{ env.STAGING_PROFILE_ID }}
-DstagingRepositoryId=${{ needs.open-release.outputs.STAGING_REPOSITORY_ID }}
nexus-staging:rc-close
curl -u ${{ secrets.OSSRH_USERNAME}}:${{ secrets.OSSRH_TOKEN }} -X POST
-H "Content-Type:application/json"
-d '{"data": {"stagedRepositoryId": "${{ needs.open-release.outputs.STAGING_REPOSITORY_ID }}", "description": "Closing repository"}}'
'https://${{ env.STAGING_HOST }}/service/local/staging/profiles/${{ needs.open-release.outputs.STAGING_PROFILE_ID }}/finish'
# Cleanup on failure: https://stackoverflow.com/a/74562058/14731
on-failure:
needs: [ open-release, deploy, close-release ]
runs-on: ubuntu-latest
if: ${{ always() && contains(needs.*.result, 'failure') }}
if: ${{ failure() || cancelled() }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0
token: ${{ secrets.WORKFLOW_TOKEN }}
- uses: actions/setup-java@v4
with:
distribution: zulu
Expand All @@ -154,20 +192,34 @@ jobs:
server-password: OSSRH_TOKEN
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Cache Dependencies
uses: actions/cache@v4
with:
# Avoid caching generated artifacts
path: |
~/.m2/repository/*
!~/.m2/repository/com/github/cowwoc/requirements
key: ${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}
key: "${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}"

- name: Drop staging repository
if: needs.open-release.outputs.STAGING_REPOSITORY_ID != ''
run: >
curl -u ${{ secrets.OSSRH_USERNAME}}:${{ secrets.OSSRH_TOKEN }} -X POST
-H "Content-Type:application/json"
-d '{"data": {"stagedRepositoryId": "${{ needs.open-release.outputs.STAGING_REPOSITORY_ID }}", "description": "Dropping repository"}}'
'https://${{ env.STAGING_HOST }}/service/local/staging/profiles/${{ needs.open-release.outputs.STAGING_PROFILE_ID }}/drop'
- name: Configure Git User
run: |
git config user.email "[email protected]"
git config user.name "Gili Tzabari"
- name: Delete tag
if: needs.open-release.outputs.TAG != ''
run: |
git push --delete origin ${{ needs.open-release.outputs.TAG }}
- name: Restore the workflow ref to its original position
if: needs.open-release.outputs.INITIAL_REF_POSITION != ''
run: |
Expand All @@ -179,15 +231,3 @@ jobs:
fi
git push -f origin ${{ github.ref_name }}
fi
- name: Delete tag
if: needs.open-release.outputs.TAG != ''
run: |
git push --delete origin ${{ needs.open-release.outputs.TAG }}
- name: Drop staging repository
if: needs.open-release.outputs.STAGING_REPOSITORY_ID != ''
run: >
./mvnw --batch-mode -V -e -DstagingProfileId=${{ env.STAGING_PROFILE_ID }}
-DstagingRepositoryId=${{ needs.open-release.outputs.STAGING_REPOSITORY_ID }}
nexus-staging:rc-drop
1 change: 0 additions & 1 deletion LICENSE-3RD-PARTY.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* [J2ObjC Annotations](https://github.com/google/j2objc/)
* [java-diff-utils](https://github.com/java-diff-utils/java-diff-utils/java-diff-utils)
* [Byte Buddy (without dependencies)](https://bytebuddy.net/byte-buddy)
* [Byte Buddy (without dependencies)](https://bytebuddy.net/byte-buddy)
* [Apache Commons Math](http://commons.apache.org/proper/commons-math/)
* [AssertJ Core](https://assertj.github.io/doc/#assertj-core)
* [testng](https://testng.org)
Expand Down
1 change: 1 addition & 0 deletions benchmark/guava/src/test/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
requires com.google.common;
requires org.testng;
requires com.github.cowwoc.requirements.guava;
requires static com.google.errorprone.annotations;

exports com.github.cowwoc.requirements.benchmark.guava to org.testng;
exports com.github.cowwoc.requirements.benchmark.guava.jmh_generated to jmh.core;
Expand Down
3 changes: 1 addition & 2 deletions benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
<compilerArgs>
<arg>-Xdiags:verbose</arg>
<arg>-Werror</arg>
<arg>-Xlint:all,-module,-requires-automatic,-processing</arg>
<arg>-implicit:class</arg>
<arg>-Xlint:all,-requires-automatic,-processing</arg>
</compilerArgs>
<annotationProcessorPaths>
<!-- WORKAROUND: https://issues.apache.org/jira/browse/MCOMPILER-369 -->
Expand Down
13 changes: 7 additions & 6 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Minor updates involving cosmetic changes have been omitted from this list.
See https://github.com/cowwoc/requirements.java/commits/master for a full list.

## Version 9.0.0 - ?
## Version 9.0.0 - 2024/05/23

* Breaking changes:
1. The library now requires JDK 21.
2. Added a `jackson` module to validate `JsonNode`.
3. Removed the Maven plugin and code generator.
* The code generator was causing a "split package" issue because code was always being generated into
the same package.
* The code generator was causing a "split package" issue because it was generating code into the same
package in all dependent libraries.
* This caused a “split package” error since only one module is allowed to export a package.
4. Removed the use of native binaries. Colored DIFFs are still supported, but Windows requires the use of
Windows Terminal (free download in Windows 10, built-in feature in Windows 11).
5. Renamed `validateThat()` to `checkIf()`.
5. Replaced `validateThat()` with `checkIf()`.
6. Replaced `assertThat()` with `assert assumeThat().elseThrow()`.
7. Added support for the built-in `assert` mechanism.
- Asserts can be used with any type of validator, but are typically used
Expand All @@ -23,8 +23,9 @@ See https://github.com/cowwoc/requirements.java/commits/master for a full list.
validation results.
10. Renamed `Validator.getActual()` to `getValue()`.
11. Replaced `isBetweenClosed(min, max)` with `isBetween(min, true, max, true)`.
12. Renamed `StringValidator.isInteger()` to `isInt()` and `isCharacter()` to `isChar()`.
13. Improved performance by reducing memory usage and the frequency of GC runs.
12. Renamed `StringValidator.isInteger()` to `asPrimitiveInteger()` and `isCharacter()`
to `asPrimitiveCharacter()`.
13. Improved performance by reducing memory allocation and the frequency of GC runs.
14. Added support for primitive types to avoid boxing when possible.
15. Dropped the `isOneOf()` and `isNotOneOf()` functionality yet again. I haven't figured out a good
design for this yet.
Expand Down
2 changes: 0 additions & 2 deletions guava/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
<arg>-Xdiags:verbose</arg>
<arg>-Werror</arg>
<arg>-Xlint:all,-requires-automatic,-requires-transitive-automatic,-module,-try</arg>
<!-- WORKAROUND: https://issues.apache.org/jira/browse/MCOMPILER-368 -->
<arg>-Xpkginfo:always</arg>
</compilerArgs>
</configuration>
</plugin>
Expand Down
4 changes: 1 addition & 3 deletions jackson/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
<arg>-Xdiags:verbose</arg>
<arg>-Werror</arg>
<arg>-Xlint:all,-requires-automatic,-requires-transitive-automatic,-module,-try</arg>
<!-- WORKAROUND: https://issues.apache.org/jira/browse/MCOMPILER-368 -->
<arg>-Xpkginfo:always</arg>
</compilerArgs>
</configuration>
</plugin>
Expand All @@ -54,7 +52,7 @@
<option>summary</option>
</additionalOptions>
<links>
<link>https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-databind/2.17.0/</link>
<link>https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-databind/2.17.1/</link>
</links>
<offlineLinks>
<!--
Expand Down
Loading

0 comments on commit 9cf4bfb

Please sign in to comment.