mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-19 16:15:09 +00:00
[FAB-6415] Java 11 support for Commercial Paper sample
Signed-off-by: Simon Stone <sstone1@uk.ibm.com> Change-Id: I3de1927a67723044899dce7ec22d4e46e4c6b944
This commit is contained in:
parent
3d19014bd7
commit
f2939e29c6
17 changed files with 126 additions and 86 deletions
|
|
@ -51,9 +51,9 @@ This `README.md` file is in the the `commercial-paper` directory, the source cod
|
|||
|
||||
## Running the Infrastructure
|
||||
|
||||
In one console window, run the `./roles/network-starter.sh` script; this will start the basic infrastructure and also start monitoring all the docker containers.
|
||||
In one console window, run the `./roles/network-starter.sh` script; this will start the basic infrastructure and also start monitoring all the docker containers.
|
||||
|
||||
You can cancel this if you wish to reuse the terminal, but it's best left open.
|
||||
You can cancel this if you wish to reuse the terminal, but it's best left open.
|
||||
|
||||
### Install and Instantiate the contract
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ In your 'MagnetoCorp' window run the following command
|
|||
|
||||
`./roles/magnetocorp.sh`
|
||||
|
||||
This will start a docker container for Fabric CLI commands, and put you in the correct directory for the source code.
|
||||
This will start a docker container for Fabric CLI commands, and put you in the correct directory for the source code.
|
||||
|
||||
**For a JavaScript Contract:**
|
||||
|
||||
|
|
@ -76,12 +76,18 @@ docker exec cliMagnetoCorp peer chaincode instantiate -n papercontract -v 0 -l n
|
|||
**For a Java Contract:**
|
||||
|
||||
```
|
||||
docker exec cliMagnetoCorp peer chaincode install -n papercontract -v 0 -p /opt/gopath/src/github.com/contract-java -l java
|
||||
pushd ./organization/magnetocorp/contract-java
|
||||
|
||||
./gradlew installDist
|
||||
|
||||
popd
|
||||
|
||||
docker exec cliMagnetoCorp peer chaincode install -n papercontract -v 0 -p /opt/gopath/src/github.com/contract-java/build/install/papercontract -l java
|
||||
|
||||
docker exec cliMagnetoCorp peer chaincode instantiate -n papercontract -v 0 -l java -c '{"Args":["org.papernet.commercialpaper:instantiate"]}' -C mychannel -P "AND ('Org1MSP.member')"
|
||||
```
|
||||
|
||||
> If you want to try both a Java and JavaScript Contract, then you will need to restart the infrastructure and deploy the other contract.
|
||||
|
||||
> If you want to try both a Java and JavaScript Contract, then you will need to restart the infrastructure and deploy the other contract.
|
||||
|
||||
## Client Applications
|
||||
|
||||
|
|
@ -100,16 +106,16 @@ npm install
|
|||
|
||||
> Note that there is NO dependency between the langauge of any one client application and any contract. Mix and match as you wish!
|
||||
|
||||
### Issue the paper
|
||||
### Issue the paper
|
||||
|
||||
This is running as *MagnetoCorp* so you can stay in the same window. These commands are to be run in the
|
||||
This is running as *MagnetoCorp* so you can stay in the same window. These commands are to be run in the
|
||||
`commercial-paper/organization/magnetocorp/application` directory or the `commercial-paper/organization/magnetocorp/application-java`
|
||||
|
||||
*Add the Identity to be used*
|
||||
|
||||
```
|
||||
node addToWallet.js
|
||||
# or
|
||||
# or
|
||||
java -cp target/commercial-paper-0.0.1-SNAPSHOT.jar org.magnetocorp.AddToWallet
|
||||
```
|
||||
|
||||
|
|
@ -117,25 +123,25 @@ java -cp target/commercial-paper-0.0.1-SNAPSHOT.jar org.magnetocorp.AddToWallet
|
|||
|
||||
```
|
||||
node issue.js
|
||||
# or
|
||||
# or
|
||||
java -cp target/commercial-paper-0.0.1-SNAPSHOT.jar org.magnetocorp.Issue
|
||||
```
|
||||
|
||||
### Buy and Redeem the paper
|
||||
|
||||
This is running as *Digibank*; you've not acted as this organization before so in your 'Digibank' window run the following command in the
|
||||
This is running as *Digibank*; you've not acted as this organization before so in your 'Digibank' window run the following command in the
|
||||
`fabric-samples/commercial-paper/` directory
|
||||
|
||||
`./roles/digibank.sh`
|
||||
`./roles/digibank.sh`
|
||||
|
||||
You can now run the applications to buy and redeem the paper. Change to either the
|
||||
You can now run the applications to buy and redeem the paper. Change to either the
|
||||
`commercial-paper/organization/digibank/application` directory or `commercial-paper/organization/digibank/application-java`
|
||||
|
||||
*Add the Identity to be used*
|
||||
|
||||
```
|
||||
node addToWallet.js
|
||||
# or
|
||||
# or
|
||||
java -cp target/commercial-paper-0.0.1-SNAPSHOT.jar org.digibank.AddToWallet
|
||||
```
|
||||
|
||||
|
|
@ -151,6 +157,6 @@ java -cp target/commercial-paper-0.0.1-SNAPSHOT.jar org.digibank.Buy
|
|||
|
||||
```
|
||||
node redeem.js
|
||||
# or
|
||||
# or
|
||||
java -cp target/commercial-paper-0.0.1-SNAPSHOT.jar org.digibank.Redeem
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,3 +1,10 @@
|
|||
.gradle/
|
||||
build/
|
||||
bin/
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
/.classpath
|
||||
/.gradle/
|
||||
/.project
|
||||
/.settings/
|
||||
/bin/
|
||||
/build/
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
plugins {
|
||||
id 'com.github.johnrengelman.shadow' version '2.0.3'
|
||||
id 'java'
|
||||
id 'java-library-distribution'
|
||||
}
|
||||
|
||||
version '0.0.1'
|
||||
|
|
@ -8,11 +7,10 @@ version '0.0.1'
|
|||
sourceCompatibility = 1.8
|
||||
|
||||
repositories {
|
||||
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven {
|
||||
url 'https://jitpack.io'
|
||||
maven {
|
||||
url 'https://jitpack.io'
|
||||
}
|
||||
maven {
|
||||
url "https://nexus.hyperledger.org/content/repositories/snapshots/"
|
||||
|
|
@ -21,23 +19,13 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.2'
|
||||
compileOnly group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.2'
|
||||
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'
|
||||
testImplementation 'org.mockito:mockito-core:2.+'
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
baseName = 'chaincode'
|
||||
version = null
|
||||
classifier = null
|
||||
|
||||
manifest {
|
||||
attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter'
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
testLogging {
|
||||
|
|
@ -45,7 +33,6 @@ test {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-parameters"
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
|||
|
|
@ -1,5 +1,21 @@
|
|||
#!/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
|
||||
|
|
@ -28,7 +44,7 @@ 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=""
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
|
@ -109,8 +125,8 @@ 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
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
@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
|
||||
|
|
@ -14,7 +30,7 @@ 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=
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
rootProject.name = 'java-contractcontract'
|
||||
rootProject.name = 'papercontract'
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class CommercialPaperContract implements ContractInterface {
|
|||
|
||||
// create an instance of the paper
|
||||
CommercialPaper paper = CommercialPaper.createInstance(issuer, paperNumber, issueDateTime, maturityDateTime,
|
||||
faceValue,"");
|
||||
faceValue,issuer,"");
|
||||
|
||||
// Smart contract, rather than paper, moves paper into ISSUED state
|
||||
paper.setIssued();
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="bin/main" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="gradle_scope" value="main"/>
|
||||
<attribute name="gradle_used_by_scope" value="main,test"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="bin/test" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="gradle_scope" value="test"/>
|
||||
<attribute name="gradle_used_by_scope" value="test"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
|
||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||
<classpathentry kind="output" path="bin/default"/>
|
||||
</classpath>
|
||||
|
|
@ -1,3 +1,10 @@
|
|||
.gradle/
|
||||
build/
|
||||
bin/
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
/.classpath
|
||||
/.gradle/
|
||||
/.project
|
||||
/.settings/
|
||||
/bin/
|
||||
/build/
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
plugins {
|
||||
id 'com.github.johnrengelman.shadow' version '2.0.3'
|
||||
id 'java'
|
||||
id 'java-library-distribution'
|
||||
}
|
||||
|
||||
version '0.0.1'
|
||||
|
|
@ -8,11 +7,10 @@ version '0.0.1'
|
|||
sourceCompatibility = 1.8
|
||||
|
||||
repositories {
|
||||
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven {
|
||||
url 'https://jitpack.io'
|
||||
maven {
|
||||
url 'https://jitpack.io'
|
||||
}
|
||||
maven {
|
||||
url "https://nexus.hyperledger.org/content/repositories/snapshots/"
|
||||
|
|
@ -21,23 +19,13 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.2'
|
||||
compileOnly group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.2'
|
||||
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'
|
||||
testImplementation 'org.mockito:mockito-core:2.+'
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
baseName = 'chaincode'
|
||||
version = null
|
||||
classifier = null
|
||||
|
||||
manifest {
|
||||
attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter'
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
testLogging {
|
||||
|
|
@ -45,7 +33,6 @@ test {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-parameters"
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
|||
|
|
@ -1,5 +1,21 @@
|
|||
#!/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
|
||||
|
|
@ -28,7 +44,7 @@ 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=""
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
|
@ -109,8 +125,8 @@ 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
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
@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
|
||||
|
|
@ -14,7 +30,7 @@ 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=
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
rootProject.name = 'java-contractcontract'
|
||||
rootProject.name = 'papercontract'
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue