Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cordformation Plugin - Kotlin DSL #403

Open
raynay-r opened this issue Apr 1, 2021 · 3 comments
Open

Cordformation Plugin - Kotlin DSL #403

raynay-r opened this issue Apr 1, 2021 · 3 comments

Comments

@raynay-r
Copy link

raynay-r commented Apr 1, 2021

I managed to create a deployNodes task in Kotlin DSL following the examples from the corda examples repo. See the following example:

tasks.register<Cordform>("deployNodes") {
    dependsOn.add("jar")

    val notaryConfig = mapOf("validating" to false)

    val rpcUsersConfig = listOf(
        mapOf(
            "user" to "user1",
            "password" to "test",
            "permissions" to listOf("ALL")
        )
    )

    // nodeDefaults not working because of protected setter
    nodeDefaults = closureOf<net.corda.plugins.Node> {
        projectCordapp(closureOf<net.corda.plugins.Cordapp> {
            deploy = false
        })

        runSchemaMigration = true
    }

    node {
        name("O=Notary,L=London,C=GB")
        p2pPort(60000)

        notary = notaryConfig

        rpcSettings(closureOf<RpcSettings> {
            address("localhost:60001")
            adminAddress("localhost:60002")
        })
        true.also { runSchemaMigration = it }
    }

    node {
        name("O=party1,L=London,C=GB")
        p2pPort(10000)

        rpcSettings(closureOf<RpcSettings> {
            address("localhost:10001")
            adminAddress("localhost:10002")
        })

        rpcUsersConfig.also { rpcUsers = it }
        true.also { runSchemaMigration = it }
    }
}

This works fine. The only issue is that I can not use the nodeDefaults field because it has a protected setter.

See: Baseform.kt

If there is no reason why this setter should stay protected, I can provide a pull request which makes it public.

@chrisr3
Copy link
Contributor

chrisr3 commented Apr 2, 2021

Hi, thanks for reporting this. I think the real problem here is that cordformation should be using Action instead of Groovy's Closure. I'll see if I can update it without breaking everything... 🤔

@chrisr3
Copy link
Contributor

chrisr3 commented Apr 3, 2021

See how the modified cordformation plugin from this branch works for you... Perhaps with something like:

tasks.register<Cordform>("deployNodes") {
    dependsOn.add("jar")

    val notaryConfig = mapOf("validating" to false)

    val rpcUsersConfig = listOf(
        mapOf(
            "user" to "user1",
            "password" to "test",
            "permissions" to listOf("ALL")
        )
    )

    nodeDefaults  {
        projectCordapp {
            deploy = false
        }

        runSchemaMigration = true
    }

    node {
        name("O=Notary,L=London,C=GB")
        p2pPort(60000)

        notary = notaryConfig

        rpcSettings {
            address("localhost:60001")
            adminAddress("localhost:60002")
        }
    }

    node {
        name("O=party1,L=London,C=GB")
        p2pPort(10000)

        rpcSettings {
            address("localhost:10001")
            adminAddress("localhost:10002")
        }

        rpcUsers = rpcUsersConfig
    }
}

@chrisr3
Copy link
Contributor

chrisr3 commented Apr 7, 2021

This will be part of the 5.0.14 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants