How to access local maven repository when building fabric chaincode with gradle inside docker?

258 views Asked by At

I have an artifact with common functions of my project installed as a jar in the local mavel repository, lets call it common.jar. Now I want to use these functions in my fabric chaincode. I added the dependency in the gradle build file of the chaincode, Intellij can built the chaincode with no problems. I now try to deploy the chaincode to the test-network of the fabric samples. I.e.

peer lifecycle chaincode install chaincode.tar.gz

This will spin up gradle inside the docker-container which is the fabric peer node. This gradle instance then tells me it cannot find my common.jar. I suspect the gradle inside the docker container cannot access the local maven repo where the jar resides. I am quite unfamiliar with docker configurations and the fabric sample network config is huge. How can I make my local maven repo availiable inside the dockered peer?

1

There are 1 answers

0
Calanais On

There are several ways of handling 3rd party dependencies like this. Some more applicable to a development context - keep this in mind when deploying into production.

  1. Though this isn't specifically what you asked, one option is to publish the module to a repository. Applicable more in a production context.

  2. You can create an 'uber-jar' or a set of JAR files and put these inside the chaincode package. It's NOT a requirement for the code to be actually built by the peer. In fact pre-building the code into one or more JARs is actaully better. You get more reproduceable consistent builds. Check this reference for details on how to do that

  3. An option that we use when developing new versions of the chaincode library itself, is to publish your module to a repository that is within the chaincode directory itself. Then reference that in your build gradle. This is the script we use for this. Should be possible to craft something similar here.