vishal gawde
vishal gawde

Reputation: 168

Adding one cordapp as corda jar dependency to other corda project

Added one cordApp as dependency in other corda project. I want to include its jar as dependency of one corda project to other project.

This is project structure with below dependency order:

  1. contractstate
  2. flownormal
  3. flowobserver
  4. api

enter image description here

I have tried to add it as dependecy in cordapps of deployNodes as follow:

task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
    directory "./build/nodes"
    node {
        name "O=Notary,L=London,C=GB"
        notary = [validating : false]
        p2pPort 10006
        cordapps = ["$corda_release_distribution:corda-finance:$corda_release_version", ":contractstate", ":flowobserver", project(":flownormal")]
    }
    node {
        name "O=PartyA,L=London,C=GB,CN=PartyA"
        p2pPort 10007
        rpcSettings {
            address("localhost:10008")
            adminAddress("localhost:10048")
        }
        webPort 10009
        cordapps = ["$corda_release_distribution:corda-finance:$corda_release_version", ":contractstate", ":flowobserver", ":flownormal"]
        rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
    }
    node {
        name "O=PartyB,L=New York,C=US,CN=PartyB"
        p2pPort 10010
        rpcSettings {
            address("localhost:10011")
            adminAddress("localhost:10051")
        }
        webPort 10012
        cordapps = ["$corda_release_distribution:corda-finance:$corda_release_version", ":contractstate", ":flowobserver", ":flownormal"]
        rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
    }
    node {
        name "O=PartyC,L=Paris,C=FR,CN=PartyC"
        p2pPort 10013
        rpcSettings {
            address("localhost:10014")
            adminAddress("localhost:10054")
        }
        webPort 10015
        cordapps = ["$corda_release_distribution:corda-finance:$corda_release_version", ":contractstate", ":flowobserver"]
        rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
    }
}

After running tsk checking cordapps inside of each node generates single jar:

enter image description here

Cordapp must include other dependent corda project jars too... in order to do it what needs to be done ?

Needs to add other corda project jars as dependency same as finance jar.

Upvotes: 0

Views: 342

Answers (1)

Joel
Joel

Reputation: 23140

As of Corda 3, you need to include the CorDapps in the deployNodes cordapps block using the following syntax:

cordapps = [
    "net.corda.examples.oracle:base:$version", 
    "net.corda.examples.oracle:client:$version"
]

You also need to set the CorDapps as dependencies in your build.gradle file's dependencies block. You can either use:

  • cordapp project(":another-cordapp")

    • Use this if the other CorDapp is defined in a module in the same project
  • cordapp "net.corda:another-cordapp:1.0"

    • Use this otherwise

If the CorDapps you were depending on where defined in another repo (this isn't the case here), you'd then have to place the CorDapp JARs in one of the repositories in your build.gradle file's repositories block. For example, you could place the CorDapp JARs in a libs folder in your project then add the following to the repositories block:

flatDir {
    dirs 'libs'
}

Upvotes: 1

Related Questions