1
votes

I am trying to integrate the two examples (Corda java template: https://github.com/corda/cordapp-template-java and Oracle example: https://github.com/corda/oracle-example ) so as to integrate Oracle node in the template. I changed build.gradle, settings.gradle and copied base and service package to template folder. Though, the project is not logically linked as Oracle corresponds to different service, it does compiles and create classes under build folder successfully. After re-syncing gradle project, the gradle tasks were successfully updated and I am able to run deployNodes successfully.

However, no jar is present in build/nodes/Oracle/cordapp folder.

Kindly advise if additional changes needs to be done.
Git url for changes made: https://github.com/ashubisht/cordapp-template-java/tree/OracleIntegration_IOURelV3_0307

Here's the updated gradle file

    buildscript {
        ext.corda_release_group = 'net.corda'
        ext.corda_release_version = '3.1-corda'
        ext.corda_gradle_plugins_version = '3.1.0'
        ext.junit_version = '4.12'
        ext.quasar_version = '0.7.9'
        ext.kotlin_version = '1.1.60'

        repositories {
            mavenLocal()
            mavenCentral()
            jcenter()
        }

        dependencies {
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version"
            classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version"
            classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version"
        }
    }

    repositories {
        mavenLocal()
        jcenter()
        mavenCentral()
        maven { url 'https://jitpack.io' }
        maven { url 'https://ci-artifactory.corda.r3cev.com/artifactory/corda-releases' }
    }

    apply plugin: 'kotlin'
    apply plugin: 'java'
    apply plugin: 'net.corda.plugins.cordapp'
    apply plugin: 'net.corda.plugins.cordformation'
    apply plugin: 'net.corda.plugins.quasar-utils'

    sourceSets {
        main {
            resources {
                srcDir "config/dev"
            }
        }
        test {
            resources {
                srcDir "config/test"
            }
        }
        integrationTest {
            java {
                compileClasspath += main.output + test.output
                runtimeClasspath += main.output + test.output
                srcDir file('src/integration-test/java')
            }
        }
    }

    configurations {
        integrationTestCompile.extendsFrom testCompile
        integrationTestRuntime.extendsFrom testRuntime
    }

    dependencies {
        testCompile "junit:junit:$junit_version"

        // Corda integration dependencies
        cordaCompile "$corda_release_group:corda-core:$corda_release_version"
        cordaCompile "$corda_release_group:corda-finance:$corda_release_version"
        cordaCompile "$corda_release_group:corda-jackson:$corda_release_version"
        cordaCompile "$corda_release_group:corda-rpc:$corda_release_version"
        cordaCompile "$corda_release_group:corda-node-api:$corda_release_version"
        cordaCompile "$corda_release_group:corda-webserver-impl:$corda_release_version"
        cordaRuntime "$corda_release_group:corda:$corda_release_version"
        cordaRuntime "$corda_release_group:corda-webserver:$corda_release_version"

        testCompile "$corda_release_group:corda-node-driver:$corda_release_version"

        // CorDapp dependencies
        // Specify your CorDapp's dependencies below, including dependent CorDapps.
        // We've defined Cash as a dependent CorDapp as an example.
        cordapp project(":cordapp")
        cordapp project(":cordapp-contracts-states")
        //Added oracle support to template for testing/ experimenting configs
        cordapp project(":base")
        cordapp project(":service")
        //Oracle changes end here
        cordapp "$corda_release_group:corda-finance:$corda_release_version"
    }

    task integrationTest(type: Test, dependsOn: []) {
        testClassesDir = sourceSets.integrationTest.output.classesDir
        classpath = sourceSets.integrationTest.runtimeClasspath
    }

    tasks.withType(JavaCompile) {
        options.compilerArgs << "-parameters" // Required for passing named arguments to your flow via the shell.
    }

    task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
        directory "./build/nodes"
        node {
            name "O=Notary,L=London,C=GB"
            notary = [validating : true]
            p2pPort 10002
            cordapps = [
                    "$project.group:cordapp-contracts-states:$project.version",
                    "$project.group:cordapp:$project.version",
                    "$corda_release_group:corda-finance:$corda_release_version"
            ]
        }
        node {
            name "O=PartyA,L=London,C=GB"
            p2pPort 10005
            rpcSettings {
                address("localhost:10006")
                adminAddress("localhost:10046")
            }
            webPort 10007
            cordapps = [
                    "$project.group:cordapp-contracts-states:$project.version",
                    "$project.group:cordapp:$project.version",
                    "$corda_release_group:corda-finance:$corda_release_version"
            ]
            rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
        }
        node {
            name "O=PartyB,L=New York,C=US"
            p2pPort 10008
            rpcSettings {
                address("localhost:10009")
                adminAddress("localhost:10049")
            }
            webPort 10010
            cordapps = [
                    "$project.group:cordapp-contracts-states:$project.version",
                    "$project.group:cordapp:$project.version",
                    "$corda_release_group:corda-finance:$corda_release_version"
            ]
            rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
        }
        node {
            name "O=Oracle,L=New York,C=US"
            p2pPort 10011
            rpcSettings {
                address("localhost:10012")
                adminAddress("localhost:10052")
            }
            webPort 10013
            //The below cordapps will be deployed to oracle.
            //Create below packages named base and service and add to dependency
            cordapps = [
                    "$project.group:cordapp-contracts-states:$project.version",
                    "net.corda.examples.oracle:base:1.0",
                        "net.corda.examples.oracle:service:1.0"
            ]
            rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
        }
    }

    task runTemplateClient(type: JavaExec) {
        classpath = sourceSets.main.runtimeClasspath
        main = 'com.template.TemplateClient'
        args 'localhost:10006'
    }
1

1 Answers

2
votes

When defining your oracle node in deployNodes, you have provided the following cordapps block:

cordapps = [
    "$project.group:cordapp-contracts-states:$project.version",
    "net.corda.examples.oracle:base:1.0",
    "net.corda.examples.oracle:service:1.0"
]

However, your project's group, as given in your project's gradle.properties file, is com.template. Therefore you need to specify your CorDapps as follows:

cordapps = [
    "$project.group:cordapp-contracts-states:$project.version",
    "com.template:base:0.1",
    "com.template:service:0.1"
]

Alternatively, you can use the following shorthand:

cordapps = [
    "$project.group:cordapp-contracts-states:$project.version",
    "$project.group:base:0.1",
    "$project.group:service:0.1"
]