Skip to content

Commit ef36056

Browse files
authored
refactor: upgrade gradle & java compatibility (#167)
1 parent 842045f commit ef36056

8 files changed

Lines changed: 226 additions & 170 deletions

File tree

.github/workflows/integration-test.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ jobs:
1111

1212
steps:
1313
- name: Checkout code
14-
uses: actions/checkout@v2
14+
uses: actions/checkout@v3
1515

1616
- name: Use Java Version ${{ matrix.java }}
17-
uses: actions/setup-java@v2
17+
uses: actions/setup-java@v3
1818
with:
19-
distribution: "zulu"
19+
distribution: "temurin"
2020
java-version: ${{ matrix.java }}
2121
cache: "gradle"
2222

23-
- name: Install
24-
run: gradle dependencies
23+
- name: Install Dependencies
24+
run: ./gradlew dependencies
2525

26-
- name: Test
27-
run: gradle integrationTest
26+
- name: Run Integration Tests
27+
run: ./gradlew integrationTest
2828
env:
2929
INTEGRATION_TESTS_MNEMONIC: ${{ secrets.MNEMONIC }}

.github/workflows/release.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Publish package to the Maven Central Repository
2+
23
on:
34
release:
45
types: [created]
@@ -18,16 +19,16 @@ jobs:
1819
packages: write
1920

2021
steps:
21-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v3
2223

2324
- name: Set up Java
24-
uses: actions/setup-java@v2
25+
uses: actions/setup-java@v3
2526
with:
26-
java-version: '8'
27-
distribution: 'adopt'
27+
java-version: "17"
28+
distribution: "temurin"
2829

2930
- name: Publish to the Maven Central Repository
30-
run: gradle publish
31+
run: ./gradlew publish
3132
env:
3233
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SIGNING_KEY }}
3334
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_SIGNING_PASSWORD }}

.github/workflows/test.yml

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,19 @@ jobs:
1414

1515
steps:
1616
- name: Checkout code
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v3
1818
with:
1919
ref: ${{ github.head_ref }}
2020

21-
- name: Merge Conflict finder
22-
uses: olivernybroe/action-conflict-finder@v1.1
23-
24-
- name: Use Java Version 8
25-
uses: actions/setup-java@v2
21+
- name: Use Java 17
22+
uses: actions/setup-java@v3
2623
with:
27-
distribution: "adopt"
28-
java-version: 8
24+
distribution: "temurin"
25+
java-version: "17"
2926
cache: "gradle"
3027

3128
- name: Format code
32-
run: gradle format
29+
run: ./gradlew formatCode
3330

3431
- name: Commit fixed code
3532
uses: stefanzweifel/git-auto-commit-action@v4
@@ -41,30 +38,48 @@ jobs:
4138
runs-on: ubuntu-latest
4239
strategy:
4340
matrix:
44-
# test against the latest update of each major Java version, as well as specific updates of LTS versions:
45-
java: [8, 11, 15, 16, 17, 18, 19, 20, 21, 22]
41+
java: [17, 18, 19, 20, 21]
4642

4743
steps:
4844
- name: Checkout code
49-
uses: actions/checkout@v2
45+
uses: actions/checkout@v3
5046
with:
5147
ref: ${{ github.head_ref }}
5248

53-
- name: Merge Conflict finder
54-
uses: olivernybroe/action-conflict-finder@v1.1
55-
5649
- name: Use Java Version ${{ matrix.java }}
57-
uses: actions/setup-java@v2
50+
uses: actions/setup-java@v3
5851
with:
59-
distribution: "zulu"
52+
distribution: "temurin"
6053
java-version: ${{ matrix.java }}
6154
cache: "gradle"
6255

63-
- name: Install
64-
run: gradle dependencies
56+
- name: Install Dependencies
57+
run: ./gradlew dependencies
6558

66-
- name: Test
67-
run: gradle test && gradle jacocoTestReport
59+
- name: Run Tests
60+
run: ./gradlew test jacocoTestReport
61+
62+
- name: Upload Test Results
63+
uses: actions/upload-artifact@v3
64+
with:
65+
name: test-results
66+
path: build/reports/tests/test
67+
68+
- name: Upload Coverage Report
69+
uses: actions/upload-artifact@v3
70+
with:
71+
name: code-coverage-report
72+
path: build/reports/jacoco/test/html
73+
74+
- name: Upload Jacoco XML Report
75+
uses: actions/upload-artifact@v3
76+
with:
77+
name: jacoco-xml-report
78+
path: build/reports/jacoco/test/jacocoTestReport.xml
6879

6980
- name: Codecov
70-
run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}
81+
uses: codecov/codecov-action@v3
82+
with:
83+
token: ${{ secrets.CODECOV_TOKEN }}
84+
files: build/reports/jacoco/test/jacocoTestReport.xml
85+
fail_ci_if_error: true

build.gradle

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@ plugins {
33
id 'maven-publish'
44
id 'signing'
55
id 'jacoco'
6-
id 'com.diffplug.spotless' version '5.6.1'
6+
id 'com.diffplug.spotless' version '6.25.0'
77
}
88

99
group = 'org.arkecosystem'
10-
version = '2.0.0'
11-
12-
sourceCompatibility = 1.8
13-
targetCompatibility = 1.8
10+
version = '2.0.0-mainsail'
1411

1512
repositories {
1613
mavenLocal()
@@ -30,9 +27,9 @@ configurations {
3027
}
3128

3229
dependencies {
33-
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.8.1'
34-
implementation group: 'com.squareup.okhttp3', name: 'mockwebserver', version: '4.9.0'
35-
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
30+
implementation 'com.squareup.okhttp3:okhttp:4.8.1'
31+
implementation 'com.squareup.okhttp3:mockwebserver:4.9.0'
32+
implementation 'com.google.code.gson:gson:2.8.6'
3633

3734
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2'
3835
testImplementation 'org.hamcrest:hamcrest-library:2.2'
@@ -41,14 +38,16 @@ dependencies {
4138
integrationImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2'
4239
integrationImplementation 'org.junit.jupiter:junit-jupiter-engine:5.7.2'
4340
integrationImplementation 'org.hamcrest:hamcrest-library:2.2'
44-
integrationImplementation 'org.arkecosystem:crypto:2.0.0'
4541
integrationCompileOnly 'org.slf4j:slf4j-api:1.7.32'
4642
integrationRuntimeOnly 'org.slf4j:slf4j-simple:1.7.32'
4743
integrationImplementation 'com.github.rholder:guava-retrying:2.0.0'
48-
integrationImplementation "cash.z.ecc.android:kotlin-bip39:1.0.2"
44+
integrationImplementation 'cash.z.ecc.android:kotlin-bip39:1.0.2'
4945
}
5046

5147
java {
48+
toolchain {
49+
languageVersion = JavaLanguageVersion.of(17)
50+
}
5251
withJavadocJar()
5352
withSourcesJar()
5453
}
@@ -74,25 +73,13 @@ spotless {
7473
include 'src/test/**/*.java'
7574
exclude '**/build/**'
7675
}
77-
googleJavaFormat('1.1').aosp()
76+
googleJavaFormat('1.17.0').aosp()
7877
removeUnusedImports()
7978
}
8079
}
8180

8281
task formatCode(dependsOn: ['spotlessApply'])
8382

84-
task fatJar(type: Jar) {
85-
manifest.from jar.manifest
86-
from {
87-
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
88-
} {
89-
exclude "META-INF/*.SF"
90-
exclude "META-INF/*.DSA"
91-
exclude "META-INF/*.RSA"
92-
}
93-
with jar
94-
}
95-
9683
build.dependsOn 'spotlessApply'
9784

9885
tasks.register('integrationTest', Test) {
@@ -107,18 +94,16 @@ tasks.register('integrationTest', Test) {
10794
}
10895

10996
wrapper {
110-
gradleVersion = '7.2'
97+
gradleVersion = '8.4.1'
11198
}
11299

113100
publishing {
114101
publications {
115102
mavenJava(MavenPublication) {
116103
from components.java
117-
pom {
118-
groupId = project.group
119-
version = project.version
120-
artifactId = 'client'
104+
artifactId = 'client'
121105

106+
pom {
122107
name = 'java-client'
123108
description = 'A Simple REST API Client Implementation in Java for the ARK CORE Blockchain Framework.'
124109
url = 'https://sdk.ark.dev/java/client'
@@ -181,8 +166,14 @@ publishing {
181166
}
182167

183168
signing {
169+
// Only sign when publishing to remote repository
170+
required { gradle.taskGraph.hasTask("publish") && !gradle.taskGraph.hasTask("publishToMavenLocal") }
171+
184172
def signingKey = findProperty("signingKey")
185173
def signingPassword = findProperty("signingPassword")
186-
useInMemoryPgpKeys(signingKey as String, signingPassword as String)
187-
sign publishing.publications.mavenJava
174+
175+
if (signingKey && signingPassword) {
176+
useInMemoryPgpKeys(signingKey as String, signingPassword as String)
177+
sign publishing.publications.mavenJava
178+
}
188179
}

gradle/wrapper/gradle-wrapper.jar

333 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)