Skip to content

Commit e660938

Browse files
committed
Migrate the build system from Maven to Gradle
1 parent f6dc0d9 commit e660938

18 files changed

+680
-384
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,12 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "maven"
3+
- package-ecosystem: "gradle"
44
directory: "/"
55
schedule:
66
interval: "weekly"
77
day: "saturday"
88
time: "06:00"
99
timezone: "Etc/UTC"
10-
groups:
11-
java-test-dependencies:
12-
patterns:
13-
- "org.junit.jupiter:*"
14-
maven-build-plugins:
15-
patterns:
16-
- "org.apache.maven.plugins:*"
17-
- "org.sonatype.plugins:*"
18-
java-production-dependencies:
19-
patterns:
20-
- "*"
21-
exclude-patterns:
22-
- "org.openjfx:*"
23-
- "org.apache.maven.plugins:*"
24-
- "org.junit.jupiter:*"
25-
- "org.sonatype.plugins:*"
2610

2711
- package-ecosystem: "github-actions"
2812
directory: "/" # even for `.github/workflows`

.github/workflows/build_and_release.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2020 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
allprojects {
18+
tasks.withType(JavaCompile).configureEach {
19+
outputs.doNotCacheIf("CodeQL scanning", { true })
20+
}
21+
}

.github/workflows/codeql-analysis.yml

Lines changed: 99 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,105 @@ on:
88
schedule:
99
- cron: '34 10 * * 4'
1010

11+
permissions: {}
12+
1113
jobs:
12-
analyse:
13-
name: Analyse
14+
CodeQL-Build:
15+
permissions:
16+
actions: read # for github/codeql-action/init to get workflow details
17+
contents: read # for actions/checkout to fetch code
18+
security-events: write # for github/codeql-action/analyze to upload SARIF results
1419
runs-on: ubuntu-latest
15-
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
# Override automatic language detection by changing the below list
25+
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
26+
language: ['java', 'javascript']
27+
# Learn more...
28+
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
29+
1630
steps:
17-
- uses: actions/checkout@v4
18-
with:
19-
fetch-depth: 2
20-
- uses: actions/setup-java@v4
21-
with:
22-
distribution: 'temurin'
23-
java-version: '17'
24-
- uses: actions/cache@v4
25-
with:
26-
path: ~/.m2/repository
27-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
28-
restore-keys: |
29-
${{ runner.os }}-maven-
30-
- name: Initialize CodeQL
31-
uses: github/codeql-action/init@v3
32-
with:
33-
languages: java
34-
- name: Build
35-
run: mvn -B compile
36-
- name: Perform CodeQL Analysis
37-
uses: github/codeql-action/analyze@v3
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
# Checkout must run before the caching key is computed using the `hashFiles` method
34+
35+
- name: Cache Gradle Modules
36+
uses: actions/cache@v4
37+
with:
38+
path: |
39+
~/.gradle/caches/modules-2/
40+
~/.gradle/caches/build-cache-1/
41+
~/.gradle/caches/signatures/
42+
~/.gradle/caches/keyrings/
43+
key: ${{ runner.os }}-gradle-cache-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
44+
if: ${{ matrix.language == 'java' }}
45+
46+
- name: Disable checksum offloading
47+
# See: https://github.com/actions/virtual-environments/issues/1187#issuecomment-686735760
48+
run: sudo ethtool -K eth0 tx off rx off
49+
50+
# Install and setup JDK 17
51+
- name: Setup JDK 17
52+
uses: actions/setup-java@v4
53+
with:
54+
distribution: temurin
55+
java-version: 17
56+
57+
# Initializes the CodeQL tools for scanning.
58+
- name: Initialize CodeQL
59+
uses: github/codeql-action/init@v3
60+
with:
61+
languages: ${{ matrix.language }}
62+
tools: latest
63+
# If you wish to specify custom queries, you can do so here or in a config file.
64+
# By default, queries listed here will override any specified in a config file.
65+
# Prefix the list here with "+" to use these queries and those in the config file.
66+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
67+
68+
- name: Compile with Gradle with Build Scan
69+
if: ${{ matrix.language == 'java' && github.repository_owner == 'gradle' }}
70+
run: ./gradlew --init-script .github/workflows/codeql-analysis.init.gradle -DcacheNode=us -S testClasses -Dhttp.keepAlive=false
71+
env:
72+
# Set the DEVELOCITY_ACCESS_KEY so that Gradle Build Scans are generated
73+
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
74+
# Potential stop-gap solution for ReadTimeout issues with the Gradle Build Cache
75+
# https://gradle.slack.com/archives/CHDLT99C6/p1636477584059200
76+
GRADLE_OPTS: -Dhttp.keepAlive=false
77+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
78+
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.GPG_PRIVATE_KEY_ID }}
79+
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSPHRASE }}
80+
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.NEXUS_USERNAME }}
81+
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.NEXUS_PASSWORD }}
82+
83+
- name: Compile with Gradle without Build Scan
84+
if: ${{ matrix.language == 'java' && github.repository_owner != 'gradle' }}
85+
run: ./gradlew --init-script .github/workflows/codeql-analysis.init.gradle -S testClasses
86+
87+
- name: Cleanup Gradle Daemons
88+
run: ./gradlew --stop
89+
if: ${{ matrix.language == 'java' }}
90+
91+
# ℹ️ Command-line programs to run using the OS shell.
92+
# 📚 https://git.io/JvXDl
93+
94+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
95+
# and modify them (or add more) to build your code if your project
96+
# uses a compiled language
97+
98+
#- run: |
99+
# make bootstrap
100+
# make release
101+
102+
- name: Perform CodeQL Analysis
103+
uses: github/codeql-action/analyze@v3
104+
with:
105+
config-file: ./.github/codeql/codeql-config.yml
106+
107+
- name: Cleanup Gradle Cache
108+
# Cleans up the Gradle caches before being cached
109+
run: |
110+
rm -f ~/.gradle/caches/modules-2/modules-2.lock
111+
rm -f ~/.gradle/caches/modules-2/gc.properties
112+
if: ${{ matrix.language == 'java' }}
Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,53 @@
11
name: Publish to Maven Central
2+
23
on:
34
workflow_dispatch:
45
inputs:
56
tag:
67
description: 'Tag'
78
required: true
89
default: '0.0.0'
10+
sonatypeUsername:
11+
description: 'Sonatype username'
12+
type: string
13+
required: true
14+
sonatypePassword:
15+
description: 'Sonatype password'
16+
type: string
17+
required: true
18+
919
jobs:
1020
publish:
1121
runs-on: ubuntu-latest
22+
1223
steps:
1324
- uses: actions/checkout@v4
14-
- name: Set up Maven Central Repository
25+
26+
- name: Set up Java
1527
uses: actions/setup-java@v4
1628
with:
1729
java-version: '17'
1830
distribution: 'temurin'
19-
server-id: ossrh
20-
server-username: MAVEN_USERNAME
21-
server-password: MAVEN_PASSWORD
22-
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
23-
gpg-passphrase: MAVEN_GPG_PASSPHRASE
31+
32+
- name: Setup Gradle
33+
uses: gradle/actions/setup-gradle@v4
34+
35+
- name: Setup GPG key information
36+
run: |
37+
mkdir -p ~/.gradle ~/.gnupg
38+
echo "signing.gnupg.homeDir=/home/runner/.gnupg" >> ~/.gradle/gradle.properties
39+
echo "signing.gnupg.executable=gpg" >> ~/.gradle/gradle.properties
40+
echo "signing.gnupg.keyName=ABC48776" >> ~/.gradle/gradle.properties
41+
echo "signing.gnupg.passphrase=${GPG_SIGNING_KEY_PW}" >> ~/.gradle/gradle.properties
42+
echo "no-tty" >> ~/.gnupg/gpg.conf >> ~/.gradle/gradle.properties
43+
env:
44+
GPG_SIGNING_KEY_PW: ${{ secrets.GPG_PASSPHRASE }}
45+
46+
- name: Build package
47+
run: ./gradlew clean build
48+
2449
- name: Publish package
25-
run: mvn deploy -B -DskipTests -Psign,deploy-central --no-transfer-progress
50+
run: ./gradlew publishToSonatype closeSonatypeStagingRepository
2651
env:
27-
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
28-
MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
29-
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
52+
SONATYPE_USERNAME: ${{ inputs.sonatypeUsername }}
53+
SONATYPE_PASSWORD: ${{ inputs.sonatypePassword }}

.gitignore

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
.project
1212
.classpath
1313

14-
# Maven #
15-
target/
16-
pom.xml.versionsBackup
14+
# Gradle
15+
.gradle
16+
build/
17+
!gradle/wrapper/gradle-wrapper.jar
18+
!**/src/main/**/build/
19+
!**/src/test/**/build/
1720

1821
# IntelliJ Settings Files (https://intellij-support.jetbrains.com/hc/en-us/articles/206544839-How-to-manage-projects-under-Version-Control-Systems) #
1922
.idea/**/workspace.xml

.idea/compiler.xml

Lines changed: 1 addition & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)