Clarifies Gradle wrapper usage. Clarifies one module = one CorDapp. (#3721)

* Clarifies Gradle wrapper usage. Clarifies one module = one CorDapp.

* Clean-up. Note on how to create nodes and CorDapps in prod.

* Fixes based on rendering.

* Addresses review comments.
This commit is contained in:
Joel Dudley 2018-08-01 17:55:00 +01:00 committed by GitHub
parent d5f4370443
commit 2e03c7f8c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 27 deletions

View File

@ -19,8 +19,18 @@ JAR will contain:
Build tools
-----------
In the instructions that follow, we assume you are using ``gradle`` and the ``cordformation`` plugin to build your
CorDapp. You can find examples of building a CorDapp using these tools in the ``build.gradle`` file of the `Kotlin CorDapp Template <https://github.com/corda/cordapp-template-kotlin>`_ and the `Java CorDapp Template <https://github.com/corda/cordapp-template-kotlin>`_.
In the instructions that follow, we assume you are using Gradle and the ``cordformation`` plugin to build your
CorDapp. You can find examples of building a CorDapp using these tools in the
`Kotlin CorDapp Template <https://github.com/corda/cordapp-template-kotlin>`_ and the
`Java CorDapp Template <https://github.com/corda/cordapp-template-kotlin>`_.
To ensure you are using the correct version of Gradle, you should use the provided Gradle Wrapper by copying across
the following folder and files from the `Kotlin CorDapp Template <https://github.com/corda/cordapp-template-kotlin>`_ or the
`Java CorDapp Template <https://github.com/corda/cordapp-template-kotlin>`_ to the root of your project:
* ``gradle/``
* ``gradlew``
* ``gradlew.bat``
Setting your dependencies
-------------------------
@ -101,7 +111,10 @@ For further information about managing dependencies, see
Example
^^^^^^^
Below is a sample of what a CorDapp's Gradle dependencies block might look like. When building your own CorDapp, you should base yourself on the ``build.gradle`` file of the `Kotlin CorDapp Template <https://github.com/corda/cordapp-template-kotlin>`_ and the `Java CorDapp Template <https://github.com/corda/cordapp-template-kotlin>`_.
Below is a sample of what a CorDapp's Gradle dependencies block might look like. When building your own CorDapp, you should
base yourself on the ``build.gradle`` file of the
`Kotlin CorDapp Template <https://github.com/corda/cordapp-template-kotlin>`_ or the
`Java CorDapp Template <https://github.com/corda/cordapp-template-kotlin>`_.
.. container:: codeset
@ -135,13 +148,14 @@ Below is a sample of what a CorDapp's Gradle dependencies block might look like.
Creating the CorDapp JAR
------------------------
Once your dependencies are set correctly, you can build your CorDapp JAR using the gradle ``jar`` task:
Once your dependencies are set correctly, you can build your CorDapp JAR(s) using the Gradle ``jar`` task
* Unix/Mac OSX: ``./gradlew jar``
* Windows: ``gradlew.bat jar``
The CorDapp JAR will be output to the ``build/libs`` folder.
Each of the project's modules will be compiled into its own CorDapp JAR. You can find these CorDapp JARs in the ``build/libs``
folders of each of the project's modules.
.. warning:: The hash of the generated CorDapp JAR is not deterministic, as it depends on variables such as the
timestamp at creation. Nodes running the same CorDapp must therefore ensure they are using the exact same CorDapp
@ -158,9 +172,9 @@ Installing the CorDapp JAR
.. note:: Before installing a CorDapp, you must create one or more nodes to install it on. For instructions, please see
:doc:`generating-a-node`.
At start-up, nodes will load any CorDapps present in their ``cordapps`` folder. Therefore, in order to install a CorDapp on
a node, the CorDapp JAR must be added to the ``<node_dir>/cordapps/`` folder (where ``node_dir`` is the folder in which
the node's JAR and configuration files are stored) and the node restarted.
At start-up, nodes will load any CorDapps present in their ``cordapps`` folder. In order to install a CorDapp on a node, the
CorDapp JAR must be added to the ``<node_dir>/cordapps/`` folder (where ``node_dir`` is the folder in which the node's JAR
and configuration files are stored) and the node restarted.
CorDapp configuration files
---------------------------
@ -175,6 +189,3 @@ CorDapp configuration can be accessed from ``CordappContext::config`` whenever a
There is an example project that demonstrates in ``samples` called ``cordapp-configuration`` and API documentation in
<api/kotlin/corda/net.corda.core.cordapp/index.html>`_.

View File

@ -165,33 +165,45 @@ Building the example CorDapp
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* Open a terminal window in the ``cordapp-example`` directory
* Build the test nodes with our CorDapp using the following command:
* Run the ``deployNodes`` Gradle task to build four nodes with our CorDapp already installed on them:
* Unix/Mac OSX: ``./gradlew deployNodes``
* Windows: ``gradlew.bat deployNodes``
This will automatically build four nodes with our CorDapp already installed
.. note:: CorDapps can be written in any language targeting the JVM. In our case, we've provided the example source in
both Kotlin (``/kotlin-source/src``) and Java (``/java-source/src``). Since both sets of source files are
functionally identical, we will refer to the Kotlin version throughout the documentation.
* After the build finishes, you will see the generated nodes in the ``kotlin-source/build/nodes`` folder
* After the build finishes, you will see the following output in the ``kotlin-source/build/nodes`` folder:
* There will be a folder for each generated node, plus a ``runnodes`` shell script (or batch file on Windows) to run
all the nodes simultaneously
* A folder for each generated node
* A ``runnodes`` shell script for running all the nodes simultaneously on osX
* A ``runnodes.bat`` batch file for running all the nodes simultaneously on Windows
* Each node in the ``nodes`` folder has the following structure:
* Each node in the ``nodes`` folder will have the following structure:
.. sourcecode:: none
. nodeName
├── corda.jar // The Corda node runtime.
├── corda-webserver.jar // The node development webserver.
├── node.conf // The node configuration file.
└── cordapps // The node's CorDapps.
.. sourcecode:: none
. nodeName
├── additional-node-infos //
├── certificates
├── corda.jar // The Corda node runtime
├── corda-webserver.jar // The development node webserver runtime
├── cordapps // The node's CorDapps
│   ├── corda-finance-3.2-corda.jar
│   └── cordapp-example-0.1.jar
├── drivers
├── logs
├── network-parameters
├── node.conf // The node's configuration file
├── nodeInfo-<HASH> // The hash will be different each time you generate a node
└── persistence.mv.db // The node's database
.. note:: ``deployNodes`` is a utility task to create an entirely new set of nodes for testing your CorDapp. In production,
you would instead create a single node as described in :doc:`generating-a-node` and build your CorDapp JARs as described
in :doc:`cordapp-build-systems`.
Running the example CorDapp
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Start the nodes by running the following command from the root of the ``cordapp-example`` folder:
@ -440,8 +452,8 @@ The nodes can be configured to communicate as a network even when distributed ac
are distributed across machines. Otherwise, the nodes will not be able to communicate.
.. note:: If you are using H2 and wish to use the same ``h2port`` value for two or more nodes, you must only assign them that
value after the nodes have been moved to their individual machines. The initial bootstrapping process requires access to the
nodes' databases and if two nodes share the same H2 port, the process will fail.
value after the nodes have been moved to their individual machines. The initial bootstrapping process requires access to
the nodes' databases and if two nodes share the same H2 port, the process will fail.
Testing your CorDapp
--------------------