You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用Maven构建Corda应用并实现Cordform插件节点部署?

Maven Equivalent for Corda's Gradle deployNodes Task (Using Cordform Common Plugin)

Hey there, I totally get where you're coming from—Corda's official docs and examples lean heavily on Gradle, so tracking down Maven equivalents for node deployment can feel like searching for a needle in a haystack. Let's fix that by replicating your Gradle deployNodes task using Maven and the Cordform Common plugin.

Step 1: Add the Cordform Common Plugin to Your pom.xml

This plugin handles node deployment in Maven, just like the Gradle Cordform task. Here's the full configuration that maps directly to your Gradle code:

<build>
    <plugins>
        <!-- Cordform Common Plugin for node deployment -->
        <plugin>
            <groupId>net.corda.plugins</groupId>
            <artifactId>cordform-common</artifactId>
            <version>${corda.plugin.version}</version> <!-- Match your Corda release version -->
            <executions>
                <execution>
                    <id>deploy-nodes</id>
                    <phase>package</phase> <!-- Runs automatically after building your JAR -->
                    <goals>
                        <goal>deploy</goal>
                    </goals>
                    <configuration>
                        <!-- Equivalent to Gradle's `directory "./build/nodes"` -->
                        <outputDirectory>${project.build.directory}/nodes</outputDirectory>
                        <!-- Network Map node reference, matches Gradle's `networkMap` -->
                        <networkMapName>O=Controller,L=London,C=GB</networkMapName>
                        <!-- Node configuration block, mirroring Gradle's `node {}` -->
                        <nodes>
                            <node>
                                <name>O=Controller,L=London,C=GB</name>
                                <!-- Advertised notary service, same as Gradle's `advertisedServices` -->
                                <advertisedServices>
                                    <service>corda.notary.validating</service>
                                </advertisedServices>
                                <!-- P2P and RPC ports -->
                                <p2pPort>10002</p2pPort>
                                <rpcPort>10003</rpcPort>
                                <!-- Cordapps to include, matching Gradle's `cordapps` list -->
                                <cordapps>
                                    <cordapp>${project.group}:cordapp-contracts-states:${project.version}</cordapp>
                                    <cordapp>${project.group}:cordapp:${project.version}</cordapp>
                                    <cordapp>net.corda:corda-finance:${corda.release.version}</cordapp>
                                </cordapps>
                            </node>
                        </nodes>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Step 2: Configure Corda's Repository

Make sure you've added Corda's official repository to your pom.xml so Maven can resolve the cordform-common plugin and Corda dependencies.

Key Notes to Match Your Gradle Setup

  • Execution Phase: The plugin runs in the package phase, which is Maven's way of ensuring it runs after building your JAR—just like Gradle's dependsOn: ['jar'].
  • Output Directory: ${project.build.directory} defaults to target in Maven, so this will create nodes in target/nodes (you can adjust this path if needed, just like you did with ./build/nodes in Gradle).
  • Version Placeholders: Replace ${corda.plugin.version} and ${corda.release.version} with your actual Corda version (e.g., 4.10 for recent stable releases).

Run the Deployment

To deploy your nodes, simply run:

mvn package

This will trigger the plugin's deploy goal, generating all node files in the specified output directory—exactly what your Gradle deployNodes task does.

内容的提问来源于stack exchange,提问作者Stefano C

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:16:11