Skip to content

Commit 6615ebb

Browse files
Restore Java 8 compatibility (#349)
Build with source and target bytecode compatibility for Java 8. This allows chaincode implementation code that requires Java 8 compatibility to compile against the fabric-chaincode-shim package. Avoid use of mavenLocal() and (deprecated) jcenter() Gradle repositories. Signed-off-by: Mark S. Lewis <[email protected]>
1 parent d384208 commit 6615ebb

File tree

15 files changed

+40
-40
lines changed

15 files changed

+40
-40
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ jobs:
2121
ref: ${{ inputs.checkout-ref }}
2222
- uses: actions/setup-java@v4
2323
with:
24-
distribution: 'temurin'
25-
java-version: '11'
24+
distribution: temurin
25+
java-version: 11
2626
- name: Validate Gradle wrapper
2727
uses: gradle/actions/wrapper-validation@v3
2828
- uses: gradle/actions/setup-gradle@v3
@@ -37,8 +37,8 @@ jobs:
3737
ref: ${{ inputs.checkout-ref }}
3838
- uses: actions/setup-java@v4
3939
with:
40-
distribution: 'temurin'
41-
java-version: '11'
40+
distribution: temurin
41+
java-version: 11
4242
- name: Populate chaincode with latest java-version
4343
run: |
4444
./gradlew -I $GITHUB_WORKSPACE/fabric-chaincode-integration-test/chaincodebootstrap.gradle -PchaincodeRepoDir=$GITHUB_WORKSPACE/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/repository publishShimPublicationToFabricRepository
@@ -70,8 +70,8 @@ jobs:
7070
ref: ${{ inputs.checkout-ref }}
7171
- uses: actions/setup-java@v4
7272
with:
73-
distribution: 'temurin'
74-
java-version: '11'
73+
distribution: temurin
74+
java-version: 11
7575
- uses: gradle/actions/setup-gradle@v3
7676
- name: Build Docker image
7777
run: ./gradlew :fabric-chaincode-docker:buildImage

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Make sure you have the following prereqs installed:
6666

6767
- [Docker](https://www.docker.com/get-docker)
6868
- [Docker Compose](https://docs.docker.com/compose/install/)
69-
- [JDK 8](https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html)
69+
- [JDK 11](https://adoptium.net/)
7070

7171
> **Note:** Java can be installed using [sdkman](https://sdkman.io/).
7272

build.gradle

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
apply plugin: 'idea'
88
apply plugin: 'eclipse-wtp'
9-
version = '2.5.2'
9+
version = '2.5.3'
1010

1111

1212
// If the nightly property is set, then this is the scheduled main
@@ -23,8 +23,6 @@ if (properties.containsKey('NIGHTLY')) {
2323
allprojects {
2424
repositories {
2525
mavenCentral()
26-
mavenLocal()
27-
jcenter()
2826
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
2927
maven { url "https://www.jitpack.io" }
3028
}
@@ -38,8 +36,12 @@ subprojects {
3836
version = rootProject.version
3937

4038
java {
41-
toolchain {
42-
languageVersion = JavaLanguageVersion.of(11)
39+
sourceCompatibility = JavaVersion.VERSION_1_8
40+
}
41+
42+
compileJava {
43+
if (javaCompiler.get().metadata.languageVersion.canCompileOrRun(10)) {
44+
options.release = 8
4345
}
4446
}
4547

examples/fabric-contract-example-as-service/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ tasks.compileJava {
1010
}
1111

1212
repositories {
13-
mavenLocal()
1413
mavenCentral()
1514
maven {
1615
url "https://www.jitpack.io"

examples/fabric-contract-example-gradle-kotlin/build.gradle.kts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ plugins {
1313

1414
version = "0.0.1"
1515

16-
java {
17-
sourceCompatibility = JavaVersion.VERSION_1_8
18-
}
19-
20-
2116
dependencies {
2217
implementation("org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.2")
2318
implementation("org.json:json:20231013")
@@ -28,9 +23,7 @@ dependencies {
2823
}
2924

3025
repositories {
31-
mavenLocal()
3226
mavenCentral()
33-
jcenter()
3427
maven {
3528
setUrl("https://jitpack.io")
3629
}

examples/fabric-contract-example-gradle/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ tasks.compileJava {
1010
}
1111

1212
repositories {
13-
mavenLocal()
1413
mavenCentral()
1514
maven {
1615
url "https://www.jitpack.io"

examples/fabric-contract-example-maven/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
1313

1414
<!-- fabric-chaincode-java -->
15-
<fabric-chaincode-java.version>2.5.2</fabric-chaincode-java.version>
15+
<fabric-chaincode-java.version>2.5.3</fabric-chaincode-java.version>
1616

1717
<!-- Logging -->
1818
<logback.version>1.3.14</logback.version>

examples/ledger-api/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ tasks.compileJava {
1010
}
1111

1212
repositories {
13-
mavenLocal()
1413
mavenCentral()
1514
maven {
1615
url "https://www.jitpack.io"

fabric-chaincode-docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ RUN apt-get update \
6464

6565
SHELL ["/bin/bash", "-c"]
6666

67-
# Copy setup scripts, and the cached dependeices
67+
# Copy setup scripts, and the cached dependencies
6868
COPY --from=dependencies /root/chaincode-java /root/chaincode-java
6969
COPY --from=dependencies /root/.m2 /root/.m2
7070

fabric-chaincode-docker/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
buildscript {
88
repositories {
9-
mavenLocal()
10-
jcenter()
119
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
1210
maven { url "https://www.jitpack.io" }
1311
mavenCentral()
@@ -66,6 +64,6 @@ task copyAllDeps(type: Copy) {
6664
task buildImage(type: DockerBuildImage) {
6765
dependsOn copyAllDeps
6866
inputDir = project.file('Dockerfile').parentFile
69-
tags = ['hyperledger/fabric-javaenv', 'hyperledger/fabric-javaenv:2.5', 'hyperledger/fabric-javaenv:amd64-2.5.2', 'hyperledger/fabric-javaenv:amd64-latest']
67+
tags = ['hyperledger/fabric-javaenv', 'hyperledger/fabric-javaenv:2.5', 'hyperledger/fabric-javaenv:amd64-2.5.3', 'hyperledger/fabric-javaenv:amd64-latest']
7068
}
7169

0 commit comments

Comments
 (0)