corda/docs/build/html/creating-a-cordapp.html

524 lines
28 KiB
HTML
Raw Normal View History

2017-01-03 13:07:48 +00:00
<!-- If you edit this, then please make the same changes to layout_for_doc_website.html, as that is used for the web
doc site generation which we put analytics tracking on to identify any potential problem pages -->
2016-11-11 11:52:29 +00:00
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2017-01-06 17:38:23 +00:00
<title>CorDapp basics &mdash; R3 Corda latest documentation</title>
2016-11-11 11:52:29 +00:00
<link rel="stylesheet" href="_static/css/custom.css" type="text/css" />
<link rel="top" title="R3 Corda latest documentation" href="index.html"/>
2017-01-06 17:38:23 +00:00
<link rel="next" title="The CorDapp template" href="tutorial-cordapp.html"/>
<link rel="prev" title="Clauses" href="clauses.html"/>
2016-11-11 11:52:29 +00:00
<script src="_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="index.html" class="icon icon-home"> R3 Corda
</a>
<div class="version">
latest
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<br>
<a href="api/index.html">API reference</a>
2017-01-03 13:07:48 +00:00
<br>
<a href="https://discourse.corda.net">Discourse Forums</a>
<br>
<a href="http://slack.corda.net">Slack</a>
<br>
2016-11-11 11:52:29 +00:00
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
2016-11-23 12:50:02 +00:00
<p class="caption"><span class="caption-text">Getting started</span></p>
<ul>
2016-11-11 11:52:29 +00:00
<li class="toctree-l1"><a class="reference internal" href="inthebox.html">What&#8217;s included?</a></li>
<li class="toctree-l1"><a class="reference internal" href="getting-set-up.html">Getting set up</a></li>
2017-01-06 17:38:23 +00:00
<li class="toctree-l1"><a class="reference internal" href="getting-set-up-fault-finding.html">Troubleshooting</a></li>
2016-11-23 12:50:02 +00:00
<li class="toctree-l1"><a class="reference internal" href="running-the-demos.html">Running the demos</a></li>
2016-11-29 18:44:59 +00:00
<li class="toctree-l1"><a class="reference internal" href="CLI-vs-IDE.html">CLI vs IDE</a></li>
2016-11-23 12:50:02 +00:00
</ul>
<p class="caption"><span class="caption-text">Key concepts</span></p>
<ul>
2016-11-11 11:52:29 +00:00
<li class="toctree-l1"><a class="reference internal" href="data-model.html">Data model</a></li>
<li class="toctree-l1"><a class="reference internal" href="transaction-data-types.html">Data types</a></li>
2016-11-29 11:38:52 +00:00
<li class="toctree-l1"><a class="reference internal" href="merkle-trees.html">Transaction tear-offs</a></li>
2016-11-11 11:52:29 +00:00
<li class="toctree-l1"><a class="reference internal" href="consensus.html">Consensus model</a></li>
2017-01-06 17:38:23 +00:00
<li class="toctree-l1"><a class="reference internal" href="clauses.html">Clauses</a></li>
2016-11-23 12:50:02 +00:00
</ul>
<p class="caption"><span class="caption-text">CorDapps</span></p>
<ul class="current">
2017-01-06 17:38:23 +00:00
<li class="toctree-l1 current"><a class="current reference internal" href="#">CorDapp basics</a><ul>
2016-11-29 11:38:52 +00:00
<li class="toctree-l2"><a class="reference internal" href="#app-plugins">App plugins</a></li>
2016-11-11 11:52:29 +00:00
<li class="toctree-l2"><a class="reference internal" href="#services">Services</a></li>
2016-11-29 11:38:52 +00:00
<li class="toctree-l2"><a class="reference internal" href="#starting-nodes">Starting nodes</a></li>
<li class="toctree-l2"><a class="reference internal" href="#installing-apps">Installing apps</a></li>
<li class="toctree-l2"><a class="reference internal" href="#starting-your-node">Starting your node</a></li>
<li class="toctree-l2"><a class="reference internal" href="#debugging-your-node">Debugging your node</a></li>
<li class="toctree-l2"><a class="reference internal" href="#viewing-persisted-state-of-your-node">Viewing persisted state of your node</a></li>
<li class="toctree-l2"><a class="reference internal" href="#building-against-corda">Building against Corda</a></li>
2017-01-06 17:38:23 +00:00
<li class="toctree-l2"><a class="reference internal" href="#gradle-plugins-for-cordapps">Gradle plugins for CorDapps</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#building-gradle-plugins">Building Gradle plugins</a></li>
<li class="toctree-l3"><a class="reference internal" href="#using-gradle-plugins">Using Gradle plugins</a></li>
<li class="toctree-l3"><a class="reference internal" href="#template-build-gradle">Template build.gradle</a></li>
<li class="toctree-l3"><a class="reference internal" href="#cordformation">Cordformation</a></li>
2016-11-11 11:52:29 +00:00
</ul>
</li>
</ul>
</li>
2017-01-06 17:38:23 +00:00
<li class="toctree-l1"><a class="reference internal" href="tutorial-cordapp.html">The CorDapp template</a></li>
2016-11-29 18:44:59 +00:00
</ul>
<p class="caption"><span class="caption-text">The Corda node</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="clientrpc.html">Client RPC</a></li>
<li class="toctree-l1"><a class="reference internal" href="messaging.html">Networking and messaging</a></li>
<li class="toctree-l1"><a class="reference internal" href="persistence.html">Persistence</a></li>
<li class="toctree-l1"><a class="reference internal" href="node-administration.html">Node administration</a></li>
<li class="toctree-l1"><a class="reference internal" href="corda-configuration-file.html">Node configuration</a></li>
<li class="toctree-l1"><a class="reference internal" href="corda-plugins.html">The Corda plugin framework</a></li>
<li class="toctree-l1"><a class="reference internal" href="node-services.html">Brief introduction to the node services</a></li>
<li class="toctree-l1"><a class="reference internal" href="node-explorer.html">Node Explorer</a></li>
<li class="toctree-l1"><a class="reference internal" href="permissioning.html">Network permissioning</a></li>
2016-11-11 11:52:29 +00:00
</ul>
<p class="caption"><span class="caption-text">Tutorials</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="tutorial-contract.html">Writing a contract</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial-contract-clauses.html">Writing a contract using clauses</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial-test-dsl.html">Writing a contract test</a></li>
2017-01-06 17:38:23 +00:00
<li class="toctree-l1"><a class="reference internal" href="tutorial-integration-testing.html">Integration testing</a></li>
2016-11-29 11:38:52 +00:00
<li class="toctree-l1"><a class="reference internal" href="tutorial-clientrpc-api.html">Client RPC API tutorial</a></li>
2017-01-06 17:38:23 +00:00
<li class="toctree-l1"><a class="reference internal" href="tutorial-building-transactions.html">Building transactions</a></li>
2016-11-25 12:10:21 +00:00
<li class="toctree-l1"><a class="reference internal" href="flow-state-machines.html">Writing flows</a></li>
<li class="toctree-l1"><a class="reference internal" href="flow-testing.html">Writing flow tests</a></li>
2016-11-29 11:38:52 +00:00
<li class="toctree-l1"><a class="reference internal" href="running-a-notary.html">Running a notary service</a></li>
<li class="toctree-l1"><a class="reference internal" href="using-a-notary.html">Using a notary service</a></li>
2016-11-11 11:52:29 +00:00
<li class="toctree-l1"><a class="reference internal" href="oracles.html">Writing oracle services</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial-attachments.html">Using attachments</a></li>
<li class="toctree-l1"><a class="reference internal" href="event-scheduling.html">Event scheduling</a></li>
</ul>
2016-11-23 12:50:02 +00:00
<p class="caption"><span class="caption-text">Other</span></p>
2016-11-11 11:52:29 +00:00
<ul>
2016-11-23 12:50:02 +00:00
<li class="toctree-l1"><a class="reference internal" href="network-simulator.html">Network Simulator</a></li>
2016-11-11 11:52:29 +00:00
</ul>
2016-11-23 12:50:02 +00:00
<p class="caption"><span class="caption-text">Component library</span></p>
2016-11-11 11:52:29 +00:00
<ul>
2016-11-23 12:50:02 +00:00
<li class="toctree-l1"><a class="reference internal" href="contract-catalogue.html">Contract catalogue</a></li>
2016-11-29 11:38:52 +00:00
<li class="toctree-l1"><a class="reference internal" href="contract-irs.html">Interest rate swaps</a></li>
2016-11-11 11:52:29 +00:00
</ul>
<p class="caption"><span class="caption-text">Appendix</span></p>
<ul>
2016-11-18 12:57:39 +00:00
<li class="toctree-l1"><a class="reference internal" href="loadtesting.html">Load testing</a></li>
2017-01-06 17:38:23 +00:00
<li class="toctree-l1"><a class="reference internal" href="setting-up-a-corda-network.html">What is a corda network?</a></li>
2016-11-11 11:52:29 +00:00
<li class="toctree-l1"><a class="reference internal" href="secure-coding-guidelines.html">Secure coding guidelines</a></li>
<li class="toctree-l1"><a class="reference internal" href="release-process.html">Release process</a></li>
<li class="toctree-l1"><a class="reference internal" href="release-notes.html">Release notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="codestyle.html">Code style guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="building-the-docs.html">Building the documentation</a></li>
2017-01-03 13:07:48 +00:00
<li class="toctree-l1"><a class="reference internal" href="publishing-corda.html">Publishing Corda</a></li>
<li class="toctree-l1"><a class="reference internal" href="azure-vm.html">Working with the Corda Demo on Azure Marketplace</a></li>
2016-11-11 11:52:29 +00:00
</ul>
2016-11-23 12:50:02 +00:00
<p class="caption"><span class="caption-text">Glossary</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
</ul>
2016-11-11 11:52:29 +00:00
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">R3 Corda</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> &raquo;</li>
2017-01-06 17:38:23 +00:00
<li>CorDapp basics</li>
2016-11-11 11:52:29 +00:00
<li class="wy-breadcrumbs-aside">
<a href="_sources/creating-a-cordapp.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
2017-01-06 17:38:23 +00:00
<div class="section" id="cordapp-basics">
<h1>CorDapp basics<a class="headerlink" href="#cordapp-basics" title="Permalink to this headline"></a></h1>
<p>A CorDapp is an application that runs on the Corda platform using the platform APIs and plugin system. They are self
2016-11-11 11:52:29 +00:00
contained in separate JARs from the node server JAR that are created and distributed.</p>
<div class="section" id="app-plugins">
2016-11-29 11:38:52 +00:00
<h2>App plugins<a class="headerlink" href="#app-plugins" title="Permalink to this headline"></a></h2>
2016-11-11 11:52:29 +00:00
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Currently apps are only supported for JVM languages.</p>
</div>
<p>To create an app plugin you must you must extend from <a class="reference external" href="api/net.corda.core.node/-corda-plugin-registry/index.html">CordaPluginRegistry</a>. The JavaDoc contains
specific details of the implementation, but you can extend the server in the following ways:</p>
<ol class="arabic simple">
2016-11-23 12:50:02 +00:00
<li>Required flows: Specify which flows will be whitelisted for use in your web APIs.</li>
2016-11-11 11:52:29 +00:00
<li>Service plugins: Register your services (see below).</li>
<li>Web APIs: You may register your own endpoints under /api/ of the built-in web server.</li>
<li>Static web endpoints: You may register your own static serving directories for serving web content.</li>
2016-11-23 12:50:02 +00:00
<li>Registering your additional classes used in RPC.</li>
2016-11-11 11:52:29 +00:00
</ol>
</div>
<div class="section" id="services">
<h2>Services<a class="headerlink" href="#services" title="Permalink to this headline"></a></h2>
2016-11-29 18:44:59 +00:00
<p>Services are classes which are constructed after the node has started. It is provided a <a class="reference external" href="api/net.corda.core.node/-plugin-service-hub/index.html">PluginServiceHub</a> which
allows a richer API than the <a class="reference external" href="api/net.corda.core.node/-service-hub/index.html">ServiceHub</a> exposed to contracts. It enables adding flows, registering
2016-11-11 11:52:29 +00:00
message handlers and more. The service does not run in a separate thread, so the only entry point to the service is during
construction, where message handlers should be registered and threads started.</p>
</div>
<div class="section" id="starting-nodes">
2016-11-29 11:38:52 +00:00
<h2>Starting nodes<a class="headerlink" href="#starting-nodes" title="Permalink to this headline"></a></h2>
2016-11-18 12:57:39 +00:00
<p>To use an app you must also have a node server. To create a node server run the <code class="docutils literal"><span class="pre">gradle</span> <span class="pre">deployNodes</span></code> task.</p>
2016-11-11 11:52:29 +00:00
<p>This will output the node JAR to <code class="docutils literal"><span class="pre">build/libs/corda.jar</span></code> and several sample/standard
node setups to <code class="docutils literal"><span class="pre">build/nodes</span></code>. For now you can use the <code class="docutils literal"><span class="pre">build/nodes/nodea</span></code> configuration as a template.</p>
<p>Each node server by default must have a <code class="docutils literal"><span class="pre">node.conf</span></code> file in the current working directory. After first
2016-11-18 12:57:39 +00:00
execution of the node server there will be many other configuration and persistence files created in a node
workspace directory. This is specified as the basedir property of the node.conf file, or else can be overidden
using <code class="docutils literal"><span class="pre">--base-directory=&lt;workspace&gt;</span></code>.</p>
2016-11-11 11:52:29 +00:00
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Outside of development environments do not store your node directories in the build folder.</p>
</div>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
2016-11-18 12:57:39 +00:00
<p class="last">Also note that the bootstrapping process of the <code class="docutils literal"><span class="pre">corda.jar</span></code> unpacks the Corda dependencies into a
temporary folder. It is therefore suggested that the CAPSULE_CACHE_DIR environment variable be set before
starting the process to control this location.</p>
2016-11-11 11:52:29 +00:00
</div>
</div>
<div class="section" id="installing-apps">
2016-11-29 11:38:52 +00:00
<h2>Installing apps<a class="headerlink" href="#installing-apps" title="Permalink to this headline"></a></h2>
2016-11-11 11:52:29 +00:00
<p>Once you have created your app JAR you can install it to a node by adding it to <code class="docutils literal"><span class="pre">&lt;node_dir&gt;/plugins/</span></code>. In this
case the <code class="docutils literal"><span class="pre">node_dir</span></code> is the location where your node server&#8217;s JAR and configuration file is.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If the directory does not exist you can create it manually.</p>
</div>
</div>
<div class="section" id="starting-your-node">
2016-11-29 11:38:52 +00:00
<h2>Starting your node<a class="headerlink" href="#starting-your-node" title="Permalink to this headline"></a></h2>
2016-11-11 11:52:29 +00:00
<p>Now you have a node server with your app installed, you can run it by navigating to <code class="docutils literal"><span class="pre">&lt;node_dir&gt;</span></code> and running</p>
<blockquote>
<div>java -jar corda.jar</div></blockquote>
<p>The plugin should automatically be registered and the configuration file used.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">If your working directory is not <code class="docutils literal"><span class="pre">&lt;node_dir&gt;</span></code> your plugins and configuration will not be used.</p>
</div>
<p>The configuration file and workspace paths can be overidden on the command line e.g.</p>
<p><code class="docutils literal"><span class="pre">java</span> <span class="pre">-jar</span> <span class="pre">corda.jar</span> <span class="pre">--config-file=test.conf</span> <span class="pre">--base-directory=/opt/r3corda/nodes/test</span></code>.</p>
<p>Otherwise the workspace folder for the node is created based upon the <code class="docutils literal"><span class="pre">basedir</span></code> property in the <code class="docutils literal"><span class="pre">node.conf</span></code> file and if this is relative it is applied relative to the current working path.</p>
</div>
<div class="section" id="debugging-your-node">
2016-11-29 11:38:52 +00:00
<h2>Debugging your node<a class="headerlink" href="#debugging-your-node" title="Permalink to this headline"></a></h2>
2016-11-11 11:52:29 +00:00
<p>To enable remote debugging of the corda process use a command line such as:</p>
<p><code class="docutils literal"><span class="pre">java</span> <span class="pre">-Dcapsule.jvm.args=&quot;-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005&quot;</span> <span class="pre">-jar</span> <span class="pre">corda.jar</span></code></p>
<p>This command line will start the debugger on port 5005 and pause the process awaiting debugger attachment.</p>
</div>
<div class="section" id="viewing-persisted-state-of-your-node">
2016-11-29 11:38:52 +00:00
<h2>Viewing persisted state of your node<a class="headerlink" href="#viewing-persisted-state-of-your-node" title="Permalink to this headline"></a></h2>
2016-11-11 11:52:29 +00:00
<p>To make examining the persisted contract states of your node or the internal node database tables easier, and providing you are
using the default database configuration used for demos, you should be able to connect to the internal node database over
a JDBC connection at the URL that is output to the logs at node start up. That URL will be of the form <code class="docutils literal"><span class="pre">jdbc:h2:tcp://&lt;host&gt;:&lt;port&gt;/node</span></code>.</p>
<p>The user name and password for the login are as per the node data source configuration.</p>
<p>The name and column layout of the internal node tables is in a state of flux and should not be relied upon to remain static
at the present time, and should certainly be treated as read-only.</p>
</div>
<div class="section" id="building-against-corda">
2016-11-29 11:38:52 +00:00
<h2>Building against Corda<a class="headerlink" href="#building-against-corda" title="Permalink to this headline"></a></h2>
2016-11-11 11:52:29 +00:00
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">This feature is subject to rapid change</p>
</div>
<p>Corda now supports publishing to Maven local to build against it. To publish to Maven local run the following in the
root directory of Corda</p>
<div class="highlight-shell"><div class="highlight"><pre><span></span>./gradlew install
</pre></div>
</div>
<p>This will publish corda-$version.jar, finance-$version.jar, core-$version.jar and node-$version.jar to the
group net.corda. You can now depend on these as you normally would a Maven dependency.</p>
</div>
<div class="section" id="gradle-plugins-for-cordapps">
2017-01-06 17:38:23 +00:00
<h2>Gradle plugins for CorDapps<a class="headerlink" href="#gradle-plugins-for-cordapps" title="Permalink to this headline"></a></h2>
<p>There are several Gradle plugins that reduce your build.gradle boilerplate and make development of CorDapps easier.
2016-11-11 11:52:29 +00:00
The available plugins are in the gradle-plugins directory of the Corda repository.</p>
<div class="section" id="building-gradle-plugins">
2017-01-06 17:38:23 +00:00
<h3>Building Gradle plugins<a class="headerlink" href="#building-gradle-plugins" title="Permalink to this headline"></a></h3>
<p>To install to your local Maven repository the plugins that CorDapp gradle files require, run the following from the
2016-11-11 11:52:29 +00:00
root of the Corda project:</p>
<div class="highlight-text"><div class="highlight"><pre><span></span>./gradlew install
</pre></div>
</div>
<p>The plugins will now be installed to your local Maven repository in ~/.m2 on Unix and %HOMEPATH%.m2 on Windows.</p>
</div>
<div class="section" id="using-gradle-plugins">
2017-01-06 17:38:23 +00:00
<h3>Using Gradle plugins<a class="headerlink" href="#using-gradle-plugins" title="Permalink to this headline"></a></h3>
<p>To use the plugins, if you are not already using the CorDapp template project, you must modify your build.gradle. Add
2016-11-11 11:52:29 +00:00
the following segments to the relevant part of your build.gradle.</p>
</div>
<div class="section" id="template-build-gradle">
2017-01-06 17:38:23 +00:00
<h3>Template build.gradle<a class="headerlink" href="#template-build-gradle" title="Permalink to this headline"></a></h3>
<p>To build against Corda and the plugins that CorDapps use, update your build.gradle to contain the following:</p>
2016-11-11 11:52:29 +00:00
<div class="highlight-groovy"><div class="highlight"><pre><span></span><span class="n">buildscript</span> <span class="o">{</span>
<span class="n">ext</span><span class="o">.</span><span class="na">corda_version</span> <span class="o">=</span> <span class="s1">&#39;&lt;enter the corda version you build against here&gt;&#39;</span>
2016-11-29 11:38:52 +00:00
<span class="n">ext</span><span class="o">.</span><span class="na">corda_gradle_plugins_version</span> <span class="o">=</span> <span class="s1">&#39;&lt;enter the gradle plugins version here&gt;&#39;</span> <span class="c1">// This is usually the same as corda_version.</span>
2016-11-11 11:52:29 +00:00
<span class="o">...</span> <span class="n">your</span> <span class="n">buildscript</span> <span class="o">...</span>
<span class="n">repositories</span> <span class="o">{</span>
<span class="o">...</span> <span class="n">other</span> <span class="n">repositories</span> <span class="o">...</span>
<span class="n">mavenLocal</span><span class="o">()</span>
<span class="o">}</span>
<span class="n">dependencies</span> <span class="o">{</span>
<span class="o">...</span> <span class="n">your</span> <span class="n">dependencies</span> <span class="o">...</span>
2016-11-29 11:38:52 +00:00
<span class="n">classpath</span> <span class="s2">&quot;net.corda.plugins:cordformation:$corda_gradle_plugins_version&quot;</span>
<span class="n">classpath</span> <span class="s2">&quot;net.corda.plugins:quasar-utils:$corda_gradle_plugins_version&quot;</span>
<span class="n">classpath</span> <span class="s2">&quot;net.corda.plugins:publish-utils:$corda_gradle_plugins_version&quot;</span>
2016-11-11 11:52:29 +00:00
<span class="o">}</span>
<span class="o">}</span>
<span class="n">apply</span> <span class="nl">plugin:</span> <span class="s1">&#39;net.corda.plugins.cordformation&#39;</span>
<span class="n">apply</span> <span class="nl">plugin:</span> <span class="s1">&#39;net.corda.plugins.quasar-utils&#39;</span>
<span class="n">apply</span> <span class="nl">plugin:</span> <span class="s1">&#39;net.corda.plugins.publish-utils&#39;</span>
<span class="n">repositories</span> <span class="o">{</span>
<span class="n">mavenLocal</span><span class="o">()</span>
<span class="o">...</span> <span class="n">other</span> <span class="n">repositories</span> <span class="n">here</span> <span class="o">...</span>
<span class="o">}</span>
<span class="n">dependencies</span> <span class="o">{</span>
<span class="n">compile</span> <span class="s2">&quot;net.corda.core:$corda_version&quot;</span>
<span class="n">compile</span> <span class="s2">&quot;net.corda.finance:$corda_version&quot;</span>
<span class="n">compile</span> <span class="s2">&quot;net.corda.node:$corda_version&quot;</span>
<span class="n">compile</span> <span class="s2">&quot;net.corda.corda:$corda_version&quot;</span>
<span class="o">...</span> <span class="n">other</span> <span class="n">dependencies</span> <span class="n">here</span> <span class="o">...</span>
<span class="o">}</span>
<span class="o">...</span> <span class="n">your</span> <span class="n">tasks</span> <span class="o">...</span>
2017-01-06 17:38:23 +00:00
<span class="c1">// Standard way to publish CorDapps to maven local with the maven-publish and publish-utils plugin.</span>
2016-11-11 11:52:29 +00:00
<span class="n">publishing</span> <span class="o">{</span>
<span class="n">publications</span> <span class="o">{</span>
<span class="n">jarAndSources</span><span class="o">(</span><span class="n">MavenPublication</span><span class="o">)</span> <span class="o">{</span>
<span class="n">from</span> <span class="n">components</span><span class="o">.</span><span class="na">java</span>
<span class="c1">// The two lines below are the tasks added by this plugin.</span>
<span class="n">artifact</span> <span class="n">sourceJar</span>
<span class="n">artifact</span> <span class="n">javadocJar</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
<div class="section" id="cordformation">
2017-01-06 17:38:23 +00:00
<h3>Cordformation<a class="headerlink" href="#cordformation" title="Permalink to this headline"></a></h3>
<p>Cordformation is the local node deployment system for CorDapps, the nodes generated are intended to be used for
2016-11-11 11:52:29 +00:00
experimenting, debugging, and testing node configurations and setups but not intended for production or testnet
deployment.</p>
<p>To use this gradle plugin you must add a new task that is of the type <code class="docutils literal"><span class="pre">net.corda.plugins.Cordform</span></code> to your
build.gradle and then configure the nodes you wish to deploy with the Node and nodes configuration DSL.
This DSL is specified in the <a class="reference external" href="api/index.html">JavaDoc</a>. An example of this is in the template-cordapp and below
is a three node example;</p>
<div class="highlight-text"><div class="highlight"><pre><span></span>task deployNodes(type: net.corda.plugins.Cordform, dependsOn: [&#39;build&#39;]) {
directory &quot;./build/nodes&quot; // The output directory
2017-01-06 17:38:23 +00:00
networkMap &quot;Controller&quot; // The artemis address of the node named here will be used as the networkMapService.address on all other nodes.
2016-11-11 11:52:29 +00:00
node {
name &quot;Controller&quot;
dirName &quot;controller&quot;
nearestCity &quot;London&quot;
advertisedServices = [ &quot;corda.notary.validating&quot; ]
artemisPort 12345
webPort 12346
cordapps []
}
node {
name &quot;NodeA&quot;
dirName &quot;nodea&quot;
nearestCity &quot;London&quot;
advertisedServices = []
artemisPort 31337
webPort 31339
cordapps []
}
node {
name &quot;NodeB&quot;
dirName &quot;nodeb&quot;
nearestCity &quot;New York&quot;
advertisedServices = []
artemisPort 31338
webPort 31340
cordapps []
}
}
</pre></div>
</div>
<p>You can create more configurations with new tasks that extend Cordform.</p>
<p>New nodes can be added by simply adding another node block and giving it a different name, directory and ports. When you
run this task it will install the nodes to the directory specified and a script will be generated (for UNIX users only
2016-11-18 12:57:39 +00:00
at present) to run the nodes with one command (<code class="docutils literal"><span class="pre">runnodes</span></code>). On MacOS X this script will run each node in a new
terminal tab, and on Linux it will open up a new XTerm for each node. On Windows the (<code class="docutils literal"><span class="pre">runnodes.bat</span></code>) script will run
one node per window.</p>
2017-01-06 17:38:23 +00:00
<p>Other CorDapps can also be specified if they are already specified as classpath or compile dependencies in your
2016-11-11 11:52:29 +00:00
<code class="docutils literal"><span class="pre">build.gradle</span></code>.</p>
</div>
2017-01-06 17:38:23 +00:00
</div>
2016-11-11 11:52:29 +00:00
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
2017-01-06 17:38:23 +00:00
<a href="tutorial-cordapp.html" class="btn btn-neutral float-right" title="The CorDapp template" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
2016-11-11 11:52:29 +00:00
2017-01-06 17:38:23 +00:00
<a href="clauses.html" class="btn btn-neutral" title="Clauses" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
2016-11-11 11:52:29 +00:00
</div>
<hr/>
<div role="contentinfo">
<p>
2016-11-29 18:44:59 +00:00
&copy; Copyright 2016, R3 Limited.
2016-11-11 11:52:29 +00:00
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'latest',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>