Skip to content

Commit

Permalink
Added significant parts of the required config.
Browse files Browse the repository at this point in the history
  • Loading branch information
Clintonio committed Oct 4, 2016
1 parent 5d40cc9 commit 654b693
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 9 deletions.
22 changes: 22 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,30 @@ dependencies {

task deployNodes(type: Cordform, dependsOn: 'build') {
directory "./build/testnodes"
networkMap "NodeA"
node {
name "Notary"
dirName "notary"
nearestCity "London"
notary true
advertisedServices = []
artemisPort 31337
}
node {
name "NodeA"
dirName "notary"
nearestCity "London"
advertisedServices = []
artemisPort 31338
webPort 31339
}
node {
name "NodeB"
dirName "notary"
nearestCity "New York"
advertisedServices = []
artemisPort 31340
webPort 31341
}
}

Expand Down
79 changes: 70 additions & 9 deletions buildSrc/src/main/groovy/Cordformation.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,64 @@ import java.nio.file.Paths
import java.nio.file.Path

class Node {
private String mName
private String name
private String dirName
private String nearestCity
private Boolean isNotary = false
private Boolean isHttps = false
private List<String> advertisedServices = []
private Integer artemisPort
private Integer webPort
public String networkMapAddress

private File nodeDir
private def project

void name(String name) {
mName = name
this.name = name
}

void dirName(String dirName) {
this.dirName = dirName
}

void nearestCity(String nearestCity) {
this.nearestCity = nearestCity
}

void notary(Boolean isNotary) {
this.isNotary = isNotary
}

void https(Boolean isHttps) {
this.isHttps = isHttps
}

void advertisedServices(List<String> advertisedServices) {
this.advertisedServices = advertisedServices
}

void artemisPort(Integer artemisPort) {
this.artemisPort = artemisPort
}

void webPort(Integer webPort) {
this.webPort = webPort
}

Node(def project) {
this.project = project
}

void build(File baseDir) {
File nodeDir = new File(baseDir, mName)
installCordaJAR(nodeDir)
installPlugins(nodeDir)
installDependencies(nodeDir)
nodeDir = new File(baseDir, dirName)
installCordaJAR()
installPlugins()
installDependencies()
installConfig()
}

private void installCordaJAR(File nodeDir) {
private void installCordaJAR() {
def cordaJar = verifyAndGetCordaJar()
project.copy {
from cordaJar
Expand All @@ -34,7 +73,7 @@ class Node {
}
}

private void installPlugins(File nodeDir) {
private void installPlugins() {
def cordaJar = verifyAndGetCordaJar()
def pluginsDir = getAndCreateDirectory(nodeDir, "plugins")
def appDeps = project.configurations.runtime.filter { it != cordaJar } // TODO: Filter out all other deps in the corda jar
Expand All @@ -44,10 +83,27 @@ class Node {
}
}

private void installDependencies(File nodeDir) {
private void installDependencies() {
// TODO:
}

private void installConfig() {
project.copy {
from ('./config/dev/nodetemplate.conf') {
filter { it
.replaceAll('@@name@@', name)
.replaceAll('@@dirName@@', dirName)
.replaceAll('@@nearestCity@@', nearestCity)
.replaceAll('@@isNotary@@', isNotary.toString())
.replaceAll('@@isHttps@@', isHttps.toString())
.replaceAll('@@advertisedServices@@', isHttps.toString())
}
}
into nodeDir
rename 'nodetemplate.conf', 'node.conf'
}
}

private File verifyAndGetCordaJar() {
def maybeCordaJAR = project.configurations.runtime.filter { it.toString().contains("corda-${project.corda_version}.jar")}
if(maybeCordaJAR.size() == 0) {
Expand All @@ -70,11 +126,16 @@ class Node {
class Cordform extends DefaultTask {
private Path directory = Paths.get("./build/nodes")
private List<Node> nodes = new ArrayList<Node>()
private String networkMapNodeName

public String directory(String directory) {
this.directory = Paths.get(directory)
}

public String networkMap(String nodeName) {
networkMapNodeName = nodeName
}

public void node(Closure configureClosure) {
nodes << project.configure(new Node(project), configureClosure)
}
Expand Down
11 changes: 11 additions & 0 deletions config/dev/nodetemplate.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
basedir : "@@dirName@@"
myLegalName : "@@name@@"
nearestCity : "@@nearestCity@@"
keyStorePassword : "cordacadevpass"
trustStorePassword : "trustpass"
artemisAddress : "localhost:31338"
webAddress : "localhost:31340"
hostNotaryServiceLocally: @@isNotary@@
extraAdvertisedServiceIds: @@advertisedServices@@
networkMapAddress : "localhost:12345"
useHTTPS : @@isHttps@@

0 comments on commit 654b693

Please sign in to comment.