Using groovy templating.

This commit is contained in:
Clinton Alexander 2016-10-11 13:24:57 +01:00
parent 32ae40cc90
commit 2bb8a5a7b6
2 changed files with 25 additions and 19 deletions

View File

@ -1,5 +1,6 @@
package com.r3corda.plugins package com.r3corda.plugins
import groovy.text.SimpleTemplateEngine
import org.gradle.api.internal.file.AbstractFileCollection import org.gradle.api.internal.file.AbstractFileCollection
import org.gradle.api.Project import org.gradle.api.Project
@ -201,16 +202,21 @@ class Node {
private void installConfig() { private void installConfig() {
project.copy { project.copy {
from Cordformation.getPluginFile(project, 'com/r3corda/plugins/nodetemplate.conf') from Cordformation.getPluginFile(project, 'com/r3corda/plugins/nodetemplate.conf')
filter { it filter {
.replaceAll('@@name@@', name) def binding = [
.replaceAll('@@dirName@@', dirName) "name": name,
.replaceAll('@@nearestCity@@', nearestCity) "dirName": dirName,
.replaceAll('@@isNotary@@', isNotary.toString()) "nearestCity": nearestCity,
.replaceAll('@@isHttps@@', isHttps.toString()) "isNotary": isNotary,
.replaceAll('@@advertisedServices@@', advertisedServices.join(",")) "isHttps": isHttps,
.replaceAll('@@networkMapAddress@@', networkMapAddress) "advertisedServices": advertisedServices,
.replaceAll('@@artemisPort@@', artemisPort.toString()) "networkMapAddress": networkMapAddress,
.replaceAll('@@webPort@@', webPort.toString()) "artemisPort": artemisPort.toString(),
"webPort": webPort.toString()
]
def engine = new SimpleTemplateEngine()
engine.createTemplate(it).make(binding)
} }
into nodeDir into nodeDir
rename 'nodetemplate.conf', 'node.conf' rename 'nodetemplate.conf', 'node.conf'

View File

@ -1,11 +1,11 @@
basedir : "@@dirName@@" basedir : "$dirName"
myLegalName : "@@name@@" myLegalName : "$name"
nearestCity : "@@nearestCity@@" nearestCity : "$nearestCity"
keyStorePassword : "cordacadevpass" keyStorePassword : "cordacadevpass"
trustStorePassword : "trustpass" trustStorePassword : "trustpass"
artemisAddress : "localhost:@@artemisPort@@" artemisAddress : "localhost:$artemisPort"
webAddress : "localhost:@@webPort@@" webAddress : "localhost:$webPort"
hostNotaryServiceLocally: @@isNotary@@ hostNotaryServiceLocally: $isNotary
extraAdvertisedServiceIds: "@@advertisedServices@@" extraAdvertisedServiceIds: "$advertisedServices"
networkMapAddress : "@@networkMapAddress@@" networkMapAddress : "$networkMapAddress"
useHTTPS : @@isHttps@@ useHTTPS : $isHttps