Skip to content

Commit

Permalink
Updates to test chaincode to exploit new microfab (#363)
Browse files Browse the repository at this point in the history
New microfab version provides an up-to-date Gradle version, which the
test chaincode can be updated to exploit.

This change also updates several dependencies to current versions.

Signed-off-by: Mark S. Lewis <[email protected]>
  • Loading branch information
bestbeforetoday authored Nov 28, 2024
1 parent 4939a15 commit 0d50c5f
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/build/
build/*
settings-gradle.lockfile
config/

_cfg
repository
Expand Down
13 changes: 7 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,15 @@ subprojects {
dependencies {
implementation 'commons-cli:commons-cli:1.9.0'
implementation 'commons-logging:commons-logging:1.3.4'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.0'

testImplementation 'org.hamcrest:hamcrest-library:3.0'
testImplementation 'org.mockito:mockito-core:5.13.0'
testImplementation 'uk.org.webcompere:system-stubs-jupiter:2.1.6'

testImplementation platform('org.junit:junit-bom:5.11.3')
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation 'org.assertj:assertj-core:3.26.3'
testImplementation 'org.mockito:mockito-core:5.14.2'
testImplementation 'uk.org.webcompere:system-stubs-jupiter:2.1.7'

testImplementation 'org.hamcrest:hamcrest-library:3.0'
}

test {
Expand Down
32 changes: 18 additions & 14 deletions fabric-chaincode-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM eclipse-temurin:11-jdk as builder
ENV DEBIAN_FRONTEND=noninteractive
ARG JAVA_IMAGE=eclipse-temurin:11-jdk

FROM ${JAVA_IMAGE} as builder
ENV DEBIAN_FRONTEND=noninteractive

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

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

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
RUN source /root/.sdkman/bin/sdkman-init.sh \
&& sdk install gradle 8.11.1 \
&& sdk install maven 3.9.9

FROM eclipse-temurin:11-jdk as dependencies
FROM ${JAVA_IMAGE} 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 All @@ -25,12 +28,10 @@ ENV PATH="/usr/bin/maven/bin:/usr/bin/maven/:/usr/bin/gradle:/usr/bin/gradle/bin
ADD build/distributions/ /root/

#Creating folders structure
RUN mkdir -p /root/chaincode-java/chaincode/src
RUN mkdir -p /root/chaincode-java/chaincode/build/out
RUN mkdir -p /root/chaincode-java/chaincode/src /root/chaincode-java/chaincode/build/out

#Making scripts runnable
RUN chmod +x /root/chaincode-java/start
RUN chmod +x /root/chaincode-java/build.sh
RUN chmod +x /root/chaincode-java/start /root/chaincode-java/build.sh

# Build protos and shim jar and installing them to maven local and gradle cache
WORKDIR /root/chaincode-java/shim-src
Expand All @@ -41,19 +42,21 @@ RUN gradle \
-x javadoc \
-x test \
-x pmdMain \
-x pmdTest
-x pmdTest \
-x spotlessCheck

WORKDIR /root/chaincode-java
# Run the Gradle and Maven commands to generate the wrapper variants
# of each tool
#Gradle doesn't run without settings.gradle file, so create one
RUN touch settings.gradle
RUN gradle wrapper
RUN mvn -N io.takari:maven:wrapper
RUN touch settings.gradle \
&& gradle wrapper \
&& ./gradlew --version \
&& mvn -N wrapper:wrapper

# Creating final javaenv image which will include all required
# dependencies to build and compile java chaincode
FROM eclipse-temurin:11-jdk
FROM ${JAVA_IMAGE}

RUN apt-get update \
&& apt-get -y install zip unzip \
Expand All @@ -66,6 +69,7 @@ SHELL ["/bin/bash", "-c"]

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

WORKDIR /root/chaincode-java
1 change: 1 addition & 0 deletions fabric-chaincode-integration-test/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
repository
_cfg
*.tar.gz
log.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'com.github.johnrengelman.shadow' version '5.2.0'
id 'com.gradleup.shadow' version '8.3.5'
id 'java'
}

Expand Down Expand Up @@ -29,9 +29,9 @@ dependencies {
}

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

manifest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.gradleup.shadow' version '8.3.5'
id 'java'
}

group 'org.hyperledger.fabric-chaincode-java'
version '1.0-SNAPSHOT'
version ''

java {
sourceCompatibility = JavaVersion.VERSION_11
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.gradleup.shadow' version '8.3.5'
id 'java'
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
10 changes: 5 additions & 5 deletions fabric-chaincode-shim/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ tasks.withType(org.gradle.api.tasks.testing.Test) {

dependencies {
implementation platform('com.google.protobuf:protobuf-bom:3.25.5')
implementation platform('io.grpc:grpc-bom:1.68.0')
implementation platform('io.grpc:grpc-bom:1.68.1')
implementation platform('io.opentelemetry:opentelemetry-bom:1.42.1')

implementation 'org.hyperledger.fabric:fabric-protos:0.3.3'
implementation 'org.bouncycastle:bcpkix-jdk18on:1.78.1'
implementation 'org.bouncycastle:bcprov-jdk18on:1.78.1'
implementation 'io.github.classgraph:classgraph:4.8.176'
implementation 'org.bouncycastle:bcpkix-jdk18on:1.79'
implementation 'org.bouncycastle:bcprov-jdk18on:1.79'
implementation 'io.github.classgraph:classgraph:4.8.179'
implementation 'com.github.everit-org.json-schema:org.everit.json.schema:1.14.4'
implementation 'org.json:json:20240303'
implementation 'com.google.protobuf:protobuf-java-util'
Expand Down Expand Up @@ -86,7 +86,7 @@ sourceSets {
}

jacoco {
toolVersion = "0.8.6"
toolVersion = "0.8.12"
}

jacocoTestReport {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down

0 comments on commit 0d50c5f

Please sign in to comment.