Skip to content

Commit 3619a97

Browse files
hotfix: Optimize Maven and Gradle configurations (#5)
* devops: Added gradle-wrapper JAR * hotfix(devops): Changed Gradle Wrapper version to 8.10.2 * hotfix(ci): Changes to CI pipeline fpr GHA workflow * hotfix(build): Added Maven configuration options * ci(devops): Configuration changes to Gradle Build * fix: Removed unknown 'enabled' property in build.gradle * fix: Removed unknown 'enabled' property in build.gradle
1 parent fc07dd5 commit 3619a97

File tree

6 files changed

+100
-30
lines changed

6 files changed

+100
-30
lines changed

.github/workflows/ci.yml

+26-7
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
# separate terms of service, privacy policy, and support
77
# documentation.
88

9-
name: Build and Release
9+
name: CI
1010

1111
on:
1212
push:
13-
branches: ['main']
13+
branches: [ 'main' ]
1414
pull_request:
1515
branches: [ 'main' ]
16+
types: [opened, synchronize, reopened, closed]
1617
workflow_dispatch:
1718

1819
permissions:
@@ -24,6 +25,15 @@ permissions:
2425
pull-requests: write
2526

2627
jobs:
28+
verify:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
- name: Get PR event name
33+
run: echo "The event type is ${{ github.event.action }}"
34+
- name: Get branch name
35+
run: echo "Branch name is ${{ github.head_ref }}"
36+
2737
gradle-build:
2838
name: Build with Gradle
2939
runs-on: ubuntu-latest
@@ -45,9 +55,9 @@ jobs:
4555
validate-wrappers: false
4656
add-job-summary-as-pr-comment: 'always'
4757
add-job-summary: 'always'
48-
49-
# - name: Validate Gradle Wrapper
50-
# uses: gradle/actions/wrapper-validation@v4
58+
59+
- name: Validate Gradle Wrapper
60+
uses: gradle/actions/wrapper-validation@v4
5161

5262
- name: Build with Gradle
5363
run: gradle build
@@ -56,8 +66,9 @@ jobs:
5666
uses: actions/upload-artifact@v4
5767
if: always()
5868
with:
59-
name: build-reports
69+
name: gradle-build-reports
6070
path: '**/build/reports/'
71+
#compression-level: 9
6172

6273
maven-build:
6374
name: Build with Maven
@@ -78,4 +89,12 @@ jobs:
7889
run: mvn -B clean install
7990

8091
- name: Build, Package and Test
81-
run: mvn -B jacoco:prepare-agent clean test package surefire-report:report jacoco:report
92+
run: mvn -B jacoco:prepare-agent clean test package surefire-report:report jacoco:report
93+
94+
- name: Upload build reports
95+
uses: actions/upload-artifact@v4
96+
if: always()
97+
with:
98+
name: maven-build-reports
99+
path: '**/target/reports/'
100+
#compression-level: 9

.mvn/maven.config

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-T4
2+
-ntp

Jenkinsfile

+69-19
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,90 @@
11
pipeline {
22
agent any
3-
options {
4-
skipStagesAfterUnstable()
5-
}
6-
tools {
7-
maven 'maven'
8-
jdk 'jdk21'
3+
4+
environment {
5+
// Define the required versions for Gradle and Maven
6+
GRADLE_VERSION = '8.10.2' // Update this to the desired version
7+
MAVEN_VERSION = '3.9.6' // Update this to the desired version
8+
GIT_TAG = "v${env.BUILD_NUMBER}" // Use Jenkins Build number as version for the tag
99
}
10+
1011
stages {
11-
stage('Verify') {
12+
stage('Checkout') {
13+
steps {
14+
// Checkout the code from the repository
15+
checkout scm
16+
}
17+
}
18+
19+
stage('Set Up Gradle') {
1220
steps {
13-
sh 'mvn --version'
14-
sh 'java --version'
21+
script {
22+
// Ensure the correct Gradle version is installed
23+
sh "sdk install gradle ${GRADLE_VERSION}"
24+
}
25+
}
26+
}
27+
28+
stage('Set Up Maven') {
29+
steps {
30+
script {
31+
// Ensure the correct Maven version is installed
32+
sh "sdk install maven ${MAVEN_VERSION}"
33+
}
1534
}
1635
}
17-
stage('Build') {
36+
37+
stage('Build with Gradle') {
1838
steps {
19-
sh 'mvn -DskipTests clean install -B --no-transfer-progress'
39+
script {
40+
// Run the Gradle build (assuming you have a build.gradle file in your project)
41+
sh './gradlew clean build'
42+
}
2043
}
2144
}
2245

23-
stage('Test') {
46+
stage('Build with Maven') {
2447
steps {
25-
sh 'mvn test'
48+
script {
49+
// Run the Maven build (assuming you have a pom.xml file in your project)
50+
sh 'mvn clean install'
51+
}
2652
}
27-
post {
28-
always {
29-
junit 'target/surefire-reports/*.xml'
53+
}
54+
55+
stage('Create Git Tag') {
56+
steps {
57+
script {
58+
// Create and push the Git tag
59+
sh "git tag ${GIT_TAG}"
60+
sh "git push origin ${GIT_TAG}"
3061
}
3162
}
3263
}
3364

34-
stage('Deliver') {
65+
stage('Create Release Assets') {
3566
steps {
36-
sh './jenkins/scripts/deliver.sh'
67+
script {
68+
// Assuming you want to upload the artifacts from build as release assets
69+
def gradleArtifact = "build/libs/*.jar" // Replace with your actual build artifact location
70+
def mavenArtifact = "target/*.jar" // Replace with your actual Maven build artifact location
71+
72+
// Example: Upload to a custom release system (GitHub, GitLab, etc.)
73+
// This can vary based on the integration or plugin used. Below is a general idea.
74+
75+
// GitHub CLI example
76+
sh "gh release create ${GIT_TAG} ${gradleArtifact} ${mavenArtifact} --title 'Release ${GIT_TAG}'"
77+
}
3778
}
3879
}
3980
}
40-
}
81+
82+
post {
83+
success {
84+
echo "Build and release process completed successfully!"
85+
}
86+
failure {
87+
echo "The build or release process failed."
88+
}
89+
}
90+
}

gradle.properties

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ org.gradle.caching=false
66

77
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
88
org.gradle.continue=true
9-
org.gradle.daemon=true
9+
org.gradle.daemon=false
1010
org.gradle.java.installations.auto-download=false
11-
org.gradle.java.installations.auto-detect=true
12-
#org.gradle.java.home=C:\\Program Files\\Java\\jdk-20.0.2
11+
org.gradle.java.installations.auto-detect=true

gradle/wrapper/gradle-wrapper.jar

42.6 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-2-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)