Skip to content

Commit

Permalink
Upgrade Gradle version
Browse files Browse the repository at this point in the history
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 <Mark.S.Lewis@outlook.com>
  • Loading branch information
bestbeforetoday authored and denyeart committed Feb 27, 2024
1 parent 78e4b4b commit fa056db
Show file tree
Hide file tree
Showing 31 changed files with 209 additions and 160 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
with:
distribution: 'temurin'
java-version: '11'
cache: 'gradle'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Build and Unit test
Expand All @@ -32,7 +31,7 @@ jobs:
arguments: |
:fabric-chaincode-shim:build
intergationtest:
intergationtest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -42,7 +41,6 @@ jobs:
with:
distribution: 'temurin'
java-version: '11'
cache: 'gradle'
- 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 All @@ -67,3 +65,19 @@ jobs:
with:
arguments: |
:fabric-chaincode-integration-test:build
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.checkout-ref }}
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
- name: Build Docker image
uses: gradle/actions/setup-gradle@v3
with:
arguments: |
:fabric-chaincode-docker:buildImage
28 changes: 15 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,25 @@ subprojects {
group = 'org.hyperledger.fabric-chaincode-java'
version = rootProject.version


sourceCompatibility = 1.8
targetCompatibility = 1.8
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}

dependencies {
implementation group: 'commons-cli', name: 'commons-cli', version: '1.6.0'
implementation group: 'commons-logging', name: 'commons-logging', version: '1.2'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.3.1'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.3.1'
implementation 'commons-cli:commons-cli:1.6.0'
implementation 'commons-logging:commons-logging:1.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'

testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
testImplementation group: 'org.mockito', name: 'mockito-core', version: '2.23.0'
testImplementation group: 'com.github.stefanbirkner', name: 'system-rules', version: 'system-rules-1.17.0'
testImplementation 'org.hamcrest:hamcrest-library:1.3'
testImplementation 'org.mockito:mockito-core:2.23.0'
testImplementation 'com.github.stefanbirkner:system-rules:system-rules-1.17.0'

testCompileOnly group: 'junit', name: 'junit', version: '4.12'
testRuntimeOnly group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '5.3.1'
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.9.1'
testCompileOnly 'junit:junit:4.12'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.3.1'
testImplementation 'org.assertj:assertj-core:3.9.1'
}

test {
Expand Down
14 changes: 8 additions & 6 deletions examples/fabric-contract-example-as-service/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'java'
}

version '0.0.1'

sourceCompatibility = 1.8
tasks.compileJava {
options.release.set(11)
}

repositories {
mavenLocal()
Expand All @@ -20,17 +22,17 @@ repositories {
}

dependencies {
compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.3.+'
compile 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.1'
compile 'org.json:json:20231013'
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
testImplementation 'org.assertj:assertj-core:3.11.1'
testImplementation 'org.mockito:mockito-core:2.+'
}

shadowJar {
baseName = 'chaincode'
version = null
classifier = null
archiveBaseName = 'chaincode'
archiveVersion = ''
archiveClassifier = ''
mergeServiceFiles()

manifest {
Expand Down
10 changes: 5 additions & 5 deletions examples/fabric-contract-example-gradle-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar


plugins {
id("com.github.johnrengelman.shadow") version "7.1.2"
id("org.jetbrains.kotlin.jvm") version "1.3.41"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("org.jetbrains.kotlin.jvm") version "1.9.22"
}


Expand Down Expand Up @@ -41,9 +41,9 @@ repositories {

tasks {
"shadowJar"(ShadowJar::class) {
baseName = "chaincode"
version = null
classifier = null
archiveBaseName = "chaincode"
archiveVersion = ""
archiveClassifier = ""
mergeServiceFiles()
manifest {
attributes(mapOf("Main-Class" to "org.hyperledger.fabric.contract.ContractRouter"))
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 17 additions & 12 deletions examples/fabric-contract-example-gradle-kotlin/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 10 additions & 10 deletions examples/fabric-contract-example-gradle-kotlin/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

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

goto fail

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

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
14 changes: 8 additions & 6 deletions examples/fabric-contract-example-gradle/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'java'
}

version '0.0.1'

sourceCompatibility = 1.8
tasks.compileJava {
options.release.set(11)
}

repositories {
mavenLocal()
Expand All @@ -20,17 +22,17 @@ repositories {
}

dependencies {
compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.5.1'
compile 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.1'
compile 'org.json:json:20231013'
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
testImplementation 'org.assertj:assertj-core:3.11.1'
testImplementation 'org.mockito:mockito-core:2.+'
}

shadowJar {
baseName = 'chaincode'
version = null
classifier = null
archiveBaseName = 'chaincode'
archiveVersion = ''
archiveClassifier = ''
mergeServiceFiles()

manifest {
Expand Down
14 changes: 8 additions & 6 deletions examples/ledger-api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'java'
}

version '0.0.1'

sourceCompatibility = 1.8
tasks.compileJava {
options.release.set(11)
}

repositories {
mavenLocal()
Expand All @@ -20,17 +22,17 @@ repositories {
}

dependencies {
compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.5'
compile 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.1'
compile 'org.json:json:20231013'
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
testImplementation 'org.assertj:assertj-core:3.11.1'
testImplementation 'org.mockito:mockito-core:2.+'
}

shadowJar {
baseName = 'chaincode'
version = null
classifier = null
archiveBaseName = 'chaincode'
archiveVersion = ''
archiveClassifier = ''
mergeServiceFiles()

manifest {
Expand Down
10 changes: 5 additions & 5 deletions fabric-chaincode-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM eclipse-temurin:11.0.21_9-jdk as builder
FROM eclipse-temurin:11.0.22_7-jdk as builder
ENV DEBIAN_FRONTEND=noninteractive

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

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

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

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

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

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

RUN apt-get update \
&& apt-get -y install zip unzip \
Expand Down
2 changes: 1 addition & 1 deletion fabric-chaincode-docker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ task copyAllDeps(type: Copy) {
task buildImage(type: DockerBuildImage) {
dependsOn copyAllDeps
inputDir = project.file('Dockerfile').parentFile
tags = ['hyperledger/fabric-javaenv', 'hyperledger/fabric-javaenv:amd64-2.5.1', 'hyperledger/fabric-javaenv:amd64-latest']
tags = ['hyperledger/fabric-javaenv', 'hyperledger/fabric-javaenv:2.5', 'hyperledger/fabric-javaenv:amd64-2.5.1', 'hyperledger/fabric-javaenv:amd64-latest']
}

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

sourceCompatibility = 1.8
tasks.compileJava {
sourceCompatibility = '1.8'
}

repositories {
mavenLocal()
Expand All @@ -18,7 +20,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.1'
implementation 'org.hyperledger.fabric:fabric-protos:0.2.+'
}

Expand Down
Loading

0 comments on commit fa056db

Please sign in to comment.