构建cordapp jar并在新节点中进行部署

时间:2018-07-03 04:52:14

标签: corda

我试图集成两个示例(Corda Java模板:https://github.com/corda/cordapp-template-java和Oracle示例:https://github.com/corda/oracle-example),以便将Oracle节点集成到模板中。 我更改了build.gradle,settings.gradle并将基本和服务包复制到模板文件夹。尽管该项目没有逻辑链接,因为Oracle对应于不同的服务,但它确实可以编译并在build文件夹下成功创建类。重新同步gradle项目后,gradle任务已成功更新,并且我能够成功运行deployNodes。

但是,build / nodes / Oracle / cordapp文件夹中没有jar。

请告知是否需要进行其他更改。
进行更改的Git网址:https://github.com/ashubisht/cordapp-template-java/tree/OracleIntegration_IOURelV3_0307

这是更新的gradle文件

    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 个答案:

答案 0 :(得分:1)

deployNodes中定义oracle节点时,您提供了以下cordapps块:

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

但是,在项目的gradle.properties文件中指定的项目组为com.template。因此,您需要按以下方式指定您的CorDapp:

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

或者,您可以使用以下速记:

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