From 2bb8a5a7b6f20082a07345221d9ba47f2b3bb91c Mon Sep 17 00:00:00 2001 From: Clinton Alexander Date: Tue, 11 Oct 2016 13:24:57 +0100 Subject: [PATCH] Using groovy templating. --- .../groovy/com/r3corda/plugins/Node.groovy | 26 ++++++++++++------- .../com/r3corda/plugins/nodetemplate.conf | 18 ++++++------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/gradle-plugins/cordformation/src/main/groovy/com/r3corda/plugins/Node.groovy b/gradle-plugins/cordformation/src/main/groovy/com/r3corda/plugins/Node.groovy index b0904df552..492e07638d 100644 --- a/gradle-plugins/cordformation/src/main/groovy/com/r3corda/plugins/Node.groovy +++ b/gradle-plugins/cordformation/src/main/groovy/com/r3corda/plugins/Node.groovy @@ -1,5 +1,6 @@ package com.r3corda.plugins +import groovy.text.SimpleTemplateEngine import org.gradle.api.internal.file.AbstractFileCollection import org.gradle.api.Project @@ -201,16 +202,21 @@ class Node { private void installConfig() { project.copy { from Cordformation.getPluginFile(project, 'com/r3corda/plugins/nodetemplate.conf') - filter { it - .replaceAll('@@name@@', name) - .replaceAll('@@dirName@@', dirName) - .replaceAll('@@nearestCity@@', nearestCity) - .replaceAll('@@isNotary@@', isNotary.toString()) - .replaceAll('@@isHttps@@', isHttps.toString()) - .replaceAll('@@advertisedServices@@', advertisedServices.join(",")) - .replaceAll('@@networkMapAddress@@', networkMapAddress) - .replaceAll('@@artemisPort@@', artemisPort.toString()) - .replaceAll('@@webPort@@', webPort.toString()) + filter { + def binding = [ + "name": name, + "dirName": dirName, + "nearestCity": nearestCity, + "isNotary": isNotary, + "isHttps": isHttps, + "advertisedServices": advertisedServices, + "networkMapAddress": networkMapAddress, + "artemisPort": artemisPort.toString(), + "webPort": webPort.toString() + ] + + def engine = new SimpleTemplateEngine() + engine.createTemplate(it).make(binding) } into nodeDir rename 'nodetemplate.conf', 'node.conf' diff --git a/gradle-plugins/cordformation/src/main/resources/com/r3corda/plugins/nodetemplate.conf b/gradle-plugins/cordformation/src/main/resources/com/r3corda/plugins/nodetemplate.conf index 7b78453ef4..8499cdf640 100644 --- a/gradle-plugins/cordformation/src/main/resources/com/r3corda/plugins/nodetemplate.conf +++ b/gradle-plugins/cordformation/src/main/resources/com/r3corda/plugins/nodetemplate.conf @@ -1,11 +1,11 @@ -basedir : "@@dirName@@" -myLegalName : "@@name@@" -nearestCity : "@@nearestCity@@" +basedir : "$dirName" +myLegalName : "$name" +nearestCity : "$nearestCity" keyStorePassword : "cordacadevpass" trustStorePassword : "trustpass" -artemisAddress : "localhost:@@artemisPort@@" -webAddress : "localhost:@@webPort@@" -hostNotaryServiceLocally: @@isNotary@@ -extraAdvertisedServiceIds: "@@advertisedServices@@" -networkMapAddress : "@@networkMapAddress@@" -useHTTPS : @@isHttps@@ +artemisAddress : "localhost:$artemisPort" +webAddress : "localhost:$webPort" +hostNotaryServiceLocally: $isNotary +extraAdvertisedServiceIds: "$advertisedServices" +networkMapAddress : "$networkMapAddress" +useHTTPS : $isHttps