Matthew Layton
Matthew Layton

Reputation: 42229

Corda - why is deployNodes outputting a useless JAR?

I'm performing this on Windows, so some of these operations might be different for Linux/Mac users.

Steps To Reproduce

Step 1: Clone the Corda V3 Kotlin template into a new folder

git clone https://github.com/corda/cordapp-template-kotlin.git MyFirstCorDapp

Step 2: clean and deploy nodes with gradle

./gradlew clean dN

Output

This image illustrates the JAR files that have been built and deployed into a cordapp folder for a node

enter image description here

Questions

  1. Why does deployNodes produce MyFirstCorDapp-0.1.jar? This file doesn't seem necessary.
  2. Why is cordapp-contracts-states-0.1.jar so big? Given that this was compiled directly from the kotlin template with no changes, I'd expect this to be much smaller.

Upvotes: 2

Views: 114

Answers (1)

opticyclic
opticyclic

Reputation: 8116

The reason why MyFirstCordapp-0.1.jar is appearing is because of this line:

task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {

The root project has a kotlin plugin so creates a jar so the deployNodes deploys it.

One solution would be to use a subprojects closure to skip the root project

task deployNodes(type: net.corda.plugins.Cordform) {
    subprojects.each { subproject ->
        dependsOn(
                subproject.tasks.matching { task ->
                    (task.name == 'jar')
                }
        )
    }

The reason why cordapp-contracts-states-0.1.jar is "so big" (775 KB) is because the corda gradle plugin packs some dependencies in it.

Upvotes: 4

Related Questions