Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/create-github-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ runs:
milestone: ${{ inputs.milestone }}
token: ${{ inputs.token }}
config-file: .github/actions/create-github-release/changelog-generator.yml
- name: Create GitHub Release
- name: Publish GitHub Release
env:
GITHUB_TOKEN: ${{ inputs.token }}
shell: bash
run: gh release create ${{ format('v{0}', inputs.milestone) }} --notes-file changelog.md
run: gh release edit ${{ format('v{0}', inputs.milestone) }} --draft=false --notes-file changelog.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
changelog:
repository: spring-io/spring-javaformat
repository: timothysparg/spring-javaformat
15 changes: 15 additions & 0 deletions .github/actions/setup-native/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Setup Native'
runs:
using: composite
steps:
- name: Set Up GraalVM
uses: graalvm/setup-graalvm@v1
with:
distribution: liberica
java-version: '17'
cache: maven
components: native-image
github-token: ${{ github.token }}
- name: Disable Java Problem Matcher
shell: bash
run: echo "::remove-matcher owner=java::"
4 changes: 2 additions & 2 deletions .github/workflows/build-and-deploy-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ name: Build and Deploy Snapshot
on:
push:
branches:
- main
- test-ci
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
build-and-deploy-snapshot:
name: Build and Deploy Snapshot
runs-on: ubuntu-latest
if: ${{ github.repository == 'spring-io/spring-javaformat' }}
steps:
- name: Check Out
uses: actions/checkout@v4
Expand All @@ -18,6 +17,7 @@ jobs:
- name: Build
run: ./mvnw clean deploy --batch-mode --no-transfer-progress --update-snapshots -DaltDeploymentRepository=distribution::file://$(pwd)/distribution-repository
- name: Deploy
if: ${{ github.repository == 'spring-io/spring-javaformat' }}
uses: spring-io/artifactory-deploy-action@v0.0.1
with:
folder: 'distribution-repository'
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/build-cli-native.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build CLI Native
on:
workflow_call:
workflow_dispatch:
permissions:
contents: read
jobs:
build:
name: Build (${{ matrix.name }})
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
include:
- name: linux-amd64
os: linux
arch: amd64
runs-on: ubuntu-latest
- name: linux-arm64
os: linux
arch: arm64
runs-on: ubuntu-24.04-arm
- name: windows-amd64
os: windows
arch: amd64
runs-on: windows-latest
- name: macos-arm64
os: macos
arch: arm64
runs-on: macos-14
steps:
- name: Check Out
uses: actions/checkout@v4
- name: Set Up
uses: ./.github/actions/setup-native
- name: Build
if: matrix.os != 'windows'
shell: bash
env:
MAVEN_OPTS: ""
run: ./mvnw -pl spring-javaformat-cli -am -Pnative package --batch-mode --no-transfer-progress --update-snapshots
- name: Build
if: matrix.os == 'windows'
shell: pwsh
env:
MAVEN_OPTS: ""
run: .\mvnw.cmd -pl spring-javaformat-cli -am -Pnative package --batch-mode --no-transfer-progress --update-snapshots
- name: Prepare Artifact
shell: bash
run: |
binary="spring-javaformat-cli/target/spring-javaformat-cli"
extension=""
if [[ "${{ matrix.os }}" == "windows" ]]; then
binary="${binary}.exe"
extension=".exe"
fi
release_name="spring-javaformat-${{ matrix.os }}-${{ matrix.arch }}${extension}"
mkdir -p native-artifacts
cp "${binary}" "native-artifacts/${release_name}"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: spring-javaformat-${{ matrix.os }}-${{ matrix.arch }}
path: native-artifacts/*
13 changes: 12 additions & 1 deletion .github/workflows/build-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,22 @@ jobs:
build:
name: Build Pull Request
runs-on: ubuntu-latest
if: ${{ github.repository == 'spring-io/spring-javaformat' }}
if: ${{ github.repository == 'timothysparg/spring-javaformat' || github.repository == 'spring-io/spring-javaformat' }}
steps:
- name: Check Out
uses: actions/checkout@v4
- name: Set Up
uses: ./.github/actions/setup
- name: Build
run: ./mvnw clean install --batch-mode --no-transfer-progress --update-snapshots
build-cli-native:
name: Build CLI Native
runs-on: ubuntu-latest
if: ${{ github.repository == 'timothysparg/spring-javaformat' || github.repository == 'spring-io/spring-javaformat' }}
steps:
- name: Check Out
uses: actions/checkout@v4
- name: Set Up Native
uses: ./.github/actions/setup-native
- name: Build CLI Native
run: ./mvnw -pl spring-javaformat-cli -am -Pnative package --batch-mode --no-transfer-progress --update-snapshots
45 changes: 45 additions & 0 deletions .github/workflows/prepare-cli-native-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Prepare CLI Native Release
on:
workflow_call:
inputs:
version:
type: string
required: true
secrets:
gh-token:
required: true
permissions:
contents: write
jobs:
create-draft-release:
name: Create Draft GitHub Release
runs-on: ubuntu-latest
steps:
- name: Check Out
uses: actions/checkout@v4
- name: Create Draft GitHub Release
env:
GH_TOKEN: ${{ secrets.gh-token || github.token }}
shell: bash
run: gh release create ${{ format('v{0}', inputs.version) }} --draft --verify-tag --notes "Draft release"
build:
name: Build
needs: create-draft-release
uses: ./.github/workflows/build-cli-native.yml
upload-assets:
name: Upload Assets
needs:
- create-draft-release
- build
runs-on: ubuntu-latest
steps:
- name: Download Native Artifacts
uses: actions/download-artifact@v4
with:
pattern: spring-javaformat-*
path: native-artifacts
merge-multiple: true
- name: Upload Assets to Draft Release
env:
GH_TOKEN: ${{ secrets.gh-token || github.token }}
run: gh release upload ${{ format('v{0}', inputs.version) }} native-artifacts/* --clobber --repo ${{ github.repository }}
14 changes: 8 additions & 6 deletions .github/workflows/promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
- name: Check Out
uses: actions/checkout@v4
- name: Set Up JFrog CLI
if: ${{ github.repository == 'spring-io/spring-javaformat' }}
uses: jfrog/setup-jfrog-cli@ff5cb544114ffc152db9cea1cd3d5978d5074946 # v4.5.11
env:
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
Expand All @@ -50,10 +51,10 @@ jobs:
fi
echo "status-code=${status_code}" >> $GITHUB_OUTPUT
- name: Download Release Artifacts
if: ${{ steps.check-sync-status.outputs.status-code == '404' }}
if: ${{ github.repository == 'spring-io/spring-javaformat' && steps.check-sync-status.outputs.status-code == '404' }}
run: jf rt download --spec ./.github/artifacts.spec --spec-vars 'buildName=${{ format('spring-javaformat-{0}', inputs.version) }};buildNumber=${{ inputs.build-number }}'
- name: Sync to Maven Central
if: ${{ steps.check-sync-status.outputs.status-code == '404' }}
if: ${{ github.repository == 'spring-io/spring-javaformat' && steps.check-sync-status.outputs.status-code == '404' }}
uses: spring-io/nexus-sync-action@v0.0.1
with:
username: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }}
Expand All @@ -65,7 +66,7 @@ jobs:
release: true
generate-checksums: true
- name: Await Maven Central Sync
if: ${{ steps.check-sync-status.outputs.status-code == '404' }}
if: ${{ github.repository == 'spring-io/spring-javaformat' && steps.check-sync-status.outputs.status-code == '404' }}
run: |
url=${{ format('https://repo.maven.apache.org/maven2/io/spring/javaformat/spring-javaformat/{0}/spring-javaformat-{0}.pom', inputs.version) }}
echo "Waiting for $url"
Expand All @@ -76,17 +77,18 @@ jobs:
done
echo "$url is available"
- name: Promote Build
if: ${{ steps.check-sync-status.outputs.status-code == '404' }}
if: ${{ github.repository == 'spring-io/spring-javaformat' && steps.check-sync-status.outputs.status-code == '404' }}
run: jfrog rt build-promote ${{ format('spring-javaformat-{0}', inputs.version)}} ${{ inputs.build-number }} libs-release-local
- name: Publish Eclipse Update Site
if: ${{ github.repository == 'spring-io/spring-javaformat' }}
uses: ./.github/actions/publish-eclipse-update-site
with:
version: ${{ inputs.version }}
build-number: ${{ inputs.build-number }}
artifactory-username: ${{ secrets.ARTIFACTORY_USERNAME }}
artifactory-password: ${{ secrets.ARTIFACTORY_PASSWORD }}
- name: Create GitHub Release
- name: Publish GitHub Release
uses: ./.github/actions/create-github-release
with:
milestone: ${{ inputs.version }}
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN || github.token }}
15 changes: 14 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
description: Environment
type: environment
required: true
permissions:
contents: write
jobs:
stage:
name: Stage
Expand All @@ -34,6 +36,7 @@ jobs:
release-version: ${{ steps.deduce-versions.outputs.release-version }}
next-version: ${{ steps.deduce-versions.outputs.next-version }}
- name: Deploy to Staging
if: ${{ github.repository == 'spring-io/spring-javaformat' }}
uses: spring-io/artifactory-deploy-action@v0.0.1
with:
folder: distribution-repository
Expand All @@ -49,9 +52,19 @@ jobs:
outputs:
release-version: ${{ steps.deduce-versions.outputs.release-version }}
release-build-number: ${{ github.run_number }}
prepare-cli-native-release:
name: Prepare CLI Native Release
needs: stage
uses: ./.github/workflows/prepare-cli-native-release.yml
with:
version: ${{ needs.stage.outputs.release-version }}
secrets:
gh-token: ${{ secrets.GH_ACTIONS_REPO_TOKEN || github.token }}
promote:
name: Promote
needs: stage
needs:
- stage
- prepare-cli-native-release
uses: ./.github/workflows/promote.yml
with:
environment: ${{ inputs.environment }}
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/rollback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ jobs:
build_name=${{ format('spring-javaformat-{0}', inputs.version)}}
build_number=${{ inputs.build-number }}
jf rt delete --build ${build_name}/${build_number}
- name: Delete Draft GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
run: |
if gh release view ${{ format('v{0}', inputs.version) }} > /dev/null 2>&1; then
gh release delete ${{ format('v{0}', inputs.version) }} --yes --cleanup-tag
fi
12 changes: 12 additions & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
-Xmx1536m
-Dtycho.disableP2Mirrors=true
-Djdk.xml.maxGeneralEntitySizeLimit=0
-Djdk.xml.totalEntitySizeLimit=0
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
49 changes: 47 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
:checkstyle-version: 9.3
== Spring Java Format



=== What is This?
A set of plugins that can be applied to any Java project to provide a consistent "`Spring`" style.
The set currently consists of:
Expand Down Expand Up @@ -211,6 +209,53 @@ springJavaFormat {



=== CLI
The CLI provides formatting and checking support without requiring Maven or Gradle integration.

WARNING: The CLI is experimental and not yet considered a stable interface.

==== Download
Native binaries for Linux, Windows, and macOS are published as assets on the corresponding https://github.com/spring-io/spring-javaformat/releases[GitHub release].

==== Usage
[source,shell]
----
spring-javaformat --help
----

The CLI provides the following commands:

* `apply` formats Java source files in place
* `validate` checks formatting without modifying files
* `check` runs Spring style checks

==== Examples
Format sources in the current project:

[source,shell]
----
spring-javaformat apply .
----

Validate formatting:

[source,shell]
----
spring-javaformat validate .
----

Run style checks:

[source,shell]
----
spring-javaformat check .
----

==== Configuration
The `apply` and `validate` commands honor `.springjavaformatconfig`.



=== Java 8 Support
By default, the formatter requires Java 17.
If you are working on an older project, you can use a variation of the formatter based off Eclipse 2021-03 (the latest Eclipse JDT version built with Java 8).
Expand Down
Loading
Loading