Skip to content

Commit fa056db

Browse files
bestbeforetodaydenyeart
authored andcommitted
Upgrade Gradle version
Include build of the Docker image in tests run on a pull request to ensure the Docker image at least builds cleanly. The integration tests use builders baked into Microfab rather than real Fabric builders and the chaincode Docker images. This means the bare-gradle test chaincode is built using the Gradle version supplied by Microfab, not the version included in the Java chaincode Docker images, and has to be left with outdated plugin versions and build.gradle content. Signed-off-by: Mark S. Lewis <[email protected]>
1 parent 78e4b4b commit fa056db

File tree

31 files changed

+209
-160
lines changed

31 files changed

+209
-160
lines changed

.github/workflows/test.yml

+17-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ jobs:
2323
with:
2424
distribution: 'temurin'
2525
java-version: '11'
26-
cache: 'gradle'
2726
- name: Validate Gradle wrapper
2827
uses: gradle/wrapper-validation-action@v2
2928
- name: Build and Unit test
@@ -32,7 +31,7 @@ jobs:
3231
arguments: |
3332
:fabric-chaincode-shim:build
3433
35-
intergationtest:
34+
intergationtest:
3635
runs-on: ubuntu-latest
3736
steps:
3837
- uses: actions/checkout@v4
@@ -42,7 +41,6 @@ jobs:
4241
with:
4342
distribution: 'temurin'
4443
java-version: '11'
45-
cache: 'gradle'
4644
- name: Populate chaincode with latest java-version
4745
run: |
4846
./gradlew -I $GITHUB_WORKSPACE/fabric-chaincode-integration-test/chaincodebootstrap.gradle -PchaincodeRepoDir=$GITHUB_WORKSPACE/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/repository publishShimPublicationToFabricRepository
@@ -67,3 +65,19 @@ jobs:
6765
with:
6866
arguments: |
6967
:fabric-chaincode-integration-test:build
68+
69+
docker:
70+
runs-on: ubuntu-latest
71+
steps:
72+
- uses: actions/checkout@v4
73+
with:
74+
ref: ${{ inputs.checkout-ref }}
75+
- uses: actions/setup-java@v4
76+
with:
77+
distribution: 'temurin'
78+
java-version: '11'
79+
- name: Build Docker image
80+
uses: gradle/actions/setup-gradle@v3
81+
with:
82+
arguments: |
83+
:fabric-chaincode-docker:buildImage

build.gradle

+15-13
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,25 @@ subprojects {
3737
group = 'org.hyperledger.fabric-chaincode-java'
3838
version = rootProject.version
3939

40-
41-
sourceCompatibility = 1.8
42-
targetCompatibility = 1.8
40+
java {
41+
toolchain {
42+
languageVersion = JavaLanguageVersion.of(11)
43+
}
44+
}
4345

4446
dependencies {
45-
implementation group: 'commons-cli', name: 'commons-cli', version: '1.6.0'
46-
implementation group: 'commons-logging', name: 'commons-logging', version: '1.2'
47-
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.3.1'
48-
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.3.1'
47+
implementation 'commons-cli:commons-cli:1.6.0'
48+
implementation 'commons-logging:commons-logging:1.2'
49+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
50+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
4951

50-
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
51-
testImplementation group: 'org.mockito', name: 'mockito-core', version: '2.23.0'
52-
testImplementation group: 'com.github.stefanbirkner', name: 'system-rules', version: 'system-rules-1.17.0'
52+
testImplementation 'org.hamcrest:hamcrest-library:1.3'
53+
testImplementation 'org.mockito:mockito-core:2.23.0'
54+
testImplementation 'com.github.stefanbirkner:system-rules:system-rules-1.17.0'
5355

54-
testCompileOnly group: 'junit', name: 'junit', version: '4.12'
55-
testRuntimeOnly group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '5.3.1'
56-
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.9.1'
56+
testCompileOnly 'junit:junit:4.12'
57+
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.3.1'
58+
testImplementation 'org.assertj:assertj-core:3.9.1'
5759
}
5860

5961
test {

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

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
plugins {
2-
id 'com.github.johnrengelman.shadow' version '7.1.2'
2+
id 'com.github.johnrengelman.shadow' version '8.1.1'
33
id 'java'
44
}
55

66
version '0.0.1'
77

8-
sourceCompatibility = 1.8
8+
tasks.compileJava {
9+
options.release.set(11)
10+
}
911

1012
repositories {
1113
mavenLocal()
@@ -20,17 +22,17 @@ repositories {
2022
}
2123

2224
dependencies {
23-
compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.3.+'
25+
compile 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.1'
2426
compile 'org.json:json:20231013'
2527
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
2628
testImplementation 'org.assertj:assertj-core:3.11.1'
2729
testImplementation 'org.mockito:mockito-core:2.+'
2830
}
2931

3032
shadowJar {
31-
baseName = 'chaincode'
32-
version = null
33-
classifier = null
33+
archiveBaseName = 'chaincode'
34+
archiveVersion = ''
35+
archiveClassifier = ''
3436
mergeServiceFiles()
3537

3638
manifest {

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
55

66

77
plugins {
8-
id("com.github.johnrengelman.shadow") version "7.1.2"
9-
id("org.jetbrains.kotlin.jvm") version "1.3.41"
8+
id("com.github.johnrengelman.shadow") version "8.1.1"
9+
id("org.jetbrains.kotlin.jvm") version "1.9.22"
1010
}
1111

1212

@@ -41,9 +41,9 @@ repositories {
4141

4242
tasks {
4343
"shadowJar"(ShadowJar::class) {
44-
baseName = "chaincode"
45-
version = null
46-
classifier = null
44+
archiveBaseName = "chaincode"
45+
archiveVersion = ""
46+
archiveClassifier = ""
4747
mergeServiceFiles()
4848
manifest {
4949
attributes(mapOf("Main-Class" to "org.hyperledger.fabric.contract.ContractRouter"))
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
44
networkTimeout=10000
5+
validateDistributionUrl=true
56
zipStoreBase=GRADLE_USER_HOME
67
zipStorePath=wrapper/dists

examples/fabric-contract-example-gradle-kotlin/gradlew

+17-12
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,8 @@ done
8383
# This is normally unused
8484
# shellcheck disable=SC2034
8585
APP_BASE_NAME=${0##*/}
86-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
86+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87+
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
9088

9189
# Use the maximum available, or set MAX_FD != -1 to use that value.
9290
MAX_FD=maximum
@@ -133,26 +131,29 @@ location of your Java installation."
133131
fi
134132
else
135133
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134+
if ! command -v java >/dev/null 2>&1
135+
then
136+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137137
138138
Please set the JAVA_HOME variable in your environment to match the
139139
location of your Java installation."
140+
fi
140141
fi
141142

142143
# Increase the maximum file descriptors if we can.
143144
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144145
case $MAX_FD in #(
145146
max*)
146147
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147-
# shellcheck disable=SC3045
148+
# shellcheck disable=SC2039,SC3045
148149
MAX_FD=$( ulimit -H -n ) ||
149150
warn "Could not query maximum file descriptor limit"
150151
esac
151152
case $MAX_FD in #(
152153
'' | soft) :;; #(
153154
*)
154155
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155-
# shellcheck disable=SC3045
156+
# shellcheck disable=SC2039,SC3045
156157
ulimit -n "$MAX_FD" ||
157158
warn "Could not set maximum file descriptor limit to $MAX_FD"
158159
esac
@@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
197198
done
198199
fi
199200

200-
# Collect all arguments for the java command;
201-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
202-
# shell script including quotes and variable substitutions, so put them in
203-
# double quotes to make sure that they get re-expanded; and
204-
# * put everything else in single quotes, so that it's not re-expanded.
201+
202+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204+
205+
# Collect all arguments for the java command:
206+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207+
# and any embedded shellness will be escaped.
208+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209+
# treated as '${Hostname}' itself on the command line.
205210

206211
set -- \
207212
"-Dorg.gradle.appname=$APP_BASE_NAME" \

examples/fabric-contract-example-gradle-kotlin/gradlew.bat

+10-10
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
4343
%JAVA_EXE% -version >NUL 2>&1
4444
if %ERRORLEVEL% equ 0 goto execute
4545

46-
echo.
47-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48-
echo.
49-
echo Please set the JAVA_HOME variable in your environment to match the
50-
echo location of your Java installation.
46+
echo. 1>&2
47+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48+
echo. 1>&2
49+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50+
echo location of your Java installation. 1>&2
5151

5252
goto fail
5353

@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5757

5858
if exist "%JAVA_EXE%" goto execute
5959

60-
echo.
61-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62-
echo.
63-
echo Please set the JAVA_HOME variable in your environment to match the
64-
echo location of your Java installation.
60+
echo. 1>&2
61+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62+
echo. 1>&2
63+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64+
echo location of your Java installation. 1>&2
6565

6666
goto fail
6767

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

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
plugins {
2-
id 'com.github.johnrengelman.shadow' version '7.1.2'
2+
id 'com.github.johnrengelman.shadow' version '8.1.1'
33
id 'java'
44
}
55

66
version '0.0.1'
77

8-
sourceCompatibility = 1.8
8+
tasks.compileJava {
9+
options.release.set(11)
10+
}
911

1012
repositories {
1113
mavenLocal()
@@ -20,17 +22,17 @@ repositories {
2022
}
2123

2224
dependencies {
23-
compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.5.1'
25+
compile 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.1'
2426
compile 'org.json:json:20231013'
2527
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
2628
testImplementation 'org.assertj:assertj-core:3.11.1'
2729
testImplementation 'org.mockito:mockito-core:2.+'
2830
}
2931

3032
shadowJar {
31-
baseName = 'chaincode'
32-
version = null
33-
classifier = null
33+
archiveBaseName = 'chaincode'
34+
archiveVersion = ''
35+
archiveClassifier = ''
3436
mergeServiceFiles()
3537

3638
manifest {

examples/ledger-api/build.gradle

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
plugins {
2-
id 'com.github.johnrengelman.shadow' version '7.1.2'
2+
id 'com.github.johnrengelman.shadow' version '8.1.1'
33
id 'java'
44
}
55

66
version '0.0.1'
77

8-
sourceCompatibility = 1.8
8+
tasks.compileJava {
9+
options.release.set(11)
10+
}
911

1012
repositories {
1113
mavenLocal()
@@ -20,17 +22,17 @@ repositories {
2022
}
2123

2224
dependencies {
23-
compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.5'
25+
compile 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.1'
2426
compile 'org.json:json:20231013'
2527
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
2628
testImplementation 'org.assertj:assertj-core:3.11.1'
2729
testImplementation 'org.mockito:mockito-core:2.+'
2830
}
2931

3032
shadowJar {
31-
baseName = 'chaincode'
32-
version = null
33-
classifier = null
33+
archiveBaseName = 'chaincode'
34+
archiveVersion = ''
35+
archiveClassifier = ''
3436
mergeServiceFiles()
3537

3638
manifest {

fabric-chaincode-docker/Dockerfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM eclipse-temurin:11.0.21_9-jdk as builder
1+
FROM eclipse-temurin:11.0.22_7-jdk as builder
22
ENV DEBIAN_FRONTEND=noninteractive
33

44
# Build tools
@@ -10,10 +10,10 @@ RUN curl -s "https://get.sdkman.io" | bash
1010

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

13-
RUN source /root/.sdkman/bin/sdkman-init.sh; sdk install gradle 7.6.3
14-
RUN source /root/.sdkman/bin/sdkman-init.sh; sdk install maven 3.9.5
13+
RUN source /root/.sdkman/bin/sdkman-init.sh; sdk install gradle 8.6
14+
RUN source /root/.sdkman/bin/sdkman-init.sh; sdk install maven 3.9.6
1515

16-
FROM eclipse-temurin:11.0.21_9-jdk as dependencies
16+
FROM eclipse-temurin:11.0.22_7-jdk as dependencies
1717

1818
COPY --from=builder /root/.sdkman/candidates/gradle/current /usr/bin/gradle
1919
COPY --from=builder /root/.sdkman/candidates/maven/current /usr/bin/maven
@@ -53,7 +53,7 @@ RUN mvn -N io.takari:maven:wrapper
5353

5454
# Creating final javaenv image which will include all required
5555
# dependencies to build and compile java chaincode
56-
FROM eclipse-temurin:11.0.21_9-jdk
56+
FROM eclipse-temurin:11.0.22_7-jdk
5757

5858
RUN apt-get update \
5959
&& apt-get -y install zip unzip \

fabric-chaincode-docker/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ task copyAllDeps(type: Copy) {
6666
task buildImage(type: DockerBuildImage) {
6767
dependsOn copyAllDeps
6868
inputDir = project.file('Dockerfile').parentFile
69-
tags = ['hyperledger/fabric-javaenv', 'hyperledger/fabric-javaenv:amd64-2.5.1', 'hyperledger/fabric-javaenv:amd64-latest']
69+
tags = ['hyperledger/fabric-javaenv', 'hyperledger/fabric-javaenv:2.5', 'hyperledger/fabric-javaenv:amd64-2.5.1', 'hyperledger/fabric-javaenv:amd64-latest']
7070
}
7171

fabric-chaincode-integration-test/src/contracts/bare-gradle/build.gradle

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ plugins {
66
group 'org.hyperledger.fabric-chaincode-java'
77
version '1.0-SNAPSHOT'
88

9-
sourceCompatibility = 1.8
9+
tasks.compileJava {
10+
sourceCompatibility = '1.8'
11+
}
1012

1113
repositories {
1214
mavenLocal()
@@ -18,7 +20,7 @@ repositories {
1820
}
1921

2022
dependencies {
21-
implementation'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.1'
23+
implementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.1'
2224
implementation 'org.hyperledger.fabric:fabric-protos:0.2.+'
2325
}
2426

0 commit comments

Comments
 (0)