0
votes

Suppose I have a small RPC client application for corda, which should be uploaded into node, and be called to do some utility work on node. In build.gradle file of my utility RPC client I have just the following dependency cordaCompile "$corda_release_group:corda-rpc:$corda_release_version" and my JAR task looks like this

jar {
    version = ''
    baseName = 'rpc_utility'
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    manifest {
        attributes 'Main-Class': 'com.example.rpcclient.MainKt'
    }
    zip64=true

    from { (configurations.compile).collect { it.isDirectory() ? it : zipTree(it) } } 
}

but when I create my jar, it results in 58 MB Jar file, with all the dependencies of Corda in it, which are already there inside the node, packed in the corda.jar file. And cordapps can use these libraries without having them inside their JAR files.

Now the question is, how should I configure my jar task and what should I include inside it to tell Java that all the dependencies it needs are right there, in the same folder inside corda.jar file.

P.S. I also tried to create a fat jar like I do now, and then minify it with Proguard, but even after a long proguard-rules list I still have errors, as Proguard seems to remove a lot of files that Corda needs, so this seems to be not a good solution, and even if I succeed, I will get a ~20 MB file, just for a few lines of code that I have in real...

1

1 Answers

1
votes

The client jar is about the right size. It not only includes the dependencies for Corda but also includes your actual CorDapp jars as well (Contract & workflows). The reason is that the:

  1. RPC client needs to talk to the Corda node, so it needs the Corda dependencies.
  2. It also needs to understand your CorDapps as your controller will invoke the flow directly.