deployNodes Gradle task appends properties from an optional file to node.conf (#1444)

* deployNodes Gradle task appends properties from an optional file to node.conf
This commit is contained in:
szymonsztuka 2017-10-10 15:03:05 +01:00 committed by Clinton
parent bd53a22efa
commit 8c9045bd73
3 changed files with 40 additions and 1 deletions

View File

@ -10,7 +10,7 @@ UNRELEASED
* The ``Cordformation`` gradle plugin has been split into ``cordformation`` and ``cordapp``. The former builds and
deploys nodes for development and testing, the latter turns a project into a cordapp project that generates JARs in
the standard CorDapp format.
the standard CorDapp format.
* ``Cordform`` and node identity generation
* Cordform may not specify a value for ``NetworkMap``, when that happens, during the task execution the following happens:
@ -30,6 +30,12 @@ UNRELEASED
``notaryNodeAddress``, ``notaryClusterAddresses`` and ``bftSMaRt`` have also been removed and replaced by a single
``notary`` config object. See :doc:`corda-configuration-file` for more details.
* Gradle task ``deployNodes`` can have an additional parameter `configFile` with the path to a properties file
to be appended to node.conf.
* Cordformation node building DSL can have an additional parameter `configFile` with the path to a properties file
to be appended to node.conf.
.. _changelog_v1:
Release 1.0

View File

@ -74,4 +74,13 @@ public class CordformNode implements NodeDefinition {
public void rpcPort(Integer rpcPort) {
config = config.withValue("rpcAddress", ConfigValueFactory.fromAnyRef(DEFAULT_HOST + ':' + rpcPort));
}
/**
* Set the path to a file with optional properties, which are appended to the generated node.conf file.
*
* @param configFile The file path.
*/
public void configFile(String configFile) {
config = config.withValue("configFile", ConfigValueFactory.fromAnyRef(configFile));
}
}

View File

@ -107,6 +107,7 @@ class Node extends CordformNode {
installBuiltPlugin()
installCordapps()
installConfig()
appendOptionalConfig()
}
/**
@ -193,6 +194,29 @@ class Node extends CordformNode {
}
}
/**
* Appends installed config file with properties from an optional file.
*/
private void appendOptionalConfig() {
final configFileProperty = "configFile"
File optionalConfig
if (project.findProperty(configFileProperty)) { //provided by -PconfigFile command line property when running Gradle task
optionalConfig = new File(project.findProperty(configFileProperty))
} else if (config.hasPath(configFileProperty)) {
optionalConfig = new File(config.getString(configFileProperty))
}
if (optionalConfig) {
if (!optionalConfig.exists()) {
println "$configFileProperty '$optionalConfig' not found"
} else {
def confFile = new File(project.buildDir.getPath() + "/../" + nodeDir, 'node.conf')
optionalConfig.withInputStream {
input -> confFile << input
}
}
}
}
/**
* Find the corda JAR amongst the dependencies.
*