Skip to content

Commit 796dc0b

Browse files
committed
update run.dev and add gradlew
Signed-off-by: Osama Rabea <159753803+OsamaRab3@users.noreply.github.com>
1 parent a090b29 commit 796dc0b

File tree

3 files changed

+285
-4
lines changed

3 files changed

+285
-4
lines changed

samples/chaincodes/java-chaincode/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
.gradle/
33
build/
44
gradle/
5-
gradlew
65
gradlew.bat
76

87
# IDE files

samples/chaincodes/java-chaincode/gradlew

Lines changed: 251 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,47 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
echo "Checking if chaincode is installed and running..."
6+
7+
if ! docker exec peer0.org1.example.com peer chaincode list --installed 2>/dev/null | grep -q "simple-asset"; then
8+
echo "ERROR: Chaincode 'simple-asset' is not installed on the peer."
9+
echo "Please install the chaincode first"
10+
exit 1
11+
fi
12+
13+
14+
if ! docker exec peer0.org1.example.com peer chaincode list --instantiated -C mychannel 2>/dev/null | grep -q "simple-asset"; then
15+
echo "ERROR: Chaincode 'simple-asset' is not committed to the channel."
16+
echo "Please commit the chaincode first."
17+
exit 1
18+
fi
19+
220

3-
# Build the chaincode (using shadowJar)
421
./gradlew clean shadowJar
522

23+
if [ ! -f "build/libs/java-chaincode-1.0-SNAPSHOT-all.jar" ]; then
24+
echo "Error: JAR file was not created. Build may have failed."
25+
exit 1
26+
fi
27+
28+
if ! docker ps | grep -q "peer0.org1.example.com"; then
29+
echo "Error: peer0.org1.example.com container is not running."
30+
echo "Please make sure the Fabric network is up and running."
31+
exit 1
32+
fi
33+
34+
# Get the IP address of peer0.org1.example.com
635
peer_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' peer0.org1.example.com)
736
if [ -z "$peer_ip" ]; then
837
echo "Error: Could not find peer0.org1.example.com IP address."
938
exit 1
1039
fi
1140
# Run the chaincode in dev mode
1241
CORE_CHAINCODE_LOGLEVEL=debug \
13-
CORE_PEER_TLS_ENABLED= true \
42+
CORE_PEER_TLS_ENABLED=true \
1443
CORE_CHAINCODE_ID_NAME=simple-asset:1.0 \
1544
CORE_PEER_ADDRESS=$peer_ip:7051 \
45+
CORE_CHAINCODE_LOGGING_LEVEL=DEBUG \
46+
CORE_CHAINCODE_LOGGING_SHIM=debug \
1647
java -jar build/libs/java-chaincode-1.0-SNAPSHOT-all.jar

0 commit comments

Comments
 (0)