diff --git a/.github/actions/create-github-release/action.yml b/.github/actions/create-github-release/action.yml new file mode 100644 index 00000000..1d72cd3a --- /dev/null +++ b/.github/actions/create-github-release/action.yml @@ -0,0 +1,21 @@ +name: Create GitHub Release +description: Create the release on GitHub with a changelog +inputs: + milestone: + required: true + token: + required: true +runs: + using: composite + steps: + - name: Generate Changelog + uses: spring-io/github-changelog-generator@v0.0.10 + with: + milestone: ${{ inputs.milestone }} + token: ${{ inputs.token }} + config-file: .github/actions/create-github-release/changelog-generator.yml + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ inputs.token }} + shell: bash + run: gh release create ${{ format('v{0}', inputs.milestone) }} --notes-file changelog.md diff --git a/.github/actions/create-github-release/changelog-generator.yml b/.github/actions/create-github-release/changelog-generator.yml new file mode 100644 index 00000000..2ce74a09 --- /dev/null +++ b/.github/actions/create-github-release/changelog-generator.yml @@ -0,0 +1,2 @@ +changelog: + repository: spring-io/spring-javaformat diff --git a/.github/actions/publish-eclipse-update-site/action.yml b/.github/actions/publish-eclipse-update-site/action.yml new file mode 100644 index 00000000..4235c9e8 --- /dev/null +++ b/.github/actions/publish-eclipse-update-site/action.yml @@ -0,0 +1,22 @@ +name: 'Publish Eclipse Update Site ' +inputs: + version: + required: true + build-number: + required: true + artifactory-username: + required: true + artifactory-password: + required: true +runs: + using: composite + steps: + - name: Stage + id: stage + shell: bash + run: . ${{ github.action_path }}/publish-eclipse-update-site.sh; + env: + VERSION: "${{ inputs.version }}" + BUILD_NUMBER: "${{ inputs.build-number }}" + ARTIFACTORY_USERNAME: "${{ inputs.artifactory-username }}" + ARTIFACTORY_PASSWORD: "${{ inputs.artifactory-password }}" diff --git a/ci/scripts/publish-eclipse-update-site-pom-template.xml b/.github/actions/publish-eclipse-update-site/publish-eclipse-update-site-pom-template.xml similarity index 100% rename from ci/scripts/publish-eclipse-update-site-pom-template.xml rename to .github/actions/publish-eclipse-update-site/publish-eclipse-update-site-pom-template.xml diff --git a/ci/scripts/publish-eclipse-update-site.sh b/.github/actions/publish-eclipse-update-site/publish-eclipse-update-site.sh old mode 100755 new mode 100644 similarity index 59% rename from ci/scripts/publish-eclipse-update-site.sh rename to .github/actions/publish-eclipse-update-site/publish-eclipse-update-site.sh index 761f74c3..9ddcee29 --- a/ci/scripts/publish-eclipse-update-site.sh +++ b/.github/actions/publish-eclipse-update-site/publish-eclipse-update-site.sh @@ -1,14 +1,11 @@ -#!/bin/bash -set -e +buildInfo=$( jfrog rt curl api/build/spring-javaformat-${VERSION}/${BUILD_NUMBER} ) +groupId=$( echo ${buildInfo} | jq -r '.buildInfo.modules[0].id' | sed 's/\(.*\):.*:.*/\1/' ) +version=$( echo ${buildInfo} | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' ) -source $(dirname $0)/common.sh +echo "Publishing ${buildName}/${buildNumber} (${groupId}:${version}) to Eclipse Update Site" -buildName=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.name' ) -buildNumber=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.number' ) -groupId=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/\(.*\):.*:.*/\1/' ) -version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' ) +jfrog rt dl --build spring-javaformat-${VERSION}/${BUILD_NUMBER} '**/io.spring.javaformat.eclipse.site*.zip' -echo "Publishing ${buildName}/${buildNumber} to Eclipse Update Site" curl \ -s \ --connect-timeout 240 \ @@ -17,7 +14,7 @@ curl \ -f \ -H "X-Explode-Archive: true" \ -X PUT \ - -T "artifactory-repo/io/spring/javaformat/io.spring.javaformat.eclipse.site/${version}/io.spring.javaformat.eclipse.site-${version}.zip" \ + -T "io/spring/javaformat/io.spring.javaformat.eclipse.site/${version}/io.spring.javaformat.eclipse.site-${version}.zip" \ "https://repo.spring.io/javaformat-eclipse-update-site/${version}/" > /dev/null || { echo "Failed to publish" >&2; exit 1; } releasedVersions=$( curl -s -f -X GET https://repo.spring.io/api/storage/javaformat-eclipse-update-site | jq -r '.children[] | .uri' | cut -c 2- | grep '[0-9].*' | sort -V ) @@ -28,9 +25,8 @@ while read -r releasedVersion; do repositories="${repositories}https://repo.spring.io/javaformat-eclipse-update-site/${releasedVersion}p2" done <<< "${releasedVersions}" -pushd git-repo > /dev/null -sed "s|##repositories##|${repositories}|" ci/scripts/publish-eclipse-update-site-pom-template.xml > publish-eclipse-update-site-pom.xml -run_maven -f publish-eclipse-update-site-pom.xml clean package || { echo "Failed to publish" >&2; exit 1; } +sed "s|##repositories##|${repositories}|" ${GITHUB_ACTION_PATH}/publish-eclipse-update-site-pom-template.xml > publish-eclipse-update-site-pom.xml +./mvnw -f publish-eclipse-update-site-pom.xml clean package || { echo "Failed to publish" >&2; exit 1; } curl \ -s \ @@ -52,6 +48,4 @@ curl \ -T "target/repository/artifacts.jar" \ "https://repo.spring.io/javaformat-eclipse-update-site/" > /dev/null || { echo "Failed to publish" >&2; exit 1; } -popd > /dev/null - echo "Publish complete" diff --git a/.github/actions/stage-code/action.yml b/.github/actions/stage-code/action.yml index a71086eb..1fc1f060 100644 --- a/.github/actions/stage-code/action.yml +++ b/.github/actions/stage-code/action.yml @@ -1,5 +1,4 @@ name: 'Stage ' -description: 'Stage Code' inputs: current-version: required: true diff --git a/.github/artifacts.spec b/.github/artifacts.spec new file mode 100644 index 00000000..0f6c3aac --- /dev/null +++ b/.github/artifacts.spec @@ -0,0 +1,23 @@ +{ + "files": [ + { + "aql": { + "items.find": { + "$and": [ + { + "@build.name": "${buildName}", + "@build.number": "${buildNumber}", + "name": { + "$nmatch": "*.zip" + }, + "name": { + "$nmatch": "*.zip.asc" + } + } + ] + } + }, + "target": "nexus/" + } + ] +} diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml index 968b265f..cad6e40b 100644 --- a/.github/workflows/promote.yml +++ b/.github/workflows/promote.yml @@ -33,5 +33,60 @@ jobs: name: Promote runs-on: ubuntu-latest steps: - - name: Promote - run: echo "Promote happens here" + - name: Check Out + uses: actions/checkout@v4 + - name: Set Up JFrog CLI + uses: jfrog/setup-jfrog-cli@7c95feb32008765e1b4e626b078dfd897c4340ad # v4.1.2 + env: + JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }} + - name: Check Maven Central Sync Status + id: check-sync-status + run: | + url=${{ format('https://repo.maven.apache.org/maven2/io/spring/javaformat/spring-javaformat/{0}/spring-javaformat-{0}.pom', inputs.version) }} + status_code=$( curl --write-out '%{http_code}' --head --silent --output /dev/null ${url} ) + if [ "${status_code}" != 200 ] && [ "${status_code}" != 404 ]; then + echo "Unexpected status code ${status_code}" + exit 1 + fi + echo "status-code=${status_code}" >> $GITHUB_OUTPUT + - name: Download Release Artifacts + if: ${{ 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' }} + uses: spring-io/nexus-sync-action@v0.0.1 + with: + username: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }} + password: ${{ secrets.OSSRH_S01_TOKEN_PASSWORD }} + staging-profile-name: ${{ secrets.OSSRH_S01_STAGING_PROFILE }} + create: true + upload: true + close: true + release: true + generate-checksums: true + - name: Await Maven Central Sync + if: ${{ 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" + until curl --fail --head --silent $url > /dev/null + do + echo "." + sleep 60 + done + echo "$url is available" + - name: Promote Build + if: ${{ 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 + 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 + uses: ./.github/actions/create-github-release + with: + milestone: ${{ inputs.version }} + token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }} diff --git a/.sdkmanrc b/.sdkmanrc index 14fdc133..828308d2 100644 --- a/.sdkmanrc +++ b/.sdkmanrc @@ -1,3 +1,3 @@ # Enable auto-env through the sdkman_auto_env config # Add key=value pairs of SDKs to use below -java=17.0.6-librca +java=17.0.12-librca diff --git a/README.adoc b/README.adoc index 72133a36..60e85607 100644 --- a/README.adoc +++ b/README.adoc @@ -1,4 +1,4 @@ -:release-version: 0.0.41 +:release-version: 0.0.42 :checkstyle-version: 9.3 == Spring Java Format diff --git a/ci/README.adoc b/ci/README.adoc deleted file mode 100644 index bdf75bd5..00000000 --- a/ci/README.adoc +++ /dev/null @@ -1,18 +0,0 @@ -== Concourse pipeline - -Ensure that you've setup the target and can login - -[source] ----- -$ fly -t spring-javaformat login -n spring-javaformat -c https://ci.spring.io ----- - -The pipeline can be deployed using the following command: - -[source] ----- -$ fly -t spring-javaformat set-pipeline -p spring-javaformat -c ci/pipeline.yml -l ci/parameters.yml ----- - -NOTE: This assumes that you have credhub integration configured with the appropriate -secrets. diff --git a/ci/config/release-scripts.yml b/ci/config/release-scripts.yml deleted file mode 100644 index d31f8cba..00000000 --- a/ci/config/release-scripts.yml +++ /dev/null @@ -1,10 +0,0 @@ -logging: - level: - io.spring.concourse: DEBUG -spring: - main: - banner-mode: off -sonatype: - exclude: - - 'build-info\.json' - - '.*\.zip' diff --git a/ci/images/README.adoc b/ci/images/README.adoc deleted file mode 100644 index 84eae160..00000000 --- a/ci/images/README.adoc +++ /dev/null @@ -1,21 +0,0 @@ -== CI Images - -These images are used by CI to run the actual builds. - -To build the image locally run the following from this directory: - ----- -$ docker build --no-cache -f /Dockerfile . ----- - -For example - ----- -$ docker build --no-cache -f spring-boot-ci-image/Dockerfile . ----- - -To test run: - ----- -$ docker run -it --entrypoint /bin/bash ✈ ----- diff --git a/ci/images/ci-image/Dockerfile b/ci/images/ci-image/Dockerfile deleted file mode 100644 index fbdbb4c0..00000000 --- a/ci/images/ci-image/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:focal-20210401 - -ADD setup.sh /setup.sh -ADD get-docker-url.sh /get-docker-url.sh -RUN ./setup.sh - -ENV JAVA_HOME /opt/openjdk -ENV PATH $JAVA_HOME/bin:$PATH -ADD docker-lib.sh /docker-lib.sh - -ENTRYPOINT [ "switch", "shell=/bin/bash", "--", "codep", "/bin/docker daemon" ] diff --git a/ci/images/docker-lib.sh b/ci/images/docker-lib.sh deleted file mode 100755 index 4c7b1d58..00000000 --- a/ci/images/docker-lib.sh +++ /dev/null @@ -1,112 +0,0 @@ -# Based on: https://github.com/concourse/docker-image-resource/blob/master/assets/common.sh - -DOCKER_LOG_FILE=${DOCKER_LOG_FILE:-/tmp/docker.log} -SKIP_PRIVILEGED=${SKIP_PRIVILEGED:-false} -STARTUP_TIMEOUT=${STARTUP_TIMEOUT:-120} - -sanitize_cgroups() { - mkdir -p /sys/fs/cgroup - mountpoint -q /sys/fs/cgroup || \ - mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup - - mount -o remount,rw /sys/fs/cgroup - - sed -e 1d /proc/cgroups | while read sys hierarchy num enabled; do - if [ "$enabled" != "1" ]; then - # subsystem disabled; skip - continue - fi - - grouping="$(cat /proc/self/cgroup | cut -d: -f2 | grep "\\<$sys\\>")" || true - if [ -z "$grouping" ]; then - # subsystem not mounted anywhere; mount it on its own - grouping="$sys" - fi - - mountpoint="/sys/fs/cgroup/$grouping" - - mkdir -p "$mountpoint" - - # clear out existing mount to make sure new one is read-write - if mountpoint -q "$mountpoint"; then - umount "$mountpoint" - fi - - mount -n -t cgroup -o "$grouping" cgroup "$mountpoint" - - if [ "$grouping" != "$sys" ]; then - if [ -L "/sys/fs/cgroup/$sys" ]; then - rm "/sys/fs/cgroup/$sys" - fi - - ln -s "$mountpoint" "/sys/fs/cgroup/$sys" - fi - done - - if ! test -e /sys/fs/cgroup/systemd ; then - mkdir /sys/fs/cgroup/systemd - mount -t cgroup -o none,name=systemd none /sys/fs/cgroup/systemd - fi -} - -start_docker() { - mkdir -p /var/log - mkdir -p /var/run - - if [ "$SKIP_PRIVILEGED" = "false" ]; then - sanitize_cgroups - - # check for /proc/sys being mounted readonly, as systemd does - if grep '/proc/sys\s\+\w\+\s\+ro,' /proc/mounts >/dev/null; then - mount -o remount,rw /proc/sys - fi - fi - - local mtu=$(cat /sys/class/net/$(ip route get 8.8.8.8|awk '{ print $5 }')/mtu) - local server_args="--mtu ${mtu}" - local registry="" - - server_args="${server_args}" - - for registry in $3; do - server_args="${server_args} --insecure-registry ${registry}" - done - - if [ -n "$4" ]; then - server_args="${server_args} --registry-mirror $4" - fi - - try_start() { - dockerd --data-root /scratch/docker ${server_args} >$DOCKER_LOG_FILE 2>&1 & - echo $! > /tmp/docker.pid - - sleep 1 - - echo waiting for docker to come up... - until docker info >/dev/null 2>&1; do - sleep 1 - if ! kill -0 "$(cat /tmp/docker.pid)" 2>/dev/null; then - return 1 - fi - done - } - - export server_args DOCKER_LOG_FILE - declare -fx try_start - trap stop_docker EXIT - - if ! timeout ${STARTUP_TIMEOUT} bash -ce 'while true; do try_start && break; done'; then - echo Docker failed to start within ${STARTUP_TIMEOUT} seconds. - return 1 - fi -} - -stop_docker() { - local pid=$(cat /tmp/docker.pid) - if [ -z "$pid" ]; then - return 0 - fi - - kill -TERM $pid -} - diff --git a/ci/images/get-docker-url.sh b/ci/images/get-docker-url.sh deleted file mode 100755 index 221b3462..00000000 --- a/ci/images/get-docker-url.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -set -e - -version="20.10.6" -echo "https://download.docker.com/linux/static/stable/x86_64/docker-$version.tgz"; diff --git a/ci/images/setup.sh b/ci/images/setup.sh deleted file mode 100755 index 6c90192c..00000000 --- a/ci/images/setup.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -set -ex - -########################################################### -# UTILS -########################################################### -export DEBIAN_FRONTEND=noninteractive -apt-get update -apt-get install --no-install-recommends -y tzdata ca-certificates net-tools libxml2-utils git curl libudev1 libxml2-utils iptables iproute2 jq fontconfig -ln -fs /usr/share/zoneinfo/UTC /etc/localtime -dpkg-reconfigure --frontend noninteractive tzdata -rm -rf /var/lib/apt/lists/* -curl https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.4/concourse-java.sh > /opt/concourse-java.sh - -########################################################### -# JAVA -########################################################### -JDK_URL=https://github.com/bell-sw/Liberica/releases/download/17.0.6+10/bellsoft-jdk17.0.6+10-linux-amd64.tar.gz - -mkdir -p /opt/openjdk -cd /opt/openjdk -curl -L ${JDK_URL} | tar zx --strip-components=1 -test -f /opt/openjdk/bin/java -test -f /opt/openjdk/bin/javac - -########################################################### -# DOCKER -########################################################### -cd / -DOCKER_URL=$( ./get-docker-url.sh ) -curl -L ${DOCKER_URL} | tar zx -mv /docker/* /bin/ -chmod +x /bin/docker* -export ENTRYKIT_VERSION=0.4.0 -curl -L https://github.com/progrium/entrykit/releases/download/v${ENTRYKIT_VERSION}/entrykit_${ENTRYKIT_VERSION}_Linux_x86_64.tgz | tar zx -chmod +x entrykit && \ -mv entrykit /bin/entrykit && \ -entrykit --symlink \ No newline at end of file diff --git a/ci/parameters.yml b/ci/parameters.yml deleted file mode 100644 index d4564cd2..00000000 --- a/ci/parameters.yml +++ /dev/null @@ -1,10 +0,0 @@ -project: spring-javaformat -branch: main -milestone: 0.0.x -github-owner: spring-io -github-repository: spring-javaformat -docker-hub-ci-organization: springci -ci-image: spring-javaformat-ci -artifactory-server: https://repo.spring.io -build-name: spring-javaformat -task-timeout: 2h00m diff --git a/ci/pipeline.yml b/ci/pipeline.yml deleted file mode 100644 index 92027920..00000000 --- a/ci/pipeline.yml +++ /dev/null @@ -1,316 +0,0 @@ -anchors: - github-release-source: &github-release-source - owner: ((github-owner)) - repository: ((github-repository)) - access_token: ((github-ci-release-token)) - artifactory-repo-put-params: &artifactory-repo-put-params - signing_key: ((signing-key)) - signing_passphrase: ((signing-passphrase)) - repo: libs-snapshot-local - folder: distribution-repository - build_uri: https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME} - build_number: ${BUILD_PIPELINE_NAME}-${BUILD_JOB_NAME}-${BUILD_NAME} - disable_checksum_uploads: true - threads: 8 - sonatype-task-params: &sonatype-task-params - SONATYPE_USERNAME: ((sonatype-username)) - SONATYPE_PASSWORD: ((sonatype-password)) - SONATYPE_URL: ((sonatype-url)) - SONATYPE_STAGING_PROFILE_ID: ((sonatype-staging-profile-id)) - artifactory-task-params: &artifactory-task-params - ARTIFACTORY_SERVER: ((artifactory-server)) - ARTIFACTORY_USERNAME: ((artifactory-username)) - ARTIFACTORY_PASSWORD: ((artifactory-password)) - docker-hub-task-params: &docker-hub-task-params - DOCKER_HUB_USERNAME: ((docker-hub-username)) - DOCKER_HUB_PASSWORD: ((docker-hub-password)) - slack-fail-params: &slack-fail-params - text: > - :concourse-failed: - silent: true - icon_emoji: ":concourse:" - username: concourse-ci - slack-success-params: &slack-success-params - text: > - :concourse-succeeded: - silent: true - icon_emoji: ":concourse:" - username: concourse-ci -resource_types: -- name: artifactory-resource - type: registry-image - source: - repository: springio/artifactory-resource - tag: "0.0.18" - username: ((docker-hub-username)) - password: ((docker-hub-password)) -- name: slack-notification - type: registry-image - source: - repository: cfcommunity/slack-notification-resource - username: ((docker-hub-username)) - password: ((docker-hub-password)) -resources: -- name: git-repo - type: git - icon: github - source: - uri: https://github.com/((github-owner))/((github-repository)).git - username: ((github-username)) - password: ((github-ci-release-token)) - branch: ((branch)) -- name: github-pre-release - type: github-release - icon: briefcase-download-outline - source: - <<: *github-release-source - pre_release: true - release: false -- name: github-release - type: github-release - icon: briefcase-download - source: - <<: *github-release-source - pre_release: false - release: true -- name: ci-images-git-repo - type: git - icon: github - source: - uri: https://github.com/((github-owner))/((github-repository)).git - branch: ((branch)) - paths: ["ci/images/*"] -- name: ci-image - type: registry-image - icon: docker - source: - username: ((docker-hub-username)) - password: ((docker-hub-password)) - tag: ((milestone)) - repository: ((docker-hub-ci-organization))/((ci-image)) -- name: artifactory-repo - type: artifactory-resource - icon: package-variant - source: - uri: ((artifactory-server)) - username: ((artifactory-username)) - password: ((artifactory-password)) - build_name: ((build-name)) -- name: slack-alert - type: slack-notification - icon: slack - source: - url: ((slack-webhook-url)) -jobs: -- name: build-ci-images - plan: - - get: ci-images-git-repo - trigger: true - - get: git-repo - - task: build-ci-image - privileged: true - file: git-repo/ci/tasks/build-ci-image.yml - params: - DOCKER_HUB_AUTH: ((docker-hub-auth)) - output_mapping: - image: ci-image - - put: ci-image - params: - image: ci-image/image.tar -- name: build - serial: true - public: true - plan: - - get: ci-image - - get: git-repo - trigger: true - - do: - - task: build-project - image: ci-image - privileged: true - timeout: ((task-timeout)) - file: git-repo/ci/tasks/build-project.yml - params: - <<: *docker-hub-task-params - BRANCH: ((branch)) - on_failure: - do: - - put: slack-alert - params: - <<: *slack-fail-params - - put: slack-alert - params: - <<: *slack-success-params -- name: stage-milestone - serial: true - plan: - - get: ci-image - - get: git-repo - trigger: false - - task: stage - image: ci-image - file: git-repo/ci/tasks/stage.yml - params: - <<: *docker-hub-task-params - RELEASE_TYPE: M - - put: artifactory-repo - params: - <<: *artifactory-repo-put-params - repo: libs-staging-local - - put: git-repo - params: - repository: stage-git-repo -- name: stage-rc - serial: true - plan: - - get: ci-image - - get: git-repo - trigger: false - - task: stage - image: ci-image - file: git-repo/ci/tasks/stage.yml - params: - <<: *docker-hub-task-params - RELEASE_TYPE: RC - - put: artifactory-repo - params: - <<: *artifactory-repo-put-params - repo: libs-staging-local - - put: git-repo - params: - repository: stage-git-repo -- name: stage-release - serial: true - plan: - - get: ci-image - - get: git-repo - trigger: false - - task: stage - image: ci-image - file: git-repo/ci/tasks/stage.yml - params: - <<: *docker-hub-task-params - RELEASE_TYPE: RELEASE - - put: artifactory-repo - params: - <<: *artifactory-repo-put-params - repo: libs-staging-local - - put: git-repo - params: - repository: stage-git-repo -- name: promote-milestone - serial: true - plan: - - get: ci-image - - get: git-repo - trigger: false - - get: artifactory-repo - trigger: false - passed: [stage-milestone] - params: - download_artifacts: false - save_build_info: true - - task: promote - file: git-repo/ci/tasks/promote.yml - params: - RELEASE_TYPE: M - <<: *artifactory-task-params - - task: generate-changelog - file: git-repo/ci/tasks/generate-changelog.yml - params: - RELEASE_TYPE: M - GITHUB_USERNAME: ((github-username)) - GITHUB_TOKEN: ((github-ci-release-token)) - - put: github-pre-release - params: - name: generated-changelog/tag - tag: generated-changelog/tag - body: generated-changelog/changelog.md -- name: promote-rc - serial: true - plan: - - get: ci-image - - get: git-repo - trigger: false - - get: artifactory-repo - trigger: false - passed: [stage-rc] - params: - download_artifacts: false - save_build_info: true - - task: promote - file: git-repo/ci/tasks/promote.yml - params: - RELEASE_TYPE: RC - <<: *artifactory-task-params - - task: generate-changelog - file: git-repo/ci/tasks/generate-changelog.yml - params: - RELEASE_TYPE: RC - - put: github-pre-release - params: - name: generated-changelog/tag - tag: generated-changelog/tag - body: generated-changelog/changelog.md -- name: promote-release - serial: true - plan: - - get: ci-image - - get: git-repo - trigger: false - - get: artifactory-repo - trigger: false - passed: [stage-release] - params: - download_artifacts: true - save_build_info: true - - task: promote - file: git-repo/ci/tasks/promote.yml - params: - RELEASE_TYPE: RELEASE - <<: *artifactory-task-params - <<: *sonatype-task-params -- name: create-github-release - serial: true - plan: - - get: ci-image - - get: git-repo - - get: artifactory-repo - trigger: true - passed: [promote-release] - params: - download_artifacts: false - save_build_info: true - - task: generate-changelog - file: git-repo/ci/tasks/generate-changelog.yml - params: - RELEASE_TYPE: RELEASE - - put: github-release - params: - name: generated-changelog/tag - tag: generated-changelog/tag - body: generated-changelog/changelog.md -- name: publish-eclipse-update-site - serial: true - plan: - - get: ci-image - - get: git-repo - trigger: false - - get: artifactory-repo - trigger: false - passed: [promote-release] - params: - save_build_info: true - - task: publish-eclipse-update-site - image: ci-image - file: git-repo/ci/tasks/publish-eclipse-update-site.yml - params: - ARTIFACTORY_USERNAME: ((artifactory-username)) - ARTIFACTORY_PASSWORD: ((artifactory-password)) -groups: -- name: builds - jobs: [build] -- name: releases - jobs: [stage-milestone, stage-rc, stage-release, promote-milestone, promote-rc, promote-release, create-github-release, publish-eclipse-update-site] -- name: ci-images - jobs: [build-ci-images] diff --git a/ci/scripts/build-project.sh b/ci/scripts/build-project.sh deleted file mode 100755 index 476c837e..00000000 --- a/ci/scripts/build-project.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -set -e - -source $(dirname $0)/common.sh -repository=$(pwd)/distribution-repository - -pushd git-repo > /dev/null -run_maven clean deploy -U -Dfull -DaltDeploymentRepository=distribution::file://${repository} -popd > /dev/null diff --git a/ci/scripts/common.sh b/ci/scripts/common.sh deleted file mode 100644 index 8eea3f79..00000000 --- a/ci/scripts/common.sh +++ /dev/null @@ -1,9 +0,0 @@ -source /opt/concourse-java.sh - -setup_symlinks - -if [[ -n $DOCKER_HUB_USERNAME ]]; then - docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD -fi - -cleanup_maven_repo "io.spring.javaformat" diff --git a/ci/scripts/generate-changelog.sh b/ci/scripts/generate-changelog.sh deleted file mode 100755 index 1e4b6e5b..00000000 --- a/ci/scripts/generate-changelog.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -e - -version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' ) - -java -jar /github-changelog-generator.jar \ - --changelog.repository=spring-io/spring-javaformat \ - ${version} generated-changelog/changelog.md - -echo ${version} > generated-changelog/version -echo v${version} > generated-changelog/tag diff --git a/ci/scripts/promote.sh b/ci/scripts/promote.sh deleted file mode 100755 index 4ce8285b..00000000 --- a/ci/scripts/promote.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -set -e - -CONFIG_DIR=git-repo/ci/config - -version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' ) - -export BUILD_INFO_LOCATION=$(pwd)/artifactory-repo/build-info.json - -java -jar /concourse-release-scripts.jar \ - --spring.config.location=${CONFIG_DIR}/release-scripts.yml \ - publishToCentral $RELEASE_TYPE $BUILD_INFO_LOCATION artifactory-repo || { exit 1; } - -java -jar /concourse-release-scripts.jar \ - --spring.config.location=${CONFIG_DIR}/release-scripts.yml \ - promote $RELEASE_TYPE $BUILD_INFO_LOCATION || { exit 1; } - -echo "Promotion complete" diff --git a/ci/scripts/stage.sh b/ci/scripts/stage.sh deleted file mode 100755 index 5b36e8b4..00000000 --- a/ci/scripts/stage.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -set -e - -source $(dirname $0)/common.sh -repository=$(pwd)/distribution-repository - -pushd git-repo > /dev/null -git fetch --tags --all > /dev/null -popd > /dev/null - -git clone git-repo stage-git-repo > /dev/null - -pushd stage-git-repo > /dev/null - -snapshotVersion=$( xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' pom.xml ) -if [[ $RELEASE_TYPE = "M" ]]; then - stageVersion=$( get_next_milestone_release $snapshotVersion) - nextVersion=$snapshotVersion -elif [[ $RELEASE_TYPE = "RC" ]]; then - stageVersion=$( get_next_rc_release $snapshotVersion) - nextVersion=$snapshotVersion -elif [[ $RELEASE_TYPE = "RELEASE" ]]; then - stageVersion=$( get_next_release $snapshotVersion) - nextVersion=$( bump_version_number $snapshotVersion) -else - echo "Unknown release type $RELEASE_TYPE" >&2; exit 1; -fi - -echo "Staging ${stageVersion} (next version will be ${nextVersion})" -run_maven versions:set -DnewVersion=${stageVersion} -DgenerateBackupPoms=false -run_maven org.eclipse.tycho:tycho-versions-plugin:update-eclipse-metadata -run_maven --projects io.spring.javaformat:spring-javaformat-vscode-extension -P '!formatter-dependencies' antrun:run@update-version frontend:install-node-and-npm frontend:npm@update-package-lock - -git config user.name "Spring Builds" > /dev/null -git config user.email "spring-builds@users.noreply.github.com" > /dev/null -git add pom.xml > /dev/null -git commit -m"Release v${stageVersion}" > /dev/null -git tag -a "v${stageVersion}" -m"Release v${stageVersion}" > /dev/null - -run_maven clean deploy -U -Dfull -DaltDeploymentRepository=distribution::default::file://${repository} - -git reset --hard HEAD^ > /dev/null -if [[ $nextVersion != $snapshotVersion ]]; then - echo "Setting next development version (v$nextVersion)" - run_maven versions:set -DnewVersion=$nextVersion -DgenerateBackupPoms=false - run_maven org.eclipse.tycho:tycho-versions-plugin:update-eclipse-metadata - run_maven --projects io.spring.javaformat:spring-javaformat-vscode-extension -P '!formatter-dependencies' antrun:run@update-version frontend:npm@update-package-lock - sed -i "s/:release-version:.*/:release-version: ${stageVersion}/g" README.adoc - sed -i "s/spring-javaformat-gradle-plugin:.*/spring-javaformat-gradle-plugin:${nextVersion}\"\)/g" samples/spring-javaformat-gradle-sample/build.gradle - sed -i "s/spring-javaformat-checkstyle:.*/spring-javaformat-checkstyle:${nextVersion}\"\)/g" samples/spring-javaformat-gradle-sample/build.gradle - sed -i "s|.*|${nextVersion}|" samples/spring-javaformat-maven-sample/pom.xml - git add -u . > /dev/null - git commit -m"Next development version (v${nextVersion})" > /dev/null -fi; - -popd > /dev/null - -echo "Staging Complete" diff --git a/ci/scripts/sync-to-maven-central.sh b/ci/scripts/sync-to-maven-central.sh deleted file mode 100755 index f691b9f9..00000000 --- a/ci/scripts/sync-to-maven-central.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -export BUILD_INFO_LOCATION=$(pwd)/artifactory-repo/build-info.json -version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' ) -java -jar /opt/concourse-release-scripts.jar syncToCentral "RELEASE" $BUILD_INFO_LOCATION || { exit 1; } - -echo "Sync complete" diff --git a/ci/tasks/build-ci-image.yml b/ci/tasks/build-ci-image.yml deleted file mode 100644 index 6f4de778..00000000 --- a/ci/tasks/build-ci-image.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -platform: linux -image_resource: - type: registry-image - source: - repository: concourse/oci-build-task - tag: 0.10.0 - username: ((docker-hub-username)) - password: ((docker-hub-password)) -inputs: -- name: ci-images-git-repo -outputs: -- name: image -caches: -- path: ci-image-cache -params: - CONTEXT: ci-images-git-repo/ci/images - DOCKERFILE: ci-images-git-repo/ci/images/ci-image/Dockerfile -run: - path: /bin/sh - args: - - "-c" - - | - mkdir -p /root/.docker - cat > /root/.docker/config.json <4.0.0 io.spring.javaformat spring-javaformat-build - 0.0.42-SNAPSHOT + 0.0.43 pom Spring JavaFormat Build Spring JavaFormat diff --git a/samples/spring-javaformat-gradle-sample/build.gradle b/samples/spring-javaformat-gradle-sample/build.gradle index 58e98809..b3bc0f41 100644 --- a/samples/spring-javaformat-gradle-sample/build.gradle +++ b/samples/spring-javaformat-gradle-sample/build.gradle @@ -4,7 +4,7 @@ buildscript { mavenCentral() } dependencies { - classpath("io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.42-SNAPSHOT") + classpath("io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.43-SNAPSHOT") } } @@ -25,5 +25,5 @@ checkstyle { } dependencies { - checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:0.0.42-SNAPSHOT") + checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:0.0.43-SNAPSHOT") } diff --git a/samples/spring-javaformat-maven-sample/pom.xml b/samples/spring-javaformat-maven-sample/pom.xml index 3fa9bfe5..cec0c38e 100644 --- a/samples/spring-javaformat-maven-sample/pom.xml +++ b/samples/spring-javaformat-maven-sample/pom.xml @@ -8,7 +8,7 @@ 0.0.1-SNAPSHOT UTF-8 - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT diff --git a/spring-javaformat-eclipse/io.spring.javaformat.eclipse.feature/feature.xml b/spring-javaformat-eclipse/io.spring.javaformat.eclipse.feature/feature.xml index 1eabec83..b50eb61c 100755 --- a/spring-javaformat-eclipse/io.spring.javaformat.eclipse.feature/feature.xml +++ b/spring-javaformat-eclipse/io.spring.javaformat.eclipse.feature/feature.xml @@ -2,7 +2,7 @@ @@ -22,7 +22,7 @@ id="io.spring.javaformat.eclipse" download-size="0" install-size="0" - version="0.0.42.qualifier" + version="0.0.43.qualifier" unpack="false"/> diff --git a/spring-javaformat-eclipse/io.spring.javaformat.eclipse.feature/pom.xml b/spring-javaformat-eclipse/io.spring.javaformat.eclipse.feature/pom.xml index 84a96e0f..f0447048 100755 --- a/spring-javaformat-eclipse/io.spring.javaformat.eclipse.feature/pom.xml +++ b/spring-javaformat-eclipse/io.spring.javaformat.eclipse.feature/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat-eclipse - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT io.spring.javaformat.eclipse.feature eclipse-feature diff --git a/spring-javaformat-eclipse/io.spring.javaformat.eclipse.site/category.xml b/spring-javaformat-eclipse/io.spring.javaformat.eclipse.site/category.xml index 8a7fb79c..3bb9eaf8 100644 --- a/spring-javaformat-eclipse/io.spring.javaformat.eclipse.site/category.xml +++ b/spring-javaformat-eclipse/io.spring.javaformat.eclipse.site/category.xml @@ -3,7 +3,7 @@ Maven Integration for Eclipse (maven-eclipse-plugin support) - + diff --git a/spring-javaformat-eclipse/io.spring.javaformat.eclipse.site/io.spring.javaformat.eclipse.product b/spring-javaformat-eclipse/io.spring.javaformat.eclipse.site/io.spring.javaformat.eclipse.product index eefcd0ae..511b7d62 100644 --- a/spring-javaformat-eclipse/io.spring.javaformat.eclipse.site/io.spring.javaformat.eclipse.product +++ b/spring-javaformat-eclipse/io.spring.javaformat.eclipse.site/io.spring.javaformat.eclipse.product @@ -1,7 +1,7 @@ - + diff --git a/spring-javaformat-eclipse/io.spring.javaformat.eclipse.site/pom.xml b/spring-javaformat-eclipse/io.spring.javaformat.eclipse.site/pom.xml index 9cf30470..806bab83 100755 --- a/spring-javaformat-eclipse/io.spring.javaformat.eclipse.site/pom.xml +++ b/spring-javaformat-eclipse/io.spring.javaformat.eclipse.site/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat-eclipse - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT io.spring.javaformat.eclipse.site eclipse-repository diff --git a/spring-javaformat-eclipse/io.spring.javaformat.eclipse.tests/META-INF/MANIFEST.MF b/spring-javaformat-eclipse/io.spring.javaformat.eclipse.tests/META-INF/MANIFEST.MF index 6c3c7374..eed2c0de 100755 --- a/spring-javaformat-eclipse/io.spring.javaformat.eclipse.tests/META-INF/MANIFEST.MF +++ b/spring-javaformat-eclipse/io.spring.javaformat.eclipse.tests/META-INF/MANIFEST.MF @@ -7,7 +7,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: Spring Java Format Plugin Tests Bundle-SymbolicName: io.spring.javaformat.eclipse.tests Automatic-Module-Name: io.spring.javaformat.eclipse.tests -Bundle-Version: 0.0.42.qualifier +Bundle-Version: 0.0.43.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-ClassPath: ., lib/assertj-core.jar, diff --git a/spring-javaformat-eclipse/io.spring.javaformat.eclipse.tests/pom.xml b/spring-javaformat-eclipse/io.spring.javaformat.eclipse.tests/pom.xml index 7452fede..29003f38 100644 --- a/spring-javaformat-eclipse/io.spring.javaformat.eclipse.tests/pom.xml +++ b/spring-javaformat-eclipse/io.spring.javaformat.eclipse.tests/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat-eclipse - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT io.spring.javaformat.eclipse.tests eclipse-test-plugin diff --git a/spring-javaformat-eclipse/io.spring.javaformat.eclipse/META-INF/MANIFEST.MF b/spring-javaformat-eclipse/io.spring.javaformat.eclipse/META-INF/MANIFEST.MF index b7e8245f..5bbf628e 100644 --- a/spring-javaformat-eclipse/io.spring.javaformat.eclipse/META-INF/MANIFEST.MF +++ b/spring-javaformat-eclipse/io.spring.javaformat.eclipse/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: Spring Java Format Plugin Bundle-SymbolicName: io.spring.javaformat.eclipse;singleton:=true Automatic-Module-Name: io.spring.javaformat.eclipse -Bundle-Version: 0.0.42.qualifier +Bundle-Version: 0.0.43.qualifier Bundle-Activator: io.spring.javaformat.eclipse.Activator Bundle-RequiredExecutionEnvironment: JavaSE-11 Require-Bundle: org.eclipse.ui, diff --git a/spring-javaformat-eclipse/io.spring.javaformat.eclipse/pom.xml b/spring-javaformat-eclipse/io.spring.javaformat.eclipse/pom.xml index d309137a..81e1a81b 100644 --- a/spring-javaformat-eclipse/io.spring.javaformat.eclipse/pom.xml +++ b/spring-javaformat-eclipse/io.spring.javaformat.eclipse/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat-eclipse - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT io.spring.javaformat.eclipse eclipse-plugin diff --git a/spring-javaformat-eclipse/io.spring.javaformat.eclipse/src/io/spring/javaformat/eclipse/projectsettings/org.eclipse.jdt.core.prefs b/spring-javaformat-eclipse/io.spring.javaformat.eclipse/src/io/spring/javaformat/eclipse/projectsettings/org.eclipse.jdt.core.prefs index 41401b15..c08217ef 100644 --- a/spring-javaformat-eclipse/io.spring.javaformat.eclipse/src/io/spring/javaformat/eclipse/projectsettings/org.eclipse.jdt.core.prefs +++ b/spring-javaformat-eclipse/io.spring.javaformat.eclipse/src/io/spring/javaformat/eclipse/projectsettings/org.eclipse.jdt.core.prefs @@ -45,7 +45,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=default org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled @@ -82,7 +82,7 @@ org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=info org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore @@ -99,7 +99,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference= org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=info org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on diff --git a/spring-javaformat-eclipse/pom.xml b/spring-javaformat-eclipse/pom.xml index fad27c8b..c1f85ed9 100644 --- a/spring-javaformat-eclipse/pom.xml +++ b/spring-javaformat-eclipse/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat-build - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-eclipse pom diff --git a/spring-javaformat-gradle/io.spring.javaformat.gradle.plugin/pom.xml b/spring-javaformat-gradle/io.spring.javaformat.gradle.plugin/pom.xml index eeef2201..650c586f 100644 --- a/spring-javaformat-gradle/io.spring.javaformat.gradle.plugin/pom.xml +++ b/spring-javaformat-gradle/io.spring.javaformat.gradle.plugin/pom.xml @@ -5,7 +5,7 @@ io.spring.javaformat spring-javaformat-gradle - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT io.spring.javaformat io.spring.javaformat.gradle.plugin diff --git a/spring-javaformat-gradle/pom.xml b/spring-javaformat-gradle/pom.xml index f5fa9333..e0da30d0 100644 --- a/spring-javaformat-gradle/pom.xml +++ b/spring-javaformat-gradle/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat-build - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-gradle pom diff --git a/spring-javaformat-gradle/spring-javaformat-gradle-plugin/pom.xml b/spring-javaformat-gradle/spring-javaformat-gradle-plugin/pom.xml index 2f5858a2..c96c929e 100644 --- a/spring-javaformat-gradle/spring-javaformat-gradle-plugin/pom.xml +++ b/spring-javaformat-gradle/spring-javaformat-gradle-plugin/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat-gradle - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-gradle-plugin pom diff --git a/spring-javaformat-intellij-idea/pom.xml b/spring-javaformat-intellij-idea/pom.xml index 5d3c5117..3605f2a0 100644 --- a/spring-javaformat-intellij-idea/pom.xml +++ b/spring-javaformat-intellij-idea/pom.xml @@ -5,7 +5,7 @@ io.spring.javaformat spring-javaformat-build - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-intellij-idea pom diff --git a/spring-javaformat-intellij-idea/spring-javaformat-intellij-idea-plugin/pom.xml b/spring-javaformat-intellij-idea/spring-javaformat-intellij-idea-plugin/pom.xml index bc99603f..46ee2658 100644 --- a/spring-javaformat-intellij-idea/spring-javaformat-intellij-idea-plugin/pom.xml +++ b/spring-javaformat-intellij-idea/spring-javaformat-intellij-idea-plugin/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat-intellij-idea - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-intellij-idea-plugin Spring JavaFormat IntelliJ IDEA Plugin diff --git a/spring-javaformat-intellij-idea/spring-javaformat-intellij-idea-runtime/pom.xml b/spring-javaformat-intellij-idea/spring-javaformat-intellij-idea-runtime/pom.xml index 66560bca..8575c456 100644 --- a/spring-javaformat-intellij-idea/spring-javaformat-intellij-idea-runtime/pom.xml +++ b/spring-javaformat-intellij-idea/spring-javaformat-intellij-idea-runtime/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat-intellij-idea - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-intellij-idea-runtime pom diff --git a/spring-javaformat-maven/pom.xml b/spring-javaformat-maven/pom.xml index 6af1736a..299baf24 100644 --- a/spring-javaformat-maven/pom.xml +++ b/spring-javaformat-maven/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat-build - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-maven pom diff --git a/spring-javaformat-maven/spring-javaformat-maven-plugin/pom.xml b/spring-javaformat-maven/spring-javaformat-maven-plugin/pom.xml index d5c84fe5..3e2efc32 100644 --- a/spring-javaformat-maven/spring-javaformat-maven-plugin/pom.xml +++ b/spring-javaformat-maven/spring-javaformat-maven-plugin/pom.xml @@ -5,7 +5,7 @@ io.spring.javaformat spring-javaformat-maven - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-maven-plugin maven-plugin diff --git a/spring-javaformat-vscode/pom.xml b/spring-javaformat-vscode/pom.xml index a2c5c8ce..703c3a3c 100644 --- a/spring-javaformat-vscode/pom.xml +++ b/spring-javaformat-vscode/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat-build - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-vscode pom diff --git a/spring-javaformat-vscode/spring-javaformat-vscode-extension/package-lock.json b/spring-javaformat-vscode/spring-javaformat-vscode-extension/package-lock.json index 5a0626dc..cf72087a 100644 --- a/spring-javaformat-vscode/spring-javaformat-vscode-extension/package-lock.json +++ b/spring-javaformat-vscode/spring-javaformat-vscode-extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "spring-javaformat-vscode-extension", - "version": "0.0.42-SNAPSHOT", + "version": "0.0.43-SNAPSHOT", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "spring-javaformat-vscode-extension", - "version": "0.0.42-SNAPSHOT", + "version": "0.0.43-SNAPSHOT", "devDependencies": { "@types/glob": "^8.0.1", "@types/mocha": "^10.0.1", @@ -14,7 +14,7 @@ "@types/vscode": "^1.75.0", "@typescript-eslint/eslint-plugin": "^5.52.0", "@vscode/test-electron": "^2.2.2", - "@vscode/vsce": "^2.17.0", + "@vscode/vsce": "^2.19.0", "eslint": "^8.33.0", "glob": "8.1.0", "mocha": "10.2.0", @@ -376,9 +376,9 @@ } }, "node_modules/@vscode/vsce": { - "version": "2.17.0", - "resolved": "https://registry.npmjs.org/@vscode/vsce/-/vsce-2.17.0.tgz", - "integrity": "sha512-W4HN5MtTVj/mroQU1d82bUEeWM3dUykMFnMYZPtZ6jrMiHN1PUoN3RGcS896N0r2rIq8KpWDtufcQHgK8VfgpA==", + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/@vscode/vsce/-/vsce-2.19.0.tgz", + "integrity": "sha512-dAlILxC5ggOutcvJY24jxz913wimGiUrHaPkk16Gm9/PGFbz1YezWtrXsTKUtJws4fIlpX2UIlVlVESWq8lkfQ==", "dev": true, "dependencies": { "azure-devops-node-api": "^11.0.1", @@ -387,6 +387,7 @@ "commander": "^6.1.0", "glob": "^7.0.6", "hosted-git-info": "^4.0.2", + "jsonc-parser": "^3.2.0", "leven": "^3.1.0", "markdown-it": "^12.3.2", "mime": "^1.3.4", @@ -397,7 +398,7 @@ "tmp": "^0.2.1", "typed-rest-client": "^1.8.4", "url-join": "^4.0.1", - "xml2js": "^0.4.23", + "xml2js": "^0.5.0", "yauzl": "^2.3.1", "yazl": "^2.2.2" }, @@ -2138,6 +2139,12 @@ "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, + "node_modules/jsonc-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", + "dev": true + }, "node_modules/keytar": { "version": "7.9.0", "resolved": "https://registry.npmjs.org/keytar/-/keytar-7.9.0.tgz", @@ -3636,9 +3643,9 @@ "dev": true }, "node_modules/xml2js": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", - "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.5.0.tgz", + "integrity": "sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==", "dev": true, "dependencies": { "sax": ">=0.6.0", diff --git a/spring-javaformat-vscode/spring-javaformat-vscode-extension/package.json b/spring-javaformat-vscode/spring-javaformat-vscode-extension/package.json index 639c5b16..86a6b65b 100644 --- a/spring-javaformat-vscode/spring-javaformat-vscode-extension/package.json +++ b/spring-javaformat-vscode/spring-javaformat-vscode-extension/package.json @@ -2,7 +2,7 @@ "name": "spring-javaformat-vscode-extension", "description": "Spring JavaFormat Visual Studio Code Extension", "displayName": "Spring JavaFormat", - "version": "0.0.42-SNAPSHOT", + "version": "0.0.43-SNAPSHOT", "publisher": "io.spring.javaformat", "engines": { "vscode": "^1.75.0" @@ -33,7 +33,7 @@ "@types/vscode": "^1.75.0", "@typescript-eslint/eslint-plugin": "^5.52.0", "@vscode/test-electron": "^2.2.2", - "@vscode/vsce": "^2.17.0", + "@vscode/vsce": "^2.19.0", "eslint": "^8.33.0", "glob": "8.1.0", "mocha": "10.2.0", diff --git a/spring-javaformat-vscode/spring-javaformat-vscode-extension/pom.xml b/spring-javaformat-vscode/spring-javaformat-vscode-extension/pom.xml index f2162ee6..cdac8ac0 100644 --- a/spring-javaformat-vscode/spring-javaformat-vscode-extension/pom.xml +++ b/spring-javaformat-vscode/spring-javaformat-vscode-extension/pom.xml @@ -5,7 +5,7 @@ io.spring.javaformat spring-javaformat-vscode - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-vscode-extension Spring JavaFormat Visual Studio Code Extension diff --git a/spring-javaformat/pom.xml b/spring-javaformat/pom.xml index 697cc5d5..fc14a0f0 100644 --- a/spring-javaformat/pom.xml +++ b/spring-javaformat/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat-build - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat pom diff --git a/spring-javaformat/spring-javaformat-checkstyle/pom.xml b/spring-javaformat/spring-javaformat-checkstyle/pom.xml index 64eb5db8..98a45e42 100644 --- a/spring-javaformat/spring-javaformat-checkstyle/pom.xml +++ b/spring-javaformat/spring-javaformat-checkstyle/pom.xml @@ -5,7 +5,7 @@ io.spring.javaformat spring-javaformat - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-checkstyle Spring JavaFormat CheckStyle diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringJUnit5Check.java b/spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringJUnit5Check.java index db7cbbfd..cdd8efc4 100644 --- a/spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringJUnit5Check.java +++ b/spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringJUnit5Check.java @@ -63,6 +63,8 @@ public class SpringJUnit5Check extends AbstractSpringCheck { LIFECYCLE_ANNOTATIONS = Collections.unmodifiableList(new ArrayList<>(annotations)); } + private static final Annotation NESTED_ANNOTATION = new Annotation("org.junit.jupiter.api", "Nested"); + private static final Set BANNED_IMPORTS; static { Set bannedImports = new LinkedHashSet<>(); @@ -84,16 +86,22 @@ public class SpringJUnit5Check extends AbstractSpringCheck { private final List lifecycleMethods = new ArrayList<>(); + private final List nestedTestClasses = new ArrayList<>(); + + private DetailAST testClass; + @Override public int[] getAcceptableTokens() { - return new int[] { TokenTypes.METHOD_DEF, TokenTypes.IMPORT }; + return new int[] { TokenTypes.METHOD_DEF, TokenTypes.IMPORT, TokenTypes.CLASS_DEF }; } @Override public void beginTree(DetailAST rootAST) { + this.testClass = null; this.imports.clear(); this.testMethods.clear(); this.lifecycleMethods.clear(); + this.nestedTestClasses.clear(); } @Override @@ -101,9 +109,13 @@ public void visitToken(DetailAST ast) { switch (ast.getType()) { case TokenTypes.METHOD_DEF: visitMethodDef(ast); + break; case TokenTypes.IMPORT: visitImport(ast); break; + case TokenTypes.CLASS_DEF: + visitClassDefinition(ast); + break; } } @@ -117,8 +129,9 @@ private void visitMethodDef(DetailAST ast) { } private boolean containsAnnotation(DetailAST ast, List annotations) { - List annotationNames = annotations.stream().flatMap((annotation) -> - Stream.of(annotation.simpleName, annotation.fullyQualifiedName())).collect(Collectors.toList()); + List annotationNames = annotations.stream() + .flatMap((annotation) -> Stream.of(annotation.simpleName, annotation.fullyQualifiedName())) + .collect(Collectors.toList()); try { return AnnotationUtil.containsAnnotation(ast, annotationNames); } @@ -126,8 +139,8 @@ private boolean containsAnnotation(DetailAST ast, List annotations) // Checkstyle >= 10.3 (https://github.com/checkstyle/checkstyle/issues/14134) Set annotationNamesSet = new HashSet<>(annotationNames); try { - return (boolean) AnnotationUtil.class.getMethod("containsAnnotation", DetailAST.class, Set.class) - .invoke(null, ast, annotationNamesSet); + return (boolean) AnnotationUtil.class.getMethod("containsAnnotation", DetailAST.class, Set.class) + .invoke(null, ast, annotationNamesSet); } catch (Exception ex2) { throw new RuntimeException("containsAnnotation failed", ex2); @@ -140,6 +153,17 @@ private void visitImport(DetailAST ast) { this.imports.put(ident.getText(), ident); } + private void visitClassDefinition(DetailAST ast) { + if (ast.getParent().getType() == TokenTypes.COMPILATION_UNIT) { + this.testClass = ast; + } + else { + if (containsAnnotation(ast, Arrays.asList(NESTED_ANNOTATION))) { + this.nestedTestClasses.add(ast); + } + } + } + @Override public void finishTree(DetailAST rootAST) { if (shouldCheck()) { @@ -148,7 +172,7 @@ public void finishTree(DetailAST rootAST) { } private boolean shouldCheck() { - if (this.testMethods.isEmpty() && this.lifecycleMethods.isEmpty()) { + if (this.testMethods.isEmpty() && this.lifecycleMethods.isEmpty() && this.nestedTestClasses.isEmpty()) { return false; } for (String unlessImport : this.unlessImports) { @@ -160,6 +184,10 @@ private boolean shouldCheck() { } private void check() { + if (this.testClass != null && !isAbstract(this.testClass)) { + checkVisibility(Arrays.asList(this.testClass), "junit5.publicClass", null); + } + checkVisibility(this.nestedTestClasses, "junit5.publicNestedClass", "junit5.privateNestedClass"); for (String bannedImport : BANNED_IMPORTS) { FullIdent ident = this.imports.get(bannedImport); if (ident != null) { @@ -171,25 +199,30 @@ private void check() { log(testMethod, "junit5.bannedTestAnnotation"); } } - checkMethodVisibility(this.testMethods, "junit5.testPublicMethod", "junit5.testPrivateMethod"); - checkMethodVisibility(this.lifecycleMethods, "junit5.lifecyclePublicMethod", "junit5.lifecyclePrivateMethod"); + checkVisibility(this.testMethods, "junit5.testPublicMethod", "junit5.testPrivateMethod"); + checkVisibility(this.lifecycleMethods, "junit5.lifecyclePublicMethod", "junit5.lifecyclePrivateMethod"); + } + + private boolean isAbstract(DetailAST ast) { + DetailAST modifiers = ast.findFirstToken(TokenTypes.MODIFIERS); + return modifiers.findFirstToken(TokenTypes.ABSTRACT) != null; } - private void checkMethodVisibility(List methods, String publicMessageKey, String privateMessageKey) { - for (DetailAST method : methods) { - DetailAST modifiers = method.findFirstToken(TokenTypes.MODIFIERS); + private void checkVisibility(List asts, String publicMessageKey, String privateMessageKey) { + for (DetailAST ast : asts) { + DetailAST modifiers = ast.findFirstToken(TokenTypes.MODIFIERS); if (modifiers.findFirstToken(TokenTypes.LITERAL_PUBLIC) != null) { - log(method, publicMessageKey); + log(ast, publicMessageKey); } - if (modifiers.findFirstToken(TokenTypes.LITERAL_PRIVATE) != null) { - log(method, privateMessageKey); + if ((privateMessageKey != null) && (modifiers.findFirstToken(TokenTypes.LITERAL_PRIVATE) != null)) { + log(ast, privateMessageKey); } } } - private void log(DetailAST method, String key) { - String name = method.findFirstToken(TokenTypes.IDENT).getText(); - log(method.getLineNo(), method.getColumnNo(), key, name); + private void log(DetailAST ast, String key) { + String name = ast.findFirstToken(TokenTypes.IDENT).getText(); + log(ast.getLineNo(), ast.getColumnNo(), key, name); } public void setUnlessImports(String unlessImports) { diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringLeadingWhitespaceCheck.java b/spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringLeadingWhitespaceCheck.java index 188e6781..8e3fa83f 100644 --- a/spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringLeadingWhitespaceCheck.java +++ b/spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringLeadingWhitespaceCheck.java @@ -17,7 +17,9 @@ package io.spring.javaformat.checkstyle.check; import java.io.File; +import java.util.ArrayDeque; import java.util.Collections; +import java.util.Deque; import java.util.HashMap; import java.util.Map; import java.util.regex.Matcher; @@ -26,6 +28,7 @@ import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.FileContents; import com.puppycrawl.tools.checkstyle.api.FileText; +import com.puppycrawl.tools.checkstyle.api.TokenTypes; import io.spring.javaformat.config.IndentationStyle; import io.spring.javaformat.config.JavaFormatConfig; @@ -49,14 +52,32 @@ public class SpringLeadingWhitespaceCheck extends AbstractSpringCheck { private IndentationStyle indentationStyle; + private final Deque textBlockPairs = new ArrayDeque<>(); + @Override public int[] getAcceptableTokens() { - return NO_REQUIRED_TOKENS; + return new int[] { TokenTypes.TEXT_BLOCK_LITERAL_BEGIN, TokenTypes.TEXT_BLOCK_LITERAL_END }; + } + + @Override + public void visitToken(DetailAST ast) { + super.visitToken(ast); + if (ast.getType() == TokenTypes.TEXT_BLOCK_LITERAL_BEGIN) { + this.textBlockPairs.add(new TextBlockPair(ast)); + } + else if (ast.getType() == TokenTypes.TEXT_BLOCK_LITERAL_END) { + this.textBlockPairs.getLast().end(ast); + } } @Override public void beginTree(DetailAST rootAST) { super.beginTree(rootAST); + this.textBlockPairs.clear(); + } + + @Override + public void finishTree(DetailAST rootAST) { FileContents fileContents = getFileContents(); FileText fileText = fileContents.getText(); File file = fileText.getFile(); @@ -66,8 +87,11 @@ public void beginTree(DetailAST rootAST) { IndentationStyle indentationStyle = (this.indentationStyle != null) ? this.indentationStyle : JavaFormatConfig.findFrom(file.getParentFile()).getIndentationStyle(); for (int i = 0; i < fileText.size(); i++) { - String line = fileText.get(i); int lineNo = i + 1; + if (isInTextBlock(lineNo)) { + continue; + } + String line = fileText.get(i); Matcher matcher = PATTERN.matcher(line); boolean found = matcher.find(0); while (found @@ -78,6 +102,11 @@ public void beginTree(DetailAST rootAST) { log(lineNo, "leadingwhitespace.incorrect", indentationStyle.toString().toLowerCase()); } } + super.finishTree(rootAST); + } + + private boolean isInTextBlock(int lineNo) { + return this.textBlockPairs.stream().anyMatch((textBlockPair) -> textBlockPair.contains(lineNo)); } public void setIndentationStyle(String indentationStyle) { @@ -85,4 +114,24 @@ public void setIndentationStyle(String indentationStyle) { ? IndentationStyle.valueOf(indentationStyle.toUpperCase()) : null; } + private static class TextBlockPair { + + private final DetailAST begin; + + private DetailAST end; + + TextBlockPair(DetailAST begin) { + this.begin = begin; + } + + public boolean contains(int lineNo) { + return (lineNo > this.begin.getLineNo()) && (lineNo <= this.end.getLineNo()); + } + + void end(DetailAST end) { + this.end = end; + } + + } + } diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringTestFileNameCheck.java b/spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringTestFileNameCheck.java index eeda7a05..01708750 100644 --- a/spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringTestFileNameCheck.java +++ b/spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringTestFileNameCheck.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2023 the original author or authors. + * Copyright 2017-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,14 +18,20 @@ import java.io.File; +import com.puppycrawl.tools.checkstyle.JavaParser; +import com.puppycrawl.tools.checkstyle.JavaParser.Options; import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; +import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.FileText; +import com.puppycrawl.tools.checkstyle.api.TokenTypes; /** - * Checks that test filenames end {@literal Tests.java} and not {@literal Test.java}. + * Checks that test class filenames end {@literal Tests.java} and not + * {@literal Test.java}. * * @author Phillip Webb + * @author Andy Wilkinson */ public class SpringTestFileNameCheck extends AbstractFileSetCheck { @@ -33,7 +39,18 @@ public class SpringTestFileNameCheck extends AbstractFileSetCheck { protected void processFiltered(File file, FileText fileText) throws CheckstyleException { String path = file.getPath().replace('\\', '/'); if (path.contains("src/test/java") && file.getName().endsWith("Test.java")) { - log(1, "testfilename.wrongName"); + visitCompilationUnit(JavaParser.parseFileText(fileText, Options.WITHOUT_COMMENTS)); + } + } + + private void visitCompilationUnit(DetailAST ast) { + DetailAST child = ast.getFirstChild(); + while (child != null) { + if (child.getType() == TokenTypes.CLASS_DEF) { + log(1, "testfilename.wrongName"); + return; + } + child = child.getNextSibling(); } } diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/main/resources/io/spring/javaformat/checkstyle/check/messages.properties b/spring-javaformat/spring-javaformat-checkstyle/src/main/resources/io/spring/javaformat/checkstyle/check/messages.properties index 9982830e..a27f9263 100644 --- a/spring-javaformat/spring-javaformat-checkstyle/src/main/resources/io/spring/javaformat/checkstyle/check/messages.properties +++ b/spring-javaformat/spring-javaformat-checkstyle/src/main/resources/io/spring/javaformat/checkstyle/check/messages.properties @@ -16,6 +16,9 @@ junit5.bannedImport=Import ''{0}'' should not be used in a JUnit 5 test. junit5.bannedTestAnnotation=JUnit 4 @Test annotation should not be used in a JUnit 5 test. junit5.lifecyclePrivateMethod=Lifecycle method ''{0}'' should not be private. junit5.lifecyclePublicMethod=Lifecycle method ''{0}'' should not be public. +junit5.publicClass=Test class ''{0}'' should not be public. +junit5.publicNestedClass=Nested test class ''{0}'' should not be public. +junit5.privateNestedClass=Nested test class ''{0}'' should not be private. junit5.testPrivateMethod=Test method ''{0}'' should not be private. junit5.testPublicMethod=Test method ''{0}'' should not be public. lambda.missingParen=Lambda argument missing parentheses. diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/main/resources/io/spring/javaformat/checkstyle/spring-checkstyle.xml b/spring-javaformat/spring-javaformat-checkstyle/src/main/resources/io/spring/javaformat/checkstyle/spring-checkstyle.xml index ba9026a6..a41c37bf 100644 --- a/spring-javaformat/spring-javaformat-checkstyle/src/main/resources/io/spring/javaformat/checkstyle/spring-checkstyle.xml +++ b/spring-javaformat/spring-javaformat-checkstyle/src/main/resources/io/spring/javaformat/checkstyle/spring-checkstyle.xml @@ -22,6 +22,7 @@ + paramaters() throws IOException { .map(Parameter::new) .collect(Collectors.toCollection(ArrayList::new)); parameters.add(new Parameter(new File(SOURCES_DIR, "nopackageinfo/NoPackageInfo.java"))); - parameters.add(new Parameter(new File(SOURCES_DIR, "src/test/java/NamedTest.java"))); - parameters.add(new Parameter(new File(SOURCES_DIR, "src/test/java/NamedTests.java"))); + Arrays.stream(new File(SOURCES_DIR, "src/test/java").listFiles(SpringChecksTests::sourceFile)) + .sorted() + .map(Parameter::new) + .forEach(parameters::add); return parameters; } diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/java/io/spring/javaformat/checkstyle/SpringConfigurationLoaderTests.java b/spring-javaformat/spring-javaformat-checkstyle/src/test/java/io/spring/javaformat/checkstyle/SpringConfigurationLoaderTests.java index c16585d5..33536e6b 100644 --- a/spring-javaformat/spring-javaformat-checkstyle/src/test/java/io/spring/javaformat/checkstyle/SpringConfigurationLoaderTests.java +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/java/io/spring/javaformat/checkstyle/SpringConfigurationLoaderTests.java @@ -16,8 +16,10 @@ package io.spring.javaformat.checkstyle; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.Properties; import java.util.Set; @@ -49,17 +51,22 @@ public void loadShouldLoadChecks() { TreeWalker treeWalker = (TreeWalker) checks.toArray()[4]; Set ordinaryChecks = (Set) Extractors.byName("ordinaryChecks").extract(treeWalker); assertThat(ordinaryChecks).hasSize(61); + Set commentChecks = (Set) Extractors.byName("commentChecks").extract(treeWalker); + assertThat(commentChecks).hasSize(6); } @Test public void loadWithExcludeShouldExcludeChecks() { - Set excludes = Collections - .singleton("com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck"); + Set excludes = new HashSet( + Arrays.asList("com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck", + "com.puppycrawl.tools.checkstyle.checks.annotation.MissingDeprecatedCheck")); Collection checks = load(excludes); assertThat(checks).hasSize(5); TreeWalker treeWalker = (TreeWalker) checks.toArray()[4]; Set ordinaryChecks = (Set) Extractors.byName("ordinaryChecks").extract(treeWalker); assertThat(ordinaryChecks).hasSize(60); + Set commentChecks = (Set) Extractors.byName("commentChecks").extract(treeWalker); + assertThat(commentChecks).hasSize(5); } @Test diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/JUnit5BadModifier.txt b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/JUnit5BadModifier.txt index 376aa13c..7ec1d4de 100644 --- a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/JUnit5BadModifier.txt +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/JUnit5BadModifier.txt @@ -1,7 +1,11 @@ ++Test class 'JUnit5BadModifier' should not be public ++Nested test class 'PublicNestedTests' should not be public ++Nested test class 'PrivateNestedTests' should not be private +Test method 'doSomethingWorks' should not be public +Test method 'doSomethingElseWorks' should not be private +Test method 'doSomethingWithTemplateWorks' should not be public +Test method 'doSomethingElseWithTemplateWorks' should not be private ++Test method 'nestedPublicTest' should not be public +Lifecycle method 'publicBeforeAll' should not be public +Lifecycle method 'publicBeforeEach' should not be public +Lifecycle method 'publicAfterAll' should not be public diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/JUnit5PublicAbstractIsValid.txt b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/JUnit5PublicAbstractIsValid.txt new file mode 100644 index 00000000..69174e4c --- /dev/null +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/JUnit5PublicAbstractIsValid.txt @@ -0,0 +1 @@ ++0 errors \ No newline at end of file diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/LeadingWhitespaceTabsAndTextBlock.txt b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/LeadingWhitespaceTabsAndTextBlock.txt new file mode 100644 index 00000000..23435c7a --- /dev/null +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/LeadingWhitespaceTabsAndTextBlock.txt @@ -0,0 +1 @@ ++0 errors diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/src/test/java/AnnotationEndingInTest.txt b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/src/test/java/AnnotationEndingInTest.txt new file mode 100644 index 00000000..69174e4c --- /dev/null +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/src/test/java/AnnotationEndingInTest.txt @@ -0,0 +1 @@ ++0 errors \ No newline at end of file diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/src/test/java/InterfaceEndingInTest.txt b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/src/test/java/InterfaceEndingInTest.txt new file mode 100644 index 00000000..69174e4c --- /dev/null +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/check/src/test/java/InterfaceEndingInTest.txt @@ -0,0 +1 @@ ++0 errors \ No newline at end of file diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/JUnit5BadModifier.java b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/JUnit5BadModifier.java index e9b91697..9c59c587 100644 --- a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/JUnit5BadModifier.java +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/JUnit5BadModifier.java @@ -88,4 +88,19 @@ private void doSomethingElseWithTemplateWorks() { // test here } + @Nested + public static class PublicNestedTests { + + @Test + public void nestedPublicTest() { + + } + + } + + @Nested + private static class PrivateNestedTests { + + } + } diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/JUnit5PublicAbstractIsValid.java b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/JUnit5PublicAbstractIsValid.java new file mode 100644 index 00000000..d56bbbd6 --- /dev/null +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/JUnit5PublicAbstractIsValid.java @@ -0,0 +1,32 @@ +/* + * Copyright 2017-2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.junit.jupiter.api.Test; + +/** + * This is a valid example. We allow abstract test classes to be + * public so that classes in other packages can extend them. + * + * @author Andy Wilkinson + */ +public abstract class JUnit5PublicAbstractIsValid { + + @Test + void doSomethingWorks() { + // test here + } + +} diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/JUnit5Valid.java b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/JUnit5Valid.java index cc7b4cd0..bad7023d 100644 --- a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/JUnit5Valid.java +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/JUnit5Valid.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ * * @author Phillip Webb */ -public class JUnit5Valid { +class JUnit5Valid { @Test void doSomethingWorks() { diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/LeadingWhitespaceTabsAndTextBlock.java b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/LeadingWhitespaceTabsAndTextBlock.java new file mode 100644 index 00000000..e9e27b7b --- /dev/null +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/LeadingWhitespaceTabsAndTextBlock.java @@ -0,0 +1,33 @@ +/* + * Copyright 2017-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Leading whitepace with a text block. + * + * @author Phillip Webb + */ +public class LeadingWhitespaceTabsAndTextBlock { + + /** + * Comments are ignored. + */ + public void hello() { + System.out.println("""" + Hello + World!"""); + } + +} diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/src/test/java/AnnotationEndingInTest.java b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/src/test/java/AnnotationEndingInTest.java new file mode 100644 index 00000000..7579aac2 --- /dev/null +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/src/test/java/AnnotationEndingInTest.java @@ -0,0 +1,25 @@ +/* + * Copyright 2017-2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This is an annotation with a legal name. Only test classes must + * have a name that ends with {@code Tests}. + * + * @author Andy Wilkinson + */ +public @interface AnnotationEndingInTest { + +} diff --git a/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/src/test/java/InterfaceEndingInTest.java b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/src/test/java/InterfaceEndingInTest.java new file mode 100644 index 00000000..b2aad5f9 --- /dev/null +++ b/spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/src/test/java/InterfaceEndingInTest.java @@ -0,0 +1,25 @@ +/* + * Copyright 2017-2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This is an interface with a legal name. Only test classes must + * have a name that ends with {@code Tests}. + * + * @author Andy Wilkinson + */ +public interface InterfaceEndingInTest { + +} diff --git a/spring-javaformat/spring-javaformat-config/pom.xml b/spring-javaformat/spring-javaformat-config/pom.xml index bc6f0d6f..39d27d20 100644 --- a/spring-javaformat/spring-javaformat-config/pom.xml +++ b/spring-javaformat/spring-javaformat-config/pom.xml @@ -5,7 +5,7 @@ io.spring.javaformat spring-javaformat - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-config Spring JavaFormat Config diff --git a/spring-javaformat/spring-javaformat-formatter-eclipse-jdk17/META-INF/MANIFEST.MF b/spring-javaformat/spring-javaformat-formatter-eclipse-jdk17/META-INF/MANIFEST.MF index 68f6b967..e8f28aee 100644 --- a/spring-javaformat/spring-javaformat-formatter-eclipse-jdk17/META-INF/MANIFEST.MF +++ b/spring-javaformat/spring-javaformat-formatter-eclipse-jdk17/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Spring Formatter Eclipse Runtime JDK17 Bundle-SymbolicName: spring-javaformat-formatter-eclipse-jdk17 -Bundle-Version: 0.0.42.qualifier +Bundle-Version: 0.0.43.qualifier Require-Bundle: org.eclipse.jdt.core;bundle-version="[1.0.0,10.0.0)", org.eclipse.jface;bundle-version="[1.0.0,10.0.0)", org.eclipse.jdt.core.source;bundle-version="[1.0.0,10.0.0)";resolution:=optional, diff --git a/spring-javaformat/spring-javaformat-formatter-eclipse-jdk17/pom.xml b/spring-javaformat/spring-javaformat-formatter-eclipse-jdk17/pom.xml index 9608ea8a..cda64abf 100644 --- a/spring-javaformat/spring-javaformat-formatter-eclipse-jdk17/pom.xml +++ b/spring-javaformat/spring-javaformat-formatter-eclipse-jdk17/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-formatter-eclipse-jdk17 eclipse-plugin diff --git a/spring-javaformat/spring-javaformat-formatter-eclipse-jdk8/META-INF/MANIFEST.MF b/spring-javaformat/spring-javaformat-formatter-eclipse-jdk8/META-INF/MANIFEST.MF index 8577d79f..6ceab19d 100644 --- a/spring-javaformat/spring-javaformat-formatter-eclipse-jdk8/META-INF/MANIFEST.MF +++ b/spring-javaformat/spring-javaformat-formatter-eclipse-jdk8/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Spring Formatter Eclipse JDK8 Bundle-SymbolicName: spring-javaformat-formatter-eclipse-jdk8 -Bundle-Version: 0.0.42.qualifier +Bundle-Version: 0.0.43.qualifier Require-Bundle: org.eclipse.jdt.core;bundle-version="[1.0.0,10.0.0)", org.eclipse.jface;bundle-version="[1.0.0,10.0.0)", org.eclipse.jdt.core.source;bundle-version="[1.0.0,10.0.0)";resolution:=optional, diff --git a/spring-javaformat/spring-javaformat-formatter-eclipse-jdk8/pom.xml b/spring-javaformat/spring-javaformat-formatter-eclipse-jdk8/pom.xml index c14b90c0..0016a013 100644 --- a/spring-javaformat/spring-javaformat-formatter-eclipse-jdk8/pom.xml +++ b/spring-javaformat/spring-javaformat-formatter-eclipse-jdk8/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-formatter-eclipse-jdk8 eclipse-plugin diff --git a/spring-javaformat/spring-javaformat-formatter-eclipse-jdt-jdk17/pom.xml b/spring-javaformat/spring-javaformat-formatter-eclipse-jdt-jdk17/pom.xml index ba028fab..3f8b1057 100644 --- a/spring-javaformat/spring-javaformat-formatter-eclipse-jdt-jdk17/pom.xml +++ b/spring-javaformat/spring-javaformat-formatter-eclipse-jdt-jdk17/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-formatter-eclipse-jdt-jdk17 Spring JavaFormat Eclipse JDT JDK-17 diff --git a/spring-javaformat/spring-javaformat-formatter-eclipse-jdt-jdk8/pom.xml b/spring-javaformat/spring-javaformat-formatter-eclipse-jdt-jdk8/pom.xml index eb9e11fa..83f65fb9 100644 --- a/spring-javaformat/spring-javaformat-formatter-eclipse-jdt-jdk8/pom.xml +++ b/spring-javaformat/spring-javaformat-formatter-eclipse-jdt-jdk8/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-formatter-eclipse-jdt-jdk8 Spring JavaFormat Eclipse JDT JDK-8 diff --git a/spring-javaformat/spring-javaformat-formatter-eclipse-rewriter/pom.xml b/spring-javaformat/spring-javaformat-formatter-eclipse-rewriter/pom.xml index 6f6e7cbb..44a54dbd 100644 --- a/spring-javaformat/spring-javaformat-formatter-eclipse-rewriter/pom.xml +++ b/spring-javaformat/spring-javaformat-formatter-eclipse-rewriter/pom.xml @@ -5,7 +5,7 @@ io.spring.javaformat spring-javaformat - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-formatter-eclipse-rewriter Spring JavaFormat Eclipse Rewriter diff --git a/spring-javaformat/spring-javaformat-formatter-eclipse-runtime/pom.xml b/spring-javaformat/spring-javaformat-formatter-eclipse-runtime/pom.xml index fc24ebcf..12ae265c 100644 --- a/spring-javaformat/spring-javaformat-formatter-eclipse-runtime/pom.xml +++ b/spring-javaformat/spring-javaformat-formatter-eclipse-runtime/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-formatter-eclipse-runtime Spring JavaFormat Eclipse Runtime diff --git a/spring-javaformat/spring-javaformat-formatter-shaded/pom.xml b/spring-javaformat/spring-javaformat-formatter-shaded/pom.xml index 9b1ef323..72eb47c8 100644 --- a/spring-javaformat/spring-javaformat-formatter-shaded/pom.xml +++ b/spring-javaformat/spring-javaformat-formatter-shaded/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-formatter-shaded Spring JavaFormat Formatter Shaded diff --git a/spring-javaformat/spring-javaformat-formatter-shader/pom.xml b/spring-javaformat/spring-javaformat-formatter-shader/pom.xml index 76eadbc2..601f6dd7 100644 --- a/spring-javaformat/spring-javaformat-formatter-shader/pom.xml +++ b/spring-javaformat/spring-javaformat-formatter-shader/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-formatter-shader Spring JavaFormat Formatter Shader diff --git a/spring-javaformat/spring-javaformat-formatter-test-support/pom.xml b/spring-javaformat/spring-javaformat-formatter-test-support/pom.xml index 6b857a01..9f247485 100644 --- a/spring-javaformat/spring-javaformat-formatter-test-support/pom.xml +++ b/spring-javaformat/spring-javaformat-formatter-test-support/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-formatter-test-support Spring JavaFormat Formatter Test Support diff --git a/spring-javaformat/spring-javaformat-formatter-tests/pom.xml b/spring-javaformat/spring-javaformat-formatter-tests/pom.xml index 8439c6e9..bc439188 100644 --- a/spring-javaformat/spring-javaformat-formatter-tests/pom.xml +++ b/spring-javaformat/spring-javaformat-formatter-tests/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-formatter-tests Spring JavaFormat Formatter Tests diff --git a/spring-javaformat/spring-javaformat-formatter/pom.xml b/spring-javaformat/spring-javaformat-formatter/pom.xml index f6aef680..3a6c41c3 100644 --- a/spring-javaformat/spring-javaformat-formatter/pom.xml +++ b/spring-javaformat/spring-javaformat-formatter/pom.xml @@ -6,7 +6,7 @@ io.spring.javaformat spring-javaformat - 0.0.42-SNAPSHOT + 0.0.43-SNAPSHOT spring-javaformat-formatter Spring JavaFormat Formatter diff --git a/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk17/eclipse/JavadocLineBreakPreparator.java b/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk17/eclipse/JavadocLineBreakPreparator.java index e0dd5d8c..b66efa27 100644 --- a/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk17/eclipse/JavadocLineBreakPreparator.java +++ b/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk17/eclipse/JavadocLineBreakPreparator.java @@ -94,8 +94,7 @@ public boolean visit(Javadoc node) { int commentIndex = this.tokenManager.firstIndexIn(node, TerminalTokens.TokenNameCOMMENT_JAVADOC); Token commentToken = this.tokenManager.get(commentIndex); this.commentTokenManager = (commentToken.getInternalStructure() != null) - ? new TokenManager(commentToken.getInternalStructure(), this.tokenManager) - : null; + ? new TokenManager(commentToken.getInternalStructure(), this.tokenManager) : null; this.declaration = node.getParent(); this.firstTagElement = true; this.hasText = false; diff --git a/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk8/eclipse/JavadocLineBreakPreparator.java b/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk8/eclipse/JavadocLineBreakPreparator.java index 4113bbf2..3a4a5f41 100644 --- a/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk8/eclipse/JavadocLineBreakPreparator.java +++ b/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk8/eclipse/JavadocLineBreakPreparator.java @@ -94,8 +94,7 @@ public boolean visit(Javadoc node) { int commentIndex = this.tokenManager.firstIndexIn(node, TerminalTokens.TokenNameCOMMENT_JAVADOC); Token commentToken = this.tokenManager.get(commentIndex); this.commentTokenManager = (commentToken.getInternalStructure() != null) - ? new TokenManager(commentToken.getInternalStructure(), this.tokenManager) - : null; + ? new TokenManager(commentToken.getInternalStructure(), this.tokenManager) : null; this.declaration = node.getParent(); this.firstTagElement = true; this.hasText = false;