Skip to content

Commit

Permalink
Restore Java 8 compatibility (#349)
Browse files Browse the repository at this point in the history
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 <Mark.S.Lewis@outlook.com>
  • Loading branch information
bestbeforetoday authored May 23, 2024
1 parent d384208 commit 6615ebb
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 40 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
ref: ${{ inputs.checkout-ref }}
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
distribution: temurin
java-version: 11
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v3
- uses: gradle/actions/setup-gradle@v3
Expand All @@ -37,8 +37,8 @@ jobs:
ref: ${{ inputs.checkout-ref }}
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
distribution: temurin
java-version: 11
- name: Populate chaincode with latest java-version
run: |
./gradlew -I $GITHUB_WORKSPACE/fabric-chaincode-integration-test/chaincodebootstrap.gradle -PchaincodeRepoDir=$GITHUB_WORKSPACE/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/repository publishShimPublicationToFabricRepository
Expand Down Expand Up @@ -70,8 +70,8 @@ jobs:
ref: ${{ inputs.checkout-ref }}
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
distribution: temurin
java-version: 11
- uses: gradle/actions/setup-gradle@v3
- name: Build Docker image
run: ./gradlew :fabric-chaincode-docker:buildImage
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Make sure you have the following prereqs installed:

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

> **Note:** Java can be installed using [sdkman](https://sdkman.io/).
Expand Down
12 changes: 7 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

apply plugin: 'idea'
apply plugin: 'eclipse-wtp'
version = '2.5.2'
version = '2.5.3'


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

java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
sourceCompatibility = JavaVersion.VERSION_1_8
}

compileJava {
if (javaCompiler.get().metadata.languageVersion.canCompileOrRun(10)) {
options.release = 8
}
}

Expand Down
1 change: 0 additions & 1 deletion examples/fabric-contract-example-as-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ tasks.compileJava {
}

repositories {
mavenLocal()
mavenCentral()
maven {
url "https://www.jitpack.io"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ plugins {

version = "0.0.1"

java {
sourceCompatibility = JavaVersion.VERSION_1_8
}


dependencies {
implementation("org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.2")
implementation("org.json:json:20231013")
Expand All @@ -28,9 +23,7 @@ dependencies {
}

repositories {
mavenLocal()
mavenCentral()
jcenter()
maven {
setUrl("https://jitpack.io")
}
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-contract-example-gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ tasks.compileJava {
}

repositories {
mavenLocal()
mavenCentral()
maven {
url "https://www.jitpack.io"
Expand Down
2 changes: 1 addition & 1 deletion examples/fabric-contract-example-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<!-- fabric-chaincode-java -->
<fabric-chaincode-java.version>2.5.2</fabric-chaincode-java.version>
<fabric-chaincode-java.version>2.5.3</fabric-chaincode-java.version>

<!-- Logging -->
<logback.version>1.3.14</logback.version>
Expand Down
1 change: 0 additions & 1 deletion examples/ledger-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ tasks.compileJava {
}

repositories {
mavenLocal()
mavenCentral()
maven {
url "https://www.jitpack.io"
Expand Down
2 changes: 1 addition & 1 deletion fabric-chaincode-docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ RUN apt-get update \

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

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

Expand Down
4 changes: 1 addition & 3 deletions fabric-chaincode-docker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

buildscript {
repositories {
mavenLocal()
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://www.jitpack.io" }
mavenCentral()
Expand Down Expand Up @@ -66,6 +64,6 @@ task copyAllDeps(type: Copy) {
task buildImage(type: DockerBuildImage) {
dependsOn copyAllDeps
inputDir = project.file('Dockerfile').parentFile
tags = ['hyperledger/fabric-javaenv', 'hyperledger/fabric-javaenv:2.5', 'hyperledger/fabric-javaenv:amd64-2.5.2', 'hyperledger/fabric-javaenv:amd64-latest']
tags = ['hyperledger/fabric-javaenv', 'hyperledger/fabric-javaenv:2.5', 'hyperledger/fabric-javaenv:amd64-2.5.3', 'hyperledger/fabric-javaenv:amd64-latest']
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ plugins {
group 'org.hyperledger.fabric-chaincode-java'
version '1.0-SNAPSHOT'

tasks.compileJava {
sourceCompatibility = '1.8'
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}

repositories {
mavenLocal()
mavenCentral()
maven { url = "https://www.jitpack.io" }
maven {
Expand All @@ -20,7 +19,7 @@ repositories {
}

dependencies {
implementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.1'
implementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.3'
implementation 'org.hyperledger.fabric:fabric-protos:0.3.3'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<!-- fabric-chaincode-java -->
<fabric-chaincode-java.version>2.5.1</fabric-chaincode-java.version>
<fabric-chaincode-java.version>2.5.3</fabric-chaincode-java.version>

</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ plugins {
group 'org.hyperledger.fabric-chaincode-java'
version '1.0-SNAPSHOT'

tasks.compileJava {
options.release.set(8)
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}

compileJava {
if (javaCompiler.get().metadata.languageVersion.canCompileOrRun(10)) {
options.release = 8
}
}

repositories {
mavenLocal()
mavenCentral()
maven { url = "https://www.jitpack.io" }
maven {
Expand All @@ -20,7 +25,7 @@ repositories {
}

dependencies {
implementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.1'
implementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.3'
implementation 'org.hyperledger.fabric:fabric-protos:0.3.3'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ plugins {
group 'org.hyperledger.fabric-chaincode-java'
version '1.0-SNAPSHOT'

tasks.compileJava {
options.release.set(8)
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}

compileJava {
if (javaCompiler.get().metadata.languageVersion.canCompileOrRun(10)) {
options.release = 8
}
}

repositories {
Expand All @@ -19,7 +25,7 @@ repositories {
}

dependencies {
implementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.1'
implementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.3'
implementation 'org.hyperledger.fabric:fabric-protos:0.3.3'
implementation 'commons-logging:commons-logging:1.2'
implementation 'com.google.code.gson:gson:2.10.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<!-- fabric-chaincode-java -->
<fabric-chaincode-java.version>2.5.1</fabric-chaincode-java.version>
<fabric-chaincode-java.version>2.5.3</fabric-chaincode-java.version>

</properties>

Expand Down

0 comments on commit 6615ebb

Please sign in to comment.