Skip to content

Commit

Permalink
Replace gradle with maven build (#62)
Browse files Browse the repository at this point in the history
Configured maven build because of lombok-issue with gradle build.
Additional benefits:
- better control about published pom.xml
- official supported plugin to upload to sonar central
  • Loading branch information
p3t authored Nov 11, 2024
1 parent 66aa427 commit 574cbac
Show file tree
Hide file tree
Showing 20 changed files with 1,175 additions and 207 deletions.
141 changes: 0 additions & 141 deletions .github/workflows/build.yml

This file was deleted.

88 changes: 88 additions & 0 deletions .github/workflows/maven_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: '[ BUILD ] Build Project (Java/Maven)'

on:
workflow_dispatch:
inputs:
release_build:
description: 'toggles an release-build, by default false'
type: boolean
default: false
required: false
build_version:
description: 'The version to build and deploy'
type: string
required: true
default: '0-SNAPSHOT'
workflow_call:
inputs:
release_build:
description: 'toggles an release-build, by default false'
type: boolean
default: false
required: false
build_version:
description: 'The version to build and deploy'
type: string
required: false
default: '0-SNAPSHOT'
outputs:
build_artifact_id:
description: 'The id of the uploaded build artifacts.'
value: ${{ jobs.Build.outputs.build_artifacts_id}}
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
BUILD_VERSION: ${{ inputs.build_version != '' && inputs.build_version || '0-SNAPSHOT' }}

jobs:
Build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: 'maven'
cache-dependency-path: '**/pom.xml'
server-id: 'github'
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }}
gpg-passphrase: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }}

- name: Set version
if: ${{ inputs.release_build }}
run: ./mvnw versions:set -DnewVersion=${{ env.BUILD_VERSION }} -DgenerateBackupPoms=false

- name: Build project, run unit and integration tests
id: Build
run: ./mvnw -T1C --batch-mode clean install

- name: Javadoc and sign artifacts
if: ${{ inputs.release_build }}
run: ./mvnw -T1C --batch-mode package javadoc:jar gpg:sign -Dgpg.signer=bc
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }}
MAVEN_GPG_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GITHUB_DEPENDENCY_GRAPH_ENABLED: false

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
./**/target/*${{inputs.build_version}}*.jar
./**/target/*${{inputs.build_version}}*.jar.asc
./**/target/reports/
retention-days: 10

- name: Publish to GitHub Packages
if: ${{ inputs.release_build }}
run: mvn deploy
env:
GITHUB_TOKEN: ${{ github.token }}
42 changes: 42 additions & 0 deletions .github/workflows/maven_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: '[ PUBLISH ] Release build with maven'

on:
workflow_call:
inputs:
build_version:
description: 'The version to be published'
type: string
required: true
Publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: 'maven'
cache-dependency-path: '**/pom.xml'
server-id: 'central'
server-username: ${{ secrets.SONATYPE_CENTRAL_USERNAME }}
server-password: ${{ secrets.SONATYPE_CENTRAL_PASSWORD }}

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts

- name: Display structure of downloaded files
run: tree

- name: Publish to Maven Central
run: ./mvnw deploy -DskipTests=true -Dmaven.javadoc.skip=true -B -V

- name: Debug
if: ${{ failure() }}
run: |
echo "Failed"
tree
62 changes: 7 additions & 55 deletions .github/workflows/start_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ jobs:
Build:
needs: [ ReleaseVersion ]
uses: ./.github/workflows/build.yml
uses: ./.github/workflows/maven_build.yml
with:
build_version: ${{ needs.ReleaseVersion.outputs.build_version }}
release_build: true
secrets: inherit
permissions:
pull-requests: write
contents: write
packages: write

UploadAssetsToRelease:
needs: [ ReleaseVersion, Build ]
Expand All @@ -72,59 +73,10 @@ jobs:
Publish:
needs: [ ReleaseVersion, Build ]
runs-on: ubuntu-latest
uses: ./.github/workflows/maven_publish.yml
with:
build_version: ${{ needs.ReleaseVersion.outputs.build_version }}
secrets: inherit
permissions:
contents: write
packages: write
env:
BUILD_VERSION: ${{ needs.ReleaseVersion.outputs.build_version }}

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- uses: actions/download-artifact@v4
with:
merge-multiple: true

- name: Display structure of downloaded files
run: tree

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4 # v3.1.0

- name: Generate gradle.properties with version
run: |
echo "version=${BUILD_VERSION}"
echo "version=${BUILD_VERSION}" >> ./gradle.properties
# The USERNAME and TOKEN need to correspond to the credentials environment variables used in
# the publishing section of your build.gradle
- name: Publish to GitHub Packages
run: ./gradlew publish
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_SIGNING_KEY_PASSWORD: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }}
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
GITHUB_DEPENDENCY_GRAPH_ENABLED: false

- name: publish to sonar central
run: ./gradlew sonatypeCentralUpload
env:
GPG_SIGNING_KEY_PASSWORD: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }}
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
SONATYPE_CENTRAL_USERNAME: ${{ secrets.SONATYPE_CENTRAL_USERNAME }}
SONATYPE_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_CENTRAL_PASSWORD }}
GITHUB_DEPENDENCY_GRAPH_ENABLED: false

- name: Debug
if: ${{ failure() }}
run: |
echo "Failed"
tree
contents: write
19 changes: 19 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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
#
# http://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.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
3 changes: 0 additions & 3 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ dependencies {
implementation("org.springframework.boot:spring-boot-gradle-plugin:3.3.5")
implementation("io.spring.gradle:dependency-management-plugin:1.1.6")
// implementation("org.kordamp.gradle:plugin-gradle-plugin:$kordampVersion")
implementation("org.kordamp.gradle:project-gradle-plugin:$kordampVersion")
implementation("org.kordamp.gradle:spotbugs-gradle-plugin:$kordampVersion")
implementation("org.kordamp.gradle:coveralls-gradle-plugin:$kordampVersion")
implementation("org.sonarqube:org.sonarqube.gradle.plugin:5.1.0.4882")
// implementation("org.kordamp.gradle:base-gradle-plugin:$kordampVersion")
// implementation("org.kordamp.gradle:jacoco-gradle-plugin:$kordampVersion")
implementation("gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.12.2")
implementation("cl.franciscosolis:SonatypeCentralUpload:1.0.3")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.3")
Expand Down
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Dependencies {

}
Loading

0 comments on commit 574cbac

Please sign in to comment.