Skip to content

hotfix: Optimize Maven and Gradle configurations #5

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

Merged
merged 7 commits into from
Apr 13, 2025
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
33 changes: 26 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
# separate terms of service, privacy policy, and support
# documentation.

name: Build and Release
name: CI

on:
push:
branches: ['main']
branches: [ 'main' ]
pull_request:
branches: [ 'main' ]
types: [opened, synchronize, reopened, closed]
workflow_dispatch:

permissions:
Expand All @@ -24,6 +25,15 @@ permissions:
pull-requests: write

jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get PR event name
run: echo "The event type is ${{ github.event.action }}"
- name: Get branch name
run: echo "Branch name is ${{ github.head_ref }}"

gradle-build:
name: Build with Gradle
runs-on: ubuntu-latest
Expand All @@ -45,9 +55,9 @@ jobs:
validate-wrappers: false
add-job-summary-as-pr-comment: 'always'
add-job-summary: 'always'
# - name: Validate Gradle Wrapper
# uses: gradle/actions/wrapper-validation@v4

- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v4

- name: Build with Gradle
run: gradle build
Expand All @@ -56,8 +66,9 @@ jobs:
uses: actions/upload-artifact@v4
if: always()
with:
name: build-reports
name: gradle-build-reports
path: '**/build/reports/'
#compression-level: 9

maven-build:
name: Build with Maven
Expand All @@ -78,4 +89,12 @@ jobs:
run: mvn -B clean install

- name: Build, Package and Test
run: mvn -B jacoco:prepare-agent clean test package surefire-report:report jacoco:report
run: mvn -B jacoco:prepare-agent clean test package surefire-report:report jacoco:report

- name: Upload build reports
uses: actions/upload-artifact@v4
if: always()
with:
name: maven-build-reports
path: '**/target/reports/'
#compression-level: 9
2 changes: 2 additions & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-T4
-ntp
88 changes: 69 additions & 19 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,90 @@
pipeline {
agent any
options {
skipStagesAfterUnstable()
}
tools {
maven 'maven'
jdk 'jdk21'

environment {
// Define the required versions for Gradle and Maven
GRADLE_VERSION = '8.10.2' // Update this to the desired version
MAVEN_VERSION = '3.9.6' // Update this to the desired version
GIT_TAG = "v${env.BUILD_NUMBER}" // Use Jenkins Build number as version for the tag
}

stages {
stage('Verify') {
stage('Checkout') {
steps {
// Checkout the code from the repository
checkout scm
}
}

stage('Set Up Gradle') {
steps {
sh 'mvn --version'
sh 'java --version'
script {
// Ensure the correct Gradle version is installed
sh "sdk install gradle ${GRADLE_VERSION}"
}
}
}

stage('Set Up Maven') {
steps {
script {
// Ensure the correct Maven version is installed
sh "sdk install maven ${MAVEN_VERSION}"
}
}
}
stage('Build') {

stage('Build with Gradle') {
steps {
sh 'mvn -DskipTests clean install -B --no-transfer-progress'
script {
// Run the Gradle build (assuming you have a build.gradle file in your project)
sh './gradlew clean build'
}
}
}

stage('Test') {
stage('Build with Maven') {
steps {
sh 'mvn test'
script {
// Run the Maven build (assuming you have a pom.xml file in your project)
sh 'mvn clean install'
}
}
post {
always {
junit 'target/surefire-reports/*.xml'
}

stage('Create Git Tag') {
steps {
script {
// Create and push the Git tag
sh "git tag ${GIT_TAG}"
sh "git push origin ${GIT_TAG}"
}
}
}

stage('Deliver') {
stage('Create Release Assets') {
steps {
sh './jenkins/scripts/deliver.sh'
script {
// Assuming you want to upload the artifacts from build as release assets
def gradleArtifact = "build/libs/*.jar" // Replace with your actual build artifact location
def mavenArtifact = "target/*.jar" // Replace with your actual Maven build artifact location

// Example: Upload to a custom release system (GitHub, GitLab, etc.)
// This can vary based on the integration or plugin used. Below is a general idea.

// GitHub CLI example
sh "gh release create ${GIT_TAG} ${gradleArtifact} ${mavenArtifact} --title 'Release ${GIT_TAG}'"
}
}
}
}
}

post {
success {
echo "Build and release process completed successfully!"
}
failure {
echo "The build or release process failed."
}
}
}
5 changes: 2 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ org.gradle.caching=false

org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.continue=true
org.gradle.daemon=true
org.gradle.daemon=false
org.gradle.java.installations.auto-download=false
org.gradle.java.installations.auto-detect=true
#org.gradle.java.home=C:\\Program Files\\Java\\jdk-20.0.2
org.gradle.java.installations.auto-detect=true
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down