Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK-4017 the maven setup does now not contain the wrapper anymore #4

Merged
merged 4 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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 }}
File renamed without changes.
3 changes: 1 addition & 2 deletions settings.xml → .mvn/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
<mirrors>
<mirror>
<id>ReLoAd-Mirror</id>
<url>https://nexus.reloadkube.managedservices.resilient-teched.com/repository/default/
</url>
<url>https://nexus.reloadkube.managedservices.resilient-teched.com/repository/default/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions Base/config.iml

This file was deleted.

File renamed without changes.
File renamed without changes.
9 changes: 7 additions & 2 deletions Base/Configs/pom.xml → Configs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@
<parent>
<groupId>works.reload</groupId>
<artifactId>versions</artifactId>
<version>1.0.0</version>
<version>${revision}${changelist}</version>
<relativePath>../Versions/pom.xml</relativePath>
</parent>

<artifactId>configs</artifactId>
<version>1.0.0</version>
<name>Configs</name>
<description>Global configurations for java tooling</description>

<properties>
<!-- project version -->
<revision>1.0.0</revision>
<changelist>-SNAPSHOT</changelist>
</properties>

<build>
<resources>
<resource>
Expand Down
File renamed without changes.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
51 changes: 19 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 [email protected]: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
<project>
<parent>
<groupId>works.reload</groupId>
<artifactId>base</artifactId>
<version>1.0.0</version>
<relativePath>.mvn/Base/pom.xml</relativePath>
</parent>
1. Add the following to your pom.xml:
````xml
<project>
<parent>
<groupId>works.reload</groupId>
<artifactId>base</artifactId>
<version>1.0.0</version>
<relativePath>.mvn/Base/pom.xml</relativePath>
</parent>

<!-- Only add this if you have a parent pom with packaging pom -->
<modules>
<module>.mvn/Base</module>
<!-- Add your modules here -->
</modules>
</project>
````
<repositories>
<repository>
<id>ReLoAd</id>
<url>https://nexus.reloadkube.managedservices.resilient-teched.com/repository/reload/</url>
</repository>
</repositories>
</project>
````

## 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.
44 changes: 43 additions & 1 deletion Base/Versions/pom.xml → Versions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>works.reload</groupId>
<artifactId>versions</artifactId>
<version>1.0.0</version>
<version>${revision}${changelist}</version>
<packaging>pom</packaging>
<name>Versions</name>
<description>All default maven versions</description>
Expand All @@ -17,8 +17,13 @@
</organization>

<properties>
<!-- project version -->
<revision>1.0.0</revision>
<changelist>-SNAPSHOT</changelist>
<!-- project settings -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<!-- plugin versions -->
<maven-antrun-plugin.version>3.1.0</maven-antrun-plugin.version>
<maven-assembly-plugin.version>3.7.0</maven-assembly-plugin.version>
<maven-dependency-plugin.version>3.6.1</maven-dependency-plugin.version>
Expand All @@ -31,9 +36,14 @@
<maven-install-plugin.version>3.1.1</maven-install-plugin.version>
<maven-deploy-plugin.version>3.1.1</maven-deploy-plugin.version>
<maven-site-plugin.version>4.0.0-M13</maven-site-plugin.version>
<flatten-maven-plugin.version>1.6.0</flatten-maven-plugin.version>
</properties>

<distributionManagement>
<repository>
<id>reload</id>
<url>https://nexus.reloadkube.managedservices.resilient-teched.com/repository/reload/</url>
</repository>
<site>
<id>${project.artifactId}-site</id>
<url>file:///tmp/dummy-site</url>
Expand Down Expand Up @@ -94,7 +104,39 @@
<artifactId>maven-site-plugin</artifactId>
<version>${maven-site-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>${flatten-maven-plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
46 changes: 8 additions & 38 deletions Base/pom.xml → pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
<parent>
<groupId>works.reload</groupId>
<artifactId>versions</artifactId>
<version>1.0.0</version>
<version>${revision}${changelist}</version>
<relativePath>./Versions/pom.xml</relativePath>
</parent>

<artifactId>base</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>Base</name>
<description>Global configurations for java projects and code validation tools</description>

<properties>
<works-reload-configs.version>1.0.0</works-reload-configs.version>
<!-- project version -->
<revision>1.0.0</revision>
<changelist>-SNAPSHOT</changelist>
<!-- dependencyManagement versions -->
<jetbrains-annotations.version>24.1.0</jetbrains-annotations.version>
<spotbugs-annotations.version>4.8.3</spotbugs-annotations.version>
Expand All @@ -42,7 +43,6 @@
<cobertura-maven-plugin.version>2.7</cobertura-maven-plugin.version>
<pitest-maven.version>1.15.8</pitest-maven.version>
<pitest-junit5-plugin.version>1.2.1</pitest-junit5-plugin.version>
<flatten-maven-plugin.version>1.6.0</flatten-maven-plugin.version>
<versions-maven-plugin.version>2.16.2</versions-maven-plugin.version>
</properties>

Expand Down Expand Up @@ -220,7 +220,7 @@
<dependency>
<groupId>works.reload</groupId>
<artifactId>configs</artifactId>
<version>${works-reload-configs.version}</version>
<version>${revision}${changelist}</version>
</dependency>
</dependencies>
<configuration>
Expand All @@ -239,7 +239,7 @@
<dependency>
<groupId>works.reload</groupId>
<artifactId>configs</artifactId>
<version>${works-reload-configs.version}</version>
<version>${revision}${changelist}</version>
</dependency>
</dependencies>
<configuration>
Expand All @@ -261,7 +261,7 @@
<dependency>
<groupId>works.reload</groupId>
<artifactId>configs</artifactId>
<version>${works-reload-configs.version}</version>
<version>${revision}${changelist}</version>
</dependency>
</dependencies>
<configuration>
Expand Down Expand Up @@ -296,11 +296,6 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>${flatten-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
Expand All @@ -321,7 +316,7 @@
<configuration>
<rules>
<requireMavenVersion>
<version>3.8.1</version>
<version>3.9.6</version>
</requireMavenVersion>
</rules>
</configuration>
Expand Down Expand Up @@ -448,31 +443,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
Expand Down