diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..331b62d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,68 @@ +name: Build +on: + push: + branches: + - '**' + tags-ignore: + - '**' + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build_feature_branch: + name: Build feature branch + runs-on: ubuntu-latest + if: "github.ref != 'refs/heads/main'" + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup Java and Maven + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + cache: 'maven' + - name: Build with Maven verify + run: ./mvnw -B verify + build_main_branch: + name: Build main branch + runs-on: ubuntu-latest + if: "github.ref == 'refs/heads/main'" + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Java and Maven + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + cache: 'maven' + server-id: 'reload' + server-username: ${{ secrets.MAVEN_SERVER_USERNAME }} + server-password: ${{ secrets.MAVEN_SERVER_PASSWORD }} + - name: Read revision version from pom.xml + shell: bash + run: | + MAVEN_POM_REVISION_VERSION="$(./mvnw help:evaluate -Dexpression=revision -q -DforceStdout)" + echo "MAVEN_POM_REVISION_VERSION=$MAVEN_POM_REVISION_VERSION" >> $GITHUB_ENV + - name: Check if revision is already tagged + shell: bash + run: | + if git tag -l v$MAVEN_POM_REVISION_VERSION | grep -q v$MAVEN_POM_REVISION_VERSION; then + echo "Revision $MAVEN_POM_REVISION_VERSION is already tagged. Skipping the build and deployment!" + exit 0 + else + DEPLOY_RELEASE=true + echo "DEPLOY_RELEASE=$DEPLOY_RELEASE" >> $GITHUB_ENV + fi + - name: Build with Maven deploy + if: ${{ env.DEPLOY_RELEASE == 'true' }} + run: ./mvnw -Dchangelist= -B deploy + - name: Create new git tag + uses: rickstaa/action-create-tag@v1 + if: ${{ env.DEPLOY_RELEASE == 'true' }} + with: + tag: ${{ env.MAVEN_POM_REVISION_VERSION }} + message: Release ${{ env.MAVEN_POM_REVISION_VERSION }} diff --git a/extensions.xml b/.mvn/extensions.xml similarity index 100% rename from extensions.xml rename to .mvn/extensions.xml diff --git a/settings.xml b/.mvn/settings.xml similarity index 91% rename from settings.xml rename to .mvn/settings.xml index 7ecad1f..0b2c5a4 100644 --- a/settings.xml +++ b/.mvn/settings.xml @@ -4,8 +4,7 @@ ReLoAd-Mirror - https://nexus.reloadkube.managedservices.resilient-teched.com/repository/default/ - + https://nexus.reloadkube.managedservices.resilient-teched.com/repository/default/ * diff --git a/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar similarity index 100% rename from wrapper/maven-wrapper.jar rename to .mvn/wrapper/maven-wrapper.jar diff --git a/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties similarity index 100% rename from wrapper/maven-wrapper.properties rename to .mvn/wrapper/maven-wrapper.properties diff --git a/Base/config.iml b/Base/config.iml deleted file mode 100644 index 9e3449c..0000000 --- a/Base/config.iml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Base/Configs/checkstyle.xml b/Configs/checkstyle.xml similarity index 100% rename from Base/Configs/checkstyle.xml rename to Configs/checkstyle.xml diff --git a/Base/Configs/pmd-ruleset.xml b/Configs/pmd-ruleset.xml similarity index 100% rename from Base/Configs/pmd-ruleset.xml rename to Configs/pmd-ruleset.xml diff --git a/Base/Configs/pom.xml b/Configs/pom.xml similarity index 82% rename from Base/Configs/pom.xml rename to Configs/pom.xml index c617d77..7b2d90f 100644 --- a/Base/Configs/pom.xml +++ b/Configs/pom.xml @@ -6,15 +6,20 @@ works.reload versions - 1.0.0 + ${revision}${changelist} ../Versions/pom.xml configs - 1.0.0 Configs Global configurations for java tooling + + + 1.0.0 + -SNAPSHOT + + diff --git a/Base/Configs/spotbugs-exclude.xml b/Configs/spotbugs-exclude.xml similarity index 100% rename from Base/Configs/spotbugs-exclude.xml rename to Configs/spotbugs-exclude.xml diff --git a/Makefile b/Makefile index 8c140b2..f4c86ac 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # This will output the help for each task # thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html .PHONY: help \ - update-dependencies update-snapshot-dependencies + update-dependencies update-snapshot-dependencies bump-version help: ## This help. @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) @@ -11,7 +11,10 @@ help: ## This help. # Updates of third-party dependencies update-dependencies: ## Update Maven dependencies and plugins which have versions defined in properties - cd Base && ../mvnw --projects :base,:versions clean versions:update-properties + ./mvnw --projects :base,:versions clean versions:update-properties update-snapshot-dependencies: ## Update locked snapshot versions with the latest available one in the POM - cd Base && ../mvnw --projects :base,:versions versions:unlock-snapshots versions:lock-snapshots + ./mvnw --projects :base,:versions versions:unlock-snapshots versions:lock-snapshots + +bump-version: ## Bump the version of the project + [ -n "$(NEW_VERSION)" ] && ./mvnw versions:set-property -Dproperty=revision -DnewVersion=$(NEW_VERSION) diff --git a/README.md b/README.md index 92ef852..ebaa256 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,29 @@ # MavenSetup -A basic setup for all maven projects containing a build and tools for java. +A basic setup for all maven projects containing building and tools for java. ## Howto setup -1. Execute the following command in the root directory of your project: - ```bash - git submodule add --name MavenSetup git@github.com:ResilientGroup/MavenSetup.git .mvn - # or if you have a fork under your namespace - git submodule add --name MavenSetup ../MavenSetup.git .mvn - ``` -2. Add the `branch = .` line to your .gitmodules file for the MavenSetup submodule. It should look like this: - ```properties - [submodule="MavenSetup"] - path = .mvn - url = ../MavenSetup.git - branch = . - ``` -3. Add the following to your pom.xml: - ````xml - - - works.reload - base - 1.0.0 - .mvn/Base/pom.xml - +1. Add the following to your pom.xml: + ````xml + + + works.reload + base + 1.0.0 + .mvn/Base/pom.xml + - - - .mvn/Base - - - - ```` + + + ReLoAd + https://nexus.reloadkube.managedservices.resilient-teched.com/repository/reload/ + + + + ```` ## Maven Wrapper Note As this setup enforces a minimum maven version, it is not guaranteed that the maven version you have installed on your system is compatible with the project. -For that, a maven wrapper is included in the setup. -This means you can use the `.mvn/mvnw` command instead of `mvn` to execute maven commands. +For that, a maven wrapper is recommended to be used. It is strongly recommended to use the wrapper in any automated build process, as it ensures that the correct maven version is used. diff --git a/Base/Versions/pom.xml b/Versions/pom.xml similarity index 73% rename from Base/Versions/pom.xml rename to Versions/pom.xml index 3cb1434..27cbcee 100644 --- a/Base/Versions/pom.xml +++ b/Versions/pom.xml @@ -5,7 +5,7 @@ works.reload versions - 1.0.0 + ${revision}${changelist} pom Versions All default maven versions @@ -17,8 +17,13 @@ + + 1.0.0 + -SNAPSHOT + UTF-8 17 + 3.1.0 3.7.0 3.6.1 @@ -31,9 +36,14 @@ 3.1.1 3.1.1 4.0.0-M13 + 1.6.0 + + reload + https://nexus.reloadkube.managedservices.resilient-teched.com/repository/reload/ + ${project.artifactId}-site file:///tmp/dummy-site @@ -94,7 +104,39 @@ maven-site-plugin ${maven-site-plugin.version} + + org.codehaus.mojo + flatten-maven-plugin + ${flatten-maven-plugin.version} + + + + org.codehaus.mojo + flatten-maven-plugin + + true + resolveCiFriendliesOnly + ${project.build.directory} + + + + flatten + process-resources + + flatten + + + + flatten.clean + clean + + clean + + + + + diff --git a/Base/pom.xml b/pom.xml similarity index 93% rename from Base/pom.xml rename to pom.xml index b4428e9..f6d15e9 100644 --- a/Base/pom.xml +++ b/pom.xml @@ -6,18 +6,19 @@ works.reload versions - 1.0.0 + ${revision}${changelist} ./Versions/pom.xml base - 1.0.0 pom Base Global configurations for java projects and code validation tools - 1.0.0 + + 1.0.0 + -SNAPSHOT 24.1.0 4.8.3 @@ -42,7 +43,6 @@ 2.7 1.15.8 1.2.1 - 1.6.0 2.16.2 @@ -220,7 +220,7 @@ works.reload configs - ${works-reload-configs.version} + ${revision}${changelist} @@ -239,7 +239,7 @@ works.reload configs - ${works-reload-configs.version} + ${revision}${changelist} @@ -261,7 +261,7 @@ works.reload configs - ${works-reload-configs.version} + ${revision}${changelist} @@ -296,11 +296,6 @@ - - org.codehaus.mojo - flatten-maven-plugin - ${flatten-maven-plugin.version} - org.codehaus.mojo versions-maven-plugin @@ -321,7 +316,7 @@ - 3.8.1 + 3.9.6 @@ -448,31 +443,6 @@ - - org.codehaus.mojo - flatten-maven-plugin - - true - resolveCiFriendliesOnly - ${project.build.directory} - - - - flatten - process-resources - - flatten - - - - flatten.clean - clean - - clean - - - - org.codehaus.mojo versions-maven-plugin