Skip to content

Commit 00dd567

Browse files
committed
Migrate the build system from Maven to Gradle
1 parent a685ed3 commit 00dd567

16 files changed

+694
-565
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +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.apache.maven.plugins:*"
23-
- "org.junit.jupiter:*"
24-
- "org.sonatype.plugins:*"
2510

2611
- package-ecosystem: "github-actions"
2712
directory: "/" # even for `.github/workflows`

.github/workflows/build_and_release_github.yml

Lines changed: 24 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -6,181 +6,44 @@ on:
66
- '*'
77

88
jobs:
9-
tagged-release:
10-
name: "Tagged Release"
11-
runs-on: "ubuntu-latest"
12-
13-
steps:
14-
- uses: "marvinpinto/action-automatic-releases@latest"
15-
id: create_release
16-
with:
17-
repo_token: "${{ secrets.GITHUB_TOKEN }}"
18-
prerelease: false
19-
draft: true
20-
21-
- name: Output Release URL File
22-
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt
23-
24-
- name: Save Release URL file for publish
25-
uses: actions/upload-artifact@v4
26-
with:
27-
name: release_url
28-
path: release_url.txt
29-
30-
- uses: little-core-labs/[email protected]
31-
id: tagName
32-
33-
- name: Output git tag
34-
run: echo "${{ steps.tagName.outputs.tag }}" > git_tag.txt
35-
36-
- name: Save git tag file for publish
37-
uses: actions/upload-artifact@v4
38-
with:
39-
name: git_tag
40-
path: git_tag.txt
41-
42-
build_and_upload:
43-
needs: tagged-release
44-
name: build_and_upload
9+
release:
4510
runs-on: ubuntu-latest
11+
if: startsWith(github.ref, 'refs/tags/')
4612
steps:
4713
- uses: actions/checkout@v4
48-
- name: maven-settings-xml-action
49-
uses: whelk-io/maven-settings-xml-action@v22
50-
with:
51-
repositories: >
52-
[
53-
{
54-
"id": "central",
55-
"url": "https://repo1.maven.org/maven2"
56-
},
57-
{
58-
"id": "github",
59-
"url": "https://maven.pkg.github.com/bitwarden/sdk",
60-
"releases": {
61-
"enabled": "true"
62-
},
63-
"snapshots": {
64-
"enabled": "true"
65-
}
66-
}
67-
]
68-
servers: >
69-
[
70-
{
71-
"id": "github",
72-
"username": "${env.PACKAGES_USER}",
73-
"password": "${env.PACKAGES_ACCESS_TOKEN}",
74-
"configuration": {
75-
"httpConfiguration": {
76-
"all": {
77-
"usePreemptive": "true"
78-
}
79-
}
80-
}
81-
}
82-
]
83-
profiles: >
84-
[
85-
{
86-
"id": "github"
87-
}
88-
]
89-
active_profiles: >
90-
[
91-
"github"
92-
]
93-
output_file: .m2/settings.xml
14+
9415
- uses: actions/setup-java@v4
9516
with:
9617
distribution: 'temurin'
9718
java-version: '20'
98-
cache: 'maven'
99-
overwrite-settings: 'false'
100-
- name: Set up GPG
101-
run: |
102-
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
103-
env:
104-
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
105-
- name: Build with Maven
106-
run: mvn -B -Psign -Dgpg.passphrase=${GPG_PASSPHRASE} -Dtest=org.purejava.integrations.keychain.BitwardenAccessTest install --settings ${{ github.workspace }}/.m2/settings.xml --file pom.xml
107-
env:
108-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
109-
PACKAGES_USER: ${{ secrets.PACKAGES_USER }}
110-
PACKAGES_ACCESS_TOKEN: ${{ secrets.PACKAGES_ACCESS_TOKEN }}
11119

112-
- name: Load Release URL File from release job
113-
uses: actions/download-artifact@v4
114-
with:
115-
name: release_url
116-
- name: Get Release File Name & Upload URL
117-
id: get_release_info
118-
run: |
119-
value=`cat release_url.txt`
120-
echo ::set-output name=upload_url::$value
121-
- name: Load git tag from release job
122-
uses: actions/download-artifact@v4
123-
with:
124-
name: git_tag
125-
- name: Get git tag info
126-
id: get_tag_info
127-
run: |
128-
value=`cat git_tag.txt`
129-
echo ::set-output name=git_tag::$value
20+
- name: Setup Gradle
21+
uses: gradle/actions/setup-gradle@v4
13022

131-
- name: Sign uber jar with key 5BFB2076ABC48776
132-
run: |
133-
echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 5BFB2076ABC48776 --detach-sign ./target/cryptomator-bitwarden-${{ steps.get_tag_info.outputs.git_tag }}.jar
134-
env:
135-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
136-
- name: Sign source tarball with key 5BFB2076ABC48776
137-
if: startsWith(github.ref, 'refs/tags/')
23+
- name: Import GPG key
13824
run: |
139-
git archive --prefix="cryptomator-bitwarden-${{ github.ref_name }}/" -o "cryptomator-bitwarden-${{ github.ref_name }}.tar.gz" ${{ github.ref }}
140-
echo "${GPG_PASSPHRASE}" | gpg --batch --quiet --passphrase-fd 0 --pinentry-mode loopback -u 5BFB2076ABC48776 --detach-sign cryptomator-bitwarden-*.tar.gz
25+
echo "$GPG_SIGNING_KEY_PW" | gpg --batch --import --yes --passphrase-fd 0 <(echo -n "$GPG_SIGNING_KEY_B64" | base64 --decode)
14126
env:
142-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
27+
GPG_SIGNING_KEY_B64: ${{ secrets.GPG_PRIVATE_KEY_B64 }}
28+
GPG_SIGNING_KEY_PW: ${{ secrets.GPG_PASSPHRASE }}
14329

144-
- name: Upload uber jar
145-
id: upload-release-asset
146-
uses: actions/[email protected]
30+
- name: Setup GPG key information
31+
run: |
32+
mkdir -p ~/.gradle ~/.gnupg
33+
echo "signing.gnupg.homeDir=/home/runner/.gnupg" >> ~/.gradle/gradle.properties
34+
echo "signing.gnupg.executable=gpg" >> ~/.gradle/gradle.properties
35+
echo "signing.gnupg.keyName=ABC48776" >> ~/.gradle/gradle.properties
36+
echo "signing.gnupg.passphrase=${GPG_SIGNING_KEY_PW}" >> ~/.gradle/gradle.properties
14737
env:
148-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149-
with:
150-
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
151-
asset_path: ./target/cryptomator-bitwarden-${{ steps.get_tag_info.outputs.git_tag }}.jar
152-
asset_name: cryptomator-bitwarden-${{ steps.get_tag_info.outputs.git_tag }}.jar
153-
asset_content_type: application/java-archive
38+
GPG_SIGNING_KEY_PW: ${{ secrets.GPG_PASSPHRASE }}
15439

155-
- name: Upload signature file for uber jar
156-
id: upload-signature-file-for-uber-jar
157-
uses: actions/[email protected]
40+
- name: Build package
41+
run: ./gradlew clean build
15842
env:
159-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
160-
with:
161-
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
162-
asset_path: ./target/cryptomator-bitwarden-${{ steps.get_tag_info.outputs.git_tag }}.jar.sig
163-
asset_name: cryptomator-bitwarden-${{ steps.get_tag_info.outputs.git_tag }}.jar.sig
164-
asset_content_type: application/pgp-signature
43+
GPG_SIGNING_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
44+
GPG_SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
16545

166-
- name: Upload tarball
167-
id: upload-release-asset-2
168-
uses: actions/[email protected]
46+
- name: Release package
47+
run: ./gradlew githubRelease
16948
env:
170-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
171-
with:
172-
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
173-
asset_path: ./cryptomator-bitwarden-${{ steps.get_tag_info.outputs.git_tag }}.tar.gz
174-
asset_name: cryptomator-bitwarden-${{ steps.get_tag_info.outputs.git_tag }}.tar.gz
175-
asset_content_type: application/tar+gzip
176-
177-
- name: Upload signature file for source tarball
178-
id: upload-signature-file-for-source-tarball
179-
uses: actions/[email protected]
180-
env:
181-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
182-
with:
183-
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
184-
asset_path: ./cryptomator-bitwarden-${{ steps.get_tag_info.outputs.git_tag }}.tar.gz.sig
185-
asset_name: cryptomator-bitwarden-${{ steps.get_tag_info.outputs.git_tag }}.tar.gz.sig
186-
asset_content_type: application/pgp-signature
49+
RELEASE_GRADLE_PLUGIN_TOKEN: ${{ secrets.RELEASE_GRADLE_PLUGIN_TOKEN }}
Lines changed: 25 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,43 @@
1-
name: Java CI with Maven
1+
name: Java CI with Gradle
22

33
on:
44
push:
55
branches: [develop]
66

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

1211
steps:
1312
- uses: actions/checkout@v4
14-
- name: maven-settings-xml-action
15-
uses: whelk-io/maven-settings-xml-action@v22
16-
with:
17-
repositories: >
18-
[
19-
{
20-
"id": "central",
21-
"url": "https://repo1.maven.org/maven2"
22-
},
23-
{
24-
"id": "github",
25-
"url": "https://maven.pkg.github.com/bitwarden/sdk",
26-
"releases": {
27-
"enabled": "true"
28-
},
29-
"snapshots": {
30-
"enabled": "true"
31-
}
32-
}
33-
]
34-
servers: >
35-
[
36-
{
37-
"id": "github",
38-
"username": "${env.PACKAGES_USER}",
39-
"password": "${env.PACKAGES_ACCESS_TOKEN}",
40-
"configuration": {
41-
"httpConfiguration": {
42-
"all": {
43-
"usePreemptive": "true"
44-
}
45-
}
46-
}
47-
}
48-
]
49-
profiles: >
50-
[
51-
{
52-
"id": "github"
53-
}
54-
]
55-
active_profiles: >
56-
[
57-
"github"
58-
]
59-
output_file: .m2/settings.xml
13+
6014
- uses: actions/setup-java@v4
6115
with:
6216
distribution: 'temurin'
6317
java-version: '20'
64-
cache: 'maven'
65-
overwrite-settings: 'false'
66-
- name: Set up GPG
18+
19+
- name: Setup Gradle
20+
uses: gradle/actions/setup-gradle@v4
21+
22+
- name: Import GPG key
6723
run: |
68-
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)
6925
env:
70-
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
71-
- name: Build with Maven
72-
run: mvn -s ${{ github.workspace }}/.m2/settings.xml -B -Psign -Dgpg.passphrase=${GPG_PASSPHRASE} -Dtest=org.purejava.integrations.keychain.BitwardenAccessTest 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
7341
env:
74-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
75-
PACKAGES_USER: ${{ secrets.PACKAGES_USER }}
76-
PACKAGES_ACCESS_TOKEN: ${{ secrets.PACKAGES_ACCESS_TOKEN }}
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+
}

0 commit comments

Comments
 (0)