mirror of
https://github.com/corda/corda.git
synced 2025-02-18 16:40:55 +00:00
Merged in clint-cordform-nodeconf-fix (pull request #429)
Fixed node config file being written to the wrong place in Cordformation templates.
This commit is contained in:
commit
f7c3b95928
@ -1,5 +1,6 @@
|
||||
package com.r3corda.plugins
|
||||
|
||||
import org.apache.tools.ant.filters.FixCrLfFilter
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import java.nio.file.Path
|
||||
@ -53,7 +54,7 @@ class Cordform extends DefaultTask {
|
||||
*/
|
||||
protected Node getNodeByName(String name) {
|
||||
for(Node node : nodes) {
|
||||
if(node.name.equals(networkMapNodeName)) {
|
||||
if(node.name == networkMapNodeName) {
|
||||
return node
|
||||
}
|
||||
}
|
||||
@ -69,7 +70,7 @@ class Cordform extends DefaultTask {
|
||||
from Cordformation.getPluginFile(project, "com/r3corda/plugins/runnodes")
|
||||
filter { String line -> line.replace("JAR_NAME", Node.JAR_NAME) }
|
||||
// Replaces end of line with lf to avoid issues with the bash interpreter and Windows style line endings.
|
||||
filter(org.apache.tools.ant.filters.FixCrLfFilter.class, eol: org.apache.tools.ant.filters.FixCrLfFilter.CrLf.newInstance("lf"))
|
||||
filter(FixCrLfFilter.class, eol: FixCrLfFilter.CrLf.newInstance("lf"))
|
||||
into "${directory}/"
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class Node {
|
||||
private Config config = ConfigFactory.empty()
|
||||
//private Map<String, Object> config = new HashMap<String, Object>()
|
||||
private File nodeDir
|
||||
private def project
|
||||
private Project project
|
||||
|
||||
/**
|
||||
* Set the name of the node.
|
||||
@ -150,7 +150,7 @@ class Node {
|
||||
* Installs this project's cordapp to this directory.
|
||||
*/
|
||||
private void installBuiltPlugin() {
|
||||
def pluginsDir = getAndCreateDirectory(nodeDir, "plugins")
|
||||
def pluginsDir = new File(nodeDir, "plugins")
|
||||
project.copy {
|
||||
from project.jar
|
||||
into pluginsDir
|
||||
@ -161,7 +161,7 @@ class Node {
|
||||
* Installs other cordapps to this node's plugins directory.
|
||||
*/
|
||||
private void installCordapps() {
|
||||
def pluginsDir = getAndCreateDirectory(nodeDir, "plugins")
|
||||
def pluginsDir = new File(nodeDir, "plugins")
|
||||
def cordapps = getCordappList()
|
||||
project.copy {
|
||||
from cordapps
|
||||
@ -175,7 +175,7 @@ class Node {
|
||||
private void installDependencies() {
|
||||
def cordaJar = verifyAndGetCordaJar()
|
||||
def cordappList = getCordappList()
|
||||
def depsDir = getAndCreateDirectory(nodeDir, "dependencies")
|
||||
def depsDir = new File(nodeDir, "dependencies")
|
||||
def appDeps = project.configurations.runtime.filter { it != cordaJar && !cordappList.contains(it) }
|
||||
project.copy {
|
||||
from appDeps
|
||||
@ -190,9 +190,17 @@ class Node {
|
||||
// Adding required default values
|
||||
config = config.withValue('extraAdvertisedServiceIds',
|
||||
ConfigValueFactory.fromAnyRef(advertisedServices.join(',')))
|
||||
|
||||
def configFileText = config.root().render(new ConfigRenderOptions(false, false, true, false)).split("\n").toList()
|
||||
Files.write(new File(nodeDir, 'node.conf').toPath(), configFileText, StandardCharsets.UTF_8)
|
||||
|
||||
// Need to write a temporary file first to use the project.copy, which resolves directories correctly.
|
||||
def tmpDir = new File(project.buildDir, "tmp")
|
||||
def tmpConfFile = new File(tmpDir, 'node.conf')
|
||||
Files.write(tmpConfFile.toPath(), configFileText, StandardCharsets.UTF_8)
|
||||
|
||||
project.copy {
|
||||
from tmpConfFile
|
||||
into nodeDir
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -223,18 +231,4 @@ class Node {
|
||||
return (it != cordaJar) && cordapps.contains(jarName)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a directory if it doesn't exist and return the file representation of it.
|
||||
*
|
||||
* @param baseDir The base directory to create the directory at.
|
||||
* @param subDirName A valid name of the subdirectory to get and create if not exists.
|
||||
* @return A file representing the subdirectory.
|
||||
*/
|
||||
private static File getAndCreateDirectory(File baseDir, String subDirName) {
|
||||
File dir = new File(baseDir, subDirName)
|
||||
assert(!dir.exists() || dir.isDirectory())
|
||||
dir.mkdirs()
|
||||
return dir
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user