Moved the version numbers for the gradle plugins into the individual projects. Added RPC user configuration block. Reformated groovy code with IntelliJ auto refactor.

This commit is contained in:
Clinton Alexander 2016-11-25 15:36:22 +00:00
parent ceabafdfb0
commit 1e025bded2
6 changed files with 31 additions and 10 deletions

View File

@ -28,7 +28,7 @@ buildscript {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'net.corda.plugins:publish-utils:0.5'
classpath 'net.corda.plugins:quasar-utils:0.5.2'
classpath 'net.corda.plugins:cordformation:0.5.3'
classpath 'net.corda.plugins:cordformation:0.5.4'
// Can run 'gradle dependencyUpdates' to find new versions of things.
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'

View File

@ -20,7 +20,6 @@ apply plugin: 'maven-publish'
allprojects {
group 'net.corda'
version "$corda_version"
}
subprojects {

View File

@ -3,6 +3,8 @@ apply plugin: 'net.corda.plugins.publish-utils'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
version = "0.5.4" // Increment appropriately before publishing locally
dependencies {
compile gradleApi()
compile localGroovy()

View File

@ -1,13 +1,11 @@
package net.corda.plugins
import com.typesafe.config.Config
import com.typesafe.config.ConfigFactory
import com.typesafe.config.ConfigRenderOptions
import com.typesafe.config.ConfigValueFactory
import com.typesafe.config.*
import org.gradle.api.Project
import java.nio.charset.StandardCharsets
import java.nio.file.Files
/**
* Represents a node that will be installed.
*/
@ -30,10 +28,18 @@ class Node {
* @note Your app will be installed by default and does not need to be included here.
*/
protected List<String> cordapps = []
/**
* Set the configuration closure list that create the RPC users for this node. This configuration block allows
* arbitrary configuration. The recommended current structure is:
* [[['user': "username_here", 'password': "password_here", 'permissions': ["permissions_here"]]]
* The above is a list to a map of keys to values using Groovy map and list shorthands.
*
* @note Incorrect configurations will not cause a DSL error.
*/
protected List<Map<String, Object>> rpcUsers = []
private String dirName
private Config config = ConfigFactory.empty()
//private Map<String, Object> config = new HashMap<String, Object>()
private File nodeDir
private Project project
@ -122,6 +128,7 @@ class Node {
*/
void build(File baseDir) {
nodeDir = new File(baseDir, dirName)
configureRpcUsers()
installCordaJAR()
installBuiltPlugin()
installCordapps()
@ -138,6 +145,13 @@ class Node {
return config.getString("artemisAddress")
}
/**
* Write the RPC users to the config
*/
private void configureRpcUsers() {
config = config.withValue("rpcUsers", ConfigValueFactory.fromIterable(rpcUsers))
}
/**
* Installs the corda fat JAR to the node directory.
*/
@ -213,12 +227,14 @@ class Node {
* @return A file representing the Corda JAR.
*/
private File verifyAndGetCordaJar() {
def maybeCordaJAR = project.configurations.runtime.filter { it.toString().contains("corda-${project.corda_version}.jar")}
if(maybeCordaJAR.size() == 0) {
def maybeCordaJAR = project.configurations.runtime.filter {
it.toString().contains("corda-${project.corda_version}.jar")
}
if (maybeCordaJAR.size() == 0) {
throw new RuntimeException("No Corda Capsule JAR found. Have you deployed the Corda project to Maven? Looked for \"corda-${project.corda_version}.jar\"")
} else {
def cordaJar = maybeCordaJAR.getSingleFile()
assert(cordaJar.isFile())
assert (cordaJar.isFile())
return cordaJar
}
}

View File

@ -2,6 +2,8 @@ apply plugin: 'groovy'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
version = "0.5" // Increment appropriately before publishing locally
dependencies {
compile gradleApi()
compile localGroovy()

View File

@ -3,6 +3,8 @@ apply plugin: 'net.corda.plugins.publish-utils'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'
version = "0.5.2" // Increment appropriately before publishing locally
dependencies {
compile gradleApi()
compile localGroovy()