hyperledger-fabrichyperledger-chaincode

Hyperledger fabric add index to java chaincode


Is it possible to add index to chaincode written in java? Looking at the tutorials and sample projects all is only with GO or JS very little info about java. If i want to add index to asset to i need to write the chaincode in GO?

I have places the META-INF folder everywhere but still no index is created. Im beginning to think that either the depolyCC.sh script cant handle it in case of java or there needs to be something made inside the gradle.build file. What might be the issue and how to fix it ?

EDIT

I read through some opf the deploiment scripts. Seems like for java its looking in the wrong place for META-INF. Since META-INF is in the root of chaingode and gradle does not but it into the build folder, packageChaincode is inside the build dir and never sees META-INF. It feels like i need to modify gradle.build somehow to make the packager see the meta-inf

    elif [ "$CC_SRC_LANGUAGE" = "java" ]; then
  CC_RUNTIME_LANGUAGE=java

  infoln "Compiling Java code..."
  pushd $CC_SRC_PATH
  ./gradlew installDist
  popd
  successln "Finished compiling Java code"
  CC_SRC_PATH=$CC_SRC_PATH/build/install/$CC_NAME



packageChaincode() {
  ORG=$1
  setGlobals $ORG
  set -x
  peer lifecycle chaincode package ${CC_NAME}.tar.gz --path ${CC_SRC_PATH} --lang ${CC_RUNTIME_LANGUAGE} --label ${CC_NAME}_${CC_VERSION} >&log.txt
  res=$?
  { set +x; } 2>/dev/null
  cat log.txt
  verifyResult $res "Chaincode packaging on peer0.org${ORG} has failed"
  successln "Chaincode is packaged on peer0.org${ORG}"

}


Solution

  • Found the solution. Basically. gralde installDist placed everything into build/install/basic folder but META-INF was on the root level. When packaging it didnt include the META-INF folder. I added copy command into gradle.build so that it would copy the META-INF folder into the build/install/basic folder. Now when building chaincode it includes the META-INF that is in build/install/basic folder and index is created. It was issue with gradle build.