diff --git a/.ci/build.sh b/.ci/build.sh index b364bdb..5bf7f22 100644 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash # # SPDX-FileCopyrightText: © Vegard IT GmbH (https://vegardit.com) +# SPDX-FileContributor: Sebastian Thomschke (Vegard IT GmbH) # SPDX-License-Identifier: Apache-2.0 -# -# @author Sebastian Thomschke, Vegard IT GmbH +# SPDX-ArtifactOfProjectHomePage: https://github.com/vegardit/copycat ##################### # Script init @@ -37,7 +37,7 @@ echo "###################################################" echo "# Determining GIT branch...... #" echo "###################################################" GIT_BRANCH=$(git branch --show-current) -echo " -> GIT Branch: $GIT_BRANCH"; echo +echo " -> GIT Branch: $GIT_BRANCH" if ! hash mvn 2>/dev/null; then @@ -64,36 +64,25 @@ if ! hash mvn 2>/dev/null; then fi -echo -echo "###################################################" -echo "# Configuring JDK Class Data Sharing... #" -echo "###################################################" -java_version=$(java -version 2>&1) -echo "$java_version" -# https://docs.oracle.com/javase/8/docs/technotes/guides/vm/class-data-sharing.html -jdk_version_checksum=$(echo "$java_version" | md5sum | cut -f1 -d" ") -if [[ ! -f $HOME/.xshare/$jdk_version_checksum ]]; then - echo " -> Generating shared class data archive..." - mkdir -p $HOME/.xshare - java -Xshare:dump -XX:+UnlockDiagnosticVMOptions -XX:SharedArchiveFile=$HOME/.xshare/$jdk_version_checksum -else - echo " -> Reusing shared class data archive..." -fi -export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS:-} -Xshare:on -XX:+UnlockDiagnosticVMOptions -XX:SharedArchiveFile=$HOME/.xshare/$jdk_version_checksum" - - echo echo "###################################################" echo "# Configuring MAVEN_OPTS... #" echo "###################################################" MAVEN_OPTS="${MAVEN_OPTS:-}" -MAVEN_OPTS="$MAVEN_OPTS -XX:+TieredCompilation -XX:TieredStopAtLevel=1" # https://zeroturnaround.com/rebellabs/your-maven-build-is-slow-speed-it-up/ -MAVEN_OPTS="$MAVEN_OPTS -Djava.security.egd=file:/dev/./urandom" # https://stackoverflow.com/questions/58991966/what-java-security-egd-option-is-for/59097932#59097932 -MAVEN_OPTS="$MAVEN_OPTS -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS" # https://stackoverflow.com/questions/5120470/how-to-time-the-different-stages-of-maven-execution/49494561#49494561 -export MAVEN_OPTS="$MAVEN_OPTS -Xmx1024m -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dhttps.protocols=TLSv1.2" +MAVEN_OPTS+=" -Djava.security.egd=file:/dev/./urandom" # https://stackoverflow.com/questions/58991966/what-java-security-egd-option-is-for/59097932#59097932 +MAVEN_OPTS+=" -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS" # https://stackoverflow.com/questions/5120470/how-to-time-the-different-stages-of-maven-execution/49494561#49494561 +MAVEN_OPTS+=" -Xmx1024m -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dhttps.protocols=TLSv1.3,TLSv1.2" echo " -> MAVEN_OPTS: $MAVEN_OPTS" +export MAVEN_OPTS -MAVEN_CLI_OPTS="-e -U --batch-mode --show-version --no-transfer-progress -s .ci/maven-settings.xml -t .ci/maven-toolchains.xml" +MAVEN_CLI_OPTS="-e -U --batch-mode --show-version -s .ci/maven-settings.xml -t .ci/maven-toolchains.xml" +if [[ -n ${GITEA_ACTIONS:-} || (-n ${CI:-} && -z ${ACT:-}) ]]; then # if running on a remote CI but not on local nektos/act runner + MAVEN_CLI_OPTS+=" --no-transfer-progress" +fi +if [[ -n ${ACT:-} ]]; then + MAVEN_CLI_OPTS+=" -Dformatter.validate.lineending=KEEP" +fi +echo " -> MAVEN_CLI_OPTS: $MAVEN_CLI_OPTS" echo @@ -101,9 +90,12 @@ echo "###################################################" echo "# Determining current Maven project version... #" echo "###################################################" # https://stackoverflow.com/questions/3545292/how-to-get-maven-project-version-to-the-bash-command-line -projectVersion="$(mvn -s .ci/maven-settings.xml help:evaluate -Dexpression=project.version -q -DforceStdout)" +projectVersion=$(python -c "import xml.etree.ElementTree as ET; \ + print(ET.parse(open('pom.xml')).getroot().find( \ + '{http://maven.apache.org/POM/4.0.0}version').text)") echo " -> Current Version: $projectVersion" + # # decide whether to perform a release build or build+deploy a snapshot version # @@ -137,6 +129,7 @@ if [[ ${projectVersion:-foo} == ${POM_CURRENT_VERSION:-bar} && ${MAY_CREATE_RELE -DreleaseVersion=${POM_RELEASE_VERSION} \ -DdevelopmentVersion=${nextDevelopmentVersion} \ help:active-profiles clean release:clean release:prepare release:perform \ + | grep -v -e "\[INFO\] Download.* from repository-restored-from-cache" `# suppress download messages from repo restored from cache ` \ | grep -v -e "\[INFO\] .* \[0.0[0-9][0-9]s\]" # the grep command suppresses all lines from maven-buildtime-extension that report plugins with execution time <=99ms else echo @@ -145,5 +138,6 @@ else echo "###################################################" mvn $MAVEN_CLI_OPTS "$@" \ help:active-profiles clean verify \ + | grep -v -e "\[INFO\] Download.* from repository-restored-from-cache" `# suppress download messages from repo restored from cache ` \ | grep -v -e "\[INFO\] .* \[0.0[0-9][0-9]s\]" # the grep command suppresses all lines from maven-buildtime-extension that report plugins with execution time <=99ms fi diff --git a/.ci/maven-settings.xml b/.ci/maven-settings.xml index 8b21d18..64b529f 100644 --- a/.ci/maven-settings.xml +++ b/.ci/maven-settings.xml @@ -7,5 +7,71 @@ ${env.GITHUB_USER} ${env.GITHUB_API_KEY} + + central + + + 10000 + 30000 + + + + + + prefer-repo-restored-from-cache + + + env.RESTORED_REPO_PATH + + + + + + repository-restored-from-cache + file://${RESTORED_REPO_PATH} + + true + + + true + + + + central + https://repo.maven.apache.org/maven2 + + true + + + false + + + + + + + repository-restored-from-cache + file://${RESTORED_REPO_PATH} + + true + + + true + + + + central + https://repo.maven.apache.org/maven2 + + true + + + false + + + + + + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6aa984e..58ec962 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,7 +53,13 @@ jobs: runs-on: ubuntu-latest steps: - - name: Show environment variables + - name: "Show: GitHub context" + env: + GITHUB_CONTEXT: ${{ toJSON(github) }} + run: echo $GITHUB_CONTEXT + + + - name: "Show: environment variables" run: env | sort @@ -61,14 +67,39 @@ jobs: uses: actions/checkout@v4 # https://github.com/actions/checkout - - name: "Install: JDK ${{ env.JAVA_VERSION }}" + - name: "Install: JDK ${{ env.JAVA_VERSION }} ☕" uses: actions/setup-java@v4 # https://github.com/actions/setup-java with: distribution: temurin java-version: ${{ env.JAVA_VERSION }} - cache: maven - - name: Test with Maven + + - name: "Cache: Restore" + id: cache-restore + uses: actions/cache/restore@v4 # https://github.com/actions/cache/blob/main/restore/README.md + with: + # IMPORTANT: path must have exactly the same value as in the cache save step otherwise restore will fail with cache key not found + path: | + ~/.m2/bin + ~/.m2/repository + !~/.m2/repository/.cache + !~/.m2/repository/.meta + !~/.m2/repository/com/vegardit/maven + !~/.m2/repository/*SNAPSHOT* + key: ${{ runner.os }}-${{ runner.arch }}-mvn-repo-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-${{ runner.arch }}-mvn-repo- + + + - name: "Move Restored Repo" + if: ${{ steps.cache-restore.outputs.cache-hit }} + run: | + RESTORED_REPO_PATH=$HOME/.m2/repository-restored + mv -v ~/.m2/repository $RESTORED_REPO_PATH + echo "RESTORED_REPO_PATH=$RESTORED_REPO_PATH" >> $GITHUB_ENV + + + - name: "Test with Maven 🔨" if: ${{ github.ref_name != 'main' || env.ACT }} env: GITHUB_USER: ${{ github.actor }} @@ -78,7 +109,7 @@ jobs: bash .ci/build.sh ${{ github.event.inputs.additional_maven_args }} - - name: Build with Maven + - name: "Build with Maven 🔨" if: ${{ github.ref_name == 'main' && !env.ACT }} env: GITHUB_USER: ${{ github.actor }} @@ -88,11 +119,37 @@ jobs: set -eu # https://github.community/t/github-actions-bot-email-address/17204 - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" bash .ci/build.sh ${{ github.event.inputs.additional_maven_args }} + ################################################## + # Cache Update + # See https://github.com/actions/cache/issues/342#issuecomment-1399442670 + ################################################## + - name: "Cache: Delete Previous" + if: ${{ steps.cache-restore.outputs.cache-hit && !env.ACT }} + env: + GH_TOKEN: ${{ github.token }} + run: | + gh extension install actions/gh-actions-cache + # "|| true" is to avoid "Error: Resource not accessible by integration" from failing the job + gh actions-cache delete ${{ steps.cache-restore.outputs.cache-primary-key }} --confirm || true + + - name: "Cache: Update" + uses: actions/cache/save@v4 # https://github.com/actions/cache/blob/main/save/README.md + with: + path: | + ~/.m2/bin + ~/.m2/repository + !~/.m2/repository/.cache + !~/.m2/repository/.meta + !~/.m2/repository/com/vegardit/maven + !~/.m2/repository/*SNAPSHOT* + key: ${{ steps.cache-restore.outputs.cache-primary-key }} + + - name: Test minimized fat jar run: | set -ex @@ -329,12 +386,6 @@ jobs: esac - - name: "Get: maven-build-artifacts" - uses: actions/download-artifact@v4 - with: - name: maven-build-artifacts - - - name: Enable Developer Command Prompt if: matrix.arch == 'windows-amd64' # makes cl.exe available on PATH @@ -342,6 +393,12 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 + - name: "Get: maven-build-artifacts" + uses: actions/download-artifact@v4 + with: + name: maven-build-artifacts + + - name: "Collect metadata" run: | set -eu diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1036e36..9b5ce57 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,33 +1,45 @@ -# Contributing +# Contributing to the Project -Thanks for your interest in contributing to this project! +Thank you for your interest in contributing to this project! We strive to make the contribution process clear and welcoming. -We want to make contributing as easy and transparent as possible. +Please take a moment to review the guidelines below. ## Code of Conduct -Our code of conduct is described in [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md). -Please follow it in all your interactions with the project. +Please review and adhere to our [Code of Conduct](CODE_OF_CONDUCT.md) in all your interactions with the project. +This helps us maintain a positive and respectful environment for everyone involved. -## Issues +## How to Contribute -We use GitHub issues to track bugs and feature requests. Please ensure your description is clear and has sufficient instructions to be able to reproduce the issue. +### Contributor Responsibilities +By submitting your contributions, you agree to the following: +- You are the sole author of the content you contribute, or you have the appropriate rights and permissions to contribute it. +- If employed, you have obtained any necessary permissions from your employer to contribute to this project. +- All contributions will be made available under the project’s license. -## Pull Requests +### Issues -Before you make a substantial pull request, please file an issue and make sure someone from the team agrees that there is a problem or room for improvement. +We use GitHub Issues to track bugs and feature requests. When submitting an issue, please ensure: +- The description is clear and concise. +- You provide enough details and steps to reproduce the issue, if applicable. +### Pull Requests -### License +Before making substantial contributions: +1. **Discuss Changes**: Please file an issue first to discuss your proposed changes with the team. This helps ensure your contribution aligns with the project’s goals. +2. **Follow Best Practices**: Adhere to the guidelines and ensure your code meets the project’s standards (see [Code Guidelines](#code-guidelines)). -By contributing your code, you agree to license your contribution under the [Apache License 2.0](LICENSE.txt). +When submitting a pull request: +- Ensure your changes are well-documented. +- Include tests for any new features or significant changes. +- Reference the relevant issue(s) in your pull request description. -### Source Code Formatting +## Licensing -Before committing your code ensure it is formatted according the [vegardit.com Eclipse formatter rules](https://github.com/vegardit/vegardit-maven-parent/blob/main/src/etc/eclipse-formatter.xml). +By contributing to this project, you agree that your contributions will be licensed under the [Apache License 2.0](LICENSE.txt). -IntelliJ users can use the [Eclipse Code Formatter](https://plugins.jetbrains.com/plugin/6546-eclipse-code-formatter) plugin to import and use the formatter settings. +The project itself is also licensed under the [Apache License 2.0](LICENSE.txt)). diff --git a/pom.xml b/pom.xml index bebe723..8fdc776 100644 --- a/pom.xml +++ b/pom.xml @@ -1,19 +1,19 @@ - + - + 4.0.0 com.vegardit.maven vegardit-maven-parent - 5.0.0 + 5.1.0 com.vegardit @@ -24,18 +24,17 @@ copycat Directory synchronization tool. https://github.com/vegardit/copycat + 2020 + Vegard IT GmbH, Germany https://vegardit.com/ - 2020 - - Apache License 2.0 repo - https://spdx.org/licenses/Apache-2.0.html + https://spdx.org/licenses/Apache-2.0 @@ -65,18 +64,18 @@ - - github.com - https://github.com/vegardit/copycat/actions - - - github.com https://github.com/vegardit/copycat/issues + + github.com + https://github.com/vegardit/copycat/actions + + + @@ -279,7 +278,6 @@ - org.eclipse.jdt org.eclipse.jdt.annotation