Skip to content

Commit 4745dba

Browse files
committed
Migrate the build system from Maven to Gradle
1 parent 914b87f commit 4745dba

17 files changed

+709
-471
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 18 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`
@@ -31,4 +15,4 @@ updates:
3115
groups:
3216
github-actions:
3317
patterns:
34-
- "*"
18+
- "*"

.github/workflows/build_and_release_github.yml

Lines changed: 23 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -10,130 +10,42 @@ jobs:
1010
name: createrelease
1111
runs-on: ubuntu-latest
1212
if: startsWith(github.ref, 'refs/tags/')
13-
steps:
14-
- name: Check out code
15-
uses: actions/checkout@v4
16-
- name: create release
17-
id: create_release
18-
uses: actions/create-release@v1
19-
env:
20-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21-
with:
22-
tag_name: ${{ github.ref }}
23-
release_name: ${{ github.ref }}
24-
draft: true
25-
prerelease: false
26-
- name: Output Release URL File
27-
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt
28-
- name: Save Release URL file for publish
29-
uses: actions/upload-artifact@v4
30-
with:
31-
name: release_url
32-
path: release_url.txt
33-
- uses: little-core-labs/[email protected]
34-
id: tagName
35-
- name: Output git tag
36-
run: echo "${{ steps.tagName.outputs.tag }}" > git_tag.txt
37-
- name: Save git tag file for publish
38-
uses: actions/upload-artifact@v4
39-
with:
40-
name: git_tag
41-
path: git_tag.txt
42-
43-
44-
build_and_upload:
45-
needs: createrelease
46-
name: build_and_upload
47-
runs-on: ubuntu-latest
4813
steps:
4914
- uses: actions/checkout@v4
15+
5016
- uses: actions/setup-java@v4
5117
with:
5218
distribution: 'temurin'
5319
java-version: '17'
54-
cache: 'maven'
55-
- name: Set up GPG
56-
run: |
57-
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
58-
env:
59-
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
60-
- name: Build with Maven
61-
run: mvn -B -Psign -Dgpg.passphrase=${GPG_PASSPHRASE} -Dtest=org.purejava.integrations.keychain.KeePassXCAccessTest install --file pom.xml
62-
env:
63-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
6420

65-
- name: Load Release URL File from release job
66-
uses: actions/download-artifact@v4
67-
with:
68-
name: release_url
69-
- name: Get Release File Name & Upload URL
70-
id: get_release_info
71-
run: |
72-
value=`cat release_url.txt`
73-
echo ::set-output name=upload_url::$value
74-
- name: Load git tag from release job
75-
uses: actions/download-artifact@v4
76-
with:
77-
name: git_tag
78-
- name: Get git tag info
79-
id: get_tag_info
80-
run: |
81-
value=`cat git_tag.txt`
82-
echo ::set-output name=git_tag::$value
21+
- name: Setup Gradle
22+
uses: gradle/actions/setup-gradle@v4
8323

84-
- name: Sign uber jar with key 5BFB2076ABC48776
24+
- name: Import GPG key
8525
run: |
86-
echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 5BFB2076ABC48776 --detach-sign ./target/keepassxc-cryptomator-${{ steps.get_tag_info.outputs.git_tag }}.jar
87-
env:
88-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
89-
- name: Sign source tarball with key 5BFB2076ABC48776
90-
if: startsWith(github.ref, 'refs/tags/')
91-
run: |
92-
git archive --prefix="keepassxc-cryptomator-${{ github.ref_name }}/" -o "keepassxc-cryptomator-${{ github.ref_name }}.tar.gz" ${{ github.ref }}
93-
echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 5BFB2076ABC48776 --detach-sign keepassxc-cryptomator-*.tar.gz
94-
env:
95-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
96-
97-
- name: Upload uber jar
98-
id: upload-release-asset
99-
uses: actions/[email protected]
26+
echo "$GPG_SIGNING_KEY_PW" | gpg --batch --import --yes --passphrase-fd 0 <(echo -n "$GPG_SIGNING_KEY_B64" | base64 --decode)
10027
env:
101-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102-
with:
103-
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
104-
asset_path: ./target/keepassxc-cryptomator-${{ steps.get_tag_info.outputs.git_tag }}.jar
105-
asset_name: keepassxc-cryptomator-${{ steps.get_tag_info.outputs.git_tag }}.jar
106-
asset_content_type: application/java-archive
28+
GPG_SIGNING_KEY_B64: ${{ secrets.GPG_PRIVATE_KEY_B64 }}
29+
GPG_SIGNING_KEY_PW: ${{ secrets.GPG_PASSPHRASE }}
10730

108-
- name: Upload signature file for uber jar
109-
id: upload-signature-file-for-uber-jar
110-
uses: actions/[email protected]
31+
- name: Setup GPG key information
32+
run: |
33+
mkdir -p ~/.gradle ~/.gnupg
34+
echo "signing.gnupg.homeDir=/home/runner/.gnupg" >> ~/.gradle/gradle.properties
35+
echo "signing.gnupg.executable=gpg" >> ~/.gradle/gradle.properties
36+
echo "signing.gnupg.keyName=ABC48776" >> ~/.gradle/gradle.properties
37+
echo "signing.gnupg.passphrase=${GPG_SIGNING_KEY_PW}" >> ~/.gradle/gradle.properties
11138
env:
112-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113-
with:
114-
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
115-
asset_path: ./target/keepassxc-cryptomator-${{ steps.get_tag_info.outputs.git_tag }}.jar.sig
116-
asset_name: keepassxc-cryptomator-${{ steps.get_tag_info.outputs.git_tag }}.jar.sig
117-
asset_content_type: application/pgp-signature
39+
GPG_SIGNING_KEY_PW: ${{ secrets.GPG_PASSPHRASE }}
11840

119-
- name: Upload tarball
120-
id: upload-release-asset-2
121-
uses: actions/[email protected]
41+
- name: Build package
42+
run: ./gradlew clean build
12243
env:
123-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124-
with:
125-
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
126-
asset_path: ./keepassxc-cryptomator-${{ steps.get_tag_info.outputs.git_tag }}.tar.gz
127-
asset_name: keepassxc-cryptomator-${{ steps.get_tag_info.outputs.git_tag }}.tar.gz
128-
asset_content_type: application/tar+gzip
44+
GPG_SIGNING_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
45+
GPG_SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
12946

130-
- name: Upload signature file for source tarball
131-
id: upload-signature-file-for-source-tarball
132-
uses: actions/[email protected]
47+
- name: Release package
48+
run: ./gradlew githubRelease
13349
env:
134-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135-
with:
136-
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
137-
asset_path: ./keepassxc-cryptomator-${{ steps.get_tag_info.outputs.git_tag }}.tar.gz.sig
138-
asset_name: keepassxc-cryptomator-${{ steps.get_tag_info.outputs.git_tag }}.tar.gz.sig
139-
asset_content_type: application/pgp-signature
50+
GPG_SIGNING_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
51+
GPG_SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

.github/workflows/build_develop.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,38 @@ on:
66

77
jobs:
88
build:
9-
109
runs-on: ubuntu-latest
1110

1211
steps:
1312
- uses: actions/checkout@v4
13+
1414
- uses: actions/setup-java@v4
1515
with:
1616
distribution: 'temurin'
1717
java-version: '17'
18-
cache: 'maven'
19-
- name: Set up GPG
18+
19+
- name: Setup Gradle
20+
uses: gradle/actions/setup-gradle@v4
21+
22+
- name: Import GPG key
2023
run: |
21-
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
24+
echo "$GPG_SIGNING_KEY_PW" | gpg --batch --import --yes --passphrase-fd 0 <(echo -n "$GPG_SIGNING_KEY_B64" | base64 --decode)
2225
env:
23-
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
24-
- name: Build with Maven
25-
run: mvn -B -Psign -Dgpg.passphrase=${GPG_PASSPHRASE} -Dtest=org.purejava.integrations.keychain.KeePassXCAccessTest install --file pom.xml
26+
GPG_SIGNING_KEY_B64: ${{ secrets.GPG_PRIVATE_KEY_B64 }}
27+
GPG_SIGNING_KEY_PW: ${{ secrets.GPG_PASSPHRASE }}
28+
29+
- name: Setup GPG key information
30+
run: |
31+
mkdir -p ~/.gradle ~/.gnupg
32+
echo "signing.gnupg.homeDir=/home/runner/.gnupg" >> ~/.gradle/gradle.properties
33+
echo "signing.gnupg.executable=gpg" >> ~/.gradle/gradle.properties
34+
echo "signing.gnupg.keyName=ABC48776" >> ~/.gradle/gradle.properties
35+
echo "signing.gnupg.passphrase=${GPG_SIGNING_KEY_PW}" >> ~/.gradle/gradle.properties
36+
env:
37+
GPG_SIGNING_KEY_PW: ${{ secrets.GPG_PASSPHRASE }}
38+
39+
- name: Build package
40+
run: ./gradlew clean build
2641
env:
27-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
42+
GPG_SIGNING_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
43+
GPG_SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
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+
}
Lines changed: 91 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: "CodeQL"
32

43
on:
@@ -7,32 +6,105 @@ on:
76
pull_request:
87
branches: [develop]
98
schedule:
10-
- cron: '0 8 * * 0'
9+
- cron: '34 10 * * 4'
10+
11+
permissions: {}
1112

1213
jobs:
13-
analyse:
14-
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
1519
runs-on: ubuntu-latest
16-
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+
1730
steps:
18-
- uses: actions/checkout@v4
19-
with:
20-
fetch-depth: 2
21-
- uses: actions/setup-java@v4
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
2237
with:
23-
distribution: 'temurin'
24-
java-version: '17'
25-
- uses: actions/cache@v4
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
2653
with:
27-
path: ~/.m2/repository
28-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
29-
restore-keys: |
30-
${{ runner.os }}-maven-
54+
distribution: temurin
55+
java-version: 17
56+
57+
# Initializes the CodeQL tools for scanning.
3158
- name: Initialize CodeQL
3259
uses: github/codeql-action/init@v3
3360
with:
34-
languages: java
35-
- name: Build
36-
run: mvn -B compile
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+
81+
- name: Compile with Gradle without Build Scan
82+
if: ${{ matrix.language == 'java' && github.repository_owner != 'gradle' }}
83+
run: ./gradlew --init-script .github/workflows/codeql-analysis.init.gradle -S testClasses
84+
85+
- name: Cleanup Gradle Daemons
86+
run: ./gradlew --stop
87+
if: ${{ matrix.language == 'java' }}
88+
89+
# ℹ️ Command-line programs to run using the OS shell.
90+
# 📚 https://git.io/JvXDl
91+
92+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
93+
# and modify them (or add more) to build your code if your project
94+
# uses a compiled language
95+
96+
#- run: |
97+
# make bootstrap
98+
# make release
99+
37100
- name: Perform CodeQL Analysis
38101
uses: github/codeql-action/analyze@v3
102+
with:
103+
config-file: ./.github/codeql/codeql-config.yml
104+
105+
- name: Cleanup Gradle Cache
106+
# Cleans up the Gradle caches before being cached
107+
run: |
108+
rm -f ~/.gradle/caches/modules-2/modules-2.lock
109+
rm -f ~/.gradle/caches/modules-2/gc.properties
110+
if: ${{ matrix.language == 'java' }}

0 commit comments

Comments
 (0)