262 lines
7.0 KiB
Groovy
262 lines
7.0 KiB
Groovy
// Note, IntelliJ does not recognise the imported Java Classes, hence they are
|
|
// highlighted in Red. However, they are recognised in the gradle compilation.
|
|
|
|
|
|
// todo: look at the declaration of the script variables, can they be combined with the declaration of the Project Context
|
|
// todo: investigate adding corda-cli to the class path then executing it directly - might not work as gradle has to set up the jar file, so its not their when you start.
|
|
// Todo: write a test flow runner helper function??
|
|
// todo: rename deployCPIsHelper
|
|
// todo: add proper logging, rather than reading Stdout
|
|
// todo: add test corda running/live task
|
|
// todo: add a test to check docker is running and display error if not + halt start corda
|
|
// todo: add a clean corda task.
|
|
// todo: fix logging level and make it configurable.
|
|
|
|
|
|
import com.r3.csde.CordaLifeCycleHelper
|
|
import com.r3.csde.ProjectContext
|
|
import com.r3.csde.DeployCPIsHelper
|
|
import com.r3.csde.BuildCPIsHelper
|
|
import com.r3.csde.ProjectUtils
|
|
import com.r3.csde.CordaStatusQueries
|
|
import com.r3.csde.VNodesHelper
|
|
import com.r3.csde.NetworkConfig
|
|
|
|
plugins {
|
|
id 'java-library'
|
|
id 'groovy'
|
|
id 'java'
|
|
}
|
|
|
|
|
|
configurations {
|
|
combinedWorker{
|
|
canBeConsumed = false
|
|
canBeResolved= true
|
|
}
|
|
|
|
myPostgresJDBC {
|
|
canBeConsumed = false
|
|
canBeResolved = true
|
|
}
|
|
|
|
notaryServerCPB {
|
|
canBeConsumed = false
|
|
canBeResolved = true
|
|
}
|
|
}
|
|
|
|
// Dependencies for supporting tools
|
|
dependencies {
|
|
combinedWorker "net.corda:corda-combined-worker:$combinedWorkerVersion"
|
|
myPostgresJDBC "org.postgresql:postgresql:$postgresqlVersion"
|
|
notaryServerCPB("com.r3.corda.notary.plugin.nonvalidating:notary-plugin-non-validating-server:$cordaNotaryPluginsVersion") {
|
|
artifact {
|
|
classifier = 'package'
|
|
extension = 'cpb'
|
|
}
|
|
}
|
|
|
|
implementation "org.codehaus.groovy:groovy-json:3.0.9"
|
|
}
|
|
|
|
// task groupings
|
|
def cordaGroup = 'csde-corda' // corda lifecycle tasks
|
|
def cordappGroup = 'csde-cordapp' // tasks to build and deploy corDapps
|
|
def queriesGroup = 'csde-queries' // tasks which query corda status
|
|
def supportingGroup = 'supporting' // tasks which should be hidden from the csde user
|
|
|
|
|
|
def cordaBinDir = System.getenv("CSDE_CORDA_BIN") ?: System.getProperty('user.home') + "/.corda/corda5"
|
|
def cordaCliBinDir = System.getenv("CSDE_CORDA_CLI") ?:System.getProperty('user.home') + "/.corda/cli"
|
|
def cordaJDBCDir = cordaBinDir + "/jdbcDrivers"
|
|
def cordaNotaryServerDir = cordaBinDir + "/notaryserver"
|
|
def signingCertAlias="gradle-plugin-default-key"
|
|
// Get error if this is not a autotyped object
|
|
// def signingCertFName = "$rootDir/config/gradle-plugin-default-key.pem"
|
|
def signingCertFName = rootDir.toString() + "/config/gradle-plugin-default-key.pem"
|
|
def keystoreAlias = "my-signing-key"
|
|
def keystoreFName = devEnvWorkspace + "/signingkeys.pfx"
|
|
def keystoreCertFName = devEnvWorkspace + "/signingkey1.pem"
|
|
def combiWorkerPidCacheFile = devEnvWorkspace + "/CordaPID.dat"
|
|
// todo: can we rely on the build directory always being /workflow/build? aslo, is the
|
|
// workflow directory the correct place to build the cpb to. shoudl it be the main build directory.
|
|
def workflowBuildDir = rootDir.toString() + "/workflows/build"
|
|
|
|
|
|
// todo: Need to read things from cordapp plugin - the cordapp names will be changed by the user
|
|
def appCpiName = 'cpi name'
|
|
def notaryCpiName = 'CSDE Notary Server CPI'
|
|
|
|
|
|
// todo: there should be a better way to set up these project context variables.
|
|
def projectContext = new ProjectContext(project,
|
|
cordaClusterURL.toString(),
|
|
cordaRpcUser,
|
|
cordaRpcPasswd,
|
|
devEnvWorkspace,
|
|
// todo: why is this not obtained in the groovy def's abouve - its inconsistent.
|
|
new String("${System.getProperty("java.home")}/bin"),
|
|
dbContainerName,
|
|
cordaJDBCDir,
|
|
combiWorkerPidCacheFile,
|
|
signingCertAlias,
|
|
signingCertFName,
|
|
keystoreAlias,
|
|
keystoreFName,
|
|
keystoreCertFName,
|
|
appCpiName,
|
|
notaryCpiName,
|
|
devEnvWorkspace,
|
|
cordaCliBinDir,
|
|
cordaNotaryServerDir,
|
|
workflowBuildDir,
|
|
cordaNotaryPluginsVersion
|
|
)
|
|
|
|
def networkConfig = new NetworkConfig("config/static-network-config.json")
|
|
|
|
def utils = new ProjectUtils()
|
|
|
|
// Initiate workspace folder
|
|
|
|
tasks.register('projInit') {
|
|
group = supportingGroup
|
|
doLast {
|
|
mkdir devEnvWorkspace
|
|
}
|
|
}
|
|
|
|
|
|
// CordaLifeCycle tasks
|
|
|
|
def cordaLifeCycle = new CordaLifeCycleHelper(projectContext)
|
|
|
|
tasks.register("startCorda") {
|
|
group = cordaGroup
|
|
dependsOn('getDevCordaLite', 'getPostgresJDBC')
|
|
doLast {
|
|
mkdir devEnvWorkspace
|
|
cordaLifeCycle.startCorda()
|
|
}
|
|
}
|
|
|
|
tasks.register("stopCorda") {
|
|
group = cordaGroup
|
|
doLast {
|
|
cordaLifeCycle.stopCorda()
|
|
}
|
|
}
|
|
|
|
tasks.register("stopAndCleanCorda") {
|
|
group = cordaGroup
|
|
dependsOn('clean')
|
|
doLast {
|
|
try {
|
|
cordaLifeCycle.stopCorda()
|
|
} catch (Exception ignore) {
|
|
println(ignore.toString())
|
|
}
|
|
delete devEnvWorkspace
|
|
}
|
|
}
|
|
|
|
tasks.register("getPostgresJDBC") {
|
|
group = supportingGroup
|
|
doLast {
|
|
copy {
|
|
from configurations.myPostgresJDBC
|
|
into "$cordaJDBCDir"
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.register("getDevCordaLite", Copy) {
|
|
group = supportingGroup
|
|
from configurations.combinedWorker
|
|
into cordaBinDir
|
|
}
|
|
|
|
|
|
// Corda status queries
|
|
|
|
def cordaStatusQueries = new CordaStatusQueries(projectContext)
|
|
|
|
|
|
tasks.register('listVNodes') {
|
|
group = queriesGroup
|
|
doLast {
|
|
cordaStatusQueries.listVNodes()
|
|
}
|
|
}
|
|
|
|
tasks.register('listCPIs') {
|
|
group = queriesGroup
|
|
doLast {
|
|
cordaStatusQueries.listCPIs()
|
|
}
|
|
}
|
|
|
|
// Build CPI tasks
|
|
|
|
def buildCPIsHelper = new BuildCPIsHelper(projectContext, networkConfig)
|
|
|
|
tasks.register("1-createGroupPolicy") {
|
|
group = cordappGroup
|
|
dependsOn('projInit')
|
|
doLast {
|
|
buildCPIsHelper.createGroupPolicy()
|
|
}
|
|
}
|
|
|
|
tasks.register("getNotaryServerCPB", Copy) {
|
|
group = supportingGroup
|
|
from configurations.notaryServerCPB
|
|
into cordaNotaryServerDir
|
|
}
|
|
|
|
tasks.register('2-createKeystore') {
|
|
group = cordappGroup
|
|
dependsOn('projInit')
|
|
doLast {
|
|
buildCPIsHelper.createKeyStore()
|
|
}
|
|
}
|
|
|
|
tasks.register('3-buildCPIs') {
|
|
group = cordappGroup
|
|
def dependsOnTasks = subprojects.collect {it.tasks.findByName("build") }
|
|
dependsOnTasks.add('1-createGroupPolicy')
|
|
dependsOnTasks.add('2-createKeystore')
|
|
dependsOnTasks.add('getNotaryServerCPB')
|
|
dependsOn dependsOnTasks
|
|
doLast{
|
|
buildCPIsHelper.buildCPIs()
|
|
}
|
|
}
|
|
|
|
|
|
// deploy CPI tasks
|
|
|
|
def deployCPIsHelper = new DeployCPIsHelper(projectContext)
|
|
|
|
tasks.register('4-deployCPIs') {
|
|
group = cordappGroup
|
|
dependsOn('3-buildCPIs')
|
|
doLast {
|
|
deployCPIsHelper.deployCPIs()
|
|
}
|
|
}
|
|
|
|
// Setup VNodes tasks
|
|
|
|
def vNodesHelper = new VNodesHelper(projectContext, networkConfig )
|
|
|
|
tasks.register('5-vNodeSetup') {
|
|
group = cordappGroup
|
|
dependsOn('4-deployCPIs')
|
|
doLast {
|
|
vNodesHelper.vNodesSetup()
|
|
}
|
|
}
|