diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0f6d9b85..f9c2b09d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,48 @@
+## v1.4.8
+Wed 4 Nov 2020 14:28:37 GMT
+
+* [7aefaa9](https://github.com/hyperledger/fabric-chaincode-java/commit/7aefaa9) [FABCJ-295](https://jira.hyperledger.org/browse/FABCJ-295) Clean sdkman cache
+* [3c1d0fa](https://github.com/hyperledger/fabric-chaincode-java/commit/3c1d0fa) [FABCJ-290](https://jira.hyperledger.org/browse/FABCJ-290) Add release guide
+* [a2707b1](https://github.com/hyperledger/fabric-chaincode-java/commit/a2707b1) Bump version to 1.4.8
+
+## v1.4.7
+Thu 8 Oct 2020 10:21:26 BST
+
+ [27141a0](https://github.com/hyperledger/fabric-chaincode-java/commit/27141a0) [FABCJ-293](https://jira.hyperledger.org/browse/FABCJ-293) Remove gradle from javaenv, defer to gradle wrapper
+
+## v1.4.6
+Wed 4 Mar 10:21:28 GMT 2020
+
+* [b54d8bb](https://github.com/hyperledger/fabric-chaincode-java/commit/b54d8bb) [FABCJ-280](https://jira.hyperledger.org/browse/FABCJ-280) Copy chaincode into temporary directory before building
+* [dac90d2](https://github.com/hyperledger/fabric-chaincode-java/commit/dac90d2) [FAB-6415](https://jira.hyperledger.org/browse/FAB-6415) Replace org.reflections with classgraph
+* [f109d19](https://github.com/hyperledger/fabric-chaincode-java/commit/f109d19) [FAB-6415](https://jira.hyperledger.org/browse/FAB-6415) Add javax.xml.bind dependency for Java 11
+* [540b9ca](https://github.com/hyperledger/fabric-chaincode-java/commit/540b9ca) [FAB-6415](https://jira.hyperledger.org/browse/FAB-6415) Add javax.annotation dependency for Java 11
+* [88e2da2](https://github.com/hyperledger/fabric-chaincode-java/commit/88e2da2) [FABCJ-270](https://jira.hyperledger.org/browse/FABCJ-270) Prepare release 1.4.6
+
+## v1.4.5
+Thu 16 Jan 16:16:48 GMT 2020
+
+* [bc99f73](https://github.com/hyperledger/fabric-chaincode-java/commit/bc99f73) [FABCJ-259](https://jira.hyperledger.org/browse/FABCJ-259) Pagination Fix
+* [8fc5763](https://github.com/hyperledger/fabric-chaincode-java/commit/8fc5763) Maven build in batch mode
+* [4f03935](https://github.com/hyperledger/fabric-chaincode-java/commit/4f03935) [FAB-17100](https://jira.hyperledger.org/browse/FAB-17100) Default Thread Pool not set correctly
+* [5ff847e](https://github.com/hyperledger/fabric-chaincode-java/commit/5ff847e) [FAB-17078](https://jira.hyperledger.org/browse/FAB-17078) Update version number
+
+## v1.4.4
+Mon 11 Nov 15:57:05 GMT 2019
+
+* [5ce56df](https://github.com/hyperledger/fabric-chaincode-java/commit/5ce56df) [FAB-16712](https://jira.hyperledger.org/browse/FAB-16712) Update contributing guide
+* [baaaef8](https://github.com/hyperledger/fabric-chaincode-java/commit/baaaef8) [FAB-16315](https://jira.hyperledger.org/browse/FAB-16315) Improved Load Ability
+* [c7efeb4](https://github.com/hyperledger/fabric-chaincode-java/commit/c7efeb4) [FAB-16871](https://jira.hyperledger.org/browse/FAB-16871) Deprecate Logger interface
+* [a4938e8](https://github.com/hyperledger/fabric-chaincode-java/commit/a4938e8) [FAB-16845](https://jira.hyperledger.org/browse/FAB-16845) Correct Logging
+* [f0a1784](https://github.com/hyperledger/fabric-chaincode-java/commit/f0a1784) [FAB-16817](https://jira.hyperledger.org/browse/FAB-16817) manifest classpath
+* [f6c007a](https://github.com/hyperledger/fabric-chaincode-java/commit/f6c007a) fabric-chaincode-java update to baseimage 0.4.16
+* [5f6d88d](https://github.com/hyperledger/fabric-chaincode-java/commit/5f6d88d) [FAB-16711](https://jira.hyperledger.org/browse/FAB-16711) azure pipelines
+* [388802e](https://github.com/hyperledger/fabric-chaincode-java/commit/388802e) [FAB-16745](https://jira.hyperledger.org/browse/FAB-16745) Remove SDK from integration tests
+* [b58f11d](https://github.com/hyperledger/fabric-chaincode-java/commit/b58f11d) [FAB-16680](https://jira.hyperledger.org/browse/FAB-16680) Fix cloudflare error on jitpack.io
+* [8cca4bb](https://github.com/hyperledger/fabric-chaincode-java/commit/8cca4bb) [FAB-16315](https://jira.hyperledger.org/browse/FAB-16315) Unrequired lock
+* [bd59b34](https://github.com/hyperledger/fabric-chaincode-java/commit/bd59b34) [FAB-16217](https://jira.hyperledger.org/browse/FAB-16217) Do not load JSON Schema schema from network
+* [55c29f9](https://github.com/hyperledger/fabric-chaincode-java/commit/55c29f9) [FAB-15895](https://jira.hyperledger.org/browse/FAB-15895) Added client identity to context
+
## v1.4.3
Wed 31 Jul 11:20:26 BST 2019
diff --git a/CODEOWNERS b/CODEOWNERS
new file mode 100644
index 00000000..6eb5f87e
--- /dev/null
+++ b/CODEOWNERS
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: Apache-2.0
+
+# Fabric Chaincode Java Maintainers
+* @hyperledger/fabric-chaincode-java-maintainers
diff --git a/COMPATIBILITY.md b/COMPATIBILITY.md
new file mode 100644
index 00000000..c964b775
--- /dev/null
+++ b/COMPATIBILITY.md
@@ -0,0 +1,53 @@
+# Support and Compatibility for fabric-chaincode-java
+
+Github is used for code base management, issues should reported in the [FABCJ](https://jira.hyperledger.org/projects/FABCJ/issues/) component in JIRA.
+
+
+## Summary of Compatibility
+
+This table shows the summary of the compatibility of the Java libraries at versions 1.4 and 2.1, together with the JVM version they require and the Fabric Peer versions they can communicate with.
+
+| | Fabric Peer v1.4 connectivity | Java 8 VM | Fabric Peer v2.1 Connectivity | Java 11 VM |
+| ----------------------- | ----------------------------- | --------- | ----------------------------- | ---------- |
+| Java libraries **v1.4** | Yes | Yes | Yes | Yes |
+| Java libraries **v2.1** | Yes | No | Yes | Yes |
+
+Testing is performed with
+ - Java v8: Openjdk version 1.8.0_222
+ - Java v11: Openjdk version 11.04_11
+
+By default a Fabric Peer v1.4 will create a Java 8 VM, and a Fabric Peer v2.1 will create a Java 11 VM. Whilst is the default, the docker image used to host the chaincode and contracts can be altered. Set the environment variable `CORE_CHAINCODE_JAVA_RUNTIME` on the peer to the name of the docker image. For example `CORE_CHAINCODE_JAVA_RUNTIME=example/customJavaRuntime:latest`
+
+The Java Libraries will connect to the peer whilst running; this is referred to as 'Fabric Peer Connectivity' in the table. For example, whilst the Fabric Peer v1.4 will create a Java 8 environment, if a Java 11 environment was configured, the Java Libraries at v2.1.0 still function when connecting to the Fabric Peer v1.4.
+
+## Compatibility
+
+The key elements are :
+
+- the version of the Fabric Contract Java libraries used
+- the version of the JVM used to run the code
+- When starting a chaincode container to run a Smart Contract the version of the runtime that is used is determined by these factors:
+
+Fabric v1.4.2, and Fabric v2.1.0 will, by default, start up docker image to host the chaincode and contracts. The version of the docker image used is defined by the version of Fabric in use.
+
+With Fabric v2.1.0, the chaincode container can be configured to be started by other means, and not the Peer. In this case, the environment used is not in the control of Fabric.
+
+The Java libraries are produced are `group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim'`
+
+### Supported JVMs
+
+v1.4.x and v2.1.0 Java Libraries are supported running in Java 11 with the x86_64 architecture. Later Java 11 versions are supported but are not tested.
+
+v1.4.x Java Libraries are supported running in Java 8 with the x86_64 architecture. Later Java 8 versions are supported but are not tested.
+
+Architecture Support: all docker images, JVMs, tools are tested under x86_64 ONLY
+
+### Default Peer Runtime selection
+
+When using Fabric 2.1.0, the default docker image that is used to run the Java chaincode is *openjdk11:jdk-11.04_11-alpine*
+
+With the default docker image used by Fabric 2.1.0. should the packaged Java code contain a Maven or Gradle build script, it will be built using Gradle 5.6.2, or Maven 3.6.2 (if both Gradle and Maven files are present Gradle is used. Gradle build files can be groovy, or kotlin. If the Gradle wrapper is present, this will used in preference to the installed version of Gradle; note that the version of Gradle in the docker image is a copy of the Gradle Wrapper, not the full Gradle install. Therefore if there is limited Internet acccess in your production environment, do not use Gradle). Alternatively it is recommended to package prebuilt jar files, including the contract and all dependencies, in which case no build or Internet access is required when installing Java chaincode.
+
+### Supported Runtime communication with the Peer
+
+Subject to a suitable runtime environment, the 1.4.4 and 2.1.0 Java Libraries can used to communicate with a Fabric 2.1.0 or 1.4.4 Peer - with the level of functionality that is implied by the Fabric version in use.
\ No newline at end of file
diff --git a/README.md b/README.md
index de2e43c0..08346fb2 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ to run Java chaincode.
## Getting Started
-Application developers interested in developing Java smart contracts for Hyperledger Fabric should read the [JavaDoc](https://fabric-chaincode-java.github.io/) which inludes download information, and links to documentation and samples.
+Application developers interested in developing Java smart contracts for Hyperledger Fabric should read the [JavaDoc](https://hyperledger.github.io/fabric-chaincode-java/) which inludes download information, and links to documentation and samples.
## Project structure
diff --git a/RELEASING.md b/RELEASING.md
new file mode 100644
index 00000000..c0b8a107
--- /dev/null
+++ b/RELEASING.md
@@ -0,0 +1,59 @@
+# Releasing
+
+The following artifacts are created as a result of releasing Fabric Chaincode Java:
+
+- docker images
+ - [fabric-javaenv](https://hub.docker.com/r/hyperledger/fabric-javaenv)
+- Java libraries
+ - [fabric-chaincode-shim](https://search.maven.org/search?q=a:fabric-chaincode-shim)
+ - [fabric-chaincode-protos](https://search.maven.org/search?q=a:fabric-chaincode-protos)
+
+**Note:** A docker image with a matching V.R version is required before releasing a new version of Fabric.
+
+## Before releasing
+
+It's useful to create an issue to keep track of each release, for example [Release 1.4.6 Java Chaincode](https://jira.hyperledger.org/browse/FABCJ-281).
+
+The following tasks are required before releasing:
+
+- Update version numbers in `build.gradle` files to the required version
+- Update test, sample, and docs files to match the new version
+- Create a new release notes file
+- Update the `CHANGELOG.md` file
+
+ The `changelog.sh` script in `scripts` will prepopulate the changelog but you must check and edit the file manually afterwards as required
+
+See the [Prepare 1.4.7 release](https://github.com/hyperledger/fabric-chaincode-java/pull/139) pull request for an example, although be careful to search for all versions in the codebase as they're easy to miss and things change!
+
+## Create release
+
+Creating a GitHub release on the [releases page](https://github.com/hyperledger/fabric-chaincode-java/releases) will trigger the build to publish the new release.
+
+When drafting the release, create a new tag for the new version (with a `v` prefix), e.g. `v1.4.6`
+
+See previous releases for examples of the title and description.
+
+## Publish Java libraries
+
+Log on to the [nexus repository manager](https://oss.sonatype.org/#welcome) to manually publish the JARs which were pushed by the release build.
+
+Find the results of the release build under _Build Promotion > Staging Repositories_ and perform the following steps:
+
+1. Close
+
+ You should see a series of close activities (see note)
+
+2. Release using the automatically drop option
+
+ You should see a series of release activities (see note)
+
+Note: you may need to refresh to update the activities view.
+
+When the release has completed and the _Staging Repositories_ list is empty, the Java chaincode libraries should appear in the maven repository. They can take some time to appear in the UI but they should exist in the repository sooner.
+
+## After releasing
+
+- Update version numbers in `build.gradle` files to the next version
+- Update test, sample, and docs files to match the new version
+
+See the [[FABCJ-281] Set to the next version 1.4.7](https://github.com/hyperledger/fabric-chaincode-java/pull/90) pull request for an example. It should include almost all the files changed to prepare for the release, except for the release notes and changelog which do not need updating.
diff --git a/build.gradle b/build.gradle
index 730f8d16..91956a12 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,7 +7,7 @@
apply plugin: 'idea'
apply plugin: 'eclipse-wtp'
apply plugin: 'com.dorongold.task-tree'
-version = '1.4.4-SNAPSHOT'
+version = '1.4.8'
buildscript {
repositories {
maven {
diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml
index 91ebe5fc..09af5a79 100644
--- a/ci/azure-pipelines.yml
+++ b/ci/azure-pipelines.yml
@@ -8,10 +8,9 @@
# cf https://crontab.guru/#0_23_*_*_*
schedules:
- cron: "0 23 * * *"
- displayName: 'Chaincode Java Nightly Driver'
+ displayName: 'Chaincode 1.4 Java Nightly Driver'
branches:
include:
- - master
- release-1.4
always: true
@@ -20,7 +19,6 @@ schedules:
trigger:
branches:
include:
- - 'master'
- 'release-1.4'
tags:
include:
@@ -31,8 +29,15 @@ trigger:
# this isn't set so command line output is given
#
variables:
- component: fabric-chaincode-node
- pipeline: ci
+ - group: Chaincode_Java_Creds
+ - group: Github-PackageRegistry-Credentials
+ - group: JARSigningPublish
+ - name: component
+ value: fabric-chaincode-java
+ - name: pipeline
+ value: ci
+ - name: PUSH_VERSION
+ value: stable
pool:
vmImage: 'ubuntu-latest'
@@ -43,9 +48,16 @@ pool:
stages:
- stage: Build_and_test
jobs:
- - job: main
- steps:
- - script: env
+ - job: main
+ steps:
+ - script: |
+ env | sort
+ java -version
+ VERSION=$(cat build.gradle | sed -n "s/version =.*'\(.*\)\(-SNAPSHOT\)\?'/\1/p")
+ VERSION=${VERSION// }
+ echo Current version in code is :${VERSION}:
+ echo "##vso[task.setvariable variable=PACKAGE_VERSION;isOutput=true]${VERSION}"
+ name: builddata
- task: Gradle@2
inputs:
workingDirectory: ''
@@ -54,30 +66,105 @@ stages:
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
+ options: '-x javadoc'
publishJUnitResults: true
testResultsFiles: '$(System.DefaultWorkingDirectory)/**/TEST-*.xml'
tasks: 'build'
- task: PublishCodeCoverageResults@1
inputs:
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/fabric-chaincode-shim/build/reports/jacoco/test/jacocoTestReport.xml'
+ - task: PublishCodeCoverageResults@1
+ inputs:
+ summaryFileLocation: "$(System.DefaultWorkingDirectory)/**/fabric-chaincode-shim/build/reports/jacoco/test/jacocoTestReport.xml"
+ # Copy the built artifacts to the staging directory, tgz, and the docker image
+ - script: |
+ set -ev
+ ./gradlew publishToMavenLocal
+ tar -zcvf localmaven.tgz ${HOME}/.m2/repository/org/hyperledger
+ docker image save hyperledger/fabric-javaenv | gzip > $(Build.ArtifactStagingDirectory)/fabric-javaenv.tar.gz
+ displayName: 'Package tgz and docker image'
+ - task: PublishBuildArtifacts@1
+ inputs:
+ pathToPublish: localmaven.tgz
+ artifactName: java-tgz
+ - task: PublishBuildArtifacts@1
+ inputs:
+ pathToPublish: $(Build.ArtifactStagingDirectory)/fabric-javaenv.tar.gz
+ artifactName: javaenv-docker-image
+
+ - job: javadoc
+ steps:
+ - script: ./gradlew javadoc
+ displayName: 'Build JavaDoc'
+ - script: |
+ git fetch origin
+ git checkout -b gh-pages origin/gh-pages
+ mkdir -p $(Build.SourceBranchName)/api
+ rm -rf $(Build.SourceBranchName)/api/*
+ cp -r fabric-chaincode-shim/build/docs/javadoc/* $(Build.SourceBranchName)/api
+ displayName: 'Update gh-pages branch'
+ - script: |
+ git config --global user.email "hlfdev.azp@gmail.com"
+ git config --global user.name "Hyperledger Bot"
+ git add -A
+ git commit -m "Publishing GitHub Pages"
+ git push https://$(GITHUB-PAT)@github.com/hyperledger/fabric-chaincode-java.git gh-pages
+ displayName: 'Commit gh-pages changes'
+ condition: and(succeeded(),eq(variables['Build.Reason'], 'IndividualCI'))
+
+ # As the next script is more complex and uses loops, run this descretely in a sh file
+ # Publishing step for git tags
- stage: Publish_tag
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags'))
jobs:
- - job: update_version
- steps:
- - script: |
- env | sort
- echo "Update the version number"
- echo "Make sure release notes are present"
- echo "Make sure change history is present"
- - job: npm_publish
+ - job: publish_release
steps:
+
+ - task: DownloadPipelineArtifact@2
+ inputs:
+ artifact: javaenv-docker-image
+ path: $(Build.SourcesDirectory)/build
+ - task: DownloadSecureFile@1
+ name: keyring
+ inputs:
+ secureFile: secring.gpg
- script: |
- echo "Setup .npmrc"
- echo "Use pipeline secret to login"
- echo "publish"
- - job: jsdoc_publish
- steps:
+ wget -qO "$PWD/manifest-tool" https://github.com/estesp/manifest-tool/releases/download/v1.0.0/manifest-tool-linux-amd64
+ chmod +x ./manifest-tool
+
+ # temporarily use this approach instead of the gittag
+ VERSION=$(cat build.gradle | sed -n "s/version =.*'\(.*\)\(-SNAPSHOT\)\?'/\1/p")
+ VERSION=${VERSION// }
+ echo Version is :${VERSION}:
+
+
+ docker image load --input build/fabric-javaenv.tar.gz
+ docker images
+ docker login ${DOCKER_REGISTRY_URL} --username=${DOCKER_REGISTRY_USERNAME} --password=${DOCKER_REGISTRY_PASSWORD}
+ echo "Logged in to docker registry"
+
+ # tag javaenv image
+ docker tag hyperledger/fabric-javaenv fabric-javaenv:amd64-${VERSION}
+
+ # push javaenv to repository
+ docker push hyperledger/fabric-javaenv:amd64-${VERSION}
+ ./manifest-tool push from-args --platforms linux/amd64 --template "hyperledger/fabric-javaenv:amd64-${VERSION}" --target "hyperledger/fabric-javaenv:${VERSION}"
+ ./manifest-tool push from-args --platforms linux/amd64 --template "hyperledger/fabric-javaenv:amd64-${VERSION}" --target "hyperledger/fabric-javaenv:1.4"
+ env:
+ DOCKER_REGISTRY_USERNAME: $(DockerHub-Username)
+ DOCKER_REGISTRY_PASSWORD: $(DockerHub-Password)
- script: |
- echo "checkout docs branch"
- echo "checking"
\ No newline at end of file
+ env | sort
+
+ # temporarily use this approach instead of the gittag
+ VERSION=$(cat build.gradle | sed -n "s/version =.*'\(.*\)\(-SNAPSHOT\)\?'/\1/p")
+ VERSION=${VERSION// }
+ echo Version is :${VERSION}:
+
+ ./gradlew -Psigning.keyId=${SIGNING_ID} -Psigning.password=${SIGNING_PASSWORD} -Psigning.secretKeyRingFile=${KEYRING_FILE} -PossrhUsername=${OSSRH_USER} -PossrhPassword=${OSSRH_PASSWORD} uploadArchives
+ env:
+ SIGNING_ID: $(JAR-Signing-Id)
+ SIGNING_PASSWORD: $(JAR-Signing-Password)
+ KEYRING_FILE: $(keyring.secureFilePath)
+ OSSRH_USER: $(OSSRH-User)
+ OSSRH_PASSWORD: $(OSSRH-Password)
diff --git a/fabric-chaincode-docker/Dockerfile b/fabric-chaincode-docker/Dockerfile
index 8c52cfca..2c65614d 100644
--- a/fabric-chaincode-docker/Dockerfile
+++ b/fabric-chaincode-docker/Dockerfile
@@ -1,4 +1,4 @@
-FROM hyperledger/fabric-baseimage:amd64-0.4.16
+FROM hyperledger/fabric-baseimage:amd64-0.4.16 as dependencies
RUN apt-get update
RUN apt-get install zip -y
RUN curl -s "https://get.sdkman.io" | bash
@@ -28,14 +28,20 @@ RUN source /root/.sdkman/bin/sdkman-init.sh; gradle clean
# Building protobuf jar and installing it to maven local and gradle cache
WORKDIR /root/chaincode-java/shim-src/fabric-chaincode-protos
-RUN source /root/.sdkman/bin/sdkman-init.sh; gradle clean build install publishToMavenLocal
+RUN source /root/.sdkman/bin/sdkman-init.sh; gradle clean build install publishToMavenLocal \
+ -x javadoc \
+ -x test
+
# Installing all jar dependencies to maven local
WORKDIR /root/chaincode-java/shim-src/fabric-chaincode-protos/build/publications/protosJar/
RUN source /root/.sdkman/bin/sdkman-init.sh; mvn -f pom-default.xml compile
# Building shim jar and installing it to maven local and gradle cache
WORKDIR /root/chaincode-java/shim-src/fabric-chaincode-shim
-RUN source /root/.sdkman/bin/sdkman-init.sh; gradle clean build install publishToMavenLocal
+RUN source /root/.sdkman/bin/sdkman-init.sh; gradle clean build install publishToMavenLocal \
+ -x javadoc \
+ -x test
+
# Installing all jar dependencies to maven local
WORKDIR /root/chaincode-java/shim-src/fabric-chaincode-shim/build/publications/shimJar/
RUN source /root/.sdkman/bin/sdkman-init.sh; mvn -f pom-default.xml compile
@@ -48,10 +54,10 @@ RUN source /root/.sdkman/bin/sdkman-init.sh; mvn compile package
# Adding shim 1.3.0 jar
WORKDIR /tmp
-RUN wget https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-chaincode-java/fabric-chaincode-shim/1.3.0/fabric-chaincode-shim-1.3.0.pom
-RUN wget https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-chaincode-java/fabric-chaincode-shim/1.3.0/fabric-chaincode-shim-1.3.0.jar
-RUN wget https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-chaincode-java/fabric-chaincode-protos/1.3.0/fabric-chaincode-protos-1.3.0.pom
-RUN wget https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-chaincode-java/fabric-chaincode-protos/1.3.0/fabric-chaincode-protos-1.3.0.jar
+RUN wget https://hyperledger.jfrog.io/hyperledger/fabric-maven/fabric-chaincode-shim/fabric-chaincode-shim/1.3.0/fabric-chaincode-shim-1.3.0.pom
+RUN wget https://hyperledger.jfrog.io/hyperledger/fabric-maven/fabric-chaincode-shim/fabric-chaincode-shim/1.3.0/fabric-chaincode-shim-1.3.0.jar
+RUN wget https://hyperledger.jfrog.io/hyperledger/fabric-maven/fabric-chaincode-protos/fabric-chaincode-protos/1.3.0/fabric-chaincode-protos-1.3.0.pom
+RUN wget https://hyperledger.jfrog.io/hyperledger/fabric-maven/fabric-chaincode-protos/fabric-chaincode-protos/1.3.0/fabric-chaincode-protos-1.3.0.jar
RUN source /root/.sdkman/bin/sdkman-init.sh; mvn install::install-file -Dfile=fabric-chaincode-protos-1.3.0.jar -DpomFile=fabric-chaincode-protos-1.3.0.pom
RUN source /root/.sdkman/bin/sdkman-init.sh; mvn install::install-file -Dfile=fabric-chaincode-shim-1.3.0.jar -DpomFile=fabric-chaincode-shim-1.3.0.pom
@@ -59,3 +65,26 @@ RUN source /root/.sdkman/bin/sdkman-init.sh; mvn install::install-file -Dfile=fa
WORKDIR /root/chaincode-java
RUN rm -rf example-src/*
RUN rm -rf shim-src
+
+RUN source /root/.sdkman/bin/sdkman-init.sh; gradle wrapper --gradle-version 4.6
+RUN source /root/.sdkman/bin/sdkman-init.sh; sdk uninstall gradle 4.6
+
+# Creating final javaenv image which will include all required
+# dependencies to build and compile java chaincode
+FROM adoptopenjdk/openjdk8
+RUN apt-get update && apt-get upgrade -y
+
+COPY --from=dependencies /root/chaincode-java/gradle /root/chaincode-java/
+COPY --from=dependencies /root/chaincode-java/gradlew /root/chaincode-java/gradlew
+COPY --from=dependencies /root/.sdkman/candidates/maven/current /usr/bin/maven
+COPY --from=dependencies /root/.sdkman/ /root/.sdkman/
+SHELL ["/bin/bash", "-c"]
+ENV PATH="/usr/bin/maven/bin:/usr/bin/maven/:${PATH}"
+
+COPY --from=dependencies /root/chaincode-java /root/chaincode-java
+COPY --from=dependencies /root/.m2 /root/.m2
+
+RUN mkdir -p /chaincode/input
+RUN mkdir -p /chaincode/output
+
+WORKDIR /root/chaincode-java
diff --git a/fabric-chaincode-docker/build.gradle b/fabric-chaincode-docker/build.gradle
index b55f4f90..5fd963c3 100644
--- a/fabric-chaincode-docker/build.gradle
+++ b/fabric-chaincode-docker/build.gradle
@@ -80,6 +80,6 @@ task copyAllDeps(type: Copy) {
task buildImage(type: DockerBuildImage) {
dependsOn copyAllDeps
inputDir = project.file('Dockerfile').parentFile
- tags = ['hyperledger/fabric-javaenv', 'hyperledger/fabric-javaenv:amd64-1.4.4', 'hyperledger/fabric-javaenv:amd64-latest']
+ tags = ['hyperledger/fabric-javaenv', 'hyperledger/fabric-javaenv:amd64-1.4.8', 'hyperledger/fabric-javaenv:amd64-latest']
}
diff --git a/fabric-chaincode-docker/build.sh b/fabric-chaincode-docker/build.sh
index 3341495b..589d4de6 100644
--- a/fabric-chaincode-docker/build.sh
+++ b/fabric-chaincode-docker/build.sh
@@ -1,9 +1,19 @@
#!/bin/bash
+TMP_DIR=$(mktemp -d)
+
buildGradle() {
- cd "$1" > /dev/null
+ echo "Copying from $1 to ${TMP_DIR}"
+ cd $1
+ tar cf - . | (cd ${TMP_DIR}; tar xf -)
+ cd ${TMP_DIR}
echo "Gradle build"
- gradle build shadowJar -x test
+ if [ -f ./gradlew ]; then
+ chmod +x ./gradlew
+ ./gradlew build shadowJar -x test
+ else
+ /root/chaincode-java/gradlew build shadowJar -x test
+ fi
retval=$?
if [ $retval -ne 0 ]; then
exit $retval
@@ -17,9 +27,12 @@ buildGradle() {
}
buildMaven() {
- cd "$1" > /dev/null
+ echo "Copying from $1 to ${TMP_DIR}"
+ cd $1
+ tar cf - . | (cd ${TMP_DIR}; tar xf -)
+ cd ${TMP_DIR}
echo "Maven build"
- mvn compile package -DskipTests -Dmaven.test.skip=true
+ mvn -B compile package -DskipTests -Dmaven.test.skip=true
retval=$?
if [ $retval -ne 0 ]; then
exit $retval
diff --git a/fabric-chaincode-example-gradle/build.gradle b/fabric-chaincode-example-gradle/build.gradle
index befed338..6ef6ee23 100644
--- a/fabric-chaincode-example-gradle/build.gradle
+++ b/fabric-chaincode-example-gradle/build.gradle
@@ -15,7 +15,7 @@ repositories {
}
dependencies {
- compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.4-SNAPSHOT'
+ compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.8'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
diff --git a/fabric-chaincode-example-maven/pom.xml b/fabric-chaincode-example-maven/pom.xml
index 9926719e..66ac3c65 100644
--- a/fabric-chaincode-example-maven/pom.xml
+++ b/fabric-chaincode-example-maven/pom.xml
@@ -12,7 +12,7 @@
UTF-8
- 1.4.4-SNAPSHOT
+ 1.4.8
1.0.13
@@ -29,8 +29,8 @@
https://www.jitpack.io
- nexus
- https://nexus.hyperledger.org/content/repositories/snapshots/
+ artifactory
+ https://hyperledger.jfrog.io/hyperledger/fabric-maven
diff --git a/fabric-chaincode-example-sacc/build.gradle b/fabric-chaincode-example-sacc/build.gradle
index c9ac43a3..b3f08af2 100644
--- a/fabric-chaincode-example-sacc/build.gradle
+++ b/fabric-chaincode-example-sacc/build.gradle
@@ -15,7 +15,7 @@ repositories {
}
dependencies {
- compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.4-SNAPSHOT'
+ compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.8'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
@@ -25,6 +25,6 @@ shadowJar {
classifier = null
manifest {
- attributes 'Main-Class': 'org.hyperledger.fabric.example.SimpleAsset'
+ attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter'
}
}
diff --git a/fabric-chaincode-example-sacc/src/main/java/org/hyperledger/fabric/example/SimpleAsset.java b/fabric-chaincode-example-sacc/src/main/java/org/hyperledger/fabric/example/SimpleAsset.java
index daf321f2..a386e4f0 100644
--- a/fabric-chaincode-example-sacc/src/main/java/org/hyperledger/fabric/example/SimpleAsset.java
+++ b/fabric-chaincode-example-sacc/src/main/java/org/hyperledger/fabric/example/SimpleAsset.java
@@ -32,7 +32,7 @@ public Response init(ChaincodeStub stub) {
stub.putStringState(args.get(0), args.get(1));
return newSuccessResponse();
} catch (Throwable e) {
- return newErrorResponse("Failed to create asset");
+ return newErrorResponse("Failed to create asset "+e.getMessage());
}
}
diff --git a/fabric-chaincode-example-sbe/build.gradle b/fabric-chaincode-example-sbe/build.gradle
index ac7a4270..b18cbfe1 100644
--- a/fabric-chaincode-example-sbe/build.gradle
+++ b/fabric-chaincode-example-sbe/build.gradle
@@ -15,7 +15,7 @@ repositories {
}
dependencies {
- compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.4-SNAPSHOT'
+ compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.8'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
diff --git a/fabric-chaincode-integration-test/build.gradle b/fabric-chaincode-integration-test/build.gradle
index 4e56f61e..5c9f5234 100644
--- a/fabric-chaincode-integration-test/build.gradle
+++ b/fabric-chaincode-integration-test/build.gradle
@@ -1,7 +1,7 @@
dependencies {
compile project(':fabric-chaincode-docker')
testCompile 'org.testcontainers:testcontainers:1.7.1'
- testCompile 'org.hyperledger.fabric-sdk-java:fabric-sdk-java:1.4.4'
+ testCompile 'org.hyperledger.fabric-sdk-java:fabric-sdk-java:1.4.8'
compile project(':fabric-chaincode-shim')
implementation group: 'org.json', name: 'json', version: '20180813'
}
diff --git a/fabric-chaincode-integration-test/getDockerImages.sh b/fabric-chaincode-integration-test/getDockerImages.sh
new file mode 100755
index 00000000..92836464
--- /dev/null
+++ b/fabric-chaincode-integration-test/getDockerImages.sh
@@ -0,0 +1,43 @@
+#!/bin/bash -e
+set -o pipefail
+
+echo "======== PULL DOCKER IMAGES ========"
+
+##########################################################
+# Pull and Tag the fabric and fabric-ca images from Artifactory
+##########################################################
+echo "Fetching images from Artifactory"
+ARTIFACTORY_URL=hyperledger-fabric.jfrog.io
+ORG_NAME="fabric"
+
+VERSION=2.0.0
+ARCH="amd64"
+: ${STABLE_VERSION:=$VERSION-stable}
+STABLE_TAG=$ARCH-$STABLE_VERSION
+MASTER_TAG=$ARCH-master
+
+echo "---------> STABLE_VERSION:" $STABLE_VERSION
+
+dockerTag() {
+ for IMAGE in peer orderer ca tools orderer ccenv; do
+ echo "Images: $IMAGE"
+ echo
+ docker pull $ARTIFACTORY_URL/fabric-$IMAGE:$STABLE_TAG
+ if [ $? != 0 ]; then
+ echo "FAILED: Docker Pull Failed on $IMAGES"
+ exit 1
+ fi
+ docker tag $ARTIFACTORY_URL/fabric-$IMAGE:$STABLE_TAG fabric-$IMAGE
+ docker tag $ARTIFACTORY_URL/fabric-$IMAGE:$STABLE_TAG fabric-$IMAGE:$MASTER_TAG
+ docker tag $ARTIFACTORY_URL/fabric-$IMAGE:$STABLE_TAG fabric-$IMAGE:$VERSION
+ echo "$ORG_NAME-$IMAGE:$MASTER_TAG"
+ echo "Deleting Artifactory docker images: $IMAGE"
+ docker rmi -f $ARTIFACTORY_URL/fabric-$IMAGE:$STABLE_TAG
+ done
+}
+
+dockerTag
+
+echo
+docker images | grep "hyperledger*"
+echo
diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sacc/build.gradle b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sacc/build.gradle
new file mode 100644
index 00000000..b3f08af2
--- /dev/null
+++ b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sacc/build.gradle
@@ -0,0 +1,30 @@
+plugins {
+ id 'com.github.johnrengelman.shadow' version '2.0.3'
+ id 'java'
+}
+
+group 'org.hyperledger.fabric-chaincode-java'
+version '1.0-SNAPSHOT'
+
+sourceCompatibility = 1.8
+
+repositories {
+ mavenLocal()
+ mavenCentral()
+ maven { url "https://www.jitpack.io" }
+}
+
+dependencies {
+ compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.8'
+ testCompile group: 'junit', name: 'junit', version: '4.12'
+}
+
+shadowJar {
+ baseName = 'chaincode'
+ version = null
+ classifier = null
+
+ manifest {
+ attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter'
+ }
+}
diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sacc/settings.gradle b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sacc/settings.gradle
new file mode 100644
index 00000000..a60de0b8
--- /dev/null
+++ b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sacc/settings.gradle
@@ -0,0 +1,2 @@
+rootProject.name = 'fabric-chaincode-example-sacc'
+
diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sacc/src/main/java/org/hyperledger/fabric/example/AllAPI.java b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sacc/src/main/java/org/hyperledger/fabric/example/AllAPI.java
new file mode 100644
index 00000000..a19b8fa5
--- /dev/null
+++ b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sacc/src/main/java/org/hyperledger/fabric/example/AllAPI.java
@@ -0,0 +1,99 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.example;
+
+import org.hyperledger.fabric.contract.Context;
+import org.hyperledger.fabric.contract.ContractInterface;
+import org.hyperledger.fabric.contract.annotation.*;
+
+
+import org.hyperledger.fabric.shim.ledger.*;
+import org.hyperledger.fabric.shim.*;
+import java.util.*;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+@Contract(name = "AllAPI",
+ info = @Info(title = "AllAPI contract",
+ description = "Contract but using all the APIs",
+ version = "0.0.1",
+ license =
+ @License(name = "SPDX-License-Identifier: Apache-2.0",
+ url = ""),
+ contact = @Contact(email = "fred@example.com",
+ name = "fred",
+ url = "http://fred.example.com")))
+@Default
+public class AllAPI implements ContractInterface {
+ public AllAPI() {
+
+ }
+
+ @Transaction()
+ public void putBulkStates(Context ctx){
+ for (int x=100; x<200; x++){
+ String key = "key"+x;
+ String value = "value:"+x;
+
+ putState(ctx,key,value);
+ }
+ }
+
+ @Transaction()
+ public void putState(Context ctx, String key, String payload){
+ ChaincodeStub stub = ctx.getStub();
+ stub.putState(key,payload.getBytes(UTF_8));
+ }
+
+ @Transaction()
+ public void putStateComposite(Context ctx, String key[], String payload){
+ String composite = new CompositeKey("composite",key).toString();
+ this.putState(ctx,composite,payload);
+ }
+
+ @Transaction()
+ public void getState(Context ctx, String key, String payload){
+ ChaincodeStub stub = ctx.getStub();
+ String result = stub.getStringState(key);
+ if (!result.equals(payload)){
+ String msg = "GetState::["+key+"] Expected "+payload+" got "+result;
+ System.out.println(msg);
+ throw new RuntimeException(msg);
+ }
+ }
+
+ @Transaction()
+ public int getByRange(Context ctx, String start, String end){
+ ChaincodeStub stub = ctx.getStub();
+ System.out.println("getByRange>>");
+ QueryResultsIterator qri = stub.getStateByRange(start,end);
+ int count=0;
+ for (KeyValue kv : qri){
+ kv.getKey();
+ kv.getStringValue();
+ count++;
+ System.out.println("["+kv.getKey()+"] "+kv.getStringValue());
+ }
+ System.out.println("getByRange<<");
+ return count;
+ }
+
+ @Transaction()
+ public String getByRangePaged(Context ctx, String start, String end, int pageSize, String bookmark){
+ ChaincodeStub stub = ctx.getStub();
+ System.out.println("getByRangePaged>>");
+ QueryResultsIteratorWithMetadata qri = stub.getStateByRangeWithPagination(start,end,pageSize,bookmark);
+ for (KeyValue kv : qri){
+ kv.getKey();
+ kv.getStringValue();
+ System.out.println("["+kv.getKey()+"] "+kv.getStringValue());
+ }
+ String newbookmark = qri.getMetadata().getBookmark();
+ int records = qri.getMetadata().getFetchedRecordsCount();
+ System.out.println(newbookmark+" @ "+records);
+
+ System.out.println("getByRangePaged<<");
+ return newbookmark;
+ }
+
+}
\ No newline at end of file
diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/build.gradle b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/build.gradle
new file mode 100644
index 00000000..37eed64f
--- /dev/null
+++ b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/build.gradle
@@ -0,0 +1,30 @@
+plugins {
+ id 'com.github.johnrengelman.shadow' version '4.0.3'
+ id 'java'
+}
+
+group 'org.hyperledger.fabric-chaincode-java'
+version '1.0'
+
+sourceCompatibility = 1.8
+
+repositories {
+ mavenLocal()
+ mavenCentral()
+ maven { url "https://www.jitpack.io" }
+}
+
+dependencies {
+ compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.8'
+ testCompile group: 'junit', name: 'junit', version: '4.12'
+}
+
+shadowJar {
+ baseName = 'chaincode'
+ version = null
+ classifier = null
+
+ manifest {
+ attributes 'Main-Class': 'org.hyperledger.fabric.example.EndorsementCC'
+ }
+}
diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/gradle/wrapper/gradle-wrapper.jar b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000..5c2d1cf0
Binary files /dev/null and b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/gradle/wrapper/gradle-wrapper.properties b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..7c4388a9
--- /dev/null
+++ b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/gradlew b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/gradlew
new file mode 100755
index 00000000..8e25e6c1
--- /dev/null
+++ b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/gradlew
@@ -0,0 +1,188 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# 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"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+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.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/gradlew.bat b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/gradlew.bat
new file mode 100644
index 00000000..24467a14
--- /dev/null
+++ b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/gradlew.bat
@@ -0,0 +1,100 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+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.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+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.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/settings.gradle b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/settings.gradle
new file mode 100644
index 00000000..fe0f3ce3
--- /dev/null
+++ b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/settings.gradle
@@ -0,0 +1,2 @@
+rootProject.name = 'fabric-chaincode-example-sbe'
+
diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/src/main/java/org/hyperledger/fabric/example/EndorsementCC.java b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/src/main/java/org/hyperledger/fabric/example/EndorsementCC.java
new file mode 100644
index 00000000..03964e45
--- /dev/null
+++ b/fabric-chaincode-integration-test/src/contracts/fabric-chaincode-example-sbe/src/main/java/org/hyperledger/fabric/example/EndorsementCC.java
@@ -0,0 +1,256 @@
+package org.hyperledger.fabric.example;
+
+import com.google.gson.JsonArray;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hyperledger.fabric.shim.ChaincodeBase;
+import org.hyperledger.fabric.shim.ChaincodeStub;
+import org.hyperledger.fabric.shim.ext.sbe.StateBasedEndorsement;
+import org.hyperledger.fabric.shim.ext.sbe.impl.StateBasedEndorsementFactory;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+public class EndorsementCC extends ChaincodeBase {
+
+ private static Log _logger = LogFactory.getLog(EndorsementCC.class);
+
+ private static Map functions;
+
+ static {
+ functions = new HashMap<>();
+ try {
+ functions.put("addorgs", EndorsementCC.class.getMethod("addOrgs", ChaincodeStub.class));
+ functions.put("delorgs", EndorsementCC.class.getMethod("delOrgs", ChaincodeStub.class));
+ functions.put("listorgs", EndorsementCC.class.getMethod("listOrgs", ChaincodeStub.class));
+ functions.put("delep", EndorsementCC.class.getMethod("delEP", ChaincodeStub.class));
+ functions.put("setval", EndorsementCC.class.getMethod("setVal", ChaincodeStub.class));
+ functions.put("getval", EndorsementCC.class.getMethod("getVal", ChaincodeStub.class));
+ functions.put("cc2cc", EndorsementCC.class.getMethod("invokeCC", ChaincodeStub.class));
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ _logger.error(e);
+ }
+ }
+
+ @Override
+ public Response init(ChaincodeStub stub) {
+ try {
+ _logger.info("Init java EndorsementCC");
+ stub.putStringState("pub", "foo");
+ _logger.info("Init done");
+ return newSuccessResponse();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ return newErrorResponse(e);
+ }
+ }
+
+ @Override
+ public Response invoke(ChaincodeStub stub) {
+ try {
+ _logger.info("Invoking java EndorsementCC");
+ String funcName = stub.getFunction();
+
+ if (functions.containsKey(funcName)) {
+ return (Response) functions.get(funcName).invoke(this, stub);
+ }
+ return newErrorResponse("Unknown function " + funcName);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ return newErrorResponse(e);
+ }
+ }
+
+ public Response addOrgs(ChaincodeStub stub) {
+ try {
+ _logger.info("Invoking addOrgs");
+ List parameters = stub.getParameters();
+ if (parameters.size() < 2) {
+ return newErrorResponse("No orgs to add specified");
+ }
+
+ byte[] epBytes;
+ if ("pub".equals(parameters.get(0))) {
+ epBytes = stub.getStateValidationParameter("pub");
+ } else if ("priv".equals(parameters.get(0))) {
+ epBytes = stub.getPrivateDataValidationParameter("col", "priv");
+ } else {
+ return newErrorResponse("Unknown key specified");
+ }
+
+ StateBasedEndorsement ep = StateBasedEndorsementFactory.getInstance().newStateBasedEndorsement(epBytes);
+ ep.addOrgs(StateBasedEndorsement.RoleType.RoleTypePeer, parameters.subList(1, parameters.size()).toArray(new String[]{}));
+ epBytes = ep.policy();
+ if ("pub".equals(parameters.get(0))) {
+ stub.setStateValidationParameter("pub", epBytes);
+ } else {
+ stub.setPrivateDataValidationParameter("col", "priv", epBytes);
+ }
+
+ return newSuccessResponse(new byte[]{});
+
+ } catch (Throwable e) {
+ return newErrorResponse(e);
+ }
+ }
+
+ public Response delOrgs(ChaincodeStub stub) {
+ try {
+ _logger.info("Invoking delOrgs");
+ List parameters = stub.getParameters();
+ if (parameters.size() < 2) {
+ return newErrorResponse("No orgs to delete specified");
+ }
+
+ byte[] epBytes;
+ if ("pub".equals(parameters.get(0))) {
+ epBytes = stub.getStateValidationParameter("pub");
+ } else if ("priv".equals(parameters.get(0))) {
+ epBytes = stub.getPrivateDataValidationParameter("col", "priv");
+ } else {
+ return newErrorResponse("Unknown key specified");
+ }
+
+ StateBasedEndorsement ep = StateBasedEndorsementFactory.getInstance().newStateBasedEndorsement(epBytes);
+ // delete organizations from the endorsement policy of that key
+ ep.delOrgs(parameters.subList(1, parameters.size()).toArray(new String[]{}));
+ epBytes = ep.policy();
+ if ("pub".equals(parameters.get(0))) {
+ stub.setStateValidationParameter("pub", epBytes);
+ } else {
+ stub.setPrivateDataValidationParameter("col", "priv", epBytes);
+ }
+
+ stub.setStateValidationParameter("endorsed_state", epBytes);
+
+ return newSuccessResponse(new byte[]{});
+ } catch (Throwable e) {
+ return newErrorResponse(e);
+ }
+ }
+
+ public Response listOrgs(ChaincodeStub stub) {
+ try {
+ _logger.info("Invoking listOrgs");
+ List parameters = stub.getParameters();
+ if (parameters.size() < 1) {
+ return newErrorResponse("No key specified");
+ }
+
+ byte[] epBytes;
+ if ("pub".equals(parameters.get(0))) {
+ epBytes = stub.getStateValidationParameter("pub");
+ } else if ("priv".equals(parameters.get(0))) {
+ epBytes = stub.getPrivateDataValidationParameter("col", "priv");
+ } else {
+ return newErrorResponse("Unknown key specified");
+ }
+ StateBasedEndorsement ep = StateBasedEndorsementFactory.getInstance().newStateBasedEndorsement(epBytes);
+
+ List orgs = ep.listOrgs();
+ JsonArray orgsList = new JsonArray();
+ orgs.forEach(org -> orgsList.add(org));
+ return newSuccessResponse(orgsList.toString().getBytes());
+ } catch (Throwable e) {
+ return newErrorResponse(e);
+ }
+ }
+
+ public Response delEP(ChaincodeStub stub) {
+ try {
+ _logger.info("Invoking delEP");
+ List parameters = stub.getParameters();
+ if (parameters.size() < 1) {
+ return newErrorResponse("No key specified");
+ }
+
+ if ("pub".equals(parameters.get(0))) {
+ stub.setStateValidationParameter("pub", null);
+ } else if ("priv".equals(parameters.get(0))) {
+ stub.setPrivateDataValidationParameter("col", "priv", null);
+ } else {
+ return newErrorResponse("Unknown key specified");
+ }
+ return newSuccessResponse(new byte[]{});
+ } catch (Throwable e) {
+ return newErrorResponse(e);
+ }
+ }
+
+ public Response setVal(ChaincodeStub stub) {
+ try {
+ _logger.info("Invoking setVal");
+ List parameters = stub.getParameters();
+ if (parameters.size() != 2) {
+ return newErrorResponse("setval expects two arguments");
+ }
+
+ if ("pub".equals(parameters.get(0))) {
+ stub.putStringState("pub", parameters.get(1));
+ _logger.info("Put state "+parameters.get(1));
+ } else if ("priv".equals(parameters.get(0))) {
+ stub.putPrivateData("col", "priv", parameters.get(1));
+ _logger.info("Put Private "+parameters.get(1));
+ } else {
+ return newErrorResponse("Unknown key specified");
+ }
+ return newSuccessResponse(new byte[]{});
+ } catch (Throwable e) {
+ e.printStackTrace();
+ return newErrorResponse(e);
+ }
+ }
+
+ public Response getVal(ChaincodeStub stub) {
+ try {
+ _logger.info("Invoking getVal");
+ List parameters = stub.getParameters();
+ if (parameters.size() != 1) {
+ return newErrorResponse("setval expects one argument");
+ }
+
+ if ("pub".equals(parameters.get(0))) {
+ _logger.info(stub.getState("pub"));
+ return newSuccessResponse((byte[])stub.getState("pub"));
+ } else if ("priv".equals(parameters.get(0))) {
+ byte[] d = stub.getPrivateData("col", "priv");
+ _logger.info("get privateData" + new String(d,UTF_8));
+
+ return newSuccessResponse((byte[])d);
+ } else {
+ return newErrorResponse("Unknown key specified");
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ return newErrorResponse(e);
+ }
+ }
+
+ public Response invokeCC(ChaincodeStub stub) {
+ try {
+ _logger.info("Invoking invokeCC");
+ List args = stub.getArgs();
+ if (args.size() < 3) {
+ return newErrorResponse("cc2cc expects at least two arguments (channel and chaincode)");
+ }
+ String channel = new String(args.get(1), UTF_8);
+ String cc = new String(args.get(2), UTF_8);
+
+ List nargs = args.subList(3, args.size());
+
+ return stub.invokeChaincode(cc, nargs, channel);
+ } catch (Throwable e) {
+ return newErrorResponse(e);
+ }
+ }
+
+ public static void main(String[] args) {
+ new EndorsementCC().start(args);
+ }
+
+}
diff --git a/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/CommandSingleton.java b/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/CommandSingleton.java
new file mode 100644
index 00000000..c4706121
--- /dev/null
+++ b/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/CommandSingleton.java
@@ -0,0 +1,58 @@
+/*
+Copyright 2020 IBM Corp. All Rights Reserved.
+
+SPDX-License-Identifier: Apache-2.0
+*/
+package org.hyperleder.fabric.shim.integration;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.concurrent.Semaphore;
+
+import org.hyperleder.fabric.shim.integration.Docker.DockerBuilder;
+import org.hyperleder.fabric.shim.integration.DockerCompose.DockerComposeBuilder;
+
+/** Utility class to run the setup script once */
+public class CommandSingleton {
+
+ private static boolean done = false;
+
+ private static Semaphore flag = new Semaphore(1);
+
+ public static void setup(){
+
+ try {
+ // things have not been setup up yet
+ flag.acquire();
+ if (done){
+ flag.release();
+ return;
+ }
+ // get current working directory for debug and reference purposes only
+ Path currentRelativePath = Paths.get("");
+ String s = currentRelativePath.toAbsolutePath().toString();
+ System.out.println("Current relative path is: " + s);
+
+ // create the docker-compose command
+ DockerComposeBuilder composebuilder = DockerCompose.newBuilder()
+ .file("src/test/resources/first-network/docker-compose-cli.yaml");
+
+ // close down anything running...
+ composebuilder.duplicate().down().build().run();
+
+ // ...and bring up
+ DockerCompose compose = composebuilder.up().detach().build();
+ compose.run();
+
+ // the cli container contains a script that does the channel create, joing
+ // and chaincode install/instantiate
+ DockerBuilder dockerBuilder = new Docker.DockerBuilder();
+ Docker docker = dockerBuilder.exec().container("cli").script("./scripts/script.sh").build();
+ docker.run();
+ done=true;
+ flag.release();
+ } catch (InterruptedException e){
+ throw new RuntimeException(e);
+ }
+ }
+}
\ No newline at end of file
diff --git a/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/SACCIntegrationTest.java b/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/SACCIntegrationTest.java
index 559c7ccc..fdf7c294 100644
--- a/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/SACCIntegrationTest.java
+++ b/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/SACCIntegrationTest.java
@@ -4,7 +4,8 @@
SPDX-License-Identifier: Apache-2.0
*/
package org.hyperleder.fabric.shim.integration;
-
+import java.util.ArrayList;
+import java.util.Arrays;
import static org.junit.Assert.assertThat;
import static org.hamcrest.core.StringContains.containsString;
import java.nio.file.Path;
@@ -25,58 +26,42 @@
public class SACCIntegrationTest {
@BeforeClass
- public static void setUp() throws Exception {
-
- // get current working directory for debug and reference purposes only
- Path currentRelativePath = Paths.get("");
- String s = currentRelativePath.toAbsolutePath().toString();
- System.out.println("Current relative path is: " + s);
-
- // create the docker-compose command
- DockerComposeBuilder composebuilder = DockerCompose.newBuilder()
- .file("src/test/resources/first-network/docker-compose-cli.yaml");
-
- // close down anything running...
- composebuilder.duplicate().down().build().run();
-
- // ...and bring up
- DockerCompose compose = composebuilder.up().detach().build();
- compose.run();
-
- // the cli container contains a script that does the channel create, joing
- // and chaincode install/instantiate
- DockerBuilder dockerBuilder = new Docker.DockerBuilder();
- Docker docker = dockerBuilder.exec().container("cli").script("./scripts/script.sh").build();
- docker.run();
+ public static void setUp() {
+ CommandSingleton.setup();
}
- @Test
- public void TestSACCChaincodeInstallInstantiateInvokeQuery() {
-
- // Need to send a number of 'peer chaincode invoke' commands
- // Setup the core buider command and then duplicate per test
+ private String invoke(String... args){
PeerBuilder coreBuilder = Peer.newBuilder().ccname("javacc").channel("mychannel");
- Result r;
- String text;
- // 2019-10-02 13:05:59.812 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 004 Chaincode invoke successful. result: status:200 message:"200"
-
- r = coreBuilder.duplicate().argsTx(new String[] { "set", "b", "200" }).build().run();
- text = r.stderr.stream()
+ Result r = coreBuilder.argsTx(args).build().run();
+ System.out.println(r.stderr);
+ String text = r.stderr.stream()
.filter(line -> line.matches(".*chaincodeInvokeOrQuery.*"))
- .collect(Collectors.joining(System.lineSeparator()));
- assertThat(text, containsString("result: status:200 message:\"200\""));
+ .collect(Collectors.joining(System.lineSeparator()))
+ .trim();
+
+ if (!text.contains("result: status:200")){
+ throw new RuntimeException(text);
+ }
+
+ int payloadIndex = text.indexOf("payload:");
+ if (payloadIndex>1){
+ return text.substring(payloadIndex+9,text.length()-1);
+ }
+ return "status:200";
+ }
- r = coreBuilder.duplicate().argsTx(new String[] { "get", "a" }).build().run();
- text = r.stderr.stream()
- .filter(line -> line.matches(".*chaincodeInvokeOrQuery.*"))
- .collect(Collectors.joining(System.lineSeparator()));
- assertThat(text, containsString("result: status:200 message:\"100\""));
+ @Test
+ public void TestQuery(){
- r = coreBuilder.duplicate().argsTx(new String[] { "get", "b" }).build().run();
- text = r.stderr.stream()
- .filter(line -> line.matches(".*chaincodeInvokeOrQuery.*"))
- .collect(Collectors.joining(System.lineSeparator()));
- assertThat(text, containsString("result: status:200 message:\"200\""));
+ String text = invoke(new String[]{"putBulkStates"});
+ assertThat(text, containsString("status:200"));
+
+ text = invoke(new String[]{"getByRange","key120","key170"});
+ assertThat(text, containsString("50"));
+
+ text = invoke(new String[]{"getByRangePaged","key120","key170","10",""});
+ System.out.println(text);
+ assertThat(text, containsString("key130"));
}
diff --git a/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/SBECCIntegrationTest.java b/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/SBECCIntegrationTest.java
index 209d3cb5..ed940675 100644
--- a/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/SBECCIntegrationTest.java
+++ b/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/SBECCIntegrationTest.java
@@ -28,10 +28,7 @@ public class SBECCIntegrationTest {
@BeforeClass
public static void setUp() throws Exception {
- // Call the inbuilt script to install/instantiate
- DockerBuilder dockerBuilder = new Docker.DockerBuilder();
- Docker docker = dockerBuilder.exec().container("cli").script("./scripts/script-sbe.sh").build();
- docker.run();
+ CommandSingleton.setup();
}
private String filter(List lines){
@@ -55,7 +52,7 @@ public void RunSBE_pub_setget() throws NoSuchAlgorithmException, InvalidKeySpecE
r = coreBuilder.duplicate().argsTx(new String[] { "setval", mode, "foo" }).build().run(true);
assertThat(filter(r.stderr), containsString("result: status:200"));
-
+
r = coreBuilder.duplicate().argsTx(new String[] { "getval", mode }).build().run(true);
assertThat(filter(r.stderr), containsString("result: status:200"));
@@ -155,6 +152,7 @@ public void RunSBE_priv() throws NoSuchAlgorithmException, InvalidKeySpecExcepti
text = filter(r.stderr);
assertThat(text, containsString("result: status:200 payload:\"[\\\"Org2MSP\\\",\\\"Org1MSP\\\"]\""));
+
r = coreBuilder.duplicate().argsTx(new String[] { "setval", mode, "val3" }).build().run(true);
text = filter(r.stderr);
assertThat(text, containsString("result: status:200"));
diff --git a/fabric-chaincode-integration-test/src/test/resources/first-network/base/docker-compose-base.yaml b/fabric-chaincode-integration-test/src/test/resources/first-network/base/docker-compose-base.yaml
index 54dcde48..92b58a50 100644
--- a/fabric-chaincode-integration-test/src/test/resources/first-network/base/docker-compose-base.yaml
+++ b/fabric-chaincode-integration-test/src/test/resources/first-network/base/docker-compose-base.yaml
@@ -9,7 +9,7 @@ services:
orderer.example.com:
container_name: orderer.example.com
- image: hyperledger/fabric-orderer:latest
+ image: hyperledger/fabric-orderer:1.4.8
environment:
- ORDERER_GENERAL_LOGLEVEL=INFO
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
diff --git a/fabric-chaincode-integration-test/src/test/resources/first-network/base/peer-base.yaml b/fabric-chaincode-integration-test/src/test/resources/first-network/base/peer-base.yaml
index e0df016e..27a33687 100644
--- a/fabric-chaincode-integration-test/src/test/resources/first-network/base/peer-base.yaml
+++ b/fabric-chaincode-integration-test/src/test/resources/first-network/base/peer-base.yaml
@@ -7,7 +7,7 @@ version: '2'
services:
peer-base:
- image: hyperledger/fabric-peer:latest
+ image: hyperledger/fabric-peer:1.4.8
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
# the following setting starts chaincode containers on the same
diff --git a/fabric-chaincode-integration-test/src/test/resources/first-network/docker-compose-cli.yaml b/fabric-chaincode-integration-test/src/test/resources/first-network/docker-compose-cli.yaml
index 65c1cea3..398a4d22 100644
--- a/fabric-chaincode-integration-test/src/test/resources/first-network/docker-compose-cli.yaml
+++ b/fabric-chaincode-integration-test/src/test/resources/first-network/docker-compose-cli.yaml
@@ -59,7 +59,7 @@ services:
cli:
container_name: cli
- image: hyperledger/fabric-tools:latest
+ image: hyperledger/fabric-tools:amd64-1.4.8
tty: true
stdin_open: true
environment:
@@ -81,8 +81,8 @@ services:
- ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
- ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
- ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
- - ./../../../../../fabric-chaincode-example-sacc:/opt/gopath/src/github.com/hyperledger/fabric/peer/chaincodes/sacc
- - ./../../../../../fabric-chaincode-example-sbe:/opt/gopath/src/github.com/hyperledger/fabric/peer/chaincodes/sbe
+ - ./../../../contracts/fabric-chaincode-example-sacc:/opt/gopath/src/github.com/hyperledger/fabric/peer/chaincodes/sacc
+ - ./../../../contracts/fabric-chaincode-example-sbe:/opt/gopath/src/github.com/hyperledger/fabric/peer/chaincodes/sbe
depends_on:
- orderer.example.com
- peer0.org1.example.com
diff --git a/fabric-chaincode-integration-test/src/test/resources/first-network/scripts/script.sh b/fabric-chaincode-integration-test/src/test/resources/first-network/scripts/script.sh
index ce98f3d2..6a5eaf2c 100755
--- a/fabric-chaincode-integration-test/src/test/resources/first-network/scripts/script.sh
+++ b/fabric-chaincode-integration-test/src/test/resources/first-network/scripts/script.sh
@@ -75,12 +75,26 @@ updateAnchorPeers 0 2
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric/peer/chaincodes/sacc"
CC_NAME="javacc"
-echo "Installing chaincode on peer 0, org 1"
+echo "Installing chaincode ${CC_NAME} on peer 0, org 1"
installChaincode 0 1
-echo "Installing chaincode on peer 0, org 2"
+echo "Installing chaincode ${CC_NAME} on peer 0, org 2"
installChaincode 0 2
-echo "Instantiating chaincode on peer 0, org 1"
+echo "Instantiating chaincode ${CC_NAME} on peer 0, org 1"
instantiateChaincode 0 1
+
+
+CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric/peer/chaincodes/sbe"
+CC_NAME="sbecc"
+COLLECTIONS_CFG=$(realpath scripts/collection_config.json)
+
+echo "Installing chaincode ${CC_NAME} on peer 0, org 1"
+installChaincode 0 1
+echo "Installing chaincode ${CC_NAME} on peer 0, org 2"
+installChaincode 0 2
+
+echo "Instantiating chaincode ${CC_NAME} on peer 0, org 1"
+instantiateChaincodeSBE 0 1
+
# exit 0
diff --git a/fabric-chaincode-integration-test/src/test/resources/first-network/scripts/utils.sh b/fabric-chaincode-integration-test/src/test/resources/first-network/scripts/utils.sh
index 4dd4190f..f6670cd4 100755
--- a/fabric-chaincode-integration-test/src/test/resources/first-network/scripts/utils.sh
+++ b/fabric-chaincode-integration-test/src/test/resources/first-network/scripts/utils.sh
@@ -165,16 +165,30 @@ instantiateChaincode() {
# while 'peer chaincode' command can get the orderer endpoint from the peer
# (if join was successful), let's supply it directly as we know it using
# the "-o" option
- if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
- set -x
- peer chaincode instantiate -o orderer.example.com:7050 -C $CHANNEL_NAME -n javacc -l ${LANGUAGE} -v ${VERSION} -c '{"Args":["init","a","100"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')" >&log.txt
- res=$?
- set +x
+ if [ -z "$COLLECTIONS_CFG" ]; then
+ if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
+ set -x
+ peer chaincode instantiate -o orderer.example.com:7050 -C $CHANNEL_NAME -n ${CC_NAME} -l ${LANGUAGE} -v ${VERSION} -c '{"Args":[]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')" >&log.txt
+ res=$?
+ set +x
+ else
+ set -x
+ peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n javacc -l ${LANGUAGE} -v ${VERSION} -c '{"Args":[]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')" >&log.txt
+ res=$?
+ set +x
+ fi
else
- set -x
- peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n javacc -l ${LANGUAGE} -v 1.0 -c '{"Args":["init","a","100"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')" >&log.txt
- res=$?
- set +x
+ if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
+ set -x
+ peer chaincode instantiate -o orderer.example.com:7050 -C $CHANNEL_NAME -n ${CC_NAME} -l ${LANGUAGE} -v ${VERSION} -c '{"Args":[]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')" --collections-config ${COLLECTIONS_CFG} >&log.txt
+ res=$?
+ set +x
+ else
+ set -x
+ peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n javacc -l ${LANGUAGE} -v ${VERSION} -c '{"Args":[]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')" --collections-config ${COLLECTIONS_CFG} >&log.txt
+ res=$?
+ set +x
+ fi
fi
cat log.txt
verifyResult $res "Chaincode instantiation on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' failed"
diff --git a/fabric-chaincode-protos/build.gradle b/fabric-chaincode-protos/build.gradle
index 7b49c2c8..6183f1c7 100644
--- a/fabric-chaincode-protos/build.gradle
+++ b/fabric-chaincode-protos/build.gradle
@@ -52,6 +52,8 @@ dependencies {
compile 'io.grpc:grpc-netty:1.23.0'
compile 'io.grpc:grpc-protobuf:1.23.0'
compile 'io.grpc:grpc-stub:1.23.0'
+ // Required if using Java 11+ as no longer bundled in the core libraries
+ compile 'javax.annotation:javax.annotation-api:1.3.2'
}
protobuf {
diff --git a/fabric-chaincode-shim/build.gradle b/fabric-chaincode-shim/build.gradle
index e6875368..4b096116 100644
--- a/fabric-chaincode-shim/build.gradle
+++ b/fabric-chaincode-shim/build.gradle
@@ -18,7 +18,7 @@ tasks.withType(org.gradle.api.tasks.testing.Test) {
test {
// Always run tests, even when nothing changed.
dependsOn 'cleanTest'
-
+
// Show test results. Potentially useful for debugging. Comment this block
// testLogging {
// events "passed", "skipped", "failed"
@@ -26,7 +26,7 @@ test {
// showCauses true
// showStandardStreams true
// exceptionFormat "full"
-
+
// }
}
@@ -35,10 +35,12 @@ dependencies {
compile 'io.netty:netty-tcnative-boringssl-static:2.0.25.Final'
compile 'org.bouncycastle:bcpkix-jdk15on:1.62'
compile 'org.bouncycastle:bcprov-jdk15on:1.62'
- compile 'org.reflections:reflections:0.9.11'
+ compile group: 'io.github.classgraph', name: 'classgraph', version: '4.8.47'
implementation 'com.github.everit-org.json-schema:org.everit.json.schema:1.11.1'
compile 'io.swagger.core.v3:swagger-annotations:2.0.0'
implementation group: 'org.json', name: 'json', version: '20180813'
+ // Required if using Java 11+ as no longer bundled in the core libraries
+ testCompile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
}
sourceSets {
@@ -92,6 +94,7 @@ jacocoTestCoverageVerification {
'org.hyperledger.fabric.contract.ContractRouter',
'org.hyperledger.fabric.contract.routing.impl.ContractDefinitionImpl',
'org.hyperledger.fabric.contract.routing.RoutingRegistry',
+ 'org.hyperledger.fabric.contract.routing.impl.RoutingRegistryImpl',
'org.hyperledger.fabric.contract.execution.impl.ContractInvocationRequest',
'org.hyperledger.fabric.contract.routing.TransactionType',
'org.hyperledger.fabric.contract.metadata.MetadataBuilder',
@@ -115,6 +118,7 @@ jacocoTestCoverageVerification {
'org.hyperledger.fabric.contract.execution.impl.ContractInvocationRequest',
'org.hyperledger.fabric.contract.routing.impl.ContractDefinitionImpl',
'org.hyperledger.fabric.contract.routing.RoutingRegistry',
+ 'org.hyperledger.fabric.contract.routing.impl.RoutingRegistryImpl',
'org.hyperledger.fabric.shim.impl.Handler',
'org.hyperledger.fabric.shim.ChaincodeBase',
'org.hyperledger.fabric.contract.metadata.MetadataBuilder',
@@ -191,7 +195,7 @@ task licenseCheck {
javadoc {
- failOnError = false
+ failOnError = true
excludes = ['org/hyperledger/fabric/contract/ContextFactory.java',
'org/hyperledger/fabric/contract/ContractRouter.java',
'org/hyperledger/fabric/contract/ContractRuntimeException.java',
@@ -200,11 +204,13 @@ javadoc {
'org/hyperledger/fabric/contract/routing/**',
'org/hyperledger/fabric/contract/systemcontract/**',
'org/hyperledger/fabric/**/impl/**',
- 'org/hyperledger/fabric/shim/helper/**',
- 'org/hyperledger/fabric/shim/ChaincodeBase.java']
+ 'org/hyperledger/fabric/shim/helper/**']
+
source = sourceSets.main.allJava
- classpath = sourceSets.main.compileClasspath
+ classpath = sourceSets.main.runtimeClasspath
+
+ javadoc.options.addStringOption('Xdoclint:none', '-quiet')
}
if (JavaVersion.current().isJava8Compatible()) {
diff --git a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/routing/impl/RoutingRegistryImpl.java b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/routing/impl/RoutingRegistryImpl.java
index ccccff32..0598ce9b 100644
--- a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/routing/impl/RoutingRegistryImpl.java
+++ b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/routing/impl/RoutingRegistryImpl.java
@@ -6,13 +6,11 @@
package org.hyperledger.fabric.contract.routing.impl;
import java.lang.reflect.Method;
-import java.net.URL;
-import java.net.URLClassLoader;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
@@ -27,9 +25,10 @@
import org.hyperledger.fabric.contract.routing.RoutingRegistry;
import org.hyperledger.fabric.contract.routing.TxFunction;
import org.hyperledger.fabric.contract.routing.TypeRegistry;
-import org.reflections.Reflections;
-import org.reflections.util.ClasspathHelper;
-import org.reflections.util.ConfigurationBuilder;
+
+import io.github.classgraph.ClassGraph;
+import io.github.classgraph.ClassInfo;
+import io.github.classgraph.ScanResult;
/**
* Registry to hold permit access to the routing definitions. This is the
@@ -143,61 +142,80 @@ public Collection getAllDefinitions() {
*/
@SuppressWarnings("unchecked")
@Override
- public void findAndSetContracts(final TypeRegistry typeRegistry) {
- final ArrayList urls = new ArrayList<>();
- final ClassLoader[] classloaders = { getClass().getClassLoader(),
- Thread.currentThread().getContextClassLoader() };
- for (int i = 0; i < classloaders.length; i++) {
- if (classloaders[i] instanceof URLClassLoader) {
- urls.addAll(Arrays.asList(((URLClassLoader) classloaders[i]).getURLs()));
- } else {
- throw new RuntimeException("classLoader is not an instanceof URLClassLoader");
+ public void findAndSetContracts(TypeRegistry typeRegistry) {
+
+ // Find all classes that are valid contract or data type instances.
+ ClassGraph classGraph = new ClassGraph()
+ .enableClassInfo()
+ .enableAnnotationInfo();
+ List> contractClasses = new ArrayList<>();
+ List> dataTypeClasses = new ArrayList<>();
+ try (ScanResult scanResult = classGraph.scan()) {
+ for (ClassInfo classInfo : scanResult.getClassesWithAnnotation(Contract.class.getCanonicalName())) {
+ logger.fine("Found class with contract annotation: " + classInfo.getName());
+ try {
+ Class> contractClass = classInfo.loadClass();
+ logger.fine("Loaded class");
+ Contract annotation = contractClass.getAnnotation(Contract.class);
+ if (annotation == null) {
+ // Since we check by name above, it makes sense to check it's actually compatible,
+ // and not some random class with the same name.
+ logger.fine("Class does not have compatible contract annotation");
+ } else if (!ContractInterface.class.isAssignableFrom(contractClass)) {
+ logger.fine("Class is not assignable from ContractInterface");
+ } else {
+ logger.fine("Class is assignable from ContractInterface");
+ contractClasses.add((Class) contractClass);
+ }
+ } catch (IllegalArgumentException e) {
+ logger.fine("Failed to load class: " + e);
+ }
+ }
+ for (ClassInfo classInfo : scanResult.getClassesWithAnnotation(DataType.class.getCanonicalName())) {
+ logger.fine("Found class with data type annotation: " + classInfo.getName());
+ try {
+ Class> dataTypeClass = classInfo.loadClass();
+ logger.fine("Loaded class");
+ DataType annotation = dataTypeClass.getAnnotation(DataType.class);
+ if (annotation == null) {
+ // Since we check by name above, it makes sense to check it's actually compatible,
+ // and not some random class with the same name.
+ logger.fine("Class does not have compatible data type annotation");
+ } else {
+ logger.fine("Class has compatible data type annotation");
+ dataTypeClasses.add(dataTypeClass);
+ }
+ } catch (IllegalArgumentException e) {
+ logger.fine("Failed to load class: " + e);
+ }
}
}
- final ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
- configurationBuilder.addUrls(urls);
- configurationBuilder.addUrls(ClasspathHelper.forJavaClassPath());
- configurationBuilder.addUrls(ClasspathHelper.forManifest());
- final Reflections ref = new Reflections(configurationBuilder);
-
- logger.info("Searching chaincode class in urls: " + configurationBuilder.getUrls());
-
// set to ensure that we don't scan the same class twice
final Set seenClass = new HashSet<>();
// loop over all the classes that have the Contract annotation
- for (final Class> cl : ref.getTypesAnnotatedWith(Contract.class)) {
- logger.info("Found class: " + cl.getCanonicalName());
- if (ContractInterface.class.isAssignableFrom(cl)) {
- logger.fine("Inheritance ok");
- final String className = cl.getCanonicalName();
-
- if (!seenClass.contains(className)) {
- final ContractDefinition contract = addNewContract((Class) cl);
+ for (Class contractClass : contractClasses) {
+ String className = contractClass.getCanonicalName();
+ if (!seenClass.contains(className)) {
+ ContractDefinition contract = addNewContract((Class) contractClass);
- logger.fine("Searching annotated methods");
- for (final Method m : cl.getMethods()) {
- if (m.getAnnotation(Transaction.class) != null) {
- logger.fine("Found annotated method " + m.getName());
+ logger.fine("Searching annotated methods");
+ for (Method m : contractClass.getMethods()) {
+ if (m.getAnnotation(Transaction.class) != null) {
+ logger.fine("Found annotated method " + m.getName());
- contract.addTxFunction(m);
+ contract.addTxFunction(m);
- }
}
-
- seenClass.add(className);
}
- } else {
- logger.fine("Class is not assignabled from Contract");
+
+ seenClass.add(className);
}
}
// now need to look for the data types have been set with the
- logger.info("Looking for the data types");
- final Set> czs = ref.getTypesAnnotatedWith(DataType.class);
- logger.info("found " + czs.size());
- czs.forEach(typeRegistry::addDataType);
+ dataTypeClasses.forEach(typeRegistry::addDataType);
}
diff --git a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/impl/InnvocationStubImpl.java b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/impl/InnvocationStubImpl.java
index 211caa88..3e79d365 100644
--- a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/impl/InnvocationStubImpl.java
+++ b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/impl/InnvocationStubImpl.java
@@ -298,7 +298,7 @@ private QueryResultsIteratorWithMetadataImpl executeGetStateByRangeWit
ByteString payload = GetStateByRange.newBuilder().setCollection(collection).setStartKey(startKey)
.setEndKey(endKey).setMetadata(metadata).build().toByteString();
- ChaincodeMessage requestMessage = ChaincodeMessageFactory.newEventMessage(GET_STATE_BY_RANGE, startKey, endKey,
+ final ChaincodeMessage requestMessage = ChaincodeMessageFactory.newEventMessage(GET_STATE_BY_RANGE, channelId, txId,
payload);
ByteString response = this.handler.invoke(requestMessage);
diff --git a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/impl/InnvocationTaskManager.java b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/impl/InnvocationTaskManager.java
index 1a7ba2ec..a5cb09e6 100644
--- a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/impl/InnvocationTaskManager.java
+++ b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/impl/InnvocationTaskManager.java
@@ -90,15 +90,17 @@ public InnvocationTaskManager(ChaincodeBase chaincode, ChaincodeID chaincodeId)
// setup the thread pool here
Properties props = chaincode.getChaincodeConfig();
- queueSize = Integer.parseInt((String) props.getOrDefault("TP_QUEUE_SIZE", "1"));
- maximumPoolSize = Integer.parseInt((String) props.getOrDefault("TP_MAX_POOL_SIZE", "1"));
- corePoolSize = Integer.parseInt((String) props.getOrDefault("TP_CORE_POOL_SIZE", "1"));
+ queueSize = Integer.parseInt((String) props.getOrDefault("TP_QUEUE_SIZE", "5000"));
+ maximumPoolSize = Integer.parseInt((String) props.getOrDefault("TP_MAX_POOL_SIZE", "5"));
+ corePoolSize = Integer.parseInt((String) props.getOrDefault("TP_CORE_POOL_SIZE", "5"));
keepAliveTime = Long.parseLong((String) props.getOrDefault("TP_KEEP_ALIVE_MS", "5000"));
- workQueue = new LinkedBlockingQueue(queueSize);
-
- logger.info(() -> "Max Pool Size" + maximumPoolSize);
+ logger.info(() -> "Max Pool Size [TP_MAX_POOL_SIZE]" + maximumPoolSize);
+ logger.info(() -> "Queue Size [TP_CORE_POOL_SIZE]" + queueSize);
+ logger.info(() -> "Core Pool Size [TP_QUEUE_SIZE]" + corePoolSize);
+ logger.info(() -> "Keep Alive Time [TP_KEEP_ALIVE_MS]" + keepAliveTime);
+ workQueue = new LinkedBlockingQueue(queueSize);
taskService = new InnvocationTaskExecutor(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue,
threadFactory, handler);
diff --git a/fabric-contract-example/gradle/build.gradle b/fabric-contract-example/gradle/build.gradle
index 21087a62..bbdfc56c 100644
--- a/fabric-contract-example/gradle/build.gradle
+++ b/fabric-contract-example/gradle/build.gradle
@@ -14,13 +14,13 @@ repositories {
url "https://www.jitpack.io"
}
maven {
- url "https://nexus.hyperledger.org/content/repositories/snapshots/"
+ url "https://hyperledger.jfrog.io/hyperledger/fabric-maven"
}
}
dependencies {
- compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.4-SNAPSHOT'
+ compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.8'
compile group: 'org.json', name: 'json', version: '20180813'
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
testImplementation 'org.assertj:assertj-core:3.11.1'
diff --git a/fabric-contract-example/maven/pom.xml b/fabric-contract-example/maven/pom.xml
index 08cd56d0..3e976b60 100644
--- a/fabric-contract-example/maven/pom.xml
+++ b/fabric-contract-example/maven/pom.xml
@@ -12,7 +12,7 @@
UTF-8
- 1.4.4-SNAPSHOT
+ 1.4.8
1.0.13
@@ -30,8 +30,8 @@
https://www.jitpack.io
- nexus
- https://nexus.hyperledger.org/content/repositories/snapshots/
+ artifactory
+ https://hyperledger.jfrog.io/hyperledger/fabric-maven
diff --git a/release_notes/v1.4.4.txt b/release_notes/v1.4.4.txt
new file mode 100644
index 00000000..5f38432c
--- /dev/null
+++ b/release_notes/v1.4.4.txt
@@ -0,0 +1,31 @@
+v1.4.4 11 November 2019
+----------------------------
+
+Release Notes
+-------------
+
+The Contract Programming model was introduced with v1.4.3; this release has fixes
+upong the original version that improvde stability and performance.
+
+This version should be used in real scenarios.
+
+For more information on the Contract Programming Model please
+see https://hyperledger-fabric.readthedocs.io/en/developapps/developing_applications.html
+
+baseimage version: 0.4.15
+Java version: openjdk version "1.8.0_181"
+
+Known Vulnerabilities
+---------------------
+none
+
+Resolved Vulnerabilities
+------------------------
+none
+
+Known Issues & Workarounds
+--------------------------
+none
+Change Log
+----------
+https://github.com/hyperledger/fabric-chaincode-java/blob/release-1.4/CHANGELOG.md#v144
\ No newline at end of file
diff --git a/release_notes/v1.4.5.txt b/release_notes/v1.4.5.txt
new file mode 100644
index 00000000..e603bf6e
--- /dev/null
+++ b/release_notes/v1.4.5.txt
@@ -0,0 +1,33 @@
+v1.4.5 16 January 2020
+----------------------------
+
+Release Notes
+-------------
+
+The work in this release has been primarily the move to github, Azure Pipelines
+and artifactory
+
+The main fix is to correct set the default values of the internal thread pools
+(https://jira.hyperledger.org/browse/FAB-17100)
+
+
+For more information on the Contract Programming Model please
+see https://hyperledger-fabric.readthedocs.io/en/developapps/developing_applications.html
+
+baseimage version: 0.4.15
+Java version: openjdk version "1.8.0_181"
+
+Known Vulnerabilities
+---------------------
+none
+
+Resolved Vulnerabilities
+------------------------
+none
+
+Known Issues & Workarounds
+--------------------------
+none
+Change Log
+----------
+https://github.com/hyperledger/fabric-chaincode-java/blob/release-1.4/CHANGELOG.md#v145
\ No newline at end of file
diff --git a/release_notes/v1.4.6.txt b/release_notes/v1.4.6.txt
new file mode 100644
index 00000000..3771b8e0
--- /dev/null
+++ b/release_notes/v1.4.6.txt
@@ -0,0 +1,27 @@
+v1.4.6 04 March 2020
+----------------------------
+
+Release Notes
+-------------
+
+This release includes changes to tolerate the use of Java 11.
+It does not update default JVM used, but backports fixes from v2.0.
+
+
+baseimage version: 0.4.15
+Java version: openjdk version "1.8.0_181"
+
+Known Vulnerabilities
+---------------------
+none
+
+Resolved Vulnerabilities
+------------------------
+none
+
+Known Issues & Workarounds
+--------------------------
+none
+Change Log
+----------
+https://github.com/hyperledger/fabric-chaincode-java/blob/release-1.4/CHANGELOG.md#v146
\ No newline at end of file
diff --git a/release_notes/v1.4.7.txt b/release_notes/v1.4.7.txt
new file mode 100644
index 00000000..7c4ac3ca
--- /dev/null
+++ b/release_notes/v1.4.7.txt
@@ -0,0 +1,22 @@
+v1.4.7 08 October 2020
+ --------------------------
+
+ Release Notes
+ -------------
+ This is a bug fix release.
+
+ Known Vulnerabilities
+ ---------------------
+ none
+
+ Resolved Vulnerabilities
+ ------------------------
+ none
+
+ Known Issues & Workarounds
+ --------------------------
+ none
+
+ Change Log
+ ----------
+ https://github.com/hyperledger/fabric-chaincode-java/blob/release-1.4/CHANGELOG.md#v147
\ No newline at end of file
diff --git a/release_notes/v1.4.8.txt b/release_notes/v1.4.8.txt
new file mode 100644
index 00000000..d540a552
--- /dev/null
+++ b/release_notes/v1.4.8.txt
@@ -0,0 +1,22 @@
+v1.4.8 04 November 2020
+ --------------------------
+
+ Release Notes
+ -------------
+ This is a bug fix release.
+
+ Known Vulnerabilities
+ ---------------------
+ none
+
+ Resolved Vulnerabilities
+ ------------------------
+ none
+
+ Known Issues & Workarounds
+ --------------------------
+ none
+
+ Change Log
+ ----------
+ https://github.com/hyperledger/fabric-chaincode-java/blob/release-1.4/CHANGELOG.md#v148
\ No newline at end of file
diff --git a/scripts/changelog.sh b/scripts/changelog.sh
index 1ea8328e..b74634c4 100755
--- a/scripts/changelog.sh
+++ b/scripts/changelog.sh
@@ -4,11 +4,19 @@
#
# SPDX-License-Identifier: Apache-2.0
#
+set -ev
+PREVIOUS_TAG=$1
+NEW_VERSION=$2
-echo "## $2\n$(date)" >> CHANGELOG.new
+: ${PREVIOUS_TAG:?}
+: ${NEW_VERSION:?}
+
+echo "## ${NEW_VERSION}" >> CHANGELOG.new
+echo "$(date)" >> CHANGELOG.new
echo "" >> CHANGELOG.new
-git log $1..HEAD --oneline | grep -v Merge | sed -e "s/\[\(FAB-[0-9]*\)\]/\[\1\](https:\/\/jira.hyperledger.org\/browse\/\1\)/" -e "s/ \(FAB-[0-9]*\)/ \[\1\](https:\/\/jira.hyperledger.org\/browse\/\1\)/" -e "s/\([0-9|a-z]*\)/* \[\1\](https:\/\/github.com\/hyperledger\/fabric-chaincode-java\/commit\/\1)/" >> CHANGELOG.new
+git log ${PREVIOUS_TAG}..HEAD --oneline | grep -v Merge | sed -e "s/\[\{0,1\}\(FAB[^0-9]*-[0-9]*\)\]\{0,1\}/\[\1\](https:\/\/jira.hyperledger.org\/browse\/\1\)/" -e "s/\([0-9|a-z]*\)/* \[\1\](https:\/\/github.com\/hyperledger\/fabric-chaincode-java\/commit\/\1)/" >> CHANGELOG.new
echo "" >> CHANGELOG.new
cat CHANGELOG.md >> CHANGELOG.new
mv -f CHANGELOG.new CHANGELOG.md
+
diff --git a/scripts/multiarch.sh b/scripts/multiarch.sh
deleted file mode 100755
index f3eb4587..00000000
--- a/scripts/multiarch.sh
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/bin/sh
-#
-# Copyright IBM Corp. All Rights Reserved.
-#
-# SPDX-License-Identifier: Apache-2.0
-#
-# This script publishes the fabric docker images to hyperledger dockerhub and nexus3 repositories.
-# when publishing the images to dockerhub the values for NS_PULL & NS_PUSH variables set to default values.
-# when publishing the images to nexus3 repository the values for NS_PULL & NS_PUSH variables set like below
-# NS_PULL=nexus3.hyperledger.org:10001/hyperledger & NS_PUSH=nexus3.hyperledger.org:10002/hyperledger
-# since nexus has separate port numbers to pull and push the images to nexus3.
-
-usage() {
- echo "Usage: $0 "
- echo " and credentials for the repository"
- echo "ENV:"
- echo " NS_PULL=$NS_PULL"
- echo " NS_PUSH=$NS_PUSH"
- echo " VERSION=$VERSION"
- echo " TWO_DIGIT_VERSION=$TWO_DIGIT_VERSION"
- exit 1
-}
-
-missing() {
- echo "Error: some image(s) missing from registry"
- echo "ENV:"
- echo " NS_PULL=$NS_PULL"
- echo " NS_PUSH=$NS_PUSH"
- echo " VERSION=$VERSION"
- echo " TWO_DIGIT_VERSION=$TWO_DIGIT_VERSION"
- exit 1
-}
-
-failed() {
- echo "Error: multiarch manifest push failed"
- echo "ENV:"
- echo " NS_PULL=$NS_PULL"
- echo " NS_PUSH=$NS_PUSH"
- echo " VERSION=$VERSION"
- echo " TWO_DIGIT_VERSION=$TWO_DIGIT_VERSION"
- exit 1
-}
-
-USER=${1:-nobody}
-PASSWORD=${2:-nohow}
-NS_PULL=${NS_PULL:-hyperledger}
-NS_PUSH=${NS_PUSH:-hyperledger}
-VERSION=${BASE_VERSION:-1.4.1}
-TWO_DIGIT_VERSION=${TWO_DIGIT_VERSION:-1.4}
-
-if [ "$#" -ne 2 ]; then
- usage
-fi
-
-# verify that manifest-tool is installed and found on PATH
-which manifest-tool
-if [ "$?" -ne 0 ]; then
- echo "manifest-tool not installed or not found on PATH"
- exit 1
-fi
-
-IMAGES="fabric-javaenv"
-
-# check that all images have been published
-for image in ${IMAGES}; do
- docker pull ${NS_PULL}/${image}:amd64-${VERSION} || missing
-done
-
-# push the multiarch manifest and tag with $VERSION,$TWO_DIGIT_VERSION and latest tag
-for image in ${IMAGES}; do
- manifest-tool --username ${USER} --password ${PASSWORD} push from-args\
- --platforms linux/amd64 --template "${NS_PULL}/${image}:ARCH-${VERSION}"\
- --target "${NS_PUSH}/${image}:${VERSION}"
- manifest-tool --username ${USER} --password ${PASSWORD} push from-args\
- --platforms linux/amd64 --template "${NS_PULL}/${image}:ARCH-${VERSION}"\
- --target "${NS_PUSH}/${image}:latest"
- manifest-tool --username ${USER} --password ${PASSWORD} push from-args\
- --platforms linux/amd64 --template "${NS_PULL}/${image}:ARCH-${VERSION}"\
- --target "${NS_PUSH}/${image}:${TWO_DIGIT_VERSION}"
-done
-
-# test that manifest is working as expected
-for image in ${IMAGES}; do
- docker pull ${NS_PULL}/${image}:${VERSION} || failed
- docker pull ${NS_PULL}/${image}:${TWO_DIGIT_VERSION} || failed
- docker pull ${NS_PULL}/${image}:latest || failed
-done
-
-echo "Successfully pushed multiarch manifest"
-exit 0