diff --git a/Accounts/build.gradle b/Accounts/build.gradle new file mode 100644 index 00000000..3b0d2b58 --- /dev/null +++ b/Accounts/build.gradle @@ -0,0 +1,8 @@ +plugins { + id 'base' +} + +wrapper { + gradleVersion = '7.4.2' + distributionType = Wrapper.DistributionType.BIN +} diff --git a/Accounts/constants.properties b/Accounts/constants.properties deleted file mode 100644 index 6425fb0b..00000000 --- a/Accounts/constants.properties +++ /dev/null @@ -1,12 +0,0 @@ -cordaReleaseGroup=net.corda -cordaCoreReleaseGroup=net.corda -cordaVersion=4.8.5 -cordaCoreVersion=4.8.5 -gradlePluginsVersion=5.0.12 -kotlinVersion=1.2.71 -junitVersion=4.12 -quasarVersion=0.7.10 -log4jVersion =2.17.1 -platformVersion=10 -slf4jVersion=1.7.25 -nettyVersion=4.1.22.Final diff --git a/Accounts/gradle/wrapper/gradle-wrapper.jar b/Accounts/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..41d9927a Binary files /dev/null and b/Accounts/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Advanced/negotiation-cordapp/gradle/wrapper/gradle-wrapper.properties b/Accounts/gradle/wrapper/gradle-wrapper.properties similarity index 92% rename from Advanced/negotiation-cordapp/gradle/wrapper/gradle-wrapper.properties rename to Accounts/gradle/wrapper/gradle-wrapper.properties index 674bdda0..aa991fce 100644 --- a/Advanced/negotiation-cordapp/gradle/wrapper/gradle-wrapper.properties +++ b/Accounts/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Accounts/gradlew b/Accounts/gradlew new file mode 100755 index 00000000..1b6c7873 --- /dev/null +++ b/Accounts/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/Advanced/auction-cordapp/gradlew.bat b/Accounts/gradlew.bat similarity index 66% rename from Advanced/auction-cordapp/gradlew.bat rename to Accounts/gradlew.bat index f9553162..107acd32 100644 --- a/Advanced/auction-cordapp/gradlew.bat +++ b/Accounts/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/Accounts/settings.gradle b/Accounts/settings.gradle new file mode 100644 index 00000000..d4cf8db1 --- /dev/null +++ b/Accounts/settings.gradle @@ -0,0 +1,2 @@ +includeBuild 'supplychain' +includeBuild 'tictacthor' diff --git a/Accounts/supplychain/README.md b/Accounts/supplychain/README.md index 41e6e905..7655c9ce 100644 --- a/Accounts/supplychain/README.md +++ b/Accounts/supplychain/README.md @@ -13,7 +13,7 @@ From the above chart, you can see the flow is going back and forth between diffe # Setting up Go into the project directory and build the project ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Run the project ``` @@ -71,7 +71,7 @@ flow start InternalMessage fromWho: BuyerProcurement, whereTo: BuyerFinance, mes [Optional verification]: run ```flow start ViewInboxByAccount acctname: BuyerFinance``` at Buyer' node terminal ## Step 3: Buyer's finance team send a payment to Seller's finance team -Navigatie to Buyer's node terminal and type in: +Navigate to Buyer's node terminal and type in: ``` flow start SendPayment whoAmI: BuyerFinance, whereTo: SellerFinance, amount: 500 ``` diff --git a/Accounts/supplychain/build.gradle b/Accounts/supplychain/build.gradle index f334d624..be02e7f2 100644 --- a/Accounts/supplychain/build.gradle +++ b/Accounts/supplychain/build.gradle @@ -1,123 +1,92 @@ -buildscript { - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - - //account - accounts_release_group = 'com.r3.corda.lib.accounts' - accounts_release_version = '1.0' - //CI - confidential_id_release_group = "com.r3.corda.lib.ci" - confidential_id_release_version = "1.0" - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" +configurations { + ganache { + canBeConsumed = false + transitive = false } } -allprojects { - apply plugin: 'kotlin' - - repositories { - mavenLocal() +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } + } - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } - //SDK lib - maven { url 'https://software.r3.com/artifactory/corda-lib' } - //Gradle Plugins - maven { url 'https://repo.gradle.org/gradle/libs-releases' } + def subPath = it.path + pluginManager.withPlugin('net.corda.plugins.cordapp') { + rootProject.dependencies { + ganache project(path: subPath, configuration: 'cordaCordapp') + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // Don't include log config files. - exclude "**/log4j2*.xml" - // We need this because log4j2.xml is pulled in from multiple dependency JARs. - // JAR signing will fail if there are multiple files with the same name. - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } +//Module dependencis dependencies { - // Kotlin. - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaCompile "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':workflows') + cordapp project(':contracts') - // For logging. - testCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - testCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - //Account lib cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version" cordapp "$accounts_release_group:accounts-contracts:$accounts_release_version" cordapp "$accounts_release_group:accounts-workflows:$accounts_release_version" + + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = false - } - cordapp("$confidential_id_release_group:ci-workflows:$confidential_id_release_version") - cordapp("$accounts_release_group:accounts-contracts:$accounts_release_version") - cordapp("$accounts_release_group:accounts-workflows:$accounts_release_version") - - cordapp project(":contracts") - cordapp project(":workflows") - runSchemaMigration = true + cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version" + cordapp "$accounts_release_group:accounts-contracts:$accounts_release_version" + cordapp "$accounts_release_group:accounts-workflows:$accounts_release_version" + cordapp project(':workflows') + cordapp project(':contracts') + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { name "O=Notary,L=London,C=GB" @@ -127,7 +96,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } - cordapps = [] + rpcUsers = [] } node { name "O=Buyer,L=London,C=GB" @@ -136,7 +105,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=Seller,L=New York,C=US" @@ -145,8 +113,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] - } node { name "O=ShippingCo,L=New York,C=US" @@ -155,6 +121,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10011") adminAddress("localhost:10052") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } } diff --git a/Accounts/supplychain/contracts/build.gradle b/Accounts/supplychain/contracts/build.gradle index eb268e39..71218207 100644 --- a/Accounts/supplychain/contracts/build.gradle +++ b/Accounts/supplychain/contracts/build.gradle @@ -1,5 +1,7 @@ -apply plugin: 'kotlin' -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { targetPlatformVersion 4 @@ -10,31 +12,20 @@ cordapp { licence "A liberal, open source licence" versionId 1 } - signing { - enabled true - } -} - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } } dependencies { // Kotlin. - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_release_group:corda-core:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // Token Account dependencies. - cordaCompile "$accounts_release_group:accounts-contracts:$accounts_release_version" + cordapp "$accounts_release_group:accounts-contracts:$accounts_release_version" } diff --git a/Accounts/supplychain/contracts/src/main/kotlin/net/corda/samples/supplychain/contracts/InvoiceStateContract.kt b/Accounts/supplychain/contracts/src/main/kotlin/net/corda/samples/supplychain/contracts/InvoiceStateContract.kt index d1300319..17b03c88 100644 --- a/Accounts/supplychain/contracts/src/main/kotlin/net/corda/samples/supplychain/contracts/InvoiceStateContract.kt +++ b/Accounts/supplychain/contracts/src/main/kotlin/net/corda/samples/supplychain/contracts/InvoiceStateContract.kt @@ -22,10 +22,10 @@ class InvoiceStateContract : Contract{ val outputs = tx.outputStates // no inputs to the transaction - "No inputs should be consumed when creating a new SantaSession.".using(inputs.isEmpty()) + "No inputs should be consumed when creating a new session.".using(inputs.isEmpty()) "Transaction must have exactly one output.".using(outputs.size == 1) - val output = outputs[0] as InvoiceState + val output = tx.outputsOfType().single() // must be three or more players "Invoice amount must be a valid number (Greater than zero)".using(output.amount > 0) null diff --git a/Accounts/supplychain/contracts/src/test/java/net/corda/samples/supplychain/contracts/ContractTests.kt b/Accounts/supplychain/contracts/src/test/kotlin/net/corda/samples/supplychain/contracts/ContractTests.kt similarity index 86% rename from Accounts/supplychain/contracts/src/test/java/net/corda/samples/supplychain/contracts/ContractTests.kt rename to Accounts/supplychain/contracts/src/test/kotlin/net/corda/samples/supplychain/contracts/ContractTests.kt index 0427c366..ebb0b616 100644 --- a/Accounts/supplychain/contracts/src/test/java/net/corda/samples/supplychain/contracts/ContractTests.kt +++ b/Accounts/supplychain/contracts/src/test/kotlin/net/corda/samples/supplychain/contracts/ContractTests.kt @@ -1,6 +1,5 @@ package net.corda.samples.supplychain.contracts - import net.corda.core.contracts.UniqueIdentifier import net.corda.core.identity.AnonymousParty import net.corda.core.identity.CordaX500Name @@ -12,8 +11,8 @@ import org.junit.Test class ContractTests { private val ledgerServices = MockServices() - val Operator = TestIdentity(CordaX500Name(organisation = "Alice", locality = "TestLand", country = "US")) - var Operator2 = TestIdentity(CordaX500Name("Bob", "TestLand", "US")) + private val Operator = TestIdentity(CordaX500Name(organisation = "Alice", locality = "TestLand", country = "US")) + private var Operator2 = TestIdentity(CordaX500Name("Bob", "TestLand", "US")) @Test fun `Invoice Amount Must Be Greater Than Zero`() { diff --git a/Accounts/supplychain/contracts/src/test/java/net/corda/samples/supplychain/contracts/StateTests.kt b/Accounts/supplychain/contracts/src/test/kotlin/net/corda/samples/supplychain/contracts/StateTests.kt similarity index 76% rename from Accounts/supplychain/contracts/src/test/java/net/corda/samples/supplychain/contracts/StateTests.kt rename to Accounts/supplychain/contracts/src/test/kotlin/net/corda/samples/supplychain/contracts/StateTests.kt index 39ad2deb..2f3dde92 100644 --- a/Accounts/supplychain/contracts/src/test/java/net/corda/samples/supplychain/contracts/StateTests.kt +++ b/Accounts/supplychain/contracts/src/test/kotlin/net/corda/samples/supplychain/contracts/StateTests.kt @@ -1,13 +1,10 @@ package net.corda.samples.supplychain.contracts -import groovy.util.GroovyTestCase.assertEquals import net.corda.samples.supplychain.states.InvoiceState -import net.corda.testing.node.MockServices +import org.junit.Assert.assertEquals import org.junit.Test class StateTests { - private val ledgerServices = MockServices() - @Test fun hasMessageFieldOfCorrectType() { // Does the message field exist? @@ -15,4 +12,4 @@ class StateTests { // Is the message field of the correct type? assertEquals(InvoiceState::class.java.getDeclaredField("amount").type, Int::class.java) } -} \ No newline at end of file +} diff --git a/Accounts/supplychain/gradle.properties b/Accounts/supplychain/gradle.properties index e0570f4a..9f1140e7 100644 --- a/Accounts/supplychain/gradle.properties +++ b/Accounts/supplychain/gradle.properties @@ -1,4 +1,34 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Supplychain Cordapp group=com.supplychain version=1.0 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +# Accounts +accounts_release_group=com.r3.corda.lib.accounts +accounts_release_version=1.0 + +# Confidential Identities (CI) +confidential_id_release_group=com.r3.corda.lib.ci +confidential_id_release_version=1.0 + +spring_boot_version=2.0.2.RELEASE diff --git a/Accounts/supplychain/gradle/wrapper/gradle-wrapper.jar b/Accounts/supplychain/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7a3265ee..00000000 Binary files a/Accounts/supplychain/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Accounts/supplychain/gradle/wrapper/gradle-wrapper.properties b/Accounts/supplychain/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Accounts/supplychain/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Accounts/supplychain/gradlew b/Accounts/supplychain/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Accounts/supplychain/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Accounts/supplychain/lib/README.txt b/Accounts/supplychain/lib/README.txt deleted file mode 100644 index b0592c95..00000000 --- a/Accounts/supplychain/lib/README.txt +++ /dev/null @@ -1,8 +0,0 @@ -The Quasar.jar in this directory is for runtime instrumentation of classes by Quasar. - -When running corda outside of the given gradle building you must add the following flag with the -correct path to your call to Java: - - java -javaagent:path-to-quasar-jar.jar ... - -See the Quasar docs for more information: http://docs.paralleluniverse.co/quasar/ \ No newline at end of file diff --git a/Accounts/supplychain/lib/quasar.jar b/Accounts/supplychain/lib/quasar.jar deleted file mode 100644 index 286f065e..00000000 Binary files a/Accounts/supplychain/lib/quasar.jar and /dev/null differ diff --git a/Accounts/supplychain/settings.gradle b/Accounts/supplychain/settings.gradle index 2514aca2..45f64fa3 100644 --- a/Accounts/supplychain/settings.gradle +++ b/Accounts/supplychain/settings.gradle @@ -1,3 +1,38 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url "$artifactoryContextUrl/corda-lib" + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file diff --git a/Accounts/supplychain/workflows/build.gradle b/Accounts/supplychain/workflows/build.gradle index b8e8c9a2..722e015a 100644 --- a/Accounts/supplychain/workflows/build.gradle +++ b/Accounts/supplychain/workflows/build.gradle @@ -1,6 +1,8 @@ -apply plugin: 'kotlin' -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { targetPlatformVersion 4 @@ -11,17 +13,9 @@ cordapp { licence "A liberal, open source licence" versionId 1 } - signing { - enabled false - } } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -37,31 +31,31 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { // Kotlin. - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" // For testing. - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" - testCompile "junit:junit:$junit_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordaCompile project(":contracts") + cordapp project(':contracts') //Account dependencies - cordaCompile "$confidential_id_release_group:ci-workflows:$confidential_id_release_version" - cordaCompile "$accounts_release_group:accounts-workflows:$accounts_release_version" + cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version" + cordapp "$accounts_release_group:accounts-workflows:$accounts_release_version" + cordapp "$accounts_release_group:accounts-contracts:$accounts_release_version" } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath } diff --git a/Accounts/supplychain/workflows/src/integrationTest/kotlin/net/corda/samples/supplychain/DriverBasedTest.kt b/Accounts/supplychain/workflows/src/integrationTest/kotlin/net/corda/samples/supplychain/DriverBasedTest.kt index fc7e791f..b18da49e 100644 --- a/Accounts/supplychain/workflows/src/integrationTest/kotlin/net/corda/samples/supplychain/DriverBasedTest.kt +++ b/Accounts/supplychain/workflows/src/integrationTest/kotlin/net/corda/samples/supplychain/DriverBasedTest.kt @@ -7,9 +7,9 @@ import net.corda.testing.driver.DriverDSL import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.driver +import org.junit.Assert.assertEquals import org.junit.Test import java.util.concurrent.Future -import kotlin.test.assertEquals class DriverBasedTest { private val bankA = TestIdentity(CordaX500Name("BankA", "", "GB")) diff --git a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/accountUtilities/CreateNewAccount.kt b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/accountUtilities/CreateNewAccount.kt index d3b511f2..fc7c34db 100644 --- a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/accountUtilities/CreateNewAccount.kt +++ b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/accountUtilities/CreateNewAccount.kt @@ -1,6 +1,5 @@ package net.corda.samples.supplychain.accountUtilities - import net.corda.core.flows.* import co.paralleluniverse.fibers.Suspendable import com.r3.corda.lib.accounts.workflows.accountService @@ -8,7 +7,6 @@ import net.corda.core.flows.FlowLogic import net.corda.core.flows.StartableByRPC import net.corda.core.utilities.getOrThrow - @StartableByRPC @StartableByService @InitiatingFlow diff --git a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/accountUtilities/QueryByAcctUUID.kt b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/accountUtilities/QueryByAcctUUID.kt index 9b4f9853..39bfd111 100644 --- a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/accountUtilities/QueryByAcctUUID.kt +++ b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/accountUtilities/QueryByAcctUUID.kt @@ -1,6 +1,5 @@ package net.corda.samples.supplychain.accountUtilities - import net.corda.core.flows.* import co.paralleluniverse.fibers.Suspendable import com.r3.corda.lib.accounts.workflows.accountService @@ -9,7 +8,6 @@ import net.corda.core.flows.StartableByRPC import net.corda.core.node.services.vault.QueryCriteria import net.corda.samples.supplychain.states.* - @StartableByRPC @StartableByService @InitiatingFlow diff --git a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/accountUtilities/ShareAccount.kt b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/accountUtilities/ShareAccount.kt index 6b692b9e..a131fa8e 100644 --- a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/accountUtilities/ShareAccount.kt +++ b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/accountUtilities/ShareAccount.kt @@ -1,6 +1,5 @@ package net.corda.samples.supplychain.accountUtilities - import net.corda.core.flows.* import co.paralleluniverse.fibers.Suspendable import com.r3.corda.lib.accounts.workflows.accountService @@ -8,7 +7,6 @@ import net.corda.core.flows.FlowLogic import net.corda.core.flows.StartableByRPC import net.corda.core.identity.Party - @StartableByRPC @StartableByService @InitiatingFlow @@ -21,9 +19,9 @@ class ShareAccountTo( override fun call(): String { //Create a new account - val AllmyAccounts = accountService.ourAccounts() - val SharedAccount = AllmyAccounts.single { it.state.data.name == acctNameShared }.state.data.identifier.id - accountService.shareAccountInfoWithParty(SharedAccount,shareTo) + val allMyAccounts = accountService.ourAccounts() + val sharedAccount = allMyAccounts.single { it.state.data.name == acctNameShared }.state.data.identifier.id + accountService.shareAccountInfoWithParty(sharedAccount,shareTo) return "Shared " + acctNameShared + " with " + shareTo.name.organisation } } diff --git a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/accountUtilities/ViewMyAccounts.kt b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/accountUtilities/ViewMyAccounts.kt index 6ee34636..b5f04488 100644 --- a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/accountUtilities/ViewMyAccounts.kt +++ b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/accountUtilities/ViewMyAccounts.kt @@ -1,14 +1,11 @@ package net.corda.samples.supplychain.accountUtilities - - import net.corda.core.flows.* import co.paralleluniverse.fibers.Suspendable import com.r3.corda.lib.accounts.workflows.accountService import net.corda.core.flows.FlowLogic import net.corda.core.flows.StartableByRPC - @StartableByRPC @StartableByService @InitiatingFlow @@ -17,8 +14,8 @@ class ViewMyAccounts() : FlowLogic>() { @Suspendable override fun call(): List { //Create a new account - val aAccountsQuery = accountService.ourAccounts().map { it.state.data.name } - return aAccountsQuery + val accountsQuery = accountService.ourAccounts().map { it.state.data.name } + return accountsQuery } } diff --git a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/InternalMessage.kt b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/InternalMessage.kt index 912da10d..cdf8d290 100644 --- a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/InternalMessage.kt +++ b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/InternalMessage.kt @@ -1,6 +1,5 @@ package net.corda.samples.supplychain.flows - import net.corda.core.flows.* import co.paralleluniverse.fibers.Suspendable import com.r3.corda.lib.accounts.workflows.accountService @@ -17,7 +16,6 @@ import net.corda.samples.supplychain.accountUtilities.NewKeyForAccount import net.corda.samples.supplychain.contracts.InternalMessageStateContract import net.corda.samples.supplychain.states.InternalMessageState - @StartableByRPC @StartableByService @InitiatingFlow @@ -57,8 +55,8 @@ class InternalMessage( progressTracker.currentStep = GENERATING_KEYS //Initiator account - val FromAccount = accountService.accountInfo(fromWho).single().state.data - val newKeyForInitiator = subFlow(NewKeyForAccount(FromAccount.identifier.id)) + val fromAccount = accountService.accountInfo(fromWho).single().state.data + val newKeyForInitiator = subFlow(NewKeyForAccount(fromAccount.identifier.id)) //val newKeyForInitiator = subFlow(RequestKeyForAccount(FromAccount)) //Recieving account diff --git a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/SendCargo.kt b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/SendCargo.kt index 322f4b27..56f27744 100644 --- a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/SendCargo.kt +++ b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/SendCargo.kt @@ -1,6 +1,5 @@ package net.corda.samples.supplychain.flows - import net.corda.core.flows.* import co.paralleluniverse.fibers.Suspendable import com.r3.corda.lib.accounts.workflows.accountService diff --git a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/SendInvoice.kt b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/SendInvoice.kt index 1f83a62c..0427e224 100644 --- a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/SendInvoice.kt +++ b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/SendInvoice.kt @@ -1,6 +1,5 @@ package net.corda.samples.supplychain.flows - import net.corda.core.flows.* import co.paralleluniverse.fibers.Suspendable import com.r3.corda.lib.accounts.workflows.accountService diff --git a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/SendPayment.kt b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/SendPayment.kt index eef49168..5bea3316 100644 --- a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/SendPayment.kt +++ b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/SendPayment.kt @@ -1,6 +1,5 @@ package net.corda.samples.supplychain.flows - import net.corda.core.flows.* import co.paralleluniverse.fibers.Suspendable import com.r3.corda.lib.accounts.workflows.accountService @@ -11,8 +10,6 @@ import net.corda.core.identity.AnonymousParty import net.corda.core.identity.CordaX500Name import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.TransactionBuilder -import java.util.concurrent.atomic.AtomicReference -import net.corda.core.node.StatesToRecord import net.corda.core.utilities.ProgressTracker import net.corda.samples.supplychain.accountUtilities.NewKeyForAccount import net.corda.samples.supplychain.contracts.PaymentStateContract diff --git a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/SendShippingRequest.kt b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/SendShippingRequest.kt index 48fac1d0..12637384 100644 --- a/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/SendShippingRequest.kt +++ b/Accounts/supplychain/workflows/src/main/kotlin/net/corda/samples/supplychain/flows/SendShippingRequest.kt @@ -1,6 +1,5 @@ package net.corda.samples.supplychain.flows - import net.corda.core.flows.* import co.paralleluniverse.fibers.Suspendable import com.r3.corda.lib.accounts.workflows.accountService diff --git a/Accounts/supplychain/workflows/src/test/kotlin/net/corda/samples/supplychain/FlowTests.kt b/Accounts/supplychain/workflows/src/test/kotlin/net/corda/samples/supplychain/FlowTests.kt index e1e6ec8a..7800b09d 100644 --- a/Accounts/supplychain/workflows/src/test/kotlin/net/corda/samples/supplychain/FlowTests.kt +++ b/Accounts/supplychain/workflows/src/test/kotlin/net/corda/samples/supplychain/FlowTests.kt @@ -1,6 +1,5 @@ package net.corda.samples.supplychain - import com.r3.corda.lib.accounts.workflows.services.AccountService import com.r3.corda.lib.accounts.workflows.services.KeyManagementBackedAccountService import net.corda.core.identity.CordaX500Name @@ -12,9 +11,10 @@ import net.corda.samples.supplychain.states.InvoiceState import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.node.* import org.junit.After +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test -import java.util.* import java.util.concurrent.ExecutionException import java.util.concurrent.Future @@ -40,23 +40,25 @@ class FlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test @Throws(ExecutionException::class, InterruptedException::class) - fun AccountCreation() { + fun accountCreation() { val createAcct = CreateNewAccount("TestAccountA") val future: Future = a.startFlow(createAcct) network.runNetwork() val accountService: AccountService = a.services.cordaService(KeyManagementBackedAccountService::class.java) val myAccount = accountService.accountInfo("TestAccountA") - assert(myAccount.size != 0) + assertTrue(myAccount.isNotEmpty()) } @Test @Throws(ExecutionException::class, InterruptedException::class) - fun InvoiceFlowTest() { + fun invoiceFlowTest() { val createAcct = CreateNewAccount("TestAccountA") val future: Future = a.startFlow(createAcct) network.runNetwork() @@ -77,10 +79,9 @@ class FlowTests { val accountService: AccountService = b.services.cordaService(KeyManagementBackedAccountService::class.java) val (_, _, identifier) = accountService.accountInfo("TestAccountB")[0].state.data val criteria = VaultQueryCriteria() - .withExternalIds(Arrays.asList(identifier.id)) + .withExternalIds(listOf(identifier.id)) val storedState = b.services.vaultService.queryBy(InvoiceState::class.java, criteria).states[0].state.data - assert(storedState.amount == 20) + assertEquals(20, storedState.amount) } - } \ No newline at end of file diff --git a/Accounts/tictacthor/README.md b/Accounts/tictacthor/README.md index 9b71cee6..5ec3dbc7 100644 --- a/Accounts/tictacthor/README.md +++ b/Accounts/tictacthor/README.md @@ -7,12 +7,12 @@ This CorDapp recreates the game of Tic Tac Toe via Corda. It primarilly demonstr ## Running the sample Deploy and run the nodes by: ``` -./gradlew deployNodes +../gradlew deployNodes ./build/nodes/runnodes ``` Then you will need to also start the spring server for the Cordapp by running the following commands seperately: -`./gradlew bootRunDevRel`will have the DevRel server running on 8080 port -, and `./gradlew bootRunSOE`will start the Solution Engineering server on 8090 port +`../gradlew bootRunDevRel`will have the DevRel server running on 8080 port +, and `../gradlew bootRunSOE`will start the Solution Engineering server on 8090 port ## Operating the Cordapp Now go to postman and excute the following in order: (All of the API are POST request!) diff --git a/Accounts/tictacthor/build.gradle b/Accounts/tictacthor/build.gradle index f60ec187..1e3c7225 100644 --- a/Accounts/tictacthor/build.gradle +++ b/Accounts/tictacthor/build.gradle @@ -1,108 +1,67 @@ -buildscript { - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - - //account - accounts_release_group = 'com.r3.corda.lib.accounts' - accounts_release_version = '1.0' - //CI - confidential_id_release_group = "com.r3.corda.lib.ci" - confidential_id_release_version = "1.0" - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" +configurations { + ganache { + canBeConsumed = false + transitive = false } } -allprojects { - apply plugin: 'kotlin' - - repositories { - mavenLocal() +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } + } - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } - //SDK lib - maven { url 'https://software.r3.com/artifactory/corda-lib' } - //Gradle Plugins - maven { url 'https://repo.gradle.org/gradle/libs-releases' } + def subPath = it.path + pluginManager.withPlugin('net.corda.plugins.cordapp') { + rootProject.dependencies { + ganache project(path: subPath, configuration: 'cordaCordapp') + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } +//Module dependencis dependencies { - - // Kotlin. - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaCompile "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") - - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordapp project(':workflows') + cordapp project(':contracts') //Account lib cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version" @@ -110,17 +69,22 @@ dependencies { cordapp "$accounts_release_group:accounts-workflows:$accounts_release_version" } -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = false - } - cordapp project(':contracts') + cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version" + cordapp "$accounts_release_group:accounts-contracts:$accounts_release_version" + cordapp "$accounts_release_group:accounts-workflows:$accounts_release_version" cordapp project(':workflows') - cordapp("$confidential_id_release_group:ci-workflows:$confidential_id_release_version") - cordapp("$accounts_release_group:accounts-contracts:$accounts_release_version") - cordapp("$accounts_release_group:accounts-workflows:$accounts_release_version") - runSchemaMigration = true + cordapp project(':contracts') + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { name "O=Notary,L=London,C=GB" @@ -130,6 +94,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { name "O=DevRel,L=London,C=GB,CN=Bob" @@ -138,8 +103,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] - } node { name "O=SolutionEng,L=New York,C=US,CN=Alice" @@ -148,22 +111,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] - } -// node { -// name "O=Observer,L=Chicago,C=US,CN=John" -// p2pPort 10011 -// rpcSettings { -// address("localhost:10010") -// adminAddress("localhost:10050") -// } -// rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] -// } -} - -task installQuasar(type: Copy) { - destinationDir rootProject.file("lib") - from(configurations.quasar) { - rename 'quasar-core(.*).jar', 'quasar.jar' } } diff --git a/Accounts/tictacthor/clients/build.gradle b/Accounts/tictacthor/clients/build.gradle index fecafac4..1022b64b 100644 --- a/Accounts/tictacthor/clients/build.gradle +++ b/Accounts/tictacthor/clients/build.gradle @@ -1,4 +1,7 @@ -apply plugin: 'org.springframework.boot' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'org.springframework.boot' +} sourceSets { main { @@ -10,43 +13,35 @@ sourceSets { dependencies { // Corda dependencies. - compile "$corda_release_group:corda-rpc:$corda_release_version" + implementation "$corda_release_group:corda-rpc:$corda_release_version" // CorDapp dependencies. - compile project(":contracts") - compile project(":workflows") + implementation project(':contracts') + implementation project(':workflows') - compile("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { + implementation("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { exclude group: "org.springframework.boot", module: "spring-boot-starter-logging" } - compile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - compile "org.apache.logging.log4j:log4j-web:${log4j_version}" - compile "org.slf4j:jul-to-slf4j:$slf4j_version" -} - -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { - kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" - javaParameters = true // Useful for reflection. - } + runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" + runtimeOnly "org.apache.logging.log4j:log4j-web:$log4j_version" + runtimeOnly "org.slf4j:jul-to-slf4j:$slf4j_version" } springBoot { mainClassName = "net.corda.samples.tictacthor.webserver.ServerKt" } - -task bootRunDevRel(type: JavaExec, dependsOn: jar) { +tasks.register('bootRunDevRel', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.tictacthor.webserver.ServerKt' args '--server.port=8080', '--config.rpc.host=localhost', '--config.rpc.port=10006', '--config.rpc.username=user1', '--config.rpc.password=test' } -task bootRunSOE(type: JavaExec, dependsOn: jar) { +tasks.register('bootRunSOE', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.tictacthor.webserver.ServerKt' args '--server.port=8090', '--config.rpc.host=localhost', '--config.rpc.port=10009', '--config.rpc.username=user1', '--config.rpc.password=test' -} \ No newline at end of file +} diff --git a/Accounts/tictacthor/clients/src/main/kotlin/net/corda/samples/tictacthor/webserver/Controller.kt b/Accounts/tictacthor/clients/src/main/kotlin/net/corda/samples/tictacthor/webserver/Controller.kt index 481fb949..2c057fe3 100644 --- a/Accounts/tictacthor/clients/src/main/kotlin/net/corda/samples/tictacthor/webserver/Controller.kt +++ b/Accounts/tictacthor/clients/src/main/kotlin/net/corda/samples/tictacthor/webserver/Controller.kt @@ -6,11 +6,9 @@ import net.corda.samples.tictacthor.flows.EndGameFlow import net.corda.samples.tictacthor.flows.StartGameFlow import net.corda.samples.tictacthor.flows.SubmitTurnFlow import net.corda.samples.tictacthor.accountsUtilities.myGame -import net.corda.samples.tictacthor.states.BoardState import net.corda.samples.tictacthor.states.Status import net.corda.core.internal.toX500Name import net.corda.core.messaging.startFlow -import net.corda.core.messaging.vaultQueryBy import net.corda.core.node.NodeInfo import org.bouncycastle.asn1.x500.X500Name import org.bouncycastle.asn1.x500.style.BCStyle diff --git a/Accounts/tictacthor/contracts/build.gradle b/Accounts/tictacthor/contracts/build.gradle index 3016d4a7..8e5bf441 100644 --- a/Accounts/tictacthor/contracts/build.gradle +++ b/Accounts/tictacthor/contracts/build.gradle @@ -1,4 +1,7 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -12,35 +15,25 @@ cordapp { signing { enabled false options { - keystore "/Users/thorgilman/Desktop/thor_key.jks" - alias "thorkey" - storepass "password" - keypass "password" - storetype "JKS" + keyStore = "/Users/thorgilman/Desktop/thor_key.jks" + alias = "thorkey" + storePassword = "password" + keyPassword = "password" + storeType = "JKS" } } } -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { - kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" - javaParameters = true // Useful for reflection. - } -} - - dependencies { // Kotlin. - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_release_group:corda-core:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // Token Account dependencies. - cordaCompile "$accounts_release_group:accounts-contracts:$accounts_release_version" -} \ No newline at end of file + cordapp "$accounts_release_group:accounts-contracts:$accounts_release_version" +} diff --git a/Accounts/tictacthor/contracts/src/main/kotlin/net/corda/samples/tictacthor/contracts/BoardContract.kt b/Accounts/tictacthor/contracts/src/main/kotlin/net/corda/samples/tictacthor/contracts/BoardContract.kt index c9096aee..e6438b80 100644 --- a/Accounts/tictacthor/contracts/src/main/kotlin/net/corda/samples/tictacthor/contracts/BoardContract.kt +++ b/Accounts/tictacthor/contracts/src/main/kotlin/net/corda/samples/tictacthor/contracts/BoardContract.kt @@ -3,10 +3,7 @@ package net.corda.samples.tictacthor.contracts import net.corda.samples.tictacthor.states.BoardState import net.corda.samples.tictacthor.states.Status import net.corda.core.contracts.* -import net.corda.core.identity.AnonymousParty -import net.corda.core.identity.Party import net.corda.core.transactions.LedgerTransaction -import java.util.* class BoardContract : Contract { companion object { @@ -31,7 +28,7 @@ class BoardContract : Contract { "The output state should be of type BoardState." using (tx.outputs[0].data is BoardState) // Business Logic - val outputBoardState = tx.outputStates[0] as BoardState + val outputBoardState = tx.outputsOfType().single() "Output board must have status GAME_IN_PROGRESS" using (outputBoardState.status == Status.GAME_IN_PROGRESS) "You cannot play a game with yourself." using ((outputBoardState.playerO) != outputBoardState.playerX) "Not valid starting board." using BoardUtils.checkIfValidStartBoard(outputBoardState.board) @@ -44,11 +41,11 @@ class BoardContract : Contract { "The output state should be of type BoardState." using (tx.outputStates.single() is BoardState) // Business Logic - val inputBoardState = tx.inputStates.single() as BoardState - val outputBoardState = tx.outputStates.single() as BoardState + val inputBoardState = tx.inputsOfType().single() + val outputBoardState = tx.outputsOfType().single() "Input board must have status GAME_IN_PROGRESS." using (inputBoardState.status == Status.GAME_IN_PROGRESS) - "It cannot be the same players turn both in the input board and the output board." using (inputBoardState.isPlayerXTurn.booleanValue() xor outputBoardState.isPlayerXTurn.booleanValue()) - val playerChar = if (inputBoardState.isPlayerXTurn.booleanValue()) 'X' else 'O' + "It cannot be the same players turn both in the input board and the output board." using (inputBoardState.isPlayerXTurn xor outputBoardState.isPlayerXTurn) + val playerChar = if (inputBoardState.isPlayerXTurn) 'X' else 'O' "Not valid board update." using BoardUtils.checkIfValidBoardUpdate(inputBoardState.board, outputBoardState.board, playerChar) // Signatures @@ -62,7 +59,7 @@ class BoardContract : Contract { "The input state should be of type BoardState." using (tx.inputs[0].state.data is BoardState) // Business Logic - val inputBoardState = tx.inputStates.single() as BoardState + val inputBoardState = tx.inputsOfType().single() "Input board must have status GAME_OVER." using (inputBoardState.status == Status.GAME_OVER) "The game must be over." using (BoardUtils.isGameOver(inputBoardState)) } diff --git a/Accounts/tictacthor/contracts/src/main/kotlin/net/corda/samples/tictacthor/states/BoardState.kt b/Accounts/tictacthor/contracts/src/main/kotlin/net/corda/samples/tictacthor/states/BoardState.kt index fe67c076..87dc8846 100644 --- a/Accounts/tictacthor/contracts/src/main/kotlin/net/corda/samples/tictacthor/states/BoardState.kt +++ b/Accounts/tictacthor/contracts/src/main/kotlin/net/corda/samples/tictacthor/states/BoardState.kt @@ -3,11 +3,8 @@ package net.corda.samples.tictacthor.states import net.corda.core.contracts.* import net.corda.core.identity.AbstractParty import net.corda.core.identity.AnonymousParty -import net.corda.core.identity.Party import net.corda.core.serialization.CordaSerializable import net.corda.samples.tictacthor.contracts.BoardContract -import java.security.PublicKey -import java.util.* import kotlin.IllegalStateException @CordaSerializable @@ -21,15 +18,15 @@ data class BoardState(val playerO: UniqueIdentifier, val playerX: UniqueIdentifier, val me: AnonymousParty, val competitor:AnonymousParty, - val isPlayerXTurn: java.lang.Boolean = java.lang.Boolean(false), - val board: Array = Array(3, {charArrayOf('E', 'E', 'E')} ), + val isPlayerXTurn: Boolean = false, + val board: Array = Array(3) { charArrayOf('E', 'E', 'E') }, val status: Status = Status.GAME_IN_PROGRESS, override val linearId: UniqueIdentifier = UniqueIdentifier()): LinearState { override val participants: List = listOfNotNull(me,competitor).map {it} // Returns the party of the current player - fun getCurrentPlayerParty(): UniqueIdentifier { return if (isPlayerXTurn.booleanValue()) playerX else playerO } + fun getCurrentPlayerParty(): UniqueIdentifier { return if (isPlayerXTurn) playerX else playerO } // Get deep copy of board private fun Array.copy() = Array(size) { get(it).clone() } @@ -37,11 +34,11 @@ data class BoardState(val playerO: UniqueIdentifier, fun returnNewBoardAfterMove(pos: Pair, me:AnonymousParty, competitor:AnonymousParty): BoardState { if (pos.first > 2 || pos.second > 2) throw IllegalStateException("Invalid board index.") val newBoard = board.copy() - if (isPlayerXTurn.booleanValue()) newBoard[pos.second][pos.first] = 'X' + if (isPlayerXTurn) newBoard[pos.second][pos.first] = 'X' else newBoard[pos.second][pos.first] = 'O' val newBoardState = copy(board = newBoard, - isPlayerXTurn = java.lang.Boolean(!isPlayerXTurn.booleanValue()), + isPlayerXTurn = !isPlayerXTurn, me = me, competitor = competitor) if (BoardContract.BoardUtils.isGameOver(newBoardState)) return newBoardState.copy(status = Status.GAME_OVER) diff --git a/Accounts/tictacthor/contracts/src/test/kotlin/net/corda/samples/tictacthor/contracts/ContractTests.kt b/Accounts/tictacthor/contracts/src/test/kotlin/net/corda/samples/tictacthor/contracts/ContractTests.kt index adcd1ff3..fce1ffd4 100644 --- a/Accounts/tictacthor/contracts/src/test/kotlin/net/corda/samples/tictacthor/contracts/ContractTests.kt +++ b/Accounts/tictacthor/contracts/src/test/kotlin/net/corda/samples/tictacthor/contracts/ContractTests.kt @@ -11,8 +11,8 @@ import org.junit.Test class ContractTests { private val ledgerServices = MockServices() - val Operator = TestIdentity(CordaX500Name(organisation = "Alice", locality = "TestLand", country = "US")) - var Operator2 = TestIdentity(CordaX500Name("Bob", "TestLand", "US")) + private val Operator = TestIdentity(CordaX500Name(organisation = "Alice", locality = "TestLand", country = "US")) + private var Operator2 = TestIdentity(CordaX500Name("Bob", "TestLand", "US")) @Test fun `Game Can Only Created When Two Different Player Presented`() { diff --git a/Accounts/tictacthor/contracts/src/test/kotlin/net/corda/samples/tictacthor/contracts/StateTests.kt b/Accounts/tictacthor/contracts/src/test/kotlin/net/corda/samples/tictacthor/contracts/StateTests.kt index 443ef534..cc96e033 100644 --- a/Accounts/tictacthor/contracts/src/test/kotlin/net/corda/samples/tictacthor/contracts/StateTests.kt +++ b/Accounts/tictacthor/contracts/src/test/kotlin/net/corda/samples/tictacthor/contracts/StateTests.kt @@ -1,9 +1,9 @@ package net.corda.samples.tictacthor.contracts -import groovy.util.GroovyTestCase.assertEquals import net.corda.core.contracts.UniqueIdentifier import net.corda.samples.tictacthor.states.BoardState import net.corda.testing.node.MockServices +import org.junit.Assert.assertEquals import org.junit.Test class StateTests { diff --git a/Accounts/tictacthor/gradle.properties b/Accounts/tictacthor/gradle.properties index 307e72d4..5aa972df 100644 --- a/Accounts/tictacthor/gradle.properties +++ b/Accounts/tictacthor/gradle.properties @@ -1,4 +1,34 @@ -name=Test -group=com.template -version=0.1 -kotlin.incremental=false \ No newline at end of file +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + +name=Tic-Tac-Thor Cordapp +group=com.tictacthor +version=1.0 + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +# Accounts +accounts_release_group=com.r3.corda.lib.accounts +accounts_release_version=1.0 + +# Confidential Identities (CI) +confidential_id_release_group=com.r3.corda.lib.ci +confidential_id_release_version=1.0 + +spring_boot_version=2.0.2.RELEASE diff --git a/Accounts/tictacthor/gradle/wrapper/gradle-wrapper.jar b/Accounts/tictacthor/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Accounts/tictacthor/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Accounts/tictacthor/gradle/wrapper/gradle-wrapper.properties b/Accounts/tictacthor/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 2a2a3a8e..00000000 --- a/Accounts/tictacthor/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/Accounts/tictacthor/gradlew b/Accounts/tictacthor/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Accounts/tictacthor/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Accounts/tictacthor/runServers.sh b/Accounts/tictacthor/runServers.sh old mode 100644 new mode 100755 index 0807fb1f..546f8d9f --- a/Accounts/tictacthor/runServers.sh +++ b/Accounts/tictacthor/runServers.sh @@ -1,3 +1,3 @@ #!/bin/sh -./gradlew bootRunDevRel & -./gradlew bootRunSOE +../gradlew bootRunDevRel & +../gradlew bootRunSOE diff --git a/Accounts/tictacthor/settings.gradle b/Accounts/tictacthor/settings.gradle index 2514aca2..d1af6c58 100644 --- a/Accounts/tictacthor/settings.gradle +++ b/Accounts/tictacthor/settings.gradle @@ -1,3 +1,39 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url "$artifactoryContextUrl/corda-lib" + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file +include 'clients' diff --git a/Accounts/tictacthor/workflows/build.gradle b/Accounts/tictacthor/workflows/build.gradle index 5b463fd4..6e234b02 100644 --- a/Accounts/tictacthor/workflows/build.gradle +++ b/Accounts/tictacthor/workflows/build.gradle @@ -1,5 +1,8 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,40 +31,28 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') - //Account dependencies - cordaCompile "$confidential_id_release_group:ci-workflows:$confidential_id_release_version" - cordaCompile "$accounts_release_group:accounts-workflows:$accounts_release_version" + // Account dependencies + cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version" + cordapp "$accounts_release_group:accounts-workflows:$accounts_release_version" + cordapp "$accounts_release_group:accounts-contracts:$accounts_release_version" } -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { - kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" - javaParameters = true // Useful for reflection. - } -} - - -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Accounts/tictacthor/workflows/src/integrationTest/kotlin/net/corda/samples/tictacthor/DriverBasedTest.kt b/Accounts/tictacthor/workflows/src/integrationTest/kotlin/net/corda/samples/tictacthor/DriverBasedTest.kt index 2de1d2be..353021dc 100644 --- a/Accounts/tictacthor/workflows/src/integrationTest/kotlin/net/corda/samples/tictacthor/DriverBasedTest.kt +++ b/Accounts/tictacthor/workflows/src/integrationTest/kotlin/net/corda/samples/tictacthor/DriverBasedTest.kt @@ -7,9 +7,9 @@ import net.corda.testing.driver.DriverDSL import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.driver +import org.junit.Assert.assertEquals import org.junit.Test import java.util.concurrent.Future -import kotlin.test.assertEquals class DriverBasedTest { private val bankA = TestIdentity(CordaX500Name("BankA", "", "GB")) diff --git a/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/CreateNewAccount.kt b/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/CreateNewAccount.kt index 581ba9fb..85ed8f4d 100644 --- a/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/CreateNewAccount.kt +++ b/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/CreateNewAccount.kt @@ -7,7 +7,6 @@ import net.corda.core.flows.FlowLogic import net.corda.core.flows.StartableByRPC import net.corda.core.utilities.getOrThrow - @StartableByRPC @StartableByService @InitiatingFlow diff --git a/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/NewKeyForAccount.kt b/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/NewKeyForAccount.kt index 64d9d156..8e4882ab 100644 --- a/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/NewKeyForAccount.kt +++ b/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/NewKeyForAccount.kt @@ -1,6 +1,5 @@ package net.corda.samples.tictacthor.accountsUtilities - import co.paralleluniverse.fibers.Suspendable import net.corda.core.flows.FlowLogic import net.corda.core.flows.StartableByRPC diff --git a/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/ShareAccount.kt b/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/ShareAccount.kt index 057b4b58..fadb9e39 100644 --- a/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/ShareAccount.kt +++ b/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/ShareAccount.kt @@ -1,6 +1,5 @@ package net.corda.samples.tictacthor.accountsUtilities - import net.corda.core.flows.* import co.paralleluniverse.fibers.Suspendable import com.r3.corda.lib.accounts.workflows.accountService @@ -8,7 +7,6 @@ import net.corda.core.flows.FlowLogic import net.corda.core.flows.StartableByRPC import net.corda.core.identity.Party - @StartableByRPC @StartableByService @InitiatingFlow @@ -21,9 +19,9 @@ class ShareAccountTo( override fun call(): String { //Create a new account - val AllmyAccounts = accountService.ourAccounts() - val SharedAccount = AllmyAccounts.single { it.state.data.name == acctNameShared }.state.data.identifier.id - accountService.shareAccountInfoWithParty(SharedAccount,shareTo) + val allMyAccounts = accountService.ourAccounts() + val sharedAccount = allMyAccounts.single { it.state.data.name == acctNameShared }.state.data.identifier.id + accountService.shareAccountInfoWithParty(sharedAccount,shareTo) return "Shared " + acctNameShared + " with " + shareTo.name.organisation } diff --git a/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/ViewMyAcconuts.kt b/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/ViewMyAcconuts.kt index 27a2669c..d047b659 100644 --- a/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/ViewMyAcconuts.kt +++ b/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/ViewMyAcconuts.kt @@ -15,8 +15,8 @@ class ViewMyAccounts() : FlowLogic>() { @Suspendable override fun call(): List { //Create a new account - val aAccountsQuery = accountService.ourAccounts().map { it.state.data.name } - return aAccountsQuery + val accountsQuery = accountService.ourAccounts().map { it.state.data.name } + return accountsQuery } } diff --git a/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/myGame.kt b/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/myGame.kt index d9385b66..a9782a04 100644 --- a/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/myGame.kt +++ b/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/accountsUtilities/myGame.kt @@ -1,6 +1,5 @@ package net.corda.samples.tictacthor.accountsUtilities - import co.paralleluniverse.fibers.Suspendable import com.r3.corda.lib.accounts.workflows.accountService import net.corda.samples.tictacthor.states.BoardState diff --git a/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/flows/StartGameFlow.kt b/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/flows/StartGameFlow.kt index eab4c75e..b12facb0 100644 --- a/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/flows/StartGameFlow.kt +++ b/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/flows/StartGameFlow.kt @@ -1,7 +1,6 @@ package net.corda.samples.tictacthor.flows import co.paralleluniverse.fibers.Suspendable -import com.r3.corda.lib.accounts.contracts.states.AccountInfo import com.r3.corda.lib.accounts.workflows.accountService import com.r3.corda.lib.accounts.workflows.flows.RequestKeyForAccount import net.corda.samples.tictacthor.accountsUtilities.NewKeyForAccount @@ -13,12 +12,10 @@ import net.corda.core.contracts.UniqueIdentifier import net.corda.core.flows.* import net.corda.core.identity.AnonymousParty import net.corda.core.identity.CordaX500Name -import net.corda.core.node.StatesToRecord import net.corda.core.node.services.vault.QueryCriteria import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.ProgressTracker -import java.util.concurrent.atomic.AtomicReference /* This flow starts a game with another node by creating an new BoardState. diff --git a/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/flows/SubmitTurnFlow.kt b/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/flows/SubmitTurnFlow.kt index 7a85691e..13567f35 100644 --- a/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/flows/SubmitTurnFlow.kt +++ b/Accounts/tictacthor/workflows/src/main/kotlin/net/corda/samples/tictacthor/flows/SubmitTurnFlow.kt @@ -16,7 +16,6 @@ import net.corda.core.node.services.vault.QueryCriteria import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.ProgressTracker -import java.util.concurrent.atomic.AtomicReference /* This flow attempts submit a turn in the game. diff --git a/Accounts/tictacthor/workflows/src/test/kotlin/net/corda/samples/tictacthor/FlowTests.kt b/Accounts/tictacthor/workflows/src/test/kotlin/net/corda/samples/tictacthor/FlowTests.kt index 44890171..0d9e849b 100644 --- a/Accounts/tictacthor/workflows/src/test/kotlin/net/corda/samples/tictacthor/FlowTests.kt +++ b/Accounts/tictacthor/workflows/src/test/kotlin/net/corda/samples/tictacthor/FlowTests.kt @@ -12,9 +12,9 @@ import net.corda.samples.tictacthor.states.BoardState import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.node.* import org.junit.After +import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test -import java.util.* import java.util.concurrent.ExecutionException import java.util.concurrent.Future @@ -40,23 +40,25 @@ class FlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test @Throws(ExecutionException::class, InterruptedException::class) - fun AccountCreation() { + fun accountCreation() { val createAcct = CreateNewAccount("TestAccountA") val future: Future = a.startFlow(createAcct) network.runNetwork() val accountService: AccountService = a.services.cordaService(KeyManagementBackedAccountService::class.java) val myAccount = accountService.accountInfo("TestAccountA") - assert(myAccount.size != 0) + assertTrue(myAccount.isNotEmpty()) } @Test @Throws(ExecutionException::class, InterruptedException::class) - fun CreateGameTest() { + fun createGameTest() { val createAcct = CreateNewAccount("TestAccountA") val future: Future = a.startFlow(createAcct) network.runNetwork() @@ -74,9 +76,9 @@ class FlowTests { network.runNetwork() val accountService: AccountService = b.services.cordaService(KeyManagementBackedAccountService::class.java) val (_, _, identifier) = accountService.accountInfo("TestAccountB")[0].state.data - val criteria = VaultQueryCriteria().withExternalIds(Arrays.asList(identifier.id)) + val criteria = VaultQueryCriteria().withExternalIds(listOf(identifier.id)) val storedGame = b.services.vaultService.queryBy(BoardState::class.java, criteria).states - assert(storedGame.size != 0) + assertTrue(storedGame.isNotEmpty()) } diff --git a/Advanced/auction-cordapp/README.md b/Advanced/auction-cordapp/README.md index 8a4b5d07..6282cb50 100644 --- a/Advanced/auction-cordapp/README.md +++ b/Advanced/auction-cordapp/README.md @@ -53,7 +53,7 @@ See https://docs.corda.net/getting-set-up.html. ## Running the nodes: Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) ``` @@ -64,7 +64,7 @@ Then type: (to run the nodes) The client can be run by executing the below command from the project root: -`./gradlew runAuctionClient` +`../gradlew runAuctionClient` Please make sure that the nodes are already running before starting the client. The client can be accessed at http://localhost:8085/ diff --git a/Advanced/auction-cordapp/build.gradle b/Advanced/auction-cordapp/build.gradle index 553ea168..46f2f2e3 100644 --- a/Advanced/auction-cordapp/build.gradle +++ b/Advanced/auction-cordapp/build.gradle @@ -1,112 +1,71 @@ -buildscript { - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } dependencies { - testCompile "junit:junit:$junit_version" - - // Corda dependencies. - cordaCompile "$corda_release_group:corda-core:$corda_release_version" - cordaCompile "$corda_release_group:corda-node-api:$corda_release_version" - cordaCompile "$corda_release_group:corda-finance-contracts:$corda_release_version" - cordaCompile "$corda_release_group:corda-finance-workflows:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp("$corda_release_group:corda-finance-contracts:$corda_release_version") - cordapp("$corda_release_group:corda-finance-workflows:$corda_release_version") - cordapp project(":workflows") - cordapp project(":contracts") - - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordapp "$corda_release_group:corda-finance-contracts:$corda_release_version" + cordapp "$corda_release_group:corda-finance-workflows:$corda_release_version" + cordapp project(':workflows') + cordapp project(':contracts') } -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = false - } - cordapp("$corda_release_group:corda-finance-contracts:$corda_release_version") - cordapp("$corda_release_group:corda-finance-workflows:$corda_release_version") + cordapp "$corda_release_group:corda-finance-contracts:$corda_release_version" + cordapp "$corda_release_group:corda-finance-workflows:$corda_release_version" cordapp project(':contracts') cordapp project(':workflows') - runSchemaMigration = true + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { name "O=Notary,L=London,C=GB" @@ -116,7 +75,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } - cordapps.clear() + rpcUsers = [] } node { name "O=PartyA,L=Paris,C=FR" @@ -125,7 +84,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] extraConfig = ['h2Settings.address' : 'localhost:20041'] } node { @@ -135,7 +93,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] extraConfig = ['h2Settings.address' : 'localhost:20042'] } node { @@ -145,15 +102,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10012") adminAddress("localhost:10052") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] extraConfig = ['h2Settings.address' : 'localhost:20043'] } } - -task installQuasar(type: Copy) { - destinationDir rootProject.file("lib") - from(configurations.quasar) { - rename 'quasar-core(.*).jar', 'quasar.jar' - } -} - diff --git a/Advanced/auction-cordapp/client/build.gradle b/Advanced/auction-cordapp/client/build.gradle index 3b3b81cf..f89913c5 100644 --- a/Advanced/auction-cordapp/client/build.gradle +++ b/Advanced/auction-cordapp/client/build.gradle @@ -1,33 +1,36 @@ -apply plugin: 'org.springframework.boot' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'org.springframework.boot' +} + dependencies { // Corda dependencies. - compile "$corda_release_group:corda-rpc:$corda_release_version" + implementation "$corda_core_group:corda-core:$corda_release_version" + implementation "$corda_release_group:corda-jackson:$corda_release_version" + implementation "$corda_release_group:corda-rpc:$corda_release_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" // CorDapp dependencies. - compile project(":contracts") - compile project(":workflows") - compile "net.corda:corda-core:$corda_release_version" - compile "net.corda:corda-jackson:$corda_release_version" - compile "net.corda:corda-rpc:$corda_release_version" - compile "net.corda:corda:$corda_release_version" - testCompile "net.corda:corda-node-driver:$corda_release_version" + implementation project(':contracts') + implementation project(':workflows') + implementation "$corda_release_group:corda-finance-workflows:$corda_release_version" - compile("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { + implementation("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { exclude group: "org.springframework.boot", module: "spring-boot-starter-logging" } - compile "org.springframework.boot:spring-boot-devtools:$spring_boot_version" + implementation "org.springframework.boot:spring-boot-devtools:$spring_boot_version" - compile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - compile "org.apache.logging.log4j:log4j-web:${log4j_version}" - compile "org.slf4j:jul-to-slf4j:$slf4j_version" + runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" + runtimeOnly "org.apache.logging.log4j:log4j-web:$log4j_version" } springBoot { mainClassName = "net.corda.samples.auction.client.Starter" } -task runAuctionClient(type: JavaExec, dependsOn: assemble) { +tasks.register('runAuctionClient', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.auction.client.Starter' -} \ No newline at end of file +} diff --git a/Advanced/auction-cordapp/config/dev/log4j2.xml b/Advanced/auction-cordapp/client/src/main/resources/log4j2.xml similarity index 100% rename from Advanced/auction-cordapp/config/dev/log4j2.xml rename to Advanced/auction-cordapp/client/src/main/resources/log4j2.xml diff --git a/Advanced/auction-cordapp/config/test/log4j2.xml b/Advanced/auction-cordapp/config/test/log4j2-test.xml similarity index 100% rename from Advanced/auction-cordapp/config/test/log4j2.xml rename to Advanced/auction-cordapp/config/test/log4j2-test.xml diff --git a/Advanced/auction-cordapp/contracts/build.gradle b/Advanced/auction-cordapp/contracts/build.gradle index f93cc55b..95b495b4 100644 --- a/Advanced/auction-cordapp/contracts/build.gradle +++ b/Advanced/auction-cordapp/contracts/build.gradle @@ -1,4 +1,7 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -13,8 +16,7 @@ cordapp { dependencies { // Corda dependencies. - cordaCompile "$corda_release_group:corda-core:$corda_release_version" - cordaCompile "$corda_release_group:corda-finance-contracts:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" -} \ No newline at end of file + cordaProvided "$corda_core_group:corda-core:$corda_release_version" + cordapp "$corda_release_group:corda-finance-contracts:$corda_release_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" +} diff --git a/Advanced/auction-cordapp/gradle.properties b/Advanced/auction-cordapp/gradle.properties index 3ae386d4..1597371f 100644 --- a/Advanced/auction-cordapp/gradle.properties +++ b/Advanced/auction-cordapp/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Auction CorDapp group=net.corda.samples version=1.0 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Advanced/auction-cordapp/gradle/wrapper/gradle-wrapper.jar b/Advanced/auction-cordapp/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Advanced/auction-cordapp/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Advanced/auction-cordapp/gradle/wrapper/gradle-wrapper.properties b/Advanced/auction-cordapp/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Advanced/auction-cordapp/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Advanced/auction-cordapp/gradlew b/Advanced/auction-cordapp/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Advanced/auction-cordapp/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Advanced/auction-cordapp/repositories.gradle b/Advanced/auction-cordapp/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Advanced/auction-cordapp/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Advanced/auction-cordapp/settings.gradle b/Advanced/auction-cordapp/settings.gradle index 7de4310f..ade9acfc 100644 --- a/Advanced/auction-cordapp/settings.gradle +++ b/Advanced/auction-cordapp/settings.gradle @@ -1,3 +1,36 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'client' \ No newline at end of file +include 'client' diff --git a/Advanced/auction-cordapp/workflows/build.gradle b/Advanced/auction-cordapp/workflows/build.gradle index d05fdbfb..172abb03 100644 --- a/Advanced/auction-cordapp/workflows/build.gradle +++ b/Advanced/auction-cordapp/workflows/build.gradle @@ -1,5 +1,8 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -13,14 +16,9 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { - srcDir rootProject.file("config/test") + srcDir rootProject.file('config/test') } } integrationTest { @@ -33,25 +31,24 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - testCompile "junit:junit:$junit_version" + testImplementation "junit:junit:$junit_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" // Corda dependencies. - cordaCompile "$corda_release_group:corda-core:$corda_release_version" - cordaCompile "$corda_release_group:corda-finance-workflows:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') + cordapp "$corda_release_group:corda-finance-workflows:$corda_release_version" } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Advanced/auction-cordapp/workflows/src/test/kotlin/net/corda/samples/auction/FlowTests.kt b/Advanced/auction-cordapp/workflows/src/test/kotlin/net/corda/samples/auction/FlowTests.kt index aa6b100c..ad1cb1be 100644 --- a/Advanced/auction-cordapp/workflows/src/test/kotlin/net/corda/samples/auction/FlowTests.kt +++ b/Advanced/auction-cordapp/workflows/src/test/kotlin/net/corda/samples/auction/FlowTests.kt @@ -38,7 +38,9 @@ class FlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test diff --git a/Advanced/build.gradle b/Advanced/build.gradle new file mode 100644 index 00000000..3b0d2b58 --- /dev/null +++ b/Advanced/build.gradle @@ -0,0 +1,8 @@ +plugins { + id 'base' +} + +wrapper { + gradleVersion = '7.4.2' + distributionType = Wrapper.DistributionType.BIN +} diff --git a/Advanced/constants.properties b/Advanced/constants.properties deleted file mode 100644 index 6425fb0b..00000000 --- a/Advanced/constants.properties +++ /dev/null @@ -1,12 +0,0 @@ -cordaReleaseGroup=net.corda -cordaCoreReleaseGroup=net.corda -cordaVersion=4.8.5 -cordaCoreVersion=4.8.5 -gradlePluginsVersion=5.0.12 -kotlinVersion=1.2.71 -junitVersion=4.12 -quasarVersion=0.7.10 -log4jVersion =2.17.1 -platformVersion=10 -slf4jVersion=1.7.25 -nettyVersion=4.1.22.Final diff --git a/Advanced/duediligence-cordapp/README.md b/Advanced/duediligence-cordapp/README.md index cdcd27e9..c4b1017e 100644 --- a/Advanced/duediligence-cordapp/README.md +++ b/Advanced/duediligence-cordapp/README.md @@ -14,11 +14,11 @@ Notes: another key feature of this app is whitlisting trusted auditors. It is do ## Pre-running the app -Deploying nodes: `./gradlew clean deployNodes` +Deploying nodes: `../gradlew clean deployNodes` Starting the nodes: `./build/nodes/runnodes` -Uploading whitelisted Auditors: `./gradlew uploadWhitelists` +Uploading whitelisted Auditors: `../gradlew uploadWhitelists` diff --git a/Advanced/duediligence-cordapp/build.gradle b/Advanced/duediligence-cordapp/build.gradle index 5476cf78..18872f2b 100644 --- a/Advanced/duediligence-cordapp/build.gradle +++ b/Advanced/duediligence-cordapp/build.gradle @@ -1,112 +1,66 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } -//Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':workflows') + cordapp project(':contracts') - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "net.corda:corda-shell:$corda_release_version" } - -//Task to deploy the nodes in order to bootstrap a network -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { - +tasks.register('deployNodes', Cordform) { /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load * the Corda network bootstrapper. */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp project(':contracts') cordapp project(':workflows') + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change //it to false for quicker project compiling time. @@ -119,6 +73,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { name "O=BankA,L=London,C=GB" @@ -127,7 +82,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=BankB,L=New York,C=US" @@ -136,7 +90,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=Trusted Auditor,L=New York,C=US" @@ -145,7 +98,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10012") adminAddress("localhost:10052") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=Regulator,L=New York,C=US" @@ -154,6 +106,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10015") adminAddress("localhost:10055") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } -} \ No newline at end of file +} diff --git a/Advanced/duediligence-cordapp/clients/build.gradle b/Advanced/duediligence-cordapp/clients/build.gradle index 7dc95b1b..3a8e7c15 100644 --- a/Advanced/duediligence-cordapp/clients/build.gradle +++ b/Advanced/duediligence-cordapp/clients/build.gradle @@ -1,4 +1,7 @@ -apply plugin: 'org.springframework.boot' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'org.springframework.boot' +} sourceSets { main { @@ -10,21 +13,21 @@ sourceSets { dependencies { // Corda dependencies. - compile "$corda_release_group:corda-rpc:$corda_release_version" + implementation "$corda_release_group:corda-rpc:$corda_release_version" // CorDapp dependencies. - compile project(":contracts") - compile project(":workflows") - compile("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { + implementation project(':contracts') + implementation project(':workflows') + implementation("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { exclude group: "org.springframework.boot", module: "spring-boot-starter-logging" } - compile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - compile "org.apache.logging.log4j:log4j-web:${log4j_version}" - compile "org.slf4j:jul-to-slf4j:$slf4j_version" + runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" + runtimeOnly "org.apache.logging.log4j:log4j-web:$log4j_version" } -task uploadWhitelists(type: JavaExec, dependsOn: assemble) { +tasks.register('uploadWhitelists', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.duediligence.client.ClientKt' args 'localhost:10006', 'localhost:10009', 'localhost:10012' -} \ No newline at end of file +} diff --git a/Advanced/duediligence-cordapp/contracts/build.gradle b/Advanced/duediligence-cordapp/contracts/build.gradle index 4dcab6cc..44c02236 100644 --- a/Advanced/duediligence-cordapp/contracts/build.gradle +++ b/Advanced/duediligence-cordapp/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "Due Diligence Contracts" vendor "Corda Open Source" @@ -12,8 +15,9 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" } diff --git a/Advanced/duediligence-cordapp/contracts/src/test/kotlin/net/corda/samples/duediligence/contracts/StateTests.kt b/Advanced/duediligence-cordapp/contracts/src/test/kotlin/net/corda/samples/duediligence/contracts/StateTests.kt index b5e5cad3..65dab68e 100644 --- a/Advanced/duediligence-cordapp/contracts/src/test/kotlin/net/corda/samples/duediligence/contracts/StateTests.kt +++ b/Advanced/duediligence-cordapp/contracts/src/test/kotlin/net/corda/samples/duediligence/contracts/StateTests.kt @@ -2,8 +2,8 @@ package net.corda.samples.duediligence.contracts import net.corda.core.identity.Party import net.corda.samples.duediligence.states.CorporateRecordsAuditRequest +import org.junit.Assert.assertEquals import org.junit.Test -import kotlin.test.assertEquals class StateTests { @Test diff --git a/Advanced/duediligence-cordapp/gradle.properties b/Advanced/duediligence-cordapp/gradle.properties index 847c1cb5..4a9acde6 100644 --- a/Advanced/duediligence-cordapp/gradle.properties +++ b/Advanced/duediligence-cordapp/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Due Diligence Cordapp group=net.corda.samples version=0.1 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Advanced/duediligence-cordapp/gradle/wrapper/gradle-wrapper.jar b/Advanced/duediligence-cordapp/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Advanced/duediligence-cordapp/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Advanced/duediligence-cordapp/gradle/wrapper/gradle-wrapper.properties b/Advanced/duediligence-cordapp/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Advanced/duediligence-cordapp/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Advanced/duediligence-cordapp/gradlew b/Advanced/duediligence-cordapp/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Advanced/duediligence-cordapp/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Advanced/duediligence-cordapp/repositories.gradle b/Advanced/duediligence-cordapp/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Advanced/duediligence-cordapp/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Advanced/duediligence-cordapp/settings.gradle b/Advanced/duediligence-cordapp/settings.gradle index 2514aca2..f303a1f7 100644 --- a/Advanced/duediligence-cordapp/settings.gradle +++ b/Advanced/duediligence-cordapp/settings.gradle @@ -1,3 +1,36 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file +include 'clients' diff --git a/Advanced/duediligence-cordapp/workflows/build.gradle b/Advanced/duediligence-cordapp/workflows/build.gradle index b9ae7b46..3e10c231 100644 --- a/Advanced/duediligence-cordapp/workflows/build.gradle +++ b/Advanced/duediligence-cordapp/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "Due Diligence Flows" vendor "Corda Open Source" @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,25 +31,25 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testRuntimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Advanced/duediligence-cordapp/workflows/src/integrationTest/kotlin/net/corda/samples/duediligence/DriverBasedTest.kt b/Advanced/duediligence-cordapp/workflows/src/integrationTest/kotlin/net/corda/samples/duediligence/DriverBasedTest.kt index 3bcba3cd..512963ae 100644 --- a/Advanced/duediligence-cordapp/workflows/src/integrationTest/kotlin/net/corda/samples/duediligence/DriverBasedTest.kt +++ b/Advanced/duediligence-cordapp/workflows/src/integrationTest/kotlin/net/corda/samples/duediligence/DriverBasedTest.kt @@ -9,7 +9,7 @@ import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.driver import org.junit.Test import java.util.concurrent.Future -import kotlin.test.assertEquals +import org.junit.Assert.assertEquals class DriverBasedTest { private val bankA = TestIdentity(CordaX500Name("BankA", "", "GB")) diff --git a/Advanced/duediligence-cordapp/workflows/src/test/kotlin/net/corda/samples/duediligence/FlowTests.kt b/Advanced/duediligence-cordapp/workflows/src/test/kotlin/net/corda/samples/duediligence/FlowTests.kt index 8a085fa6..1c90601d 100644 --- a/Advanced/duediligence-cordapp/workflows/src/test/kotlin/net/corda/samples/duediligence/FlowTests.kt +++ b/Advanced/duediligence-cordapp/workflows/src/test/kotlin/net/corda/samples/duediligence/FlowTests.kt @@ -1,8 +1,6 @@ package net.corda.samples.duediligence import net.corda.core.contracts.ContractState -import net.corda.core.contracts.StateAndRef -import net.corda.core.contracts.UniqueIdentifier import net.corda.core.contracts.UniqueIdentifier.Companion.fromString import net.corda.core.identity.CordaX500Name import net.corda.core.node.services.Vault.RelevancyStatus @@ -11,19 +9,17 @@ import net.corda.core.node.services.vault.QueryCriteria import net.corda.samples.duediligence.flows.RequestToValidateCorporateRecordsInitiator import net.corda.samples.duediligence.states.CorporateRecordsAuditRequest import net.corda.testing.node.* -import org.jgroups.util.Util import org.junit.After +import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test import java.util.* -import java.util.concurrent.Future - class FlowTests { - lateinit var network: MockNetwork - lateinit var a: StartedMockNode - lateinit var b: StartedMockNode + private lateinit var network: MockNetwork + private lateinit var a: StartedMockNode + private lateinit var b: StartedMockNode @Before fun setup() { @@ -40,7 +36,9 @@ class FlowTests { @After fun tearDown() { - + if (::network.isInitialized) { + network.stopNodes() + } } @Test @@ -58,11 +56,11 @@ class FlowTests { //Query the input //Query the input val inputCriteria: QueryCriteria.LinearStateQueryCriteria = QueryCriteria.LinearStateQueryCriteria() - .withUuid(Arrays.asList(UUID.fromString(id.toString()))) + .withUuid(listOf(UUID.fromString(id.toString()))) .withStatus(StateStatus.UNCONSUMED) .withRelevancyStatus(RelevancyStatus.RELEVANT) val (state) = a.services.vaultService.queryBy(ContractState::class.java, inputCriteria).states.get(0) val result = state.data as CorporateRecordsAuditRequest - Util.assertEquals(result.linearId, id) + assertEquals(result.linearId, id) } } \ No newline at end of file diff --git a/Advanced/gradle/wrapper/gradle-wrapper.jar b/Advanced/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..41d9927a Binary files /dev/null and b/Advanced/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Basic/flow-database-access/gradle/wrapper/gradle-wrapper.properties b/Advanced/gradle/wrapper/gradle-wrapper.properties similarity index 92% rename from Basic/flow-database-access/gradle/wrapper/gradle-wrapper.properties rename to Advanced/gradle/wrapper/gradle-wrapper.properties index 674bdda0..aa991fce 100644 --- a/Basic/flow-database-access/gradle/wrapper/gradle-wrapper.properties +++ b/Advanced/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Advanced/gradlew b/Advanced/gradlew new file mode 100755 index 00000000..1b6c7873 --- /dev/null +++ b/Advanced/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/Accounts/tictacthor/gradlew.bat b/Advanced/gradlew.bat similarity index 66% rename from Accounts/tictacthor/gradlew.bat rename to Advanced/gradlew.bat index f9553162..107acd32 100644 --- a/Accounts/tictacthor/gradlew.bat +++ b/Advanced/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/Advanced/negotiation-cordapp/README.md b/Advanced/negotiation-cordapp/README.md index 63c9a38b..cb26d0c2 100644 --- a/Advanced/negotiation-cordapp/README.md +++ b/Advanced/negotiation-cordapp/README.md @@ -36,7 +36,7 @@ For development environment setup, please refer to: [Setup Guide](https://docs.c ### Running the nodes: Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) ``` diff --git a/Advanced/negotiation-cordapp/build.gradle b/Advanced/negotiation-cordapp/build.gradle index 4f3f1b72..6145bf63 100644 --- a/Advanced/negotiation-cordapp/build.gradle +++ b/Advanced/negotiation-cordapp/build.gradle @@ -1,104 +1,70 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } -//Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + cordaBootstrapper files('simplelogger.properties') + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':workflows') + cordapp project(':contracts') - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "net.corda:corda-shell:$corda_release_version" } - -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - cordapp project(':contracts') cordapp project(':workflows') - runSchemaMigration = true + rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { name "O=Notary,L=London,C=GB" @@ -108,6 +74,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { name "O=PartyA,L=London,C=GB" @@ -116,7 +83,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=PartyB,L=New York,C=US" @@ -125,6 +91,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } -} \ No newline at end of file +} diff --git a/Advanced/negotiation-cordapp/config/dev/log4j2.xml b/Advanced/negotiation-cordapp/config/dev/log4j2.xml deleted file mode 100644 index 34ba4d45..00000000 --- a/Advanced/negotiation-cordapp/config/dev/log4j2.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - logs - node-${hostName} - ${log-path}/archive - - - - - - - - - %highlight{%level{length=1} %d{HH:mm:ss} %T %c{1}.%M - %msg%n}{INFO=white,WARN=red,FATAL=bright red blink} - > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Advanced/negotiation-cordapp/contracts/build.gradle b/Advanced/negotiation-cordapp/contracts/build.gradle index c3cf38ee..bcc08c7e 100644 --- a/Advanced/negotiation-cordapp/contracts/build.gradle +++ b/Advanced/negotiation-cordapp/contracts/build.gradle @@ -1,5 +1,7 @@ -apply plugin: 'kotlin' -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -18,31 +20,12 @@ sourceSets { } } } -dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" - - - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - -} dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_release_group:corda-core:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } - -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { - kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" - javaParameters = true // Useful for reflection. - } -} \ No newline at end of file diff --git a/Advanced/negotiation-cordapp/gradle.properties b/Advanced/negotiation-cordapp/gradle.properties index 3a66affe..1637e431 100644 --- a/Advanced/negotiation-cordapp/gradle.properties +++ b/Advanced/negotiation-cordapp/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Negotiation Cordapp -group=com.negotiation -version=0.2 -kotlin.incremental=false \ No newline at end of file +group=net.corda.samples +version=0.1 + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Advanced/negotiation-cordapp/gradle/wrapper/gradle-wrapper.jar b/Advanced/negotiation-cordapp/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7a3265ee..00000000 Binary files a/Advanced/negotiation-cordapp/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Advanced/negotiation-cordapp/gradlew b/Advanced/negotiation-cordapp/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Advanced/negotiation-cordapp/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Advanced/negotiation-cordapp/gradlew.bat b/Advanced/negotiation-cordapp/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Advanced/negotiation-cordapp/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Advanced/negotiation-cordapp/lib/README.txt b/Advanced/negotiation-cordapp/lib/README.txt deleted file mode 100644 index b0592c95..00000000 --- a/Advanced/negotiation-cordapp/lib/README.txt +++ /dev/null @@ -1,8 +0,0 @@ -The Quasar.jar in this directory is for runtime instrumentation of classes by Quasar. - -When running corda outside of the given gradle building you must add the following flag with the -correct path to your call to Java: - - java -javaagent:path-to-quasar-jar.jar ... - -See the Quasar docs for more information: http://docs.paralleluniverse.co/quasar/ \ No newline at end of file diff --git a/Advanced/negotiation-cordapp/lib/quasar.jar b/Advanced/negotiation-cordapp/lib/quasar.jar deleted file mode 100644 index 7282d8c8..00000000 Binary files a/Advanced/negotiation-cordapp/lib/quasar.jar and /dev/null differ diff --git a/Advanced/negotiation-cordapp/repositories.gradle b/Advanced/negotiation-cordapp/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Advanced/negotiation-cordapp/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Advanced/negotiation-cordapp/settings.gradle b/Advanced/negotiation-cordapp/settings.gradle index b4446eaf..c1f46514 100644 --- a/Advanced/negotiation-cordapp/settings.gradle +++ b/Advanced/negotiation-cordapp/settings.gradle @@ -1,2 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' -include 'contracts' \ No newline at end of file +include 'contracts' diff --git a/Advanced/negotiation-cordapp/src/main/resources/simplelogger.properties b/Advanced/negotiation-cordapp/simplelogger.properties similarity index 100% rename from Advanced/negotiation-cordapp/src/main/resources/simplelogger.properties rename to Advanced/negotiation-cordapp/simplelogger.properties diff --git a/Advanced/negotiation-cordapp/workflows/build.gradle b/Advanced/negotiation-cordapp/workflows/build.gradle index a1cc2ccd..32895da5 100644 --- a/Advanced/negotiation-cordapp/workflows/build.gradle +++ b/Advanced/negotiation-cordapp/workflows/build.gradle @@ -1,9 +1,8 @@ -apply plugin: 'kotlin' -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' -apply plugin: 'net.corda.plugins.cordformation' - -//jar.baseName = "negotiation-workflows" +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -25,30 +24,15 @@ sourceSets { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaCompile "$corda_release_group:corda-jackson:$corda_release_version" - cordaCompile "$corda_release_group:corda-rpc:$corda_release_version" - cordaCompile "$corda_release_group:corda-node-api:$corda_release_version" - - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" - // Needed by deployNodes task. - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" + cordaProvided "$corda_release_group:corda-jackson:$corda_release_version" + cordaProvided "$corda_release_group:corda-rpc:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { - kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" - javaParameters = true // Useful for reflection. - } -} - - diff --git a/Advanced/negotiation-cordapp/workflows/src/test/kotlin/net/corda/samples/negotiation/AcceptanceFlowTests.kt b/Advanced/negotiation-cordapp/workflows/src/test/kotlin/net/corda/samples/negotiation/AcceptanceFlowTests.kt index 8726aea7..492a5254 100644 --- a/Advanced/negotiation-cordapp/workflows/src/test/kotlin/net/corda/samples/negotiation/AcceptanceFlowTests.kt +++ b/Advanced/negotiation-cordapp/workflows/src/test/kotlin/net/corda/samples/negotiation/AcceptanceFlowTests.kt @@ -8,8 +8,8 @@ import net.corda.core.node.services.queryBy import net.corda.testing.internal.chooseIdentity import org.junit.Test import java.util.concurrent.ExecutionException -import kotlin.test.assertEquals import kotlin.test.assertFailsWith +import org.junit.Assert.assertEquals class AcceptanceFlowTests: FlowTestsBase() { @Test diff --git a/Advanced/negotiation-cordapp/workflows/src/test/kotlin/net/corda/samples/negotiation/FlowTestsBase.kt b/Advanced/negotiation-cordapp/workflows/src/test/kotlin/net/corda/samples/negotiation/FlowTestsBase.kt index b6df9d5c..7e933f2a 100644 --- a/Advanced/negotiation-cordapp/workflows/src/test/kotlin/net/corda/samples/negotiation/FlowTestsBase.kt +++ b/Advanced/negotiation-cordapp/workflows/src/test/kotlin/net/corda/samples/negotiation/FlowTestsBase.kt @@ -37,7 +37,9 @@ abstract class FlowTestsBase { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } fun nodeACreatesProposal(isBuyer: Boolean, amount: Int, counterparty: Party): UniqueIdentifier { diff --git a/Advanced/negotiation-cordapp/workflows/src/test/kotlin/net/corda/samples/negotiation/ProposalFlowTests.kt b/Advanced/negotiation-cordapp/workflows/src/test/kotlin/net/corda/samples/negotiation/ProposalFlowTests.kt index 7e811785..8f5509cc 100644 --- a/Advanced/negotiation-cordapp/workflows/src/test/kotlin/net/corda/samples/negotiation/ProposalFlowTests.kt +++ b/Advanced/negotiation-cordapp/workflows/src/test/kotlin/net/corda/samples/negotiation/ProposalFlowTests.kt @@ -3,8 +3,8 @@ package net.corda.samples.negotiation import net.corda.samples.negotiation.states.ProposalState import net.corda.core.node.services.queryBy import net.corda.testing.internal.chooseIdentity +import org.junit.Assert.assertEquals import org.junit.Test -import kotlin.test.assertEquals class ProposalFlowTests: FlowTestsBase() { diff --git a/Advanced/obligation-cordapp/README.md b/Advanced/obligation-cordapp/README.md index a3f53b66..8928db12 100644 --- a/Advanced/obligation-cordapp/README.md +++ b/Advanced/obligation-cordapp/README.md @@ -27,7 +27,7 @@ interact with it via a web browser. To run the finished application, you have tw Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) ``` @@ -37,15 +37,15 @@ Then type: (to run the nodes) ### Starting the webserver Once the nodes are up, we will start the webservers next. This app consists of three nodes and one notary, so we will be starting 3 webservers separately. First, lets start PartyA's webserver. Open a new tab of the terminal (make sure you are still in the project directory) and run: ``` -./gradlew runPartyAServer +../gradlew runPartyAServer ``` repeat the same for PartyB and PartyC, run each of the commands in a new tab: ``` -./gradlew runPartyBServer +../gradlew runPartyBServer ``` and ``` -./gradlew runPartyCServer +../gradlew runPartyCServer ``` ### Interacting with the CorDapp diff --git a/Advanced/obligation-cordapp/build.gradle b/Advanced/obligation-cordapp/build.gradle index 3a8de607..02d8de63 100644 --- a/Advanced/obligation-cordapp/build.gradle +++ b/Advanced/obligation-cordapp/build.gradle @@ -1,122 +1,73 @@ -buildscript { - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - // Can be removed post-release - used to get nightly snapshot build. - maven { url 'https://software.r3.com/artifactory/corda-lib' } - maven { url 'https://software.r3.com/artifactory/corda-lib-dev' } - maven { url 'https://jitpack.io' } - maven { url "https://repo.gradle.org/gradle/libs-releases-local" } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaCompile "$corda_release_group:corda-finance-contracts:$corda_release_version" - cordaCompile "$corda_release_group:corda-finance-workflows:$corda_release_version" - - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") - cordapp "$corda_release_group:corda-finance-contracts:$corda_release_version" + cordapp project(':workflows') + cordapp project(':contracts') + cordapp "$corda_core_group:corda-finance-contracts:$corda_release_version" cordapp "$corda_release_group:corda-finance-workflows:$corda_release_version" cordapp "$corda_release_group:corda-confidential-identities:$corda_release_version" - - - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" - - } -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp project(':contracts') cordapp project(':workflows') - cordapp("$corda_release_group:corda-finance-contracts:$corda_release_version") - cordapp("$corda_release_group:corda-finance-workflows:$corda_release_version") - cordapp("$corda_release_group:corda-confidential-identities:$corda_release_version") + cordapp "$corda_core_group:corda-finance-contracts:$corda_release_version" + cordapp "$corda_release_group:corda-finance-workflows:$corda_release_version" + cordapp "$corda_release_group:corda-confidential-identities:$corda_release_version" rpcUsers = [[ user: "user1", "password": "password", "permissions": ["ALL"]]] - runSchemaMigration = true + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { name "O=Notary,L=London,C=GB" @@ -128,6 +79,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address "0.0.0.0:10003" adminAddress "0.0.0.0:10103" } + rpcUsers = [] } node { name "O=ParticipantA,L=London,C=GB" @@ -160,11 +112,3 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { } } } - -task installQuasar(type: Copy) { - destinationDir rootProject.file("lib") - from(configurations.quasar) { - rename 'quasar-core(.*).jar', 'quasar.jar' - } -} - diff --git a/Advanced/obligation-cordapp/clients/build.gradle b/Advanced/obligation-cordapp/clients/build.gradle index f2f05db0..a2355fcb 100755 --- a/Advanced/obligation-cordapp/clients/build.gradle +++ b/Advanced/obligation-cordapp/clients/build.gradle @@ -1,18 +1,8 @@ - -repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://dl.bintray.com/kotlin/exposed' } - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda-releases' } +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'io.spring.dependency-management' } -apply plugin: 'kotlin' -apply plugin: 'io.spring.dependency-management' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - sourceSets { main { resources { @@ -29,54 +19,44 @@ dependencyManagement { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - compile "net.corda:corda-core:$corda_release_version" - compile "net.corda:corda-jackson:$corda_release_version" - compile "net.corda:corda-rpc:$corda_release_version" - compile "net.corda:corda:$corda_release_version" - testCompile "net.corda:corda-node-driver:$corda_release_version" + implementation "net.corda:corda-core:$corda_release_version" + implementation "net.corda:corda-jackson:$corda_release_version" + implementation "net.corda:corda-rpc:$corda_release_version" - compile("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { + implementation("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { exclude group: "org.springframework.boot", module: "spring-boot-starter-logging" } - compile "org.springframework.boot:spring-boot-starter-log4j2:$spring_boot_version" - compile "org.apache.logging.log4j:log4j-web:$log4j_version" - - cordapp project(":workflows") - cordapp project(":contracts") - -} - + implementation "org.springframework.boot:spring-boot-starter-log4j2:$spring_boot_version" + implementation "org.apache.logging.log4j:log4j-web:$log4j_version" -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { - kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" - javaParameters = true // Useful for reflection. - } + implementation project(':workflows') + implementation project(':contracts') + implementation "$corda_core_group:corda-finance-contracts:$corda_release_version" + implementation "$corda_release_group:corda-finance-workflows:$corda_release_version" } -task runPartyAServer(type: JavaExec, dependsOn: jar) { +tasks.register('runPartyAServer', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.obligation.server.ServerKt' args '--server.port=10009', '--config.rpc.host=localhost', '--config.rpc.port=10008', '--config.rpc.username=user1', '--config.rpc.password=password' } -task runPartyBServer(type: JavaExec, dependsOn: jar) { +tasks.register('runPartyBServer', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.obligation.server.ServerKt' args '--server.port=10012', '--config.rpc.host=localhost', '--config.rpc.port=10011', '--config.rpc.username=user1', '--config.rpc.password=password' } -task runPartyCServer(type: JavaExec, dependsOn: jar) { +tasks.register('runPartyCServer', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.obligation.server.ServerKt' args '--server.port=10015', '--config.rpc.host=localhost', '--config.rpc.port=10014', '--config.rpc.username=user1', '--config.rpc.password=password' } - - diff --git a/Advanced/obligation-cordapp/contracts/build.gradle b/Advanced/obligation-cordapp/contracts/build.gradle index 3d217f19..5de9bc5a 100644 --- a/Advanced/obligation-cordapp/contracts/build.gradle +++ b/Advanced/obligation-cordapp/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "Obligation Contracts" vendor "Corda Open Source" @@ -12,16 +15,13 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" - - cordaCompile "$corda_core_release_group:corda-finance-contracts:$corda_release_version" - cordaCompile "$corda_core_release_group:corda-finance-workflows:$corda_release_version" - cordapp "$corda_release_group:corda-finance-contracts:$corda_release_version" - cordapp "$corda_release_group:corda-finance-workflows:$corda_release_version" - cordapp("$corda_release_group:corda-confidential-identities:$corda_release_version") + cordaProvided "$corda_core_group:corda-core:$corda_release_version" -} \ No newline at end of file + cordapp "$corda_core_group:corda-finance-contracts:$corda_release_version" + cordapp "$corda_release_group:corda-confidential-identities:$corda_release_version" +} diff --git a/Advanced/obligation-cordapp/contracts/src/test/kotlin/net/corda/samples/obligation/state/IOUStateTests.kt b/Advanced/obligation-cordapp/contracts/src/test/kotlin/net/corda/samples/obligation/state/IOUStateTests.kt index cfa90a7b..6c20b855 100644 --- a/Advanced/obligation-cordapp/contracts/src/test/kotlin/net/corda/samples/obligation/state/IOUStateTests.kt +++ b/Advanced/obligation-cordapp/contracts/src/test/kotlin/net/corda/samples/obligation/state/IOUStateTests.kt @@ -8,11 +8,11 @@ import net.corda.samples.obligation.BOB import net.corda.samples.obligation.MEGACORP import net.corda.samples.obligation.MINICORP import net.corda.samples.obligation.states.IOUState +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotEquals +import org.junit.Assert.assertNotNull import org.junit.Test -import java.util.* -import kotlin.test.assertEquals -import kotlin.test.assertNotEquals -import kotlin.test.assertNotNull +import org.junit.Assert.assertTrue /** * Practical exercise instructions. @@ -118,7 +118,7 @@ class IOUStateTests { */ @Test fun isLinearState() { - assert(LinearState::class.java.isAssignableFrom(IOUState::class.java)) + assertTrue(LinearState::class.java.isAssignableFrom(IOUState::class.java)) } /** @@ -158,10 +158,10 @@ class IOUStateTests { val paidIdx = fields.indexOf(IOUState::class.java.getDeclaredField("paid")) val linearIdIdx = fields.indexOf(IOUState::class.java.getDeclaredField("linearId")) - assert(amountIdx < lenderIdx) - assert(lenderIdx < borrowerIdx) - assert(borrowerIdx < paidIdx) - assert(paidIdx < linearIdIdx) + assertTrue(amountIdx < lenderIdx) + assertTrue(lenderIdx < borrowerIdx) + assertTrue(borrowerIdx < paidIdx) + assertTrue(paidIdx < linearIdIdx) } /** diff --git a/Advanced/obligation-cordapp/gradle.properties b/Advanced/obligation-cordapp/gradle.properties index 78d0c638..2898970d 100644 --- a/Advanced/obligation-cordapp/gradle.properties +++ b/Advanced/obligation-cordapp/gradle.properties @@ -1,4 +1,27 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Obligation Cordapp group=com.obligation version=1.0 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE +spring_dependency_management_version=1.0.11.RELEASE diff --git a/Advanced/obligation-cordapp/gradle/wrapper/gradle-wrapper.jar b/Advanced/obligation-cordapp/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Advanced/obligation-cordapp/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Advanced/obligation-cordapp/gradle/wrapper/gradle-wrapper.properties b/Advanced/obligation-cordapp/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Advanced/obligation-cordapp/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Advanced/obligation-cordapp/gradlew b/Advanced/obligation-cordapp/gradlew deleted file mode 100755 index 4453ccea..00000000 --- a/Advanced/obligation-cordapp/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save ( ) { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Advanced/obligation-cordapp/gradlew.bat b/Advanced/obligation-cordapp/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Advanced/obligation-cordapp/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Advanced/obligation-cordapp/lib/README.txt b/Advanced/obligation-cordapp/lib/README.txt deleted file mode 100644 index b0592c95..00000000 --- a/Advanced/obligation-cordapp/lib/README.txt +++ /dev/null @@ -1,8 +0,0 @@ -The Quasar.jar in this directory is for runtime instrumentation of classes by Quasar. - -When running corda outside of the given gradle building you must add the following flag with the -correct path to your call to Java: - - java -javaagent:path-to-quasar-jar.jar ... - -See the Quasar docs for more information: http://docs.paralleluniverse.co/quasar/ \ No newline at end of file diff --git a/Advanced/obligation-cordapp/lib/quasar.jar b/Advanced/obligation-cordapp/lib/quasar.jar deleted file mode 100644 index 286f065e..00000000 Binary files a/Advanced/obligation-cordapp/lib/quasar.jar and /dev/null differ diff --git a/Advanced/obligation-cordapp/repositories.gradle b/Advanced/obligation-cordapp/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Advanced/obligation-cordapp/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Advanced/obligation-cordapp/runWebServers.sh b/Advanced/obligation-cordapp/runWebServers.sh index a7235465..393f2b9a 100755 --- a/Advanced/obligation-cordapp/runWebServers.sh +++ b/Advanced/obligation-cordapp/runWebServers.sh @@ -1,4 +1,4 @@ #!/bin/sh -./gradlew runPartyAServer & -./gradlew runPartyBServer & -./gradlew runPartyCServer & +../gradlew runPartyAServer & +../gradlew runPartyBServer & +../gradlew runPartyCServer & diff --git a/Advanced/obligation-cordapp/settings.gradle b/Advanced/obligation-cordapp/settings.gradle index 2514aca2..ff5fa45c 100644 --- a/Advanced/obligation-cordapp/settings.gradle +++ b/Advanced/obligation-cordapp/settings.gradle @@ -1,3 +1,37 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + id 'io.spring.dependency-management' version spring_dependency_management_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file +include 'clients' diff --git a/Advanced/obligation-cordapp/workflows/build.gradle b/Advanced/obligation-cordapp/workflows/build.gradle index 9ece5b8e..b4a0c65a 100644 --- a/Advanced/obligation-cordapp/workflows/build.gradle +++ b/Advanced/obligation-cordapp/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "Obligation Flows" vendor "Corda Open Source" @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,37 +31,29 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaCompile "$corda_core_release_group:corda-finance-contracts:$corda_release_version" - cordaCompile "$corda_core_release_group:corda-finance-workflows:$corda_release_version" - - cordaRuntime "$corda_release_group:corda:$corda_release_version" - - //finance - cordaCompile "$corda_release_group:corda-finance-contracts:$corda_release_version" - cordaCompile "$corda_release_group:corda-finance-workflows:$corda_release_version" - - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") - cordapp "$corda_release_group:corda-finance-contracts:$corda_release_version" - cordapp "$corda_release_group:corda-finance-workflows:$corda_release_version" - cordapp("$corda_release_group:corda-confidential-identities:$corda_release_version") + cordapp project(':contracts') + cordapp "$corda_release_group:corda-confidential-identities:$corda_release_version" + // Finance CorDapps + cordapp "$corda_core_group:corda-finance-contracts:$corda_release_version" + cordapp "$corda_release_group:corda-finance-workflows:$corda_release_version" } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Advanced/obligation-cordapp/workflows/src/test/kotlin/net/corda/samples/obligation/flow/IOUIssueFlowTests.kt b/Advanced/obligation-cordapp/workflows/src/test/kotlin/net/corda/samples/obligation/flow/IOUIssueFlowTests.kt index a856d5b3..e8b4afd0 100644 --- a/Advanced/obligation-cordapp/workflows/src/test/kotlin/net/corda/samples/obligation/flow/IOUIssueFlowTests.kt +++ b/Advanced/obligation-cordapp/workflows/src/test/kotlin/net/corda/samples/obligation/flow/IOUIssueFlowTests.kt @@ -1,6 +1,5 @@ package net.corda.samples.obligation.flow -import groovy.util.GroovyTestCase.assertEquals import net.corda.samples.obligation.flows.IOUIssueFlowResponder import net.corda.core.contracts.Command import net.corda.core.contracts.TransactionVerificationException @@ -14,7 +13,11 @@ import net.corda.testing.node.* import net.corda.samples.obligation.contract.IOUContract import net.corda.samples.obligation.flows.IOUIssueFlow import net.corda.samples.obligation.states.IOUState -import org.junit.* +import org.junit.After +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Before +import org.junit.Test import kotlin.test.assertFailsWith /** @@ -26,9 +29,9 @@ import kotlin.test.assertFailsWith * On some machines/configurations you may have to use the "JAR manifest" option for shortening the command line. */ class IOUIssueFlowTests { - lateinit var mockNetwork: MockNetwork - lateinit var a: StartedMockNode - lateinit var b: StartedMockNode + private lateinit var mockNetwork: MockNetwork + private lateinit var a: StartedMockNode + private lateinit var b: StartedMockNode @Before fun setup() { @@ -46,7 +49,9 @@ class IOUIssueFlowTests { @After fun tearDown() { - mockNetwork.stopNodes() + if (::mockNetwork.isInitialized) { + mockNetwork.stopNodes() + } } /** @@ -80,11 +85,11 @@ class IOUIssueFlowTests { println(ptx.tx) // Check the transaction is well formed... // No outputs, one input IOUState and a command with the right properties. - assert(ptx.tx.inputs.isEmpty()) - assert(ptx.tx.outputs.single().data is IOUState) + assertTrue(ptx.tx.inputs.isEmpty()) + assertTrue(ptx.tx.outputs.single().data is IOUState) val command = ptx.tx.commands.single() - assert(command.value is IOUContract.Commands.Issue) - assert(command.signers.toSet() == iou.participants.map { it.owningKey }.toSet()) + assertTrue(command.value is IOUContract.Commands.Issue) + assertEquals(iou.participants.mapTo(HashSet()) { it.owningKey }, command.signers.toSet()) ptx.verifySignaturesExcept( borrower.owningKey, mockNetwork.defaultNotaryNode.info.legalIdentitiesAndCerts.first().owningKey diff --git a/Advanced/obligation-cordapp/workflows/src/test/kotlin/net/corda/samples/obligation/flow/IOUSettleFlowTests.kt b/Advanced/obligation-cordapp/workflows/src/test/kotlin/net/corda/samples/obligation/flow/IOUSettleFlowTests.kt index f9034509..84378548 100644 --- a/Advanced/obligation-cordapp/workflows/src/test/kotlin/net/corda/samples/obligation/flow/IOUSettleFlowTests.kt +++ b/Advanced/obligation-cordapp/workflows/src/test/kotlin/net/corda/samples/obligation/flow/IOUSettleFlowTests.kt @@ -18,20 +18,23 @@ import net.corda.testing.node.MockNodeParameters import net.corda.testing.node.StartedMockNode import net.corda.samples.obligation.contract.IOUContract import net.corda.samples.obligation.flows.* -import org.junit.* -import java.util.* -import kotlin.test.assertEquals import kotlin.test.assertFailsWith +import org.junit.After +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Before +import org.junit.Test +import java.util.Currency /** * Practical exercise instructions Flows part 3. * Uncomment the unit tests and use the hints + unit test body to complete the FLows such that the unit tests pass. */ class IOUSettleFlowTests { - lateinit var mockNetwork: MockNetwork - lateinit var a: StartedMockNode - lateinit var b: StartedMockNode - lateinit var c: StartedMockNode + private lateinit var mockNetwork: MockNetwork + private lateinit var a: StartedMockNode + private lateinit var b: StartedMockNode + private lateinit var c: StartedMockNode @Before fun setup() { @@ -49,7 +52,9 @@ class IOUSettleFlowTests { @After fun tearDown() { - mockNetwork.stopNodes() + if (::mockNetwork.isInitialized) { + mockNetwork.stopNodes() + } } /** @@ -100,8 +105,8 @@ class IOUSettleFlowTests { // One output IOUState, one input IOUState reference, input and output cash a.transaction { val ledgerTx = settleResult.toLedgerTransaction(a.services, false) - assert(ledgerTx.inputs.size == 2) - assert(ledgerTx.outputs.size == 2) + assertTrue(ledgerTx.inputs.size == 2) + assertTrue(ledgerTx.outputs.size == 2) val outputIou = ledgerTx.outputs.map { it.data }.filterIsInstance().single() assertEquals( outputIou, @@ -119,7 +124,7 @@ class IOUSettleFlowTests { outputCashSum, (inputIou.amount - inputIou.paid - outputIou.paid)) val command = ledgerTx.commands.requireSingleCommand() - assert(command.value == IOUContract.Commands.Settle()) + assertEquals(IOUContract.Commands.Settle(), command.value) // Check the transaction has been signed by the borrower. settleResult.verifySignaturesExcept(b.info.chooseIdentityAndCert().party.owningKey, mockNetwork.defaultNotaryNode.info.legalIdentitiesAndCerts.first().owningKey) diff --git a/Advanced/obligation-cordapp/workflows/src/test/kotlin/net/corda/samples/obligation/flow/IOUTransferFlowTests.kt b/Advanced/obligation-cordapp/workflows/src/test/kotlin/net/corda/samples/obligation/flow/IOUTransferFlowTests.kt index 89fa11b8..841e71f9 100644 --- a/Advanced/obligation-cordapp/workflows/src/test/kotlin/net/corda/samples/obligation/flow/IOUTransferFlowTests.kt +++ b/Advanced/obligation-cordapp/workflows/src/test/kotlin/net/corda/samples/obligation/flow/IOUTransferFlowTests.kt @@ -18,6 +18,7 @@ import net.corda.testing.node.StartedMockNode import net.corda.samples.obligation.contract.IOUContract import net.corda.samples.obligation.flows.IOUTransferFlow import org.junit.After +import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test import kotlin.test.assertFailsWith @@ -27,10 +28,10 @@ import kotlin.test.assertFailsWith * Uncomment the unit tests and use the hints + unit test body to complete the Flows such that the unit tests pass. */ class IOUTransferFlowTests { - lateinit var mockNetwork: MockNetwork - lateinit var a: StartedMockNode - lateinit var b: StartedMockNode - lateinit var c: StartedMockNode + private lateinit var mockNetwork: MockNetwork + private lateinit var a: StartedMockNode + private lateinit var b: StartedMockNode + private lateinit var c: StartedMockNode @Before fun setup() { @@ -48,7 +49,9 @@ class IOUTransferFlowTests { @After fun tearDown() { - mockNetwork.stopNodes() + if (::mockNetwork.isInitialized) { + mockNetwork.stopNodes() + } } /** @@ -91,14 +94,14 @@ class IOUTransferFlowTests { val ptx = future.getOrThrow() // Check the transaction is well formed... // One output IOUState, one input state reference and a Transfer command with the right properties. - assert(ptx.tx.inputs.size == 1) - assert(ptx.tx.outputs.size == 1) - assert(ptx.tx.inputs.single() == StateRef(stx.id, 0)) + assertEquals(1, ptx.tx.inputs.size) + assertEquals(1, ptx.tx.outputs.size) + assertEquals(StateRef(stx.id, 0), ptx.tx.inputs.single()) println("Input state ref: ${ptx.tx.inputs.single()} == ${StateRef(stx.id, 0)}") val outputIou = ptx.tx.outputs.single().data as IOUState println("Output state: $outputIou") val command = ptx.tx.commands.single() - assert(command.value == IOUContract.Commands.Transfer()) + assertEquals(IOUContract.Commands.Transfer(), command.value) ptx.verifySignaturesExcept(b.info.chooseIdentityAndCert().party.owningKey, c.info.chooseIdentityAndCert().party.owningKey, mockNetwork.defaultNotaryNode.info.legalIdentitiesAndCerts.first().owningKey) } diff --git a/Advanced/secretsanta-cordapp/README.md b/Advanced/secretsanta-cordapp/README.md index 8f823c8c..bb653997 100644 --- a/Advanced/secretsanta-cordapp/README.md +++ b/Advanced/secretsanta-cordapp/README.md @@ -30,7 +30,7 @@ If you've never built a cordapp before you may need to configure gradle and java To run the corda nodes you just need to run the `deployNodes` gradle task and the nodes will be available for you to run directly. ``` -./gradlew deployNodes +../gradlew deployNodes ./build/nodes/runnodes ``` @@ -40,7 +40,7 @@ Run the `runSantaServer` Gradle task. By default, it connects to the node with R the username `user1` and the password `test`, and serves the webserver on port `localhost:10056`. ``` -./gradlew runSantaServer +../gradlew runSantaServer ``` The frontend will be visible on [localhost:10056](http://localhost:10056) diff --git a/Advanced/secretsanta-cordapp/build.gradle b/Advanced/secretsanta-cordapp/build.gradle index 2a9a1b5c..132c713e 100644 --- a/Advanced/secretsanta-cordapp/build.gradle +++ b/Advanced/secretsanta-cordapp/build.gradle @@ -1,111 +1,64 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } -//Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") - - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordapp project(':workflows') + cordapp project(':contracts') } -//Task to deploy the nodes in order to bootstrap a network -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { - +tasks.register('deployNodes', Cordform) { /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load * the Corda network bootstrapper. */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp project(':contracts') cordapp project(':workflows') + rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change //it to false for quicker project compiling time. @@ -118,6 +71,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { name "O=Santa,L=London,C=GB" @@ -126,9 +80,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10016") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } - node { name "O=Elf,L=London,C=GB" p2pPort 10007 @@ -136,8 +88,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10017") adminAddress("localhost:10027") } - - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } - } diff --git a/Advanced/secretsanta-cordapp/clients/build.gradle b/Advanced/secretsanta-cordapp/clients/build.gradle index 7ef0bb28..76a43df6 100644 --- a/Advanced/secretsanta-cordapp/clients/build.gradle +++ b/Advanced/secretsanta-cordapp/clients/build.gradle @@ -1,11 +1,6 @@ -apply plugin: 'org.springframework.boot' - -buildscript { - repositories { - maven { - url = uri("https://plugins.gradle.org/m2/") - } - } +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'org.springframework.boot' } sourceSets { @@ -20,21 +15,19 @@ dependencies { implementation 'com.google.code.gson:gson:2.8.5' // Corda dependencies. - compile "$corda_release_group:corda-rpc:$corda_release_version" + implementation "$corda_release_group:corda-rpc:$corda_release_version" // CorDapp dependencies. - compile project(":contracts") - compile project(":workflows") - compile("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { + implementation project(':contracts') + implementation project(':workflows') + implementation("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { exclude group: "org.springframework.boot", module: "spring-boot-starter-logging" } - compile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - compile "org.apache.logging.log4j:log4j-web:${log4j_version}" - compile "org.slf4j:jul-to-slf4j:$slf4j_version" + runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" + runtimeOnly "org.apache.logging.log4j:log4j-web:${log4j_version}" // SendGrid implementation 'com.sendgrid:sendgrid-java:4.7.0' - compile 'com.sendgrid:sendgrid-java:4.7.0' } @@ -46,7 +39,8 @@ springBoot { * execute your rpc methods in the main method of the client.kt. You can somewhat see this as a quick test of making * RPC calls to your nodes. */ -task runSantaClient(type: JavaExec, dependsOn: assemble) { +tasks.register('runSantaClient', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.secretsanta.ClientKt' args 'localhost:10016', 'user1', 'test' @@ -55,7 +49,8 @@ task runSantaClient(type: JavaExec, dependsOn: assemble) { /* This task will start the springboot server that connects to your node (via RPC connection). All of the http requests * are in the Controller file. You can leave the Server.kt and NodeRPCConnection.kt file untouched for your use. */ -task runSantaServer(type: JavaExec, dependsOn: assemble) { +tasks.register('runSantaServer', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.secretsanta.webserver.ServerKt' args '--server.port=10056', '--config.rpc.host=localhost', '--config.rpc.port=10016', '--config.rpc.username=user1', '--config.rpc.password=test' diff --git a/Advanced/secretsanta-cordapp/contracts/build.gradle b/Advanced/secretsanta-cordapp/contracts/build.gradle index bbc5b798..74a6b53f 100644 --- a/Advanced/secretsanta-cordapp/contracts/build.gradle +++ b/Advanced/secretsanta-cordapp/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "Secret Santa Contracts" vendor "Corda Open Source" @@ -12,8 +15,9 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Advanced/secretsanta-cordapp/contracts/src/test/kotlin/net/corda/samples/secretsanta/contracts/SantaSessionContractTests.kt b/Advanced/secretsanta-cordapp/contracts/src/test/kotlin/net/corda/samples/secretsanta/contracts/SantaSessionContractTests.kt index 9fa36ed5..9fadf041 100644 --- a/Advanced/secretsanta-cordapp/contracts/src/test/kotlin/net/corda/samples/secretsanta/contracts/SantaSessionContractTests.kt +++ b/Advanced/secretsanta-cordapp/contracts/src/test/kotlin/net/corda/samples/secretsanta/contracts/SantaSessionContractTests.kt @@ -1,6 +1,5 @@ package net.corda.samples.secretsanta.contracts -import junit.framework.TestCase import net.corda.core.contracts.CommandData import net.corda.core.contracts.Contract import net.corda.core.contracts.TypeOnlyCommandData @@ -8,10 +7,10 @@ import net.corda.core.identity.CordaX500Name import net.corda.samples.secretsanta.states.SantaSessionState import net.corda.testing.contracts.DummyState import net.corda.testing.core.TestIdentity -import net.corda.testing.dsl.TransactionDSL -import net.corda.testing.dsl.TransactionDSLInterpreter import net.corda.testing.node.MockServices import net.corda.testing.node.ledger +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test import java.util.* @@ -46,15 +45,15 @@ class SantaSessionContractTests { @Test fun SantaSessionContractImplementsContract() { - assert(SantaSessionContract() is Contract) + assertTrue(SantaSessionContract() is Contract) } @Test fun constructorTest() { val st = SantaSessionState(playerNames, playerEmails, santa.party, elf.party) - TestCase.assertEquals(santa.party, st.issuer) - TestCase.assertEquals(playerNames, st.playerNames) - TestCase.assertEquals(playerEmails, st.playerEmails) + assertEquals(santa.party, st.issuer) + assertEquals(playerNames, st.playerNames) + assertEquals(playerEmails, st.playerEmails) } // TODO @@ -68,14 +67,14 @@ class SantaSessionContractTests { // Has an input, will fail. input(SantaSessionContract.ID, t1) output(SantaSessionContract.ID, t2) - command(Arrays.asList(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) + command(listOf(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) this.fails() } transaction { // Has no input, will verify. output(SantaSessionContract.ID, st) - command(Arrays.asList(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) + command(listOf(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) this.verifies() } } @@ -88,14 +87,14 @@ class SantaSessionContractTests { // Has two outputs, will fail. output(SantaSessionContract.ID, st) output(SantaSessionContract.ID, st) - command(Arrays.asList(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) + command(listOf(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) this.fails() } transaction { // Has one output, will verify. output(SantaSessionContract.ID, st) - command(Arrays.asList(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) + command(listOf(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) this.verifies() } } @@ -107,8 +106,8 @@ class SantaSessionContractTests { transaction { output(SantaSessionContract.ID, st) // Has two commands, will fail. - command(Arrays.asList(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) - command(Arrays.asList(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) + command(listOf(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) + command(listOf(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) this.fails() } transaction { @@ -127,13 +126,13 @@ class SantaSessionContractTests { transaction{ // Has wrong output type, will fail. output(SantaSessionContract.ID, DummyState()) - command(Arrays.asList(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) + command(listOf(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) this.fails() } transaction { // Has correct output type, will verify. output(SantaSessionContract.ID, st) - command(Arrays.asList(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) + command(listOf(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) this.verifies() } @@ -146,14 +145,14 @@ class SantaSessionContractTests { transaction { // Has wrong command type, will fail. output(SantaSessionContract.ID, st) - command(Arrays.asList(santa.publicKey), Commands.DummyCommand()) + command(listOf(santa.publicKey), Commands.DummyCommand()) this.fails() } transaction { // Has correct command type, will verify. output(SantaSessionContract.ID, st) - command(Arrays.asList(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) + command(listOf(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) this.verifies() } @@ -169,13 +168,13 @@ class SantaSessionContractTests { transaction { // Has three players SantaSessionState, will verify. output(SantaSessionContract.ID, threePlayerSantaState) - command(Arrays.asList(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) + command(listOf(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) this.verifies() } transaction { // Has over three players SantaSessionState, will verify. output(SantaSessionContract.ID, st) - command(Arrays.asList(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) + command(listOf(santa.publicKey, elf.publicKey), SantaSessionContract.Commands.Issue()) this.verifies() } diff --git a/Advanced/secretsanta-cordapp/contracts/src/test/kotlin/net/corda/samples/secretsanta/contracts/SantaSessionStateTests.kt b/Advanced/secretsanta-cordapp/contracts/src/test/kotlin/net/corda/samples/secretsanta/contracts/SantaSessionStateTests.kt index 539efecd..506a902a 100644 --- a/Advanced/secretsanta-cordapp/contracts/src/test/kotlin/net/corda/samples/secretsanta/contracts/SantaSessionStateTests.kt +++ b/Advanced/secretsanta-cordapp/contracts/src/test/kotlin/net/corda/samples/secretsanta/contracts/SantaSessionStateTests.kt @@ -1,23 +1,24 @@ package net.corda.samples.secretsanta.contracts -import junit.framework.TestCase import net.corda.core.contracts.ContractState import net.corda.core.contracts.LinearState import net.corda.core.identity.CordaX500Name import net.corda.samples.secretsanta.states.SantaSessionState import net.corda.testing.core.TestIdentity import org.junit.After +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotEquals +import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test -import org.junit.jupiter.api.Assertions import java.util.* - class SantaSessionStateTests { private val playerNames: MutableList = ArrayList() private val playerEmails: MutableList = ArrayList() private val santa = TestIdentity(CordaX500Name("Santa", "", "GB")).party private val elf = TestIdentity(CordaX500Name("Elf", "", "GB")).party + @Before fun setup() { playerNames.add("david") @@ -41,32 +42,32 @@ class SantaSessionStateTests { // unmatching names @Test(expected = IllegalArgumentException::class) fun unmatchingNameTest() { - val badNames = ArrayList(Arrays.asList("alice", "bob", "charlie", "olivia", "peter")) - val goodEmails = ArrayList(Arrays.asList("david@corda.net", "alice@corda.net", "bob@corda.net", "charlie@corda.net", "olivia@corda.net", "peter@corda.net")) + val badNames = listOf("alice", "bob", "charlie", "olivia", "peter") + val goodEmails = listOf("david@corda.net", "alice@corda.net", "bob@corda.net", "charlie@corda.net", "olivia@corda.net", "peter@corda.net") val st = SantaSessionState(badNames, goodEmails, santa, elf) } // few name test @Test(expected = IllegalArgumentException::class) fun fewNameTest() { // here there are too few names - val badNames = ArrayList(Arrays.asList("peter")) - val goodEmails = ArrayList(Arrays.asList("david@corda.net", "alice@corda.net", "bob@corda.net", "charlie@corda.net", "olivia@corda.net", "peter@corda.net")) + val badNames = listOf("peter") + val goodEmails = listOf("david@corda.net", "alice@corda.net", "bob@corda.net", "charlie@corda.net", "olivia@corda.net", "peter@corda.net") val st = SantaSessionState(badNames, goodEmails, santa, elf) } // unmatching emails @Test(expected = IllegalArgumentException::class) fun unmatchingEmailTest() { // note there's no matching email for david, david@corda.net - val goodNames = ArrayList(Arrays.asList("david", "alice", "bob", "charlie", "olivia", "peter")) - val badEmails = ArrayList(Arrays.asList("alice@corda.net", "bob@corda.net", "charlie@corda.net", "olivia@corda.net", "peter@corda.net")) + val goodNames = listOf("david", "alice", "bob", "charlie", "olivia", "peter") + val badEmails = listOf("alice@corda.net", "bob@corda.net", "charlie@corda.net", "olivia@corda.net", "peter@corda.net") val st = SantaSessionState(goodNames, badEmails, santa, elf) } // too few emails @Test(expected = IllegalArgumentException::class) fun fewEmailTest() { - val goodNames = ArrayList(Arrays.asList("david", "alice", "bob", "charlie", "olivia", "peter")) - val badEmails = ArrayList(Arrays.asList("peter@corda.net")) + val goodNames = listOf("david", "alice", "bob", "charlie", "olivia", "peter") + val badEmails = listOf("peter@corda.net") val st = SantaSessionState(goodNames, badEmails, santa, elf) } @@ -101,29 +102,29 @@ class SantaSessionStateTests { @Test fun stateGetters() { val st = SantaSessionState(playerNames, playerEmails, santa, elf) - TestCase.assertEquals(santa, st.issuer) - TestCase.assertEquals(playerNames, st.playerNames) - TestCase.assertEquals(playerEmails, st.playerEmails) - Assertions.assertTrue(st.playerNames.contains("olivia")) - Assertions.assertTrue(st.playerNames.contains("peter")) - Assertions.assertTrue(st.playerEmails.contains("olivia@corda.net")) - Assertions.assertTrue(st.playerEmails.contains("peter@corda.net")) - Assertions.assertNotEquals(st.getAssignments()!!["david"], st.getAssignments()!!["peter"]) + assertEquals(santa, st.issuer) + assertEquals(playerNames, st.playerNames) + assertEquals(playerEmails, st.playerEmails) + assertTrue(st.playerNames.contains("olivia")) + assertTrue(st.playerNames.contains("peter")) + assertTrue(st.playerEmails.contains("olivia@corda.net")) + assertTrue(st.playerEmails.contains("peter@corda.net")) + assertNotEquals(st.getAssignments()!!["david"], st.getAssignments()!!["peter"]) } @Test fun stateImplementsContractState() { val st = SantaSessionState(playerNames, playerEmails, santa, elf) - Assertions.assertTrue(st is ContractState) - Assertions.assertTrue(st is LinearState) + assertTrue(st is ContractState) + assertTrue(st is LinearState) } @Test fun stateHasOneParticipant() { val st = SantaSessionState(playerNames, playerEmails, santa, elf) - TestCase.assertEquals(2, st.participants.size) - Assertions.assertTrue(st.participants.contains(santa)) - Assertions.assertTrue(st.participants.contains(elf)) + assertEquals(2, st.participants.size) + assertTrue(st.participants.contains(santa)) + assertTrue(st.participants.contains(elf)) } @Test @@ -131,16 +132,16 @@ class SantaSessionStateTests { val st = SantaSessionState(playerNames, playerEmails, santa, elf) val assignments: HashMap? = st.getAssignments() // correct number of assignments - TestCase.assertEquals(playerNames.size, assignments!!.size) + assertEquals(playerNames.size, assignments!!.size) // iterate through assignments for validity for (santa_candidate in playerNames) { // ensure all these players actually exist - Assertions.assertTrue(playerNames.contains(santa_candidate)) + assertTrue(playerNames.contains(santa_candidate)) for (target_candidate in playerNames) { // skip duplicates in iteration if (santa_candidate == target_candidate) { continue } // ensure no one is assigned themselves - Assertions.assertNotEquals(santa_candidate, assignments[santa_candidate]) + assertNotEquals(santa_candidate, assignments[santa_candidate]) } } } diff --git a/Advanced/secretsanta-cordapp/gradle.properties b/Advanced/secretsanta-cordapp/gradle.properties index 2bc8427a..c66841a6 100644 --- a/Advanced/secretsanta-cordapp/gradle.properties +++ b/Advanced/secretsanta-cordapp/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Secret Santa group=com.secretsanta version=0.1 -kotlin.incremental=false + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Advanced/secretsanta-cordapp/gradle/wrapper/gradle-wrapper.jar b/Advanced/secretsanta-cordapp/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Advanced/secretsanta-cordapp/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Advanced/secretsanta-cordapp/gradle/wrapper/gradle-wrapper.properties b/Advanced/secretsanta-cordapp/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Advanced/secretsanta-cordapp/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Advanced/secretsanta-cordapp/gradlew b/Advanced/secretsanta-cordapp/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Advanced/secretsanta-cordapp/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Advanced/secretsanta-cordapp/gradlew.bat b/Advanced/secretsanta-cordapp/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Advanced/secretsanta-cordapp/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Advanced/secretsanta-cordapp/repositories.gradle b/Advanced/secretsanta-cordapp/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Advanced/secretsanta-cordapp/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Advanced/secretsanta-cordapp/settings.gradle b/Advanced/secretsanta-cordapp/settings.gradle index 2514aca2..ade9acfc 100644 --- a/Advanced/secretsanta-cordapp/settings.gradle +++ b/Advanced/secretsanta-cordapp/settings.gradle @@ -1,3 +1,36 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file +include 'client' diff --git a/Advanced/secretsanta-cordapp/workflows/build.gradle b/Advanced/secretsanta-cordapp/workflows/build.gradle index bcf7cf38..bcbf0e21 100644 --- a/Advanced/secretsanta-cordapp/workflows/build.gradle +++ b/Advanced/secretsanta-cordapp/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "Secret Santa Flows" vendor "Corda Open Source" @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,25 +31,24 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath } diff --git a/Advanced/secretsanta-cordapp/workflows/src/main/kotlin/net/corda/samples/secretsanta/flows/CreateSantaSessionFlow.kt b/Advanced/secretsanta-cordapp/workflows/src/main/kotlin/net/corda/samples/secretsanta/flows/CreateSantaSessionFlow.kt index cf14a92a..87ac4de7 100644 --- a/Advanced/secretsanta-cordapp/workflows/src/main/kotlin/net/corda/samples/secretsanta/flows/CreateSantaSessionFlow.kt +++ b/Advanced/secretsanta-cordapp/workflows/src/main/kotlin/net/corda/samples/secretsanta/flows/CreateSantaSessionFlow.kt @@ -1,7 +1,6 @@ package net.corda.samples.secretsanta.flows import co.paralleluniverse.fibers.Suspendable -import com.sun.istack.Nullable import net.corda.core.contracts.CommandData import net.corda.core.flows.* import net.corda.core.identity.CordaX500Name @@ -11,6 +10,7 @@ import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.ProgressTracker import net.corda.samples.secretsanta.contracts.SantaSessionContract import net.corda.samples.secretsanta.states.SantaSessionState +import org.jetbrains.annotations.Nullable /** diff --git a/Advanced/secretsanta-cordapp/workflows/src/test/kotlin/net/corda/samples/secretsanta/CheckAssignedSantaFlowTests.kt b/Advanced/secretsanta-cordapp/workflows/src/test/kotlin/net/corda/samples/secretsanta/CheckAssignedSantaFlowTests.kt index 0b78ff0c..5b75ae77 100644 --- a/Advanced/secretsanta-cordapp/workflows/src/test/kotlin/net/corda/samples/secretsanta/CheckAssignedSantaFlowTests.kt +++ b/Advanced/secretsanta-cordapp/workflows/src/test/kotlin/net/corda/samples/secretsanta/CheckAssignedSantaFlowTests.kt @@ -1,15 +1,16 @@ package net.corda.samples.secretsanta import net.corda.core.contracts.UniqueIdentifier.Companion.fromString -import net.corda.core.crypto.SecureHash import net.corda.core.identity.CordaX500Name import net.corda.core.node.NetworkParameters import net.corda.samples.secretsanta.flows.CheckAssignedSantaFlow import net.corda.samples.secretsanta.flows.CreateSantaSessionFlow import net.corda.samples.secretsanta.states.SantaSessionState import net.corda.testing.node.* -import org.jgroups.util.Util import org.junit.After +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test import org.junit.jupiter.api.Assertions @@ -19,13 +20,13 @@ import java.util.concurrent.ExecutionException class CheckAssignedSantaFlowTests { - lateinit var network: MockNetwork - lateinit var santa: StartedMockNode - lateinit var elf: StartedMockNode + private lateinit var network: MockNetwork + private lateinit var santa: StartedMockNode + private lateinit var elf: StartedMockNode - private val testNetworkParameters = NetworkParameters(4, Arrays.asList(), 10485760, 10485760 * 5, Instant.now(), 1, java.util.LinkedHashMap>()) - private val playerNames = ArrayList(Arrays.asList("david", "alice", "bob", "charlie", "olivia", "peter")) - private val playerEmails = ArrayList(Arrays.asList("david@corda.net", "alice@corda.net", "bob@corda.net", "charlie@corda.net", "olivia@corda.net", "peter@corda.net")) + private val testNetworkParameters = NetworkParameters(4, emptyList(), 10485760, 10485760 * 5, Instant.now(), 1, LinkedHashMap()) + private val playerNames = listOf("david", "alice", "bob", "charlie", "olivia", "peter") + private val playerEmails = listOf("david@corda.net", "alice@corda.net", "bob@corda.net", "charlie@corda.net", "olivia@corda.net", "peter@corda.net") @Before @@ -46,14 +47,16 @@ class CheckAssignedSantaFlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test(expected = IllegalArgumentException::class) @Throws(Exception::class) fun checkingBadSessionID() { val f1 = CheckAssignedSantaFlow(fromString("badUID")) - val future1 = santa.startFlow(f1) + val future1 = santa.startFlow(f1) network.runNetwork() val f1Output = future1.get() } @@ -62,8 +65,8 @@ class CheckAssignedSantaFlowTests { @Throws(Exception::class) fun checkingMissingSessionID() { val f1 = CheckAssignedSantaFlow(fromString("8237fd23-3dab-4a9b-b2ea-671006a660b5")) - val future1 = santa!!.startFlow(f1) - network!!.runNetwork() + val future1 = santa.startFlow(f1) + network.runNetwork() val f1Output = future1.get() } @@ -71,97 +74,97 @@ class CheckAssignedSantaFlowTests { @Test @Throws(Exception::class) fun flowProducesCorrectState() { - val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf!!.info.legalIdentities[0]) - val future = santa!!.startFlow(f1) - network!!.runNetwork() + val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf.info.legalIdentities[0]) + val future = santa.startFlow(f1) + network.runNetwork() val f1Output = future.get().tx.outputsOfType(SantaSessionState::class.java)[0] val f2 = CheckAssignedSantaFlow(f1Output.linearId) - val future2 = santa!!.startFlow(f2) - network!!.runNetwork() + val future2 = santa.startFlow(f2) + network.runNetwork() val f2Output = future2.get() - Util.assertEquals(playerNames, f1Output.playerNames) - Util.assertEquals(playerNames, f2Output.playerNames) + assertEquals(playerNames, f1Output.playerNames) + assertEquals(playerNames, f2Output.playerNames) // ensure these states are really the same - Util.assertEquals(f1Output.playerNames, f2Output.playerNames) - Util.assertEquals(f1Output.playerEmails, f2Output.playerEmails) - Util.assertEquals(f1Output.getAssignments(), f2Output.getAssignments()) - assert(f1Output.playerNames.contains("david")) - assert(f1Output.playerNames.contains("olivia")) - assert(!f1Output.playerNames.contains("derek")) - assert(f2Output.playerNames.contains("david")) - assert(f2Output.playerNames.contains("olivia")) - assert(!f2Output.playerNames.contains("derek")) - Util.assertEquals(f1Output.getAssignments()!!["david"], f2Output.getAssignments()!!["david"]) - Util.assertEquals(f1Output.getAssignments()!!["peter"], f2Output.getAssignments()!!["peter"]) + assertEquals(f1Output.playerNames, f2Output.playerNames) + assertEquals(f1Output.playerEmails, f2Output.playerEmails) + assertEquals(f1Output.getAssignments(), f2Output.getAssignments()) + assertTrue(f1Output.playerNames.contains("david")) + assertTrue(f1Output.playerNames.contains("olivia")) + assertFalse(f1Output.playerNames.contains("derek")) + assertTrue(f2Output.playerNames.contains("david")) + assertTrue(f2Output.playerNames.contains("olivia")) + assertFalse(f2Output.playerNames.contains("derek")) + assertEquals(f1Output.getAssignments()!!["david"], f2Output.getAssignments()!!["david"]) + assertEquals(f1Output.getAssignments()!!["peter"], f2Output.getAssignments()!!["peter"]) Assertions.assertNotEquals(f1Output.getAssignments()!!["peter"], f2Output.getAssignments()!!["david"]) - Util.assertEquals(f1Output.linearId, f2Output.linearId) + assertEquals(f1Output.linearId, f2Output.linearId) } @Test @Throws(Exception::class) fun bothNodesRetrieveTheSameState() { - val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf!!.info.legalIdentities[0]) - val future = santa!!.startFlow(f1) - network!!.runNetwork() + val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf.info.legalIdentities[0]) + val future = santa.startFlow(f1) + network.runNetwork() val f1Output = future.get().tx.outputsOfType(SantaSessionState::class.java)[0] val f2 = CheckAssignedSantaFlow(f1Output.linearId) val f3 = CheckAssignedSantaFlow(f1Output.linearId) - val future2 = santa!!.startFlow(f2) - val future3 = elf!!.startFlow(f3) - network!!.runNetwork() + val future2 = santa.startFlow(f2) + val future3 = elf.startFlow(f3) + network.runNetwork() val f2Output = future2.get() val f3Output = future3.get() - Util.assertEquals(playerNames, f1Output.playerNames) - Util.assertEquals(playerNames, f2Output.playerNames) + assertEquals(playerNames, f1Output.playerNames) + assertEquals(playerNames, f2Output.playerNames) // ensure these states are really the same - Util.assertEquals(f2Output.playerNames, f3Output.playerNames) - Util.assertEquals(f2Output.playerEmails, f3Output.playerEmails) - Util.assertEquals(f2Output.getAssignments(), f3Output.getAssignments()) - assert(f2Output.playerNames.contains("david")) - assert(f2Output.playerNames.contains("olivia")) - assert(!f2Output.playerNames.contains("derek")) - assert(f3Output.playerNames.contains("david")) - assert(f3Output.playerNames.contains("olivia")) - assert(!f3Output.playerNames.contains("derek")) - Util.assertEquals(f3Output.getAssignments()!!["david"], f2Output.getAssignments()!!["david"]) - Util.assertEquals(f3Output.getAssignments()!!["peter"], f2Output.getAssignments()!!["peter"]) + assertEquals(f2Output.playerNames, f3Output.playerNames) + assertEquals(f2Output.playerEmails, f3Output.playerEmails) + assertEquals(f2Output.getAssignments(), f3Output.getAssignments()) + assertTrue(f2Output.playerNames.contains("david")) + assertTrue(f2Output.playerNames.contains("olivia")) + assertFalse(f2Output.playerNames.contains("derek")) + assertTrue(f3Output.playerNames.contains("david")) + assertTrue(f3Output.playerNames.contains("olivia")) + assertFalse(f3Output.playerNames.contains("derek")) + assertEquals(f3Output.getAssignments()!!["david"], f2Output.getAssignments()!!["david"]) + assertEquals(f3Output.getAssignments()!!["peter"], f2Output.getAssignments()!!["peter"]) Assertions.assertNotEquals(f3Output.getAssignments()!!["peter"], f2Output.getAssignments()!!["david"]) - Util.assertEquals(f3Output.linearId, f2Output.linearId) + assertEquals(f3Output.linearId, f2Output.linearId) } // ensure we can create and query a santa session @Test @Throws(Exception::class) fun canRetrieveWithConvertedStringId() { - val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf!!.info.legalIdentities[0]) - val future = santa!!.startFlow(f1) - network!!.runNetwork() + val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf.info.legalIdentities[0]) + val future = santa.startFlow(f1) + network.runNetwork() val f1Output = future.get().tx.outputsOfType(SantaSessionState::class.java)[0] val strSessionId = f1Output.linearId.toString() println("CONVERTED STRING ID: $strSessionId") val convertedId = fromString(strSessionId) val f2 = CheckAssignedSantaFlow(convertedId) - val future2 = santa!!.startFlow(f2) - network!!.runNetwork() + val future2 = santa.startFlow(f2) + network.runNetwork() val f2Output = future2.get() - Util.assertEquals(playerNames, f1Output.playerNames) - Util.assertEquals(playerNames, f2Output.playerNames) + assertEquals(playerNames, f1Output.playerNames) + assertEquals(playerNames, f2Output.playerNames) // ensure these states are really the same - Util.assertEquals(f1Output.playerNames, f2Output.playerNames) - Util.assertEquals(f1Output.playerEmails, f2Output.playerEmails) - Util.assertEquals(f1Output.getAssignments(), f2Output.getAssignments()) - assert(f1Output.playerNames.contains("david")) - assert(f1Output.playerNames.contains("olivia")) - assert(!f1Output.playerNames.contains("derek")) - assert(f2Output.playerNames.contains("david")) - assert(f2Output.playerNames.contains("olivia")) - assert(!f2Output.playerNames.contains("derek")) - Util.assertEquals(f1Output.getAssignments()!!["david"], f2Output.getAssignments()!!["david"]) - Util.assertEquals(f1Output.getAssignments()!!["peter"], f2Output.getAssignments()!!["peter"]) + assertEquals(f1Output.playerNames, f2Output.playerNames) + assertEquals(f1Output.playerEmails, f2Output.playerEmails) + assertEquals(f1Output.getAssignments(), f2Output.getAssignments()) + assertTrue(f1Output.playerNames.contains("david")) + assertTrue(f1Output.playerNames.contains("olivia")) + assertFalse(f1Output.playerNames.contains("derek")) + assertTrue(f2Output.playerNames.contains("david")) + assertTrue(f2Output.playerNames.contains("olivia")) + assertFalse(f2Output.playerNames.contains("derek")) + assertEquals(f1Output.getAssignments()!!["david"], f2Output.getAssignments()!!["david"]) + assertEquals(f1Output.getAssignments()!!["peter"], f2Output.getAssignments()!!["peter"]) Assertions.assertNotEquals(f1Output.getAssignments()!!["peter"], f2Output.getAssignments()!!["david"]) - Util.assertEquals(f1Output.linearId, f2Output.linearId) + assertEquals(f1Output.linearId, f2Output.linearId) } } diff --git a/Advanced/secretsanta-cordapp/workflows/src/test/kotlin/net/corda/samples/secretsanta/CreateSantaSessionFlowTests.kt b/Advanced/secretsanta-cordapp/workflows/src/test/kotlin/net/corda/samples/secretsanta/CreateSantaSessionFlowTests.kt index bb15b329..e464e14f 100644 --- a/Advanced/secretsanta-cordapp/workflows/src/test/kotlin/net/corda/samples/secretsanta/CreateSantaSessionFlowTests.kt +++ b/Advanced/secretsanta-cordapp/workflows/src/test/kotlin/net/corda/samples/secretsanta/CreateSantaSessionFlowTests.kt @@ -1,16 +1,14 @@ package net.corda.samples.secretsanta - -import net.corda.core.crypto.SecureHash import net.corda.core.identity.CordaX500Name import net.corda.core.node.NetworkParameters -import net.corda.core.transactions.SignedTransaction import net.corda.samples.secretsanta.contracts.SantaSessionContract import net.corda.samples.secretsanta.flows.CreateSantaSessionFlow import net.corda.samples.secretsanta.states.SantaSessionState import net.corda.testing.node.* -import org.jgroups.util.Util import org.junit.After +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test import org.junit.jupiter.api.Assertions @@ -19,13 +17,13 @@ import java.util.* class CreateSantaSessionFlowTests { - lateinit var network: MockNetwork - lateinit var santa: StartedMockNode - lateinit var elf: StartedMockNode + private lateinit var network: MockNetwork + private lateinit var santa: StartedMockNode + private lateinit var elf: StartedMockNode - private val testNetworkParameters = NetworkParameters(4, Arrays.asList(), 10485760, 10485760 * 5, Instant.now(), 1, LinkedHashMap>()) - private val playerNames = ArrayList(Arrays.asList("david", "alice", "bob", "charlie", "olivia", "peter")) - private val playerEmails = ArrayList(Arrays.asList("david@corda.net", "alice@corda.net", "bob@corda.net", "charlie@corda.net", "olivia@corda.net", "peter@corda.net")) + private val testNetworkParameters = NetworkParameters(4, emptyList(), 10485760, 10485760 * 5, Instant.now(), 1, LinkedHashMap()) + private val playerNames = listOf("david", "alice", "bob", "charlie", "olivia", "peter") + private val playerEmails = listOf("david@corda.net", "alice@corda.net", "bob@corda.net", "charlie@corda.net", "olivia@corda.net", "peter@corda.net") @Before @@ -47,101 +45,103 @@ class CreateSantaSessionFlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test @Throws(Exception::class) fun flowUsesCorrectNotary() { - val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf!!.info.legalIdentities[0]) - val future = santa!!.startFlow(f1) - network!!.runNetwork() + val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf.info.legalIdentities[0]) + val future = santa.startFlow(f1) + network.runNetwork() val signedTransaction = future.get() - Util.assertEquals(1, signedTransaction.tx.outputStates.size) + assertEquals(1, signedTransaction.tx.outputStates.size) // ensure correct notary is used - Util.assertEquals(network!!.notaryNodes[0].info.legalIdentities[0], signedTransaction.notary) + assertEquals(network.notaryNodes[0].info.legalIdentities[0], signedTransaction.notary) } @Test @Throws(Exception::class) fun canCreateSession() { - val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf!!.info.legalIdentities[0]) - val future = santa!!.startFlow(f1) - network!!.runNetwork() + val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf.info.legalIdentities[0]) + val future = santa.startFlow(f1) + network.runNetwork() val signedTransaction = future.get() - Util.assertEquals(1, signedTransaction.tx.outputStates.size) + assertEquals(1, signedTransaction.tx.outputStates.size) val output = signedTransaction.tx.outputsOfType(SantaSessionState::class.java)[0] // get some random data from the output to verify - Util.assertEquals(playerNames, output.playerNames) + assertEquals(playerNames, output.playerNames) } @Test @Throws(Exception::class) fun transactionConstructedHasCorrectOutput() { - val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf!!.info.legalIdentities[0]) - val future = santa!!.startFlow(f1) - network!!.runNetwork() + val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf.info.legalIdentities[0]) + val future = santa.startFlow(f1) + network.runNetwork() val signedTransaction = future.get() - Util.assertEquals(1, signedTransaction.tx.outputStates.size) + assertEquals(1, signedTransaction.tx.outputStates.size) val (_, _, notary) = signedTransaction.tx.outputs[0] // ensure correct notary is used is used - Util.assertEquals(network!!.notaryNodes[0].info.legalIdentities[0], notary) + assertEquals(network.notaryNodes[0].info.legalIdentities[0], notary) val output = signedTransaction.tx.outputsOfType(SantaSessionState::class.java)[0] // checking player names, emails, and assignments. - Util.assertEquals(playerNames, output.playerNames) - Util.assertEquals(playerEmails, output.playerEmails) - Util.assertEquals(playerEmails.size, output.getAssignments()!!.size) + assertEquals(playerNames, output.playerNames) + assertEquals(playerEmails, output.playerEmails) + assertEquals(playerEmails.size, output.getAssignments()!!.size) } @Test @Throws(Exception::class) fun transactionConstructedHasOneOutputUsingTheCorrectContract() { - val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf!!.info.legalIdentities[0]) - val future = santa!!.startFlow(f1) - network!!.runNetwork() + val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf.info.legalIdentities[0]) + val future = santa.startFlow(f1) + network.runNetwork() val signedTransaction = future.get() - Util.assertEquals(1, signedTransaction.tx.outputStates.size) + assertEquals(1, signedTransaction.tx.outputStates.size) val (_, contract) = signedTransaction.tx.outputs[0] - Util.assertEquals("net.corda.samples.secretsanta.contracts.SantaSessionContract", contract) + assertEquals("net.corda.samples.secretsanta.contracts.SantaSessionContract", contract) } @Test @Throws(Exception::class) fun transactionConstructedByFlowHasOneIssueCommand() { - val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf!!.info.legalIdentities[0]) - val future = santa!!.startFlow(f1) - network!!.runNetwork() + val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf.info.legalIdentities[0]) + val future = santa.startFlow(f1) + network.runNetwork() val signedTransaction = future.get() - Util.assertEquals(1, signedTransaction.tx.commands.size) + assertEquals(1, signedTransaction.tx.commands.size) val (value) = signedTransaction.tx.commands[0] - assert(value is SantaSessionContract.Commands.Issue) + assertTrue(value is SantaSessionContract.Commands.Issue) } @Test @Throws(Exception::class) fun transactionConstructedByFlowHasOneCommandWithTheIssuerAndTheOwnerAsASigners() { - val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf!!.info.legalIdentities[0]) - val future = santa!!.startFlow(f1) - network!!.runNetwork() + val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf.info.legalIdentities[0]) + val future = santa.startFlow(f1) + network.runNetwork() val signedTransaction = future.get() - Util.assertEquals(1, signedTransaction.tx.commands.size) + assertEquals(1, signedTransaction.tx.commands.size) val (_, signers) = signedTransaction.tx.commands[0] - Util.assertEquals(2, signers.size) - Util.assertTrue(signers.contains(santa!!.info.legalIdentities[0].owningKey)) - Util.assertTrue(signers.contains(elf!!.info.legalIdentities[0].owningKey)) + assertEquals(2, signers.size) + assertTrue(signers.contains(santa.info.legalIdentities[0].owningKey)) + assertTrue(signers.contains(elf.info.legalIdentities[0].owningKey)) } @Test @Throws(Exception::class) fun transactionConstructedByFlowHasNoInputsAttachmentsOrTimeWindows() { - val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf!!.info.legalIdentities[0]) - val future = santa!!.startFlow(f1) - network!!.runNetwork() + val f1 = CreateSantaSessionFlow(playerNames, playerEmails, elf.info.legalIdentities[0]) + val future = santa.startFlow(f1) + network.runNetwork() val signedTransaction = future.get() - Util.assertEquals(0, signedTransaction.tx.inputs.size) - Util.assertEquals(1, signedTransaction.tx.outputs.size) + assertEquals(0, signedTransaction.tx.inputs.size) + assertEquals(1, signedTransaction.tx.outputs.size) // The single attachment is the contract attachment. - Util.assertEquals(1, signedTransaction.tx.attachments.size) + assertEquals(1, signedTransaction.tx.attachments.size) Assertions.assertNull(signedTransaction.tx.timeWindow) } } diff --git a/Advanced/settings.gradle b/Advanced/settings.gradle new file mode 100644 index 00000000..d1a7eafa --- /dev/null +++ b/Advanced/settings.gradle @@ -0,0 +1,7 @@ +includeBuild 'auction-cordapp' +includeBuild 'duediligence-cordapp' +includeBuild 'negotiation-cordapp' +includeBuild 'obligation-cordapp' +includeBuild 'secretsanta-cordapp' +includeBuild 'snakesandladders-cordapp' +includeBuild 'syndicated-lending' diff --git a/Advanced/snakesandladders-cordapp/README.md b/Advanced/snakesandladders-cordapp/README.md index ae80630b..25d7dfa0 100644 --- a/Advanced/snakesandladders-cordapp/README.md +++ b/Advanced/snakesandladders-cordapp/README.md @@ -19,7 +19,7 @@ Oracle node is used to obtain the player dice rolls. # Setting up Go into the project directory and build the project ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Run the project ``` @@ -30,9 +30,9 @@ Now, you should have four Corda terminals opened automatically. Run the below command to start clients: -``` ./gradlew runClassicGamesClient``` +``` ../gradlew runClassicGamesClient``` -``` ./gradlew runMegaGamesClient``` +``` ../gradlew runMegaGamesClient``` The clients can be accessed at http://localhost:50007 and http://localhost:50008 for Classic Games and Mega Games respectively. diff --git a/Advanced/snakesandladders-cordapp/build.gradle b/Advanced/snakesandladders-cordapp/build.gradle index 1ade9411..ea377daa 100644 --- a/Advanced/snakesandladders-cordapp/build.gradle +++ b/Advanced/snakesandladders-cordapp/build.gradle @@ -1,106 +1,54 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - //accounts - accounts_release_version = '1.0' - accounts_release_group = 'com.r3.corda.lib.accounts' - confidential_id_release_group = "com.r3.corda.lib.ci" - confidential_id_release_version = "1.0" - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } - //SDK lib - maven { url 'https://software.r3.com/artifactory/corda-lib' } - //Gradle Plugins - maven { url 'https://repo.gradle.org/gradle/libs-releases' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } -//Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") - cordapp project(":oracle-flows") - cordapp project(":oracle-service") - - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordapp project(':workflows') + cordapp project(':contracts') + cordapp project(':oracle-flows') + cordapp project(':oracle-service') //accounts cordapp "$accounts_release_group:accounts-contracts:$accounts_release_version" @@ -108,22 +56,24 @@ dependencies { cordapp "$accounts_release_group:accounts-workflows:$accounts_release_version" } - -//Task to deploy the nodes in order to bootstrap a network - -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = false - } - cordapp("$confidential_id_release_group:ci-workflows:$confidential_id_release_version") - cordapp("$accounts_release_group:accounts-contracts:$accounts_release_version") - cordapp("$accounts_release_group:accounts-workflows:$accounts_release_version") + cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version" + cordapp "$accounts_release_group:accounts-contracts:$accounts_release_version" + cordapp "$accounts_release_group:accounts-workflows:$accounts_release_version" - cordapp project(":contracts") - cordapp project(":workflows") - cordapp project(":oracle-flows") - runSchemaMigration = true + cordapp project(':contracts') + cordapp project(':workflows') + cordapp project(':oracle-flows') + rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { name "O=Notary,L=London,C=GB" @@ -133,7 +83,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } - cordapps.clear(); + rpcUsers = [] } node { name "O=ClassicGames,L=London,C=GB" @@ -142,7 +92,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=MegaGames,L=New York,C=US" @@ -151,8 +100,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] - } node { name "O=Oracle,L=Mumbai,C=IN" @@ -161,9 +108,8 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10012") adminAddress("localhost:10052") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] cordapps.clear(); - cordapp project(":oracle-service") - cordapp project(":oracle-flows") + cordapp project(':oracle-service') + cordapp project(':oracle-flows') } } diff --git a/Advanced/snakesandladders-cordapp/clients/build.gradle b/Advanced/snakesandladders-cordapp/clients/build.gradle index 84f9fe7a..3c232b1d 100644 --- a/Advanced/snakesandladders-cordapp/clients/build.gradle +++ b/Advanced/snakesandladders-cordapp/clients/build.gradle @@ -1,4 +1,7 @@ -apply plugin: 'org.springframework.boot' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'org.springframework.boot' +} sourceSets { main { @@ -10,36 +13,34 @@ sourceSets { dependencies { // Corda dependencies. - compile "$corda_release_group:corda-rpc:$corda_release_version" + implementation "$corda_release_group:corda-rpc:$corda_release_version" // CorDapp dependencies. - compile project(":contracts") - compile project(":workflows") - compile "net.corda:corda-core:$corda_release_version" - compile "net.corda:corda-jackson:$corda_release_version" - compile "net.corda:corda-rpc:$corda_release_version" - compile "net.corda:corda:$corda_release_version" - compile("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { + implementation project(':contracts') + implementation project(':workflows') + implementation "net.corda:corda-core:$corda_release_version" + implementation "net.corda:corda-jackson:$corda_release_version" + implementation "net.corda:corda-rpc:$corda_release_version" + implementation("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { exclude group: "org.springframework.boot", module: "spring-boot-starter-logging" } - compile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - compile "org.apache.logging.log4j:log4j-web:${log4j_version}" - compile "org.slf4j:jul-to-slf4j:$slf4j_version" + runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" + runtimeOnly "org.apache.logging.log4j:log4j-web:${log4j_version}" } - - springBoot { mainClassName = "net.corda.samples.snl.webserver.Server" } -task runClassicGamesClient(type: JavaExec, dependsOn: assemble) { +tasks.register('runClassicGamesClient', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.snl.webserver.ServerKt' args '--server.port=50007', '--config.rpc.host=localhost', '--config.rpc.port=10006', '--config.rpc.username=user1', '--config.rpc.password=test' } -task runMegaGamesClient(type: JavaExec, dependsOn: assemble) { +tasks.register('runMegaGamesClient', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.snl.webserver.ServerKt' args '--server.port=50008', '--config.rpc.host=localhost', '--config.rpc.port=10009', '--config.rpc.username=user1', '--config.rpc.password=test' diff --git a/Advanced/snakesandladders-cordapp/clients/src/main/kotlin/net/corda/samples/snl/webserver/Controller.kt b/Advanced/snakesandladders-cordapp/clients/src/main/kotlin/net/corda/samples/snl/webserver/Controller.kt index 37cbbe1c..a902318c 100644 --- a/Advanced/snakesandladders-cordapp/clients/src/main/kotlin/net/corda/samples/snl/webserver/Controller.kt +++ b/Advanced/snakesandladders-cordapp/clients/src/main/kotlin/net/corda/samples/snl/webserver/Controller.kt @@ -1,15 +1,11 @@ package net.corda.samples.snl.webserver import net.corda.core.internal.toX500Name -import net.corda.core.messaging.startFlow -import net.corda.core.messaging.vaultQueryBy import net.corda.core.node.NodeInfo import org.bouncycastle.asn1.x500.X500Name import org.bouncycastle.asn1.x500.style.BCStyle import org.slf4j.LoggerFactory -import org.springframework.http.HttpStatus import org.springframework.http.MediaType.APPLICATION_JSON_VALUE -import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* diff --git a/Advanced/snakesandladders-cordapp/contracts/build.gradle b/Advanced/snakesandladders-cordapp/contracts/build.gradle index 6527d4b4..59676701 100644 --- a/Advanced/snakesandladders-cordapp/contracts/build.gradle +++ b/Advanced/snakesandladders-cordapp/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "Snakes And Ladder Contracts" vendor "Corda Open Source" @@ -12,8 +15,9 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Advanced/snakesandladders-cordapp/contracts/src/main/kotlin/net/corda/samples/snl/contracts/BoardConfigContract.kt b/Advanced/snakesandladders-cordapp/contracts/src/main/kotlin/net/corda/samples/snl/contracts/BoardConfigContract.kt index eef93b06..4886166d 100644 --- a/Advanced/snakesandladders-cordapp/contracts/src/main/kotlin/net/corda/samples/snl/contracts/BoardConfigContract.kt +++ b/Advanced/snakesandladders-cordapp/contracts/src/main/kotlin/net/corda/samples/snl/contracts/BoardConfigContract.kt @@ -10,10 +10,10 @@ class BoardConfigContract : Contract { @Throws(IllegalArgumentException::class) override fun verify(tx: LedgerTransaction) { // Contract verification logic should be implemented here - if (tx.outputStates.size != 1 || tx.inputStates.size != 0) throw IllegalArgumentException("Zero Input and One Output Expected") + if (tx.outputStates.size != 1 || tx.inputStates.isNotEmpty()) throw IllegalArgumentException("Zero Input and One Output Expected") if (tx.getOutput(0) !is BoardConfig) throw IllegalArgumentException("Output of type BoardConfig expected") val boardConfig = tx.getOutput(0) as BoardConfig - if (boardConfig.snakePositions == null || boardConfig.snakePositions.size == 0 || boardConfig.ladderPositions == null || boardConfig.ladderPositions.size == 0) throw IllegalArgumentException("Snake and Ladder Positions should not be empty or null") + if (boardConfig.snakePositions == null || boardConfig.snakePositions.isEmpty() || boardConfig.ladderPositions == null || boardConfig.ladderPositions.size == 0) throw IllegalArgumentException("Snake and Ladder Positions should not be empty or null") } interface Commands : CommandData { diff --git a/Advanced/snakesandladders-cordapp/contracts/src/main/kotlin/net/corda/samples/snl/contracts/GameBoardContract.kt b/Advanced/snakesandladders-cordapp/contracts/src/main/kotlin/net/corda/samples/snl/contracts/GameBoardContract.kt index 90e0d69f..76f5ce98 100644 --- a/Advanced/snakesandladders-cordapp/contracts/src/main/kotlin/net/corda/samples/snl/contracts/GameBoardContract.kt +++ b/Advanced/snakesandladders-cordapp/contracts/src/main/kotlin/net/corda/samples/snl/contracts/GameBoardContract.kt @@ -28,14 +28,14 @@ class GameBoardContract : Contract { @Throws(IllegalArgumentException::class) private fun verifyCreate(tx: LedgerTransaction) { // Contract verification logic for create game should be implemented here - if (tx.outputStates.size != 1 || tx.inputStates.size != 0) throw IllegalArgumentException("Zero Input and One Output Expected") + if (tx.outputStates.size != 1 || tx.inputStates.isNotEmpty()) throw IllegalArgumentException("Zero Input and One Output Expected") if (tx.getOutput(0) !is GameBoard) throw IllegalArgumentException("Output of type GameBoard expected") } @Throws(IllegalArgumentException::class) private fun verifyPlay(tx: LedgerTransaction) { // Contract verification logic for play move should be implemented here - if (tx.references.size == 0 || tx.getReferenceInput(0) !is BoardConfig) { + if (tx.references.isEmpty() || tx.getReferenceInput(0) !is BoardConfig) { throw IllegalArgumentException("One reference Input of BoardConfig Expected") } if (tx.outputStates.size != 1 || tx.inputStates.size != 1) throw IllegalArgumentException("One Input and One Output Expected") diff --git a/Advanced/snakesandladders-cordapp/contracts/src/main/kotlin/net/corda/samples/snl/states/GameBoard.kt b/Advanced/snakesandladders-cordapp/contracts/src/main/kotlin/net/corda/samples/snl/states/GameBoard.kt index ba10f900..e9ba41b0 100644 --- a/Advanced/snakesandladders-cordapp/contracts/src/main/kotlin/net/corda/samples/snl/states/GameBoard.kt +++ b/Advanced/snakesandladders-cordapp/contracts/src/main/kotlin/net/corda/samples/snl/states/GameBoard.kt @@ -13,6 +13,5 @@ import java.util.* class GameBoard(override val linearId: UniqueIdentifier, val player1: AbstractParty, val player2: AbstractParty, val currentPlayer: String, val player1Pos: Int, val player2Pos: Int, val winner: String?, val lastRoll: Int) : LinearState { override val participants: List - get() = Arrays.asList(player1, player2) - + get() = listOf(player1, player2) } diff --git a/Advanced/snakesandladders-cordapp/gradle.properties b/Advanced/snakesandladders-cordapp/gradle.properties index 307e72d4..da215da4 100644 --- a/Advanced/snakesandladders-cordapp/gradle.properties +++ b/Advanced/snakesandladders-cordapp/gradle.properties @@ -1,4 +1,31 @@ -name=Test -group=com.template +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + +name=Snakes And Ladders +group=com.sexample version=0.1 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.68.Final + +spring_boot_version=2.0.2.RELEASE + +accounts_release_version=1.0.2 +accounts_release_group=com.r3.corda.lib.accounts +confidential_id_release_group=com.r3.corda.lib.ci +confidential_id_release_version=1.1 diff --git a/Advanced/snakesandladders-cordapp/gradle/wrapper/gradle-wrapper.jar b/Advanced/snakesandladders-cordapp/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Advanced/snakesandladders-cordapp/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Advanced/snakesandladders-cordapp/gradle/wrapper/gradle-wrapper.properties b/Advanced/snakesandladders-cordapp/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Advanced/snakesandladders-cordapp/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Advanced/snakesandladders-cordapp/gradlew b/Advanced/snakesandladders-cordapp/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Advanced/snakesandladders-cordapp/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Advanced/snakesandladders-cordapp/gradlew.bat b/Advanced/snakesandladders-cordapp/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Advanced/snakesandladders-cordapp/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Advanced/snakesandladders-cordapp/oracle-flows/build.gradle b/Advanced/snakesandladders-cordapp/oracle-flows/build.gradle index f841b45b..fa808b6b 100644 --- a/Advanced/snakesandladders-cordapp/oracle-flows/build.gradle +++ b/Advanced/snakesandladders-cordapp/oracle-flows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "Oracle Flows Cordapp" vendor "Corda Open Source" @@ -12,15 +15,10 @@ cordapp { } } - dependencies { // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":oracle-service") - -} \ No newline at end of file + cordapp project(':oracle-service') +} diff --git a/Advanced/snakesandladders-cordapp/oracle-flows/src/main/kotlin/net/corda/samples/snl/oracle/flows/DiceRollerFlow.kt b/Advanced/snakesandladders-cordapp/oracle-flows/src/main/kotlin/net/corda/samples/snl/oracle/flows/DiceRollerFlow.kt index 6b8fe537..da8ecee8 100644 --- a/Advanced/snakesandladders-cordapp/oracle-flows/src/main/kotlin/net/corda/samples/snl/oracle/flows/DiceRollerFlow.kt +++ b/Advanced/snakesandladders-cordapp/oracle-flows/src/main/kotlin/net/corda/samples/snl/oracle/flows/DiceRollerFlow.kt @@ -17,11 +17,10 @@ class DiceRollerFlow(private val player: String, private val oracle: Party) : Fl class DiceRollerFlowHandler(private val requestSession: FlowSession) : FlowLogic() { @Suspendable @Throws(FlowException::class) - override fun call(): Unit { - val player = requestSession.receive(String::class.java).unwrap{ it -> it } + override fun call() { + val player = requestSession.receive(String::class.java).unwrap { it } val service: DiceRollService = serviceHub.cordaService(DiceRollService::class.java) val roll: Int = service.diceRoll(player) requestSession.send(roll) - return } } diff --git a/Advanced/snakesandladders-cordapp/oracle-flows/src/main/kotlin/net/corda/samples/snl/oracle/flows/OracleSignatureFlow.kt b/Advanced/snakesandladders-cordapp/oracle-flows/src/main/kotlin/net/corda/samples/snl/oracle/flows/OracleSignatureFlow.kt index ef755d04..f4d4ac4a 100644 --- a/Advanced/snakesandladders-cordapp/oracle-flows/src/main/kotlin/net/corda/samples/snl/oracle/flows/OracleSignatureFlow.kt +++ b/Advanced/snakesandladders-cordapp/oracle-flows/src/main/kotlin/net/corda/samples/snl/oracle/flows/OracleSignatureFlow.kt @@ -21,15 +21,13 @@ class OracleSignatureFlow(private val oracle: Party, private val ftx: FilteredTr class OracleSignatureFlowHandler(private val requestSession: FlowSession) : FlowLogic() { @Suspendable @Throws(FlowException::class) - override fun call(): Unit { + override fun call() { val transaction = requestSession.receive(FilteredTransaction::class.java).unwrap{ it-> it } - var signature: TransactionSignature? = null - signature = try { + val signature = try { serviceHub.cordaService(DiceRollService::class.java).sign(transaction) } catch (e: Exception) { - throw FlowException(e) + throw FlowException(e.message, e) } requestSession.send(signature) - return } } diff --git a/Advanced/snakesandladders-cordapp/oracle-service/build.gradle b/Advanced/snakesandladders-cordapp/oracle-service/build.gradle index 8a953dd8..c0bb218c 100644 --- a/Advanced/snakesandladders-cordapp/oracle-service/build.gradle +++ b/Advanced/snakesandladders-cordapp/oracle-service/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "Oracle Service Cordapp" vendor "Corda Open Source" @@ -15,8 +18,5 @@ cordapp { dependencies { // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" -} \ No newline at end of file + cordaProvided "$corda_core_group:corda-core:$corda_release_version" +} diff --git a/Advanced/snakesandladders-cordapp/repositories.gradle b/Advanced/snakesandladders-cordapp/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Advanced/snakesandladders-cordapp/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Advanced/snakesandladders-cordapp/settings.gradle b/Advanced/snakesandladders-cordapp/settings.gradle index 6fcfbbb5..fdd56ce4 100644 --- a/Advanced/snakesandladders-cordapp/settings.gradle +++ b/Advanced/snakesandladders-cordapp/settings.gradle @@ -1,5 +1,41 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url "$artifactoryContextUrl/corda-lib" + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' include 'oracle-service' include 'clients' -include 'oracle-flows' \ No newline at end of file +include 'oracle-flows' diff --git a/Advanced/snakesandladders-cordapp/workflows/build.gradle b/Advanced/snakesandladders-cordapp/workflows/build.gradle index 49a36c51..44841f57 100644 --- a/Advanced/snakesandladders-cordapp/workflows/build.gradle +++ b/Advanced/snakesandladders-cordapp/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "Template Flows" vendor "Corda Open Source" @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,31 +31,30 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") - cordapp project(":oracle-flows") + cordapp project(':contracts') + cordapp project(':oracle-flows') //Account dependencies - cordaCompile "$confidential_id_release_group:ci-workflows:$confidential_id_release_version" - cordaCompile "$accounts_release_group:accounts-workflows:$accounts_release_version" - cordaCompile "$accounts_release_group:accounts-contracts:$accounts_release_version" + cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version" + cordapp "$accounts_release_group:accounts-workflows:$accounts_release_version" + cordapp "$accounts_release_group:accounts-contracts:$accounts_release_version" } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Advanced/snakesandladders-cordapp/workflows/src/main/kotlin/net/corda/samples/snl/flows/CreateBoardConfig.kt b/Advanced/snakesandladders-cordapp/workflows/src/main/kotlin/net/corda/samples/snl/flows/CreateBoardConfig.kt index 34d0912f..0c6c457e 100644 --- a/Advanced/snakesandladders-cordapp/workflows/src/main/kotlin/net/corda/samples/snl/flows/CreateBoardConfig.kt +++ b/Advanced/snakesandladders-cordapp/workflows/src/main/kotlin/net/corda/samples/snl/flows/CreateBoardConfig.kt @@ -27,9 +27,9 @@ class CreateBoardConfig private constructor() { val notary = serviceHub.networkMapCache.getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")) val accountService: AccountService = serviceHub.cordaService(KeyManagementBackedAccountService::class.java) val p1accountInfo = accountService.accountInfo(player1) - if (p1accountInfo.size == 0) throw FlowException("Player $player1 doesn't exist!") + if (p1accountInfo.isEmpty()) throw FlowException("Player $player1 doesn't exist!") val p2accountInfo = accountService.accountInfo(player2) - if (p1accountInfo.size == 0) throw FlowException("Player $player2 doesn't exist!") + if (p1accountInfo.isEmpty()) throw FlowException("Player $player2 doesn't exist!") val player1: AbstractParty = subFlow(RequestKeyForAccount(p1accountInfo[0].state.data)) val player2: AbstractParty = subFlow(RequestKeyForAccount(p2accountInfo[0].state.data)) val ladderPositions: MutableMap = LinkedHashMap() @@ -46,15 +46,15 @@ class CreateBoardConfig private constructor() { snakePositions[93] = 89 snakePositions[95] = 75 snakePositions[99] = 21 - val boardConfig = BoardConfig(ladderPositions, snakePositions, Arrays.asList(player1, player2)) + val boardConfig = BoardConfig(ladderPositions, snakePositions, listOf(player1, player2)) val transactionBuilder = TransactionBuilder(notary) .addOutputState(boardConfig) - .addCommand(Create(), Arrays.asList(player1.owningKey, player2.owningKey)) + .addCommand(Create(), listOf(player1.owningKey, player2.owningKey)) transactionBuilder.verify(serviceHub) val selfSignedTransaction = serviceHub.signInitialTransaction(transactionBuilder, player1.owningKey) val player2Session = initiateFlow(p2accountInfo[0].state.data.host) var signedTransaction = subFlow(CollectSignaturesFlow(selfSignedTransaction, listOf(player2Session), setOf(player1.owningKey))) - return if (!p2accountInfo[0].state.data.host.equals(ourIdentity)) { + return if (p2accountInfo[0].state.data.host != ourIdentity) { signedTransaction = subFlow(FinalityFlow(signedTransaction, listOf(player2Session))) try { accountService.shareStateAndSyncAccounts(signedTransaction @@ -80,7 +80,7 @@ class CreateBoardConfig private constructor() { // Custom Logic to validate transaction. } }) - return if (!counterpartySession.counterparty.equals(ourIdentity)) subFlow(ReceiveFinalityFlow(counterpartySession)) else null + return if (counterpartySession.counterparty != ourIdentity) subFlow(ReceiveFinalityFlow(counterpartySession)) else null } } } \ No newline at end of file diff --git a/Advanced/snakesandladders-cordapp/workflows/src/main/kotlin/net/corda/samples/snl/flows/CreateGameFlow.kt b/Advanced/snakesandladders-cordapp/workflows/src/main/kotlin/net/corda/samples/snl/flows/CreateGameFlow.kt index f8ddd05a..7ec43ab7 100644 --- a/Advanced/snakesandladders-cordapp/workflows/src/main/kotlin/net/corda/samples/snl/flows/CreateGameFlow.kt +++ b/Advanced/snakesandladders-cordapp/workflows/src/main/kotlin/net/corda/samples/snl/flows/CreateGameFlow.kt @@ -32,22 +32,22 @@ class CreateGameFlow private constructor() { val p1accountInfo = accountService.accountInfo(player1) if (p1accountInfo.size == 0) throw FlowException("Player $player1 doesn't exist!") val p2accountInfo = accountService.accountInfo(player2) - if (p1accountInfo.size == 0) throw FlowException("Player $player2 doesn't exist!") + if (p1accountInfo.isEmpty()) throw FlowException("Player $player2 doesn't exist!") val player1: AbstractParty = subFlow(RequestKeyForAccount(p1accountInfo[0].state.data)) val player2: AbstractParty = subFlow(RequestKeyForAccount(p2accountInfo[0].state.data)) val gameBoard = GameBoard(UniqueIdentifier(null, UUID.randomUUID()), player1, player2, this.player1, 1, 1, null, 0) val boardConfigList = serviceHub.vaultService.queryBy(BoardConfig::class.java).states - if (boardConfigList.size == 0) throw FlowException("Please create board config first") + if (boardConfigList.isEmpty()) throw FlowException("Please create board config first") val transactionBuilder = TransactionBuilder(notary) .addOutputState(gameBoard) - .addCommand(Create(), Arrays.asList(player1.owningKey, player2.owningKey)) + .addCommand(Create(), listOf(player1.owningKey, player2.owningKey)) .addReferenceState(ReferencedStateAndRef(boardConfigList[0])) transactionBuilder.verify(serviceHub) val selfSignedTransaction = serviceHub.signInitialTransaction(transactionBuilder, player1.owningKey) val player2Session = initiateFlow(p2accountInfo[0].state.data.host) val signedTransaction = subFlow(CollectSignaturesFlow(selfSignedTransaction, listOf(player2Session), listOf(player1.owningKey))) - if (!p2accountInfo[0].state.data.host.equals(ourIdentity)) { + if (p2accountInfo[0].state.data.host != ourIdentity) { subFlow(FinalityFlow(signedTransaction, listOf(player2Session))) try { accountService.shareStateAndSyncAccounts(signedTransaction @@ -73,7 +73,7 @@ class CreateGameFlow private constructor() { // Custom Logic to validate transaction. } }) - return if (!counterpartySession.counterparty.equals(ourIdentity)) subFlow(ReceiveFinalityFlow(counterpartySession)) else null + return if (counterpartySession.counterparty != ourIdentity) subFlow(ReceiveFinalityFlow(counterpartySession)) else null } } } \ No newline at end of file diff --git a/Advanced/snakesandladders-cordapp/workflows/src/main/kotlin/net/corda/samples/snl/flows/PlayerMoveFlow.kt b/Advanced/snakesandladders-cordapp/workflows/src/main/kotlin/net/corda/samples/snl/flows/PlayerMoveFlow.kt index 311147f8..8e1d8252 100644 --- a/Advanced/snakesandladders-cordapp/workflows/src/main/kotlin/net/corda/samples/snl/flows/PlayerMoveFlow.kt +++ b/Advanced/snakesandladders-cordapp/workflows/src/main/kotlin/net/corda/samples/snl/flows/PlayerMoveFlow.kt @@ -9,7 +9,6 @@ import com.sun.istack.NotNull import net.corda.core.contracts.Command import net.corda.core.contracts.ContractState import net.corda.core.contracts.ReferencedStateAndRef -import net.corda.core.crypto.TransactionSignature import net.corda.core.flows.* import net.corda.core.identity.AbstractParty import net.corda.core.identity.CordaX500Name @@ -41,7 +40,7 @@ class PlayerMoveFlow private constructor() { //Get current player account info val currentPlayerAccountInfo = accountService.accountInfo(player) - if (currentPlayerAccountInfo.size == 0) throw FlowException("Player $player doesn't exist!") + if (currentPlayerAccountInfo.isEmpty()) throw FlowException("Player $player doesn't exist!") val currPlayer: AbstractParty = subFlow(RequestKeyForAccount(currentPlayerAccountInfo[0].state.data)) // Get game board @@ -49,7 +48,7 @@ class PlayerMoveFlow private constructor() { null, StateStatus.UNCONSUMED, null) val gameBoardList = serviceHub.vaultService .queryBy(GameBoard::class.java, linearStateQueryCriteria).states - if (gameBoardList.size == 0) throw FlowException("Game doesn't exist!") + if (gameBoardList.isEmpty()) throw FlowException("Game doesn't exist!") val gameBoard = gameBoardList[0].state.data if (gameBoard.winner != null) { throw FlowException("This Game is Over") @@ -68,7 +67,7 @@ class PlayerMoveFlow private constructor() { }) val otherPlayer: AbstractParty = subFlow(RequestKeyForAccount(otherPlayerAccountInfo.get())) val boardConfigList = serviceHub.vaultService.queryBy(BoardConfig::class.java).states - if (boardConfigList.size == 0) throw FlowException("Board config missing") + if (boardConfigList.isEmpty()) throw FlowException("Board config missing") val boardConfig = boardConfigList[0].state.data // Calculate Player Position @@ -100,8 +99,7 @@ class PlayerMoveFlow private constructor() { val transactionBuilder = TransactionBuilder(notary) .addInputState(gameBoardList[0]) .addOutputState(outputGameBoard) - .addCommand(PlayMove(diceRolled), Arrays.asList(currPlayer.owningKey, - otherPlayer.owningKey)) + .addCommand(PlayMove(diceRolled), listOf(currPlayer.owningKey, otherPlayer.owningKey)) .addReferenceState(ReferencedStateAndRef(boardConfigList[0])) transactionBuilder.verify(serviceHub) val selfSignedTransaction = serviceHub.signInitialTransaction(transactionBuilder, currPlayer.owningKey) @@ -109,15 +107,14 @@ class PlayerMoveFlow private constructor() { .getNodeByLegalName(CordaX500Name.parse("O=Oracle,L=Mumbai,C=IN"))!!.legalIdentities[0] val ftx = selfSignedTransaction.buildFilteredTransaction(Predicate { o: Any? -> - (o is Command<*> && (o as Command<*>).signers.contains(oracle.owningKey) - && (o as Command<*>).value is PlayMove) + (o is Command<*> && o.signers.contains(oracle.owningKey) && o.value is PlayMove) }) val oracleSignature = subFlow(OracleSignatureFlow(oracle, ftx))!! val selfAndOracleSignedTransaction = selfSignedTransaction.withAdditionalSignature(oracleSignature) val otherPlayerSession = initiateFlow(otherPlayerAccountInfo.get().host) var signedTransaction = subFlow(CollectSignaturesFlow(selfAndOracleSignedTransaction, listOf(otherPlayerSession), listOf(currPlayer.owningKey))) - if (!otherPlayerAccountInfo.get().host.equals(ourIdentity)) { + if (otherPlayerAccountInfo.get().host != ourIdentity) { signedTransaction = subFlow(FinalityFlow(signedTransaction, listOf(otherPlayerSession))) try { accountService.shareStateAndSyncAccounts(signedTransaction @@ -143,7 +140,7 @@ class PlayerMoveFlow private constructor() { // Custom Logic to validate transaction. } }) - return if (!counterpartySession.counterparty.equals(ourIdentity)) subFlow(ReceiveFinalityFlow(counterpartySession)) else null + return if (counterpartySession.counterparty != ourIdentity) subFlow(ReceiveFinalityFlow(counterpartySession)) else null } } } \ No newline at end of file diff --git a/Advanced/snakesandladders-cordapp/workflows/src/main/kotlin/net/corda/samples/snl/flows/QueyGameInfo.kt b/Advanced/snakesandladders-cordapp/workflows/src/main/kotlin/net/corda/samples/snl/flows/QueyGameInfo.kt index de85d57b..b5c63672 100644 --- a/Advanced/snakesandladders-cordapp/workflows/src/main/kotlin/net/corda/samples/snl/flows/QueyGameInfo.kt +++ b/Advanced/snakesandladders-cordapp/workflows/src/main/kotlin/net/corda/samples/snl/flows/QueyGameInfo.kt @@ -22,7 +22,7 @@ class QueyGameInfo(private val gameId: String) : FlowLogic() { null, StateStatus.UNCONSUMED, null) val gameBoardList = serviceHub.vaultService .queryBy(GameBoard::class.java, linearStateQueryCriteria).states - if (gameBoardList.size == 0) throw FlowException("Game doesn't exist!") + if (gameBoardList.isEmpty()) throw FlowException("Game doesn't exist!") val gameBoard = gameBoardList[0].state.data val accountService: AccountService = serviceHub.cordaService(KeyManagementBackedAccountService::class.java) val player1 = accountService.accountInfo(gameBoard.player1.owningKey)!!.state.data.name diff --git a/Advanced/snakesandladders-cordapp/workflows/src/test/kotlin/net/corda/samples/snl/FlowTests.kt b/Advanced/snakesandladders-cordapp/workflows/src/test/kotlin/net/corda/samples/snl/FlowTests.kt index 83814c54..31de51ba 100644 --- a/Advanced/snakesandladders-cordapp/workflows/src/test/kotlin/net/corda/samples/snl/FlowTests.kt +++ b/Advanced/snakesandladders-cordapp/workflows/src/test/kotlin/net/corda/samples/snl/FlowTests.kt @@ -10,7 +10,7 @@ import net.corda.samples.snl.states.BoardConfig import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.node.* import org.junit.After -import org.junit.Assert +import org.junit.Assert.assertNotNull import org.junit.Before import org.junit.Test @@ -37,10 +37,11 @@ class FlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } - @Test @Throws(Exception::class) fun testCreateBoardConfigFlow() { @@ -55,7 +56,7 @@ class FlowTests { network.runNetwork() val signedTransaction = signedTransactionCordaFuture.get() val boardConfig = signedTransaction.tx.getOutput(0) as BoardConfig - Assert.assertNotNull(boardConfig) + assertNotNull(boardConfig) } @@ -75,6 +76,6 @@ class FlowTests { val signedTransactionCordaFuture1 = a.startFlow(createGameFlow) network.runNetwork() val gameId = signedTransactionCordaFuture1.get() - Assert.assertNotNull(gameId) + assertNotNull(gameId) } } \ No newline at end of file diff --git a/Advanced/syndicated-lending/README.md b/Advanced/syndicated-lending/README.md index b5110324..9db6e728 100644 --- a/Advanced/syndicated-lending/README.md +++ b/Advanced/syndicated-lending/README.md @@ -20,7 +20,7 @@ See https://docs.corda.net/getting-set-up.html. Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) ``` diff --git a/Advanced/syndicated-lending/build.gradle b/Advanced/syndicated-lending/build.gradle index 4e59c913..8e3c4fd2 100644 --- a/Advanced/syndicated-lending/build.gradle +++ b/Advanced/syndicated-lending/build.gradle @@ -1,109 +1,66 @@ -buildscript { //properties that you need to build the project +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } -//Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':workflows') + cordapp project(':contracts') - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -//Task to deploy the nodes in order to bootstrap a network -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { - +tasks.register('deployNodes', Cordform) { /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load * the Corda network bootstrapper. */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp project(':contracts') cordapp project(':workflows') + rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change //it to false for quicker project compiling time. @@ -116,6 +73,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { name "O=PeterCo,L=London,C=GB" @@ -124,7 +82,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=BankOfAshu,L=New York,C=US" @@ -133,7 +90,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=BankOfSneha,L=New York,C=US" @@ -142,7 +98,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10012") adminAddress("localhost:10052") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=BankOfTom,L=New York,C=US" @@ -151,6 +106,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10016") adminAddress("localhost:10056") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } } diff --git a/Advanced/syndicated-lending/constants.properties b/Advanced/syndicated-lending/constants.properties deleted file mode 100644 index ee9c2200..00000000 --- a/Advanced/syndicated-lending/constants.properties +++ /dev/null @@ -1,12 +0,0 @@ -cordaReleaseGroup=net.corda -cordaCoreReleaseGroup=net.corda -cordaVersion=4.8.5 -cordaCoreVersion=4.8.5 -gradlePluginsVersion=5.0.12 -kotlinVersion=1.2.71 -junitVersion=4.12 -quasarVersion=0.7.13_r3 -log4jVersion=2.17.1 -platformVersion=10 -slf4jVersion=1.7.30 -nettyVersion=4.1.68.Final diff --git a/Advanced/syndicated-lending/contracts/build.gradle b/Advanced/syndicated-lending/contracts/build.gradle index d5e2ffda..d96e2337 100644 --- a/Advanced/syndicated-lending/contracts/build.gradle +++ b/Advanced/syndicated-lending/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "lending Contracts" vendor "Corda Open Source" @@ -12,8 +15,10 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" + // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Advanced/syndicated-lending/gradle.properties b/Advanced/syndicated-lending/gradle.properties index b3be24aa..1296091b 100644 --- a/Advanced/syndicated-lending/gradle.properties +++ b/Advanced/syndicated-lending/gradle.properties @@ -1,4 +1,26 @@ -name=Test +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + +name=Syndicated Lending group=net.corda.samples.lending version=0.1 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.68.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Advanced/syndicated-lending/gradle/wrapper/gradle-wrapper.jar b/Advanced/syndicated-lending/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Advanced/syndicated-lending/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Advanced/syndicated-lending/gradle/wrapper/gradle-wrapper.properties b/Advanced/syndicated-lending/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Advanced/syndicated-lending/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Advanced/syndicated-lending/gradlew b/Advanced/syndicated-lending/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Advanced/syndicated-lending/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Advanced/syndicated-lending/gradlew.bat b/Advanced/syndicated-lending/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Advanced/syndicated-lending/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Advanced/syndicated-lending/repositories.gradle b/Advanced/syndicated-lending/repositories.gradle deleted file mode 100644 index 7dc03179..00000000 --- a/Advanced/syndicated-lending/repositories.gradle +++ /dev/null @@ -1,7 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Advanced/syndicated-lending/settings.gradle b/Advanced/syndicated-lending/settings.gradle index b4446eaf..45f64fa3 100644 --- a/Advanced/syndicated-lending/settings.gradle +++ b/Advanced/syndicated-lending/settings.gradle @@ -1,2 +1,38 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url "$artifactoryContextUrl/corda-lib" + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' -include 'contracts' \ No newline at end of file +include 'contracts' diff --git a/Advanced/syndicated-lending/workflows/build.gradle b/Advanced/syndicated-lending/workflows/build.gradle index ebb29961..5da155e3 100644 --- a/Advanced/syndicated-lending/workflows/build.gradle +++ b/Advanced/syndicated-lending/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "lending Flows" vendor "Corda Open Source" @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,25 +31,24 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/ApproveLoanBidTest.kt b/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/ApproveLoanBidTest.kt index 7dcac0d0..4cd04a02 100644 --- a/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/ApproveLoanBidTest.kt +++ b/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/ApproveLoanBidTest.kt @@ -1,6 +1,5 @@ package net.corda.samples.lending -import groovy.util.GroovyTestCase.assertEquals import net.corda.core.identity.CordaX500Name import net.corda.core.node.services.Vault import net.corda.core.node.services.vault.QueryCriteria @@ -12,7 +11,7 @@ import net.corda.samples.lending.states.LoanBidState import net.corda.samples.lending.states.ProjectState import net.corda.testing.node.* import org.junit.After -import org.junit.Assert +import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test import java.util.concurrent.Future @@ -40,7 +39,9 @@ class ApproveLoanBidTest { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test @@ -65,7 +66,6 @@ class ApproveLoanBidTest { val future3: Future = borrower.startFlow(approveLoanBidFlow) network.runNetwork() val loanBidApproved = bankA.services.vaultService.queryBy(LoanBidState::class.java, inputCriteria).states[0].state.data - assertEquals("APPROVED",loanBidApproved.status) - + assertEquals("APPROVED", loanBidApproved.status) } } \ No newline at end of file diff --git a/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/ApproveSyndicateBidTest.kt b/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/ApproveSyndicateBidTest.kt index b6b85d7c..cfa75b64 100644 --- a/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/ApproveSyndicateBidTest.kt +++ b/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/ApproveSyndicateBidTest.kt @@ -1,6 +1,5 @@ package net.corda.samples.lending -import groovy.util.GroovyTestCase import net.corda.core.identity.CordaX500Name import net.corda.core.node.services.Vault import net.corda.core.node.services.vault.QueryCriteria @@ -13,6 +12,7 @@ import net.corda.samples.lending.states.SyndicateState import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.node.* import org.junit.After +import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test import java.util.concurrent.Future @@ -43,7 +43,9 @@ class ApproveSyndicateBidTest { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test @@ -76,7 +78,7 @@ class ApproveSyndicateBidTest { network.runNetwork() val loanBidApproved = bankA.services.vaultService.queryBy(LoanBidState::class.java, inputCriteria).states[0].state.data - GroovyTestCase.assertEquals("APPROVED", loanBidApproved.status) + assertEquals("APPROVED", loanBidApproved.status) //lead bank create Syndication val approveLoanBidID = loanBidApproved.linearId diff --git a/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/CreateSyndicateTest.kt b/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/CreateSyndicateTest.kt index ec01c302..e3f28b35 100644 --- a/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/CreateSyndicateTest.kt +++ b/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/CreateSyndicateTest.kt @@ -1,7 +1,5 @@ package net.corda.samples.lending -import groovy.util.GroovyTestCase -import groovy.util.GroovyTestCase.assertEquals import net.corda.core.identity.CordaX500Name import net.corda.core.node.services.Vault import net.corda.core.node.services.vault.QueryCriteria @@ -16,6 +14,7 @@ import net.corda.samples.lending.states.SyndicateState import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.node.* import org.junit.After +import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test import java.util.concurrent.Future @@ -46,7 +45,9 @@ class CreateSyndicateTest { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test diff --git a/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/SubmitLoanBidTest.kt b/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/SubmitLoanBidTest.kt index 5f973b3c..279e1f70 100644 --- a/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/SubmitLoanBidTest.kt +++ b/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/SubmitLoanBidTest.kt @@ -37,7 +37,9 @@ class SubmitLoanBidTest { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test diff --git a/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/SubmitProjectTest.kt b/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/SubmitProjectTest.kt index 18ad37e9..6179e4f4 100644 --- a/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/SubmitProjectTest.kt +++ b/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/SubmitProjectTest.kt @@ -33,7 +33,9 @@ class SubmitProjectTest { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test diff --git a/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/SubmitSyndicationBidTest.kt b/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/SubmitSyndicationBidTest.kt index 00d00928..c8d1449d 100644 --- a/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/SubmitSyndicationBidTest.kt +++ b/Advanced/syndicated-lending/workflows/src/test/kotlin/net/corda/samples/lending/SubmitSyndicationBidTest.kt @@ -1,6 +1,5 @@ package net.corda.samples.lending -import groovy.util.GroovyTestCase import net.corda.core.identity.CordaX500Name import net.corda.core.node.services.Vault import net.corda.core.node.services.vault.QueryCriteria @@ -13,6 +12,7 @@ import net.corda.samples.lending.states.SyndicateState import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.node.* import org.junit.After +import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test import java.util.concurrent.Future @@ -43,7 +43,9 @@ class SubmitSyndicationBidTest { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test @@ -74,7 +76,7 @@ class SubmitSyndicationBidTest { val future3: Future = borrower.startFlow(approveLoanBidFlow) network.runNetwork() val loanBidApproved = bankA.services.vaultService.queryBy(LoanBidState::class.java, inputCriteria).states[0].state.data - GroovyTestCase.assertEquals("APPROVED", loanBidApproved.status) + assertEquals("APPROVED", loanBidApproved.status) //lead bank create Syndication val approveLoanBidID = loanBidApproved.linearId diff --git a/Basic/build.gradle b/Basic/build.gradle new file mode 100644 index 00000000..3b0d2b58 --- /dev/null +++ b/Basic/build.gradle @@ -0,0 +1,8 @@ +plugins { + id 'base' +} + +wrapper { + gradleVersion = '7.4.2' + distributionType = Wrapper.DistributionType.BIN +} diff --git a/Basic/constants.properties b/Basic/constants.properties deleted file mode 100644 index 6425fb0b..00000000 --- a/Basic/constants.properties +++ /dev/null @@ -1,12 +0,0 @@ -cordaReleaseGroup=net.corda -cordaCoreReleaseGroup=net.corda -cordaVersion=4.8.5 -cordaCoreVersion=4.8.5 -gradlePluginsVersion=5.0.12 -kotlinVersion=1.2.71 -junitVersion=4.12 -quasarVersion=0.7.10 -log4jVersion =2.17.1 -platformVersion=10 -slf4jVersion=1.7.25 -nettyVersion=4.1.22.Final diff --git a/Basic/cordapp-example/build.gradle b/Basic/cordapp-example/build.gradle index 173c7362..08490762 100644 --- a/Basic/cordapp-example/build.gradle +++ b/Basic/cordapp-example/build.gradle @@ -1,126 +1,100 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/./constants.properties").withInputStream { constants.load(it) } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' +configurations { + ganache { + canBeConsumed = false + transitive = false } +} - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" + pluginManager.withPlugin('org.jetbrains.kotlin.plugin.allopen') { + allOpen { + annotations( + 'javax.persistence.Entity', + 'javax.persistence.Embeddable', + 'javax.persistence.MappedSuperclass' + ) + } } -} - -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } + def subPath = it.path + pluginManager.withPlugin('net.corda.plugins.cordapp') { + rootProject.dependencies { + ganache project(path: subPath, configuration: 'cordaCordapp') + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") - - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordapp project(':workflows') + cordapp project(':contracts') } //Task to build the jar for ganache. -task ganache { - subprojects { - if (it.project.name != "clients") { - dependsOn jar - doLast { - copy { - from "${buildDir}/libs" - into "${rootDir}/build/libs" - } - } +tasks.register('ganache') { + dependsOn configurations.ganache.buildDependencies + doLast { + copy { + from configurations.ganache + into layout.buildDirectory.dir('libs') } } } -//Task to deploy the nodes in order to bootstrap a network -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { - +tasks.register('deployNodes', Cordform) { /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load * the Corda network bootstrapper. */ nodeDefaults { - projectCordapp { - deploy = false - } - cordapp project(':contracts') cordapp project(':workflows') + cordapp project(':contracts') + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change //it to false for quicker project compiling time. @@ -133,6 +107,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { name "O=PartyA,L=London,C=GB" @@ -141,7 +116,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=PartyB,L=New York,C=US" @@ -150,7 +124,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } - } diff --git a/Basic/cordapp-example/clients/build.gradle b/Basic/cordapp-example/clients/build.gradle index 17d20a7f..672d2bc4 100644 --- a/Basic/cordapp-example/clients/build.gradle +++ b/Basic/cordapp-example/clients/build.gradle @@ -1,27 +1,29 @@ -apply plugin: 'org.springframework.boot' +plugins { + id 'org.springframework.boot' + id 'org.jetbrains.kotlin.jvm' +} sourceSets { main { resources { - srcDir rootProject.file("config/dev") + srcDir file("$rootDir/config/dev") } } } dependencies { // Corda dependencies. - compile "$corda_release_group:corda-rpc:$corda_release_version" - compile "net.corda:corda-jackson:$corda_release_version" + implementation "$corda_release_group:corda-rpc:$corda_release_version" + implementation "net.corda:corda-jackson:$corda_release_version" // CorDapp dependencies. - compile project(":contracts") - compile project(":workflows") - compile("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { + implementation project(':contracts') + implementation project(':workflows') + implementation("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { exclude group: "org.springframework.boot", module: "spring-boot-starter-logging" } - compile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - compile "org.apache.logging.log4j:log4j-web:${log4j_version}" - compile "org.slf4j:jul-to-slf4j:$slf4j_version" + runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" + runtimeOnly "org.apache.logging.log4j:log4j-web:$log4j_version" } @@ -33,7 +35,8 @@ springBoot { * execute your rpc methods in the main method of the client.kt. You can somewhat see this as a quick test of making * RPC calls to your nodes. */ -task runTestClient(type: JavaExec, dependsOn: assemble) { +tasks.register('runTestClient', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.example.ClientKt' args 'localhost:10006', 'user1', 'test' @@ -42,13 +45,15 @@ task runTestClient(type: JavaExec, dependsOn: assemble) { /* This task will start the springboot server that connects to your node (via RPC connection). All of the http requests * are in the Controller file. You can leave the Server.kt and NodeRPCConnection.kt file untouched for your use. */ -task runPartyAServer(type: JavaExec, dependsOn: assemble) { +tasks.register('runPartyAServer', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.example.webserver.ServerKt' args '--server.port=50005', '--config.rpc.host=localhost', '--config.rpc.port=10006', '--config.rpc.username=user1', '--config.rpc.password=test' } -task runPartyBServer(type: JavaExec, dependsOn: assemble) { +tasks.register('runPartyBServer', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.example.webserver.ServerKt' args '--server.port=50006', '--config.rpc.host=localhost', '--config.rpc.port=10009', '--config.rpc.username=user1', '--config.rpc.password=test' diff --git a/Basic/cordapp-example/constants.properties b/Basic/cordapp-example/constants.properties deleted file mode 100644 index 996bc7ee..00000000 --- a/Basic/cordapp-example/constants.properties +++ /dev/null @@ -1,12 +0,0 @@ -cordaReleaseGroup=net.corda -cordaCoreReleaseGroup=net.corda -cordaVersion=4.8.5 -cordaCoreVersion=4.8.5 -gradlePluginsVersion=5.0.12 -kotlinVersion=1.2.71 -junitVersion=4.12 -quasarVersion=0.7.10 -log4jVersion=2.17.1 -platformVersion=8 -slf4jVersion=1.7.25 -nettyVersion=4.1.22.Final diff --git a/Basic/cordapp-example/contracts/build.gradle b/Basic/cordapp-example/contracts/build.gradle index 45e6118f..17216e11 100644 --- a/Basic/cordapp-example/contracts/build.gradle +++ b/Basic/cordapp-example/contracts/build.gradle @@ -1,8 +1,13 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'net.corda.plugins.cordapp' + id 'org.jetbrains.kotlin.jvm' + id 'org.jetbrains.kotlin.plugin.jpa' + id 'org.jetbrains.kotlin.plugin.allopen' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "Example-Cordapp Contracts" vendor "Corda Open Source" @@ -12,8 +17,9 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Basic/cordapp-example/workflows/src/main/resources/migration/iou.changelog-master.xml b/Basic/cordapp-example/contracts/src/main/resources/migration/iou.changelog-master.xml similarity index 100% rename from Basic/cordapp-example/workflows/src/main/resources/migration/iou.changelog-master.xml rename to Basic/cordapp-example/contracts/src/main/resources/migration/iou.changelog-master.xml diff --git a/Basic/cordapp-example/workflows/src/main/resources/migration/iou.changelog-v1.xml b/Basic/cordapp-example/contracts/src/main/resources/migration/iou.changelog-v1.xml similarity index 100% rename from Basic/cordapp-example/workflows/src/main/resources/migration/iou.changelog-v1.xml rename to Basic/cordapp-example/contracts/src/main/resources/migration/iou.changelog-v1.xml diff --git a/Basic/cordapp-example/gradle.properties b/Basic/cordapp-example/gradle.properties index 7a118224..7b4bb27f 100644 --- a/Basic/cordapp-example/gradle.properties +++ b/Basic/cordapp-example/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Example Cordapp group=com.example version=1.0 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Basic/cordapp-example/gradle/wrapper/gradle-wrapper.jar b/Basic/cordapp-example/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Basic/cordapp-example/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Basic/cordapp-example/gradle/wrapper/gradle-wrapper.properties b/Basic/cordapp-example/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Basic/cordapp-example/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Basic/cordapp-example/gradlew b/Basic/cordapp-example/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Basic/cordapp-example/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Basic/cordapp-example/gradlew.bat b/Basic/cordapp-example/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Basic/cordapp-example/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Basic/cordapp-example/repositories.gradle b/Basic/cordapp-example/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Basic/cordapp-example/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Basic/cordapp-example/settings.gradle b/Basic/cordapp-example/settings.gradle index 2514aca2..47c41b8e 100644 --- a/Basic/cordapp-example/settings.gradle +++ b/Basic/cordapp-example/settings.gradle @@ -1,3 +1,38 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.jetbrains.kotlin.plugin.jpa' version kotlin_plugin_version + id 'org.jetbrains.kotlin.plugin.allopen' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file +include 'clients' diff --git a/Basic/cordapp-example/workflows/build.gradle b/Basic/cordapp-example/workflows/build.gradle index 980b9c22..e11fbe98 100644 --- a/Basic/cordapp-example/workflows/build.gradle +++ b/Basic/cordapp-example/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' + id 'org.jetbrains.kotlin.jvm' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "Example-Cordapp Flows" vendor "Corda Open Source" @@ -13,14 +16,9 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { - srcDir rootProject.file("config/test") + srcDir file("$rootDir/config/test") } } integrationTest { @@ -33,25 +31,24 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Basic/cordapp-example/workflows/src/test/kotlin/net/corda/samples/example/FlowTests.kt b/Basic/cordapp-example/workflows/src/test/kotlin/net/corda/samples/example/FlowTests.kt index f8e62814..965a76ee 100644 --- a/Basic/cordapp-example/workflows/src/test/kotlin/net/corda/samples/example/FlowTests.kt +++ b/Basic/cordapp-example/workflows/src/test/kotlin/net/corda/samples/example/FlowTests.kt @@ -36,7 +36,9 @@ class IOUFlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test @@ -123,4 +125,4 @@ class IOUFlowTests { } } } -} \ No newline at end of file +} diff --git a/Basic/flow-database-access/README.md b/Basic/flow-database-access/README.md index cd62a59c..2f059ab8 100644 --- a/Basic/flow-database-access/README.md +++ b/Basic/flow-database-access/README.md @@ -26,7 +26,7 @@ For development environment setup, please refer to: [Setup Guide](https://docs.c Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) ``` diff --git a/Basic/flow-database-access/build.gradle b/Basic/flow-database-access/build.gradle index be5150ed..42e000c8 100644 --- a/Basic/flow-database-access/build.gradle +++ b/Basic/flow-database-access/build.gradle @@ -1,96 +1,63 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") + cordapp project(':workflows') - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp project(':workflows') runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change @@ -103,7 +70,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - cordapps = [] rpcUsers = [[user: "user1", "password": "test", "permissions": [ "StartFlow.com.flowdb.AddTokenValueFlow", "StartFlow.com.flowdb.UpdateTokenValueFlow", diff --git a/Basic/flow-database-access/config/dev/log4j2.xml b/Basic/flow-database-access/config/dev/log4j2.xml deleted file mode 100644 index 34ba4d45..00000000 --- a/Basic/flow-database-access/config/dev/log4j2.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - logs - node-${hostName} - ${log-path}/archive - - - - - - - - - %highlight{%level{length=1} %d{HH:mm:ss} %T %c{1}.%M - %msg%n}{INFO=white,WARN=red,FATAL=bright red blink} - > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Basic/flow-database-access/config/test/log4j2-test.xml b/Basic/flow-database-access/config/test/log4j2-test.xml deleted file mode 100644 index a7697a38..00000000 --- a/Basic/flow-database-access/config/test/log4j2-test.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - build/logs - node-${hostName} - - - - - - - [%-5level] %d{HH:mm:ss.SSS} [%t] %c{1}.%M - %msg%n - > - - - - - - - - - - - - - - - - - diff --git a/Basic/flow-database-access/gradle.properties b/Basic/flow-database-access/gradle.properties index 5fadce58..abdd802a 100644 --- a/Basic/flow-database-access/gradle.properties +++ b/Basic/flow-database-access/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Flow Database Cordapp group=com.flowdb version=0.1 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Basic/flow-database-access/gradle/wrapper/gradle-wrapper.jar b/Basic/flow-database-access/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7a3265ee..00000000 Binary files a/Basic/flow-database-access/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Basic/flow-database-access/gradlew b/Basic/flow-database-access/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Basic/flow-database-access/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Basic/flow-database-access/gradlew.bat b/Basic/flow-database-access/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Basic/flow-database-access/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Basic/flow-database-access/lib/README.txt b/Basic/flow-database-access/lib/README.txt deleted file mode 100644 index b0592c95..00000000 --- a/Basic/flow-database-access/lib/README.txt +++ /dev/null @@ -1,8 +0,0 @@ -The Quasar.jar in this directory is for runtime instrumentation of classes by Quasar. - -When running corda outside of the given gradle building you must add the following flag with the -correct path to your call to Java: - - java -javaagent:path-to-quasar-jar.jar ... - -See the Quasar docs for more information: http://docs.paralleluniverse.co/quasar/ \ No newline at end of file diff --git a/Basic/flow-database-access/lib/quasar.jar b/Basic/flow-database-access/lib/quasar.jar deleted file mode 100644 index 7282d8c8..00000000 Binary files a/Basic/flow-database-access/lib/quasar.jar and /dev/null differ diff --git a/Basic/flow-database-access/settings.gradle b/Basic/flow-database-access/settings.gradle index 768052d4..5e80b832 100644 --- a/Basic/flow-database-access/settings.gradle +++ b/Basic/flow-database-access/settings.gradle @@ -1 +1,34 @@ -include 'workflows' \ No newline at end of file +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + +include 'workflows' diff --git a/Basic/flow-database-access/workflows/build.gradle b/Basic/flow-database-access/workflows/build.gradle index 4c07acad..24492053 100644 --- a/Basic/flow-database-access/workflows/build.gradle +++ b/Basic/flow-database-access/workflows/build.gradle @@ -1,29 +1,7 @@ -apply plugin: 'kotlin' -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -jar { - // CorDapps do not configure the Node's logging. - exclude '**/log4j2*.xml' -} - -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} - -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { - kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" - javaParameters = true // Useful for reflection. - } +plugins { + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' + id 'org.jetbrains.kotlin.jvm' } cordapp { @@ -38,18 +16,15 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaCompile "$corda_release_group:corda-jackson:$corda_release_version" - cordaCompile "$corda_release_group:corda-rpc:$corda_release_version" - cordaCompile "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" + cordaProvided "$corda_release_group:corda-jackson:$corda_release_version" + cordaProvided "$corda_release_group:corda-rpc:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" - cordaRuntime "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testRuntimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" } - diff --git a/Basic/flow-database-access/workflows/src/test/kotlin/net/corda/samples/flowdb/FlowTests.kt b/Basic/flow-database-access/workflows/src/test/kotlin/net/corda/samples/flowdb/FlowTests.kt index 25dbc606..1cb524e4 100644 --- a/Basic/flow-database-access/workflows/src/test/kotlin/net/corda/samples/flowdb/FlowTests.kt +++ b/Basic/flow-database-access/workflows/src/test/kotlin/net/corda/samples/flowdb/FlowTests.kt @@ -32,7 +32,9 @@ class FlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test diff --git a/Basic/flow-database-access/workflows/src/main/resources/log4j2-test.xml b/Basic/flow-database-access/workflows/src/test/resources/log4j2-test.xml similarity index 100% rename from Basic/flow-database-access/workflows/src/main/resources/log4j2-test.xml rename to Basic/flow-database-access/workflows/src/test/resources/log4j2-test.xml diff --git a/Basic/flow-http-access/README.md b/Basic/flow-http-access/README.md index c33c266c..8e2e8934 100644 --- a/Basic/flow-http-access/README.md +++ b/Basic/flow-http-access/README.md @@ -54,7 +54,7 @@ For development environment setup, please refer to: [Setup Guide](https://docs.c Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) ``` diff --git a/Basic/flow-http-access/build.gradle b/Basic/flow-http-access/build.gradle index 32a36aa1..a0c487c5 100644 --- a/Basic/flow-http-access/build.gradle +++ b/Basic/flow-http-access/build.gradle @@ -1,105 +1,63 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - okhttp_version = '3.5.0' - - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") + cordapp project(':workflows') - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } - -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load * the Corda network bootstrapper. */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp project(':workflows') runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change @@ -112,7 +70,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - cordapps = [] rpcUsers = [[ user: "user1", "password": "test", "permissions": ["StartFlow.com.flowhttp.HttpCallFlow"]]] } } diff --git a/Basic/flow-http-access/config/dev/log4j2.xml b/Basic/flow-http-access/config/dev/log4j2.xml deleted file mode 100644 index 34ba4d45..00000000 --- a/Basic/flow-http-access/config/dev/log4j2.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - logs - node-${hostName} - ${log-path}/archive - - - - - - - - - %highlight{%level{length=1} %d{HH:mm:ss} %T %c{1}.%M - %msg%n}{INFO=white,WARN=red,FATAL=bright red blink} - > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Basic/flow-http-access/config/test/log4j2-test.xml b/Basic/flow-http-access/config/test/log4j2-test.xml deleted file mode 100644 index a7697a38..00000000 --- a/Basic/flow-http-access/config/test/log4j2-test.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - build/logs - node-${hostName} - - - - - - - [%-5level] %d{HH:mm:ss.SSS} [%t] %c{1}.%M - %msg%n - > - - - - - - - - - - - - - - - - - diff --git a/Basic/flow-http-access/gradle.properties b/Basic/flow-http-access/gradle.properties index 751cf8cf..849500eb 100644 --- a/Basic/flow-http-access/gradle.properties +++ b/Basic/flow-http-access/gradle.properties @@ -1,4 +1,28 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Flow Http Access group=com.flowhttp version=1.0 -kotlin.incremental=false \ No newline at end of file + +okhttp_version=3.5.0 + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Basic/flow-http-access/gradle/wrapper/gradle-wrapper.jar b/Basic/flow-http-access/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7a3265ee..00000000 Binary files a/Basic/flow-http-access/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Basic/flow-http-access/gradlew b/Basic/flow-http-access/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Basic/flow-http-access/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Basic/flow-http-access/gradlew.bat b/Basic/flow-http-access/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Basic/flow-http-access/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Basic/flow-http-access/lib/README.txt b/Basic/flow-http-access/lib/README.txt deleted file mode 100644 index b0592c95..00000000 --- a/Basic/flow-http-access/lib/README.txt +++ /dev/null @@ -1,8 +0,0 @@ -The Quasar.jar in this directory is for runtime instrumentation of classes by Quasar. - -When running corda outside of the given gradle building you must add the following flag with the -correct path to your call to Java: - - java -javaagent:path-to-quasar-jar.jar ... - -See the Quasar docs for more information: http://docs.paralleluniverse.co/quasar/ \ No newline at end of file diff --git a/Basic/flow-http-access/lib/quasar.jar b/Basic/flow-http-access/lib/quasar.jar deleted file mode 100644 index 7282d8c8..00000000 Binary files a/Basic/flow-http-access/lib/quasar.jar and /dev/null differ diff --git a/Basic/flow-http-access/repositories.gradle b/Basic/flow-http-access/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Basic/flow-http-access/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Basic/flow-http-access/settings.gradle b/Basic/flow-http-access/settings.gradle index 768052d4..5e80b832 100644 --- a/Basic/flow-http-access/settings.gradle +++ b/Basic/flow-http-access/settings.gradle @@ -1 +1,34 @@ -include 'workflows' \ No newline at end of file +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + +include 'workflows' diff --git a/Basic/flow-http-access/workflows/build.gradle b/Basic/flow-http-access/workflows/build.gradle index d015dec8..3a0ce086 100644 --- a/Basic/flow-http-access/workflows/build.gradle +++ b/Basic/flow-http-access/workflows/build.gradle @@ -1,9 +1,8 @@ -apply plugin: 'kotlin' -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -apply from: '../repositories.gradle' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -17,25 +16,18 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaCompile "$corda_release_group:corda-jackson:$corda_release_version" - cordaCompile "$corda_release_group:corda-rpc:$corda_release_version" - cordaCompile "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" + cordaProvided "$corda_release_group:corda-jackson:$corda_release_version" + cordaProvided "$corda_release_group:corda-rpc:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" - cordaRuntime "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testRuntimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" // OkHTTP: A simple HTTP library. - compile "com.squareup.okhttp3:okhttp:$okhttp_version" -} - -jar { - // CorDapps do not configure the Node's logging. - exclude '**/log4j2*.xml' + implementation "com.squareup.okhttp3:okhttp:$okhttp_version" } diff --git a/Basic/flow-http-access/workflows/src/test/kotlin/net/corda/samples/flowhttp/FlowTests.kt b/Basic/flow-http-access/workflows/src/test/kotlin/net/corda/samples/flowhttp/FlowTests.kt index 3b8b4739..eb6a2ee9 100644 --- a/Basic/flow-http-access/workflows/src/test/kotlin/net/corda/samples/flowhttp/FlowTests.kt +++ b/Basic/flow-http-access/workflows/src/test/kotlin/net/corda/samples/flowhttp/FlowTests.kt @@ -27,7 +27,9 @@ class FlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test diff --git a/Basic/flow-http-access/workflows/src/main/resources/log4j2-test.xml b/Basic/flow-http-access/workflows/src/test/resources/log4j2-test.xml similarity index 100% rename from Basic/flow-http-access/workflows/src/main/resources/log4j2-test.xml rename to Basic/flow-http-access/workflows/src/test/resources/log4j2-test.xml diff --git a/Basic/gradle/wrapper/gradle-wrapper.jar b/Basic/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..41d9927a Binary files /dev/null and b/Basic/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Basic/flow-http-access/gradle/wrapper/gradle-wrapper.properties b/Basic/gradle/wrapper/gradle-wrapper.properties similarity index 92% rename from Basic/flow-http-access/gradle/wrapper/gradle-wrapper.properties rename to Basic/gradle/wrapper/gradle-wrapper.properties index d757f3d3..aa991fce 100644 --- a/Basic/flow-http-access/gradle/wrapper/gradle-wrapper.properties +++ b/Basic/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/Basic/gradlew b/Basic/gradlew new file mode 100755 index 00000000..1b6c7873 --- /dev/null +++ b/Basic/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/Accounts/supplychain/gradlew.bat b/Basic/gradlew.bat similarity index 66% rename from Accounts/supplychain/gradlew.bat rename to Basic/gradlew.bat index f9553162..107acd32 100644 --- a/Accounts/supplychain/gradlew.bat +++ b/Basic/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/Basic/ping-pong/README.md b/Basic/ping-pong/README.md index 35552db2..3526e132 100644 --- a/Basic/ping-pong/README.md +++ b/Basic/ping-pong/README.md @@ -63,7 +63,7 @@ For development environment setup, please refer to: [Setup Guide](https://docs.c Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) ``` diff --git a/Basic/ping-pong/build.gradle b/Basic/ping-pong/build.gradle index 94bd0ef8..112ba3cf 100644 --- a/Basic/ping-pong/build.gradle +++ b/Basic/ping-pong/build.gradle @@ -1,107 +1,56 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. - } - } - - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") + cordapp project(':workflows') - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load * the Corda network bootstrapper. */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp project(':workflows') + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change //it to false for quicker project compiling time. @@ -114,6 +63,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { name "O=PartyA,L=London,C=GB" @@ -122,7 +72,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=PartyB,L=New York,C=US" @@ -131,6 +80,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] } } diff --git a/Basic/ping-pong/client/build.gradle b/Basic/ping-pong/client/build.gradle index 296c9563..119e4587 100644 --- a/Basic/ping-pong/client/build.gradle +++ b/Basic/ping-pong/client/build.gradle @@ -1,33 +1,28 @@ -apply plugin: 'org.springframework.boot' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'org.springframework.boot' } dependencies { // Corda dependencies. - compile "$corda_release_group:corda-rpc:$corda_release_version" + implementation "$corda_release_group:corda-rpc:$corda_release_version" // CorDapp dependencies. - compile project(":workflows") - compile("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { - exclude group: "org.springframework.boot", module: "spring-boot-starter-logging" + implementation project(':workflows') + implementation("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { + exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' } - compile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - compile "org.apache.logging.log4j:log4j-web:${log4j_version}" - compile "org.slf4j:jul-to-slf4j:$slf4j_version" + runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" + runtimeOnly "org.apache.logging.log4j:log4j-web:$log4j_version" } /* The Client is the communication channel between the external and the node. This task will help you immediately * execute your rpc methods in the main method of the client.kt. You can somewhat see this as a quick test of making * RPC calls to your nodes. */ -task pingPartyBKotlin(type: JavaExec, dependsOn: assemble) { +tasks.register('pingPartyBKotlin', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.pingpong.ClientKt' args 'localhost:10006', 'O=PartyB,L=New York,C=US' -} \ No newline at end of file +} diff --git a/Basic/ping-pong/config/dev/log4j2.xml b/Basic/ping-pong/config/dev/log4j2.xml deleted file mode 100644 index 34ba4d45..00000000 --- a/Basic/ping-pong/config/dev/log4j2.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - logs - node-${hostName} - ${log-path}/archive - - - - - - - - - %highlight{%level{length=1} %d{HH:mm:ss} %T %c{1}.%M - %msg%n}{INFO=white,WARN=red,FATAL=bright red blink} - > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Basic/ping-pong/config/test/log4j2-test.xml b/Basic/ping-pong/config/test/log4j2-test.xml deleted file mode 100644 index a7697a38..00000000 --- a/Basic/ping-pong/config/test/log4j2-test.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - build/logs - node-${hostName} - - - - - - - [%-5level] %d{HH:mm:ss.SSS} [%t] %c{1}.%M - %msg%n - > - - - - - - - - - - - - - - - - - diff --git a/Basic/ping-pong/gradle.properties b/Basic/ping-pong/gradle.properties index 3a0ea857..228d081a 100644 --- a/Basic/ping-pong/gradle.properties +++ b/Basic/ping-pong/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=ping-pong Cordapp group=com.pingpong version=1.0 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Basic/ping-pong/gradle/wrapper/gradle-wrapper.jar b/Basic/ping-pong/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7a3265ee..00000000 Binary files a/Basic/ping-pong/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Basic/ping-pong/gradlew b/Basic/ping-pong/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Basic/ping-pong/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Basic/ping-pong/gradlew.bat b/Basic/ping-pong/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Basic/ping-pong/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Basic/ping-pong/lib/README.txt b/Basic/ping-pong/lib/README.txt deleted file mode 100644 index b0592c95..00000000 --- a/Basic/ping-pong/lib/README.txt +++ /dev/null @@ -1,8 +0,0 @@ -The Quasar.jar in this directory is for runtime instrumentation of classes by Quasar. - -When running corda outside of the given gradle building you must add the following flag with the -correct path to your call to Java: - - java -javaagent:path-to-quasar-jar.jar ... - -See the Quasar docs for more information: http://docs.paralleluniverse.co/quasar/ \ No newline at end of file diff --git a/Basic/ping-pong/lib/quasar.jar b/Basic/ping-pong/lib/quasar.jar deleted file mode 100644 index 7282d8c8..00000000 Binary files a/Basic/ping-pong/lib/quasar.jar and /dev/null differ diff --git a/Basic/ping-pong/repositories.gradle b/Basic/ping-pong/repositories.gradle deleted file mode 100644 index 117d8a1e..00000000 --- a/Basic/ping-pong/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} \ No newline at end of file diff --git a/Basic/ping-pong/settings.gradle b/Basic/ping-pong/settings.gradle index 116206b9..a8bdb453 100644 --- a/Basic/ping-pong/settings.gradle +++ b/Basic/ping-pong/settings.gradle @@ -1,2 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'client' diff --git a/Basic/ping-pong/workflows/build.gradle b/Basic/ping-pong/workflows/build.gradle index f97ab26e..4e24ecb5 100644 --- a/Basic/ping-pong/workflows/build.gradle +++ b/Basic/ping-pong/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "PingPong Flows" vendor "Corda Open Source" @@ -13,16 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } - test { - resources { - srcDir rootProject.file("config/test") - } - } integrationTest { kotlin { compileClasspath += main.output + test.output @@ -33,22 +26,21 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Basic/settings.gradle b/Basic/settings.gradle new file mode 100644 index 00000000..1b93b12f --- /dev/null +++ b/Basic/settings.gradle @@ -0,0 +1,5 @@ +includeBuild 'cordapp-example' +includeBuild 'flow-database-access' +includeBuild 'flow-http-access' +includeBuild 'ping-pong' +includeBuild 'tutorial-applestamp' diff --git a/Basic/tutorial-applestamp/build.gradle b/Basic/tutorial-applestamp/build.gradle index 891cc71e..c80c07f9 100644 --- a/Basic/tutorial-applestamp/build.gradle +++ b/Basic/tutorial-applestamp/build.gradle @@ -1,113 +1,65 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } - //SDK lib - maven { url 'https://software.r3.com/artifactory/corda-lib' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") - - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" - + cordapp project(':workflows') + cordapp project(':contracts') } -//Task to deploy the nodes in order to bootstrap a network -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load * the Corda network bootstrapper. */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp project(':contracts') cordapp project(':workflows') + rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change //it to false for quicker project compiling time. @@ -120,6 +72,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { name "O=AppleFarm,L=London,C=GB" @@ -128,7 +81,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=Peter,L=New York,C=US" @@ -137,7 +89,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } - } diff --git a/Basic/tutorial-applestamp/config/dev/log4j2.xml b/Basic/tutorial-applestamp/config/dev/log4j2.xml deleted file mode 100644 index 34ba4d45..00000000 --- a/Basic/tutorial-applestamp/config/dev/log4j2.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - logs - node-${hostName} - ${log-path}/archive - - - - - - - - - %highlight{%level{length=1} %d{HH:mm:ss} %T %c{1}.%M - %msg%n}{INFO=white,WARN=red,FATAL=bright red blink} - > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Basic/tutorial-applestamp/contracts/build.gradle b/Basic/tutorial-applestamp/contracts/build.gradle index b3b0e7ea..1afe8901 100644 --- a/Basic/tutorial-applestamp/contracts/build.gradle +++ b/Basic/tutorial-applestamp/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "4.8LTS Tutorial Contracts" vendor "Corda Open Source" @@ -12,8 +15,7 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" } diff --git a/Basic/tutorial-applestamp/gradle.properties b/Basic/tutorial-applestamp/gradle.properties index 083c23da..d074856e 100644 --- a/Basic/tutorial-applestamp/gradle.properties +++ b/Basic/tutorial-applestamp/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Test group=com.tutorial version=0.1 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Basic/tutorial-applestamp/gradle/wrapper/gradle-wrapper.jar b/Basic/tutorial-applestamp/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Basic/tutorial-applestamp/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Basic/tutorial-applestamp/gradle/wrapper/gradle-wrapper.properties b/Basic/tutorial-applestamp/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Basic/tutorial-applestamp/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Basic/tutorial-applestamp/gradlew b/Basic/tutorial-applestamp/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Basic/tutorial-applestamp/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Basic/tutorial-applestamp/gradlew.bat b/Basic/tutorial-applestamp/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Basic/tutorial-applestamp/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Basic/tutorial-applestamp/repositories.gradle b/Basic/tutorial-applestamp/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Basic/tutorial-applestamp/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Basic/tutorial-applestamp/settings.gradle b/Basic/tutorial-applestamp/settings.gradle index 2514aca2..c1f46514 100644 --- a/Basic/tutorial-applestamp/settings.gradle +++ b/Basic/tutorial-applestamp/settings.gradle @@ -1,3 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file diff --git a/Basic/tutorial-applestamp/workflows/build.gradle b/Basic/tutorial-applestamp/workflows/build.gradle index 4d4e0e69..089fdd70 100644 --- a/Basic/tutorial-applestamp/workflows/build.gradle +++ b/Basic/tutorial-applestamp/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "4.8LTS Tutorial Flows" vendor "Corda Open Source" @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,25 +31,25 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testRuntimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/BusinessNetworks/build.gradle b/BusinessNetworks/build.gradle new file mode 100644 index 00000000..3b0d2b58 --- /dev/null +++ b/BusinessNetworks/build.gradle @@ -0,0 +1,8 @@ +plugins { + id 'base' +} + +wrapper { + gradleVersion = '7.4.2' + distributionType = Wrapper.DistributionType.BIN +} diff --git a/BusinessNetworks/constants.properties b/BusinessNetworks/constants.properties deleted file mode 100644 index 0e908f05..00000000 --- a/BusinessNetworks/constants.properties +++ /dev/null @@ -1,13 +0,0 @@ -cordaReleaseGroup=net.corda -cordaCoreReleaseGroup=net.corda -cordaVersion=4.8.5 -cordaCoreVersion=4.8.5 -gradlePluginsVersion=5.0.12 -kotlinVersion=1.2.71 -junitVersion=4.12 -quasarVersion=0.7.10 -log4jVersion =2.17.1 -platformVersion=10 -slf4jVersion=1.7.25 -nettyVersion=4.1.22.Final -corda_bn_extension_version=1.1-RC03 diff --git a/BusinessNetworks/gradle/wrapper/gradle-wrapper.jar b/BusinessNetworks/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..41d9927a Binary files /dev/null and b/BusinessNetworks/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Basic/ping-pong/gradle/wrapper/gradle-wrapper.properties b/BusinessNetworks/gradle/wrapper/gradle-wrapper.properties similarity index 92% rename from Basic/ping-pong/gradle/wrapper/gradle-wrapper.properties rename to BusinessNetworks/gradle/wrapper/gradle-wrapper.properties index d757f3d3..aa991fce 100644 --- a/Basic/ping-pong/gradle/wrapper/gradle-wrapper.properties +++ b/BusinessNetworks/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/BusinessNetworks/gradlew b/BusinessNetworks/gradlew new file mode 100755 index 00000000..1b6c7873 --- /dev/null +++ b/BusinessNetworks/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/Advanced/duediligence-cordapp/gradlew.bat b/BusinessNetworks/gradlew.bat similarity index 66% rename from Advanced/duediligence-cordapp/gradlew.bat rename to BusinessNetworks/gradlew.bat index f9553162..107acd32 100644 --- a/Advanced/duediligence-cordapp/gradlew.bat +++ b/BusinessNetworks/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/BusinessNetworks/insurancebusinessnetwork/README.md b/BusinessNetworks/insurancebusinessnetwork/README.md index b349328d..1beafaeb 100644 --- a/BusinessNetworks/insurancebusinessnetwork/README.md +++ b/BusinessNetworks/insurancebusinessnetwork/README.md @@ -33,7 +33,7 @@ The NetworkOperator will be create and primarily manage the network. As introduc Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) ``` @@ -41,7 +41,7 @@ Then type: (to run the nodes) ``` #### Interacting with the CorDapp -**Step 1:** Create the network in NetwprkOperator's terminal +**Step 1:** Create the network in NetworkOperator's terminal ``` flow start CreateNetwork ``` diff --git a/BusinessNetworks/insurancebusinessnetwork/build.gradle b/BusinessNetworks/insurancebusinessnetwork/build.gradle index af158df1..6efc7cf6 100644 --- a/BusinessNetworks/insurancebusinessnetwork/build.gradle +++ b/BusinessNetworks/insurancebusinessnetwork/build.gradle @@ -1,133 +1,70 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - //Membership Attestation - corda_bn_extension_version=constants.getProperty("corda_bn_extension_version") - - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") - cordapp("net.corda.bn:business-networks-contracts:$corda_bn_extension_version") - cordapp("net.corda.bn:business-networks-workflows:$corda_bn_extension_version") + cordapp project(':workflows') + cordapp project(':contracts') + cordapp "net.corda.bn:business-networks-contracts:$corda_bn_extension_version" + cordapp "net.corda.bn:business-networks-workflows:$corda_bn_extension_version" - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -//Task to build the jar for ganache. -task ganache { - subprojects { - if (it.project.name != "clients") { - dependsOn jar - doLast { - copy { - from "${buildDir}/libs" - into "${rootDir}/build/libs" - } - } - } - } -} - -//Task to deploy the nodes in order to bootstrap a network -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { - +tasks.register('deployNodes', Cordform) { /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load * the Corda network bootstrapper. */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp project(':contracts') cordapp project(':workflows') - cordapp("net.corda.bn:business-networks-contracts:$corda_bn_extension_version") - cordapp("net.corda.bn:business-networks-workflows:$corda_bn_extension_version") + cordapp "net.corda.bn:business-networks-contracts:$corda_bn_extension_version" + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change //it to false for quicker project compiling time. @@ -140,6 +77,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { name "O=NetworkOperator,L=London,C=GB" @@ -148,7 +86,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=Insurance,L=New York,C=US" @@ -157,7 +94,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=CarePro,L=New York,C=US" @@ -166,7 +102,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10012") adminAddress("localhost:10052") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } - } diff --git a/BusinessNetworks/insurancebusinessnetwork/contracts/build.gradle b/BusinessNetworks/insurancebusinessnetwork/contracts/build.gradle index 9ceb88c2..8255c545 100644 --- a/BusinessNetworks/insurancebusinessnetwork/contracts/build.gradle +++ b/BusinessNetworks/insurancebusinessnetwork/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "Example-Cordapp Contracts" vendor "Corda Open Source" @@ -12,10 +15,12 @@ cordapp { } dependencies { - cordapp("net.corda.bn:business-networks-contracts:$corda_bn_extension_version") + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" + + cordapp "net.corda.bn:business-networks-contracts:$corda_bn_extension_version" } diff --git a/BusinessNetworks/insurancebusinessnetwork/contracts/src/main/kotlin/net/corda/samples/businessmembership/contracts/InsuranceStateContract.kt b/BusinessNetworks/insurancebusinessnetwork/contracts/src/main/kotlin/net/corda/samples/businessmembership/contracts/InsuranceStateContract.kt index ac0f82e6..17fd4003 100644 --- a/BusinessNetworks/insurancebusinessnetwork/contracts/src/main/kotlin/net/corda/samples/businessmembership/contracts/InsuranceStateContract.kt +++ b/BusinessNetworks/insurancebusinessnetwork/contracts/src/main/kotlin/net/corda/samples/businessmembership/contracts/InsuranceStateContract.kt @@ -20,11 +20,10 @@ class InsuranceStateContract : Contract { override fun verify(tx: LedgerTransaction) { val command = tx.commands.requireSingleCommand() - val output = if (tx.outputStates.isNotEmpty()) tx.outputs.single() else null - val outputState = output?.data as? InsuranceState + val output = tx.outputsOfType().single() when (command.value) { - is Commands.Issue -> verifyIssue(tx,outputState!!.networkId, outputState.insurer, outputState.careProvider) + is Commands.Issue -> verifyIssue(tx, output.networkId, output.insurer, output.careProvider) else -> throw IllegalArgumentException("Unsupported command ${command.value}") } } diff --git a/BusinessNetworks/insurancebusinessnetwork/contracts/src/test/kotlin/net/corda/samples/businessmembership/contracts/ContractTests.kt b/BusinessNetworks/insurancebusinessnetwork/contracts/src/test/kotlin/net/corda/samples/businessmembership/contracts/ContractTests.kt index 82c0736f..07c24386 100644 --- a/BusinessNetworks/insurancebusinessnetwork/contracts/src/test/kotlin/net/corda/samples/businessmembership/contracts/ContractTests.kt +++ b/BusinessNetworks/insurancebusinessnetwork/contracts/src/test/kotlin/net/corda/samples/businessmembership/contracts/ContractTests.kt @@ -5,16 +5,13 @@ import net.corda.core.identity.CordaX500Name import net.corda.samples.businessmembership.states.InsuranceState import net.corda.testing.core.TestIdentity import net.corda.testing.node.MockServices +import net.corda.testing.node.ledger import org.junit.Test -import java.util.Arrays -import net.corda.testing.node.* - class ContractTests { - private val ledgerServices = MockServices( - Arrays.asList("net.corda.samples.businessmembership.contracts")) - var alice = TestIdentity(CordaX500Name("Alice", "TestLand", "US")) - var bob = TestIdentity(CordaX500Name("Bob", "TestLand", "US")) + private val ledgerServices = MockServices(listOf("net.corda.samples.businessmembership.contracts")) + private val alice = TestIdentity(CordaX500Name("Alice", "TestLand", "US")) + private val bob = TestIdentity(CordaX500Name("Bob", "TestLand", "US")) @Test fun failsDueToParticipantsAreNotNetworkMembers() { @@ -27,4 +24,4 @@ class ContractTests { } } } -} \ No newline at end of file +} diff --git a/BusinessNetworks/insurancebusinessnetwork/contracts/src/test/kotlin/net/corda/samples/businessmembership/contracts/StateTests.kt b/BusinessNetworks/insurancebusinessnetwork/contracts/src/test/kotlin/net/corda/samples/businessmembership/contracts/StateTests.kt index 281dc6cf..0d2c6827 100644 --- a/BusinessNetworks/insurancebusinessnetwork/contracts/src/test/kotlin/net/corda/samples/businessmembership/contracts/StateTests.kt +++ b/BusinessNetworks/insurancebusinessnetwork/contracts/src/test/kotlin/net/corda/samples/businessmembership/contracts/StateTests.kt @@ -1,14 +1,11 @@ package net.corda.samples.businessmembership.contracts -import groovy.util.GroovyTestCase.assertEquals import net.corda.core.identity.Party import net.corda.samples.businessmembership.states.InsuranceState -import net.corda.testing.node.MockServices +import org.junit.Assert.assertEquals import org.junit.Test class StateTests { - private val ledgerServices = MockServices() - @Test fun hasFieldOfCorrectType() { // Does the message field exist? @@ -16,4 +13,4 @@ class StateTests { // Is the message field of the correct type? assertEquals(InsuranceState::class.java.getDeclaredField("insurer").type, Party::class.java) } -} \ No newline at end of file +} diff --git a/BusinessNetworks/insurancebusinessnetwork/gradle.properties b/BusinessNetworks/insurancebusinessnetwork/gradle.properties index 7ad8399f..32ddb534 100644 --- a/BusinessNetworks/insurancebusinessnetwork/gradle.properties +++ b/BusinessNetworks/insurancebusinessnetwork/gradle.properties @@ -1,4 +1,28 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Membership Attestation Cordapp group=net.corda.samples version=1.0 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +corda_bn_extension_version=1.1-RC03 + +spring_boot_version=2.0.2.RELEASE diff --git a/BusinessNetworks/insurancebusinessnetwork/gradle/wrapper/gradle-wrapper.jar b/BusinessNetworks/insurancebusinessnetwork/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/BusinessNetworks/insurancebusinessnetwork/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/BusinessNetworks/insurancebusinessnetwork/gradle/wrapper/gradle-wrapper.properties b/BusinessNetworks/insurancebusinessnetwork/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/BusinessNetworks/insurancebusinessnetwork/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/BusinessNetworks/insurancebusinessnetwork/gradlew b/BusinessNetworks/insurancebusinessnetwork/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/BusinessNetworks/insurancebusinessnetwork/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/BusinessNetworks/insurancebusinessnetwork/gradlew.bat b/BusinessNetworks/insurancebusinessnetwork/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/BusinessNetworks/insurancebusinessnetwork/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/BusinessNetworks/insurancebusinessnetwork/repositories.gradle b/BusinessNetworks/insurancebusinessnetwork/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/BusinessNetworks/insurancebusinessnetwork/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/BusinessNetworks/insurancebusinessnetwork/settings.gradle b/BusinessNetworks/insurancebusinessnetwork/settings.gradle index b4446eaf..45f64fa3 100644 --- a/BusinessNetworks/insurancebusinessnetwork/settings.gradle +++ b/BusinessNetworks/insurancebusinessnetwork/settings.gradle @@ -1,2 +1,38 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url "$artifactoryContextUrl/corda-lib" + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' -include 'contracts' \ No newline at end of file +include 'contracts' diff --git a/BusinessNetworks/insurancebusinessnetwork/workflows/build.gradle b/BusinessNetworks/insurancebusinessnetwork/workflows/build.gradle index 183dd97a..3685918f 100644 --- a/BusinessNetworks/insurancebusinessnetwork/workflows/build.gradle +++ b/BusinessNetworks/insurancebusinessnetwork/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "Example-Cordapp Flows" vendor "Corda Open Source" @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,28 +31,25 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. cordapp project(":contracts") - cordapp("net.corda.bn:business-networks-contracts:$corda_bn_extension_version") - cordapp("net.corda.bn:business-networks-workflows:$corda_bn_extension_version") - + cordapp "net.corda.bn:business-networks-contracts:$corda_bn_extension_version" + cordapp "net.corda.bn:business-networks-workflows:$corda_bn_extension_version" } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/BusinessNetworks/insurancebusinessnetwork/workflows/src/integrationTest/kotlin/net/corda/samples/businessmembership/DriverBasedTest.kt b/BusinessNetworks/insurancebusinessnetwork/workflows/src/integrationTest/kotlin/net/corda/samples/businessmembership/DriverBasedTest.kt index 847abfb9..dad04181 100644 --- a/BusinessNetworks/insurancebusinessnetwork/workflows/src/integrationTest/kotlin/net/corda/samples/businessmembership/DriverBasedTest.kt +++ b/BusinessNetworks/insurancebusinessnetwork/workflows/src/integrationTest/kotlin/net/corda/samples/businessmembership/DriverBasedTest.kt @@ -7,9 +7,9 @@ import net.corda.testing.driver.DriverDSL import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.driver +import org.junit.Assert.assertEquals import org.junit.Test import java.util.concurrent.Future -import kotlin.test.assertEquals class DriverBasedTest { private val bankA = TestIdentity(CordaX500Name("BankA", "", "GB")) diff --git a/BusinessNetworks/insurancebusinessnetwork/workflows/src/main/kotlin/net/corda/samples/businessmembership/flows/membershipFlows/ActiveMembers.kt b/BusinessNetworks/insurancebusinessnetwork/workflows/src/main/kotlin/net/corda/samples/businessmembership/flows/membershipFlows/ActiveMembers.kt index fbf616ed..aaeddfe2 100644 --- a/BusinessNetworks/insurancebusinessnetwork/workflows/src/main/kotlin/net/corda/samples/businessmembership/flows/membershipFlows/ActiveMembers.kt +++ b/BusinessNetworks/insurancebusinessnetwork/workflows/src/main/kotlin/net/corda/samples/businessmembership/flows/membershipFlows/ActiveMembers.kt @@ -8,7 +8,7 @@ import net.corda.core.flows.StartableByRPC import net.corda.core.identity.CordaX500Name @StartableByRPC -class ActiveMembers(val membershipId: UniqueIdentifier): FlowLogic() { +class ActiveMembers(private val membershipId: UniqueIdentifier): FlowLogic() { @Suspendable override fun call(): String { diff --git a/BusinessNetworks/insurancebusinessnetwork/workflows/src/main/kotlin/net/corda/samples/businessmembership/flows/membershipFlows/RequestMembership.kt b/BusinessNetworks/insurancebusinessnetwork/workflows/src/main/kotlin/net/corda/samples/businessmembership/flows/membershipFlows/RequestMembership.kt index e0fa5a70..e9d7c09e 100644 --- a/BusinessNetworks/insurancebusinessnetwork/workflows/src/main/kotlin/net/corda/samples/businessmembership/flows/membershipFlows/RequestMembership.kt +++ b/BusinessNetworks/insurancebusinessnetwork/workflows/src/main/kotlin/net/corda/samples/businessmembership/flows/membershipFlows/RequestMembership.kt @@ -7,11 +7,11 @@ import net.corda.core.flows.StartableByRPC import net.corda.core.identity.Party @StartableByRPC -class RequestMembership(val authorisedParty: Party, val networkId: String) : FlowLogic() { +class RequestMembership(private val authorisedParty: Party, private val networkId: String) : FlowLogic() { @Suspendable override fun call(): String { - subFlow(RequestMembershipFlow(this.authorisedParty,this.networkId,null,null)) - return "\nRequest membership sent from [${ourIdentity.name.organisation}] nodes (ourself) to an authorized network member [${this.authorisedParty.name.organisation}]" + subFlow(RequestMembershipFlow(authorisedParty, networkId,null, null)) + return "\nRequest membership sent from [${ourIdentity.name.organisation}] nodes (ourself) to an authorized network member [${authorisedParty.name.organisation}]" } } //flow start RequestMembership authorisedParty: NetworkOperator, networkId: \ No newline at end of file diff --git a/BusinessNetworks/insurancebusinessnetwork/workflows/src/main/resources/migration/iou.changelog-master.xml b/BusinessNetworks/insurancebusinessnetwork/workflows/src/main/resources/migration/iou.changelog-master.xml deleted file mode 100644 index 32b4d1dd..00000000 --- a/BusinessNetworks/insurancebusinessnetwork/workflows/src/main/resources/migration/iou.changelog-master.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/BusinessNetworks/insurancebusinessnetwork/workflows/src/main/resources/migration/iou.changelog-v1.xml b/BusinessNetworks/insurancebusinessnetwork/workflows/src/main/resources/migration/iou.changelog-v1.xml deleted file mode 100644 index 660d7b3a..00000000 --- a/BusinessNetworks/insurancebusinessnetwork/workflows/src/main/resources/migration/iou.changelog-v1.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/BusinessNetworks/insurancebusinessnetwork/workflows/src/test/kotlin/net/corda/samples/businessmembership/FlowTests.kt b/BusinessNetworks/insurancebusinessnetwork/workflows/src/test/kotlin/net/corda/samples/businessmembership/FlowTests.kt index 7be9bb9b..66859ab5 100644 --- a/BusinessNetworks/insurancebusinessnetwork/workflows/src/test/kotlin/net/corda/samples/businessmembership/FlowTests.kt +++ b/BusinessNetworks/insurancebusinessnetwork/workflows/src/test/kotlin/net/corda/samples/businessmembership/FlowTests.kt @@ -12,11 +12,12 @@ import org.junit.Test import java.util.concurrent.ExecutionException import java.util.concurrent.Future +import org.junit.Assert.assertEquals class FlowTests { - private var network: MockNetwork? = null - private var a: StartedMockNode? = null - private var b: StartedMockNode? = null + private lateinit var network: MockNetwork + private lateinit var a: StartedMockNode + private lateinit var b: StartedMockNode @Before fun setup() { @@ -27,32 +28,34 @@ class FlowTests { TestCordapp.findCordapp("net.corda.samples.businessmembership.flows"), TestCordapp.findCordapp("net.corda.bn.flows"), TestCordapp.findCordapp("net.corda.bn.states")))) - a = network!!.createPartyNode(null) - b = network!!.createPartyNode(null) - network!!.runNetwork() + a = network.createPartyNode(null) + b = network.createPartyNode(null) + network.runNetwork() } @After fun tearDown() { - network!!.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test @Throws(ExecutionException::class, InterruptedException::class) fun createNetworkTest() { val flow = CreateNetwork() - val future: Future = a!!.startFlow(flow) - network!!.runNetwork() + val future: Future = a.startFlow(flow) + network.runNetwork() val resString: String = future.get() println(resString) val subString = resString.indexOf("NetworkID: ") val networkId = resString.substring(subString + 11) println("-$networkId-") val inputCriteria: QueryCriteria = QueryCriteria.LinearStateQueryCriteria().withStatus(Vault.StateStatus.UNCONSUMED) - val (_, networkId1) = a!!.services.vaultService + val (_, networkId1) = a.services.vaultService .queryBy(MembershipState::class.java, inputCriteria).states[0].state.data println(networkId1) - assert(networkId1 == networkId) + assertEquals(networkId, networkId1) } } \ No newline at end of file diff --git a/BusinessNetworks/settings.gradle b/BusinessNetworks/settings.gradle new file mode 100644 index 00000000..b69bd337 --- /dev/null +++ b/BusinessNetworks/settings.gradle @@ -0,0 +1 @@ +includeBuild 'insurancebusinessnetwork' diff --git a/Features/attachment-blacklist/README.md b/Features/attachment-blacklist/README.md index bd1b517a..0378087c 100644 --- a/Features/attachment-blacklist/README.md +++ b/Features/attachment-blacklist/README.md @@ -30,7 +30,7 @@ For development environment setup, please refer to: [Setup Guide](https://docs.c ### Deploy and run the node ``` -./greadlew deployNodes +../gradlew deployNodes ./build/node/runnodes ``` @@ -43,8 +43,8 @@ Before attempting to reach any agreements, you must upload the blacklist as an a be able to *initiate* an agreement. The blacklist can be uploaded via [RPC](https://docs.corda.net/docs/corda-os/api-rpc.html#api-rpc-operations) by running the following command from the project's root folder: -* Unix/Mac OSX: ` ./gradlew uploadBlacklist` -* Windows: `gradlew uploadBlacklist` +* Unix/Mac OSX: ` ../gradlew uploadBlacklist` +* Windows: `..\gradlew uploadBlacklist` Or by running the `Upload blacklist` run configuration from IntelliJ. diff --git a/Features/attachment-blacklist/build.gradle b/Features/attachment-blacklist/build.gradle index d05d7817..7d054010 100644 --- a/Features/attachment-blacklist/build.gradle +++ b/Features/attachment-blacklist/build.gradle @@ -1,112 +1,71 @@ -buildscript { -// ext.kotlin_version = '1.3.31' - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - spring_boot_version = '2.0.2.RELEASE' - ext.spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - } - -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':workflows') + cordapp project(':contracts') - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } - -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp project(':contracts') cordapp project(':workflows') - - runSchemaMigration = true - projectCordapp { deploy = true } + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } - node { name "O=Notary,L=London,C=GB" notary = [validating: false] @@ -115,6 +74,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { name "O=Monogram Bank,L=London,C=GB" @@ -123,7 +83,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=Hiseville Deposit Bank,L=Sao Paulo,C=BR" @@ -132,7 +91,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=George State Bank,L=New York,C=US" @@ -141,6 +99,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10012") adminAddress("localhost:10052") } - rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] } } diff --git a/Features/attachment-blacklist/clients/build.gradle b/Features/attachment-blacklist/clients/build.gradle index d902f1a6..a0b08bcd 100644 --- a/Features/attachment-blacklist/clients/build.gradle +++ b/Features/attachment-blacklist/clients/build.gradle @@ -1,5 +1,7 @@ -apply plugin: 'org.springframework.boot' -apply plugin: 'kotlin' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'org.springframework.boot' +} sourceSets { main { @@ -11,26 +13,28 @@ sourceSets { dependencies { // Corda dependencies. - compile "$corda_release_group:corda-rpc:$corda_release_version" + implementation "$corda_release_group:corda-rpc:$corda_release_version" // CorDapp dependencies. - compile project(":contracts") - compile project(":workflows") + implementation project(':contracts') + implementation project(':workflows') + implementation project(path: ':contracts', configuration: 'testArtifacts') - compile("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { + implementation("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { exclude group: "org.springframework.boot", module: "spring-boot-starter-logging" } - compile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - compile "org.apache.logging.log4j:log4j-web:${log4j_version}" - compile "org.slf4j:jul-to-slf4j:$slf4j_version" + runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" + runtimeOnly "org.apache.logging.log4j:log4j-web:$log4j_version" + runtimeOnly "org.slf4j:jul-to-slf4j:$slf4j_version" } springBoot { mainClassName = "net.corda.samples.blacklist.webserver.Server" } -task uploadBlacklist(type: JavaExec, dependsOn: assemble) { +tasks.register('uploadBlacklist', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.blacklist.clients.ClientKt' args 'localhost:10006', 'localhost:10009', 'localhost:10012' diff --git a/Features/attachment-blacklist/clients/src/main/kotlin/net/corda/samples/blacklist/clients/Client.kt b/Features/attachment-blacklist/clients/src/main/kotlin/net/corda/samples/blacklist/clients/Client.kt index 0cc17c24..d9a0a7db 100644 --- a/Features/attachment-blacklist/clients/src/main/kotlin/net/corda/samples/blacklist/clients/Client.kt +++ b/Features/attachment-blacklist/clients/src/main/kotlin/net/corda/samples/blacklist/clients/Client.kt @@ -5,11 +5,11 @@ import net.corda.core.crypto.SecureHash import net.corda.core.messaging.CordaRPCOps import net.corda.core.utilities.NetworkHostAndPort.Companion.parse import net.corda.core.utilities.loggerFor -import net.corda.examples.attachments.ATTACHMENT_EXPECTED_CONTENTS -import net.corda.examples.attachments.ATTACHMENT_FILE_NAME -import net.corda.examples.attachments.BLACKLIST_JAR_PATH +import net.corda.samples.blacklist.BLACKLISTED_PARTIES +import net.corda.samples.blacklist.BLACKLIST_JAR_NAME +import net.corda.samples.blacklist.contracts.AgreementContract.Companion.BLACKLIST_FILE_NAME import org.slf4j.Logger -import java.io.File +import java.io.FileNotFoundException import java.util.jar.JarInputStream /** @@ -31,26 +31,28 @@ private class UploadBlacklistClient { val rpcConnection = CordaRPCClient(nodeAddress).start("user1", "test") val proxy = rpcConnection.proxy - val attachmentHash = uploadAttachment(proxy, BLACKLIST_JAR_PATH) + val attachmentHash = uploadAttachment(proxy, BLACKLIST_JAR_NAME) logger.info("Blacklist uploaded to node at $nodeAddress") val attachmentJar = downloadAttachment(proxy, attachmentHash) logger.info("Blacklist downloaded from node at $nodeAddress") - checkAttachment(attachmentJar, ATTACHMENT_FILE_NAME, ATTACHMENT_EXPECTED_CONTENTS) + checkAttachment(attachmentJar, BLACKLIST_FILE_NAME, BLACKLISTED_PARTIES) logger.info("Attachment contents checked on node at $nodeAddress") rpcConnection.notifyServerAndClose() } } -} -/** - * Uploads the attachment at [attachmentPath] to the node. - */ -private fun uploadAttachment(proxy: CordaRPCOps, attachmentPath: String): SecureHash { - val attachmentUploadInputStream = File(attachmentPath).inputStream() - return proxy.uploadAttachment(attachmentUploadInputStream) + /** + * Uploads the attachment at [attachmentPath] to the node. + */ + @Suppress("SameParameterValue") + private fun uploadAttachment(proxy: CordaRPCOps, attachmentPath: String): SecureHash { + val attachmentUploadInputStream = javaClass.classLoader.getResourceAsStream(attachmentPath) + ?: throw FileNotFoundException("$attachmentPath not found") + return proxy.uploadAttachment(attachmentUploadInputStream) + } } /** @@ -64,10 +66,12 @@ private fun downloadAttachment(proxy: CordaRPCOps, attachmentHash: SecureHash): /** * Checks the [expectedFileName] and [expectedContents] of the downloaded [attachmentJar]. */ +@Suppress("SameParameterValue") private fun checkAttachment(attachmentJar: JarInputStream, expectedFileName: String, expectedContents: List) { - var name = attachmentJar.nextEntry.name + var name: String? = null while (name != expectedFileName) { - name = attachmentJar.nextEntry.name + val jarEntry = attachmentJar.nextEntry ?: throw FileNotFoundException("$expectedFileName not found") + name = jarEntry.name } val contents = attachmentJar.bufferedReader().readLines() diff --git a/Features/attachment-blacklist/contracts/build.gradle b/Features/attachment-blacklist/contracts/build.gradle index a13086fd..c408a72f 100644 --- a/Features/attachment-blacklist/contracts/build.gradle +++ b/Features/attachment-blacklist/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "Attachment Blacklist" @@ -12,24 +15,26 @@ cordapp { } } -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { - kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" - javaParameters = true // Useful for reflection. +configurations { + testArtifacts { + canBeResolved = false } } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_release_group:corda-core:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" +} + +def testJar = tasks.register('testJar', Jar) { + archiveClassifier = 'tests' + from sourceSets.test.output } -jar { - // CorDapps do not configure a Node's logging. - exclude '**/log4j2*.xml' +artifacts { + testArtifacts testJar } diff --git a/Features/attachment-blacklist/contracts/src/main/kotlin/net/corda/samples/blacklist/Constants.kt b/Features/attachment-blacklist/contracts/src/main/kotlin/net/corda/samples/blacklist/Constants.kt deleted file mode 100644 index f396fee2..00000000 --- a/Features/attachment-blacklist/contracts/src/main/kotlin/net/corda/samples/blacklist/Constants.kt +++ /dev/null @@ -1,20 +0,0 @@ -package net.corda.examples.attachments - -const val BLACKLIST_JAR_PATH = "../contracts/src/main/resources/blacklist.jar" -const val ATTACHMENT_FILE_NAME = "blacklist.txt" -val ATTACHMENT_EXPECTED_CONTENTS = listOf( - "Crossland Savings", - "TCF National Bank Wisconsin", - "George State Bank", - "The James Polk Stone Community Bank", - "Tifton Banking Company") -val BLACKLISTED_PARTIES = listOf( - "Crossland Savings", - "TCF National Bank Wisconsin", - "George State Bank", - "The James Polk Stone Community Bank", - "Tifton Banking Company" -) - -// This jar exists, but does not meet the constraints imposed by AttachmentContract. -const val INCORRECT_JAR_PATH = "src/test/resources/invalid.jar" diff --git a/Features/attachment-blacklist/contracts/src/main/kotlin/net/corda/samples/blacklist/contracts/AgreementContract.kt b/Features/attachment-blacklist/contracts/src/main/kotlin/net/corda/samples/blacklist/contracts/AgreementContract.kt index 55bb2105..5825ca6b 100644 --- a/Features/attachment-blacklist/contracts/src/main/kotlin/net/corda/samples/blacklist/contracts/AgreementContract.kt +++ b/Features/attachment-blacklist/contracts/src/main/kotlin/net/corda/samples/blacklist/contracts/AgreementContract.kt @@ -11,6 +11,7 @@ import net.corda.samples.blacklist.states.AgreementState open class AgreementContract : Contract { companion object { const val AGREEMENT_CONTRACT_ID = "net.corda.samples.blacklist.contracts.AgreementContract" + const val BLACKLIST_FILE_NAME = "blacklist.txt" val BLACKLIST_JAR_HASH = SecureHash.parse("4CEC607599723D7E0393EB5F05F24562732CD1B217DEAEDEABD4C25AFE5B333A") } @@ -33,29 +34,34 @@ open class AgreementContract : Contract { "The jar's hash should be correct" using (attachment.id == BLACKLIST_JAR_HASH) // We extract the blacklisted company names from the JAR. - val attachmentJar = attachment.openAsJAR() - while (attachmentJar.nextEntry.name != "blacklist.txt") { - // Calling `attachmentJar.nextEntry` causes us to scroll through the JAR. - } - val blacklistedCompanies = mutableListOf() - val bufferedReader = attachmentJar.bufferedReader() - var company = bufferedReader.readLine() - while (company != null) { - blacklistedCompanies.add(company) - company = bufferedReader.readLine() - } + attachment.openAsJAR().use { attachmentJar -> + while (true) { + // Calling `attachmentJar.nextEntry` causes us to scroll through the JAR. + val jarEntry = attachmentJar.nextEntry ?: throw IllegalArgumentException("blacklist.txt not found.") + if (jarEntry.name == BLACKLIST_FILE_NAME) { + break + } + } + val blacklistedCompanies = mutableSetOf() + val bufferedReader = attachmentJar.bufferedReader() + var company = bufferedReader.readLine() + while (company != null) { + blacklistedCompanies.add(company) + company = bufferedReader.readLine() + } - // Constraints on the blacklisted parties. - val agreement = tx.outputsOfType().single() - val participants = agreement.participants - val participantsOrgs = participants.map { it.name.organisation } - val overlap = blacklistedCompanies.toSet().intersect(participantsOrgs) - "The agreement involved blacklisted parties: $overlap" using (overlap.isEmpty()) + // Constraints on the blacklisted parties. + val agreement = tx.outputsOfType().single() + val participants = agreement.participants + val participantsOrgs = participants.mapTo(HashSet()) { it.name.organisation } + val overlap = blacklistedCompanies.intersect(participantsOrgs) + "The agreement involved blacklisted parties: $overlap" using (overlap.isEmpty()) - // Constraints on the signers. - val command = tx.commands.single() - val participantKeys = participants.map { it.owningKey } - "All the parties to the agreement are signers" using (command.signers.containsAll(participantKeys)) + // Constraints on the signers. + val command = tx.commands.single() + val participantKeys = participants.map { it.owningKey } + "All the parties to the agreement are signers" using (command.signers.containsAll(participantKeys)) + } } interface Commands { diff --git a/Features/attachment-blacklist/contracts/src/main/resources/log4j2.xml b/Features/attachment-blacklist/contracts/src/main/resources/log4j2.xml deleted file mode 100644 index aaabc5aa..00000000 --- a/Features/attachment-blacklist/contracts/src/main/resources/log4j2.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - build/logs - blacklist-${hostName} - - - - - - - [%-5level] %d{HH:mm:ss.SSS} [%t] %c{1}.%M - %msg%n - > - - - - - - - - - - - - - - - - - diff --git a/Features/attachment-blacklist/contracts/src/test/kotlin/net/corda/samples/blacklist/Constants.kt b/Features/attachment-blacklist/contracts/src/test/kotlin/net/corda/samples/blacklist/Constants.kt new file mode 100644 index 00000000..c1465948 --- /dev/null +++ b/Features/attachment-blacklist/contracts/src/test/kotlin/net/corda/samples/blacklist/Constants.kt @@ -0,0 +1,10 @@ +package net.corda.samples.blacklist + +const val BLACKLIST_JAR_NAME = "blacklist.jar" +val BLACKLISTED_PARTIES = listOf( + "Crossland Savings", + "TCF National Bank Wisconsin", + "George State Bank", + "The James Polk Stone Community Bank", + "Tifton Banking Company" +) diff --git a/Features/attachment-blacklist/contracts/src/test/kotlin/net/corda/samples/blacklist/contracts/ContractTests.kt b/Features/attachment-blacklist/contracts/src/test/kotlin/net/corda/samples/blacklist/contracts/ContractTests.kt index f6e9175e..97119929 100644 --- a/Features/attachment-blacklist/contracts/src/test/kotlin/net/corda/samples/blacklist/contracts/ContractTests.kt +++ b/Features/attachment-blacklist/contracts/src/test/kotlin/net/corda/samples/blacklist/contracts/ContractTests.kt @@ -2,8 +2,8 @@ package net.corda.samples.blacklist.contracts import net.corda.core.crypto.generateKeyPair import net.corda.core.identity.CordaX500Name -import net.corda.examples.attachments.BLACKLISTED_PARTIES -import net.corda.examples.attachments.BLACKLIST_JAR_PATH +import net.corda.samples.blacklist.BLACKLIST_JAR_NAME +import net.corda.samples.blacklist.BLACKLISTED_PARTIES import net.corda.samples.blacklist.contracts.AgreementContract.Companion.AGREEMENT_CONTRACT_ID import net.corda.samples.blacklist.states.AgreementState import net.corda.testing.core.TestIdentity @@ -12,7 +12,8 @@ import net.corda.testing.node.MockServices import net.corda.testing.node.ledger import net.corda.testing.node.makeTestIdentityService import org.junit.Test -import java.io.File +import java.io.FileNotFoundException +import java.io.InputStream class ContractTests { private val ledgerServices = MockServices(listOf("net.corda.samples.blacklist.contracts"), identityService = makeTestIdentityService(), initialIdentity = TestIdentity(CordaX500Name("TestIdentity", "", "GB"))) @@ -22,18 +23,20 @@ class ContractTests { private val miniCorp = TestIdentity(miniCorpName) private val agreementTxt = "$megaCorpName agrees with $miniCorpName that..." - private val validAttachment = File(BLACKLIST_JAR_PATH) private val blacklistedPartyKeyPair = generateKeyPair() private val blacklistedPartyPubKey = blacklistedPartyKeyPair.public private val blacklistedPartyName = CordaX500Name(organisation = BLACKLISTED_PARTIES[0], locality = "London", country = "GB") private val blacklistedParty = getTestPartyAndCertificate(blacklistedPartyName, blacklistedPartyPubKey).party + private fun getValidAttachment(): InputStream { + return javaClass.classLoader.getResourceAsStream(BLACKLIST_JAR_NAME) ?: throw FileNotFoundException("blacklist.jar not found") + } + @Test fun `agreement transaction contains one non-contract attachment`() { ledgerServices.ledger { // We upload a test attachment to the ledger. - val attachmentInputStream = validAttachment.inputStream() - val attachmentHash = attachment(attachmentInputStream) + val attachmentHash = attachment(getValidAttachment()) transaction { output(AGREEMENT_CONTRACT_ID, AgreementState(megaCorp.party, miniCorp.party, agreementTxt)) @@ -49,8 +52,7 @@ class ContractTests { fun `the non-contract attachment must not blacklist any of the participants`() { ledgerServices.ledger { // We upload a test attachment to the ledger. - val attachmentInputStream = validAttachment.inputStream() - val attachmentHash = attachment(attachmentInputStream) + val attachmentHash = attachment(getValidAttachment()) transaction { output(AGREEMENT_CONTRACT_ID, AgreementState(megaCorp.party, blacklistedParty, agreementTxt)) diff --git a/Features/attachment-blacklist/contracts/src/test/kotlin/net/corda/samples/blacklist/states/StateTests.kt b/Features/attachment-blacklist/contracts/src/test/kotlin/net/corda/samples/blacklist/states/StateTests.kt index e1f4f0d4..eacb5164 100644 --- a/Features/attachment-blacklist/contracts/src/test/kotlin/net/corda/samples/blacklist/states/StateTests.kt +++ b/Features/attachment-blacklist/contracts/src/test/kotlin/net/corda/samples/blacklist/states/StateTests.kt @@ -2,9 +2,9 @@ package net.corda.samples.blacklist.states import net.corda.core.identity.CordaX500Name import net.corda.testing.core.TestIdentity +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Test -import kotlin.test.assertEquals -import kotlin.test.assertTrue class StateTests { @@ -12,12 +12,12 @@ class StateTests { private val bob = TestIdentity(CordaX500Name("Bob", "", "GB")).party @Test - fun `agreementStateHasParamsOfCorrectTypeInConstructor`() { + fun agreementStateHasParamsOfCorrectTypeInConstructor() { AgreementState(alice, bob, "this is an agreement txt") } @Test - fun `agreementStateHasGettersForPartyAPartyBTxt`() { + fun agreementStateHasGettersForPartyAPartyBTxt() { val agreementState = AgreementState(alice, bob, "this is an agreement txt") assertEquals(alice, agreementState.partyA) assertEquals(bob, agreementState.partyB) @@ -25,7 +25,7 @@ class StateTests { } @Test - fun `agreementStateHasTwoParticipantsPartyAPartyB`() { + fun agreementStateHasTwoParticipantsPartyAPartyB() { val agreementState = AgreementState(alice, bob, "this is an agreement txt") assertEquals(2, agreementState.participants.size) assertTrue(agreementState.participants.contains(alice)) diff --git a/Features/attachment-blacklist/contracts/src/main/resources/blacklist.jar b/Features/attachment-blacklist/contracts/src/test/resources/blacklist.jar similarity index 100% rename from Features/attachment-blacklist/contracts/src/main/resources/blacklist.jar rename to Features/attachment-blacklist/contracts/src/test/resources/blacklist.jar diff --git a/Features/attachment-blacklist/gradle.properties b/Features/attachment-blacklist/gradle.properties index 493dc36c..c0e9b72e 100644 --- a/Features/attachment-blacklist/gradle.properties +++ b/Features/attachment-blacklist/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Attachment Blacklist group=com.blacklist version=1.0 -kotlin.incremental=false + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Features/attachment-blacklist/gradle/wrapper/gradle-wrapper.jar b/Features/attachment-blacklist/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7a3265ee..00000000 Binary files a/Features/attachment-blacklist/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Features/attachment-blacklist/gradle/wrapper/gradle-wrapper.properties b/Features/attachment-blacklist/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 674bdda0..00000000 --- a/Features/attachment-blacklist/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Features/attachment-blacklist/gradlew b/Features/attachment-blacklist/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Features/attachment-blacklist/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Features/attachment-blacklist/gradlew.bat b/Features/attachment-blacklist/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Features/attachment-blacklist/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Features/attachment-blacklist/lib/README.txt b/Features/attachment-blacklist/lib/README.txt deleted file mode 100644 index b0592c95..00000000 --- a/Features/attachment-blacklist/lib/README.txt +++ /dev/null @@ -1,8 +0,0 @@ -The Quasar.jar in this directory is for runtime instrumentation of classes by Quasar. - -When running corda outside of the given gradle building you must add the following flag with the -correct path to your call to Java: - - java -javaagent:path-to-quasar-jar.jar ... - -See the Quasar docs for more information: http://docs.paralleluniverse.co/quasar/ \ No newline at end of file diff --git a/Features/attachment-blacklist/lib/quasar.jar b/Features/attachment-blacklist/lib/quasar.jar deleted file mode 100644 index 7282d8c8..00000000 Binary files a/Features/attachment-blacklist/lib/quasar.jar and /dev/null differ diff --git a/Features/attachment-blacklist/repositories.gradle b/Features/attachment-blacklist/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Features/attachment-blacklist/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Features/attachment-blacklist/settings.gradle b/Features/attachment-blacklist/settings.gradle index d58d1730..f303a1f7 100644 --- a/Features/attachment-blacklist/settings.gradle +++ b/Features/attachment-blacklist/settings.gradle @@ -1,4 +1,36 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' include 'clients' - diff --git a/Features/attachment-blacklist/workflows/build.gradle b/Features/attachment-blacklist/workflows/build.gradle index 9c4931f3..8aa79fc8 100644 --- a/Features/attachment-blacklist/workflows/build.gradle +++ b/Features/attachment-blacklist/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "Attachment Blacklist" @@ -14,11 +17,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -34,30 +32,25 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation project(path: ':contracts', configuration: 'testArtifacts') + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath } - -jar { - // CorDapps do not configure a Node's logging. - exclude '**/log4j2*.xml' -} diff --git a/Features/attachment-blacklist/workflows/src/test/kotlin/net/corda/samples/blacklist/flows/FlowTests.kt b/Features/attachment-blacklist/workflows/src/test/kotlin/net/corda/samples/blacklist/flows/FlowTests.kt index fa5d4ba5..b098d464 100644 --- a/Features/attachment-blacklist/workflows/src/test/kotlin/net/corda/samples/blacklist/flows/FlowTests.kt +++ b/Features/attachment-blacklist/workflows/src/test/kotlin/net/corda/samples/blacklist/flows/FlowTests.kt @@ -7,17 +7,18 @@ import net.corda.core.identity.Party import net.corda.core.node.services.queryBy import net.corda.core.transactions.SignedTransaction import net.corda.core.utilities.getOrThrow -import net.corda.examples.attachments.BLACKLIST_JAR_PATH -import net.corda.examples.attachments.INCORRECT_JAR_PATH +import net.corda.samples.blacklist.BLACKLIST_JAR_NAME import net.corda.samples.blacklist.states.AgreementState import net.corda.testing.node.* import org.junit.After import org.junit.Before import org.junit.Test -import java.io.File +import java.io.FileNotFoundException +import java.io.InputStream import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertNotNull +import kotlin.test.assertTrue class FlowTests { private lateinit var network: MockNetwork @@ -29,6 +30,10 @@ class FlowTests { private lateinit var blacklistAttachment: SecureHash private lateinit var incorrectAttachment: SecureHash + private fun getAttachment(resourceName: String): InputStream { + return javaClass.classLoader.getResourceAsStream(resourceName) ?: throw FileNotFoundException("$resourceName not found") + } + @Before fun setup() { network = MockNetwork(MockNetworkParameters(cordappsForAllNodes = listOf( @@ -44,16 +49,14 @@ class FlowTests { // We upload the valid attachment to the first node, who will propagate it to the other node as part of the // flow. - val attachmentInputStream = File(BLACKLIST_JAR_PATH).inputStream() a.transaction { - blacklistAttachment = a.services.attachments.importAttachment(attachmentInputStream, "user", "blacklist") + blacklistAttachment = a.services.attachments.importAttachment(getAttachment(BLACKLIST_JAR_NAME), "user", "blacklist") } // We upload the invalid attachment to the first node, who will propagate it to the other node as part of the // flow. - val incorrectAttachmentInputStream = File(INCORRECT_JAR_PATH).inputStream() a.transaction { - incorrectAttachment = a.services.attachments.importAttachment(incorrectAttachmentInputStream, "user", "blacklist") + incorrectAttachment = a.services.attachments.importAttachment(getAttachment("invalid.jar"), "user", "blacklist") } b.registerInitiatedFlow(AgreeFlow::class.java) @@ -63,7 +66,9 @@ class FlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test @@ -101,7 +106,7 @@ class FlowTests { // Checks on the blacklist. val attachments = recordedTx.tx.attachments assertEquals(2, attachments.size) - assert(attachments.contains(blacklistAttachment)) + assertTrue(attachments.contains(blacklistAttachment)) } } diff --git a/Features/attachment-sendfile/README.md b/Features/attachment-sendfile/README.md index 8ad19071..d58975d6 100644 --- a/Features/attachment-sendfile/README.md +++ b/Features/attachment-sendfile/README.md @@ -46,14 +46,14 @@ For development environment setup, please refer to: [Setup Guide](https://docs.c ### Deploy and run the node ``` -./greadlew deployNodes +../gradlew clean deployNodes ./build/node/runnodes ``` if you have any questions during setup, please go to https://docs.corda.net/getting-set-up.html for detailed setup instructions. Once all three nodes are started up, in Seller's node shell, run: ``` -flow start SendAttachment receiver: Buyer +flow start SendAttachment receiver: Buyer, zipPath: /path/to/test.zip ``` After this call, we already finished 1. uploading a zip file to Seller's node @@ -71,4 +71,3 @@ This command is telling the node to retrieve attachment from the transaction tha * This uploaded file is hardcoded into the flow. * The transaction retrieving is also hardcoded to retrieve the first state that being stored in the vault. - diff --git a/Features/attachment-sendfile/build.gradle b/Features/attachment-sendfile/build.gradle index b59c237b..f8d458f6 100644 --- a/Features/attachment-sendfile/build.gradle +++ b/Features/attachment-sendfile/build.gradle @@ -1,102 +1,71 @@ -buildscript { - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } +//Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaCompile "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" - cordapp project('workflows') - cordapp project('contracts') + // CorDapp dependencies. + cordapp project(':workflows') + cordapp project(':contracts') - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { - +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = true - } - cordapp project('contracts') - cordapp project('workflows') - runSchemaMigration = true + cordapp project(':contracts') + cordapp project(':workflows') + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } - node { name "O=Notary,L=London,C=GB" notary = [validating : false] @@ -105,6 +74,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { @@ -114,7 +84,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { @@ -124,6 +93,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } } diff --git a/Features/attachment-sendfile/contracts/build.gradle b/Features/attachment-sendfile/contracts/build.gradle index 64730d03..4775c891 100644 --- a/Features/attachment-sendfile/contracts/build.gradle +++ b/Features/attachment-sendfile/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "Attachment Sendfile" vendor "Corda Open Source" @@ -11,24 +14,11 @@ cordapp { } } -sourceSets { - main { - java { - srcDir 'src/main/kotlin' - java.outputDir = file('bin/main') - } - } - test { - java { - srcDir 'src/test/kotlin' - java.outputDir = file('bin/test') - } - } -} - dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" + // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Features/attachment-sendfile/contracts/src/test/kotlin/net.corda.samples.sendfile/contracts/InvoiceContractTests.kt b/Features/attachment-sendfile/contracts/src/test/kotlin/net.corda.samples.sendfile/contracts/InvoiceContractTests.kt index 7efe0fa8..e6dc13c2 100644 --- a/Features/attachment-sendfile/contracts/src/test/kotlin/net.corda.samples.sendfile/contracts/InvoiceContractTests.kt +++ b/Features/attachment-sendfile/contracts/src/test/kotlin/net.corda.samples.sendfile/contracts/InvoiceContractTests.kt @@ -5,37 +5,30 @@ import net.corda.core.contracts.Contract import net.corda.core.contracts.TypeOnlyCommandData import net.corda.core.identity.CordaX500Name import net.corda.samples.sendfile.states.InvoiceState -import net.corda.testing.core.DummyCommandData import net.corda.testing.core.TestIdentity -import net.corda.testing.dsl.TransactionDSL -import net.corda.testing.dsl.TransactionDSLInterpreter import net.corda.testing.node.MockServices import net.corda.testing.node.ledger -import net.corda.testing.node.transaction -import org.jgroups.util.Util +import org.junit.Assert.assertTrue import org.junit.Test -import java.lang.Compiler.command -import java.util.* - class InvoiceContractTests { // A pre-defined dummy command. interface Commands : CommandData { - class DummyCommand : TypeOnlyCommandData(), InvoiceContractTests.Commands + class DummyCommand : TypeOnlyCommandData(), Commands } private val ledgerServices = MockServices( - Arrays.asList("net.corda.samples.sendfile.contracts") + listOf("net.corda.samples.sendfile.contracts") ) private val a = TestIdentity(CordaX500Name("Alice", "", "GB")) private val b = TestIdentity(CordaX500Name("Bob", "", "GB")) private val STRINGID = "StringID that is unique" - private val st = InvoiceState(STRINGID, Arrays.asList(a.party, b.party)) + private val st = InvoiceState(STRINGID, listOf(a.party, b.party)) @Test - fun InvoiceContractImplementsContract() { - assert(InvoiceContract() is Contract) + fun invoiceContractImplementsContract() { + assertTrue(InvoiceContract() is Contract) } @Test @@ -44,8 +37,8 @@ class InvoiceContractTests { transaction { output(InvoiceContract.ID, st) // Has two commands, will fail. - command(Arrays.asList(a.publicKey, b.publicKey), InvoiceContract.Commands.Issue()) - command(Arrays.asList(a.publicKey, b.publicKey), InvoiceContract.Commands.Issue()) + command(listOf(a.publicKey, b.publicKey), InvoiceContract.Commands.Issue()) + command(listOf(a.publicKey, b.publicKey), InvoiceContract.Commands.Issue()) this.fails() } } @@ -53,7 +46,7 @@ class InvoiceContractTests { ledgerServices.ledger { transaction { output(InvoiceContract.ID, st) - command(Arrays.asList(a.publicKey, b.publicKey), InvoiceContract.Commands.Issue()) + command(listOf(a.publicKey, b.publicKey), InvoiceContract.Commands.Issue()) this.verifies() } } @@ -66,7 +59,7 @@ class InvoiceContractTests { transaction { output(InvoiceContract.ID, st) // Has dummy command, will fail. - command(Arrays.asList(a.publicKey, b.publicKey), Commands.DummyCommand()) + command(listOf(a.publicKey, b.publicKey), Commands.DummyCommand()) this.fails() } @@ -76,7 +69,7 @@ class InvoiceContractTests { transaction { output(InvoiceContract.ID, st) // Has two commands, will fail. - command(Arrays.asList(a.publicKey, b.publicKey), InvoiceContract.Commands.Issue()) + command(listOf(a.publicKey, b.publicKey), InvoiceContract.Commands.Issue()) this.verifies() } diff --git a/Features/attachment-sendfile/contracts/src/test/kotlin/net.corda.samples.sendfile/states/InvoiceStateTests.kt b/Features/attachment-sendfile/contracts/src/test/kotlin/net.corda.samples.sendfile/states/InvoiceStateTests.kt index 716380df..8856ef53 100644 --- a/Features/attachment-sendfile/contracts/src/test/kotlin/net.corda.samples.sendfile/states/InvoiceStateTests.kt +++ b/Features/attachment-sendfile/contracts/src/test/kotlin/net.corda.samples.sendfile/states/InvoiceStateTests.kt @@ -1,11 +1,9 @@ -package net.corda.samples.sendfile.contracts +package net.corda.samples.sendfile.states import net.corda.core.identity.CordaX500Name -import net.corda.samples.sendfile.states.InvoiceState import net.corda.testing.core.TestIdentity -import org.jgroups.util.Util +import org.junit.Assert.assertEquals import org.junit.Test -import java.util.* class InvoiceStateTests { private val a = TestIdentity(CordaX500Name("Alice", "", "GB")).party @@ -14,7 +12,7 @@ class InvoiceStateTests { @Test fun constructorTest() { - val (invoiceAttachmentID) = InvoiceState(STRINGID, Arrays.asList(a, b)) - Util.assertEquals(STRINGID, invoiceAttachmentID) + val (invoiceAttachmentID) = InvoiceState(STRINGID, listOf(a, b)) + assertEquals(STRINGID, invoiceAttachmentID) } } diff --git a/Features/attachment-sendfile/gradle.properties b/Features/attachment-sendfile/gradle.properties index e796847c..014f9ca5 100644 --- a/Features/attachment-sendfile/gradle.properties +++ b/Features/attachment-sendfile/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Attachment Sendfile group=com.sendfile version=0.1 -kotlin.incremental=false + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Features/attachment-sendfile/gradle/wrapper/gradle-wrapper.jar b/Features/attachment-sendfile/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Features/attachment-sendfile/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Features/attachment-sendfile/gradle/wrapper/gradle-wrapper.properties b/Features/attachment-sendfile/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Features/attachment-sendfile/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Features/attachment-sendfile/gradlew b/Features/attachment-sendfile/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Features/attachment-sendfile/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Features/attachment-sendfile/gradlew.bat b/Features/attachment-sendfile/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Features/attachment-sendfile/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Features/attachment-sendfile/repositories.gradle b/Features/attachment-sendfile/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Features/attachment-sendfile/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Features/attachment-sendfile/settings.gradle b/Features/attachment-sendfile/settings.gradle index 0473ad43..c1f46514 100644 --- a/Features/attachment-sendfile/settings.gradle +++ b/Features/attachment-sendfile/settings.gradle @@ -1,2 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' diff --git a/Features/attachment-sendfile/workflows/build.gradle b/Features/attachment-sendfile/workflows/build.gradle index 6f0a089c..41e6e712 100644 --- a/Features/attachment-sendfile/workflows/build.gradle +++ b/Features/attachment-sendfile/workflows/build.gradle @@ -1,10 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' -//apply plugin: 'net.corda.plugins.cordformation' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "Attachment Sendfile" @@ -15,12 +17,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } - test { resources { srcDir rootProject.file("config/test") @@ -37,26 +33,24 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" -// cordaCompile "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath } diff --git a/Features/attachment-sendfile/workflows/file.zip b/Features/attachment-sendfile/workflows/file.zip deleted file mode 100644 index 789ee5b4..00000000 Binary files a/Features/attachment-sendfile/workflows/file.zip and /dev/null differ diff --git a/Features/attachment-sendfile/workflows/src/integrationTest/kotlin/net/corda/samples/sendfile/DriverBasedTest.kt b/Features/attachment-sendfile/workflows/src/integrationTest/kotlin/net/corda/samples/sendfile/DriverBasedTest.kt index b18e9f3a..98c0f60c 100644 --- a/Features/attachment-sendfile/workflows/src/integrationTest/kotlin/net/corda/samples/sendfile/DriverBasedTest.kt +++ b/Features/attachment-sendfile/workflows/src/integrationTest/kotlin/net/corda/samples/sendfile/DriverBasedTest.kt @@ -7,9 +7,9 @@ import net.corda.testing.driver.DriverDSL import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.driver +import org.junit.Assert.assertEquals import org.junit.Test import java.util.concurrent.Future -import kotlin.test.assertEquals class DriverBasedTest { private val bankA = TestIdentity(CordaX500Name("BankA", "", "GB")) diff --git a/Features/attachment-sendfile/workflows/src/main/kotlin/net/corda/samples/sendfile/flows/DownloadAttachment.kt b/Features/attachment-sendfile/workflows/src/main/kotlin/net/corda/samples/sendfile/flows/DownloadAttachment.kt index 8a7aab09..f5aca3de 100644 --- a/Features/attachment-sendfile/workflows/src/main/kotlin/net/corda/samples/sendfile/flows/DownloadAttachment.kt +++ b/Features/attachment-sendfile/workflows/src/main/kotlin/net/corda/samples/sendfile/flows/DownloadAttachment.kt @@ -30,6 +30,7 @@ class DownloadAttachment( } override val progressTracker = tracker() + @Suspendable override fun call():String { progressTracker.currentStep = RETRIEVING_ID @@ -40,7 +41,7 @@ class DownloadAttachment( val state = serviceHub.vaultService.queryBy( contractStateType = InvoiceState::class.java, criteria = criteria - ).states.get(0).state.data.invoiceAttachmentID + ).states[0].state.data.invoiceAttachmentID progressTracker.currentStep = DOWNLOAD_ATTACHMENT val content = serviceHub.attachments.openAttachment(SecureHash.parse(state))!! diff --git a/Features/attachment-sendfile/workflows/src/main/kotlin/net/corda/samples/sendfile/flows/SendAttachment.kt b/Features/attachment-sendfile/workflows/src/main/kotlin/net/corda/samples/sendfile/flows/SendAttachment.kt index e680325f..cbf49f8f 100644 --- a/Features/attachment-sendfile/workflows/src/main/kotlin/net/corda/samples/sendfile/flows/SendAttachment.kt +++ b/Features/attachment-sendfile/workflows/src/main/kotlin/net/corda/samples/sendfile/flows/SendAttachment.kt @@ -13,6 +13,7 @@ import net.corda.core.utilities.ProgressTracker import net.corda.samples.sendfile.contracts.InvoiceContract import net.corda.samples.sendfile.states.InvoiceState import java.io.File +import java.nio.file.Paths // ********* @@ -22,7 +23,7 @@ import java.io.File @StartableByRPC class SendAttachment( private val receiver: Party, - private val unitTest: Boolean + private val zipPath: String ) : FlowLogic() { companion object { object GENERATING_TRANSACTION : ProgressTracker.Step("Generating transaction") @@ -36,9 +37,8 @@ class SendAttachment( ) } - constructor(receiver: Party) : this(receiver, unitTest = false) - override val progressTracker = tracker() + @Suspendable override fun call():SignedTransaction { // Obtain a reference from a notary we wish to use. @@ -49,16 +49,12 @@ class SendAttachment( //upload attachment via private method val path = System.getProperty("user.dir") - println("Working Directory = $path") - - val zipPath = if (unitTest!!) "../test.zip" else "../../../test.zip" + logger.info("Working Directory = {}}", path) - //Change the path to "../test.zip" for passing the unit test. - //because the unit test are in a different working directory than the running node. val attachmenthash = SecureHash.parse(uploadAttachment(zipPath, serviceHub, ourIdentity, - "testzip")) + Paths.get(zipPath).fileName.toString())) progressTracker.currentStep = GENERATING_TRANSACTION //build transaction diff --git a/Features/attachment-sendfile/workflows/src/test/kotlin/net/corda/samples/sendfile/flows/FlowTests.kt b/Features/attachment-sendfile/workflows/src/test/kotlin/net/corda/samples/sendfile/flows/FlowTests.kt index 8af5fcb3..0167fda1 100644 --- a/Features/attachment-sendfile/workflows/src/test/kotlin/net/corda/samples/sendfile/flows/FlowTests.kt +++ b/Features/attachment-sendfile/workflows/src/test/kotlin/net/corda/samples/sendfile/flows/FlowTests.kt @@ -1,11 +1,14 @@ package net.corda.samples.sendfile.flows +import java.io.FileNotFoundException +import java.nio.file.Paths import net.corda.core.identity.CordaX500Name import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNetworkNotarySpec import net.corda.testing.node.MockNetworkParameters import net.corda.testing.node.TestCordapp import org.junit.After +import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test @@ -19,6 +22,10 @@ class FlowTests { private val a = network.createNode() private val b = network.createNode() + private val testZip = Paths.get( + (this::class.java.classLoader.getResource("test.zip") ?: throw FileNotFoundException("test.zip not found") + ).toURI()).toAbsolutePath() + init { listOf(a, b).forEach { } @@ -36,16 +43,16 @@ class FlowTests { //because the unit test are in a different working directory than the running node. @Test fun `attachment list has more than one element`() { - val future = a.startFlow(SendAttachment(b.info.legalIdentities.first(), true)) + val future = a.startFlow(SendAttachment(b.info.legalIdentities.first(), testZip.toString())) network.runNetwork() val ptx = future.get() - assert(ptx.tx.attachments.size > 1) + assertTrue(ptx.tx.attachments.size > 1) } //Test #2 test successful download of the attachment by the receiving node. @Test fun `attachment downloaded by buyer`() { - val future = a.startFlow(SendAttachment(b.info.legalIdentities.first(), true)) + val future = a.startFlow(SendAttachment(b.info.legalIdentities.first(), testZip.toString())) network.runNetwork() val future1 = b.startFlow(DownloadAttachment(a.info.legalIdentities.first(), "file.zip")) network.runNetwork() diff --git a/Features/attachment-sendfile/test.zip b/Features/attachment-sendfile/workflows/src/test/resources/test.zip similarity index 100% rename from Features/attachment-sendfile/test.zip rename to Features/attachment-sendfile/workflows/src/test/resources/test.zip diff --git a/Features/build.gradle b/Features/build.gradle new file mode 100644 index 00000000..3b0d2b58 --- /dev/null +++ b/Features/build.gradle @@ -0,0 +1,8 @@ +plugins { + id 'base' +} + +wrapper { + gradleVersion = '7.4.2' + distributionType = Wrapper.DistributionType.BIN +} diff --git a/Features/confidentialIdentity-whistleblower/README.md b/Features/confidentialIdentity-whistleblower/README.md index 964f4e0e..85a0595a 100644 --- a/Features/confidentialIdentity-whistleblower/README.md +++ b/Features/confidentialIdentity-whistleblower/README.md @@ -21,7 +21,7 @@ For development environment setup, please refer to: [Setup Guide](https://docs.c ### Deploy and run the node Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) ``` diff --git a/Features/confidentialIdentity-whistleblower/build.gradle b/Features/confidentialIdentity-whistleblower/build.gradle index 267868b9..b1b859dd 100644 --- a/Features/confidentialIdentity-whistleblower/build.gradle +++ b/Features/confidentialIdentity-whistleblower/build.gradle @@ -1,131 +1,72 @@ -buildscript { - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - - // springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } - } - - tasks.withType(JavaCompile) { - options.compilerArgs << "-parameters" // Required for shell commands. +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -cordapp { - info { - name "Confidential Identity Whistleblower" - vendor "Corda Open Source" - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version - } -} - - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } +//Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaCompile "$corda_release_group:corda-confidential-identities:$corda_release_version" - - cordaRuntime "$corda_release_group:corda:$corda_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':workflows') + cordapp project(':contracts') + cordapp "$corda_release_group:corda-confidential-identities:$corda_release_version" - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = false - } - cordapp project(':workflows') cordapp project(':contracts') - - runSchemaMigration = true - } - node { - name "O=Notary,L=Nakuru,C=KE" - notary = [validating: true] - p2pPort 10006 - rpcSettings { - address("localhost:10007") - adminAddress("localhost:10008") - } + cordapp "$corda_release_group:corda-confidential-identities:$corda_release_version" + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { name "O=BraveEmployee,L=Nairobi,C=KE" @@ -134,8 +75,9 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10010") adminAddress("localhost:10011") } - rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] + rpcUsers = [] } + node { name "O=TradeBody,L=Kisumu,C=KE" p2pPort 10013 @@ -143,8 +85,8 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10014") adminAddress("localhost:10015") } - rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] } + node { name "O=BadCompany,L=Eldoret,C=KE" p2pPort 10017 @@ -152,6 +94,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10018") adminAddress("localhost:10019") } - rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] } } diff --git a/Features/confidentialIdentity-whistleblower/contracts/build.gradle b/Features/confidentialIdentity-whistleblower/contracts/build.gradle index 8c8d55df..5422cfbc 100644 --- a/Features/confidentialIdentity-whistleblower/contracts/build.gradle +++ b/Features/confidentialIdentity-whistleblower/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "Confidential Identity Whistleblower" @@ -12,24 +15,11 @@ cordapp { } } -sourceSets { - - main { - java { - srcDir 'src/main/kotlin' - java.outputDir = file('bin/main') - } - } - test { - java { - srcDir 'src/test/kotlin' - java.outputDir = file('bin/test') - } - } -} - dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - cordaCompile "$corda_release_group:corda-core:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" + + // Corda dependencies. + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Features/confidentialIdentity-whistleblower/contracts/src/test/kotlin/net/corda/samples/whistleblower/contracts/BlowWhistleContractTests.kt b/Features/confidentialIdentity-whistleblower/contracts/src/test/kotlin/net/corda/samples/whistleblower/contracts/BlowWhistleContractTests.kt index 77f1cba9..ac0922dc 100644 --- a/Features/confidentialIdentity-whistleblower/contracts/src/test/kotlin/net/corda/samples/whistleblower/contracts/BlowWhistleContractTests.kt +++ b/Features/confidentialIdentity-whistleblower/contracts/src/test/kotlin/net/corda/samples/whistleblower/contracts/BlowWhistleContractTests.kt @@ -8,9 +8,8 @@ import net.corda.samples.whistleblower.states.BlowWhistleState import net.corda.testing.core.TestIdentity import net.corda.testing.node.MockServices import net.corda.testing.node.ledger +import org.junit.Assert.assertTrue import org.junit.Test -import java.util.* - class BlowWhistleContractTests { private val a = TestIdentity(CordaX500Name("alice", "", "GB")) @@ -18,10 +17,10 @@ class BlowWhistleContractTests { private val c = TestIdentity(CordaX500Name("bad corp", "", "GB")) private val ledgerServices = MockServices( - Arrays.asList("net.corda.samples.whistleblower.contracts") + listOf("net.corda.samples.whistleblower.contracts") ) - var st: BlowWhistleState = BlowWhistleState(c.party, a.party.anonymise(), b.party.anonymise()) + private val st = BlowWhistleState(c.party, a.party.anonymise(), b.party.anonymise()) // A pre-defined dummy command. interface Commands : CommandData { @@ -30,8 +29,8 @@ class BlowWhistleContractTests { @Test - fun SantaSessionContractImplementsContract() { - assert(BlowWhistleContract() is Contract) + fun contractImplementsContract() { + assertTrue(BlowWhistleContract() is Contract) } @Test @@ -41,14 +40,14 @@ class BlowWhistleContractTests { // Has an input, will fail. output(BLOW_WHISTLE_CONTRACT_ID, st) output(BLOW_WHISTLE_CONTRACT_ID, st) - command(Arrays.asList(a.publicKey, b.publicKey), BlowWhistleContract.Commands.BlowWhistleCmd()) + command(listOf(a.publicKey, b.publicKey), BlowWhistleContract.Commands.BlowWhistleCmd()) fails() } transaction { // Has no input, will verify. output(BLOW_WHISTLE_CONTRACT_ID, st) - command(Arrays.asList(a.publicKey, b.publicKey), BlowWhistleContract.Commands.BlowWhistleCmd()) + command(listOf(a.publicKey, b.publicKey), BlowWhistleContract.Commands.BlowWhistleCmd()) verifies() } } @@ -60,14 +59,14 @@ class BlowWhistleContractTests { transaction { // Has wrong command type, will fail. output(BLOW_WHISTLE_CONTRACT_ID, st) - command(Arrays.asList(a.publicKey, b.publicKey), Commands.DummyCommand()) + command(listOf(a.publicKey, b.publicKey), Commands.DummyCommand()) fails() } transaction { // Has correct command type, will verify. output(BLOW_WHISTLE_CONTRACT_ID, st) - command(Arrays.asList(a.publicKey, b.publicKey), BlowWhistleContract.Commands.BlowWhistleCmd()) + command(listOf(a.publicKey, b.publicKey), BlowWhistleContract.Commands.BlowWhistleCmd()) verifies() } } diff --git a/Features/confidentialIdentity-whistleblower/contracts/src/test/kotlin/net/corda/samples/whistleblower/states/BlowWhistleStateTests.kt b/Features/confidentialIdentity-whistleblower/contracts/src/test/kotlin/net/corda/samples/whistleblower/states/BlowWhistleStateTests.kt index 8922c560..cb0bdbf8 100644 --- a/Features/confidentialIdentity-whistleblower/contracts/src/test/kotlin/net/corda/samples/whistleblower/states/BlowWhistleStateTests.kt +++ b/Features/confidentialIdentity-whistleblower/contracts/src/test/kotlin/net/corda/samples/whistleblower/states/BlowWhistleStateTests.kt @@ -5,10 +5,10 @@ import net.corda.core.contracts.LinearState import net.corda.core.contracts.UniqueIdentifier import net.corda.core.identity.CordaX500Name import net.corda.testing.core.TestIdentity -import org.jgroups.util.Util +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Test - class BlowWhistleStateTests { private val a = TestIdentity(CordaX500Name("alice", "", "GB")) private val b = TestIdentity(CordaX500Name("bob", "", "GB")) @@ -19,16 +19,16 @@ class BlowWhistleStateTests { // here, c is the bad corporation, a is the Whistleblower, and b is the investigator val st = BlowWhistleState(c.party, a.party.anonymise(), b.party.anonymise()) - Util.assertEquals(a.party, st.whistleBlower) - Util.assertEquals(c.party, st.badCompany) - Util.assertEquals(b.party, st.investigator) + assertEquals(a.party, st.whistleBlower) + assertEquals(c.party, st.badCompany) + assertEquals(b.party, st.investigator) } @Test fun stateImplementTests() { val st = BlowWhistleState(c.party, a.party.anonymise(), b.party.anonymise()) - Util.assertTrue(st is ContractState) - Util.assertTrue(st is LinearState) - Util.assertTrue(st.linearId is UniqueIdentifier) + assertTrue(st is ContractState) + assertTrue(st is LinearState) + assertTrue(st.linearId is UniqueIdentifier) } } diff --git a/Features/confidentialIdentity-whistleblower/gradle.properties b/Features/confidentialIdentity-whistleblower/gradle.properties index 0ca51958..be4d93b3 100644 --- a/Features/confidentialIdentity-whistleblower/gradle.properties +++ b/Features/confidentialIdentity-whistleblower/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Confidential Identity Whistleblower group=net.whistleblower version=0.1 -kotlin.incremental=false + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Features/confidentialIdentity-whistleblower/gradle/wrapper/gradle-wrapper.jar b/Features/confidentialIdentity-whistleblower/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Features/confidentialIdentity-whistleblower/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Features/confidentialIdentity-whistleblower/gradle/wrapper/gradle-wrapper.properties b/Features/confidentialIdentity-whistleblower/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Features/confidentialIdentity-whistleblower/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Features/confidentialIdentity-whistleblower/gradlew b/Features/confidentialIdentity-whistleblower/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Features/confidentialIdentity-whistleblower/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Features/confidentialIdentity-whistleblower/gradlew.bat b/Features/confidentialIdentity-whistleblower/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Features/confidentialIdentity-whistleblower/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Features/confidentialIdentity-whistleblower/repositories.gradle b/Features/confidentialIdentity-whistleblower/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Features/confidentialIdentity-whistleblower/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Features/confidentialIdentity-whistleblower/settings.gradle b/Features/confidentialIdentity-whistleblower/settings.gradle index 0473ad43..c1f46514 100644 --- a/Features/confidentialIdentity-whistleblower/settings.gradle +++ b/Features/confidentialIdentity-whistleblower/settings.gradle @@ -1,2 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' diff --git a/Features/confidentialIdentity-whistleblower/workflows/build.gradle b/Features/confidentialIdentity-whistleblower/workflows/build.gradle index 1e5b04ec..5adfc57c 100644 --- a/Features/confidentialIdentity-whistleblower/workflows/build.gradle +++ b/Features/confidentialIdentity-whistleblower/workflows/build.gradle @@ -1,11 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' -apply plugin: 'net.corda.plugins.cordformation' - +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "Confidential Identity Whistleblower" vendor "Corda Open Source" @@ -15,12 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } - test { resources { srcDir rootProject.file("config/test") @@ -37,33 +32,25 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_release_group:corda-core:$corda_release_version" - cordaCompile "$corda_release_group:corda-jackson:$corda_release_version" - cordaCompile "$corda_release_group:corda-rpc:$corda_release_version" - cordaCompile "$corda_release_group:corda-node-api:$corda_release_version" - cordaCompile "$corda_release_group:corda-confidential-identities:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" - cordaRuntime "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" - - cordapp "$corda_release_group:corda-confidential-identities:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') + cordapp "$corda_release_group:corda-confidential-identities:$corda_release_version" } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath } diff --git a/Features/confidentialIdentity-whistleblower/workflows/src/test/kotlin/net/corda/samples/whistleblower/flows/FlowTests.kt b/Features/confidentialIdentity-whistleblower/workflows/src/test/kotlin/net/corda/samples/whistleblower/flows/FlowTests.kt index 6342942e..8af3bbbe 100644 --- a/Features/confidentialIdentity-whistleblower/workflows/src/test/kotlin/net/corda/samples/whistleblower/flows/FlowTests.kt +++ b/Features/confidentialIdentity-whistleblower/workflows/src/test/kotlin/net/corda/samples/whistleblower/flows/FlowTests.kt @@ -6,6 +6,7 @@ import net.corda.testing.node.MockNetworkNotarySpec import net.corda.testing.node.MockNetworkParameters import net.corda.testing.node.TestCordapp import org.junit.After +import org.junit.Assert.assertFalse import org.junit.Before import org.junit.Test @@ -39,8 +40,7 @@ class FlowTests { val future = a.startFlow(BlowWhistleFlow(b.info.legalIdentities.first(), c.info.legalIdentities.first())) network.runNetwork() val ptx = future.get() - assert(!ptx.tx.requiredSigningKeys.contains(a.info.legalIdentities.first().owningKey)) - assert(!ptx.tx.requiredSigningKeys.contains(b.info.legalIdentities.first().owningKey)) - + assertFalse(ptx.tx.requiredSigningKeys.contains(a.info.legalIdentities.first().owningKey)) + assertFalse(ptx.tx.requiredSigningKeys.contains(b.info.legalIdentities.first().owningKey)) } } diff --git a/Features/constants.properties b/Features/constants.properties deleted file mode 100644 index 6425fb0b..00000000 --- a/Features/constants.properties +++ /dev/null @@ -1,12 +0,0 @@ -cordaReleaseGroup=net.corda -cordaCoreReleaseGroup=net.corda -cordaVersion=4.8.5 -cordaCoreVersion=4.8.5 -gradlePluginsVersion=5.0.12 -kotlinVersion=1.2.71 -junitVersion=4.12 -quasarVersion=0.7.10 -log4jVersion =2.17.1 -platformVersion=10 -slf4jVersion=1.7.25 -nettyVersion=4.1.22.Final diff --git a/Features/contractsdk-recordplayers/README.md b/Features/contractsdk-recordplayers/README.md index c1946c35..acfdf5ea 100644 --- a/Features/contractsdk-recordplayers/README.md +++ b/Features/contractsdk-recordplayers/README.md @@ -19,7 +19,7 @@ This repository demonstrates how you can configure and use it in your own projec Configuration is essentially three small steps: -- adding `maven { url 'https://software.r3.com/artifactory/corda-lib-dev' }` to `repositories.gradle` +- adding `maven { url 'https://software.r3.com/artifactory/corda-lib-dev' }` to `settings.gradle` - adding `compile "com.r3.corda.lib.contracts:contract-sdk:0.9-SNAPSHOT"` to the `build.gradle` file of your contract module in your cordapp - adding the annotations to your apps! @@ -42,7 +42,7 @@ Take a look at the small RecordPlayerContract sample in this repository to see h To run the cordapps, just use the gradle wrapper script the same way you normally would. ```sh -$ ./gradlew deployNodes +$ ../gradlew deployNodes $ ./build/nodes/runnodes >>> flow start net.corda.samples.contractsdk.flows.IssueRecordPlayerFlow dealer: "O=Alice Audio,L=New York,C=US", needle: spherical diff --git a/Features/contractsdk-recordplayers/build.gradle b/Features/contractsdk-recordplayers/build.gradle index c937c22a..d6d70af4 100644 --- a/Features/contractsdk-recordplayers/build.gradle +++ b/Features/contractsdk-recordplayers/build.gradle @@ -1,112 +1,69 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - - // springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { // Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':workflows') + cordapp project(':contracts') + cordapp "com.r3.corda.lib.contracts:contract-sdk:$contracts_sdk_version" - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -//Task to deploy the nodes in order to bootstrap a network -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { - +tasks.register('deployNodes', Cordform) { /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load * the Corda network bootstrapper. */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp project(':contracts') cordapp project(':workflows') + cordapp "com.r3.corda.lib.contracts:contract-sdk:$contracts_sdk_version" + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid // problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change // it to false for quicker project compiling time. @@ -120,6 +77,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10011") adminAddress("localhost:10021") } + rpcUsers = [] } node { name "O=Manufacturer,L=London,C=GB" @@ -128,7 +86,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10012") adminAddress("localhost:10022") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { @@ -138,9 +95,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10013") adminAddress("localhost:10023") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } - node { name "O=Bob Hustle Records,L=Egypt,C=US" p2pPort 10004 @@ -148,7 +103,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10014") adminAddress("localhost:10024") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } - } diff --git a/Features/contractsdk-recordplayers/clients/build.gradle b/Features/contractsdk-recordplayers/clients/build.gradle index eb58eac2..864e3037 100644 --- a/Features/contractsdk-recordplayers/clients/build.gradle +++ b/Features/contractsdk-recordplayers/clients/build.gradle @@ -1,4 +1,7 @@ -apply plugin: 'org.springframework.boot' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'org.springframework.boot' +} sourceSets { main { @@ -10,20 +13,19 @@ sourceSets { dependencies { // Corda dependencies. - compile "$corda_release_group:corda-rpc:$corda_release_version" + implementation "$corda_release_group:corda-rpc:$corda_release_version" // CorDapp dependencies. - compile project(":contracts") - compile project(":workflows") - compile("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { + implementation project(':contracts') + implementation project(':workflows') + implementation("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { exclude group: "org.springframework.boot", module: "spring-boot-starter-logging" } - compile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - compile "org.apache.logging.log4j:log4j-web:${log4j_version}" - compile "org.slf4j:jul-to-slf4j:$slf4j_version" + runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" + runtimeOnly "org.apache.logging.log4j:log4j-web:${log4j_version}" + runtimeOnly "org.slf4j:jul-to-slf4j:$slf4j_version" } - springBoot { mainClassName = "com.template.webserver.ServerKt" } @@ -32,7 +34,8 @@ springBoot { * execute your rpc methods in the main method of the client.kt. You can somewhat see this as a quick test of making * RPC calls to your nodes. */ -task runTemplateClient(type: JavaExec, dependsOn: assemble) { +tasks.register('runTemplateClient', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'com.template.ClientKt' args 'localhost:10006', 'user1', 'test' @@ -41,8 +44,9 @@ task runTemplateClient(type: JavaExec, dependsOn: assemble) { /* This task will start the springboot server that connects to your node (via RPC connection). All of the http requests * are in the Controller file. You can leave the Server.kt and NodeRPCConnection.kt file untouched for your use. */ -task runTemplateServer(type: JavaExec, dependsOn: assemble) { +tasks.register('runTemplateServer', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'com.template.webserver.ServerKt' args '--server.port=10050', '--config.rpc.host=localhost', '--config.rpc.port=10006', '--config.rpc.username=user1', '--config.rpc.password=test' -} \ No newline at end of file +} diff --git a/Features/contractsdk-recordplayers/contracts/build.gradle b/Features/contractsdk-recordplayers/contracts/build.gradle index 1970f312..9068bea0 100644 --- a/Features/contractsdk-recordplayers/contracts/build.gradle +++ b/Features/contractsdk-recordplayers/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "Contracts SDK - Record Player" vendor "Corda Open Source" @@ -12,39 +15,26 @@ cordapp { } sourceSets { - main { - java { - srcDir 'src/main/java' - java.outputDir = file('bin/main') - } - resources { - srcDir rootProject.file("config/dev") - } - } test { - java { - srcDir 'src/test/java' - java.outputDir = file('bin/main') - } resources { srcDir rootProject.file("config/test") } } integrationTest { - java { + kotlin { compileClasspath += main.output + test.output runtimeClasspath += main.output + test.output - srcDir file('src/integrationTest/java') + srcDir file('src/integrationTest/kotlin') } } } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - - compile "com.r3.corda.lib.contracts:contract-sdk:0.9-SNAPSHOT" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" + + cordapp "com.r3.corda.lib.contracts:contract-sdk:$contracts_sdk_version" } diff --git a/Features/contractsdk-recordplayers/contracts/src/main/kotlin/net/corda/samples/contractsdk/contracts/RecordPlayerContract.kt b/Features/contractsdk-recordplayers/contracts/src/main/kotlin/net/corda/samples/contractsdk/contracts/RecordPlayerContract.kt index 550e514c..28fd73d3 100644 --- a/Features/contractsdk-recordplayers/contracts/src/main/kotlin/net/corda/samples/contractsdk/contracts/RecordPlayerContract.kt +++ b/Features/contractsdk-recordplayers/contracts/src/main/kotlin/net/corda/samples/contractsdk/contracts/RecordPlayerContract.kt @@ -1,10 +1,8 @@ package net.corda.samples.contractsdk.contracts - import com.r3.corda.lib.contracts.contractsdk.StandardContract import com.r3.corda.lib.contracts.contractsdk.annotations.* import com.r3.corda.lib.contracts.contractsdk.verifiers.StandardCommand -import com.r3.corda.lib.contracts.contractsdk.verifiers.StandardState import net.corda.core.contracts.* import net.corda.core.transactions.LedgerTransaction @@ -40,10 +38,8 @@ class RecordPlayerContract : StandardContract(), Contract { class Update : Commands, StandardCommand { // We can add additional logic to the update command without adding extra boilerplate override fun verifyFurther(tx: LedgerTransaction) { - val inputs = tx.inputStates - val outputs = tx.outputStates - val oldRp = inputs[0] as RecordPlayerState - val newRp = outputs[0] as RecordPlayerState + val oldRp = tx.inputsOfType().single() + val newRp = tx.outputsOfType().single() // We can still use Corda DSL function requireThat to replicate conditions-checks requireThat { diff --git a/Features/contractsdk-recordplayers/contracts/src/main/kotlin/net/corda/samples/contractsdk/states/RecordPlayerState.kt b/Features/contractsdk-recordplayers/contracts/src/main/kotlin/net/corda/samples/contractsdk/states/RecordPlayerState.kt index d0a4bb1f..bc7c6c44 100644 --- a/Features/contractsdk-recordplayers/contracts/src/main/kotlin/net/corda/samples/contractsdk/states/RecordPlayerState.kt +++ b/Features/contractsdk-recordplayers/contracts/src/main/kotlin/net/corda/samples/contractsdk/states/RecordPlayerState.kt @@ -8,7 +8,6 @@ import net.corda.core.contracts.UniqueIdentifier import net.corda.core.identity.AbstractParty import net.corda.core.identity.Party import net.corda.core.serialization.ConstructorForDeserialization -import java.util.* import net.corda.samples.contractsdk.contracts.RecordPlayerContract @@ -45,7 +44,7 @@ class RecordPlayerState @ConstructorForDeserialization constructor(manufacturer: /* This method will indicate who are the participants and required signers when * this state is used in a transaction. */ override val participants: List - get() = Arrays.asList(manufacturer, dealer) + get() = listOf(manufacturer, dealer) fun update(needle: Needle?, magneticStrength: Int, coilTurns: Int, amplifierSNR: Int, songsPlayed: Int): RecordPlayerState { // take our params and apply them to the state object diff --git a/Features/contractsdk-recordplayers/contracts/src/test/kotlin/net/corda/samples/contractsdk/contracts/ContractTests.kt b/Features/contractsdk-recordplayers/contracts/src/test/kotlin/net/corda/samples/contractsdk/contracts/ContractTests.kt deleted file mode 100644 index cfddb693..00000000 --- a/Features/contractsdk-recordplayers/contracts/src/test/kotlin/net/corda/samples/contractsdk/contracts/ContractTests.kt +++ /dev/null @@ -1,35 +0,0 @@ -package net.corda.samples.contractsdk.contracts - -import net.corda.core.identity.CordaX500Name -import net.corda.testing.core.TestIdentity -import net.corda.testing.node.MockServices -import net.corda.testing.node.ledger -import org.junit.Test - -class ContractTests { - private val ledgerServices: MockServices = MockServices(listOf("com.template")) - var alice = TestIdentity(CordaX500Name("Alice", "TestLand", "US")) - var bob = TestIdentity(CordaX500Name("Alice", "TestLand", "US")) - - @Test - fun dummytest() { - val state = TemplateState("Hello-World", alice.party, bob.party) - ledgerServices.ledger { - // Should fail bid price is equal to previous highest bid - transaction { - //failing transaction - input(TemplateContract.ID, state) - output(TemplateContract.ID, state) - command(alice.publicKey, TemplateContract.Commands.Create()) - fails() - } - //pass - transaction { - //passing transaction - output(TemplateContract.ID, state) - command(alice.publicKey, TemplateContract.Commands.Create()) - verifies() - } - } - } -} diff --git a/Features/contractsdk-recordplayers/contracts/src/test/kotlin/net/corda/samples/contractsdk/contracts/StateTests.kt b/Features/contractsdk-recordplayers/contracts/src/test/kotlin/net/corda/samples/contractsdk/contracts/StateTests.kt deleted file mode 100644 index 096cdafb..00000000 --- a/Features/contractsdk-recordplayers/contracts/src/test/kotlin/net/corda/samples/contractsdk/contracts/StateTests.kt +++ /dev/null @@ -1,14 +0,0 @@ -package net.corda.samples.contractsdk.contracts - -import org.junit.Test -import kotlin.test.assertEquals - -class StateTests { - @Test - fun hasFieldOfCorrectType() { - // Does the field exist? - TemplateState::class.java.getDeclaredField("msg") - // Is the field of the correct type? - assertEquals(TemplateState::class.java.getDeclaredField("msg").type, String()::class.java) - } -} diff --git a/Features/contractsdk-recordplayers/gradle.properties b/Features/contractsdk-recordplayers/gradle.properties index c62b18d6..0fec4083 100644 --- a/Features/contractsdk-recordplayers/gradle.properties +++ b/Features/contractsdk-recordplayers/gradle.properties @@ -1,4 +1,28 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Contracts SDK - Record Player group=com.contractsdk version=0.1 -kotlin.incremental=false + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +contracts_sdk_version=0.9-SNAPSHOT + +spring_boot_version=2.0.2.RELEASE diff --git a/Features/contractsdk-recordplayers/gradle/wrapper/gradle-wrapper.jar b/Features/contractsdk-recordplayers/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Features/contractsdk-recordplayers/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Features/contractsdk-recordplayers/gradle/wrapper/gradle-wrapper.properties b/Features/contractsdk-recordplayers/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Features/contractsdk-recordplayers/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Features/contractsdk-recordplayers/gradlew b/Features/contractsdk-recordplayers/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Features/contractsdk-recordplayers/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Features/contractsdk-recordplayers/gradlew.bat b/Features/contractsdk-recordplayers/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Features/contractsdk-recordplayers/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Features/contractsdk-recordplayers/repositories.gradle b/Features/contractsdk-recordplayers/repositories.gradle deleted file mode 100644 index fe9d46cd..00000000 --- a/Features/contractsdk-recordplayers/repositories.gradle +++ /dev/null @@ -1,9 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } - maven { url 'https://software.r3.com/artifactory/corda-lib-dev' } -} diff --git a/Features/contractsdk-recordplayers/settings.gradle b/Features/contractsdk-recordplayers/settings.gradle index 2514aca2..b3c5c7b4 100644 --- a/Features/contractsdk-recordplayers/settings.gradle +++ b/Features/contractsdk-recordplayers/settings.gradle @@ -1,3 +1,39 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url "$artifactoryContextUrl/corda-lib-dev" + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file +include 'clients' diff --git a/Features/contractsdk-recordplayers/workflows/build.gradle b/Features/contractsdk-recordplayers/workflows/build.gradle index 54bd7131..4e326585 100644 --- a/Features/contractsdk-recordplayers/workflows/build.gradle +++ b/Features/contractsdk-recordplayers/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "Contracts SDK - Record Player" vendor "Corda Open Source" @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,25 +31,24 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') + cordapp "com.r3.corda.lib.contracts:contract-sdk:$contracts_sdk_version" } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath } diff --git a/Features/contractsdk-recordplayers/workflows/src/integrationTest/kotlin/net/corda/samples/contractsdk/DriverBasedTest.kt b/Features/contractsdk-recordplayers/workflows/src/integrationTest/kotlin/net/corda/samples/contractsdk/DriverBasedTest.kt index b9477b54..95a3850a 100644 --- a/Features/contractsdk-recordplayers/workflows/src/integrationTest/kotlin/net/corda/samples/contractsdk/DriverBasedTest.kt +++ b/Features/contractsdk-recordplayers/workflows/src/integrationTest/kotlin/net/corda/samples/contractsdk/DriverBasedTest.kt @@ -7,9 +7,9 @@ import net.corda.testing.driver.DriverDSL import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.driver +import org.junit.Assert.assertEquals import org.junit.Test import java.util.concurrent.Future -import kotlin.test.assertEquals class DriverBasedTest { private val bankA = TestIdentity(CordaX500Name("BankA", "", "GB")) diff --git a/Features/contractsdk-recordplayers/workflows/src/main/kotlin/net/corda/samples/contractsdk/flows/UpdateRecordPlayerFlow.kt b/Features/contractsdk-recordplayers/workflows/src/main/kotlin/net/corda/samples/contractsdk/flows/UpdateRecordPlayerFlow.kt index 5f6c056e..423d3d4b 100644 --- a/Features/contractsdk-recordplayers/workflows/src/main/kotlin/net/corda/samples/contractsdk/flows/UpdateRecordPlayerFlow.kt +++ b/Features/contractsdk-recordplayers/workflows/src/main/kotlin/net/corda/samples/contractsdk/flows/UpdateRecordPlayerFlow.kt @@ -16,7 +16,6 @@ import net.corda.core.utilities.ProgressTracker import net.corda.samples.contractsdk.contracts.RecordPlayerContract import net.corda.samples.contractsdk.states.Needle import net.corda.samples.contractsdk.states.RecordPlayerState -import java.util.* import java.util.stream.Collectors // ****************** @@ -37,7 +36,7 @@ class UpdateRecordPlayerFlow(stateId: UniqueIdentifier, needleId: String, magnet @Suspendable @Throws(FlowException::class) override fun call(): SignedTransaction { - val listOfLinearIds = Arrays.asList(stateId.id) + val listOfLinearIds = listOf(stateId.id) val queryCriteria: QueryCriteria = LinearStateQueryCriteria(null, listOfLinearIds) val (states) = serviceHub.vaultService.queryBy(RecordPlayerState::class.java, queryCriteria) val inputStateAndRef = states[0] as StateAndRef<*> @@ -51,7 +50,7 @@ class UpdateRecordPlayerFlow(stateId: UniqueIdentifier, needleId: String, magnet val notary = serviceHub.networkMapCache.getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")) // METHOD 2 val command = Command( RecordPlayerContract.Commands.Update(), - Arrays.asList(manufacturer.owningKey, dealer.owningKey) + listOf(manufacturer.owningKey, dealer.owningKey) ) // Create a new TransactionBuilder object. diff --git a/Features/contractsdk-recordplayers/workflows/src/test/kotlin/net/corda/samples/contractsdk/flows/IssueRecordPlayerFlowTests.kt b/Features/contractsdk-recordplayers/workflows/src/test/kotlin/net/corda/samples/contractsdk/flows/IssueRecordPlayerFlowTests.kt index 8a529b2e..08d20185 100644 --- a/Features/contractsdk-recordplayers/workflows/src/test/kotlin/net/corda/samples/contractsdk/flows/IssueRecordPlayerFlowTests.kt +++ b/Features/contractsdk-recordplayers/workflows/src/test/kotlin/net/corda/samples/contractsdk/flows/IssueRecordPlayerFlowTests.kt @@ -2,7 +2,6 @@ package net.corda.samples.contractsdk.flows import com.google.common.collect.ImmutableList import net.corda.core.contracts.UniqueIdentifier -import net.corda.core.crypto.SecureHash import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party import net.corda.core.node.NetworkParameters @@ -10,11 +9,12 @@ import net.corda.core.utilities.getOrThrow import net.corda.samples.contractsdk.states.Needle import net.corda.samples.contractsdk.states.RecordPlayerState import net.corda.testing.node.* -import org.jgroups.util.Util -import org.junit.* +import org.junit.After +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotEquals +import org.junit.Before +import org.junit.Test import java.time.Instant -import java.util.* -import kotlin.collections.LinkedHashMap /** * Practical exercise instructions Flows part 1. @@ -22,15 +22,15 @@ import kotlin.collections.LinkedHashMap */ class IssueRecordPlayerFlowTests { - lateinit var network: MockNetwork - lateinit var manufacturerNode: StartedMockNode - lateinit var dealerBNode: StartedMockNode - lateinit var dealerCNode: StartedMockNode - lateinit var manufacturer: Party - lateinit var dealerB: Party - lateinit var dealerC: Party + private lateinit var network: MockNetwork + private lateinit var manufacturerNode: StartedMockNode + private lateinit var dealerBNode: StartedMockNode + private lateinit var dealerCNode: StartedMockNode + private lateinit var manufacturer: Party + private lateinit var dealerB: Party + private lateinit var dealerC: Party - val testNetworkParameters = NetworkParameters(4, Arrays.asList(), 10485760, 10485760 * 5, Instant.now(), 1, LinkedHashMap>()) + private val testNetworkParameters = NetworkParameters(4, emptyList(), 10485760, 10485760 * 5, Instant.now(), 1, LinkedHashMap()) @Before fun setup() { @@ -52,7 +52,9 @@ class IssueRecordPlayerFlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test @@ -65,9 +67,9 @@ class IssueRecordPlayerFlowTests { val signedTransaction = future.get() if (signedTransaction != null) { - Util.assertEquals(1, signedTransaction.tx.outputStates.size) + assertEquals(1, signedTransaction.tx.outputStates.size) } - Util.assertEquals(network.notaryNodes[0].info.legalIdentities[0], signedTransaction?.notary) + assertEquals(network.notaryNodes[0].info.legalIdentities[0], signedTransaction?.notary) } @Test @@ -80,7 +82,7 @@ class IssueRecordPlayerFlowTests { val ptx = future.getOrThrow() val (_, contract) = ptx!!.tx.outputs.single() - Util.assertEquals("net.corda.samples.contractsdk.contracts.RecordPlayerContract", contract) + assertEquals("net.corda.samples.contractsdk.contracts.RecordPlayerContract", contract) } @Test @@ -94,9 +96,9 @@ class IssueRecordPlayerFlowTests { val output = signedTransaction!!.tx.outputsOfType(RecordPlayerState::class.java)[0] // get some random data from the output to verify - Util.assertEquals(st.manufacturer, output.manufacturer) - Util.assertEquals(st.dealer, output.dealer) - Assert.assertNotEquals(st.dealer, output.manufacturer) - Util.assertEquals(st.needle, output.needle) + assertEquals(st.manufacturer, output.manufacturer) + assertEquals(st.dealer, output.dealer) + assertNotEquals(st.dealer, output.manufacturer) + assertEquals(st.needle, output.needle) } } diff --git a/Features/contractsdk-recordplayers/workflows/src/test/kotlin/net/corda/samples/contractsdk/flows/UpdateRecordPlayerFlowTests.kt b/Features/contractsdk-recordplayers/workflows/src/test/kotlin/net/corda/samples/contractsdk/flows/UpdateRecordPlayerFlowTests.kt index 26eaa7fe..edbf6acc 100644 --- a/Features/contractsdk-recordplayers/workflows/src/test/kotlin/net/corda/samples/contractsdk/flows/UpdateRecordPlayerFlowTests.kt +++ b/Features/contractsdk-recordplayers/workflows/src/test/kotlin/net/corda/samples/contractsdk/flows/UpdateRecordPlayerFlowTests.kt @@ -1,29 +1,29 @@ package net.corda.samples.contractsdk.flows import com.google.common.collect.ImmutableList -import net.corda.core.crypto.SecureHash import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party import net.corda.core.node.NetworkParameters import net.corda.samples.contractsdk.states.Needle import net.corda.samples.contractsdk.states.RecordPlayerState import net.corda.testing.node.* -import org.jgroups.util.Util -import org.junit.* import java.time.Instant -import java.util.* -import kotlin.collections.LinkedHashMap +import org.junit.After +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotEquals +import org.junit.Before +import org.junit.Test class UpdateRecordPlayerFlowTests { - lateinit var network: MockNetwork - lateinit var manufacturerNode: StartedMockNode - lateinit var dealerBNode: StartedMockNode - lateinit var dealerCNode: StartedMockNode - lateinit var manufacturer: Party - lateinit var dealerB: Party - lateinit var dealerC: Party + private lateinit var network: MockNetwork + private lateinit var manufacturerNode: StartedMockNode + private lateinit var dealerBNode: StartedMockNode + private lateinit var dealerCNode: StartedMockNode + private lateinit var manufacturer: Party + private lateinit var dealerB: Party + private lateinit var dealerC: Party - val testNetworkParameters = NetworkParameters(4, Arrays.asList(), 10485760, 10485760 * 5, Instant.now(), 1, LinkedHashMap>()) + private val testNetworkParameters = NetworkParameters(4, emptyList(), 10485760, 10485760 * 5, Instant.now(), 1, LinkedHashMap()) @Before fun setup() { @@ -45,7 +45,9 @@ class UpdateRecordPlayerFlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test @@ -62,8 +64,8 @@ class UpdateRecordPlayerFlowTests { val signedTransaction = future.get() // assert our contract SDK conditions - Util.assertEquals(1, signedTransaction!!.tx.outputStates.size) - Util.assertEquals(network.notaryNodes[0].info.legalIdentities[0], signedTransaction!!.notary) + assertEquals(1, signedTransaction!!.tx.outputStates.size) + assertEquals(network.notaryNodes[0].info.legalIdentities[0], signedTransaction.notary) } // ensure that our linear state updates work correctly @@ -72,7 +74,7 @@ class UpdateRecordPlayerFlowTests { fun flowUpdateTest() { val f1 = IssueRecordPlayerFlow(dealerB, "SPHERICAL") val future = manufacturerNode.startFlow(f1) - network!!.runNetwork() + network.runNetwork() val f1Output = future.get()!!.tx.outputsOfType(RecordPlayerState::class.java)[0] val f2 = UpdateRecordPlayerFlow( @@ -85,10 +87,10 @@ class UpdateRecordPlayerFlowTests { val future2 = dealerBNode.startFlow(f2) network.runNetwork() val f2Output = future2.get()!!.tx.outputsOfType(RecordPlayerState::class.java)[0] - Util.assertEquals(Needle.SPHERICAL, f1Output.needle) - Util.assertEquals(Needle.DAMAGED, f2Output.needle) - Util.assertEquals(f1Output.magneticStrength, f2Output.magneticStrength) - Util.assertEquals(f1Output.songsPlayed + 5, f2Output.songsPlayed) - Assert.assertNotEquals(f1Output.songsPlayed.toLong(), f2Output.songsPlayed.toLong()) + assertEquals(Needle.SPHERICAL, f1Output.needle) + assertEquals(Needle.DAMAGED, f2Output.needle) + assertEquals(f1Output.magneticStrength, f2Output.magneticStrength) + assertEquals(f1Output.songsPlayed + 5, f2Output.songsPlayed) + assertNotEquals(f1Output.songsPlayed.toLong(), f2Output.songsPlayed.toLong()) } } diff --git a/Features/cordaService-autopayroll/README.md b/Features/cordaService-autopayroll/README.md index 03e5d628..e1d347f9 100644 --- a/Features/cordaService-autopayroll/README.md +++ b/Features/cordaService-autopayroll/README.md @@ -25,7 +25,7 @@ For development environment setup, please refer to: [Setup Guide](https://docs.c ### Deploy and run the node ``` -./greadlew deployNodes +../gradlew clean deployNodes ./build/node/runnodes ``` diff --git a/Features/cordaService-autopayroll/build.gradle b/Features/cordaService-autopayroll/build.gradle index 61288215..2c9d3d3c 100644 --- a/Features/cordaService-autopayroll/build.gradle +++ b/Features/cordaService-autopayroll/build.gradle @@ -1,123 +1,70 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':workflows') + cordapp project(':contracts') - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = true - } - cordapp project(':contracts') cordapp project(':workflows') - - } - node { - name "O=Notary,L=London,C=GB" - notary = [validating : false] - p2pPort 10002 - rpcSettings { - address("localhost:10003") - adminAddress("localhost:10043") - } - } - node { - name "O=FinanceTeam,L=London,C=GB" - p2pPort 10005 - rpcSettings { - address("localhost:10006") - adminAddress("localhost:10046") - } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] + cordapp project(':contracts') + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { name "O=PetersonThomas,L=New York,C=US" @@ -126,7 +73,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] + rpcUsers = [] } node { name "O=GeorgeJefferson,L=San Diego,C=US" @@ -135,7 +82,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10012") adminAddress("localhost:10052") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=BankOperator,L=Toronto,C=CA" @@ -144,6 +90,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10015") adminAddress("localhost:10055") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } -} \ No newline at end of file +} diff --git a/Features/cordaService-autopayroll/contracts/build.gradle b/Features/cordaService-autopayroll/contracts/build.gradle index c2a8b119..f0eafea2 100644 --- a/Features/cordaService-autopayroll/contracts/build.gradle +++ b/Features/cordaService-autopayroll/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "AutoPayroll Contracts" vendor "Corda Open Source" @@ -12,10 +15,10 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" -} \ No newline at end of file + cordaProvided "$corda_core_group:corda-core:$corda_release_version" +} diff --git a/Features/cordaService-autopayroll/contracts/src/main/kotlin/net/corda/samples/autopayroll/contracts/MoneyStateContract.kt b/Features/cordaService-autopayroll/contracts/src/main/kotlin/net/corda/samples/autopayroll/contracts/MoneyStateContract.kt index 1c6f49e5..3e9a41cb 100644 --- a/Features/cordaService-autopayroll/contracts/src/main/kotlin/net/corda/samples/autopayroll/contracts/MoneyStateContract.kt +++ b/Features/cordaService-autopayroll/contracts/src/main/kotlin/net/corda/samples/autopayroll/contracts/MoneyStateContract.kt @@ -6,6 +6,7 @@ import net.corda.core.contracts.Contract import net.corda.core.transactions.LedgerTransaction import net.corda.core.contracts.requireSingleCommand import net.corda.core.contracts.requireThat + // ************ // * Contract * // ************ diff --git a/Features/cordaService-autopayroll/contracts/src/main/kotlin/net/corda/samples/autopayroll/contracts/PaymentRequestContract.kt b/Features/cordaService-autopayroll/contracts/src/main/kotlin/net/corda/samples/autopayroll/contracts/PaymentRequestContract.kt index 4d250adf..3e10cfc5 100644 --- a/Features/cordaService-autopayroll/contracts/src/main/kotlin/net/corda/samples/autopayroll/contracts/PaymentRequestContract.kt +++ b/Features/cordaService-autopayroll/contracts/src/main/kotlin/net/corda/samples/autopayroll/contracts/PaymentRequestContract.kt @@ -6,6 +6,7 @@ import net.corda.core.contracts.Contract import net.corda.core.contracts.requireSingleCommand import net.corda.core.contracts.requireThat import net.corda.core.transactions.LedgerTransaction + // ************ // * Contract * // ************ diff --git a/Features/cordaService-autopayroll/contracts/src/test/kotlin/net/corda/samples/autopayroll/ContractTests.kt b/Features/cordaService-autopayroll/contracts/src/test/kotlin/net/corda/samples/autopayroll/ContractTests.kt index 8d0cfe42..eb194ed8 100644 --- a/Features/cordaService-autopayroll/contracts/src/test/kotlin/net/corda/samples/autopayroll/ContractTests.kt +++ b/Features/cordaService-autopayroll/contracts/src/test/kotlin/net/corda/samples/autopayroll/ContractTests.kt @@ -10,25 +10,25 @@ import org.junit.Test class ContractTests { private val ledgerServices = MockServices() - val partya = TestIdentity(CordaX500Name(organisation = "Alice", locality = "TestLand", country = "US")) - var partyb = TestIdentity(CordaX500Name("Bob", "TestLand", "US")) + private val partyA = TestIdentity(CordaX500Name(organisation = "Alice", locality = "TestLand", country = "US")) + private val partyB = TestIdentity(CordaX500Name("Bob", "TestLand", "US")) @Test fun `No Negative PayCheck Value`() { - val tokenPass = MoneyState(10, partyb.party) - val tokenFail = MoneyState(-10, partyb.party) + val tokenPass = MoneyState(10, partyB.party) + val tokenFail = MoneyState(-10, partyB.party) ledgerServices.ledger { transaction { output(MoneyStateContract.ID, tokenFail) - command(partya.publicKey, MoneyStateContract.Commands.Pay()) + command(partyA.publicKey, MoneyStateContract.Commands.Pay()) this.fails() } } ledgerServices.ledger { transaction { output(MoneyStateContract.ID, tokenPass) - command(partya.publicKey, MoneyStateContract.Commands.Pay()) + command(partyA.publicKey, MoneyStateContract.Commands.Pay()) this.verifies() } } diff --git a/Features/cordaService-autopayroll/contracts/src/test/kotlin/net/corda/samples/autopayroll/StateTests.kt b/Features/cordaService-autopayroll/contracts/src/test/kotlin/net/corda/samples/autopayroll/StateTests.kt index dd63e2fc..faf7c91b 100644 --- a/Features/cordaService-autopayroll/contracts/src/test/kotlin/net/corda/samples/autopayroll/StateTests.kt +++ b/Features/cordaService-autopayroll/contracts/src/test/kotlin/net/corda/samples/autopayroll/StateTests.kt @@ -1,14 +1,10 @@ package net.corda.samples.autopayroll -import groovy.util.GroovyTestCase.assertEquals -import net.corda.core.contracts.UniqueIdentifier import net.corda.samples.autopayroll.states.MoneyState -import net.corda.testing.node.MockServices +import org.junit.Assert.assertEquals import org.junit.Test class StateTests { - private val ledgerServices = MockServices() - @Test fun hasFieldOfCorrectType() { // Does the message field exist? diff --git a/Features/cordaService-autopayroll/gradle.properties b/Features/cordaService-autopayroll/gradle.properties index 19c3a5be..373c4b69 100644 --- a/Features/cordaService-autopayroll/gradle.properties +++ b/Features/cordaService-autopayroll/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Autopayroll Cordapp group=net.autopayroll version=0.1 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Features/cordaService-autopayroll/gradle/wrapper/gradle-wrapper.jar b/Features/cordaService-autopayroll/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Features/cordaService-autopayroll/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Features/cordaService-autopayroll/gradle/wrapper/gradle-wrapper.properties b/Features/cordaService-autopayroll/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Features/cordaService-autopayroll/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Features/cordaService-autopayroll/gradlew b/Features/cordaService-autopayroll/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Features/cordaService-autopayroll/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Features/cordaService-autopayroll/gradlew.bat b/Features/cordaService-autopayroll/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Features/cordaService-autopayroll/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Features/cordaService-autopayroll/repositories.gradle b/Features/cordaService-autopayroll/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Features/cordaService-autopayroll/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Features/cordaService-autopayroll/settings.gradle b/Features/cordaService-autopayroll/settings.gradle index b4446eaf..c1f46514 100644 --- a/Features/cordaService-autopayroll/settings.gradle +++ b/Features/cordaService-autopayroll/settings.gradle @@ -1,2 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' -include 'contracts' \ No newline at end of file +include 'contracts' diff --git a/Features/cordaService-autopayroll/workflows/build.gradle b/Features/cordaService-autopayroll/workflows/build.gradle index f00b1bc0..c8bfe1d4 100644 --- a/Features/cordaService-autopayroll/workflows/build.gradle +++ b/Features/cordaService-autopayroll/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "autopayroll Flows" vendor "Corda Open Source" @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,25 +31,23 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } task integrationTest(type: Test, dependsOn: []) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Features/cordaService-autopayroll/workflows/src/integrationTest/kotlin/net/corda/samples/autopayroll/DriverBasedTest.kt b/Features/cordaService-autopayroll/workflows/src/integrationTest/kotlin/net/corda/samples/autopayroll/DriverBasedTest.kt index 4485656c..e5c55785 100644 --- a/Features/cordaService-autopayroll/workflows/src/integrationTest/kotlin/net/corda/samples/autopayroll/DriverBasedTest.kt +++ b/Features/cordaService-autopayroll/workflows/src/integrationTest/kotlin/net/corda/samples/autopayroll/DriverBasedTest.kt @@ -7,9 +7,9 @@ import net.corda.testing.driver.DriverDSL import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.driver +import org.junit.Assert.assertEquals import org.junit.Test import java.util.concurrent.Future -import kotlin.test.assertEquals class DriverBasedTest { private val bankA = TestIdentity(CordaX500Name("BankA", "", "GB")) diff --git a/Features/cordaService-autopayroll/workflows/src/test/kotlin/net/corda/samples/autopayroll/FlowTests.kt b/Features/cordaService-autopayroll/workflows/src/test/kotlin/net/corda/samples/autopayroll/FlowTests.kt index 4001aa7a..4ba1ef99 100644 --- a/Features/cordaService-autopayroll/workflows/src/test/kotlin/net/corda/samples/autopayroll/FlowTests.kt +++ b/Features/cordaService-autopayroll/workflows/src/test/kotlin/net/corda/samples/autopayroll/FlowTests.kt @@ -2,7 +2,6 @@ package net.corda.samples.autopayroll import net.corda.samples.autopayroll.flows.RequestFlowInitiator import net.corda.samples.autopayroll.flows.RequestFlowResponder -import groovy.util.GroovyTestCase.assertEquals import net.corda.core.identity.CordaX500Name import net.corda.core.transactions.SignedTransaction import net.corda.testing.node.MockNetwork @@ -10,6 +9,7 @@ import net.corda.testing.node.MockNetworkNotarySpec import net.corda.testing.node.MockNetworkParameters import net.corda.testing.node.TestCordapp import org.junit.After +import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test @@ -39,7 +39,7 @@ class FlowTests { //Test #1 check if the requestState is being sent to the bank operator behind the scene. @Test - fun `requestStateSent`() { + fun requestStateSent() { val future = a.startFlow(RequestFlowInitiator("500", b.info.legalIdentities.first())) network.runNetwork() val ptx = future.get() diff --git a/Features/customlogging-yocordapp/README.md b/Features/customlogging-yocordapp/README.md index 2522f7ba..a091864f 100644 --- a/Features/customlogging-yocordapp/README.md +++ b/Features/customlogging-yocordapp/README.md @@ -79,7 +79,7 @@ See https://docs.corda.net/getting-set-up.html. Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) diff --git a/Features/customlogging-yocordapp/build.gradle b/Features/customlogging-yocordapp/build.gradle index 6d3ba637..bd86d910 100644 --- a/Features/customlogging-yocordapp/build.gradle +++ b/Features/customlogging-yocordapp/build.gradle @@ -1,122 +1,70 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':workflows') + cordapp project(':contracts') - cordaCompile "org.apache.logging.log4j:log4j-core:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -//Task to deploy the nodes in order to bootstrap a network -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { - +tasks.register('deployNodes', Cordform) { /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load * the Corda network bootstrapper. */ nodeDefaults { - projectCordapp { - deploy = false - } - cordapp project(':contracts') cordapp project(':workflows') - - runSchemaMigration = false - - // there are other ways to specify that config for example - extraConfig = [ - custom: [ - jvmArgs: ["-Dlog4j.configurationFile="+projectDir+"/config/dev/log4j2.xml"] - ] - ] + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { name "O=Notary,L=London,C=GB" @@ -126,6 +74,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { name "O=PartyA,L=London,C=GB" @@ -134,7 +83,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=PartyB,L=New York,C=US" @@ -143,7 +91,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } - } diff --git a/Features/customlogging-yocordapp/contracts/build.gradle b/Features/customlogging-yocordapp/contracts/build.gradle index 7c539baf..40558170 100644 --- a/Features/customlogging-yocordapp/contracts/build.gradle +++ b/Features/customlogging-yocordapp/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "Logging CorDapp" vendor "Corda Open Source" @@ -12,8 +15,10 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" + // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Features/customlogging-yocordapp/contracts/src/main/kotlin/net/corda/samples/logging/states/YoState.kt b/Features/customlogging-yocordapp/contracts/src/main/kotlin/net/corda/samples/logging/states/YoState.kt index f0eee1de..e9229547 100644 --- a/Features/customlogging-yocordapp/contracts/src/main/kotlin/net/corda/samples/logging/states/YoState.kt +++ b/Features/customlogging-yocordapp/contracts/src/main/kotlin/net/corda/samples/logging/states/YoState.kt @@ -6,7 +6,6 @@ import net.corda.core.identity.AbstractParty import net.corda.core.identity.Party import net.corda.core.serialization.ConstructorForDeserialization import net.corda.samples.logging.contracts.YoContract -import java.util.* // ********* // * State * @@ -31,7 +30,7 @@ class YoState : ContractState { } override val participants: List - get() = Arrays.asList(target) + get() = listOf(target) override fun toString(): String { return origin.name.toString() + ": " + yo diff --git a/Features/customlogging-yocordapp/contracts/src/test/kotlin/net/corda/samples/logging/contracts/ContractTests.kt b/Features/customlogging-yocordapp/contracts/src/test/kotlin/net/corda/samples/logging/contracts/ContractTests.kt index 04f5ed6a..edc45d95 100644 --- a/Features/customlogging-yocordapp/contracts/src/test/kotlin/net/corda/samples/logging/contracts/ContractTests.kt +++ b/Features/customlogging-yocordapp/contracts/src/test/kotlin/net/corda/samples/logging/contracts/ContractTests.kt @@ -1,13 +1,9 @@ package net.corda.samples.logging.contracts -import net.corda.testing.node.MockServices import org.junit.Test class ContractTests { - private val ledgerServices = MockServices() - @Test fun `dummy test`() { - } } diff --git a/Features/customlogging-yocordapp/contracts/src/test/kotlin/net/corda/samples/logging/states/StateTests.kt b/Features/customlogging-yocordapp/contracts/src/test/kotlin/net/corda/samples/logging/states/StateTests.kt index db6b8132..2f507504 100644 --- a/Features/customlogging-yocordapp/contracts/src/test/kotlin/net/corda/samples/logging/states/StateTests.kt +++ b/Features/customlogging-yocordapp/contracts/src/test/kotlin/net/corda/samples/logging/states/StateTests.kt @@ -1,13 +1,9 @@ package net.corda.samples.logging.states -import net.corda.testing.node.MockServices import org.junit.Test class StateTests { - private val ledgerServices = MockServices() - @Test fun `dummy test`() { - } } diff --git a/Features/customlogging-yocordapp/gradle.properties b/Features/customlogging-yocordapp/gradle.properties index 8cad0ede..af3bf828 100644 --- a/Features/customlogging-yocordapp/gradle.properties +++ b/Features/customlogging-yocordapp/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Logging CorDapp group=net.corda.samples.logging version=0.1 -kotlin.incremental=false + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Features/customlogging-yocordapp/gradle/wrapper/gradle-wrapper.jar b/Features/customlogging-yocordapp/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Features/customlogging-yocordapp/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Features/customlogging-yocordapp/gradle/wrapper/gradle-wrapper.properties b/Features/customlogging-yocordapp/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Features/customlogging-yocordapp/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Features/customlogging-yocordapp/gradlew b/Features/customlogging-yocordapp/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Features/customlogging-yocordapp/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Features/customlogging-yocordapp/gradlew.bat b/Features/customlogging-yocordapp/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Features/customlogging-yocordapp/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Features/customlogging-yocordapp/repositories.gradle b/Features/customlogging-yocordapp/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Features/customlogging-yocordapp/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Features/customlogging-yocordapp/settings.gradle b/Features/customlogging-yocordapp/settings.gradle index 0473ad43..c1f46514 100644 --- a/Features/customlogging-yocordapp/settings.gradle +++ b/Features/customlogging-yocordapp/settings.gradle @@ -1,2 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' diff --git a/Features/customlogging-yocordapp/workflows/build.gradle b/Features/customlogging-yocordapp/workflows/build.gradle index b03ce715..1c45c33d 100644 --- a/Features/customlogging-yocordapp/workflows/build.gradle +++ b/Features/customlogging-yocordapp/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "Logging CorDapp" vendor "Corda Open Source" @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,27 +31,25 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "org.apache.logging.log4j:log4j-core:${log4j_version}" - - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" + cordaProvided "org.apache.logging.log4j:log4j-api:$log4j_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath } diff --git a/Features/customlogging-yocordapp/workflows/src/integrationTest/kotlin/net/corda/samples/logging/flows/DriverBasedTest.kt b/Features/customlogging-yocordapp/workflows/src/integrationTest/kotlin/net/corda/samples/logging/flows/DriverBasedTest.kt index ffcdc75c..fbf322c9 100644 --- a/Features/customlogging-yocordapp/workflows/src/integrationTest/kotlin/net/corda/samples/logging/flows/DriverBasedTest.kt +++ b/Features/customlogging-yocordapp/workflows/src/integrationTest/kotlin/net/corda/samples/logging/flows/DriverBasedTest.kt @@ -7,9 +7,9 @@ import net.corda.testing.driver.DriverDSL import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.driver +import org.junit.Assert.assertEquals import org.junit.Test import java.util.concurrent.Future -import kotlin.test.assertEquals class DriverBasedTest { private val bankA = TestIdentity(CordaX500Name("BankA", "", "GB")) diff --git a/Features/customlogging-yocordapp/workflows/src/main/kotlin/net/corda/samples/logging/flows/Flows.kt b/Features/customlogging-yocordapp/workflows/src/main/kotlin/net/corda/samples/logging/flows/Flows.kt deleted file mode 100644 index c789549d..00000000 --- a/Features/customlogging-yocordapp/workflows/src/main/kotlin/net/corda/samples/logging/flows/Flows.kt +++ /dev/null @@ -1,27 +0,0 @@ -package net.corda.samples.logging.flows - -import co.paralleluniverse.fibers.Suspendable -import net.corda.core.flows.* -import net.corda.core.utilities.ProgressTracker - -// ********* -// * Flows * -// ********* -@InitiatingFlow -@StartableByRPC -class Initiator : FlowLogic() { - override val progressTracker = ProgressTracker() - - @Suspendable - override fun call() { - // Initiator flow logic goes here. - } -} - -@InitiatedBy(Initiator::class) -class Responder(val counterpartySession: FlowSession) : FlowLogic() { - @Suspendable - override fun call() { - // Responder flow logic goes here. - } -} diff --git a/Features/customlogging-yocordapp/workflows/src/main/kotlin/net/corda/samples/logging/flows/YoFlow.kt b/Features/customlogging-yocordapp/workflows/src/main/kotlin/net/corda/samples/logging/flows/YoFlow.kt index 036ab406..efbdfc88 100644 --- a/Features/customlogging-yocordapp/workflows/src/main/kotlin/net/corda/samples/logging/flows/YoFlow.kt +++ b/Features/customlogging-yocordapp/workflows/src/main/kotlin/net/corda/samples/logging/flows/YoFlow.kt @@ -13,8 +13,6 @@ import net.corda.samples.logging.contracts.YoContract import net.corda.samples.logging.states.YoState import org.apache.logging.log4j.ThreadContext import org.slf4j.LoggerFactory -import java.util.* - // ********* // * Flows * @@ -51,11 +49,11 @@ class YoFlow(private val target: Party) : FlowLogic() { // publish to the log with the additional context logger.info("Initializing the transaction.") // flush the threadContext - ThreadContext.removeAll(Arrays.asList("initiator", "target")) + ThreadContext.removeAll(listOf("initiator", "target")) // Obtain a reference from a notary we wish to use. val notary = serviceHub.networkMapCache.getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")) // METHOD 2 - val command = Command(YoContract.Commands.Send(), Arrays.asList(me.owningKey)) + val command = Command(YoContract.Commands.Send(), listOf(me.owningKey)) val state = YoState(me, target) val stateAndContract = StateAndContract(state, YoContract.ID) val utx = TransactionBuilder(notary).withItems(stateAndContract, command) @@ -70,7 +68,7 @@ class YoFlow(private val target: Party) : FlowLogic() { // publish to the log with the additional context logger.info("Finalizing the transaction.") // flush the threadContext - ThreadContext.removeAll(Arrays.asList("tx_id", "notary")) + ThreadContext.removeAll(listOf("tx_id", "notary")) progressTracker.currentStep = FINALISING val targetSession = initiateFlow(target) diff --git a/Features/customlogging-yocordapp/workflows/src/test/kotlin/net/corda/samples/logging/flows/FlowTests.kt b/Features/customlogging-yocordapp/workflows/src/test/kotlin/net/corda/samples/logging/flows/FlowTests.kt index cd1748e5..1242da9d 100644 --- a/Features/customlogging-yocordapp/workflows/src/test/kotlin/net/corda/samples/logging/flows/FlowTests.kt +++ b/Features/customlogging-yocordapp/workflows/src/test/kotlin/net/corda/samples/logging/flows/FlowTests.kt @@ -1,24 +1,22 @@ package net.corda.samples.logging.flows - import net.corda.core.identity.CordaX500Name import net.corda.testing.node.* import org.junit.After import org.junit.Before import org.junit.Test import java.util.concurrent.ExecutionException - +import kotlin.test.assertTrue +import kotlin.test.fail class FlowTests { - - lateinit var mockNetwork: MockNetwork - lateinit var a: StartedMockNode - lateinit var b: StartedMockNode + private lateinit var mockNetwork: MockNetwork + private lateinit var a: StartedMockNode + private lateinit var b: StartedMockNode @Before fun setup() { - - val mockNetwork = MockNetwork(MockNetworkParameters(cordappsForAllNodes = listOf( + mockNetwork = MockNetwork(MockNetworkParameters(cordappsForAllNodes = listOf( TestCordapp.findCordapp("net.corda.samples.logging.contracts"), TestCordapp.findCordapp("net.corda.samples.logging.flows") ), @@ -29,26 +27,23 @@ class FlowTests { b = mockNetwork.createNode(MockNodeParameters()) val startedNodes = arrayListOf(a, b) // For real nodes this happens automatically, but we have to manually register the flow for tests - startedNodes.forEach { it.registerInitiatedFlow(Responder::class.java) } + startedNodes.forEach { it.registerInitiatedFlow(YoFlowResponder::class.java) } mockNetwork.runNetwork() } @After fun tearDown() { - - } - - @Test - fun `dummy test`() { + if (::mockNetwork.isInitialized) { + mockNetwork.stopNodes() + } } @Throws(ExecutionException::class, InterruptedException::class) + @Test fun dummyTest() { val future = a.startFlow(YoFlow(b.info.legalIdentities.first())) mockNetwork.runNetwork() - val ptx = future.get() - if (ptx != null) { - assert(ptx.tx.inputs.isEmpty()) - } + val ptx = future.get() ?: fail("No flow response") + assertTrue(ptx.tx.inputs.isEmpty()) } } diff --git a/Features/customquery-carinsurance/README.md b/Features/customquery-carinsurance/README.md index 40f45bd8..d90aa200 100644 --- a/Features/customquery-carinsurance/README.md +++ b/Features/customquery-carinsurance/README.md @@ -39,7 +39,7 @@ For development environment setup, please refer to: [Setup Guide](https://docs.c Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) diff --git a/Features/customquery-carinsurance/build.gradle b/Features/customquery-carinsurance/build.gradle index bb7ba836..c5a1396f 100644 --- a/Features/customquery-carinsurance/build.gradle +++ b/Features/customquery-carinsurance/build.gradle @@ -1,114 +1,80 @@ -buildscript { - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } + } - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } + pluginManager.withPlugin('org.jetbrains.kotlin.plugin.allopen') { + allOpen { + annotations( + 'javax.persistence.Entity', + 'javax.persistence.Embeddable', + 'javax.persistence.MappedSuperclass' + ) + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } +//Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaCompile "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':workflows') + cordapp project(':contracts') - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -cordapp { - info { - name "Queryablestate Car Insurance" - vendor "Corda Open Source" - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version - } -} -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = false - } - cordapp project(":contracts") - cordapp project(":workflows") - runSchemaMigration = true + cordapp project(':contracts') + cordapp project(':workflows') + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { name "O=Notary,L=London,C=GB" @@ -118,6 +84,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] cordapps.clear() } node { @@ -127,7 +94,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] extraConfig = ['h2Settings.address' : 'localhost:20041'] } node { @@ -137,7 +103,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] extraConfig = ['h2Settings.address' : 'localhost:20042'] } } diff --git a/Features/customquery-carinsurance/clients/build.gradle b/Features/customquery-carinsurance/clients/build.gradle index f0e4add4..bba079ea 100755 --- a/Features/customquery-carinsurance/clients/build.gradle +++ b/Features/customquery-carinsurance/clients/build.gradle @@ -1,17 +1,8 @@ -repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://dl.bintray.com/kotlin/exposed' } - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda-releases' } +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'io.spring.dependency-management' } -apply plugin: 'kotlin' -apply plugin: 'io.spring.dependency-management' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - sourceSets { main { resources { @@ -28,39 +19,26 @@ dependencyManagement { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" // Corda dependencies. - compile "net.corda:corda-core:$corda_release_version" - compile "net.corda:corda-jackson:$corda_release_version" - compile "net.corda:corda-rpc:$corda_release_version" - compile "net.corda:corda:$corda_release_version" - testCompile "net.corda:corda-node-driver:$corda_release_version" + implementation "net.corda:corda-core:$corda_release_version" + implementation "net.corda:corda-jackson:$corda_release_version" + implementation "net.corda:corda-rpc:$corda_release_version" - compile("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { + implementation("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { exclude group: "org.springframework.boot", module: "spring-boot-starter-logging" } - compile "org.springframework.boot:spring-boot-starter-log4j2:$spring_boot_version" - compile "org.apache.logging.log4j:log4j-web:$log4j_version" - - cordapp project(":workflows") - cordapp project(":contracts") + implementation "org.springframework.boot:spring-boot-starter-log4j2:$spring_boot_version" + implementation "org.apache.logging.log4j:log4j-web:$log4j_version" + implementation project(':workflows') + implementation project(':contracts') } -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { - kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" - javaParameters = true // Useful for reflection. - } -} - -task bootRun(type: JavaExec, dependsOn: jar) { +tasks.register('bootRun', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.carinsurance.server.ServerKt' args '--server.port=8080', '--config.rpc.host=localhost', '--config.rpc.port=10006', '--config.rpc.username=user1', '--config.rpc.password=test' diff --git a/Features/customquery-carinsurance/clients/src/main/kotlin/net/corda/samples/carinsurance/server/MainController.kt b/Features/customquery-carinsurance/clients/src/main/kotlin/net/corda/samples/carinsurance/server/MainController.kt index 8ff10fa5..dc2a8165 100755 --- a/Features/customquery-carinsurance/clients/src/main/kotlin/net/corda/samples/carinsurance/server/MainController.kt +++ b/Features/customquery-carinsurance/clients/src/main/kotlin/net/corda/samples/carinsurance/server/MainController.kt @@ -15,9 +15,6 @@ import org.springframework.http.MediaType.APPLICATION_JSON_VALUE import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* - -val SERVICE_NAMES = listOf("Notary", "Network Map Service") - /** * A Spring Boot Server API controller for interacting with the node via RPC. */ diff --git a/Features/customquery-carinsurance/contracts/build.gradle b/Features/customquery-carinsurance/contracts/build.gradle index e168f119..18d595ab 100644 --- a/Features/customquery-carinsurance/contracts/build.gradle +++ b/Features/customquery-carinsurance/contracts/build.gradle @@ -1,11 +1,15 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'org.jetbrains.kotlin.plugin.jpa' + id 'org.jetbrains.kotlin.plugin.allopen' + id 'net.corda.plugins.cordapp' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() minimumPlatformVersion corda_platform_version.toInteger() contract { - name "Queryablestate Car Insurance" + name "CustomQuery Car Insurance" vendor "Corda Open Source" licence "Apache License, Version 2.0" versionId 1 @@ -13,10 +17,10 @@ cordapp { } dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - compileOnly "$corda_release_group:corda-testserver-impl:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" + // Corda dependencies. + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Features/customquery-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/contracts/InsuranceContract.kt b/Features/customquery-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/contracts/InsuranceContract.kt index 0f3aa315..6efecf94 100644 --- a/Features/customquery-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/contracts/InsuranceContract.kt +++ b/Features/customquery-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/contracts/InsuranceContract.kt @@ -27,7 +27,7 @@ class InsuranceContract : Contract { "Transaction must have no input states." using (inputs.isEmpty()) } is Commands.AddClaim -> requireThat { - "Insurance transaction must have input states, the insurance police" using (!inputs.isEmpty()) + "Insurance transaction must have input states, the insurance police" using (inputs.isNotEmpty()) } } } diff --git a/Features/customquery-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/schema/InsuranceSchemaV1.kt b/Features/customquery-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/schema/InsuranceSchemaV1.kt index 7a277ecc..1fe6e26e 100644 --- a/Features/customquery-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/schema/InsuranceSchemaV1.kt +++ b/Features/customquery-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/schema/InsuranceSchemaV1.kt @@ -1,13 +1,20 @@ package net.corda.samples.carinsurance.schema //4.6 changes -import jdk.nashorn.internal.objects.annotations.Constructor import net.corda.core.schemas.MappedSchema import net.corda.core.schemas.PersistentState import org.hibernate.annotations.Type import java.io.Serializable -import java.util.* -import javax.persistence.* +import javax.persistence.CascadeType +import javax.persistence.Column +import javax.persistence.Entity +import javax.persistence.Id +import javax.persistence.JoinColumn +import javax.persistence.JoinColumns +import javax.persistence.OneToMany +import javax.persistence.OneToOne +import javax.persistence.Table +import java.util.UUID /** * The family of schemas for IOUState. @@ -22,8 +29,8 @@ object InsuranceSchemaV1 : MappedSchema( version = 1, mappedTypes = listOf(PersistentClaim::class.java, PersistentInsurance::class.java, PersistentVehicle::class.java)) { - override val migrationResource: String? - get() = "insurance.changelog-master"; + override val migrationResource: String + get() = "insurance.changelog-master" @Entity @Table(name = "CLAIM_DETAIL") diff --git a/Features/customquery-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/states/InsuranceState.kt b/Features/customquery-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/states/InsuranceState.kt index f9f36cfb..3bfb59d6 100644 --- a/Features/customquery-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/states/InsuranceState.kt +++ b/Features/customquery-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/states/InsuranceState.kt @@ -8,9 +8,6 @@ import net.corda.core.schemas.PersistentState import net.corda.core.schemas.QueryableState import net.corda.samples.carinsurance.contracts.InsuranceContract import net.corda.samples.carinsurance.schema.InsuranceSchemaV1 -import java.util.* -import kotlin.collections.ArrayList - // ********* // * State * @@ -38,7 +35,7 @@ data class InsuranceState(val policyNumber: String, } } - var vDetail = InsuranceSchemaV1.PersistentVehicle(vehicleDetail.registrationNumber, + val vDetail = InsuranceSchemaV1.PersistentVehicle(vehicleDetail.registrationNumber, vehicleDetail.chasisNumber, vehicleDetail.make, vehicleDetail.model, @@ -60,4 +57,3 @@ data class InsuranceState(val policyNumber: String, override fun supportedSchemas(): Iterable = listOf(InsuranceSchemaV1) } - diff --git a/Features/customquery-carinsurance/workflows/src/main/resources/migration/claim-detail.changelog-v1.xml b/Features/customquery-carinsurance/contracts/src/main/resources/migration/claim-detail.changelog-v1.xml similarity index 100% rename from Features/customquery-carinsurance/workflows/src/main/resources/migration/claim-detail.changelog-v1.xml rename to Features/customquery-carinsurance/contracts/src/main/resources/migration/claim-detail.changelog-v1.xml diff --git a/Features/customquery-carinsurance/workflows/src/main/resources/migration/insurance-detail.changelog-v1.xml b/Features/customquery-carinsurance/contracts/src/main/resources/migration/insurance-detail.changelog-v1.xml similarity index 100% rename from Features/customquery-carinsurance/workflows/src/main/resources/migration/insurance-detail.changelog-v1.xml rename to Features/customquery-carinsurance/contracts/src/main/resources/migration/insurance-detail.changelog-v1.xml diff --git a/Features/customquery-carinsurance/workflows/src/main/resources/migration/insurance.changelog-master.xml b/Features/customquery-carinsurance/contracts/src/main/resources/migration/insurance.changelog-master.xml similarity index 100% rename from Features/customquery-carinsurance/workflows/src/main/resources/migration/insurance.changelog-master.xml rename to Features/customquery-carinsurance/contracts/src/main/resources/migration/insurance.changelog-master.xml diff --git a/Features/customquery-carinsurance/workflows/src/main/resources/migration/vehicle-detail.changelog-v1.xml b/Features/customquery-carinsurance/contracts/src/main/resources/migration/vehicle-detail.changelog-v1.xml similarity index 100% rename from Features/customquery-carinsurance/workflows/src/main/resources/migration/vehicle-detail.changelog-v1.xml rename to Features/customquery-carinsurance/contracts/src/main/resources/migration/vehicle-detail.changelog-v1.xml diff --git a/Features/customquery-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/contracts/InsuranceContractTests.kt b/Features/customquery-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/contracts/InsuranceContractTests.kt index 13b9e94e..0210ecdc 100644 --- a/Features/customquery-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/contracts/InsuranceContractTests.kt +++ b/Features/customquery-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/contracts/InsuranceContractTests.kt @@ -10,8 +10,8 @@ import net.corda.samples.carinsurance.states.VehicleDetail import net.corda.testing.core.TestIdentity import net.corda.testing.node.MockServices import net.corda.testing.node.ledger +import org.junit.Assert.assertTrue import org.junit.Test -import java.util.* class InsuranceContractTests { // A pre-defined dummy command. @@ -20,18 +20,18 @@ class InsuranceContractTests { } private val ledgerServices = MockServices( - Arrays.asList("net.corda.samples.carinsurance.contracts") + listOf("net.corda.samples.carinsurance.contracts") ) private val a = TestIdentity(CordaX500Name("Alice", "", "GB")) private val b = TestIdentity(CordaX500Name("Bob", "", "GB")) - var registrationNumber = "registration number: 2ds9Fvk" - var chassisNum = "chassis# aedl3sc" - var make = "Toyota" - var model = "Corolla" - var variant = "SE" - var color = "hot rod beige" - var fuelType = "regular" - var vd = VehicleDetail( + private val registrationNumber = "registration number: 2ds9Fvk" + private val chassisNum = "chassis# aedl3sc" + private val make = "Toyota" + private val model = "Corolla" + private val variant = "SE" + private val color = "hot rod beige" + private val fuelType = "regular" + private val vd = VehicleDetail( registrationNumber, chassisNum, make, @@ -39,19 +39,19 @@ class InsuranceContractTests { variant, color, fuelType) - var desc = "claim description: my car was hit by a blockchain" - var claimNumber = "B-132022" - var claimAmount = 3000 - var c = Claim(claimNumber, desc, claimAmount) + private val desc = "claim description: my car was hit by a blockchain" + private val claimNumber = "B-132022" + private val claimAmount = 3000 + private val c = Claim(claimNumber, desc, claimAmount) // in this test scenario, alice is our insurer. - var policyNum = "R3-Policy-A4byCd" - var insuredValue = 100000L - var duration = 50 - var premium = 5 - var insurer = a.party - var insuree = b.party - var st = InsuranceState( + private val policyNum = "R3-Policy-A4byCd" + private val insuredValue = 100000L + private val duration = 50 + private val premium = 5 + private val insurer = a.party + private val insuree = b.party + private val st = InsuranceState( policyNum, insuredValue, duration, @@ -59,11 +59,11 @@ class InsuranceContractTests { insurer, insuree, vd, - Arrays.asList(c)) + listOf(c)) @Test fun contractImplementsContract() { - assert(InsuranceContract() is Contract) + assertTrue(InsuranceContract() is Contract) } @Test @@ -72,15 +72,15 @@ class InsuranceContractTests { transaction { output(InsuranceContract.ID, st) // Has two commands, will fail. - command(Arrays.asList(a.publicKey, b.publicKey), InsuranceContract.Commands.IssueInsurance()) - command(Arrays.asList(a.publicKey, b.publicKey), InsuranceContract.Commands.IssueInsurance()) + command(listOf(a.publicKey, b.publicKey), InsuranceContract.Commands.IssueInsurance()) + command(listOf(a.publicKey, b.publicKey), InsuranceContract.Commands.IssueInsurance()) fails() } transaction { output(InsuranceContract.ID, st) // Has one command, will verify. - command(Arrays.asList(a.publicKey, b.publicKey), InsuranceContract.Commands.IssueInsurance()) + command(listOf(a.publicKey, b.publicKey), InsuranceContract.Commands.IssueInsurance()) verifies() } } @@ -92,14 +92,14 @@ class InsuranceContractTests { transaction { // Has wrong command type, will fail. output(InsuranceContract.ID, st) - command(Arrays.asList(a.publicKey), Commands.DummyCommand()) + command(listOf(a.publicKey), Commands.DummyCommand()) fails() } transaction { // Has correct command type, will verify. output(InsuranceContract.ID, st) - command(Arrays.asList(a.publicKey, b.publicKey), InsuranceContract.Commands.IssueInsurance()) + command(listOf(a.publicKey, b.publicKey), InsuranceContract.Commands.IssueInsurance()) verifies() } } diff --git a/Features/customquery-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/ClaimTests.kt b/Features/customquery-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/ClaimTests.kt index a6d1333f..d36396ea 100644 --- a/Features/customquery-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/ClaimTests.kt +++ b/Features/customquery-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/ClaimTests.kt @@ -1,6 +1,6 @@ package net.corda.samples.carinsurance.states -import org.junit.Assert +import org.junit.Assert.assertEquals import org.junit.Test class ClaimTests { @@ -11,8 +11,8 @@ class ClaimTests { @Test fun constructorTest() { val (claimNumber1, claimDescription, claimAmount1) = Claim(claimNumber, desc, claimAmount) - Assert.assertEquals(claimNumber, claimNumber1) - Assert.assertEquals(desc, claimDescription) - Assert.assertEquals(claimAmount.toLong(), claimAmount1.toLong()) + assertEquals(claimNumber, claimNumber1) + assertEquals(desc, claimDescription) + assertEquals(claimAmount.toLong(), claimAmount1.toLong()) } } diff --git a/Features/customquery-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/InsuranceStateTests.kt b/Features/customquery-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/InsuranceStateTests.kt index 329db9f6..0ec3497c 100644 --- a/Features/customquery-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/InsuranceStateTests.kt +++ b/Features/customquery-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/InsuranceStateTests.kt @@ -2,14 +2,14 @@ package net.corda.samples.carinsurance.states import net.corda.core.identity.CordaX500Name import net.corda.testing.core.TestIdentity -import org.jgroups.util.Util +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Test -import java.util.* class InsuranceStateTests { - var a = TestIdentity(CordaX500Name("Alice", "", "GB")) - var b = TestIdentity(CordaX500Name("Bob", "", "GB")) + private val a = TestIdentity(CordaX500Name("Alice", "", "GB")) + private val b = TestIdentity(CordaX500Name("Bob", "", "GB")) @Test fun constructorTest() { @@ -48,16 +48,16 @@ class InsuranceStateTests { insurer, insuree, vd, - Arrays.asList(c)) + listOf(c)) - Util.assertEquals(policyNum, policyNumber) - Util.assertEquals(insuredValue, insuredValue1) - Util.assertEquals(duration, duration1) - Util.assertEquals(premium, premium1) - Util.assertEquals(insurer, insurer1) - Util.assertEquals(insuree, insuree1) - Util.assertEquals(vd, vehicleDetail) - Util.assertTrue(participants.contains(a.party)) - Util.assertTrue(participants.contains(b.party)) + assertEquals(policyNum, policyNumber) + assertEquals(insuredValue, insuredValue1) + assertEquals(duration, duration1) + assertEquals(premium, premium1) + assertEquals(insurer, insurer1) + assertEquals(insuree, insuree1) + assertEquals(vd, vehicleDetail) + assertTrue(participants.contains(a.party)) + assertTrue(participants.contains(b.party)) } } diff --git a/Features/customquery-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/VehicleDetailTests.kt b/Features/customquery-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/VehicleDetailTests.kt index 33755365..27467e35 100644 --- a/Features/customquery-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/VehicleDetailTests.kt +++ b/Features/customquery-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/VehicleDetailTests.kt @@ -2,13 +2,13 @@ package net.corda.samples.carinsurance.states import net.corda.core.identity.CordaX500Name import net.corda.testing.core.TestIdentity -import org.jgroups.util.Util +import org.junit.Assert.assertEquals import org.junit.Test class VehicleDetailTests { - var a = TestIdentity(CordaX500Name("Alice", "", "GB")) - var b = TestIdentity(CordaX500Name("Bob", "", "GB")) + private val a = TestIdentity(CordaX500Name("Alice", "", "GB")) + private val b = TestIdentity(CordaX500Name("Bob", "", "GB")) @Test fun constructorTest() { @@ -29,12 +29,12 @@ class VehicleDetailTests { color, fuelType) - Util.assertEquals(registrationNumber, registrationNumber1) - Util.assertEquals(chassisNum, chasisNumber) - Util.assertEquals(make, make1) - Util.assertEquals(model, model1) - Util.assertEquals(variant, variant1) - Util.assertEquals(color, color1) - Util.assertEquals(fuelType, fuelType1) + assertEquals(registrationNumber, registrationNumber1) + assertEquals(chassisNum, chasisNumber) + assertEquals(make, make1) + assertEquals(model, model1) + assertEquals(variant, variant1) + assertEquals(color, color1) + assertEquals(fuelType, fuelType1) } } diff --git a/Features/customquery-carinsurance/gradle.properties b/Features/customquery-carinsurance/gradle.properties index 0f727ec3..e77161a4 100644 --- a/Features/customquery-carinsurance/gradle.properties +++ b/Features/customquery-carinsurance/gradle.properties @@ -1,4 +1,27 @@ -name=Queryablestate Car Insurance +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + +name=CustomQuery Car Insurance group=com.carinsurance version=0.1 -kotlin.incremental=false + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE +spring_dependency_management_version=1.0.11.RELEASE diff --git a/Features/customquery-carinsurance/gradle/wrapper/gradle-wrapper.jar b/Features/customquery-carinsurance/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Features/customquery-carinsurance/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Features/customquery-carinsurance/gradle/wrapper/gradle-wrapper.properties b/Features/customquery-carinsurance/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Features/customquery-carinsurance/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Features/customquery-carinsurance/gradlew b/Features/customquery-carinsurance/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Features/customquery-carinsurance/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Features/customquery-carinsurance/gradlew.bat b/Features/customquery-carinsurance/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Features/customquery-carinsurance/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Features/customquery-carinsurance/repositories.gradle b/Features/customquery-carinsurance/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Features/customquery-carinsurance/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Features/customquery-carinsurance/settings.gradle b/Features/customquery-carinsurance/settings.gradle index 2514aca2..e51ba7b5 100644 --- a/Features/customquery-carinsurance/settings.gradle +++ b/Features/customquery-carinsurance/settings.gradle @@ -1,3 +1,39 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.jetbrains.kotlin.plugin.allopen' version kotlin_plugin_version + id 'org.jetbrains.kotlin.plugin.jpa' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + id 'io.spring.dependency-management' version spring_dependency_management_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file +include 'clients' diff --git a/Features/customquery-carinsurance/workflows/build.gradle b/Features/customquery-carinsurance/workflows/build.gradle index 9bd73035..2142d25f 100644 --- a/Features/customquery-carinsurance/workflows/build.gradle +++ b/Features/customquery-carinsurance/workflows/build.gradle @@ -1,12 +1,14 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { - name "Queryablestate Car Insurance" + name "CustomQuery Car Insurance" vendor "Corda Open Source" licence "Apache License, Version 2.0" versionId 1 @@ -14,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -35,25 +32,23 @@ sourceSets { configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - compileOnly "$corda_release_group:corda-testserver-impl:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } - -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath } diff --git a/Features/customquery-carinsurance/workflows/src/main/kotlin/net/corda/samples/carinsurance/flows/InsuranceClaim.kt b/Features/customquery-carinsurance/workflows/src/main/kotlin/net/corda/samples/carinsurance/flows/InsuranceClaim.kt index c8ef9dfe..37b94ea4 100644 --- a/Features/customquery-carinsurance/workflows/src/main/kotlin/net/corda/samples/carinsurance/flows/InsuranceClaim.kt +++ b/Features/customquery-carinsurance/workflows/src/main/kotlin/net/corda/samples/carinsurance/flows/InsuranceClaim.kt @@ -2,12 +2,7 @@ package net.corda.samples.carinsurance.flows import co.paralleluniverse.fibers.Suspendable import net.corda.core.flows.* -import net.corda.core.node.services.Vault import net.corda.core.node.services.Vault.StateStatus -import net.corda.core.node.services.vault.Builder -import net.corda.core.node.services.vault.Builder.equal -import net.corda.core.node.services.vault.CriteriaExpression -import net.corda.core.node.services.vault.QueryCriteria import net.corda.core.node.services.vault.QueryCriteria.VaultCustomQueryCriteria import net.corda.core.node.services.vault.QueryCriteria.VaultQueryCriteria import net.corda.core.node.services.vault.builder @@ -19,7 +14,6 @@ import net.corda.samples.carinsurance.contracts.InsuranceContract import net.corda.samples.carinsurance.schema.InsuranceSchemaV1 import net.corda.samples.carinsurance.states.Claim import net.corda.samples.carinsurance.states.InsuranceState -import java.lang.reflect.Field // ********* // * Flows * @@ -43,7 +37,7 @@ class InsuranceClaim(val claimInfo: ClaimInfo, /** And you can have joint custom criteria as well. Simply add additional criteria and add it to the criteria object by using and(). * val insuredValuecriteria = VaultCustomQueryCriteria(builder { InsuranceSchemaV1.PersistentInsurance::insuredValue.equal(insuredValue, false) }) * **/ - var criteria= VaultQueryCriteria(StateStatus.UNCONSUMED).and(policyNumbercriteria) + val criteria= VaultQueryCriteria(StateStatus.UNCONSUMED).and(policyNumbercriteria) ///.and(insuredValuecriteria) val insuranceStateAndRefs = serviceHub.vaultService.queryBy(InsuranceState::class.java, criteria) /***************************************************************************************/ @@ -56,7 +50,7 @@ class InsuranceClaim(val claimInfo: ClaimInfo, //compose claim val claim = Claim(claimInfo.claimNumber, claimInfo.claimDescription, claimInfo.claimAmount) val input = inputStateAndRef.state.data - var claimlist = ArrayList() + val claimlist = ArrayList() claimlist.add(claim) for (item in input.claims) { claimlist.add(item) diff --git a/Features/customquery-carinsurance/workflows/src/main/kotlin/net/corda/samples/carinsurance/flows/IssueInsurance.kt b/Features/customquery-carinsurance/workflows/src/main/kotlin/net/corda/samples/carinsurance/flows/IssueInsurance.kt index 13c8052c..f8b42cfc 100644 --- a/Features/customquery-carinsurance/workflows/src/main/kotlin/net/corda/samples/carinsurance/flows/IssueInsurance.kt +++ b/Features/customquery-carinsurance/workflows/src/main/kotlin/net/corda/samples/carinsurance/flows/IssueInsurance.kt @@ -12,7 +12,6 @@ import net.corda.samples.carinsurance.contracts.InsuranceContract import net.corda.samples.carinsurance.states.InsuranceState import net.corda.samples.carinsurance.states.VehicleDetail - // ********* // * Flows * // ********* diff --git a/Features/customquery-carinsurance/workflows/src/test/kotlin/net/corda/samples/carinsurance/flows/FlowTests.kt b/Features/customquery-carinsurance/workflows/src/test/kotlin/net/corda/samples/carinsurance/flows/FlowTests.kt index 1a844dd6..e40f38c9 100644 --- a/Features/customquery-carinsurance/workflows/src/test/kotlin/net/corda/samples/carinsurance/flows/FlowTests.kt +++ b/Features/customquery-carinsurance/workflows/src/test/kotlin/net/corda/samples/carinsurance/flows/FlowTests.kt @@ -9,7 +9,8 @@ import net.corda.testing.node.MockNetworkNotarySpec import net.corda.testing.node.MockNetworkParameters import net.corda.testing.node.TestCordapp import org.junit.After -import org.junit.Assert +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotNull import org.junit.Before import org.junit.Test @@ -60,7 +61,7 @@ class FlowTests { val ptx = future.get() //assertion for single output - Assert.assertEquals(1, ptx.tx.outputStates.size.toLong()) + assertEquals(1, ptx.tx.outputStates.size.toLong()) } @Test @@ -93,7 +94,7 @@ class FlowTests { //assertion for single output val inState = ptx2.tx.getOutput(0) as InsuranceState - Assert.assertNotNull(inState) + assertNotNull(inState) } } diff --git a/Features/dockerform-yocordapp/README.md b/Features/dockerform-yocordapp/README.md index 6e265664..015b0790 100644 --- a/Features/dockerform-yocordapp/README.md +++ b/Features/dockerform-yocordapp/README.md @@ -25,7 +25,7 @@ If you have docker installed you can use our gradle tasks to generate a valid do ```bash # generate the docker-compose file -./gradlew prepareDockerNodes +../gradlew prepareDockerNodes # run our corda network docker-compose -f ./build/nodes/docker-compose.yml up diff --git a/Features/dockerform-yocordapp/build.gradle b/Features/dockerform-yocordapp/build.gradle index 7b46f80e..6f03c888 100644 --- a/Features/dockerform-yocordapp/build.gradle +++ b/Features/dockerform-yocordapp/build.gradle @@ -1,155 +1,63 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Dockerform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':contracts') + cordapp project(':workflows') - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -//Task to deploy the nodes in order to bootstrap a network -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { - - /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them - * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand - * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load - * the Corda network bootstrapper. - */ - nodeDefaults { - projectCordapp { - deploy = false - } - cordapp project(':contracts') - cordapp project(':workflows') - runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid - //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change - //it to false for quicker project compiling time. - } - node { - name "O=Notary,L=London,C=GB" - notary = [validating : false] - p2pPort 10002 - rpcSettings { - address("localhost:10003") - adminAddress("localhost:10043") - } - } - node { - name "O=PartyA,L=London,C=GB" - p2pPort 10005 - rpcSettings { - address("localhost:10006") - adminAddress("localhost:10046") - } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] - } - node { - name "O=PartyB,L=New York,C=US" - p2pPort 10008 - rpcSettings { - address("localhost:10009") - adminAddress("localhost:10049") - } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] - } - -} - -task prepareDockerNodes(type: net.corda.plugins.Dockerform, dependsOn: ['jar']) { - +tasks.register('prepareDockerNodes', Dockerform) { dockerImage = "corda/corda-zulu-java1.8-" + corda_release_version + ":latest" nodeDefaults { - projectCordapp { - deploy = false - } - cordapp project("contracts") - cordapp project("workflows") + cordapp project('contracts') + cordapp project('workflows') runSchemaMigration = true rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] } @@ -163,6 +71,7 @@ task prepareDockerNodes(type: net.corda.plugins.Dockerform, dependsOn: ['jar']) address("0.0.0.0:10011") adminAddress("0.0.0.0:10041") } + rpcUsers = [] sshdPort 2221 } @@ -188,4 +97,3 @@ task prepareDockerNodes(type: net.corda.plugins.Dockerform, dependsOn: ['jar']) sshdPort 2223 } } - diff --git a/Features/dockerform-yocordapp/contracts/build.gradle b/Features/dockerform-yocordapp/contracts/build.gradle index 10ceef5b..60a51e77 100644 --- a/Features/dockerform-yocordapp/contracts/build.gradle +++ b/Features/dockerform-yocordapp/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "DockerForm Yo Cordapp" vendor "Corda Open Source" @@ -12,8 +15,10 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" + // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Features/dockerform-yocordapp/contracts/src/main/kotlin/net/corda/samples/dockerform/states/YoState.kt b/Features/dockerform-yocordapp/contracts/src/main/kotlin/net/corda/samples/dockerform/states/YoState.kt index 2c69dedd..23a9789a 100644 --- a/Features/dockerform-yocordapp/contracts/src/main/kotlin/net/corda/samples/dockerform/states/YoState.kt +++ b/Features/dockerform-yocordapp/contracts/src/main/kotlin/net/corda/samples/dockerform/states/YoState.kt @@ -32,9 +32,9 @@ class YoState : ContractState { } override val participants: List - get() = Arrays.asList(target) + get() = listOf(target) override fun toString(): String { - return origin.name.toString() + ": " + yo + return "${origin.name}: $yo" } } diff --git a/Features/dockerform-yocordapp/contracts/src/test/kotlin/net/corda/samples/dockerform/contracts/ContractTests.kt b/Features/dockerform-yocordapp/contracts/src/test/kotlin/net/corda/samples/dockerform/contracts/ContractTests.kt index bdd93752..a1277fda 100644 --- a/Features/dockerform-yocordapp/contracts/src/test/kotlin/net/corda/samples/dockerform/contracts/ContractTests.kt +++ b/Features/dockerform-yocordapp/contracts/src/test/kotlin/net/corda/samples/dockerform/contracts/ContractTests.kt @@ -1,13 +1,9 @@ package net.corda.samples.dockerform.contracts -import net.corda.testing.node.MockServices import org.junit.Test class ContractTests { - private val ledgerServices = MockServices() - @Test fun `dummy test`() { - } } diff --git a/Features/dockerform-yocordapp/contracts/src/test/kotlin/net/corda/samples/dockerform/states/StateTests.kt b/Features/dockerform-yocordapp/contracts/src/test/kotlin/net/corda/samples/dockerform/states/StateTests.kt index 840a4102..b5fe9efe 100644 --- a/Features/dockerform-yocordapp/contracts/src/test/kotlin/net/corda/samples/dockerform/states/StateTests.kt +++ b/Features/dockerform-yocordapp/contracts/src/test/kotlin/net/corda/samples/dockerform/states/StateTests.kt @@ -1,13 +1,9 @@ package net.corda.samples.dockerform.states -import net.corda.testing.node.MockServices import org.junit.Test class StateTests { - private val ledgerServices = MockServices() - @Test fun `dummy test`() { - } } diff --git a/Features/dockerform-yocordapp/gradle.properties b/Features/dockerform-yocordapp/gradle.properties index b63fea67..b2fa33be 100644 --- a/Features/dockerform-yocordapp/gradle.properties +++ b/Features/dockerform-yocordapp/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=DockerForm Yo Cordapp group=net.corda.samples.dockerform version=0.1 -kotlin.incremental=false + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Features/dockerform-yocordapp/gradle/wrapper/gradle-wrapper.jar b/Features/dockerform-yocordapp/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Features/dockerform-yocordapp/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Features/dockerform-yocordapp/gradle/wrapper/gradle-wrapper.properties b/Features/dockerform-yocordapp/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Features/dockerform-yocordapp/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Features/dockerform-yocordapp/gradlew b/Features/dockerform-yocordapp/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Features/dockerform-yocordapp/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Features/dockerform-yocordapp/gradlew.bat b/Features/dockerform-yocordapp/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Features/dockerform-yocordapp/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Features/dockerform-yocordapp/repositories.gradle b/Features/dockerform-yocordapp/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Features/dockerform-yocordapp/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Features/dockerform-yocordapp/settings.gradle b/Features/dockerform-yocordapp/settings.gradle index 2514aca2..c1f46514 100644 --- a/Features/dockerform-yocordapp/settings.gradle +++ b/Features/dockerform-yocordapp/settings.gradle @@ -1,3 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file diff --git a/Features/dockerform-yocordapp/workflows/build.gradle b/Features/dockerform-yocordapp/workflows/build.gradle index 642bbbdf..b56258d8 100644 --- a/Features/dockerform-yocordapp/workflows/build.gradle +++ b/Features/dockerform-yocordapp/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "DockerForm Yo Cordapp" vendor "Corda Open Source" @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,25 +31,23 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath } diff --git a/Features/dockerform-yocordapp/workflows/src/integrationTest/kotlin/com/dockerform/DriverBasedTest.kt b/Features/dockerform-yocordapp/workflows/src/integrationTest/kotlin/com/dockerform/DriverBasedTest.kt index e5979a28..b337d8c0 100644 --- a/Features/dockerform-yocordapp/workflows/src/integrationTest/kotlin/com/dockerform/DriverBasedTest.kt +++ b/Features/dockerform-yocordapp/workflows/src/integrationTest/kotlin/com/dockerform/DriverBasedTest.kt @@ -7,9 +7,9 @@ import net.corda.testing.driver.DriverDSL import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.driver +import org.junit.Assert.assertEquals import org.junit.Test import java.util.concurrent.Future -import kotlin.test.assertEquals class DriverBasedTest { private val bankA = TestIdentity(CordaX500Name("BankA", "", "GB")) diff --git a/Features/dockerform-yocordapp/workflows/src/main/kotlin/net/corda/samples/dockerform/flows/YoFlow.kt b/Features/dockerform-yocordapp/workflows/src/main/kotlin/net/corda/samples/dockerform/flows/YoFlow.kt index 2a933352..6697fe60 100644 --- a/Features/dockerform-yocordapp/workflows/src/main/kotlin/net/corda/samples/dockerform/flows/YoFlow.kt +++ b/Features/dockerform-yocordapp/workflows/src/main/kotlin/net/corda/samples/dockerform/flows/YoFlow.kt @@ -11,8 +11,6 @@ import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.ProgressTracker import net.corda.samples.dockerform.contracts.YoContract import net.corda.samples.dockerform.states.YoState -import java.util.* - // ********* // * Flows * @@ -43,7 +41,7 @@ class YoFlow(private val target: Party) : FlowLogic() { // Obtain a reference from a notary we wish to use. val notary = serviceHub.networkMapCache.getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")) // METHOD 2 - val command = Command(YoContract.Commands.Send(), Arrays.asList(me.owningKey)) + val command = Command(YoContract.Commands.Send(), listOf(me.owningKey)) val state = YoState(me, target) val stateAndContract = StateAndContract(state, YoContract.ID) val utx = TransactionBuilder(notary).withItems(stateAndContract, command) diff --git a/Features/dockerform-yocordapp/workflows/src/test/kotlin/net/corda/samples/dockerform/flows/FlowTests.kt b/Features/dockerform-yocordapp/workflows/src/test/kotlin/net/corda/samples/dockerform/flows/FlowTests.kt index 20ec6666..3f79b81b 100644 --- a/Features/dockerform-yocordapp/workflows/src/test/kotlin/net/corda/samples/dockerform/flows/FlowTests.kt +++ b/Features/dockerform-yocordapp/workflows/src/test/kotlin/net/corda/samples/dockerform/flows/FlowTests.kt @@ -1,31 +1,27 @@ package net.corda.samples.dockerform.flows - import net.corda.core.identity.CordaX500Name import net.corda.testing.node.* import org.junit.After import org.junit.Before import org.junit.Test import java.util.concurrent.ExecutionException - +import org.junit.Assert.assertTrue class FlowTests { - - lateinit var mockNetwork: MockNetwork - lateinit var a: StartedMockNode - lateinit var b: StartedMockNode + private lateinit var mockNetwork: MockNetwork + private lateinit var a: StartedMockNode + private lateinit var b: StartedMockNode @Before fun setup() { - - val mockNetwork = MockNetwork(MockNetworkParameters(cordappsForAllNodes = listOf( + mockNetwork = MockNetwork(MockNetworkParameters(cordappsForAllNodes = listOf( TestCordapp.findCordapp("net.corda.samples.dockerform.contracts"), TestCordapp.findCordapp("net.corda.samples.dockerform.flows") ), notarySpecs = listOf(MockNetworkNotarySpec(CordaX500Name("Notary","London","GB"))) )) - a = mockNetwork.createNode(MockNodeParameters()) b = mockNetwork.createNode(MockNodeParameters()) val startedNodes = arrayListOf(a, b) @@ -36,20 +32,19 @@ class FlowTests { @After fun tearDown() { - - } - - @Test - fun `dummy test`() { + if (::mockNetwork.isInitialized) { + mockNetwork.stopNodes() + } } @Throws(ExecutionException::class, InterruptedException::class) + @Test fun dummyTest() { val future = a.startFlow(YoFlow(b.info.legalIdentities.first())) mockNetwork.runNetwork() val ptx = future.get() if (ptx != null) { - assert(ptx.tx.inputs.isEmpty()) + assertTrue(ptx.tx.inputs.isEmpty()) } } } diff --git a/Features/encumbrance-avatar/README.md b/Features/encumbrance-avatar/README.md index 0b4a3b0a..cdd90b3f 100644 --- a/Features/encumbrance-avatar/README.md +++ b/Features/encumbrance-avatar/README.md @@ -33,7 +33,7 @@ performing the DVP for the NFT against the tokens. Build and run the CorDapp using below command. This will deploy three nodes - buyer, seller and notary. ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ./build/nodes/runnodes ``` diff --git a/Features/encumbrance-avatar/build.gradle b/Features/encumbrance-avatar/build.gradle index 81976b50..bd86d910 100644 --- a/Features/encumbrance-avatar/build.gradle +++ b/Features/encumbrance-avatar/build.gradle @@ -1,109 +1,67 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':workflows') + cordapp project(':contracts') - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -//Task to deploy the nodes in order to bootstrap a network -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { - +tasks.register('deployNodes', Cordform) { /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load * the Corda network bootstrapper. */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp project(':contracts') cordapp project(':workflows') + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change //it to false for quicker project compiling time. @@ -116,6 +74,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { name "O=PartyA,L=London,C=GB" @@ -124,7 +83,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=PartyB,L=New York,C=US" @@ -133,7 +91,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } - } diff --git a/Features/encumbrance-avatar/contracts/build.gradle b/Features/encumbrance-avatar/contracts/build.gradle index f41925b2..4e02d337 100644 --- a/Features/encumbrance-avatar/contracts/build.gradle +++ b/Features/encumbrance-avatar/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "Avatar Contracts" vendor "Corda Open Source" @@ -12,8 +15,10 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" + // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Features/encumbrance-avatar/contracts/src/main/kotlin/net/corda/samples/avatar/contracts/AvatarContract.kt b/Features/encumbrance-avatar/contracts/src/main/kotlin/net/corda/samples/avatar/contracts/AvatarContract.kt index 72cda78c..d7e215f6 100644 --- a/Features/encumbrance-avatar/contracts/src/main/kotlin/net/corda/samples/avatar/contracts/AvatarContract.kt +++ b/Features/encumbrance-avatar/contracts/src/main/kotlin/net/corda/samples/avatar/contracts/AvatarContract.kt @@ -18,7 +18,7 @@ class AvatarContract: Contract { override fun verify(tx: LedgerTransaction) { // Verification logic goes here. - val commandWithParties = tx.commands.requireSingleCommand(Commands::class.java) + val commandWithParties = tx.commands.requireSingleCommand() val signers = commandWithParties.signers when (commandWithParties.value) { @@ -26,38 +26,38 @@ class AvatarContract: Contract { "No inputs should be consumed when sending the Hello-World message.".using(tx.inputs.isEmpty()) "There should be 0 input states.".using(tx.inputs.isEmpty()) "There should be 2 output states.".using(tx.outputStates.size == 2) - "There should be 1 expiry state.".using(tx.outputsOfType(Expiry::class.java).size == 1) - "There shoule be 1 Avatar created.".using(tx.outputsOfType(Avatar::class.java).size == 1) + "There should be 1 expiry state.".using(tx.outputsOfType().size == 1) + "There shoule be 1 Avatar created.".using(tx.outputsOfType().size == 1) - val avatar = tx.outputsOfType(Avatar::class.java)[0] + val avatar = tx.outputsOfType()[0] "Avatar Owner must always sign the newly created Avatar.".using(signers.contains(avatar.owner.owningKey)) val avatarEncumbrance = tx.outputs.first { it.data is Avatar }.encumbrance "Avatar needs to be encumbered".using(avatarEncumbrance != null) } - is Commands.Transfer -> requireThat{ + is Commands.Transfer -> requireThat { "There should be 2 inputs.".using(tx.inputs.size == 2) - "There must be 1 expiry as an input.".using(tx.inputsOfType(Expiry::class.java).size == 1) - "There must be 1 avatar as an input".using(tx.inputsOfType(Avatar::class.java).size == 1) + "There must be 1 expiry as an input.".using(tx.inputsOfType().size == 1) + "There must be 1 avatar as an input".using(tx.inputsOfType().size == 1) "There should be two output states".using(tx.inputs.size == 2) - "There should be 1 expiry state.".using(tx.outputsOfType(Expiry::class.java).size == 1) - "There shoule be 1 Avatar created.".using(tx.outputsOfType(Avatar::class.java).size == 1) + "There should be 1 expiry state.".using(tx.outputsOfType().size == 1) + "There shoule be 1 Avatar created.".using(tx.outputsOfType().size == 1) - val newAvatar = tx.outputsOfType(Avatar::class.java).stream().findFirst().orElseThrow { + val newAvatar = tx.outputsOfType().stream().findFirst().orElseThrow { IllegalArgumentException( "No Avatar created for transferring." ) } - val oldAvatar = tx.inputsOfType(Avatar::class.java).stream().findFirst().orElseThrow { + val oldAvatar = tx.inputsOfType().stream().findFirst().orElseThrow { IllegalArgumentException( "Existing Avatar to transfer not found." ) } - "New and old Avatar must just have the owners changed.".using(newAvatar.equals(oldAvatar)) + "New and old Avatar must just have the owners changed.".using(newAvatar== oldAvatar) "New Owner should sign the new Avatar".using(signers.contains(newAvatar.owner.owningKey)) "Old owner must sign the old Avatar".using(signers.contains(oldAvatar.owner.owningKey)) } diff --git a/Features/encumbrance-avatar/contracts/src/main/kotlin/net/corda/samples/avatar/contracts/ExpiryContract.kt b/Features/encumbrance-avatar/contracts/src/main/kotlin/net/corda/samples/avatar/contracts/ExpiryContract.kt index 84f56bb2..a410c34d 100644 --- a/Features/encumbrance-avatar/contracts/src/main/kotlin/net/corda/samples/avatar/contracts/ExpiryContract.kt +++ b/Features/encumbrance-avatar/contracts/src/main/kotlin/net/corda/samples/avatar/contracts/ExpiryContract.kt @@ -18,12 +18,12 @@ class ExpiryContract : Contract { @Throws(IllegalArgumentException::class) override fun verify(tx: LedgerTransaction) { - val commandWithParties = tx.commands.requireSingleCommand(AvatarContract.Commands::class.java) + val commandWithParties = tx.commands.requireSingleCommand() - var expiry: Expiry = tx.outputsOfType(Expiry::class.java)[0] + var expiry: Expiry = tx.outputsOfType()[0] when (commandWithParties.value) { is AvatarContract.Commands.Transfer -> requireThat{ - expiry = tx.inputsOfType(Expiry::class.java)[0] + expiry = tx.inputsOfType()[0] } } diff --git a/Features/encumbrance-avatar/contracts/src/main/kotlin/net/corda/samples/avatar/states/Avatar.kt b/Features/encumbrance-avatar/contracts/src/main/kotlin/net/corda/samples/avatar/states/Avatar.kt index dd980627..07cc1f67 100644 --- a/Features/encumbrance-avatar/contracts/src/main/kotlin/net/corda/samples/avatar/states/Avatar.kt +++ b/Features/encumbrance-avatar/contracts/src/main/kotlin/net/corda/samples/avatar/states/Avatar.kt @@ -4,8 +4,6 @@ import net.corda.samples.avatar.contracts.AvatarContract import net.corda.core.contracts.BelongsToContract import net.corda.core.contracts.ContractState import net.corda.core.identity.AbstractParty -import java.util.* - //Avatar can be thought of as any metaverse avatar which needs to be created and sold on at an exchange. This entity //has an id and owner associated with it. We will see how this avatar can only be sold within a certain time limit. @@ -14,15 +12,12 @@ class Avatar(val owner: AbstractParty, val avatarId: String, override val participants: List = listOf(owner)) : ContractState { - override fun equals(other: Any?): Boolean { if (this === other) return true - if (other == null || javaClass != other.javaClass) return false - val avatar = other as Avatar - return avatarId == avatar.avatarId + return (other is Avatar) && avatarId == other.avatarId } override fun hashCode(): Int { - return Objects.hash(avatarId) + return avatarId.hashCode() } } diff --git a/Features/encumbrance-avatar/contracts/src/main/kotlin/net/corda/samples/avatar/states/Expiry.kt b/Features/encumbrance-avatar/contracts/src/main/kotlin/net/corda/samples/avatar/states/Expiry.kt index b8fa8cec..dbe05218 100644 --- a/Features/encumbrance-avatar/contracts/src/main/kotlin/net/corda/samples/avatar/states/Expiry.kt +++ b/Features/encumbrance-avatar/contracts/src/main/kotlin/net/corda/samples/avatar/states/Expiry.kt @@ -5,7 +5,7 @@ import net.corda.core.contracts.BelongsToContract import net.corda.core.contracts.ContractState import net.corda.core.identity.AbstractParty import java.time.Instant -import java.util.* +import java.util.Objects @BelongsToContract(ExpiryContract::class) class Expiry(val expiry: Instant, @@ -13,13 +13,9 @@ class Expiry(val expiry: Instant, val owner: AbstractParty, override val participants: List = listOf(owner)) : ContractState { - - override fun equals(other: Any?): Boolean { if (this === other) return true - if (other == null || javaClass != other.javaClass) return false - val expiry1 = other as Expiry - return expiry == expiry1.expiry && avatarId == expiry1.avatarId + return (other is Expiry) && expiry == other.expiry && avatarId == other.avatarId } override fun hashCode(): Int { diff --git a/Features/encumbrance-avatar/contracts/src/test/kotlin/net/corda/samples/avatar/contracts/ContractTests.kt b/Features/encumbrance-avatar/contracts/src/test/kotlin/net/corda/samples/avatar/contracts/ContractTests.kt index e5e8c112..80d729ca 100644 --- a/Features/encumbrance-avatar/contracts/src/test/kotlin/net/corda/samples/avatar/contracts/ContractTests.kt +++ b/Features/encumbrance-avatar/contracts/src/test/kotlin/net/corda/samples/avatar/contracts/ContractTests.kt @@ -14,8 +14,8 @@ import java.time.temporal.ChronoUnit class ContractTests { private val ledgerServices: MockServices = MockServices(listOf("net.corda.samples.avatar")) - var seller = TestIdentity(CordaX500Name("Alice", "TestLand", "US")) - var buyer = TestIdentity(CordaX500Name("Alice", "TestLand", "US")) + private val seller = TestIdentity(CordaX500Name("Alice", "TestLand", "US")) + private val buyer = TestIdentity(CordaX500Name("Alice", "TestLand", "US")) @Test fun thereMustBeTwoOutputs() { diff --git a/Features/encumbrance-avatar/gradle.properties b/Features/encumbrance-avatar/gradle.properties index 7b120146..99d5c4d3 100644 --- a/Features/encumbrance-avatar/gradle.properties +++ b/Features/encumbrance-avatar/gradle.properties @@ -1,4 +1,26 @@ -name=Test +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + +name=Encumbrance Avatar group=net.corda.samples.avatar version=0.1 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Features/encumbrance-avatar/gradle/wrapper/gradle-wrapper.jar b/Features/encumbrance-avatar/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Features/encumbrance-avatar/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Features/encumbrance-avatar/gradle/wrapper/gradle-wrapper.properties b/Features/encumbrance-avatar/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Features/encumbrance-avatar/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Features/encumbrance-avatar/gradlew b/Features/encumbrance-avatar/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Features/encumbrance-avatar/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Features/encumbrance-avatar/gradlew.bat b/Features/encumbrance-avatar/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Features/encumbrance-avatar/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Features/encumbrance-avatar/repositories.gradle b/Features/encumbrance-avatar/repositories.gradle deleted file mode 100644 index 7dc03179..00000000 --- a/Features/encumbrance-avatar/repositories.gradle +++ /dev/null @@ -1,7 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Features/encumbrance-avatar/settings.gradle b/Features/encumbrance-avatar/settings.gradle index 2514aca2..c1f46514 100644 --- a/Features/encumbrance-avatar/settings.gradle +++ b/Features/encumbrance-avatar/settings.gradle @@ -1,3 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file diff --git a/Features/encumbrance-avatar/workflows/build.gradle b/Features/encumbrance-avatar/workflows/build.gradle index 80b63940..90bebb0d 100644 --- a/Features/encumbrance-avatar/workflows/build.gradle +++ b/Features/encumbrance-avatar/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "Avatar Flows" vendor "Corda Open Source" @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,25 +31,23 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Features/encumbrance-avatar/workflows/src/integrationTest/kotlin/net/corda/samples/avatar/DriverBasedTest.kt b/Features/encumbrance-avatar/workflows/src/integrationTest/kotlin/net/corda/samples/avatar/DriverBasedTest.kt index 022887ca..ba6c37d0 100644 --- a/Features/encumbrance-avatar/workflows/src/integrationTest/kotlin/net/corda/samples/avatar/DriverBasedTest.kt +++ b/Features/encumbrance-avatar/workflows/src/integrationTest/kotlin/net/corda/samples/avatar/DriverBasedTest.kt @@ -7,9 +7,9 @@ import net.corda.testing.driver.DriverDSL import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.driver +import org.junit.Assert.assertEquals import org.junit.Test import java.util.concurrent.Future -import kotlin.test.assertEquals class DriverBasedTest { private val bankA = TestIdentity(CordaX500Name("BankA", "", "GB")) diff --git a/Features/encumbrance-avatar/workflows/src/main/kotlin/net/corda/samples/avatar/flows/CreateAvatarFlow.kt b/Features/encumbrance-avatar/workflows/src/main/kotlin/net/corda/samples/avatar/flows/CreateAvatarFlow.kt index 3ce2d08a..3ea4b4bd 100644 --- a/Features/encumbrance-avatar/workflows/src/main/kotlin/net/corda/samples/avatar/flows/CreateAvatarFlow.kt +++ b/Features/encumbrance-avatar/workflows/src/main/kotlin/net/corda/samples/avatar/flows/CreateAvatarFlow.kt @@ -11,7 +11,6 @@ import net.corda.samples.avatar.states.Expiry import java.time.Duration import java.time.Instant import java.time.temporal.ChronoUnit -import java.util.* @InitiatingFlow @StartableByRPC @@ -46,6 +45,6 @@ class CreateAvatar(private val avatarId: String, expiryAfterMinutes: Long) : Flo .setTimeWindow(Instant.now(), Duration.ofSeconds(10)) txBuilder.verify(serviceHub) val signedTransaction = serviceHub.signInitialTransaction(txBuilder) - return subFlow(FinalityFlow(signedTransaction, Arrays.asList())) + return subFlow(FinalityFlow(signedTransaction, emptyList())) } } \ No newline at end of file diff --git a/Features/encumbrance-avatar/workflows/src/main/kotlin/net/corda/samples/avatar/flows/TransferAvatarFlow.kt b/Features/encumbrance-avatar/workflows/src/main/kotlin/net/corda/samples/avatar/flows/TransferAvatarFlow.kt index 1a9710e3..b384cf65 100644 --- a/Features/encumbrance-avatar/workflows/src/main/kotlin/net/corda/samples/avatar/flows/TransferAvatarFlow.kt +++ b/Features/encumbrance-avatar/workflows/src/main/kotlin/net/corda/samples/avatar/flows/TransferAvatarFlow.kt @@ -14,10 +14,6 @@ import net.corda.samples.avatar.states.Avatar import net.corda.samples.avatar.states.Expiry import java.time.Duration import java.time.Instant -import java.util.* -import java.util.function.Predicate -import java.util.function.Supplier - @InitiatingFlow @StartableByRPC @@ -32,17 +28,17 @@ class TransferAvatar(private val avatarId: String, private val buyer: String) : //get avatar from db val avatarPage: Vault.Page = serviceHub.vaultService.queryBy(Avatar::class.java) val avatarStateAndRef: StateAndRef = - avatarPage.states.stream().filter(Predicate> { (state): StateAndRef -> + avatarPage.states.stream().filter { (state): StateAndRef -> state.data.avatarId.equals(this.avatarId, true) - }).findAny() - .orElseThrow(Supplier { CordaRuntimeException("No avatar found with avatar id as : $avatarId") }) + }.findAny() + .orElseThrow { CordaRuntimeException("No avatar found with avatar id as : $avatarId") } //get expiry from db val expiryPage: Vault.Page = serviceHub.vaultService.queryBy(Expiry::class.java) val expiryStateAndRef: StateAndRef = - expiryPage.states.stream().filter(Predicate> { (state): StateAndRef -> + expiryPage.states.stream().filter { (state): StateAndRef -> state.data.avatarId.equals(avatarId, true) - }).findAny().orElseThrow(Supplier { CordaRuntimeException("No expiry found with avatar id as $avatarId") }) + }.findAny().orElseThrow { CordaRuntimeException("No expiry found with avatar id as $avatarId") } //change owner val avatar = Avatar(buyerParty, avatarId) @@ -55,13 +51,13 @@ class TransferAvatar(private val avatarId: String, private val buyer: String) : .addOutputState(avatar, AvatarContract.AVATAR_CONTRACT_ID, notary, 1) .addOutputState(expiry, ExpiryContract.EXPIRY_CONTRACT_ID, notary, 0) .addCommand( - AvatarContract.Commands.Transfer(), Arrays.asList( + AvatarContract.Commands.Transfer(), listOf( buyerParty.owningKey, avatarStateAndRef.state.data.owner.owningKey ) ) .addCommand( - ExpiryContract.Commands.Pass(), Arrays.asList( + ExpiryContract.Commands.Pass(), listOf( buyerParty.owningKey, expiryStateAndRef.state.data.owner.owningKey ) diff --git a/Features/encumbrance-avatar/workflows/src/test/kotlin/net/corda/samples/avatar/FlowTests.kt b/Features/encumbrance-avatar/workflows/src/test/kotlin/net/corda/samples/avatar/FlowTests.kt index e8eefaf8..bc309e37 100644 --- a/Features/encumbrance-avatar/workflows/src/test/kotlin/net/corda/samples/avatar/FlowTests.kt +++ b/Features/encumbrance-avatar/workflows/src/test/kotlin/net/corda/samples/avatar/FlowTests.kt @@ -1,18 +1,15 @@ package net.corda.samples.avatar -import net.corda.core.concurrent.CordaFuture import net.corda.testing.node.* import org.junit.After import org.junit.Before import org.junit.Test import net.corda.core.node.services.vault.QueryCriteria -import net.corda.core.transactions.SignedTransaction import net.corda.core.node.services.Vault.StateStatus import net.corda.samples.avatar.flows.CreateAvatar import net.corda.samples.avatar.flows.TransferAvatar import net.corda.samples.avatar.states.Avatar - class FlowTests { private lateinit var network: MockNetwork private lateinit var a: StartedMockNode @@ -31,31 +28,34 @@ class FlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } + @Test fun `Create Avatar Test`() { val flow = CreateAvatar( "PETER-7526", 3) - val future: CordaFuture = a.startFlow(flow) + a.startFlow(flow) network.runNetwork() //successful query means the state is stored at node b's vault. Flow went through. val inputCriteria: QueryCriteria = QueryCriteria.VaultQueryCriteria().withStatus(StateStatus.UNCONSUMED) - val state = a.services.vaultService.queryBy(Avatar::class.java, inputCriteria).states[0].state.data + a.services.vaultService.queryBy(Avatar::class.java, inputCriteria).states[0].state.data } @Test fun `Transfer Avatar Test`() { val createflow = CreateAvatar( "PETER-7526", 3) - val future: CordaFuture = a.startFlow(createflow) + a.startFlow(createflow) network.runNetwork() val transferflow = TransferAvatar( "PETER-7526", b.info.legalIdentities[0].name.organisation) - val future2: CordaFuture = a.startFlow(transferflow) + a.startFlow(transferflow) network.runNetwork() //successful query means the state is stored at node b's vault. Flow went through. val inputCriteria: QueryCriteria = QueryCriteria.VaultQueryCriteria().withStatus(StateStatus.UNCONSUMED) - val state = b.services.vaultService.queryBy(Avatar::class.java, inputCriteria).states[0].state.data + b.services.vaultService.queryBy(Avatar::class.java, inputCriteria).states[0].state.data } } \ No newline at end of file diff --git a/Features/gradle/wrapper/gradle-wrapper.jar b/Features/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..41d9927a Binary files /dev/null and b/Features/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Features/gradle/wrapper/gradle-wrapper.properties b/Features/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..aa991fce --- /dev/null +++ b/Features/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Features/gradlew b/Features/gradlew new file mode 100755 index 00000000..1b6c7873 --- /dev/null +++ b/Features/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/Features/gradlew.bat b/Features/gradlew.bat new file mode 100644 index 00000000..107acd32 --- /dev/null +++ b/Features/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/Features/notarychange-iou/README.md b/Features/notarychange-iou/README.md index d2bf3ae7..67a65240 100644 --- a/Features/notarychange-iou/README.md +++ b/Features/notarychange-iou/README.md @@ -33,7 +33,7 @@ For development environment setup, please refer to: [Setup Guide](https://docs.c Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) ``` diff --git a/Features/notarychange-iou/build.gradle b/Features/notarychange-iou/build.gradle index bc07342d..8bd886fb 100644 --- a/Features/notarychange-iou/build.gradle +++ b/Features/notarychange-iou/build.gradle @@ -1,103 +1,70 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':workflows') + cordapp project(':contracts') - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } - - -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = true - } cordapp project(':contracts') cordapp project(':workflows') - runSchemaMigration = true + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { name "O=NotaryA,L=London,C=GB" @@ -107,6 +74,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { name "O=NotaryB,L=London,C=GB" @@ -116,7 +84,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=PartyA,L=New York,C=US" @@ -125,7 +92,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=PartyB,L=San Diego,C=US" @@ -134,6 +100,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10012") adminAddress("localhost:10052") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } } diff --git a/Features/notarychange-iou/contracts/build.gradle b/Features/notarychange-iou/contracts/build.gradle index 9c163582..1faea114 100644 --- a/Features/notarychange-iou/contracts/build.gradle +++ b/Features/notarychange-iou/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "Notary-Change Contracts" vendor "Corda Open Source" @@ -12,8 +15,10 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" + // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Features/notarychange-iou/contracts/src/main/kotlin/net/corda/samples/notarychange/contracts/IOUContract.kt b/Features/notarychange-iou/contracts/src/main/kotlin/net/corda/samples/notarychange/contracts/IOUContract.kt index e6d3fdd4..a4ecf8eb 100644 --- a/Features/notarychange-iou/contracts/src/main/kotlin/net/corda/samples/notarychange/contracts/IOUContract.kt +++ b/Features/notarychange-iou/contracts/src/main/kotlin/net/corda/samples/notarychange/contracts/IOUContract.kt @@ -1,11 +1,9 @@ package net.corda.samples.notarychange.contracts - import net.corda.core.contracts.* import net.corda.core.transactions.LedgerTransaction import net.corda.samples.notarychange.states.IOUState - class IOUContract : Contract { /** * The verify() function of all the states' contracts must not throw an exception for a transaction to be @@ -16,7 +14,7 @@ class IOUContract : Contract { val cmd = tx.commands.requireSingleCommand() when (cmd.value) { is Commands.Create -> requireThat { - val out: IOUState = tx.outputsOfType(IOUState::class.java)[0] + val out: IOUState = tx.outputsOfType()[0] // IOU-specific constraints. "The IOU's value must be non-negative.".using(out.value > 0) } diff --git a/Features/notarychange-iou/contracts/src/main/kotlin/net/corda/samples/notarychange/states/IOUState.kt b/Features/notarychange-iou/contracts/src/main/kotlin/net/corda/samples/notarychange/states/IOUState.kt index 11ee63cd..196d2539 100644 --- a/Features/notarychange-iou/contracts/src/main/kotlin/net/corda/samples/notarychange/states/IOUState.kt +++ b/Features/notarychange-iou/contracts/src/main/kotlin/net/corda/samples/notarychange/states/IOUState.kt @@ -6,28 +6,25 @@ import net.corda.core.contracts.UniqueIdentifier import net.corda.core.identity.AbstractParty import net.corda.core.identity.Party import net.corda.samples.notarychange.contracts.IOUContract -import java.util.* - /** * The state object recording IOU agreements between two parties. + * @param value the value of the IOU. + * @param lender the party issuing the IOU. + * @param borrower the party receiving and approving the IOU. * * A state must implement [ContractState] or one of its descendants. */ @BelongsToContract(IOUContract::class) -class IOUState -/** - * @param value the value of the IOU. - * @param lender the party issuing the IOU. - * @param borrower the party receiving and approving the IOU. - */(val value: Int, +class IOUState( + val value: Int, val lender: Party, val borrower: Party, override val linearId: UniqueIdentifier) : LinearState { override val participants: List - get() = Arrays.asList(lender, borrower) + get() = listOf(lender, borrower) override fun toString(): String { - return String.format("IOUState(value=%s, lender=%s, borrower=%s, linearId=%s)", value, lender, borrower, linearId) + return "IOUState(value=$value, lender=$lender, borrower=$borrower, linearId=$linearId)" } -} \ No newline at end of file +} diff --git a/Features/notarychange-iou/contracts/src/test/kotlin/net/corda/samples/notarychange/contracts/ContractTests.kt b/Features/notarychange-iou/contracts/src/test/kotlin/net/corda/samples/notarychange/contracts/ContractTests.kt index 6ee8540d..97f1f684 100644 --- a/Features/notarychange-iou/contracts/src/test/kotlin/net/corda/samples/notarychange/contracts/ContractTests.kt +++ b/Features/notarychange-iou/contracts/src/test/kotlin/net/corda/samples/notarychange/contracts/ContractTests.kt @@ -8,7 +8,6 @@ import net.corda.testing.node.MockServices import net.corda.testing.node.ledger import org.junit.Test - class ContractTests { private val ledgerServices = MockServices() private val megaCorp = TestIdentity(CordaX500Name("MegaCorp", "London", "GB")) diff --git a/Features/notarychange-iou/contracts/src/test/kotlin/net/corda/samples/notarychange/contracts/StateTests.kt b/Features/notarychange-iou/contracts/src/test/kotlin/net/corda/samples/notarychange/contracts/StateTests.kt index 2819f372..ca325f1d 100644 --- a/Features/notarychange-iou/contracts/src/test/kotlin/net/corda/samples/notarychange/contracts/StateTests.kt +++ b/Features/notarychange-iou/contracts/src/test/kotlin/net/corda/samples/notarychange/contracts/StateTests.kt @@ -1,16 +1,15 @@ package net.corda.samples.notarychange.contracts import net.corda.samples.notarychange.states.IOUState -import net.corda.testing.node.MockServices +import org.junit.Assert.assertSame import org.junit.Test class StateTests { - private val ledgerServices = MockServices() @Test @Throws(NoSuchFieldException::class) fun hasAmountFieldOfCorrectType() { // Does the message field exist? IOUState::class.java.getDeclaredField("value") - assert(IOUState::class.java.getDeclaredField("value").getType() == Int::class.javaPrimitiveType) + assertSame(IOUState::class.java.getDeclaredField("value").type, Int::class.javaPrimitiveType) } } \ No newline at end of file diff --git a/Features/notarychange-iou/gradle.properties b/Features/notarychange-iou/gradle.properties index e51e23da..40400206 100644 --- a/Features/notarychange-iou/gradle.properties +++ b/Features/notarychange-iou/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Notary-Change Cordapp group=com.notarychange version=0.1 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Features/notarychange-iou/gradle/wrapper/gradle-wrapper.jar b/Features/notarychange-iou/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Features/notarychange-iou/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Features/notarychange-iou/gradle/wrapper/gradle-wrapper.properties b/Features/notarychange-iou/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Features/notarychange-iou/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Features/notarychange-iou/gradlew b/Features/notarychange-iou/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Features/notarychange-iou/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Features/notarychange-iou/gradlew.bat b/Features/notarychange-iou/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Features/notarychange-iou/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Features/notarychange-iou/repositories.gradle b/Features/notarychange-iou/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Features/notarychange-iou/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Features/notarychange-iou/settings.gradle b/Features/notarychange-iou/settings.gradle index 2514aca2..c1f46514 100644 --- a/Features/notarychange-iou/settings.gradle +++ b/Features/notarychange-iou/settings.gradle @@ -1,3 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file diff --git a/Features/notarychange-iou/workflows/build.gradle b/Features/notarychange-iou/workflows/build.gradle index 756ca6d0..60e5299a 100644 --- a/Features/notarychange-iou/workflows/build.gradle +++ b/Features/notarychange-iou/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "Notary-Change Flows" vendor "Corda Open Source" @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,25 +31,24 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Features/notarychange-iou/workflows/src/main/kotlin/net/corda/samples/notarychange/flows/IssueFlow.kt b/Features/notarychange-iou/workflows/src/main/kotlin/net/corda/samples/notarychange/flows/IssueFlow.kt index 55dfec3f..ef0a2ed7 100644 --- a/Features/notarychange-iou/workflows/src/main/kotlin/net/corda/samples/notarychange/flows/IssueFlow.kt +++ b/Features/notarychange-iou/workflows/src/main/kotlin/net/corda/samples/notarychange/flows/IssueFlow.kt @@ -11,7 +11,6 @@ import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.ProgressTracker import net.corda.samples.notarychange.contracts.IOUContract import net.corda.samples.notarychange.states.IOUState -import java.util.* class IssueFlow { @InitiatingFlow @@ -24,12 +23,12 @@ class IssueFlow { private val VERIFYING_TRANSACTION = ProgressTracker.Step("Verifying contract constraints.") private val SIGNING_TRANSACTION = ProgressTracker.Step("Signing transaction with our private key.") private val GATHERING_SIGS: ProgressTracker.Step = object : ProgressTracker.Step("Gathering the counterparty's signature.") { - override fun childProgressTracker(): ProgressTracker? { + override fun childProgressTracker(): ProgressTracker { return CollectSignaturesFlow.tracker() } } private val FINALISING_TRANSACTION: ProgressTracker.Step = object : ProgressTracker.Step("Obtaining notary signature and recording transaction.") { - override fun childProgressTracker(): ProgressTracker? { + override fun childProgressTracker(): ProgressTracker { return FinalityFlow.tracker() } } @@ -77,7 +76,7 @@ class IssueFlow { val iouState = IOUState(iouValue, me, otherParty, UniqueIdentifier()) val txCommand = Command( IOUContract.Commands.Create(), - Arrays.asList(iouState.lender.owningKey, iouState.borrower.owningKey)) + listOf(iouState.lender.owningKey, iouState.borrower.owningKey)) val txBuilder = TransactionBuilder(notary!!) .addOutputState(iouState) .addCommand(txCommand) @@ -97,12 +96,12 @@ class IssueFlow { // Send the state to the counterparty, and receive it back with their signature. val otherPartySession = initiateFlow(otherParty) val fullySignedTx = subFlow( - CollectSignaturesFlow(partSignedTx, Arrays.asList(otherPartySession), CollectSignaturesFlow.tracker())) + CollectSignaturesFlow(partSignedTx, listOf(otherPartySession), CollectSignaturesFlow.tracker())) // Stage 5. progressTracker.currentStep = FINALISING_TRANSACTION // Notarise and record the transaction in both parties' vaults. - return subFlow(FinalityFlow(fullySignedTx, Arrays.asList(otherPartySession))).toString() + ", IOU created with linearId: " + iouState.linearId.toString() + return subFlow(FinalityFlow(fullySignedTx, listOf(otherPartySession))).toString() + ", IOU created with linearId: " + iouState.linearId.toString() } } diff --git a/Features/notarychange-iou/workflows/src/main/kotlin/net/corda/samples/notarychange/flows/SettleFlow.kt b/Features/notarychange-iou/workflows/src/main/kotlin/net/corda/samples/notarychange/flows/SettleFlow.kt index 57bf83cc..ab7dad4e 100644 --- a/Features/notarychange-iou/workflows/src/main/kotlin/net/corda/samples/notarychange/flows/SettleFlow.kt +++ b/Features/notarychange-iou/workflows/src/main/kotlin/net/corda/samples/notarychange/flows/SettleFlow.kt @@ -12,7 +12,6 @@ import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.ProgressTracker import net.corda.samples.notarychange.contracts.IOUContract import net.corda.samples.notarychange.states.IOUState -import java.util.* class SettleFlow { @InitiatingFlow @@ -25,12 +24,12 @@ class SettleFlow { private val VERIFYING_TRANSACTION = ProgressTracker.Step("Verifying contract constraints.") private val SIGNING_TRANSACTION = ProgressTracker.Step("Signing transaction with our private key.") private val GATHERING_SIGS: ProgressTracker.Step = object : ProgressTracker.Step("Gathering the counterparty's signature.") { - override fun childProgressTracker(): ProgressTracker? { + override fun childProgressTracker(): ProgressTracker { return CollectSignaturesFlow.tracker() } } private val FINALISING_TRANSACTION: ProgressTracker.Step = object : ProgressTracker.Step("Obtaining notary signature and recording transaction.") { - override fun childProgressTracker(): ProgressTracker? { + override fun childProgressTracker(): ProgressTracker { return FinalityFlow.tracker() } } @@ -68,7 +67,7 @@ class SettleFlow { progressTracker.currentStep = QUERYING_VAULT val queryCriteria: QueryCriteria = LinearStateQueryCriteria(null, listOf(linearId.id)) val (states) = serviceHub.vaultService.queryBy(IOUState::class.java, queryCriteria) - if (states.size == 0) { + if (states.isEmpty()) { throw FlowException("No IOU found for LinearId:$linearId") } val iouStateStateAndRef = states[0] @@ -78,10 +77,9 @@ class SettleFlow { } progressTracker.currentStep = GENERATING_TRANSACTION // Generate an unsigned transaction. - val me = ourIdentity val txCommand = Command( IOUContract.Commands.Settle(), - Arrays.asList(inputStateToSettle.lender.owningKey, inputStateToSettle.borrower.owningKey)) + listOf(inputStateToSettle.lender.owningKey, inputStateToSettle.borrower.owningKey)) val txBuilder = TransactionBuilder(notary) .addInputState(iouStateStateAndRef) .addCommand(txCommand) diff --git a/Features/notarychange-iou/workflows/src/main/kotlin/net/corda/samples/notarychange/flows/SwitchNotaryFlow.kt b/Features/notarychange-iou/workflows/src/main/kotlin/net/corda/samples/notarychange/flows/SwitchNotaryFlow.kt index 80b96a89..0e7e84be 100644 --- a/Features/notarychange-iou/workflows/src/main/kotlin/net/corda/samples/notarychange/flows/SwitchNotaryFlow.kt +++ b/Features/notarychange-iou/workflows/src/main/kotlin/net/corda/samples/notarychange/flows/SwitchNotaryFlow.kt @@ -15,7 +15,7 @@ import net.corda.samples.notarychange.states.IOUState class SwitchNotaryFlow(private val linearId: UniqueIdentifier, private val newNotary: Party) : FlowLogic() { private val QUERYING_VAULT = ProgressTracker.Step("Fetching IOU from node's vault.") private val INITITATING_TRANSACTION: ProgressTracker.Step = object : ProgressTracker.Step("Initiating Notary Change Transaction") { - override fun childProgressTracker(): ProgressTracker? { + override fun childProgressTracker(): ProgressTracker { return tracker() } } @@ -30,7 +30,7 @@ class SwitchNotaryFlow(private val linearId: UniqueIdentifier, private val newNo progressTracker.currentStep = QUERYING_VAULT val queryCriteria: QueryCriteria = LinearStateQueryCriteria(null, listOf(linearId.id)) val (states) = serviceHub.vaultService.queryBy(IOUState::class.java, queryCriteria) - if (states.size == 0) { + if (states.isEmpty()) { throw FlowException("No IOU found for LinearId:$linearId") } progressTracker.currentStep = INITITATING_TRANSACTION diff --git a/Features/notarychange-iou/workflows/src/test/kotlin/net/corda/samples/notarychange/FlowTests.kt b/Features/notarychange-iou/workflows/src/test/kotlin/net/corda/samples/notarychange/FlowTests.kt index 1bd97e3b..3551bf79 100644 --- a/Features/notarychange-iou/workflows/src/test/kotlin/net/corda/samples/notarychange/FlowTests.kt +++ b/Features/notarychange-iou/workflows/src/test/kotlin/net/corda/samples/notarychange/FlowTests.kt @@ -7,23 +7,23 @@ import net.corda.samples.notarychange.flows.IssueFlow import net.corda.samples.notarychange.flows.SettleFlow import net.corda.samples.notarychange.flows.SwitchNotaryFlow import net.corda.testing.node.* -import org.hamcrest.CoreMatchers import org.junit.After import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.rules.ExpectedException +import org.junit.rules.TestRule import java.util.concurrent.ExecutionException import kotlin.test.assertFailsWith -@Rule -val exception = ExpectedException.none() - class FlowTests { + private lateinit var network: MockNetwork + private lateinit var a: StartedMockNode + private lateinit var b: StartedMockNode - private var network: MockNetwork? = null - private var a: StartedMockNode? = null - private var b: StartedMockNode? = null + @Rule + @JvmField + val exception: TestRule = ExpectedException.none() @Before fun setup() { @@ -32,42 +32,44 @@ class FlowTests { TestCordapp.findCordapp("net.corda.samples.notarychange.flows") ), notarySpecs = listOf(MockNetworkNotarySpec(CordaX500Name("NotaryA", "London", "GB")), MockNetworkNotarySpec(CordaX500Name("NotaryB", "Toronto", "CA"))))) - a = network!!.createPartyNode(null) - b = network!!.createPartyNode(null) - network!!.runNetwork() + a = network.createPartyNode(null) + b = network.createPartyNode(null) + network.runNetwork() } @After fun tearDown() { - network!!.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test @Throws(ExecutionException::class, InterruptedException::class) - fun NoNotaryChangesExpectToFail() { - val issueflow = IssueFlow.Initiator(20, b!!.info.legalIdentities[0]) - val future = a!!.startFlow(issueflow) - network!!.runNetwork() + fun noNotaryChangesExpectToFail() { + val issueflow = IssueFlow.Initiator(20, b.info.legalIdentities[0]) + val future = a.startFlow(issueflow) + network.runNetwork() val returnString = future.get() println("\n----------") println(returnString) val id = returnString.substring(returnString.indexOf("linearId: ") + 10) println(id) val settleflow = SettleFlow.Initiator(fromString(id), - network!!.notaryNodes[1].info.legalIdentities[0]) - val future2 = b!!.startFlow(settleflow) - network!!.runNetwork() + network.notaryNodes[1].info.legalIdentities[0]) + val future2 = b.startFlow(settleflow) + network.runNetwork() assertFailsWith { future2.getOrThrow() } } @Test @Throws(ExecutionException::class, InterruptedException::class) - fun CondunctNotaryChanges() { - val issueflow = IssueFlow.Initiator(20, b!!.info.legalIdentities[0]) - val future = a!!.startFlow(issueflow) - network!!.runNetwork() + fun condunctNotaryChanges() { + val issueflow = IssueFlow.Initiator(20, b.info.legalIdentities[0]) + val future = a.startFlow(issueflow) + network.runNetwork() val returnString = future.get() println("\n----------") println(returnString) @@ -76,17 +78,15 @@ class FlowTests { //notary change val notarychange = SwitchNotaryFlow(fromString(id), - network!!.notaryNodes[1].info.legalIdentities[0]) - val future3 = b!!.startFlow(notarychange) - network!!.runNetwork() + network.notaryNodes[1].info.legalIdentities[0]) + b.startFlow(notarychange) + network.runNetwork() //settle val settleflow = SettleFlow.Initiator(fromString(id), - network!!.notaryNodes[1].info.legalIdentities[0]) - val future2 = b!!.startFlow(settleflow) - network!!.runNetwork() + network.notaryNodes[1].info.legalIdentities[0]) + val future2 = b.startFlow(settleflow) + network.runNetwork() future2.get() } - - -} \ No newline at end of file +} diff --git a/Features/observableStates-tradereporting/README.md b/Features/observableStates-tradereporting/README.md index 2e28cdad..9fd23b97 100644 --- a/Features/observableStates-tradereporting/README.md +++ b/Features/observableStates-tradereporting/README.md @@ -33,7 +33,7 @@ For development environment setup, please refer to: [Setup Guide](https://docs.c Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) ``` diff --git a/Features/observableStates-tradereporting/build.gradle b/Features/observableStates-tradereporting/build.gradle index 1b88ea3d..18bbe5e9 100644 --- a/Features/observableStates-tradereporting/build.gradle +++ b/Features/observableStates-tradereporting/build.gradle @@ -1,122 +1,70 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") - - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" -} + cordapp project(':workflows') + cordapp project(':contracts') -//Task to build the jar for ganache. -task ganache { - subprojects { - if (it.project.name != "clients") { - dependsOn jar - doLast { - copy { - from "${buildDir}/libs" - into "${rootDir}/build/libs" - } - } - } - } + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } - -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = true - } cordapp project(':contracts') cordapp project(':workflows') - runSchemaMigration = true - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. + rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"] ]] } node { name "O=Notary,L=London,C=GB" @@ -126,7 +74,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10004") } - cordapps.clear() + rpcUsers = [] } node { name "O=Seller,L=London,C=GB" @@ -160,4 +108,4 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { adminAddress("localhost:10016") } } -} \ No newline at end of file +} diff --git a/Features/observableStates-tradereporting/contracts/build.gradle b/Features/observableStates-tradereporting/contracts/build.gradle index f274c808..b9c103a5 100644 --- a/Features/observableStates-tradereporting/contracts/build.gradle +++ b/Features/observableStates-tradereporting/contracts/build.gradle @@ -1,10 +1,13 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { - name "Template Contracts" + name "Trade-Reporting Contracts" vendor "Corda Open Source" licence "Apache License, Version 2.0" versionId 1 @@ -12,8 +15,10 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" + // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Features/observableStates-tradereporting/contracts/src/main/kotlin/net/corda/samples/observable/contracts/HighlyRegulatedContract.kt b/Features/observableStates-tradereporting/contracts/src/main/kotlin/net/corda/samples/observable/contracts/HighlyRegulatedContract.kt index 63818ac1..ba6f7d36 100644 --- a/Features/observableStates-tradereporting/contracts/src/main/kotlin/net/corda/samples/observable/contracts/HighlyRegulatedContract.kt +++ b/Features/observableStates-tradereporting/contracts/src/main/kotlin/net/corda/samples/observable/contracts/HighlyRegulatedContract.kt @@ -15,10 +15,10 @@ class HighlyRegulatedContract : Contract { override fun verify(tx: LedgerTransaction) { // Verification logic goes here. val cmd = tx.commands.requireSingleCommand() - val output = tx.outputsOfType(HighlyRegulatedState::class.java)[0] + val output = tx.outputsOfType()[0] when(cmd.value){ is Commands.Trade -> requireThat { - "The Buyer and the seller cannot be the same entity." using (!output.buyer.equals(output.seller)) + "The Buyer and the seller cannot be the same entity." using (output.buyer != output.seller) } } } diff --git a/Features/observableStates-tradereporting/contracts/src/test/kotlin/net/corda/samples/observable/contracts/ContractTests.kt b/Features/observableStates-tradereporting/contracts/src/test/kotlin/net/corda/samples/observable/contracts/ContractTests.kt index 7ea5438d..9b5e54d9 100644 --- a/Features/observableStates-tradereporting/contracts/src/test/kotlin/net/corda/samples/observable/contracts/ContractTests.kt +++ b/Features/observableStates-tradereporting/contracts/src/test/kotlin/net/corda/samples/observable/contracts/ContractTests.kt @@ -9,8 +9,8 @@ import org.junit.Test class ContractTests { private val ledgerServices = MockServices() - val partya = TestIdentity(CordaX500Name(organisation = "Alice", locality = "TestLand", country = "US")) - var partyb = TestIdentity(CordaX500Name("Bob", "TestLand", "US")) + private val partya = TestIdentity(CordaX500Name(organisation = "Alice", locality = "TestLand", country = "US")) + private val partyb = TestIdentity(CordaX500Name("Bob", "TestLand", "US")) @Test fun `No Negative PayCheck Value`() { diff --git a/Features/observableStates-tradereporting/contracts/src/test/kotlin/net/corda/samples/observable/contracts/StateTests.kt b/Features/observableStates-tradereporting/contracts/src/test/kotlin/net/corda/samples/observable/contracts/StateTests.kt index 2bdc0b52..6cdbcfd1 100644 --- a/Features/observableStates-tradereporting/contracts/src/test/kotlin/net/corda/samples/observable/contracts/StateTests.kt +++ b/Features/observableStates-tradereporting/contracts/src/test/kotlin/net/corda/samples/observable/contracts/StateTests.kt @@ -2,6 +2,7 @@ package net.corda.samples.observable.contracts import net.corda.core.identity.Party import net.corda.samples.observable.states.HighlyRegulatedState +import org.junit.Assert.assertSame import org.junit.Test class StateTests { @@ -10,6 +11,6 @@ class StateTests { fun hasFieldOfCorrectType() { // Does the message field exist? HighlyRegulatedState::class.java.getDeclaredField("buyer") - assert(HighlyRegulatedState::class.java.getDeclaredField("buyer").type == Party::class.java) + assertSame(Party::class.java, HighlyRegulatedState::class.java.getDeclaredField("buyer").type) } -} \ No newline at end of file +} diff --git a/Features/observableStates-tradereporting/gradle.properties b/Features/observableStates-tradereporting/gradle.properties index c2b34872..3677067d 100644 --- a/Features/observableStates-tradereporting/gradle.properties +++ b/Features/observableStates-tradereporting/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Observable State Cordapp group=com.observable version=0.1 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Features/observableStates-tradereporting/gradle/wrapper/gradle-wrapper.jar b/Features/observableStates-tradereporting/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Features/observableStates-tradereporting/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Features/observableStates-tradereporting/gradle/wrapper/gradle-wrapper.properties b/Features/observableStates-tradereporting/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Features/observableStates-tradereporting/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Features/observableStates-tradereporting/gradlew b/Features/observableStates-tradereporting/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Features/observableStates-tradereporting/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Features/observableStates-tradereporting/gradlew.bat b/Features/observableStates-tradereporting/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Features/observableStates-tradereporting/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Features/observableStates-tradereporting/repositories.gradle b/Features/observableStates-tradereporting/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Features/observableStates-tradereporting/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Features/observableStates-tradereporting/settings.gradle b/Features/observableStates-tradereporting/settings.gradle index 2514aca2..c1f46514 100644 --- a/Features/observableStates-tradereporting/settings.gradle +++ b/Features/observableStates-tradereporting/settings.gradle @@ -1,3 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file diff --git a/Features/observableStates-tradereporting/workflows/build.gradle b/Features/observableStates-tradereporting/workflows/build.gradle index 5088f6b5..750377f6 100644 --- a/Features/observableStates-tradereporting/workflows/build.gradle +++ b/Features/observableStates-tradereporting/workflows/build.gradle @@ -1,11 +1,14 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { - name "Template Flows" + name "Trade-Reporting Flows" vendor "Corda Open Source" licence "Apache License, Version 2.0" versionId 1 @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,25 +31,23 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Features/observableStates-tradereporting/workflows/src/test/kotlin/net/corda/samples/observable/FlowTests.kt b/Features/observableStates-tradereporting/workflows/src/test/kotlin/net/corda/samples/observable/FlowTests.kt index 0cd146f4..e7312554 100644 --- a/Features/observableStates-tradereporting/workflows/src/test/kotlin/net/corda/samples/observable/FlowTests.kt +++ b/Features/observableStates-tradereporting/workflows/src/test/kotlin/net/corda/samples/observable/FlowTests.kt @@ -1,6 +1,5 @@ package net.corda.samples.observable - import net.corda.core.identity.CordaX500Name import net.corda.samples.observable.flows.TradeAndReport import net.corda.samples.observable.states.HighlyRegulatedState @@ -9,7 +8,7 @@ import net.corda.testing.node.MockNetworkNotarySpec import net.corda.testing.node.MockNetworkParameters import net.corda.testing.node.TestCordapp import org.junit.After -import org.junit.Before +import org.junit.Assert.assertTrue import org.junit.Test import java.util.concurrent.ExecutionException @@ -24,23 +23,20 @@ class FlowTests { private val c = network.createNode() private val d = network.createNode() - @Throws - fun setup() = network.runNetwork() - @After fun tearDown() = network.stopNodes() @Test @Throws(ExecutionException::class, InterruptedException::class) - fun CheckIfObserverHaveTheStates() { - a.startFlow(TradeAndReport(d.info.legalIdentities.get(0), - b.info.legalIdentities[0], c.info.legalIdentities.get(0))) + fun checkIfObserverHaveTheStates() { + a.startFlow(TradeAndReport(d.info.legalIdentities[0], + b.info.legalIdentities[0], c.info.legalIdentities[0])) network.runNetwork() val bNodeStoredStates = b.services.vaultService.queryBy(HighlyRegulatedState::class.java) .states[0].state.data - assert(bNodeStoredStates.participants.contains(d.info.legalIdentities.get(0))) + assertTrue(bNodeStoredStates.participants.contains(d.info.legalIdentities[0])) val cNodeStoredStates: HighlyRegulatedState = c.services.vaultService.queryBy(HighlyRegulatedState::class.java) .states.get(0).state.data - assert(cNodeStoredStates.participants.contains(d.info.legalIdentities.get(0))) + assertTrue(cNodeStoredStates.participants.contains(d.info.legalIdentities[0])) } -} \ No newline at end of file +} diff --git a/Features/oracle-primenumber/README.md b/Features/oracle-primenumber/README.md index 088c4bd1..87e5ec44 100644 --- a/Features/oracle-primenumber/README.md +++ b/Features/oracle-primenumber/README.md @@ -34,7 +34,7 @@ For development environment setup, please refer to: [Setup Guide](https://docs.c Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) ``` diff --git a/Features/oracle-primenumber/build.gradle b/Features/oracle-primenumber/build.gradle index 63e46e0c..1742341c 100644 --- a/Features/oracle-primenumber/build.gradle +++ b/Features/oracle-primenumber/build.gradle @@ -1,118 +1,71 @@ -buildscript { - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.quasar-utils' -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' - -cordapp { - targetPlatformVersion corda_platform_version.toInteger() - minimumPlatformVersion corda_platform_version.toInteger() - info { - name "Oracle Primenumber" - vendor "Corda Open Source" - } -} - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } +//Module dependencis dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - - cordaCompile "$corda_release_group:corda-rpc:$corda_release_version" - cordaCompile "$corda_release_group:corda-jackson:$corda_release_version" - cordaCompile "$corda_release_group:corda-node-api:$corda_release_version" - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - - cordaRuntime "$corda_release_group:corda:$corda_release_version" - cordaRuntime "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" - - testCompile "junit:junit:$junit_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" - - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") - cordapp project(":workflows") -} + cordapp project(':workflows') + cordapp project(':contracts') -task deployNodesKotlin(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" +} +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = false - } - runSchemaMigration = true + cordapp project(':contracts') + cordapp project(':workflows') + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } - node { name "O=Notary,L=London,C=GB" notary = [validating : false] @@ -121,7 +74,7 @@ task deployNodesKotlin(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } - cordapps = [] + rpcUsers = [] } node { @@ -131,9 +84,6 @@ task deployNodesKotlin(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - cordapp project(":contracts") - cordapp project(":workflows") - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { @@ -143,8 +93,5 @@ task deployNodesKotlin(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - cordapp project(":contracts") - cordapp project(":workflows") - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } } diff --git a/Features/oracle-primenumber/contracts/build.gradle b/Features/oracle-primenumber/contracts/build.gradle index 32baccdb..a0cfb29d 100644 --- a/Features/oracle-primenumber/contracts/build.gradle +++ b/Features/oracle-primenumber/contracts/build.gradle @@ -1,5 +1,7 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -13,32 +15,11 @@ cordapp { } } -sourceSets { - main { - java { - srcDir 'src/main/java' - java.outputDir = file('bin/main') - } - } - - test { - java { - srcDir 'src/test/java' - java.outputDir = file('bin/test') - } - } -} - dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaCompile "$corda_release_group:corda-jackson:$corda_release_version" - cordaCompile "$corda_release_group:corda-rpc:$corda_release_version" - cordaCompile "$corda_release_group:corda-node-api:$corda_release_version" - - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Features/oracle-primenumber/contracts/src/main/kotlin/net/corda/samples/contracts/PrimeContract.kt b/Features/oracle-primenumber/contracts/src/main/kotlin/net/corda/samples/oracle/contracts/PrimeContract.kt similarity index 87% rename from Features/oracle-primenumber/contracts/src/main/kotlin/net/corda/samples/contracts/PrimeContract.kt rename to Features/oracle-primenumber/contracts/src/main/kotlin/net/corda/samples/oracle/contracts/PrimeContract.kt index e33561d7..bf5bc750 100644 --- a/Features/oracle-primenumber/contracts/src/main/kotlin/net/corda/samples/contracts/PrimeContract.kt +++ b/Features/oracle-primenumber/contracts/src/main/kotlin/net/corda/samples/oracle/contracts/PrimeContract.kt @@ -1,14 +1,14 @@ -package net.corda.samples.contracts +package net.corda.samples.oracle.contracts import net.corda.core.contracts.* import net.corda.core.transactions.LedgerTransaction -import net.corda.samples.states.PrimeState +import net.corda.samples.oracle.states.PrimeState class PrimeContract : Contract { companion object { - const val PRIME_PROGRAM_ID: ContractClassName = "net.corda.samples.contracts.PrimeContract" + const val PRIME_PROGRAM_ID: ContractClassName = "net.corda.samples.oracle.contracts.PrimeContract" } // Commands signed by oracles must contain the facts the oracle is attesting to. diff --git a/Features/oracle-primenumber/contracts/src/main/kotlin/net/corda/samples/states/PrimeState.kt b/Features/oracle-primenumber/contracts/src/main/kotlin/net/corda/samples/oracle/states/PrimeState.kt similarity index 76% rename from Features/oracle-primenumber/contracts/src/main/kotlin/net/corda/samples/states/PrimeState.kt rename to Features/oracle-primenumber/contracts/src/main/kotlin/net/corda/samples/oracle/states/PrimeState.kt index 07513124..fda111c1 100644 --- a/Features/oracle-primenumber/contracts/src/main/kotlin/net/corda/samples/states/PrimeState.kt +++ b/Features/oracle-primenumber/contracts/src/main/kotlin/net/corda/samples/oracle/states/PrimeState.kt @@ -1,17 +1,17 @@ -package net.corda.samples.states +package net.corda.samples.oracle.states import net.corda.core.contracts.BelongsToContract import net.corda.core.contracts.ContractState import net.corda.core.identity.AbstractParty -import net.corda.samples.contracts.PrimeContract - +import net.corda.samples.oracle.contracts.PrimeContract // If 'n' is a natural number N then 'nthPrime' is the Nth prime. // `Requester` is the Party that will store this fact in its vault. @BelongsToContract(PrimeContract::class) data class PrimeState(val n: Int, val nthPrime: Int, - val requester: AbstractParty) : ContractState { + val requester: AbstractParty +) : ContractState { override val participants: List get() = listOf(requester) override fun toString() = "The ${n}th prime number is $nthPrime." -} +} \ No newline at end of file diff --git a/Features/oracle-primenumber/contracts/src/test/kotlin/net/corda/samples/contracts/PrimeContractTests.kt b/Features/oracle-primenumber/contracts/src/test/kotlin/net/corda/samples/oracle/contracts/PrimeContractTests.kt similarity index 69% rename from Features/oracle-primenumber/contracts/src/test/kotlin/net/corda/samples/contracts/PrimeContractTests.kt rename to Features/oracle-primenumber/contracts/src/test/kotlin/net/corda/samples/oracle/contracts/PrimeContractTests.kt index 8481866d..6b9a6163 100644 --- a/Features/oracle-primenumber/contracts/src/test/kotlin/net/corda/samples/contracts/PrimeContractTests.kt +++ b/Features/oracle-primenumber/contracts/src/test/kotlin/net/corda/samples/oracle/contracts/PrimeContractTests.kt @@ -1,16 +1,15 @@ -package net.corda.samples.contracts +package net.corda.samples.oracle.contracts import net.corda.core.contracts.CommandData import net.corda.core.contracts.Contract import net.corda.core.contracts.TypeOnlyCommandData import net.corda.core.identity.CordaX500Name -import net.corda.samples.states.PrimeState +import net.corda.samples.oracle.states.PrimeState import net.corda.testing.core.TestIdentity import net.corda.testing.node.MockServices import net.corda.testing.node.ledger -import org.jgroups.util.Util +import org.junit.Assert import org.junit.Test -import java.util.* class PrimeContractTests { @@ -20,22 +19,21 @@ class PrimeContractTests { } private val ledgerServices = MockServices( - Arrays.asList("net.corda.samples.contracts") + listOf("net.corda.samples.oracle.contracts") ) private val a = TestIdentity(CordaX500Name("Alice", "", "GB")) - private val b = TestIdentity(CordaX500Name("Bob", "", "GB")) private val st = PrimeState(1, 5, a.party) @Test fun contractImplementsContract() { - assert(PrimeContract() is Contract) + Assert.assertTrue(PrimeContract() is Contract) } @Test fun constructorTest() { - Util.assertEquals(1, st.n) - Util.assertEquals(5, st.nthPrime) + Assert.assertEquals(1, st.n) + Assert.assertEquals(5, st.nthPrime) } @Test @@ -44,14 +42,14 @@ class PrimeContractTests { transaction { output(PrimeContract.PRIME_PROGRAM_ID, st) // Has two commands, will fail. - command(Arrays.asList(a.publicKey), PrimeContract.Create(1, 5)) - command(Arrays.asList(a.publicKey), PrimeContract.Create(1, 5)) + command(listOf(a.publicKey), PrimeContract.Create(1, 5)) + command(listOf(a.publicKey), PrimeContract.Create(1, 5)) fails() } transaction { output(PrimeContract.PRIME_PROGRAM_ID, st) // Has one command, will verify. - command(Arrays.asList(a.publicKey), PrimeContract.Create(1, 5)) + command(listOf(a.publicKey), PrimeContract.Create(1, 5)) verifies() } } @@ -64,16 +62,16 @@ class PrimeContractTests { transaction { // Has wrong command type, will fail. output(PrimeContract.PRIME_PROGRAM_ID, st) - command(Arrays.asList(a.publicKey), Commands.DummyCommand()) + command(listOf(a.publicKey), Commands.DummyCommand()) fails() } transaction { // Has correct command type, will verify. output(PrimeContract.PRIME_PROGRAM_ID, st) - command(Arrays.asList(a.publicKey), PrimeContract.Create(1, 5)) + command(listOf(a.publicKey), PrimeContract.Create(1, 5)) verifies() } } } -} +} \ No newline at end of file diff --git a/Features/oracle-primenumber/contracts/src/test/kotlin/net/corda/samples/oracle/states/PrimeStateTests.kt b/Features/oracle-primenumber/contracts/src/test/kotlin/net/corda/samples/oracle/states/PrimeStateTests.kt new file mode 100644 index 00000000..9695bb72 --- /dev/null +++ b/Features/oracle-primenumber/contracts/src/test/kotlin/net/corda/samples/oracle/states/PrimeStateTests.kt @@ -0,0 +1,18 @@ +package net.corda.samples.oracle.states + +import net.corda.core.identity.CordaX500Name +import net.corda.testing.core.TestIdentity +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Test + +class PrimeStateTests { + private val a = TestIdentity(CordaX500Name("Alice", "", "GB")) + + @Test + fun constructorTest() { + val st = PrimeState(1, 5, a.party) + assertEquals(a.party, st.requester) + assertTrue(st.participants.contains(a.party)) + } +} \ No newline at end of file diff --git a/Features/oracle-primenumber/contracts/src/test/kotlin/net/corda/samples/states/PrimeStateTests.kt b/Features/oracle-primenumber/contracts/src/test/kotlin/net/corda/samples/states/PrimeStateTests.kt deleted file mode 100644 index 589e3640..00000000 --- a/Features/oracle-primenumber/contracts/src/test/kotlin/net/corda/samples/states/PrimeStateTests.kt +++ /dev/null @@ -1,19 +0,0 @@ -package net.corda.samples.states - -import net.corda.core.identity.CordaX500Name -import net.corda.testing.core.TestIdentity -import org.jgroups.util.Util -import org.junit.Assert -import org.junit.Test - -class PrimeStateTests { - - var a = TestIdentity(CordaX500Name("Alice", "", "GB")) - - @Test - fun constructorTest() { - val st = PrimeState(1, 5, a.party) - Assert.assertEquals(a.party, st.requester) - Util.assertTrue(st.participants.contains(a.party)) - } -} diff --git a/Features/oracle-primenumber/gradle.properties b/Features/oracle-primenumber/gradle.properties index 46571434..b2f70dda 100644 --- a/Features/oracle-primenumber/gradle.properties +++ b/Features/oracle-primenumber/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Oracle Primenumber -group=com.oracle +group=com.exmple.oracle version=1.0 -kotlin.incremental=false + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Features/oracle-primenumber/gradle/wrapper/gradle-wrapper.jar b/Features/oracle-primenumber/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Features/oracle-primenumber/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Features/oracle-primenumber/gradle/wrapper/gradle-wrapper.properties b/Features/oracle-primenumber/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 674bdda0..00000000 --- a/Features/oracle-primenumber/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Features/oracle-primenumber/gradlew b/Features/oracle-primenumber/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Features/oracle-primenumber/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Features/oracle-primenumber/gradlew.bat b/Features/oracle-primenumber/gradlew.bat deleted file mode 100644 index e95643d6..00000000 --- a/Features/oracle-primenumber/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Features/oracle-primenumber/lib/README.txt b/Features/oracle-primenumber/lib/README.txt deleted file mode 100644 index b0592c95..00000000 --- a/Features/oracle-primenumber/lib/README.txt +++ /dev/null @@ -1,8 +0,0 @@ -The Quasar.jar in this directory is for runtime instrumentation of classes by Quasar. - -When running corda outside of the given gradle building you must add the following flag with the -correct path to your call to Java: - - java -javaagent:path-to-quasar-jar.jar ... - -See the Quasar docs for more information: http://docs.paralleluniverse.co/quasar/ \ No newline at end of file diff --git a/Features/oracle-primenumber/lib/quasar.jar b/Features/oracle-primenumber/lib/quasar.jar deleted file mode 100644 index 7282d8c8..00000000 Binary files a/Features/oracle-primenumber/lib/quasar.jar and /dev/null differ diff --git a/Features/oracle-primenumber/repositories.gradle b/Features/oracle-primenumber/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Features/oracle-primenumber/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Features/oracle-primenumber/settings.gradle b/Features/oracle-primenumber/settings.gradle index c46db016..c1f46514 100644 --- a/Features/oracle-primenumber/settings.gradle +++ b/Features/oracle-primenumber/settings.gradle @@ -1,2 +1,35 @@ -include 'contracts' +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' +include 'contracts' diff --git a/Features/oracle-primenumber/workflows/build.gradle b/Features/oracle-primenumber/workflows/build.gradle index 58f7b344..a728b642 100644 --- a/Features/oracle-primenumber/workflows/build.gradle +++ b/Features/oracle-primenumber/workflows/build.gradle @@ -1,5 +1,8 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -13,19 +16,40 @@ cordapp { } } +sourceSets { + test { + resources { + srcDir rootProject.file("config/test") + } + } + integrationTest { + kotlin { + compileClasspath += main.output + test.output + runtimeClasspath += main.output + test.output + srcDir file('src/integrationTest/kotlin') + } + } +} + +configurations { + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly +} + dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaCompile "$corda_release_group:corda-jackson:$corda_release_version" - cordaCompile "$corda_release_group:corda-rpc:$corda_release_version" - cordaCompile "$corda_release_group:corda-node-api:$corda_release_version" - - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') +} + +tasks.register('integrationTest', Test) { + testClassesDirs = sourceSets.integrationTest.output.classesDirs + classpath = sourceSets.integrationTest.runtimeClasspath } diff --git a/Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/flows/CreatePrime.kt b/Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/oracle/flows/CreatePrime.kt similarity index 95% rename from Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/flows/CreatePrime.kt rename to Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/oracle/flows/CreatePrime.kt index eb818fa8..72d57b18 100644 --- a/Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/flows/CreatePrime.kt +++ b/Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/oracle/flows/CreatePrime.kt @@ -1,6 +1,7 @@ package net.corda.samples.oracle.flows import co.paralleluniverse.fibers.Suspendable +import java.util.function.Predicate import net.corda.core.contracts.Command import net.corda.core.flows.FinalityFlow import net.corda.core.flows.FlowLogic @@ -10,10 +11,9 @@ import net.corda.core.identity.CordaX500Name import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.ProgressTracker -import net.corda.samples.contracts.PrimeContract -import net.corda.samples.contracts.PrimeContract.Companion.PRIME_PROGRAM_ID -import net.corda.samples.states.PrimeState -import java.util.function.Predicate +import net.corda.samples.oracle.contracts.PrimeContract +import net.corda.samples.oracle.contracts.PrimeContract.Companion.PRIME_PROGRAM_ID +import net.corda.samples.oracle.states.PrimeState // The client-side flows that: // - Uses 'QueryPrime' to request the Nth prime number diff --git a/Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/flows/QueryHandler.kt b/Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/oracle/flows/QueryHandler.kt similarity index 100% rename from Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/flows/QueryHandler.kt rename to Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/oracle/flows/QueryHandler.kt diff --git a/Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/flows/QueryPrime.kt b/Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/oracle/flows/QueryPrime.kt similarity index 100% rename from Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/flows/QueryPrime.kt rename to Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/oracle/flows/QueryPrime.kt diff --git a/Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/flows/SignHandler.kt b/Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/oracle/flows/SignHandler.kt similarity index 100% rename from Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/flows/SignHandler.kt rename to Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/oracle/flows/SignHandler.kt diff --git a/Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/flows/SignPrime.kt b/Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/oracle/flows/SignPrime.kt similarity index 100% rename from Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/flows/SignPrime.kt rename to Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/oracle/flows/SignPrime.kt diff --git a/Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/services/Oracle.kt b/Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/oracle/services/Oracle.kt similarity index 95% rename from Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/services/Oracle.kt rename to Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/oracle/services/Oracle.kt index 568afe86..12c5e1b9 100644 --- a/Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/services/Oracle.kt +++ b/Features/oracle-primenumber/workflows/src/main/kotlin/net/corda/samples/oracle/services/Oracle.kt @@ -6,11 +6,10 @@ import net.corda.core.node.ServiceHub import net.corda.core.node.services.CordaService import net.corda.core.serialization.SingletonSerializeAsToken import net.corda.core.transactions.FilteredTransaction -import net.corda.samples.contracts.PrimeContract +import net.corda.samples.oracle.contracts.PrimeContract import java.math.BigInteger import java.util.LinkedHashMap - class MaxSizeHashMap(private val maxSize: Int = 1024) : LinkedHashMap() { override fun removeEldestEntry(eldest: Map.Entry?) = size > maxSize } @@ -43,12 +42,14 @@ class Oracle(val services: ServiceHub) : SingletonSerializeAsToken() { // Returns the Nth prime for N > 0. fun query(n: Int): Int { - return cache.get(n) ?: { + return cache[n] ?: // URL param is n not N. + run { require(n > 0) { "n must be at least one." } // URL param is n not N. val result = primes.take(n).last() - cache.put(n, result) + cache[n] = result + // URL param is n not N. result - }() + } } // Signs over a transaction if the specified Nth prime for a particular N is correct. @@ -79,7 +80,7 @@ class Oracle(val services: ServiceHub) : SingletonSerializeAsToken() { * Function that checks if all of the commands that should be signed by the input public key are visible. * This functionality is required from Oracles to check that all of the commands they should sign are visible. */ - ftx.checkCommandVisibility(services.myInfo.legalIdentities.first().owningKey); + ftx.checkCommandVisibility(services.myInfo.legalIdentities.first().owningKey) if (isValidMerkleTree) { return services.createSignature(ftx, myKey) diff --git a/Features/oracle-primenumber/workflows/src/test/kotlin/net/corda/samples/flows/PrimesClientTests.kt b/Features/oracle-primenumber/workflows/src/test/kotlin/net/corda/samples/oracle/flows/PrimesClientTests.kt similarity index 75% rename from Features/oracle-primenumber/workflows/src/test/kotlin/net/corda/samples/flows/PrimesClientTests.kt rename to Features/oracle-primenumber/workflows/src/test/kotlin/net/corda/samples/oracle/flows/PrimesClientTests.kt index 73d8e3c4..502e40bb 100644 --- a/Features/oracle-primenumber/workflows/src/test/kotlin/net/corda/samples/flows/PrimesClientTests.kt +++ b/Features/oracle-primenumber/workflows/src/test/kotlin/net/corda/samples/oracle/flows/PrimesClientTests.kt @@ -1,21 +1,18 @@ -package net.corda.samples.flows +package net.corda.samples.oracle.flows import net.corda.core.identity.CordaX500Name import net.corda.core.utilities.getOrThrow -import net.corda.samples.oracle.flows.CreatePrime -import net.corda.samples.oracle.flows.QueryHandler -import net.corda.samples.oracle.flows.SignHandler -import net.corda.samples.states.PrimeState +import net.corda.samples.oracle.states.PrimeState import net.corda.testing.node.* import org.junit.After +import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test -import kotlin.test.assertEquals class PrimesClientTests { private val mockNet = MockNetwork(MockNetworkParameters(cordappsForAllNodes = listOf( - TestCordapp.findCordapp("net.corda.samples.flows"), - TestCordapp.findCordapp("net.corda.samples.contracts")), + TestCordapp.findCordapp("net.corda.samples.oracle.flows"), + TestCordapp.findCordapp("net.corda.samples.oracle.contracts")), notarySpecs = listOf(MockNetworkNotarySpec(CordaX500Name("Notary","London","GB"))) )) private lateinit var a: StartedMockNode diff --git a/Features/oracle-primenumber/workflows/src/test/kotlin/net/corda/samples/services/PrimesServiceTests.kt b/Features/oracle-primenumber/workflows/src/test/kotlin/net/corda/samples/oracle/services/PrimesServiceTests.kt similarity index 85% rename from Features/oracle-primenumber/workflows/src/test/kotlin/net/corda/samples/services/PrimesServiceTests.kt rename to Features/oracle-primenumber/workflows/src/test/kotlin/net/corda/samples/oracle/services/PrimesServiceTests.kt index 7b61eedd..34c697aa 100644 --- a/Features/oracle-primenumber/workflows/src/test/kotlin/net/corda/samples/services/PrimesServiceTests.kt +++ b/Features/oracle-primenumber/workflows/src/test/kotlin/net/corda/samples/oracle/services/PrimesServiceTests.kt @@ -1,25 +1,24 @@ -package net.corda.samples.services +package net.corda.samples.oracle.services +import java.util.function.Predicate +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith import net.corda.core.contracts.Command import net.corda.core.contracts.StateAndContract import net.corda.core.identity.CordaX500Name import net.corda.core.transactions.TransactionBuilder -import net.corda.samples.contracts.PrimeContract -import net.corda.samples.contracts.PrimeContract.Companion.PRIME_PROGRAM_ID -import net.corda.samples.oracle.services.Oracle -import net.corda.samples.states.PrimeState +import net.corda.samples.oracle.contracts.PrimeContract +import net.corda.samples.oracle.states.PrimeState import net.corda.testing.core.SerializationEnvironmentRule import net.corda.testing.core.TestIdentity import net.corda.testing.node.MockServices +import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test -import java.util.function.Predicate -import kotlin.test.assertEquals -import kotlin.test.assertFailsWith class PrimesServiceTests { private val oracleIdentity = TestIdentity(CordaX500Name("Oracle", "New York", "US")) - private val dummyServices = MockServices(listOf("net.corda.samples.contracts"), oracleIdentity) + private val dummyServices = MockServices(listOf("net.corda.samples.oracle.contracts"), oracleIdentity) private val oracle = Oracle(dummyServices) private val aliceIdentity = TestIdentity(CordaX500Name("Alice", "", "GB")) private val notaryIdentity = TestIdentity(CordaX500Name("Notary", "", "GB")) @@ -43,7 +42,7 @@ class PrimesServiceTests { fun `oracle signs transactions including a valid prime`() { val command = Command(PrimeContract.Create(10, 29), listOf(oracleIdentity.publicKey)) val state = PrimeState(10, 29, aliceIdentity.party) - val stateAndContract = StateAndContract(state, PRIME_PROGRAM_ID) + val stateAndContract = StateAndContract(state, PrimeContract.PRIME_PROGRAM_ID) val ftx = TransactionBuilder(notaryIdentity.party) .withItems(stateAndContract, command) .toWireTransaction(dummyServices) @@ -55,14 +54,14 @@ class PrimesServiceTests { }) val signature = oracle.sign(ftx) - assert(signature.verify(ftx.id)) + assertTrue(signature.verify(ftx.id)) } @Test fun `oracle does not sign transactions including an invalid prime`() { val command = Command(PrimeContract.Create(10, 1000), listOf(oracleIdentity.publicKey)) val state = PrimeState(10, 29, aliceIdentity.party) - val stateAndContract = StateAndContract(state, PRIME_PROGRAM_ID) + val stateAndContract = StateAndContract(state, PrimeContract.PRIME_PROGRAM_ID) val ftx = TransactionBuilder(notaryIdentity.party) .withItems(stateAndContract, command) .toWireTransaction(oracle.services) @@ -74,4 +73,4 @@ class PrimesServiceTests { }) assertFailsWith { oracle.sign(ftx) } } -} +} \ No newline at end of file diff --git a/Features/postgres-cordapp/README.md b/Features/postgres-cordapp/README.md index 58d0349e..9a31de8c 100644 --- a/Features/postgres-cordapp/README.md +++ b/Features/postgres-cordapp/README.md @@ -19,7 +19,7 @@ docker run --name postgres_for_corda -e POSTGRES_PASSWORD=test -d -p 5432:5432 p # run sql scripts locally on the postgres instance to configure it for use cat config.sql | docker exec -i postgres_for_corda psql -h localhost -p 5432 -U postgres -./gradlew deployNodes +../gradlew deployNodes ./build/nodes/runnodes ``` diff --git a/Features/postgres-cordapp/build.gradle b/Features/postgres-cordapp/build.gradle index c0a7f07a..938aaf57 100644 --- a/Features/postgres-cordapp/build.gradle +++ b/Features/postgres-cordapp/build.gradle @@ -1,113 +1,68 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':workflows') + cordapp project(':contracts') - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" - - cordaDriver "org.postgresql:postgresql:42.2.19" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" + cordaDriver "org.postgresql:postgresql:$postgresql_version" } -//Task to deploy the nodes in order to bootstrap a network -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { - +tasks.register('deployNodes', Cordform) { /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load * the Corda network bootstrapper. */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp project(':contracts') cordapp project(':workflows') + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change //it to false for quicker project compiling time. @@ -121,6 +76,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10011") adminAddress("localhost:10021") } + rpcUsers = [] } node { @@ -132,11 +88,10 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { } extraConfig = [ - "dataSourceProperties.dataSourceClassName": "org.postgresql.ds.PGSimpleDataSource", - "dataSourceProperties.dataSource.url" : "jdbc:postgresql://localhost:5432/postgres", - "dataSourceProperties.dataSource.user" : 'party_a', - "dataSourceProperties.dataSource.password": 'test', - "jarDirs" : ['${ rootProject.projectDir }/drivers'] + "dataSourceProperties.dataSourceClassName": "org.postgresql.ds.PGSimpleDataSource", + "dataSourceProperties.dataSource.url" : "jdbc:postgresql://localhost:5432/postgres", + "dataSourceProperties.dataSource.user" : 'party_a', + "dataSourceProperties.dataSource.password": 'test' ] } @@ -149,12 +104,10 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { } extraConfig = [ - "dataSourceProperties.dataSourceClassName": "org.postgresql.ds.PGSimpleDataSource", - "dataSourceProperties.dataSource.url" : "jdbc:postgresql://localhost:5432/postgres", - "dataSourceProperties.dataSource.user" : 'party_b', - "dataSourceProperties.dataSource.password": 'test', - "jarDirs" : ['${ rootProject.projectDir }/drivers'] + "dataSourceProperties.dataSourceClassName": "org.postgresql.ds.PGSimpleDataSource", + "dataSourceProperties.dataSource.url" : "jdbc:postgresql://localhost:5432/postgres", + "dataSourceProperties.dataSource.user" : 'party_b', + "dataSourceProperties.dataSource.password": 'test' ] } - } diff --git a/Features/postgres-cordapp/clients/build.gradle b/Features/postgres-cordapp/clients/build.gradle index eb58eac2..94580acb 100644 --- a/Features/postgres-cordapp/clients/build.gradle +++ b/Features/postgres-cordapp/clients/build.gradle @@ -1,4 +1,7 @@ -apply plugin: 'org.springframework.boot' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'org.springframework.boot' +} sourceSets { main { @@ -10,39 +13,42 @@ sourceSets { dependencies { // Corda dependencies. - compile "$corda_release_group:corda-rpc:$corda_release_version" + implementation "$corda_release_group:corda-rpc:$corda_release_version" // CorDapp dependencies. - compile project(":contracts") - compile project(":workflows") - compile("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { + implementation project(':contracts') + implementation project(':workflows') + + implementation("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { exclude group: "org.springframework.boot", module: "spring-boot-starter-logging" } - compile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - compile "org.apache.logging.log4j:log4j-web:${log4j_version}" - compile "org.slf4j:jul-to-slf4j:$slf4j_version" -} + runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" + runtimeOnly "org.apache.logging.log4j:log4j-web:$log4j_version" + runtimeOnly "org.slf4j:jul-to-slf4j:$slf4j_version" +} springBoot { - mainClassName = "com.template.webserver.ServerKt" + mainClassName = 'net.corda.samples.postgres.webserver.ServerKt' } /* The Client is the communication channel between the external and the node. This task will help you immediately * execute your rpc methods in the main method of the client.kt. You can somewhat see this as a quick test of making * RPC calls to your nodes. */ -task runTemplateClient(type: JavaExec, dependsOn: assemble) { +tasks.register('runTemplateClient', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath - main = 'com.template.ClientKt' + main = 'net.corda.samples.postgres.ClientKt' args 'localhost:10006', 'user1', 'test' } /* This task will start the springboot server that connects to your node (via RPC connection). All of the http requests * are in the Controller file. You can leave the Server.kt and NodeRPCConnection.kt file untouched for your use. */ -task runTemplateServer(type: JavaExec, dependsOn: assemble) { +tasks.register('runTemplateServer', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath - main = 'com.template.webserver.ServerKt' + main = 'net.corda.samples.postgres.webserver.ServerKt' args '--server.port=10050', '--config.rpc.host=localhost', '--config.rpc.port=10006', '--config.rpc.username=user1', '--config.rpc.password=test' -} \ No newline at end of file +} diff --git a/Features/postgres-cordapp/contracts/build.gradle b/Features/postgres-cordapp/contracts/build.gradle index f274c808..8198b453 100644 --- a/Features/postgres-cordapp/contracts/build.gradle +++ b/Features/postgres-cordapp/contracts/build.gradle @@ -1,10 +1,13 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { - name "Template Contracts" + name "PostgreSQL Contracts" vendor "Corda Open Source" licence "Apache License, Version 2.0" versionId 1 @@ -12,8 +15,9 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "junit:junit:$junit_version" + // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Features/postgres-cordapp/contracts/src/main/kotlin/net/corda/samples/postgres/contracts/YoContract.kt b/Features/postgres-cordapp/contracts/src/main/kotlin/net/corda/samples/postgres/contracts/YoContract.kt index 49313e27..d43d0a62 100644 --- a/Features/postgres-cordapp/contracts/src/main/kotlin/net/corda/samples/postgres/contracts/YoContract.kt +++ b/Features/postgres-cordapp/contracts/src/main/kotlin/net/corda/samples/postgres/contracts/YoContract.kt @@ -7,7 +7,6 @@ import net.corda.core.contracts.requireThat import net.corda.core.transactions.LedgerTransaction import net.corda.samples.postgres.states.YoState - // ************ // * Contract * // ************ diff --git a/Features/postgres-cordapp/contracts/src/main/kotlin/net/corda/samples/postgres/states/YoState.kt b/Features/postgres-cordapp/contracts/src/main/kotlin/net/corda/samples/postgres/states/YoState.kt index 84cb3860..529eeff8 100644 --- a/Features/postgres-cordapp/contracts/src/main/kotlin/net/corda/samples/postgres/states/YoState.kt +++ b/Features/postgres-cordapp/contracts/src/main/kotlin/net/corda/samples/postgres/states/YoState.kt @@ -1,13 +1,11 @@ package net.corda.samples.postgres.states - import net.corda.core.contracts.BelongsToContract import net.corda.core.contracts.ContractState import net.corda.core.identity.AbstractParty import net.corda.core.identity.Party import net.corda.core.serialization.ConstructorForDeserialization import net.corda.samples.postgres.contracts.YoContract -import java.util.* // ********* // * State * @@ -32,7 +30,7 @@ class YoState : ContractState { } override val participants: List - get() = Arrays.asList(target) + get() = listOf(target) override fun toString(): String { return origin.name.toString() + ": " + yo diff --git a/Features/postgres-cordapp/contracts/src/test/kotlin/net/corda/samples/postgres/contracts/ContractTests.kt b/Features/postgres-cordapp/contracts/src/test/kotlin/net/corda/samples/postgres/contracts/ContractTests.kt index f2aa61a2..8d55c957 100644 --- a/Features/postgres-cordapp/contracts/src/test/kotlin/net/corda/samples/postgres/contracts/ContractTests.kt +++ b/Features/postgres-cordapp/contracts/src/test/kotlin/net/corda/samples/postgres/contracts/ContractTests.kt @@ -1,13 +1,9 @@ package net.corda.samples.postgres.contracts -import net.corda.testing.node.MockServices import org.junit.Test class ContractTests { - private val ledgerServices = MockServices() - @Test fun `dummy test`() { - } } diff --git a/Features/postgres-cordapp/contracts/src/test/kotlin/net/corda/samples/postgres/states/StateTests.kt b/Features/postgres-cordapp/contracts/src/test/kotlin/net/corda/samples/postgres/states/StateTests.kt index c0540657..e41e3e3b 100644 --- a/Features/postgres-cordapp/contracts/src/test/kotlin/net/corda/samples/postgres/states/StateTests.kt +++ b/Features/postgres-cordapp/contracts/src/test/kotlin/net/corda/samples/postgres/states/StateTests.kt @@ -1,14 +1,9 @@ package net.corda.samples.postgres.states -import net.corda.testing.node.MockServices import org.junit.Test class StateTests { - private val ledgerServices = MockServices() - @Test fun `dummy test`() { - } } - diff --git a/Features/postgres-cordapp/drivers/postgresql-42.2.19.jar b/Features/postgres-cordapp/drivers/postgresql-42.2.19.jar deleted file mode 100644 index eb818ef4..00000000 Binary files a/Features/postgres-cordapp/drivers/postgresql-42.2.19.jar and /dev/null differ diff --git a/Features/postgres-cordapp/gradle.properties b/Features/postgres-cordapp/gradle.properties index 985a19e5..855ae2dd 100644 --- a/Features/postgres-cordapp/gradle.properties +++ b/Features/postgres-cordapp/gradle.properties @@ -1,4 +1,28 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=PostgreSQL Cordapp group=net.corda.samples.postgres version=0.1 -kotlin.incremental=false + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +postgresql_version=42.3.3 + +spring_boot_version=2.0.2.RELEASE diff --git a/Features/postgres-cordapp/gradle/wrapper/gradle-wrapper.jar b/Features/postgres-cordapp/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Features/postgres-cordapp/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Features/postgres-cordapp/gradle/wrapper/gradle-wrapper.properties b/Features/postgres-cordapp/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Features/postgres-cordapp/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Features/postgres-cordapp/gradlew b/Features/postgres-cordapp/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Features/postgres-cordapp/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Features/postgres-cordapp/gradlew.bat b/Features/postgres-cordapp/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Features/postgres-cordapp/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Features/postgres-cordapp/repositories.gradle b/Features/postgres-cordapp/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Features/postgres-cordapp/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Features/postgres-cordapp/settings.gradle b/Features/postgres-cordapp/settings.gradle index 2514aca2..f303a1f7 100644 --- a/Features/postgres-cordapp/settings.gradle +++ b/Features/postgres-cordapp/settings.gradle @@ -1,3 +1,36 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file +include 'clients' diff --git a/Features/postgres-cordapp/workflows/build.gradle b/Features/postgres-cordapp/workflows/build.gradle index 5088f6b5..e0e24c4f 100644 --- a/Features/postgres-cordapp/workflows/build.gradle +++ b/Features/postgres-cordapp/workflows/build.gradle @@ -1,11 +1,14 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { - name "Template Flows" + name "PostgreSQL Flows" vendor "Corda Open Source" licence "Apache License, Version 2.0" versionId 1 @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,25 +31,23 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Features/postgres-cordapp/workflows/src/integrationTest/kotlin/net/corda/samples/postgres/DriverBasedTest.kt b/Features/postgres-cordapp/workflows/src/integrationTest/kotlin/net/corda/samples/postgres/DriverBasedTest.kt index 74674e93..2c572128 100644 --- a/Features/postgres-cordapp/workflows/src/integrationTest/kotlin/net/corda/samples/postgres/DriverBasedTest.kt +++ b/Features/postgres-cordapp/workflows/src/integrationTest/kotlin/net/corda/samples/postgres/DriverBasedTest.kt @@ -7,9 +7,9 @@ import net.corda.testing.driver.DriverDSL import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.driver +import org.junit.Assert.assertEquals import org.junit.Test import java.util.concurrent.Future -import kotlin.test.assertEquals class DriverBasedTest { private val bankA = TestIdentity(CordaX500Name("BankA", "", "GB")) diff --git a/Features/postgres-cordapp/workflows/src/main/kotlin/net/corda/samples/postgres/flows/YoFlow.kt b/Features/postgres-cordapp/workflows/src/main/kotlin/net/corda/samples/postgres/flows/YoFlow.kt index de86fc20..d423ee22 100644 --- a/Features/postgres-cordapp/workflows/src/main/kotlin/net/corda/samples/postgres/flows/YoFlow.kt +++ b/Features/postgres-cordapp/workflows/src/main/kotlin/net/corda/samples/postgres/flows/YoFlow.kt @@ -11,8 +11,6 @@ import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.ProgressTracker import net.corda.samples.postgres.contracts.YoContract import net.corda.samples.postgres.states.YoState -import java.util.* - // ********* // * Flows * @@ -34,7 +32,6 @@ class YoFlow(private val target: Party) : FlowLogic() { fun tracker() = ProgressTracker(CREATING, SIGNING, VERIFYING, FINALISING) } - @Suspendable @Throws(FlowException::class) override fun call(): SignedTransaction { @@ -43,7 +40,7 @@ class YoFlow(private val target: Party) : FlowLogic() { // Obtain a reference from a notary we wish to use. val notary = serviceHub.networkMapCache.getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")) // METHOD 2 - val command = Command(YoContract.Commands.Send(), Arrays.asList(me.owningKey)) + val command = Command(YoContract.Commands.Send(), listOf(me.owningKey)) val state = YoState(me, target) val stateAndContract = StateAndContract(state, YoContract.ID) val utx = TransactionBuilder(notary).withItems(stateAndContract, command) @@ -57,7 +54,6 @@ class YoFlow(private val target: Party) : FlowLogic() { return subFlow(FinalityFlow(stx, listOf(targetSession), FINALISING.childProgressTracker())) } - } @InitiatedBy(YoFlow::class) diff --git a/Features/postgres-cordapp/workflows/src/test/kotlin/net/corda/samples/postgres/flows/FlowTests.kt b/Features/postgres-cordapp/workflows/src/test/kotlin/net/corda/samples/postgres/flows/FlowTests.kt index 4f801ef6..e1015bc0 100644 --- a/Features/postgres-cordapp/workflows/src/test/kotlin/net/corda/samples/postgres/flows/FlowTests.kt +++ b/Features/postgres-cordapp/workflows/src/test/kotlin/net/corda/samples/postgres/flows/FlowTests.kt @@ -1,30 +1,26 @@ package net.corda.samples.postgres.flows - import net.corda.core.identity.CordaX500Name import net.corda.testing.node.* import org.junit.After +import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test import java.util.concurrent.ExecutionException - class FlowTests { - - lateinit var mockNetwork: MockNetwork - lateinit var a: StartedMockNode - lateinit var b: StartedMockNode + private lateinit var mockNetwork: MockNetwork + private lateinit var a: StartedMockNode + private lateinit var b: StartedMockNode @Before fun setup() { - - val mockNetwork = MockNetwork(MockNetworkParameters(cordappsForAllNodes = listOf( + mockNetwork = MockNetwork(MockNetworkParameters(cordappsForAllNodes = listOf( TestCordapp.findCordapp("net.corda.samples.postgres.contracts"), TestCordapp.findCordapp("net.corda.samples.postgres.flows")), notarySpecs = listOf(MockNetworkNotarySpec(CordaX500Name("Notary","London","GB"))) )) - a = mockNetwork.createNode(MockNodeParameters()) b = mockNetwork.createNode(MockNodeParameters()) val startedNodes = arrayListOf(a, b) @@ -35,20 +31,19 @@ class FlowTests { @After fun tearDown() { - - } - - @Test - fun `dummy test`() { + if (::mockNetwork.isInitialized) { + mockNetwork.stopNodes() + } } @Throws(ExecutionException::class, InterruptedException::class) + @Test fun dummyTest() { val future = a.startFlow(YoFlow(b.info.legalIdentities.first())) mockNetwork.runNetwork() val ptx = future.get() if (ptx != null) { - assert(ptx.tx.inputs.isEmpty()) + assertTrue(ptx.tx.inputs.isEmpty()) } } } diff --git a/Features/queryableState-carinsurance/README.md b/Features/queryableState-carinsurance/README.md index a08028b1..526bf18d 100644 --- a/Features/queryableState-carinsurance/README.md +++ b/Features/queryableState-carinsurance/README.md @@ -18,7 +18,7 @@ made against the insurance. We use them to demonstrate _One-to-Many_ relationshi A spring boot client is provided with the cordapp, which exposes two REST endpoints (see `Controller` in the clients module) to trigger the flows. -Use the command `./gradlew bootRun` in the project root folder to run the [Spring Boot +Use the command `../gradlew bootRun` in the project root folder to run the [Spring Boot Server](https://spring.io/projects/spring-boot#overview). ### Flows @@ -41,7 +41,7 @@ For development environment setup, please refer to: [Setup Guide](https://docs.c Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) ``` @@ -73,4 +73,4 @@ http://www.h2database.com/html/download.html

Refer here for more details regarding connecting to the node database. -https://docs.corda.net/head/node-database-access-h2.html \ No newline at end of file +https://docs.corda.net/head/node-database-access-h2.html diff --git a/Features/queryableState-carinsurance/build.gradle b/Features/queryableState-carinsurance/build.gradle index bb7ba836..040983d7 100644 --- a/Features/queryableState-carinsurance/build.gradle +++ b/Features/queryableState-carinsurance/build.gradle @@ -1,114 +1,78 @@ -buildscript { - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } + } - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } + pluginManager.withPlugin('org.jetbrains.kotlin.plugin.allopen') { + allOpen { + annotations( + 'javax.persistence.Entity', + 'javax.persistence.Embeddable', + 'javax.persistence.MappedSuperclass' + ) + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } +//Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaCompile "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") - - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordapp project(':workflows') + cordapp project(':contracts') } -cordapp { - info { - name "Queryablestate Car Insurance" - vendor "Corda Open Source" - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version - } -} -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = false - } - cordapp project(":contracts") - cordapp project(":workflows") - runSchemaMigration = true + cordapp project(':contracts') + cordapp project(':workflows') + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { name "O=Notary,L=London,C=GB" @@ -118,6 +82,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] cordapps.clear() } node { @@ -127,7 +92,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] extraConfig = ['h2Settings.address' : 'localhost:20041'] } node { @@ -137,7 +101,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] extraConfig = ['h2Settings.address' : 'localhost:20042'] } } diff --git a/Features/queryableState-carinsurance/clients/build.gradle b/Features/queryableState-carinsurance/clients/build.gradle index f0e4add4..bba079ea 100755 --- a/Features/queryableState-carinsurance/clients/build.gradle +++ b/Features/queryableState-carinsurance/clients/build.gradle @@ -1,17 +1,8 @@ -repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://dl.bintray.com/kotlin/exposed' } - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda-releases' } +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'io.spring.dependency-management' } -apply plugin: 'kotlin' -apply plugin: 'io.spring.dependency-management' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - sourceSets { main { resources { @@ -28,39 +19,26 @@ dependencyManagement { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" // Corda dependencies. - compile "net.corda:corda-core:$corda_release_version" - compile "net.corda:corda-jackson:$corda_release_version" - compile "net.corda:corda-rpc:$corda_release_version" - compile "net.corda:corda:$corda_release_version" - testCompile "net.corda:corda-node-driver:$corda_release_version" + implementation "net.corda:corda-core:$corda_release_version" + implementation "net.corda:corda-jackson:$corda_release_version" + implementation "net.corda:corda-rpc:$corda_release_version" - compile("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { + implementation("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { exclude group: "org.springframework.boot", module: "spring-boot-starter-logging" } - compile "org.springframework.boot:spring-boot-starter-log4j2:$spring_boot_version" - compile "org.apache.logging.log4j:log4j-web:$log4j_version" - - cordapp project(":workflows") - cordapp project(":contracts") + implementation "org.springframework.boot:spring-boot-starter-log4j2:$spring_boot_version" + implementation "org.apache.logging.log4j:log4j-web:$log4j_version" + implementation project(':workflows') + implementation project(':contracts') } -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { - kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" - javaParameters = true // Useful for reflection. - } -} - -task bootRun(type: JavaExec, dependsOn: jar) { +tasks.register('bootRun', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.carinsurance.server.ServerKt' args '--server.port=8080', '--config.rpc.host=localhost', '--config.rpc.port=10006', '--config.rpc.username=user1', '--config.rpc.password=test' diff --git a/Features/queryableState-carinsurance/clients/src/main/kotlin/net/corda/samples/carinsurance/server/MainController.kt b/Features/queryableState-carinsurance/clients/src/main/kotlin/net/corda/samples/carinsurance/server/MainController.kt index 8ff10fa5..dc2a8165 100755 --- a/Features/queryableState-carinsurance/clients/src/main/kotlin/net/corda/samples/carinsurance/server/MainController.kt +++ b/Features/queryableState-carinsurance/clients/src/main/kotlin/net/corda/samples/carinsurance/server/MainController.kt @@ -15,9 +15,6 @@ import org.springframework.http.MediaType.APPLICATION_JSON_VALUE import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* - -val SERVICE_NAMES = listOf("Notary", "Network Map Service") - /** * A Spring Boot Server API controller for interacting with the node via RPC. */ diff --git a/Features/queryableState-carinsurance/contracts/build.gradle b/Features/queryableState-carinsurance/contracts/build.gradle index e168f119..1739f0ff 100644 --- a/Features/queryableState-carinsurance/contracts/build.gradle +++ b/Features/queryableState-carinsurance/contracts/build.gradle @@ -1,5 +1,9 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'org.jetbrains.kotlin.plugin.jpa' + id 'org.jetbrains.kotlin.plugin.allopen' + id 'net.corda.plugins.cordapp' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -13,10 +17,10 @@ cordapp { } dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - compileOnly "$corda_release_group:corda-testserver-impl:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" + // Corda dependencies. + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Features/queryableState-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/contracts/InsuranceContract.kt b/Features/queryableState-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/contracts/InsuranceContract.kt index 0f3aa315..6efecf94 100644 --- a/Features/queryableState-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/contracts/InsuranceContract.kt +++ b/Features/queryableState-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/contracts/InsuranceContract.kt @@ -27,7 +27,7 @@ class InsuranceContract : Contract { "Transaction must have no input states." using (inputs.isEmpty()) } is Commands.AddClaim -> requireThat { - "Insurance transaction must have input states, the insurance police" using (!inputs.isEmpty()) + "Insurance transaction must have input states, the insurance police" using (inputs.isNotEmpty()) } } } diff --git a/Features/queryableState-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/schema/InsuranceSchemaV1.kt b/Features/queryableState-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/schema/InsuranceSchemaV1.kt index 9c7986a4..5cc201ad 100644 --- a/Features/queryableState-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/schema/InsuranceSchemaV1.kt +++ b/Features/queryableState-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/schema/InsuranceSchemaV1.kt @@ -1,13 +1,20 @@ package net.corda.samples.carinsurance.schema //4.6 changes -import jdk.nashorn.internal.objects.annotations.Constructor import net.corda.core.schemas.MappedSchema import net.corda.core.schemas.PersistentState import org.hibernate.annotations.Type import java.io.Serializable -import java.util.* -import javax.persistence.* +import javax.persistence.CascadeType +import javax.persistence.Column +import javax.persistence.Entity +import javax.persistence.Id +import javax.persistence.JoinColumn +import javax.persistence.JoinColumns +import javax.persistence.OneToMany +import javax.persistence.OneToOne +import javax.persistence.Table +import java.util.UUID /** * The family of schemas for IOUState. @@ -22,7 +29,7 @@ object InsuranceSchemaV1 : MappedSchema( version = 1, mappedTypes = listOf(PersistentClaim::class.java, PersistentInsurance::class.java, PersistentVehicle::class.java)) { - override val migrationResource: String? + override val migrationResource: String get() = "insurance.changelog-master"; @Entity diff --git a/Features/queryableState-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/states/InsuranceState.kt b/Features/queryableState-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/states/InsuranceState.kt index f9f36cfb..112adcbf 100644 --- a/Features/queryableState-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/states/InsuranceState.kt +++ b/Features/queryableState-carinsurance/contracts/src/main/kotlin/net/corda/samples/carinsurance/states/InsuranceState.kt @@ -8,9 +8,6 @@ import net.corda.core.schemas.PersistentState import net.corda.core.schemas.QueryableState import net.corda.samples.carinsurance.contracts.InsuranceContract import net.corda.samples.carinsurance.schema.InsuranceSchemaV1 -import java.util.* -import kotlin.collections.ArrayList - // ********* // * State * @@ -27,7 +24,6 @@ data class InsuranceState(val policyNumber: String, override val participants: List = listOf(insuree, insurer)) : QueryableState { override fun generateMappedObject(schema: MappedSchema): PersistentState { if (schema is InsuranceSchemaV1) { -// var persistentClaims = listOf() val persistentClaims : MutableList = mutableListOf() if (claims.isNotEmpty()) { for (item in claims) { @@ -38,7 +34,7 @@ data class InsuranceState(val policyNumber: String, } } - var vDetail = InsuranceSchemaV1.PersistentVehicle(vehicleDetail.registrationNumber, + val vDetail = InsuranceSchemaV1.PersistentVehicle(vehicleDetail.registrationNumber, vehicleDetail.chasisNumber, vehicleDetail.make, vehicleDetail.model, diff --git a/Features/queryableState-carinsurance/workflows/src/main/resources/migration/claim-detail.changelog-v1.xml b/Features/queryableState-carinsurance/contracts/src/main/resources/migration/claim-detail.changelog-v1.xml similarity index 100% rename from Features/queryableState-carinsurance/workflows/src/main/resources/migration/claim-detail.changelog-v1.xml rename to Features/queryableState-carinsurance/contracts/src/main/resources/migration/claim-detail.changelog-v1.xml diff --git a/Features/queryableState-carinsurance/workflows/src/main/resources/migration/insurance-detail.changelog-v1.xml b/Features/queryableState-carinsurance/contracts/src/main/resources/migration/insurance-detail.changelog-v1.xml similarity index 100% rename from Features/queryableState-carinsurance/workflows/src/main/resources/migration/insurance-detail.changelog-v1.xml rename to Features/queryableState-carinsurance/contracts/src/main/resources/migration/insurance-detail.changelog-v1.xml diff --git a/Features/queryableState-carinsurance/workflows/src/main/resources/migration/insurance.changelog-master.xml b/Features/queryableState-carinsurance/contracts/src/main/resources/migration/insurance.changelog-master.xml similarity index 100% rename from Features/queryableState-carinsurance/workflows/src/main/resources/migration/insurance.changelog-master.xml rename to Features/queryableState-carinsurance/contracts/src/main/resources/migration/insurance.changelog-master.xml diff --git a/Features/queryableState-carinsurance/workflows/src/main/resources/migration/vehicle-detail.changelog-v1.xml b/Features/queryableState-carinsurance/contracts/src/main/resources/migration/vehicle-detail.changelog-v1.xml similarity index 100% rename from Features/queryableState-carinsurance/workflows/src/main/resources/migration/vehicle-detail.changelog-v1.xml rename to Features/queryableState-carinsurance/contracts/src/main/resources/migration/vehicle-detail.changelog-v1.xml diff --git a/Features/queryableState-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/contracts/InsuranceContractTests.kt b/Features/queryableState-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/contracts/InsuranceContractTests.kt index 13b9e94e..0210ecdc 100644 --- a/Features/queryableState-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/contracts/InsuranceContractTests.kt +++ b/Features/queryableState-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/contracts/InsuranceContractTests.kt @@ -10,8 +10,8 @@ import net.corda.samples.carinsurance.states.VehicleDetail import net.corda.testing.core.TestIdentity import net.corda.testing.node.MockServices import net.corda.testing.node.ledger +import org.junit.Assert.assertTrue import org.junit.Test -import java.util.* class InsuranceContractTests { // A pre-defined dummy command. @@ -20,18 +20,18 @@ class InsuranceContractTests { } private val ledgerServices = MockServices( - Arrays.asList("net.corda.samples.carinsurance.contracts") + listOf("net.corda.samples.carinsurance.contracts") ) private val a = TestIdentity(CordaX500Name("Alice", "", "GB")) private val b = TestIdentity(CordaX500Name("Bob", "", "GB")) - var registrationNumber = "registration number: 2ds9Fvk" - var chassisNum = "chassis# aedl3sc" - var make = "Toyota" - var model = "Corolla" - var variant = "SE" - var color = "hot rod beige" - var fuelType = "regular" - var vd = VehicleDetail( + private val registrationNumber = "registration number: 2ds9Fvk" + private val chassisNum = "chassis# aedl3sc" + private val make = "Toyota" + private val model = "Corolla" + private val variant = "SE" + private val color = "hot rod beige" + private val fuelType = "regular" + private val vd = VehicleDetail( registrationNumber, chassisNum, make, @@ -39,19 +39,19 @@ class InsuranceContractTests { variant, color, fuelType) - var desc = "claim description: my car was hit by a blockchain" - var claimNumber = "B-132022" - var claimAmount = 3000 - var c = Claim(claimNumber, desc, claimAmount) + private val desc = "claim description: my car was hit by a blockchain" + private val claimNumber = "B-132022" + private val claimAmount = 3000 + private val c = Claim(claimNumber, desc, claimAmount) // in this test scenario, alice is our insurer. - var policyNum = "R3-Policy-A4byCd" - var insuredValue = 100000L - var duration = 50 - var premium = 5 - var insurer = a.party - var insuree = b.party - var st = InsuranceState( + private val policyNum = "R3-Policy-A4byCd" + private val insuredValue = 100000L + private val duration = 50 + private val premium = 5 + private val insurer = a.party + private val insuree = b.party + private val st = InsuranceState( policyNum, insuredValue, duration, @@ -59,11 +59,11 @@ class InsuranceContractTests { insurer, insuree, vd, - Arrays.asList(c)) + listOf(c)) @Test fun contractImplementsContract() { - assert(InsuranceContract() is Contract) + assertTrue(InsuranceContract() is Contract) } @Test @@ -72,15 +72,15 @@ class InsuranceContractTests { transaction { output(InsuranceContract.ID, st) // Has two commands, will fail. - command(Arrays.asList(a.publicKey, b.publicKey), InsuranceContract.Commands.IssueInsurance()) - command(Arrays.asList(a.publicKey, b.publicKey), InsuranceContract.Commands.IssueInsurance()) + command(listOf(a.publicKey, b.publicKey), InsuranceContract.Commands.IssueInsurance()) + command(listOf(a.publicKey, b.publicKey), InsuranceContract.Commands.IssueInsurance()) fails() } transaction { output(InsuranceContract.ID, st) // Has one command, will verify. - command(Arrays.asList(a.publicKey, b.publicKey), InsuranceContract.Commands.IssueInsurance()) + command(listOf(a.publicKey, b.publicKey), InsuranceContract.Commands.IssueInsurance()) verifies() } } @@ -92,14 +92,14 @@ class InsuranceContractTests { transaction { // Has wrong command type, will fail. output(InsuranceContract.ID, st) - command(Arrays.asList(a.publicKey), Commands.DummyCommand()) + command(listOf(a.publicKey), Commands.DummyCommand()) fails() } transaction { // Has correct command type, will verify. output(InsuranceContract.ID, st) - command(Arrays.asList(a.publicKey, b.publicKey), InsuranceContract.Commands.IssueInsurance()) + command(listOf(a.publicKey, b.publicKey), InsuranceContract.Commands.IssueInsurance()) verifies() } } diff --git a/Features/queryableState-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/ClaimTests.kt b/Features/queryableState-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/ClaimTests.kt index a6d1333f..d36396ea 100644 --- a/Features/queryableState-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/ClaimTests.kt +++ b/Features/queryableState-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/ClaimTests.kt @@ -1,6 +1,6 @@ package net.corda.samples.carinsurance.states -import org.junit.Assert +import org.junit.Assert.assertEquals import org.junit.Test class ClaimTests { @@ -11,8 +11,8 @@ class ClaimTests { @Test fun constructorTest() { val (claimNumber1, claimDescription, claimAmount1) = Claim(claimNumber, desc, claimAmount) - Assert.assertEquals(claimNumber, claimNumber1) - Assert.assertEquals(desc, claimDescription) - Assert.assertEquals(claimAmount.toLong(), claimAmount1.toLong()) + assertEquals(claimNumber, claimNumber1) + assertEquals(desc, claimDescription) + assertEquals(claimAmount.toLong(), claimAmount1.toLong()) } } diff --git a/Features/queryableState-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/InsuranceStateTests.kt b/Features/queryableState-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/InsuranceStateTests.kt index 329db9f6..0ec3497c 100644 --- a/Features/queryableState-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/InsuranceStateTests.kt +++ b/Features/queryableState-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/InsuranceStateTests.kt @@ -2,14 +2,14 @@ package net.corda.samples.carinsurance.states import net.corda.core.identity.CordaX500Name import net.corda.testing.core.TestIdentity -import org.jgroups.util.Util +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Test -import java.util.* class InsuranceStateTests { - var a = TestIdentity(CordaX500Name("Alice", "", "GB")) - var b = TestIdentity(CordaX500Name("Bob", "", "GB")) + private val a = TestIdentity(CordaX500Name("Alice", "", "GB")) + private val b = TestIdentity(CordaX500Name("Bob", "", "GB")) @Test fun constructorTest() { @@ -48,16 +48,16 @@ class InsuranceStateTests { insurer, insuree, vd, - Arrays.asList(c)) + listOf(c)) - Util.assertEquals(policyNum, policyNumber) - Util.assertEquals(insuredValue, insuredValue1) - Util.assertEquals(duration, duration1) - Util.assertEquals(premium, premium1) - Util.assertEquals(insurer, insurer1) - Util.assertEquals(insuree, insuree1) - Util.assertEquals(vd, vehicleDetail) - Util.assertTrue(participants.contains(a.party)) - Util.assertTrue(participants.contains(b.party)) + assertEquals(policyNum, policyNumber) + assertEquals(insuredValue, insuredValue1) + assertEquals(duration, duration1) + assertEquals(premium, premium1) + assertEquals(insurer, insurer1) + assertEquals(insuree, insuree1) + assertEquals(vd, vehicleDetail) + assertTrue(participants.contains(a.party)) + assertTrue(participants.contains(b.party)) } } diff --git a/Features/queryableState-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/VehicleDetailTests.kt b/Features/queryableState-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/VehicleDetailTests.kt index 33755365..9248f0c0 100644 --- a/Features/queryableState-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/VehicleDetailTests.kt +++ b/Features/queryableState-carinsurance/contracts/src/test/kotlin/net/corda/samples/carinsurance/states/VehicleDetailTests.kt @@ -1,15 +1,9 @@ package net.corda.samples.carinsurance.states -import net.corda.core.identity.CordaX500Name -import net.corda.testing.core.TestIdentity -import org.jgroups.util.Util +import org.junit.Assert.assertEquals import org.junit.Test class VehicleDetailTests { - - var a = TestIdentity(CordaX500Name("Alice", "", "GB")) - var b = TestIdentity(CordaX500Name("Bob", "", "GB")) - @Test fun constructorTest() { val registrationNumber = "registration number: 2ds9Fvk" @@ -29,12 +23,12 @@ class VehicleDetailTests { color, fuelType) - Util.assertEquals(registrationNumber, registrationNumber1) - Util.assertEquals(chassisNum, chasisNumber) - Util.assertEquals(make, make1) - Util.assertEquals(model, model1) - Util.assertEquals(variant, variant1) - Util.assertEquals(color, color1) - Util.assertEquals(fuelType, fuelType1) + assertEquals(registrationNumber, registrationNumber1) + assertEquals(chassisNum, chasisNumber) + assertEquals(make, make1) + assertEquals(model, model1) + assertEquals(variant, variant1) + assertEquals(color, color1) + assertEquals(fuelType, fuelType1) } } diff --git a/Features/queryableState-carinsurance/gradle.properties b/Features/queryableState-carinsurance/gradle.properties index 0f727ec3..2403194e 100644 --- a/Features/queryableState-carinsurance/gradle.properties +++ b/Features/queryableState-carinsurance/gradle.properties @@ -1,4 +1,27 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Queryablestate Car Insurance group=com.carinsurance version=0.1 -kotlin.incremental=false + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE +spring_dependency_management_version=1.0.11.RELEASE diff --git a/Features/queryableState-carinsurance/gradle/wrapper/gradle-wrapper.jar b/Features/queryableState-carinsurance/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Features/queryableState-carinsurance/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Features/queryableState-carinsurance/gradle/wrapper/gradle-wrapper.properties b/Features/queryableState-carinsurance/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Features/queryableState-carinsurance/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Features/queryableState-carinsurance/gradlew b/Features/queryableState-carinsurance/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Features/queryableState-carinsurance/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Features/queryableState-carinsurance/gradlew.bat b/Features/queryableState-carinsurance/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Features/queryableState-carinsurance/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Features/queryableState-carinsurance/repositories.gradle b/Features/queryableState-carinsurance/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Features/queryableState-carinsurance/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Features/queryableState-carinsurance/settings.gradle b/Features/queryableState-carinsurance/settings.gradle index 2514aca2..e51ba7b5 100644 --- a/Features/queryableState-carinsurance/settings.gradle +++ b/Features/queryableState-carinsurance/settings.gradle @@ -1,3 +1,39 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.jetbrains.kotlin.plugin.allopen' version kotlin_plugin_version + id 'org.jetbrains.kotlin.plugin.jpa' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + id 'io.spring.dependency-management' version spring_dependency_management_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file +include 'clients' diff --git a/Features/queryableState-carinsurance/workflows/build.gradle b/Features/queryableState-carinsurance/workflows/build.gradle index 9bd73035..1f054552 100644 --- a/Features/queryableState-carinsurance/workflows/build.gradle +++ b/Features/queryableState-carinsurance/workflows/build.gradle @@ -1,10 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "Queryablestate Car Insurance" vendor "Corda Open Source" @@ -14,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -35,25 +32,23 @@ sourceSets { configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - compileOnly "$corda_release_group:corda-testserver-impl:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } - -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath } diff --git a/Features/queryableState-carinsurance/workflows/src/integrationTest/kotlin/net/corda/samples/carinsurance/DriverBasedTest.kt b/Features/queryableState-carinsurance/workflows/src/integrationTest/kotlin/net/corda/samples/carinsurance/DriverBasedTest.kt index 19a77d22..49148c76 100644 --- a/Features/queryableState-carinsurance/workflows/src/integrationTest/kotlin/net/corda/samples/carinsurance/DriverBasedTest.kt +++ b/Features/queryableState-carinsurance/workflows/src/integrationTest/kotlin/net/corda/samples/carinsurance/DriverBasedTest.kt @@ -7,9 +7,9 @@ import net.corda.testing.driver.DriverDSL import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.driver +import org.junit.Assert.assertEquals import org.junit.Test import java.util.concurrent.Future -import kotlin.test.assertEquals class DriverBasedTest { private val bankA = TestIdentity(CordaX500Name("BankA", "", "GB")) diff --git a/Features/queryableState-carinsurance/workflows/src/main/kotlin/net/corda/samples/carinsurance/flows/InsuranceClaim.kt b/Features/queryableState-carinsurance/workflows/src/main/kotlin/net/corda/samples/carinsurance/flows/InsuranceClaim.kt index b7d3bf4b..b1168f4a 100644 --- a/Features/queryableState-carinsurance/workflows/src/main/kotlin/net/corda/samples/carinsurance/flows/InsuranceClaim.kt +++ b/Features/queryableState-carinsurance/workflows/src/main/kotlin/net/corda/samples/carinsurance/flows/InsuranceClaim.kt @@ -26,12 +26,12 @@ class InsuranceClaim(val claimInfo: ClaimInfo, // to fetch the desired Insurance state from the vault. This filtered state would be used as input to the // transaction. val insuranceStateAndRefs = serviceHub.vaultService.queryBy().states - val inputStateAndRef = insuranceStateAndRefs.filter { it.state.data.policyNumber.equals(policyNumber) }[0] + val inputStateAndRef = insuranceStateAndRefs.filter { it.state.data.policyNumber == policyNumber }[0] //compose claim val claim = Claim(claimInfo.claimNumber, claimInfo.claimDescription, claimInfo.claimAmount) val input = inputStateAndRef.state.data - var claimlist = ArrayList() + val claimlist = ArrayList() claimlist.add(claim) for (item in input.claims) { claimlist.add(item) diff --git a/Features/queryableState-carinsurance/workflows/src/main/kotlin/net/corda/samples/carinsurance/flows/IssueInsurance.kt b/Features/queryableState-carinsurance/workflows/src/main/kotlin/net/corda/samples/carinsurance/flows/IssueInsurance.kt index 13c8052c..f8b42cfc 100644 --- a/Features/queryableState-carinsurance/workflows/src/main/kotlin/net/corda/samples/carinsurance/flows/IssueInsurance.kt +++ b/Features/queryableState-carinsurance/workflows/src/main/kotlin/net/corda/samples/carinsurance/flows/IssueInsurance.kt @@ -12,7 +12,6 @@ import net.corda.samples.carinsurance.contracts.InsuranceContract import net.corda.samples.carinsurance.states.InsuranceState import net.corda.samples.carinsurance.states.VehicleDetail - // ********* // * Flows * // ********* diff --git a/Features/queryableState-carinsurance/workflows/src/test/kotlin/net/corda/samples/carinsurance/flows/FlowTests.kt b/Features/queryableState-carinsurance/workflows/src/test/kotlin/net/corda/samples/carinsurance/flows/FlowTests.kt index bea17e20..c4b845f3 100644 --- a/Features/queryableState-carinsurance/workflows/src/test/kotlin/net/corda/samples/carinsurance/flows/FlowTests.kt +++ b/Features/queryableState-carinsurance/workflows/src/test/kotlin/net/corda/samples/carinsurance/flows/FlowTests.kt @@ -8,7 +8,7 @@ import net.corda.testing.node.MockNetworkNotarySpec import net.corda.testing.node.MockNetworkParameters import net.corda.testing.node.TestCordapp import org.junit.After -import org.junit.Assert +import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test @@ -59,6 +59,6 @@ class FlowTests { val ptx = future.get() //assertion for single output - Assert.assertEquals(1, ptx.tx.outputStates.size.toLong()) + assertEquals(1, ptx.tx.outputStates.size.toLong()) } } diff --git a/Features/referenceStates-sanctionsBody/README.md b/Features/referenceStates-sanctionsBody/README.md index c47d8b20..b4a23e22 100644 --- a/Features/referenceStates-sanctionsBody/README.md +++ b/Features/referenceStates-sanctionsBody/README.md @@ -14,7 +14,7 @@ For development environment setup, please refer to: [Setup Guide](https://docs.c Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) ``` diff --git a/Features/referenceStates-sanctionsBody/build.gradle b/Features/referenceStates-sanctionsBody/build.gradle index d9cd4a63..6e60682f 100644 --- a/Features/referenceStates-sanctionsBody/build.gradle +++ b/Features/referenceStates-sanctionsBody/build.gradle @@ -1,103 +1,70 @@ -buildscript { - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - } - - repositories { - mavenCentral() - - maven { - url 'https://software.r3.com/artifactory/corda-releases' - } - mavenLocal() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':workflows') + cordapp project(':contracts') - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = false - } - cordapp project(":contracts") - cordapp project(":workflows") - rpcUsers = [['username': "user1", 'password': "test", 'permissions': [ 'ALL' ]]] - runSchemaMigration = true + cordapp project(':contracts') + cordapp project(':workflows') + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { @@ -108,6 +75,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10001") adminAddress("localhost:10002") } + rpcUsers = [] } node { name "O=SanctionsBody,L=London,C=GB" diff --git a/Features/referenceStates-sanctionsBody/contracts/build.gradle b/Features/referenceStates-sanctionsBody/contracts/build.gradle index ede5b328..c57eb77f 100644 --- a/Features/referenceStates-sanctionsBody/contracts/build.gradle +++ b/Features/referenceStates-sanctionsBody/contracts/build.gradle @@ -1,5 +1,7 @@ -apply plugin: 'kotlin' -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -12,34 +14,11 @@ cordapp { } } -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } - test { - resources { - srcDir rootProject.file("config/test") - } - } - integrationTest { - kotlin { - compileClasspath += main.output + test.output - runtimeClasspath += main.output + test.output - srcDir file('src/integrationTest/kotlin') - } - } -} - - dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Features/referenceStates-sanctionsBody/contracts/src/main/kotlin/net/corda/samples/referencestates/contracts/SanctionableIOUContract.kt b/Features/referenceStates-sanctionsBody/contracts/src/main/kotlin/net/corda/samples/referencestates/contracts/SanctionableIOUContract.kt index e2514555..ebec0636 100644 --- a/Features/referenceStates-sanctionsBody/contracts/src/main/kotlin/net/corda/samples/referencestates/contracts/SanctionableIOUContract.kt +++ b/Features/referenceStates-sanctionsBody/contracts/src/main/kotlin/net/corda/samples/referencestates/contracts/SanctionableIOUContract.kt @@ -23,8 +23,7 @@ import net.corda.core.transactions.LedgerTransaction */ class SanctionableIOUContract : Contract { companion object { - @JvmStatic - val IOU_CONTRACT_ID = "net.corda.samples.referencestates.contracts.SanctionableIOUContract" + const val IOU_CONTRACT_ID = "net.corda.samples.referencestates.contracts.SanctionableIOUContract" } /** @@ -35,11 +34,11 @@ class SanctionableIOUContract : Contract { val command = tx.commands.requireSingleCommand() - require(tx.referenceInputRefsOfType(SanctionedEntities::class.java).singleOrNull() != null) { + require(tx.referenceInputRefsOfType().singleOrNull() != null) { "All transactions require a list of sanctioned entities" } - val sanctionedEntities = tx.referenceInputRefsOfType(SanctionedEntities::class.java).single().state.data + val sanctionedEntities = tx.referenceInputRefsOfType().single().state.data require(sanctionedEntities.issuer.name == command.value.sanctionsBody.name) { "${sanctionedEntities.issuer.name.organisation} is an invalid issuer of sanctions lists for this contracts" } diff --git a/Features/referenceStates-sanctionsBody/contracts/src/main/kotlin/net/corda/samples/referencestates/contracts/SanctionedEntitiesContract.kt b/Features/referenceStates-sanctionsBody/contracts/src/main/kotlin/net/corda/samples/referencestates/contracts/SanctionedEntitiesContract.kt index fa1cea33..aa49f13c 100644 --- a/Features/referenceStates-sanctionsBody/contracts/src/main/kotlin/net/corda/samples/referencestates/contracts/SanctionedEntitiesContract.kt +++ b/Features/referenceStates-sanctionsBody/contracts/src/main/kotlin/net/corda/samples/referencestates/contracts/SanctionedEntitiesContract.kt @@ -8,8 +8,7 @@ import net.corda.core.transactions.LedgerTransaction class SanctionedEntitiesContract : Contract { companion object { - @JvmStatic - val SANCTIONS_CONTRACT_ID = "net.corda.samples.referencestates.contracts.SanctionedEntitiesContract" + const val SANCTIONS_CONTRACT_ID = "net.corda.samples.referencestates.contracts.SanctionedEntitiesContract" } /** @@ -17,22 +16,20 @@ class SanctionedEntitiesContract : Contract { * considered valid. */ override fun verify(tx: LedgerTransaction) { - val command = tx.commandsOfType(Commands::class.java).single() + val command = tx.commandsOfType().single() if (command.value is Commands.Create) { requireThat { "when creating a sanctions list there should be no inputs" using (tx.inputStates.isEmpty()) - "when creating a sanctions list there should be one output" using (tx.outputsOfType(SanctionedEntities::class.java).size == 1) + "when creating a sanctions list there should be one output" using (tx.outputsOfType().size == 1) val out = tx.outputsOfType(SanctionedEntities::class.java).single() "The issuer of the sanctions list must sign" using (out.issuer.owningKey in command.signers) } } else if (command.value is Commands.Update) { requireThat { - "There must be exactly one input Sanctions List when updating" using (tx.inputsOfType(SanctionedEntities::class.java).size == 1) - "There must be exactly one output Sanctions List when updating" using (tx.outputsOfType( - SanctionedEntities::class.java - ).size == 1) + "There must be exactly one input Sanctions List when updating" using (tx.inputsOfType().size == 1) + "There must be exactly one output Sanctions List when updating" using (tx.outputsOfType().size == 1) val input = tx.inputsOfType().single() val output = tx.outputsOfType().single() "The issuer must remain the same across an update" using (input.issuer == output.issuer) diff --git a/Features/referenceStates-sanctionsBody/contracts/src/test/kotlin/net/corda/samples/referencestates/contracts/IOUContractTests.kt b/Features/referenceStates-sanctionsBody/contracts/src/test/kotlin/net/corda/samples/referencestates/contracts/IOUContractTests.kt index 0ee15da3..a19a1d42 100644 --- a/Features/referenceStates-sanctionsBody/contracts/src/test/kotlin/net/corda/samples/referencestates/contracts/IOUContractTests.kt +++ b/Features/referenceStates-sanctionsBody/contracts/src/test/kotlin/net/corda/samples/referencestates/contracts/IOUContractTests.kt @@ -14,7 +14,7 @@ import net.corda.testing.node.ledger import org.junit.Test class IOUContractTests { - val DUMMY_NOTARY = TestIdentity(DUMMY_NOTARY_NAME, 20).party + private val DUMMY_NOTARY = TestIdentity(DUMMY_NOTARY_NAME, 20).party private val issuer = TestIdentity(CordaX500Name("SanctionsIssuer", "London", "GB")) private val megaCorp = TestIdentity(CordaX500Name("MegaCorp", "London", "GB")) diff --git a/Features/referenceStates-sanctionsBody/contracts/src/test/kotlin/net/corda/samples/referencestates/states/SanctionableIOUStateTests.kt b/Features/referenceStates-sanctionsBody/contracts/src/test/kotlin/net/corda/samples/referencestates/states/SanctionableIOUStateTests.kt index 98c3a264..1cdace1d 100644 --- a/Features/referenceStates-sanctionsBody/contracts/src/test/kotlin/net/corda/samples/referencestates/states/SanctionableIOUStateTests.kt +++ b/Features/referenceStates-sanctionsBody/contracts/src/test/kotlin/net/corda/samples/referencestates/states/SanctionableIOUStateTests.kt @@ -5,12 +5,13 @@ import net.corda.core.contracts.LinearState import net.corda.core.contracts.UniqueIdentifier import net.corda.core.identity.CordaX500Name import net.corda.testing.core.TestIdentity -import org.jgroups.util.Util +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Test class SanctionableIOUStateTests { - var a = TestIdentity(CordaX500Name("Alice", "", "GB")) - var b = TestIdentity(CordaX500Name("Bob", "", "GB")) + private val a = TestIdentity(CordaX500Name("Alice", "", "GB")) + private val b = TestIdentity(CordaX500Name("Bob", "", "GB")) @Test fun constructorTest() { @@ -19,13 +20,13 @@ class SanctionableIOUStateTests { val borrower = b.party val uid = UniqueIdentifier() val st = SanctionableIOUState(value, lender, borrower, uid) - Util.assertTrue(st is ContractState) - Util.assertTrue(st is LinearState) - Util.assertEquals(value, st.value) - Util.assertEquals(lender, st.lender) - Util.assertEquals(borrower, st.borrower) - Util.assertEquals(uid, st.linearId) - Util.assertTrue(st.participants.contains(a.party)) - Util.assertTrue(st.participants.contains(b.party)) + assertTrue(st is ContractState) + assertTrue(st is LinearState) + assertEquals(value, st.value) + assertEquals(lender, st.lender) + assertEquals(borrower, st.borrower) + assertEquals(uid, st.linearId) + assertTrue(st.participants.contains(a.party)) + assertTrue(st.participants.contains(b.party)) } } diff --git a/Features/referenceStates-sanctionsBody/contracts/src/test/kotlin/net/corda/samples/referencestates/states/SanctionedEntitiesTests.kt b/Features/referenceStates-sanctionsBody/contracts/src/test/kotlin/net/corda/samples/referencestates/states/SanctionedEntitiesTests.kt index 64271ef1..a9ff54d6 100644 --- a/Features/referenceStates-sanctionsBody/contracts/src/test/kotlin/net/corda/samples/referencestates/states/SanctionedEntitiesTests.kt +++ b/Features/referenceStates-sanctionsBody/contracts/src/test/kotlin/net/corda/samples/referencestates/states/SanctionedEntitiesTests.kt @@ -4,27 +4,28 @@ import net.corda.core.contracts.ContractState import net.corda.core.contracts.LinearState import net.corda.core.identity.CordaX500Name import net.corda.testing.core.TestIdentity -import org.jgroups.util.Util +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue import org.junit.Test -import java.util.* class SanctionedEntitiesTests { - var a = TestIdentity(CordaX500Name("Alice", "", "GB")) - var b = TestIdentity(CordaX500Name("Bob", "", "GB")) - var c = TestIdentity(CordaX500Name("Charlie", "", "GB")) + private val a = TestIdentity(CordaX500Name("Alice", "", "GB")) + private val b = TestIdentity(CordaX500Name("Bob", "", "GB")) + private val c = TestIdentity(CordaX500Name("Charlie", "", "GB")) @Test fun constructorTest() { - val badPeople = Arrays.asList(a.party) + val badPeople = listOf(a.party) val issuer = b.party val st = SanctionedEntities(badPeople, b.party) - Util.assertTrue(st is ContractState) - Util.assertTrue(st is LinearState) - Util.assertEquals(badPeople, st.badPeople) - Util.assertEquals(issuer, st.issuer) - Util.assertTrue(st.participants.contains(b.party)) - Util.assertFalse(st.participants.contains(a.party)) - Util.assertFalse(st.participants.contains(c.party)) + assertTrue(st is ContractState) + assertTrue(st is LinearState) + assertEquals(badPeople, st.badPeople) + assertEquals(issuer, st.issuer) + assertTrue(st.participants.contains(b.party)) + assertFalse(st.participants.contains(a.party)) + assertFalse(st.participants.contains(c.party)) } } diff --git a/Features/referenceStates-sanctionsBody/gradle.properties b/Features/referenceStates-sanctionsBody/gradle.properties index 50f1d5c2..3e67ecce 100644 --- a/Features/referenceStates-sanctionsBody/gradle.properties +++ b/Features/referenceStates-sanctionsBody/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Reference States SanctionsBody group=com.referencestates version=0.1 -kotlin.incremental=false + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Features/referenceStates-sanctionsBody/gradle/wrapper/gradle-wrapper.jar b/Features/referenceStates-sanctionsBody/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7a3265ee..00000000 Binary files a/Features/referenceStates-sanctionsBody/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Features/referenceStates-sanctionsBody/gradle/wrapper/gradle-wrapper.properties b/Features/referenceStates-sanctionsBody/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 674bdda0..00000000 --- a/Features/referenceStates-sanctionsBody/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Features/referenceStates-sanctionsBody/gradlew b/Features/referenceStates-sanctionsBody/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Features/referenceStates-sanctionsBody/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Features/referenceStates-sanctionsBody/gradlew.bat b/Features/referenceStates-sanctionsBody/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Features/referenceStates-sanctionsBody/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Features/referenceStates-sanctionsBody/lib/README.txt b/Features/referenceStates-sanctionsBody/lib/README.txt deleted file mode 100644 index b0592c95..00000000 --- a/Features/referenceStates-sanctionsBody/lib/README.txt +++ /dev/null @@ -1,8 +0,0 @@ -The Quasar.jar in this directory is for runtime instrumentation of classes by Quasar. - -When running corda outside of the given gradle building you must add the following flag with the -correct path to your call to Java: - - java -javaagent:path-to-quasar-jar.jar ... - -See the Quasar docs for more information: http://docs.paralleluniverse.co/quasar/ \ No newline at end of file diff --git a/Features/referenceStates-sanctionsBody/lib/quasar.jar b/Features/referenceStates-sanctionsBody/lib/quasar.jar deleted file mode 100644 index 7282d8c8..00000000 Binary files a/Features/referenceStates-sanctionsBody/lib/quasar.jar and /dev/null differ diff --git a/Features/referenceStates-sanctionsBody/repositories.gradle b/Features/referenceStates-sanctionsBody/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Features/referenceStates-sanctionsBody/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Features/referenceStates-sanctionsBody/settings.gradle b/Features/referenceStates-sanctionsBody/settings.gradle index c46db016..061c6655 100644 --- a/Features/referenceStates-sanctionsBody/settings.gradle +++ b/Features/referenceStates-sanctionsBody/settings.gradle @@ -1,2 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'contracts' include 'workflows' diff --git a/Features/referenceStates-sanctionsBody/workflows/build.gradle b/Features/referenceStates-sanctionsBody/workflows/build.gradle index 636fe587..dc927ebd 100644 --- a/Features/referenceStates-sanctionsBody/workflows/build.gradle +++ b/Features/referenceStates-sanctionsBody/workflows/build.gradle @@ -1,7 +1,8 @@ -apply plugin: 'kotlin' -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' -apply plugin: 'net.corda.plugins.cordformation' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -24,35 +25,29 @@ sourceSets { kotlin { compileClasspath += main.output + test.output runtimeClasspath += main.output + test.output - srcDir file('src/integration-test/kotlin') + srcDir file('src/integrationTest/kotlin') } } } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaCompile "$corda_release_group:corda-jackson:$corda_release_version" - cordaCompile "$corda_release_group:corda-rpc:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - - testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath } diff --git a/Features/referenceStates-sanctionsBody/workflows/src/main/kotlin/net/corda/samples/referencestates/flows/GetSanctionsListFlow.kt b/Features/referenceStates-sanctionsBody/workflows/src/main/kotlin/net/corda/samples/referencestates/flows/GetSanctionsListFlow.kt index e79b189e..9b874428 100644 --- a/Features/referenceStates-sanctionsBody/workflows/src/main/kotlin/net/corda/samples/referencestates/flows/GetSanctionsListFlow.kt +++ b/Features/referenceStates-sanctionsBody/workflows/src/main/kotlin/net/corda/samples/referencestates/flows/GetSanctionsListFlow.kt @@ -22,7 +22,7 @@ import net.corda.core.utilities.unwrap * All methods called within the [FlowLogic] sub-class need to be annotated with the @Suspendable annotation. */ object GetSanctionsListFlow { - private val YES = "YES" + private const val YES = "YES" @InitiatingFlow @StartableByRPC diff --git a/Features/referenceStates-sanctionsBody/workflows/src/main/kotlin/net/corda/samples/referencestates/flows/IOUIssueFlow.kt b/Features/referenceStates-sanctionsBody/workflows/src/main/kotlin/net/corda/samples/referencestates/flows/IOUIssueFlow.kt index da381dd0..e477ae88 100644 --- a/Features/referenceStates-sanctionsBody/workflows/src/main/kotlin/net/corda/samples/referencestates/flows/IOUIssueFlow.kt +++ b/Features/referenceStates-sanctionsBody/workflows/src/main/kotlin/net/corda/samples/referencestates/flows/IOUIssueFlow.kt @@ -130,7 +130,7 @@ object IOUIssueFlow { @Suspendable fun getSanctionsList(sanctionsBody: Party): StateAndRef? { return serviceHub.vaultService.queryBy(SanctionedEntities::class.java) - .states.filter { it.state.data.issuer == sanctionsBody }.singleOrNull() + .states.singleOrNull { it.state.data.issuer == sanctionsBody } } @Suspendable @@ -153,14 +153,13 @@ object IOUIssueFlow { } val txId = subFlow(signTransactionFlow).id - val recordedTx = subFlow( + return subFlow( ReceiveFinalityFlow( otherPartySession, expectedTxId = txId, statesToRecord = StatesToRecord.ALL_VISIBLE ) ) - return recordedTx } } diff --git a/Features/referenceStates-sanctionsBody/workflows/src/test/kotlin/net/corda/samples/referencestates/flows/IOUFlowTests.kt b/Features/referenceStates-sanctionsBody/workflows/src/test/kotlin/net/corda/samples/referencestates/flows/IOUFlowTests.kt index c3fb9aa1..a710f085 100644 --- a/Features/referenceStates-sanctionsBody/workflows/src/test/kotlin/net/corda/samples/referencestates/flows/IOUFlowTests.kt +++ b/Features/referenceStates-sanctionsBody/workflows/src/test/kotlin/net/corda/samples/referencestates/flows/IOUFlowTests.kt @@ -20,12 +20,12 @@ import java.time.Duration import java.time.temporal.ChronoUnit class IOUFlowTests { - lateinit var network: MockNetwork - lateinit var a: StartedMockNode - lateinit var b: StartedMockNode - lateinit var c: StartedMockNode - lateinit var issuer: StartedMockNode - lateinit var issuerParty: Party + private lateinit var network: MockNetwork + private lateinit var a: StartedMockNode + private lateinit var b: StartedMockNode + private lateinit var c: StartedMockNode + private lateinit var issuer: StartedMockNode + private lateinit var issuerParty: Party @Before fun setup() { @@ -50,7 +50,9 @@ class IOUFlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test(expected = TransactionVerificationException.ContractRejection::class) @@ -81,7 +83,6 @@ class IOUFlowTests { signedTx.verifySignaturesExcept(b.info.singleIdentity().owningKey) println("@@@@@@@@@@${a.services.vaultService.queryBy(SanctionedEntities::class.java).states.firstOrNull()}") - } @Test(expected = TransactionVerificationException.ContractRejection::class) @@ -161,7 +162,6 @@ class IOUFlowTests { network.runNetwork() dealFuture3.getOrThrow() - } private fun getSanctionsList(node: StartedMockNode, issuerOfSanctions: Party) { @@ -215,6 +215,5 @@ class IOUFlowTests { network.runNetwork() dealFuture4.getOrThrow(timeout = Duration.of(30, ChronoUnit.MINUTES)) - } } diff --git a/Features/referenceStates-sanctionsBody/workflows/src/test/kotlin/net/corda/samples/referencestates/flows/SanctionsFlowTests.kt b/Features/referenceStates-sanctionsBody/workflows/src/test/kotlin/net/corda/samples/referencestates/flows/SanctionsFlowTests.kt index 8ed0234a..bea8b95d 100644 --- a/Features/referenceStates-sanctionsBody/workflows/src/test/kotlin/net/corda/samples/referencestates/flows/SanctionsFlowTests.kt +++ b/Features/referenceStates-sanctionsBody/workflows/src/test/kotlin/net/corda/samples/referencestates/flows/SanctionsFlowTests.kt @@ -3,16 +3,16 @@ package net.corda.samples.referencestates.flows import net.corda.core.identity.CordaX500Name import net.corda.testing.node.* import org.junit.After +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test -import kotlin.test.assertEquals -import kotlin.test.assertTrue class SanctionsFlowTests { - lateinit var network: MockNetwork - lateinit var a: StartedMockNode - lateinit var b: StartedMockNode - lateinit var c: StartedMockNode + private lateinit var network: MockNetwork + private lateinit var a: StartedMockNode + private lateinit var b: StartedMockNode + private lateinit var c: StartedMockNode @Before fun setup() { @@ -32,7 +32,9 @@ class SanctionsFlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test @@ -57,7 +59,6 @@ class SanctionsFlowTests { network.runNetwork() assertEquals(issueListFuture.get().state.data, getListFuture.get().single().state.data) - } @@ -77,9 +78,9 @@ class SanctionsFlowTests { val updateListFuture = a.startFlow(updateFlow) network.runNetwork() - assertTrue { + assertTrue( c.info.legalIdentities.first() in updateListFuture.get().state.data.badPeople - } + ) val getUpdatedListFlow = GetSanctionsListFlow.Initiator(a.info.legalIdentities.first()) val getUpdatedListFuture = b.startFlow(getUpdatedListFlow) diff --git a/Features/schedulableState-heartbeat/README.md b/Features/schedulableState-heartbeat/README.md index 43f06840..62e23b00 100644 --- a/Features/schedulableState-heartbeat/README.md +++ b/Features/schedulableState-heartbeat/README.md @@ -28,7 +28,7 @@ For development environment setup, please refer to: [Setup Guide](https://docs.c Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) ``` diff --git a/Features/schedulableState-heartbeat/build.gradle b/Features/schedulableState-heartbeat/build.gradle index 3615d17a..5b4d2b0f 100644 --- a/Features/schedulableState-heartbeat/build.gradle +++ b/Features/schedulableState-heartbeat/build.gradle @@ -1,103 +1,67 @@ -buildscript { - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':workflows') + cordapp project(':contracts') - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = false - } - - cordapp project("contracts") - cordapp project("workflows") - - runSchemaMigration = true + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { @@ -108,7 +72,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } - cordapps = [] } node { @@ -118,7 +81,8 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - cordapps = [] rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] + cordapp project(':contracts') + cordapp project(':workflows') } } diff --git a/Features/schedulableState-heartbeat/contracts/build.gradle b/Features/schedulableState-heartbeat/contracts/build.gradle index 6fa5d151..360f6ca8 100644 --- a/Features/schedulableState-heartbeat/contracts/build.gradle +++ b/Features/schedulableState-heartbeat/contracts/build.gradle @@ -1,7 +1,7 @@ -apply plugin: 'kotlin' -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -15,31 +15,10 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_release_group:corda-core:$corda_release_version" - cordaCompile "$corda_release_group:corda-jackson:$corda_release_version" - cordaCompile "$corda_release_group:corda-rpc:$corda_release_version" - cordaCompile "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" - cordaRuntime "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" -} - -jar { - // CorDapps do not configure a Node's logging. - exclude '**/log4j2*.xml' -} - -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { - kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" - javaParameters = true // Useful for reflection. - } + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Features/schedulableState-heartbeat/contracts/src/main/resources/log4j2-test.xml b/Features/schedulableState-heartbeat/contracts/src/main/resources/log4j2-test.xml deleted file mode 100644 index c22d8edd..00000000 --- a/Features/schedulableState-heartbeat/contracts/src/main/resources/log4j2-test.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - build/logs - com.heartbeat-${hostName} - - - - - - - [%-5level] %d{HH:mm:ss.SSS} [%t] %c{1}.%M - %msg%n - > - - - - - - - - - - - - - - - - - diff --git a/Features/schedulableState-heartbeat/contracts/src/test/kotlin/net/corda/samples/heartbeat/contracts/HeartContractTests.kt b/Features/schedulableState-heartbeat/contracts/src/test/kotlin/net/corda/samples/heartbeat/contracts/HeartContractTests.kt index 1d545e34..dd43d414 100644 --- a/Features/schedulableState-heartbeat/contracts/src/test/kotlin/net/corda/samples/heartbeat/contracts/HeartContractTests.kt +++ b/Features/schedulableState-heartbeat/contracts/src/test/kotlin/net/corda/samples/heartbeat/contracts/HeartContractTests.kt @@ -6,21 +6,20 @@ import net.corda.samples.heartbeat.states.HeartState import net.corda.testing.core.TestIdentity import net.corda.testing.node.MockServices import net.corda.testing.node.ledger +import org.junit.Assert.assertTrue import org.junit.Test -import java.util.* class HeartContractTests { private val a = TestIdentity(CordaX500Name("Alice", "", "GB")) - private val b = TestIdentity(CordaX500Name("Bob", "", "GB")) private val ledgerServices = MockServices( - Arrays.asList("net.corda.samples.heartbeat.contracts") + listOf("net.corda.samples.heartbeat.contracts") ) - var st: HeartState = HeartState(a.party) + private val st: HeartState = HeartState(a.party) @Test fun contractImplementsContract() { - assert(HeartContract() is Contract) + assertTrue(HeartContract() is Contract) } @Test @@ -29,7 +28,7 @@ class HeartContractTests { transaction { // Has correct command type, will verify. output(HeartContract.contractID, st) - command(Arrays.asList(a.publicKey), HeartContract.Commands.Beat()) + command(listOf(a.publicKey), HeartContract.Commands.Beat()) verifies() } } diff --git a/Features/schedulableState-heartbeat/contracts/src/test/kotlin/net/corda/samples/heartbeat/states/HeartStateTests.kt b/Features/schedulableState-heartbeat/contracts/src/test/kotlin/net/corda/samples/heartbeat/states/HeartStateTests.kt index c1fb13ba..b0e1510a 100644 --- a/Features/schedulableState-heartbeat/contracts/src/test/kotlin/net/corda/samples/heartbeat/states/HeartStateTests.kt +++ b/Features/schedulableState-heartbeat/contracts/src/test/kotlin/net/corda/samples/heartbeat/states/HeartStateTests.kt @@ -4,10 +4,10 @@ import net.corda.core.contracts.ContractState import net.corda.core.contracts.SchedulableState import net.corda.core.identity.CordaX500Name import net.corda.testing.core.TestIdentity -import org.jgroups.util.Util +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue import org.junit.Test - class HeartStateTests { private val a = TestIdentity(CordaX500Name("Alice", "", "GB")) private val b = TestIdentity(CordaX500Name("Bob", "", "GB")) @@ -15,14 +15,14 @@ class HeartStateTests { @Test fun constructorTest() { val st = HeartState(a.party) - Util.assertTrue(st.participants.contains(a.party)) - Util.assertFalse(st.participants.contains(b.party)) + assertTrue(st.participants.contains(a.party)) + assertFalse(st.participants.contains(b.party)) } @Test fun stateImplementsContractStateTest() { val st = HeartState(a.party) - Util.assertTrue(st is ContractState) - Util.assertTrue(st is SchedulableState) + assertTrue(st is ContractState) + assertTrue(st is SchedulableState) } } diff --git a/Features/schedulableState-heartbeat/gradle.properties b/Features/schedulableState-heartbeat/gradle.properties index a1627a48..f283b0f4 100644 --- a/Features/schedulableState-heartbeat/gradle.properties +++ b/Features/schedulableState-heartbeat/gradle.properties @@ -1,4 +1,26 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=SchedulableState Heartbeat group=com.heartbeat version=0.2 -kotlin.incremental=false + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +spring_boot_version=2.0.2.RELEASE diff --git a/Features/schedulableState-heartbeat/gradle/wrapper/gradle-wrapper.jar b/Features/schedulableState-heartbeat/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7a3265ee..00000000 Binary files a/Features/schedulableState-heartbeat/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Features/schedulableState-heartbeat/gradle/wrapper/gradle-wrapper.properties b/Features/schedulableState-heartbeat/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 674bdda0..00000000 --- a/Features/schedulableState-heartbeat/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Features/schedulableState-heartbeat/gradlew b/Features/schedulableState-heartbeat/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Features/schedulableState-heartbeat/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Features/schedulableState-heartbeat/gradlew.bat b/Features/schedulableState-heartbeat/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Features/schedulableState-heartbeat/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Features/schedulableState-heartbeat/lib/README.txt b/Features/schedulableState-heartbeat/lib/README.txt deleted file mode 100644 index b0592c95..00000000 --- a/Features/schedulableState-heartbeat/lib/README.txt +++ /dev/null @@ -1,8 +0,0 @@ -The Quasar.jar in this directory is for runtime instrumentation of classes by Quasar. - -When running corda outside of the given gradle building you must add the following flag with the -correct path to your call to Java: - - java -javaagent:path-to-quasar-jar.jar ... - -See the Quasar docs for more information: http://docs.paralleluniverse.co/quasar/ \ No newline at end of file diff --git a/Features/schedulableState-heartbeat/lib/quasar.jar b/Features/schedulableState-heartbeat/lib/quasar.jar deleted file mode 100644 index 7282d8c8..00000000 Binary files a/Features/schedulableState-heartbeat/lib/quasar.jar and /dev/null differ diff --git a/Features/schedulableState-heartbeat/repositories.gradle b/Features/schedulableState-heartbeat/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Features/schedulableState-heartbeat/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Features/schedulableState-heartbeat/settings.gradle b/Features/schedulableState-heartbeat/settings.gradle index c46db016..061c6655 100644 --- a/Features/schedulableState-heartbeat/settings.gradle +++ b/Features/schedulableState-heartbeat/settings.gradle @@ -1,2 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'contracts' include 'workflows' diff --git a/Features/schedulableState-heartbeat/workflows/build.gradle b/Features/schedulableState-heartbeat/workflows/build.gradle index f661537b..7244f5d1 100644 --- a/Features/schedulableState-heartbeat/workflows/build.gradle +++ b/Features/schedulableState-heartbeat/workflows/build.gradle @@ -1,7 +1,8 @@ -apply plugin: 'kotlin' -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -14,34 +15,22 @@ cordapp { } } +sourceSets { + test { + resources { + srcDir "../config/test" + } + } +} + dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_release_group:corda-core:$corda_release_version" - cordaCompile "$corda_release_group:corda-jackson:$corda_release_version" - cordaCompile "$corda_release_group:corda-rpc:$corda_release_version" - cordaCompile "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" - cordaRuntime "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" - cordapp project(":contracts") -} - -jar { - // CorDapps do not configure a Node's logging. - exclude '**/log4j2*.xml' -} - -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { - kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" - javaParameters = true // Useful for reflection. - } + // CorDapp dependencies. + cordapp project(':contracts') } diff --git a/Features/schedulableState-heartbeat/workflows/src/test/kotlin/net/corda/samples/heartbeat/flows/FlowTests.kt b/Features/schedulableState-heartbeat/workflows/src/test/kotlin/net/corda/samples/heartbeat/flows/FlowTests.kt index a9ab2e49..34a1d45b 100644 --- a/Features/schedulableState-heartbeat/workflows/src/test/kotlin/net/corda/samples/heartbeat/flows/FlowTests.kt +++ b/Features/schedulableState-heartbeat/workflows/src/test/kotlin/net/corda/samples/heartbeat/flows/FlowTests.kt @@ -29,7 +29,9 @@ class FlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test diff --git a/Features/settings.gradle b/Features/settings.gradle new file mode 100644 index 00000000..fbd6cd70 --- /dev/null +++ b/Features/settings.gradle @@ -0,0 +1,17 @@ +includeBuild 'attachment-blacklist' +includeBuild 'attachment-sendfile' +includeBuild 'confidentialIdentity-whistleblower' +includeBuild 'contractsdk-recordplayers' +includeBuild 'cordaService-autopayroll' +includeBuild 'customlogging-yocordapp' +includeBuild 'customquery-carinsurance' +includeBuild 'dockerform-yocordapp' +includeBuild 'encumbrance-avatar' +includeBuild 'notarychange-iou' +includeBuild 'observableStates-tradereporting' +includeBuild 'oracle-primenumber' +includeBuild 'postgres-cordapp' +includeBuild 'queryableState-carinsurance' +includeBuild 'referenceStates-sanctionsBody' +includeBuild 'schedulableState-heartbeat' +includeBuild 'state-reissuance' diff --git a/Features/state-reissuance/README.md b/Features/state-reissuance/README.md index 371bbcb6..3ed84454 100644 --- a/Features/state-reissuance/README.md +++ b/Features/state-reissuance/README.md @@ -22,7 +22,7 @@ See https://docs.corda.net/getting-set-up.html. Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) -`./gradlew clean deployNodes` +`../gradlew clean deployNodes` Then type: (to run the nodes) diff --git a/Features/state-reissuance/build.gradle b/Features/state-reissuance/build.gradle index 91740f63..ad2d2875 100644 --- a/Features/state-reissuance/build.gradle +++ b/Features/state-reissuance/build.gradle @@ -1,98 +1,53 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - //re-issuance - reissuance_release_group = 'com.r3.corda.lib.reissuance' - reissuance_release_version = '1.0-GA' - //TokenSDK - confidential_id_release_group = 'com.r3.corda.lib.ci' - confidential_id_release_version = '1.0' - tokens_release_version = '1.2' - tokens_release_group = 'com.r3.corda.lib.tokens' - } - - repositories { - mavenLocal() - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://software.r3.com/artifactory/corda-lib' } - maven { url 'https://jitpack.io' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } //Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':workflows') + cordapp project(':contracts') cordapp "$reissuance_release_group:reissuance-cordapp-contracts:$reissuance_release_version" cordapp "$reissuance_release_group:reissuance-cordapp-workflows:$reissuance_release_version" @@ -103,23 +58,16 @@ dependencies { // CI dependencies. cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version" - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -//Task to deploy the nodes in order to bootstrap a network -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { - +tasks.register('deployNodes', Cordform) { /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load * the Corda network bootstrapper. */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp project(':contracts') cordapp project(':workflows') cordapp "$reissuance_release_group:reissuance-cordapp-contracts:$reissuance_release_version" @@ -127,6 +75,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version" cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version" cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version" + rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change //it to false for quicker project compiling time. @@ -139,6 +88,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { name "O=PartyA,L=London,C=GB" @@ -147,7 +97,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=PartyB,L=New York,C=US" @@ -156,7 +105,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=PartyC,L=New York,C=US" @@ -165,7 +113,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10012") adminAddress("localhost:10052") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } - } diff --git a/Features/state-reissuance/constants.properties b/Features/state-reissuance/constants.properties deleted file mode 100644 index ee9c2200..00000000 --- a/Features/state-reissuance/constants.properties +++ /dev/null @@ -1,12 +0,0 @@ -cordaReleaseGroup=net.corda -cordaCoreReleaseGroup=net.corda -cordaVersion=4.8.5 -cordaCoreVersion=4.8.5 -gradlePluginsVersion=5.0.12 -kotlinVersion=1.2.71 -junitVersion=4.12 -quasarVersion=0.7.13_r3 -log4jVersion=2.17.1 -platformVersion=10 -slf4jVersion=1.7.30 -nettyVersion=4.1.68.Final diff --git a/Features/state-reissuance/contracts/build.gradle b/Features/state-reissuance/contracts/build.gradle index 3c07278b..d104c51d 100644 --- a/Features/state-reissuance/contracts/build.gradle +++ b/Features/state-reissuance/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "State Re-Issuance Contracts" vendor "Corda Open Source" @@ -12,8 +15,10 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" + // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" } diff --git a/Features/state-reissuance/contracts/src/main/kotlin/net/corda/samples/statereissuance/contracts/LandTitleContract.kt b/Features/state-reissuance/contracts/src/main/kotlin/net/corda/samples/statereissuance/contracts/LandTitleContract.kt index 8f78ef52..c71d6bea 100644 --- a/Features/state-reissuance/contracts/src/main/kotlin/net/corda/samples/statereissuance/contracts/LandTitleContract.kt +++ b/Features/state-reissuance/contracts/src/main/kotlin/net/corda/samples/statereissuance/contracts/LandTitleContract.kt @@ -31,24 +31,25 @@ class LandTitleContract : Contract { // Land Title Issue Contract Verification Logic goes here if (tx.outputStates.size != 1) throw IllegalArgumentException("One Output Expected") val command = tx.getCommand(0) - if (!command.signers.contains((tx.getOutput(0) as LandTitleState).issuer.owningKey)) + if (!command.signers.contains(tx.outputsOfType()[0].issuer.owningKey)) { throw IllegalArgumentException("Issuer Signature Required") + } } private fun verifyTransfer(tx: LedgerTransaction) { // Land Title Transfer Contract Verification Logic goes here val command = tx.getCommand(0) - val landTitleState = tx.getInput(0) as LandTitleState + val landTitleState = tx.inputsOfType().single() if (!command.signers.contains(landTitleState.issuer.owningKey) && (landTitleState.owner != null && command.signers.contains(landTitleState.owner.owningKey))) - throw java.lang.IllegalArgumentException("Issuer and Owner must Sign") + throw IllegalArgumentException("Issuer and Owner must Sign") } private fun verifyExit(tx: LedgerTransaction) { // Land Title Exit Contract Verification Logic goes here - if (tx.outputStates.size != 0) throw java.lang.IllegalArgumentException("Zero Output Expected") + if (tx.outputStates.isNotEmpty()) throw java.lang.IllegalArgumentException("Zero Output Expected") if (tx.inputStates.size != 1) throw java.lang.IllegalArgumentException("One Input Expected") val command = tx.getCommand(0) - if (!command.signers.contains((tx.getInput(0) as LandTitleState).issuer.owningKey)) throw java.lang.IllegalArgumentException("Issuer Signature Required") + if (!command.signers.contains((tx.inputsOfType()[0]).issuer.owningKey)) throw IllegalArgumentException("Issuer Signature Required") } interface Commands : CommandData { diff --git a/Features/state-reissuance/contracts/src/main/kotlin/net/corda/samples/statereissuance/states/LandTitleState.kt b/Features/state-reissuance/contracts/src/main/kotlin/net/corda/samples/statereissuance/states/LandTitleState.kt index 80d3d94e..de78968e 100644 --- a/Features/state-reissuance/contracts/src/main/kotlin/net/corda/samples/statereissuance/states/LandTitleState.kt +++ b/Features/state-reissuance/contracts/src/main/kotlin/net/corda/samples/statereissuance/states/LandTitleState.kt @@ -15,12 +15,12 @@ data class LandTitleState(override val linearId: UniqueIdentifier, val owner: Party, override val participants: List = listOf(issuer, owner) ) : LinearState { - override fun equals(o: Any?): Boolean { - if (this === o) return true - return if (o == null || javaClass != o.javaClass) false else linearId.equals((o as LandTitleState).linearId) + override fun equals(other: Any?): Boolean { + if (this === other) return true + return other is LandTitleState && linearId == other.linearId } override fun hashCode(): Int { return linearId.hashCode() } -} \ No newline at end of file +} diff --git a/Features/state-reissuance/contracts/src/test/kotlin/net/corda/samples/statereissuance/contracts/ContractTests.kt b/Features/state-reissuance/contracts/src/test/kotlin/net/corda/samples/statereissuance/contracts/ContractTests.kt index 59283af2..e5012e1b 100644 --- a/Features/state-reissuance/contracts/src/test/kotlin/net/corda/samples/statereissuance/contracts/ContractTests.kt +++ b/Features/state-reissuance/contracts/src/test/kotlin/net/corda/samples/statereissuance/contracts/ContractTests.kt @@ -7,11 +7,10 @@ import org.junit.Test class ContractTests { private val ledgerServices: MockServices = MockServices(listOf("net.corda.samples.statereissuance")) - var alice = TestIdentity(CordaX500Name("Alice", "TestLand", "US")) - var bob = TestIdentity(CordaX500Name("Alice", "TestLand", "US")) + private val alice = TestIdentity(CordaX500Name("Alice", "TestLand", "US")) + private val bob = TestIdentity(CordaX500Name("Alice", "TestLand", "US")) @Test fun dummytest() { - } -} \ No newline at end of file +} diff --git a/Features/state-reissuance/contracts/src/test/kotlin/net/corda/samples/statereissuance/contracts/StateTests.kt b/Features/state-reissuance/contracts/src/test/kotlin/net/corda/samples/statereissuance/contracts/StateTests.kt index 4988ca51..77b0276b 100644 --- a/Features/state-reissuance/contracts/src/test/kotlin/net/corda/samples/statereissuance/contracts/StateTests.kt +++ b/Features/state-reissuance/contracts/src/test/kotlin/net/corda/samples/statereissuance/contracts/StateTests.kt @@ -5,6 +5,5 @@ import org.junit.Test class StateTests { @Test fun hasFieldOfCorrectType() { - } -} \ No newline at end of file +} diff --git a/Features/state-reissuance/gradle.properties b/Features/state-reissuance/gradle.properties index a162c381..9df1c512 100644 --- a/Features/state-reissuance/gradle.properties +++ b/Features/state-reissuance/gradle.properties @@ -1,4 +1,36 @@ -name=Test +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + +name=State Reissuance group=com.statereissuance version=0.1 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.22.Final + +# Reissuance +reissuance_release_group=com.r3.corda.lib.reissuance +reissuance_release_version=1.0-GA + +# TokenSDK +confidential_id_release_group=com.r3.corda.lib.ci +confidential_id_release_version=1.1 +tokens_release_version=1.2 +tokens_release_group=com.r3.corda.lib.tokens + +spring_boot_version=2.0.2.RELEASE diff --git a/Features/state-reissuance/gradle/wrapper/gradle-wrapper.jar b/Features/state-reissuance/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Features/state-reissuance/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Features/state-reissuance/gradle/wrapper/gradle-wrapper.properties b/Features/state-reissuance/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Features/state-reissuance/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Features/state-reissuance/gradlew b/Features/state-reissuance/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Features/state-reissuance/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Features/state-reissuance/gradlew.bat b/Features/state-reissuance/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Features/state-reissuance/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Features/state-reissuance/repositories.gradle b/Features/state-reissuance/repositories.gradle deleted file mode 100644 index 7dc03179..00000000 --- a/Features/state-reissuance/repositories.gradle +++ /dev/null @@ -1,7 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Features/state-reissuance/settings.gradle b/Features/state-reissuance/settings.gradle index 2514aca2..03d1e67e 100644 --- a/Features/state-reissuance/settings.gradle +++ b/Features/state-reissuance/settings.gradle @@ -1,3 +1,38 @@ -include 'workflows' +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url "$artifactoryContextUrl/corda-lib" + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'contracts' -include 'clients' \ No newline at end of file +include 'workflows' diff --git a/Features/state-reissuance/workflows/build.gradle b/Features/state-reissuance/workflows/build.gradle index c8cd1bf5..15be60f3 100644 --- a/Features/state-reissuance/workflows/build.gradle +++ b/Features/state-reissuance/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "State Re-Issuance Flows" vendor "Corda Open Source" @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,29 +31,26 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') cordapp "$reissuance_release_group:reissuance-cordapp-contracts:$reissuance_release_version" cordapp "$reissuance_release_group:reissuance-cordapp-workflows:$reissuance_release_version" cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version" - cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version" -} + cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version"} -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/IssueLandTitleFlow.kt b/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/IssueLandTitleFlow.kt index 9d99eeee..cb0d5c5f 100644 --- a/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/IssueLandTitleFlow.kt +++ b/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/IssueLandTitleFlow.kt @@ -42,7 +42,7 @@ class IssueLandTitle(private val owner: Party, val ptx = serviceHub.signInitialTransaction(builder) // Step 7. Assuming no exceptions, we can now finalise the transaction - return subFlow(FinalityFlow(ptx, listOf(initiateFlow(owner)))) + return subFlow(FinalityFlow(ptx, listOf(initiateFlow(owner)))) } } diff --git a/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/TransferLandTitleFlow.kt b/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/TransferLandTitleFlow.kt index 79ea7a06..b3aa43dd 100644 --- a/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/TransferLandTitleFlow.kt +++ b/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/TransferLandTitleFlow.kt @@ -11,8 +11,6 @@ import net.corda.core.utilities.ProgressTracker import net.corda.core.utilities.unwrap import net.corda.samples.statereissuance.contracts.LandTitleContract import net.corda.samples.statereissuance.states.LandTitleState -import java.util.* - @InitiatingFlow @StartableByRPC @@ -47,10 +45,10 @@ class TransferLandTitle(private val plotIdentifier: UniqueIdentifier, val newOwnerSession = initiateFlow(owner) newOwnerSession.send("not-signer") - val stx = subFlow(CollectSignaturesFlow(ptx, Arrays.asList(issuerSession))) + val stx = subFlow(CollectSignaturesFlow(ptx, listOf(issuerSession))) // Step 7. Assuming no exceptions, we can now finalise the transaction - return subFlow(FinalityFlow(stx, listOf(issuerSession,newOwnerSession))) + return subFlow(FinalityFlow(stx, listOf(issuerSession,newOwnerSession))) } } diff --git a/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/reissuance/AcceptLandReissuanceFlow.kt b/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/reissuance/AcceptLandReissuanceFlow.kt index 0ff66520..8315c22a 100644 --- a/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/reissuance/AcceptLandReissuanceFlow.kt +++ b/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/reissuance/AcceptLandReissuanceFlow.kt @@ -11,7 +11,6 @@ import net.corda.core.flows.* import net.corda.core.identity.Party import net.corda.core.transactions.SignedTransaction import net.corda.core.utilities.ProgressTracker -import java.util.* @InitiatingFlow @StartableByRPC @@ -27,7 +26,7 @@ class AcceptLandReissuance(private val issuer: Party, val stateAndRef = reissueRequestStateAndRefs.stream().filter { it.state.data.stateRefsToReissue.contains(stateRef) } .findAny().orElseThrow { IllegalArgumentException("ReIssuance Request does not exist") } - return subFlow(ReissueStates(stateAndRef, Arrays.asList(issuer))) + return subFlow(ReissueStates(stateAndRef, listOf(issuer))) } } diff --git a/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/reissuance/RejectLandReissuanceFlow.kt b/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/reissuance/RejectLandReissuanceFlow.kt index 1a33e5d6..3ccd4364 100644 --- a/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/reissuance/RejectLandReissuanceFlow.kt +++ b/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/reissuance/RejectLandReissuanceFlow.kt @@ -1,7 +1,6 @@ package net.corda.samples.statereissuance.flows.reissuance import co.paralleluniverse.fibers.Suspendable -import com.r3.corda.lib.reissuance.flows.ReissueStates import com.r3.corda.lib.reissuance.flows.RejectReissuanceRequest import com.r3.corda.lib.reissuance.states.ReissuanceRequest import net.corda.core.contracts.ContractState @@ -12,7 +11,6 @@ import net.corda.core.flows.InitiatingFlow import net.corda.core.flows.StartableByRPC import net.corda.core.identity.Party import net.corda.core.utilities.ProgressTracker -import java.util.* @InitiatingFlow @StartableByRPC diff --git a/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/reissuance/RequestReissueLandStateFlow.kt b/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/reissuance/RequestReissueLandStateFlow.kt index d979e777..cc6ea2ae 100644 --- a/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/reissuance/RequestReissueLandStateFlow.kt +++ b/Features/state-reissuance/workflows/src/main/kotlin/net/corda/samples/statereissuance/flows/reissuance/RequestReissueLandStateFlow.kt @@ -10,7 +10,6 @@ import net.corda.core.flows.StartableByRPC import net.corda.core.identity.Party import net.corda.samples.statereissuance.contracts.LandTitleContract import net.corda.samples.statereissuance.states.LandTitleState -import java.util.* @InitiatingFlow @StartableByRPC @@ -24,7 +23,7 @@ class RequestReissueLandState(val issuer: Party, val stateAndRef = landTitleStateAndRefs.stream().filter { it.state.data.linearId == plotIdentifier } .findAny().orElseThrow { IllegalArgumentException("Land Not Found") } - return subFlow(RequestReissuance(issuer, Arrays.asList(stateAndRef.ref), LandTitleContract.Commands.Issue(), + return subFlow(RequestReissuance(issuer, listOf(stateAndRef.ref), LandTitleContract.Commands.Issue(), listOf(), null) ) } diff --git a/Features/state-reissuance/workflows/src/test/kotlin/net/corda/samples/statereissuance/FlowTests.kt b/Features/state-reissuance/workflows/src/test/kotlin/net/corda/samples/statereissuance/FlowTests.kt index 419f2e91..27f8f5b9 100644 --- a/Features/state-reissuance/workflows/src/test/kotlin/net/corda/samples/statereissuance/FlowTests.kt +++ b/Features/state-reissuance/workflows/src/test/kotlin/net/corda/samples/statereissuance/FlowTests.kt @@ -4,12 +4,7 @@ import net.corda.testing.node.* import org.junit.After import org.junit.Before import org.junit.Test -import java.util.concurrent.Future; -import net.corda.core.node.services.vault.QueryCriteria -import net.corda.core.transactions.SignedTransaction import net.corda.core.identity.CordaX500Name -import net.corda.core.node.services.Vault.StateStatus - class FlowTests { private lateinit var network: MockNetwork @@ -34,11 +29,12 @@ class FlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test - fun `DummyTest`() { - + fun dummyTest() { } -} \ No newline at end of file +} diff --git a/Tokens/bikemarket/README.md b/Tokens/bikemarket/README.md index 0c547b0b..d2583abd 100644 --- a/Tokens/bikemarket/README.md +++ b/Tokens/bikemarket/README.md @@ -23,7 +23,7 @@ Through out the sample, we will see how to create, transacte, and redeem a token ## Running the sample Deploy and run the nodes by: ``` -./gradlew deployNodes +../gradlew deployNodes ./build/nodes/runnodes ``` if you have any questions during setup, please go to https://docs.corda.net/getting-set-up.html for detailed setup instructions. diff --git a/Tokens/bikemarket/build.gradle b/Tokens/bikemarket/build.gradle index a9f4a729..fa9dfe10 100644 --- a/Tokens/bikemarket/build.gradle +++ b/Tokens/bikemarket/build.gradle @@ -1,119 +1,78 @@ -buildscript { - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - //Token - tokens_release_group = 'com.r3.corda.lib.tokens' - tokens_release_version = '1.2' - //CI - confidential_id_release_group = "com.r3.corda.lib.ci" - confidential_id_release_version = "1.0" - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } - // Can be removed post-release - used to get nightly snapshot build. - maven { url 'https://software.r3.com/artifactory/corda-lib' } - maven { url 'https://software.r3.com/artifactory/corda-tokens-dev' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") - - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordapp project(':workflows') + cordapp project(':contracts') // Token SDK dependencies. cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version" cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version" // CI dependencies cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version" + + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { + +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp("$tokens_release_group:tokens-contracts:$tokens_release_version") cordapp("$tokens_release_group:tokens-workflows:$tokens_release_version") cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version" cordapp project(':contracts') cordapp project(':workflows') - runSchemaMigration = true + rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { name "O=Notary,L=London,C=GB" @@ -123,6 +82,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { name "O=BikeCo,L=London,C=GB" @@ -131,7 +91,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=LicensedDealership,L=New York,C=US" @@ -140,7 +99,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=UsedPartsAgency,L=San Francisco,C=US" @@ -149,7 +107,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10011") adminAddress("localhost:10052") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=Buyer,L=San Diego,C=US" @@ -158,14 +115,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10013") adminAddress("localhost:10055") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] - } -} - -task installQuasar(type: Copy) { - destinationDir rootProject.file("lib") - from(configurations.quasar) { - rename 'quasar-core(.*).jar', 'quasar.jar' } } - diff --git a/Tokens/bikemarket/contracts/build.gradle b/Tokens/bikemarket/contracts/build.gradle index f237431d..bd955811 100644 --- a/Tokens/bikemarket/contracts/build.gradle +++ b/Tokens/bikemarket/contracts/build.gradle @@ -1,9 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "bikemarket Contracts" vendor "Corda Open Source" @@ -13,11 +15,12 @@ cordapp { } dependencies { + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + // Corda dependencies. - cordaCompile "$corda_release_group:corda-core:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_release_group:corda-core:$corda_release_version" + testImplementation"$corda_release_group:corda-node-driver:$corda_release_version" // Token SDK dependencies. - cordaCompile "$tokens_release_group:tokens-contracts:$tokens_release_version" + cordaProvided "$tokens_release_group:tokens-contracts:$tokens_release_version" } \ No newline at end of file diff --git a/Tokens/bikemarket/contracts/src/main/kotlin/net/corda/samples/bikemarket/contracts/FrameContract.kt b/Tokens/bikemarket/contracts/src/main/kotlin/net/corda/samples/bikemarket/contracts/FrameContract.kt index 271cf718..3859e84e 100644 --- a/Tokens/bikemarket/contracts/src/main/kotlin/net/corda/samples/bikemarket/contracts/FrameContract.kt +++ b/Tokens/bikemarket/contracts/src/main/kotlin/net/corda/samples/bikemarket/contracts/FrameContract.kt @@ -2,15 +2,13 @@ package net.corda.samples.bikemarket.contracts import com.r3.corda.lib.tokens.contracts.EvolvableTokenContract import net.corda.core.contracts.Contract -import net.corda.core.contracts.Requirements -import net.corda.core.contracts.requireThat import net.corda.core.transactions.LedgerTransaction import net.corda.samples.bikemarket.states.FrameTokenState class FrameContract : EvolvableTokenContract(), Contract { override fun additionalCreateChecks(tx: LedgerTransaction) { - val newToken = tx.outputStates.single() as FrameTokenState + val newToken = tx.outputsOfType().single() newToken.apply { require(serialNum != "") {"serialNum cannot be empty"} } diff --git a/Tokens/bikemarket/contracts/src/main/kotlin/net/corda/samples/bikemarket/contracts/WheelsContract.kt b/Tokens/bikemarket/contracts/src/main/kotlin/net/corda/samples/bikemarket/contracts/WheelsContract.kt index 26265f90..e36b33ca 100644 --- a/Tokens/bikemarket/contracts/src/main/kotlin/net/corda/samples/bikemarket/contracts/WheelsContract.kt +++ b/Tokens/bikemarket/contracts/src/main/kotlin/net/corda/samples/bikemarket/contracts/WheelsContract.kt @@ -3,7 +3,6 @@ package net.corda.samples.bikemarket.contracts import com.r3.corda.lib.tokens.contracts.EvolvableTokenContract import net.corda.core.contracts.Contract import net.corda.core.transactions.LedgerTransaction -import net.corda.samples.bikemarket.states.FrameTokenState import net.corda.samples.bikemarket.states.WheelsTokenState // ************ @@ -11,7 +10,7 @@ import net.corda.samples.bikemarket.states.WheelsTokenState // ************ class WheelsContract: EvolvableTokenContract(), Contract{ override fun additionalCreateChecks(tx: LedgerTransaction) { - val newToken = tx.outputStates.single() as WheelsTokenState + val newToken = tx.outputsOfType().single() newToken.apply { require(serialNum != "") {"serialNum cannot be empty"} } diff --git a/Tokens/bikemarket/contracts/src/test/kotlin/net/corda/samples/bikemarket/contracts/StateTests.kt b/Tokens/bikemarket/contracts/src/test/kotlin/net/corda/samples/bikemarket/contracts/StateTests.kt index 95c894e8..8cf2c4c7 100644 --- a/Tokens/bikemarket/contracts/src/test/kotlin/net/corda/samples/bikemarket/contracts/StateTests.kt +++ b/Tokens/bikemarket/contracts/src/test/kotlin/net/corda/samples/bikemarket/contracts/StateTests.kt @@ -2,6 +2,7 @@ package net.corda.samples.bikemarket.contracts import net.corda.samples.bikemarket.states.WheelsTokenState import net.corda.testing.node.MockServices +import org.junit.Assert.assertEquals import org.junit.Test class StateTests { @@ -13,6 +14,6 @@ class StateTests { // Does the message field exist? WheelsTokenState::class.java.getDeclaredField("serialNum") // Is the message field of the correct type? - assert(WheelsTokenState::class.java.getDeclaredField("serialNum").type == String::class.java) + assertEquals(String::class.java, WheelsTokenState::class.java.getDeclaredField("serialNum").type) } } \ No newline at end of file diff --git a/Tokens/bikemarket/gradle.properties b/Tokens/bikemarket/gradle.properties index 215a62ad..10b935af 100644 --- a/Tokens/bikemarket/gradle.properties +++ b/Tokens/bikemarket/gradle.properties @@ -1,4 +1,34 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Bikemarket Cordapp group=com.bikemarket version=1.0 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.68.Final + +# Token +tokens_release_group=com.r3.corda.lib.tokens +tokens_release_version=1.2 + +# Confidential Identities (CI) +confidential_id_release_group=com.r3.corda.lib.ci +confidential_id_release_version=1.0 + +spring_boot_version=2.0.2.RELEASE diff --git a/Tokens/bikemarket/gradle/wrapper/gradle-wrapper.jar b/Tokens/bikemarket/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Tokens/bikemarket/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Tokens/bikemarket/gradle/wrapper/gradle-wrapper.properties b/Tokens/bikemarket/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Tokens/bikemarket/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Tokens/bikemarket/gradlew b/Tokens/bikemarket/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Tokens/bikemarket/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Tokens/bikemarket/gradlew.bat b/Tokens/bikemarket/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Tokens/bikemarket/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Tokens/bikemarket/repositories.gradle b/Tokens/bikemarket/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Tokens/bikemarket/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Tokens/bikemarket/settings.gradle b/Tokens/bikemarket/settings.gradle index 2514aca2..45f64fa3 100644 --- a/Tokens/bikemarket/settings.gradle +++ b/Tokens/bikemarket/settings.gradle @@ -1,3 +1,38 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url "$artifactoryContextUrl/corda-lib" + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file diff --git a/Tokens/bikemarket/workflows/build.gradle b/Tokens/bikemarket/workflows/build.gradle index 43242234..d12d3210 100644 --- a/Tokens/bikemarket/workflows/build.gradle +++ b/Tokens/bikemarket/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "bikemarket Flows" vendor "Corda Open Source" @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,31 +31,29 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. - cordapp project(":contracts") + cordapp project(':contracts') // Token SDK dependencies. - cordaCompile "$tokens_release_group:tokens-workflows:$tokens_release_version" + cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version" + cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version" cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version" - } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Tokens/bikemarket/workflows/src/main/kotlin/net/corda/samples/bikemarket/flows/IssueNewBike.kt b/Tokens/bikemarket/workflows/src/main/kotlin/net/corda/samples/bikemarket/flows/IssueNewBike.kt index 82138b04..f7e99e1d 100644 --- a/Tokens/bikemarket/workflows/src/main/kotlin/net/corda/samples/bikemarket/flows/IssueNewBike.kt +++ b/Tokens/bikemarket/workflows/src/main/kotlin/net/corda/samples/bikemarket/flows/IssueNewBike.kt @@ -27,7 +27,7 @@ class IssueNewBike(val frameSerial: String, //Step 1: Frame Token //get frame states on ledger val frameStateAndRef = serviceHub.vaultService.queryBy().states - .filter { it.state.data.serialNum.equals(frameSerial) }[0] + .filter { it.state.data.serialNum == frameSerial }[0] //get the TokenType object val frametokentype = frameStateAndRef.state.data @@ -43,7 +43,7 @@ class IssueNewBike(val frameSerial: String, //Step 2: Wheels Token val wheelStateAndRef = serviceHub.vaultService.queryBy().states - .filter { it.state.data.serialNum.equals(wheelsSerial) }[0] + .filter { it.state.data.serialNum == wheelsSerial }[0] //get the TokenType object val wheeltokentype: WheelsTokenState = wheelStateAndRef.state.data diff --git a/Tokens/bikemarket/workflows/src/main/kotlin/net/corda/samples/bikemarket/flows/TotalPart.kt b/Tokens/bikemarket/workflows/src/main/kotlin/net/corda/samples/bikemarket/flows/TotalPart.kt index ac5234cf..6fd32fd8 100644 --- a/Tokens/bikemarket/workflows/src/main/kotlin/net/corda/samples/bikemarket/flows/TotalPart.kt +++ b/Tokens/bikemarket/workflows/src/main/kotlin/net/corda/samples/bikemarket/flows/TotalPart.kt @@ -2,11 +2,9 @@ package net.corda.samples.bikemarket.flows import co.paralleluniverse.fibers.Suspendable import com.r3.corda.lib.tokens.contracts.types.TokenPointer -import com.r3.corda.lib.tokens.workflows.flows.rpc.MoveNonFungibleTokensHandler import com.r3.corda.lib.tokens.workflows.flows.rpc.RedeemNonFungibleTokens import com.r3.corda.lib.tokens.workflows.flows.rpc.RedeemNonFungibleTokensHandler import net.corda.core.flows.* -import net.corda.core.identity.Party import net.corda.core.node.services.queryBy import net.corda.core.utilities.ProgressTracker import net.corda.samples.bikemarket.states.FrameTokenState @@ -23,11 +21,11 @@ class TotalPart(val part: String, @Suspendable override fun call():String { - if (part.equals("frame")){ + if (part == "frame"){ val frameSerial = serial //transfer frame token val frameStateAndRef = serviceHub.vaultService.queryBy().states - .filter { it.state.data.serialNum.equals(frameSerial) }[0] + .filter { it.state.data.serialNum == frameSerial }[0] //get the TokenType object val frametokentype = frameStateAndRef.state.data @@ -39,11 +37,11 @@ class TotalPart(val part: String, val stx = subFlow(RedeemNonFungibleTokens(frametokenPointer,issuer)) return "\nThe frame part is totaled, and the token is redeem to BikeCo" + "\nTransaction ID: " + stx.id - }else if(part.equals("wheels")){ + }else if(part == "wheels"){ val wheelsSerial = serial //transfer wheel token val wheelStateAndRef = serviceHub.vaultService.queryBy().states - .filter { it.state.data.serialNum.equals(wheelsSerial) }[0] + .filter { it.state.data.serialNum == wheelsSerial }[0] //get the TokenType object val wheeltokentype: WheelsTokenState = wheelStateAndRef.state.data @@ -65,7 +63,7 @@ class TotalPartResponder(val counterpartySession: FlowSession) : FlowLogic @Suspendable override fun call() { // Responder flow logic goes here. - subFlow(RedeemNonFungibleTokensHandler(counterpartySession)); + subFlow(RedeemNonFungibleTokensHandler(counterpartySession)) } } diff --git a/Tokens/bikemarket/workflows/src/main/kotlin/net/corda/samples/bikemarket/flows/TransferBikeToken.kt b/Tokens/bikemarket/workflows/src/main/kotlin/net/corda/samples/bikemarket/flows/TransferBikeToken.kt index dab4ae14..a01c3cdf 100644 --- a/Tokens/bikemarket/workflows/src/main/kotlin/net/corda/samples/bikemarket/flows/TransferBikeToken.kt +++ b/Tokens/bikemarket/workflows/src/main/kotlin/net/corda/samples/bikemarket/flows/TransferBikeToken.kt @@ -6,13 +6,10 @@ import com.r3.corda.lib.tokens.workflows.flows.move.addMoveNonFungibleTokens import com.r3.corda.lib.tokens.workflows.internal.flows.distribution.UpdateDistributionListFlow import com.r3.corda.lib.tokens.workflows.internal.flows.finality.ObserverAwareFinalityFlow import com.r3.corda.lib.tokens.workflows.internal.flows.finality.ObserverAwareFinalityFlowHandler -import com.r3.corda.lib.tokens.workflows.utilities.getPreferredNotary -import net.corda.core.contracts.requireThat import net.corda.core.flows.* import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party import net.corda.core.node.services.queryBy -import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.ProgressTracker import net.corda.samples.bikemarket.states.FrameTokenState @@ -33,7 +30,7 @@ class TransferBikeToken(val frameSerial: String, //Step 1: Frame Token //get frame states on ledger val frameStateAndRef = serviceHub.vaultService.queryBy().states - .filter { it.state.data.serialNum.equals(frameSerial) }[0] + .filter { it.state.data.serialNum == frameSerial }[0] //get the TokenType object val frametokentype = frameStateAndRef.state.data @@ -43,7 +40,7 @@ class TransferBikeToken(val frameSerial: String, //Step 2: Wheels Token val wheelStateAndRef = serviceHub.vaultService.queryBy().states - .filter { it.state.data.serialNum.equals(wheelsSerial) }[0] + .filter { it.state.data.serialNum == wheelsSerial }[0] //get the TokenType object val wheeltokentype: WheelsTokenState = wheelStateAndRef.state.data @@ -73,7 +70,7 @@ class TransferBikeToken(val frameSerial: String, @InitiatedBy(TransferBikeToken::class) class TransferBikeTokenResponder(val flowSession: FlowSession) : FlowLogic() { @Suspendable - override fun call(): Unit { + override fun call() { subFlow(ObserverAwareFinalityFlowHandler(flowSession)) } } diff --git a/Tokens/bikemarket/workflows/src/main/kotlin/net/corda/samples/bikemarket/flows/TransferPartToken.kt b/Tokens/bikemarket/workflows/src/main/kotlin/net/corda/samples/bikemarket/flows/TransferPartToken.kt index 3a4595e6..783f25ee 100644 --- a/Tokens/bikemarket/workflows/src/main/kotlin/net/corda/samples/bikemarket/flows/TransferPartToken.kt +++ b/Tokens/bikemarket/workflows/src/main/kotlin/net/corda/samples/bikemarket/flows/TransferPartToken.kt @@ -43,11 +43,11 @@ class TransferPartToken(val part: String, subFlow(UpdateDistributionListFlow(stx)) return ("Transfer ownership of the frame (" + this.serial + ") to" + holder.name.organisation + "\nTransaction ID: " + stx.id) - }else if(part.equals("wheels")){ + }else if(part == "wheels"){ val wheelsSerial = serial //transfer wheel token val wheelStateAndRef = serviceHub.vaultService.queryBy().states - .filter { it.state.data.serialNum.equals(wheelsSerial) }[0] + .filter { it.state.data.serialNum == wheelsSerial }[0] //get the TokenType object val wheeltokentype: WheelsTokenState = wheelStateAndRef.state.data @@ -72,7 +72,7 @@ class TransferPartTokenResponder(val counterpartySession: FlowSession) : FlowLog @Suspendable override fun call() { // Responder flow logic goes here. - subFlow(MoveNonFungibleTokensHandler(counterpartySession)); + subFlow(MoveNonFungibleTokensHandler(counterpartySession)) } } diff --git a/Tokens/bikemarket/workflows/src/test/kotlin/net/corda/samples/bikemarket/FlowTests.kt b/Tokens/bikemarket/workflows/src/test/kotlin/net/corda/samples/bikemarket/FlowTests.kt index c7a00ce4..04c1ce1e 100644 --- a/Tokens/bikemarket/workflows/src/test/kotlin/net/corda/samples/bikemarket/FlowTests.kt +++ b/Tokens/bikemarket/workflows/src/test/kotlin/net/corda/samples/bikemarket/FlowTests.kt @@ -8,14 +8,15 @@ import net.corda.samples.bikemarket.states.FrameTokenState import net.corda.samples.bikemarket.states.WheelsTokenState import net.corda.testing.node.* import org.junit.After +import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test import java.util.concurrent.Future class FlowTests { - private var network: MockNetwork? = null - private var a: StartedMockNode? = null - private var b: StartedMockNode? = null + private lateinit var network: MockNetwork + private lateinit var a: StartedMockNode + private lateinit var b: StartedMockNode @Before fun setup() { @@ -26,33 +27,35 @@ class FlowTests { TestCordapp.findCordapp("net.corda.samples.bikemarket.flows"), TestCordapp.findCordapp("com.r3.corda.lib.tokens.contracts"), TestCordapp.findCordapp("com.r3.corda.lib.tokens.workflows")))) - a = network!!.createPartyNode(null) - b = network!!.createPartyNode(null) - network!!.runNetwork() + a = network.createPartyNode(null) + b = network.createPartyNode(null) + network.runNetwork() } @After fun tearDown() { - network!!.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test fun bikeTokensCreation() { val frameflow = CreateFrameToken("8742") - val future: Future = a!!.startFlow(frameflow) - network!!.runNetwork() + val future: Future = a.startFlow(frameflow) + network.runNetwork() val wheelflow = CreateWheelToken("8755") - val future2: Future = a!!.startFlow(wheelflow) - network!!.runNetwork() - val (state) = a!!.services.vaultService.queryBy(FrameTokenState::class.java).states.stream().filter { + val future2: Future = a.startFlow(wheelflow) + network.runNetwork() + val (state) = a.services.vaultService.queryBy(FrameTokenState::class.java).states.stream().filter { (state) -> state.data.serialNum.equals("8742") }.findAny() .orElseThrow { IllegalArgumentException("frame serial symbol 8742 not found from vault") } val frameSerialStored: String = state.data.serialNum - val (state1) = a!!.services.vaultService.queryBy(WheelsTokenState::class.java).states.stream().filter { + val (state1) = a.services.vaultService.queryBy(WheelsTokenState::class.java).states.stream().filter { (state1) -> state1.data.serialNum.equals("8755") }.findAny() .orElseThrow { IllegalArgumentException("wheel serial symbol 8755 not found from vault") } val wheelsSerialStored: String = state1.data.serialNum - assert(frameSerialStored == "8742") - assert(wheelsSerialStored == "8755") + assertEquals("8742", frameSerialStored) + assertEquals("8755", wheelsSerialStored) } } \ No newline at end of file diff --git a/Tokens/build.gradle b/Tokens/build.gradle new file mode 100644 index 00000000..3b0d2b58 --- /dev/null +++ b/Tokens/build.gradle @@ -0,0 +1,8 @@ +plugins { + id 'base' +} + +wrapper { + gradleVersion = '7.4.2' + distributionType = Wrapper.DistributionType.BIN +} diff --git a/Tokens/constants.properties b/Tokens/constants.properties deleted file mode 100644 index 6425fb0b..00000000 --- a/Tokens/constants.properties +++ /dev/null @@ -1,12 +0,0 @@ -cordaReleaseGroup=net.corda -cordaCoreReleaseGroup=net.corda -cordaVersion=4.8.5 -cordaCoreVersion=4.8.5 -gradlePluginsVersion=5.0.12 -kotlinVersion=1.2.71 -junitVersion=4.12 -quasarVersion=0.7.10 -log4jVersion =2.17.1 -platformVersion=10 -slf4jVersion=1.7.25 -nettyVersion=4.1.22.Final diff --git a/Tokens/dollartohousetoken/README.md b/Tokens/dollartohousetoken/README.md index d745fe06..9e9aa8f4 100644 --- a/Tokens/dollartohousetoken/README.md +++ b/Tokens/dollartohousetoken/README.md @@ -25,7 +25,7 @@ For development environment setup, please refer to: [Setup Guide](https://docs.c ## Running the nodes Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) ``` diff --git a/Tokens/dollartohousetoken/build.gradle b/Tokens/dollartohousetoken/build.gradle index 7c037f2c..f3f4b2ce 100644 --- a/Tokens/dollartohousetoken/build.gradle +++ b/Tokens/dollartohousetoken/build.gradle @@ -1,117 +1,75 @@ -buildscript { - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - - //corda_gradle_plugins_version = '4.0.45' - - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //Tokens - tokens_release_group = 'com.r3.corda.lib.tokens' - tokens_release_version = '1.2' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } - //SDK lib - maven { url 'https://software.r3.com/artifactory/corda-lib' } - //Gradle Plugins - maven { url 'https://repo.gradle.org/gradle/libs-releases' } - +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") - - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordapp project(':workflows') + cordapp project(':contracts') // Token SDK dependencies. cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version" cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version" + + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp("$tokens_release_group:tokens-contracts:$tokens_release_version") cordapp("$tokens_release_group:tokens-workflows:$tokens_release_version") cordapp project(':contracts') cordapp project(':workflows') - runSchemaMigration = true + rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { name "O=Notary,L=London,C=GB" @@ -121,7 +79,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } - cordapps = [] + rpcUsers = [] } node { name "O=PartyA,L=London,C=GB" @@ -130,7 +88,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=PartyB,L=New York,C=US" @@ -139,7 +96,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=PartyC,L=Mumbai,C=IN" @@ -148,14 +104,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10013") adminAddress("localhost:10052") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } } - -task installQuasar(type: Copy) { - destinationDir rootProject.file("lib") - from(configurations.quasar) { - rename 'quasar-core(.*).jar', 'quasar.jar' - } -} - diff --git a/Tokens/dollartohousetoken/contracts/build.gradle b/Tokens/dollartohousetoken/contracts/build.gradle index 2c40c755..90905769 100644 --- a/Tokens/dollartohousetoken/contracts/build.gradle +++ b/Tokens/dollartohousetoken/contracts/build.gradle @@ -1,4 +1,7 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -15,13 +18,13 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // Token SDK dependencies. - cordaCompile "$tokens_release_group:tokens-contracts:$tokens_release_version" -} \ No newline at end of file + cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version" +} diff --git a/Tokens/dollartohousetoken/contracts/src/main/kotlin/net/corda/samples/dollartohousetoken/contracts/HouseContract.kt b/Tokens/dollartohousetoken/contracts/src/main/kotlin/net/corda/samples/dollartohousetoken/contracts/HouseContract.kt index 6a3287c4..bc12a527 100644 --- a/Tokens/dollartohousetoken/contracts/src/main/kotlin/net/corda/samples/dollartohousetoken/contracts/HouseContract.kt +++ b/Tokens/dollartohousetoken/contracts/src/main/kotlin/net/corda/samples/dollartohousetoken/contracts/HouseContract.kt @@ -2,8 +2,6 @@ package net.corda.samples.dollartohousetoken.contracts import com.r3.corda.lib.tokens.contracts.EvolvableTokenContract import net.corda.core.contracts.Contract -import net.corda.core.contracts.Requirements -import net.corda.core.contracts.requireThat import net.corda.core.transactions.LedgerTransaction import net.corda.samples.dollartohousetoken.states.HouseState @@ -16,7 +14,7 @@ class HouseContract : EvolvableTokenContract(),Contract { } override fun additionalCreateChecks(tx: LedgerTransaction) { // Write contract validation logic to be performed while creation of token - val outputState = tx.getOutput(0) as HouseState + val outputState = tx.outputsOfType()[0] outputState.apply { require(outputState.valuationOfHouse.quantity > 0) {"Valuation cannot be zero"} } diff --git a/Tokens/dollartohousetoken/contracts/src/main/kotlin/net/corda/samples/dollartohousetoken/states/HouseState.kt b/Tokens/dollartohousetoken/contracts/src/main/kotlin/net/corda/samples/dollartohousetoken/states/HouseState.kt index e2159732..7f0491c8 100644 --- a/Tokens/dollartohousetoken/contracts/src/main/kotlin/net/corda/samples/dollartohousetoken/states/HouseState.kt +++ b/Tokens/dollartohousetoken/contracts/src/main/kotlin/net/corda/samples/dollartohousetoken/states/HouseState.kt @@ -1,13 +1,12 @@ package net.corda.samples.dollartohousetoken.states import net.corda.core.contracts.BelongsToContract -import net.corda.core.identity.AbstractParty import com.r3.corda.lib.tokens.contracts.states.EvolvableTokenType import net.corda.core.contracts.Amount import net.corda.core.contracts.UniqueIdentifier import net.corda.core.identity.Party import net.corda.samples.dollartohousetoken.contracts.HouseContract -import java.util.* +import java.util.Currency // ********* diff --git a/Tokens/dollartohousetoken/contracts/src/test/kotlin/net/corda/samples/dollartohousetoken/contracts/ContractTests.kt b/Tokens/dollartohousetoken/contracts/src/test/kotlin/net/corda/samples/dollartohousetoken/contracts/ContractTests.kt index 02c2efc6..0b13f3f5 100644 --- a/Tokens/dollartohousetoken/contracts/src/test/kotlin/net/corda/samples/dollartohousetoken/contracts/ContractTests.kt +++ b/Tokens/dollartohousetoken/contracts/src/test/kotlin/net/corda/samples/dollartohousetoken/contracts/ContractTests.kt @@ -8,22 +8,21 @@ import net.corda.testing.core.TestIdentity import net.corda.testing.node.MockServices import net.corda.testing.node.ledger import org.junit.Test -import java.util.* class ContractTests { private val ledgerServices = MockServices() - val Operator = TestIdentity(CordaX500Name(organisation = "Alice", locality = "TestLand", country = "US")) + private val Operator = TestIdentity(CordaX500Name(organisation = "Alice", locality = "TestLand", country = "US")) //sample tests @Test fun `SerialNumber Cannot Be Empty`() { val tokenPass = HouseState(UniqueIdentifier(), - Arrays.asList(Operator.party), + listOf(Operator.party), Amount.parseCurrency("1000 USD"), 10, "500sqft", "none", "NYC") val tokenFail = HouseState(UniqueIdentifier(), - Arrays.asList(Operator.party), + listOf(Operator.party), Amount.parseCurrency("0 USD"), 10, "500sqft", "none", "NYC") diff --git a/Tokens/dollartohousetoken/contracts/src/test/kotlin/net/corda/samples/dollartohousetoken/contracts/StateTests.kt b/Tokens/dollartohousetoken/contracts/src/test/kotlin/net/corda/samples/dollartohousetoken/contracts/StateTests.kt index 4489f58e..6a009f4b 100644 --- a/Tokens/dollartohousetoken/contracts/src/test/kotlin/net/corda/samples/dollartohousetoken/contracts/StateTests.kt +++ b/Tokens/dollartohousetoken/contracts/src/test/kotlin/net/corda/samples/dollartohousetoken/contracts/StateTests.kt @@ -2,6 +2,7 @@ package net.corda.samples.dollartohousetoken.contracts import net.corda.samples.dollartohousetoken.states.HouseState import net.corda.testing.node.MockServices +import org.junit.Assert.assertEquals import org.junit.Test @@ -14,6 +15,6 @@ class StateTests { fun hasConstructionAreaFieldOfCorrectType() { // Does the message field exist? HouseState::class.java.getDeclaredField("constructionArea") - assert(HouseState::class.java.getDeclaredField("constructionArea").type == String::class.java) + assertEquals(String::class.java, HouseState::class.java.getDeclaredField("constructionArea").type) } } \ No newline at end of file diff --git a/Tokens/dollartohousetoken/gradle.properties b/Tokens/dollartohousetoken/gradle.properties index 645753f5..07480a50 100644 --- a/Tokens/dollartohousetoken/gradle.properties +++ b/Tokens/dollartohousetoken/gradle.properties @@ -1,4 +1,34 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Dollartohousetoken CorDapp group=com.dollartohousetoken version=1.0 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.68.Final + +# Token +tokens_release_group=com.r3.corda.lib.tokens +tokens_release_version=1.2 + +# Confidential Identities (CI) +confidential_id_release_group=com.r3.corda.lib.ci +confidential_id_release_version=1.0 + +spring_boot_version=2.0.2.RELEASE diff --git a/Tokens/dollartohousetoken/gradle/wrapper/gradle-wrapper.jar b/Tokens/dollartohousetoken/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Tokens/dollartohousetoken/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Tokens/dollartohousetoken/gradle/wrapper/gradle-wrapper.properties b/Tokens/dollartohousetoken/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 72f925be..00000000 --- a/Tokens/dollartohousetoken/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip \ No newline at end of file diff --git a/Tokens/dollartohousetoken/gradlew b/Tokens/dollartohousetoken/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Tokens/dollartohousetoken/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Tokens/dollartohousetoken/gradlew.bat b/Tokens/dollartohousetoken/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Tokens/dollartohousetoken/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Tokens/dollartohousetoken/repositories.gradle b/Tokens/dollartohousetoken/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Tokens/dollartohousetoken/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Tokens/dollartohousetoken/settings.gradle b/Tokens/dollartohousetoken/settings.gradle index 2514aca2..45f64fa3 100644 --- a/Tokens/dollartohousetoken/settings.gradle +++ b/Tokens/dollartohousetoken/settings.gradle @@ -1,3 +1,38 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url "$artifactoryContextUrl/corda-lib" + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file diff --git a/Tokens/dollartohousetoken/workflows/build.gradle b/Tokens/dollartohousetoken/workflows/build.gradle index 84e4a2a1..eaf0b4d0 100644 --- a/Tokens/dollartohousetoken/workflows/build.gradle +++ b/Tokens/dollartohousetoken/workflows/build.gradle @@ -1,5 +1,8 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,29 +31,27 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. cordapp project(":contracts") // Token SDK dependencies. - cordaCompile "$tokens_release_group:tokens-workflows:$tokens_release_version" + cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version" + cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version" } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Tokens/dollartohousetoken/workflows/src/integrationTest/kotlin/net/corda/samples/dollartohousetoken/DriverBasedTest.kt b/Tokens/dollartohousetoken/workflows/src/integrationTest/kotlin/net/corda/samples/dollartohousetoken/DriverBasedTest.kt index 411a4b99..601ec878 100644 --- a/Tokens/dollartohousetoken/workflows/src/integrationTest/kotlin/net/corda/samples/dollartohousetoken/DriverBasedTest.kt +++ b/Tokens/dollartohousetoken/workflows/src/integrationTest/kotlin/net/corda/samples/dollartohousetoken/DriverBasedTest.kt @@ -7,9 +7,9 @@ import net.corda.testing.driver.DriverDSL import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.driver +import org.junit.Assert.assertEquals import org.junit.Test import java.util.concurrent.Future -import kotlin.test.assertEquals class DriverBasedTest { private val bankA = TestIdentity(CordaX500Name("BankA", "", "GB")) diff --git a/Tokens/dollartohousetoken/workflows/src/main/kotlin/net/corda/samples/dollartohousetoken/flows/CreateAndIssueHouseToken.kt b/Tokens/dollartohousetoken/workflows/src/main/kotlin/net/corda/samples/dollartohousetoken/flows/CreateAndIssueHouseToken.kt index 16881e9c..65145058 100644 --- a/Tokens/dollartohousetoken/workflows/src/main/kotlin/net/corda/samples/dollartohousetoken/flows/CreateAndIssueHouseToken.kt +++ b/Tokens/dollartohousetoken/workflows/src/main/kotlin/net/corda/samples/dollartohousetoken/flows/CreateAndIssueHouseToken.kt @@ -15,7 +15,8 @@ import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party import net.corda.core.utilities.ProgressTracker import net.corda.samples.dollartohousetoken.states.HouseState -import java.util.* +import java.util.Currency +import java.util.UUID // ********* // * Flows * @@ -40,7 +41,7 @@ class CreateAndIssueHouseToken(val owner: Party, /* Construct the output state */ val uuid = fromString(UUID.randomUUID().toString()) - val houseState = HouseState(UniqueIdentifier(),Arrays.asList(issuer),valuationOfHouse,noOfBedRooms,constructionArea,additionInfo,address) + val houseState = HouseState(UniqueIdentifier(), listOf(issuer),valuationOfHouse,noOfBedRooms,constructionArea,additionInfo,address) /* Create an instance of TransactionState using the houseState token and the notary */ val transactionState = houseState withNotary notary!! diff --git a/Tokens/dollartohousetoken/workflows/src/main/kotlin/net/corda/samples/dollartohousetoken/flows/FiatCurrencyIssueFlow.kt b/Tokens/dollartohousetoken/workflows/src/main/kotlin/net/corda/samples/dollartohousetoken/flows/FiatCurrencyIssueFlow.kt index 79d182b8..a58c9d93 100644 --- a/Tokens/dollartohousetoken/workflows/src/main/kotlin/net/corda/samples/dollartohousetoken/flows/FiatCurrencyIssueFlow.kt +++ b/Tokens/dollartohousetoken/workflows/src/main/kotlin/net/corda/samples/dollartohousetoken/flows/FiatCurrencyIssueFlow.kt @@ -1,10 +1,7 @@ package net.corda.samples.dollartohousetoken.flows import co.paralleluniverse.fibers.Suspendable -import com.r3.corda.lib.tokens.contracts.internal.schemas.FungibleTokenSchema import com.r3.corda.lib.tokens.contracts.states.FungibleToken -import com.r3.corda.lib.tokens.contracts.types.IssuedTokenType -import com.r3.corda.lib.tokens.contracts.types.TokenType import com.r3.corda.lib.tokens.contracts.utilities.issuedBy import com.r3.corda.lib.tokens.money.FiatCurrency import com.r3.corda.lib.tokens.workflows.flows.rpc.IssueTokens diff --git a/Tokens/dollartohousetoken/workflows/src/main/kotlin/net/corda/samples/dollartohousetoken/flows/HouseSale.kt b/Tokens/dollartohousetoken/workflows/src/main/kotlin/net/corda/samples/dollartohousetoken/flows/HouseSale.kt index 284d4b3f..2da603cb 100644 --- a/Tokens/dollartohousetoken/workflows/src/main/kotlin/net/corda/samples/dollartohousetoken/flows/HouseSale.kt +++ b/Tokens/dollartohousetoken/workflows/src/main/kotlin/net/corda/samples/dollartohousetoken/flows/HouseSale.kt @@ -14,7 +14,6 @@ import net.corda.core.contracts.UniqueIdentifier import net.corda.core.flows.* import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party -import net.corda.core.node.services.Vault import net.corda.core.node.services.queryBy import net.corda.core.node.services.vault.QueryCriteria import net.corda.core.transactions.SignedTransaction @@ -22,8 +21,8 @@ import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.ProgressTracker import net.corda.core.utilities.unwrap import net.corda.samples.dollartohousetoken.states.HouseState -import org.checkerframework.common.aliasing.qual.Unique -import java.util.* +import java.util.Currency +import java.util.UUID // ********* // * Flows * @@ -64,7 +63,7 @@ class HouseSale(val houseId: String, val inputs = subFlow(ReceiveStateAndRefFlow(buyerSession)) // Recieve output for the fiat currency from the buyer, this would contain the transfered amount from buyer to yourself - val moneyReceived: List = buyerSession.receive>().unwrap { it -> it} + val moneyReceived: List = buyerSession.receive>().unwrap { it } /* Create a fiat currency proposal for the house token using the helper function provided by Token SDK. */ addMoveTokens(txBuilder, inputs, moneyReceived) diff --git a/Tokens/dollartohousetoken/workflows/src/test/kotlin/net/corda/samples/dollartohousetoken/FlowTests.kt b/Tokens/dollartohousetoken/workflows/src/test/kotlin/net/corda/samples/dollartohousetoken/FlowTests.kt index 16c88d1a..7c0f0782 100644 --- a/Tokens/dollartohousetoken/workflows/src/test/kotlin/net/corda/samples/dollartohousetoken/FlowTests.kt +++ b/Tokens/dollartohousetoken/workflows/src/test/kotlin/net/corda/samples/dollartohousetoken/FlowTests.kt @@ -1,6 +1,5 @@ package net.corda.samples.dollartohousetoken -import com.google.common.collect.ImmutableList import net.corda.core.contracts.Amount import net.corda.core.identity.CordaX500Name import net.corda.core.node.services.Vault.StateStatus @@ -13,15 +12,14 @@ import net.corda.testing.node.* import org.junit.After import org.junit.Before import org.junit.Test -import java.util.* +import java.util.UUID import java.util.concurrent.Future import kotlin.test.assertEquals - class FlowTests { - private var network: MockNetwork? = null - private var a: StartedMockNode? = null - private var b: StartedMockNode? = null + private lateinit var network: MockNetwork + private lateinit var a: StartedMockNode + private lateinit var b: StartedMockNode @Before fun setup() { @@ -33,30 +31,32 @@ class FlowTests { ), networkParameters = testNetworkParameters(minimumPlatformVersion = 4), notarySpecs = listOf(MockNetworkNotarySpec(CordaX500Name("Notary","London","GB"))) )) - a = network!!.createPartyNode(null) - b = network!!.createPartyNode(null) - network!!.runNetwork() + a = network.createPartyNode(null) + b = network.createPartyNode(null) + network.runNetwork() } @After fun tearDown() { - network!!.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test fun houseTokenStateCreation() { - val createAndIssueFlow = CreateAndIssueHouseToken(b!!.info.legalIdentities[0], + val createAndIssueFlow = CreateAndIssueHouseToken(b.info.legalIdentities[0], Amount.parseCurrency("1000 USD"), 10, "500 sqft", "NA", "NYC") - val future: Future = a!!.startFlow(createAndIssueFlow) - network!!.runNetwork() + val future: Future = a.startFlow(createAndIssueFlow) + network.runNetwork() val resultString = future.get() println(resultString) - val subString = resultString.indexOf("UUID: "); + val subString = resultString.indexOf("UUID: ") val nonfungibleTokenId = resultString.substring(subString + 6, resultString.indexOf(". (This")) - println("-" + nonfungibleTokenId + "-") - val inputCriteria: QueryCriteria = LinearStateQueryCriteria().withUuid(Arrays.asList(UUID.fromString(nonfungibleTokenId))).withStatus(StateStatus.UNCONSUMED) - val storedNonFungibleTokenb = b!!.services.vaultService.queryBy(HouseState::class.java, inputCriteria).states + println("-$nonfungibleTokenId-") + val inputCriteria: QueryCriteria = LinearStateQueryCriteria().withUuid(listOf(UUID.fromString(nonfungibleTokenId))).withStatus(StateStatus.UNCONSUMED) + val storedNonFungibleTokenb = b.services.vaultService.queryBy(HouseState::class.java, inputCriteria).states val (linearId) = storedNonFungibleTokenb[0].state.data println("-$linearId-") assertEquals(linearId.toString(), nonfungibleTokenId) diff --git a/Tokens/fungiblehousetoken/README.md b/Tokens/fungiblehousetoken/README.md index a1685493..269c8405 100644 --- a/Tokens/fungiblehousetoken/README.md +++ b/Tokens/fungiblehousetoken/README.md @@ -29,7 +29,7 @@ For development environment setup, please refer to: [Setup Guide](https://docs.c Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper) ``` -./gradlew clean deployNodes +../gradlew clean deployNodes ``` Then type: (to run the nodes) ``` diff --git a/Tokens/fungiblehousetoken/build.gradle b/Tokens/fungiblehousetoken/build.gradle index 3fa4d4c2..264d7eaa 100644 --- a/Tokens/fungiblehousetoken/build.gradle +++ b/Tokens/fungiblehousetoken/build.gradle @@ -1,114 +1,75 @@ -buildscript { - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - - //TokenSDK - tokens_release_group = 'com.r3.corda.lib.tokens' - tokens_release_version = '1.2' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } - //SDK lib - maven { url 'https://software.r3.com/artifactory/corda-lib' } - //Gradle Plugins - maven { url 'https://repo.gradle.org/gradle/libs-releases' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") - - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordapp project(':workflows') + cordapp project(':contracts') // Token SDK dependencies. cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version" cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version" + + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" } -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp("$tokens_release_group:tokens-contracts:$tokens_release_version") cordapp("$tokens_release_group:tokens-workflows:$tokens_release_version") cordapp project(':contracts') cordapp project(':workflows') - runSchemaMigration = true + rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { name "O=Notary,L=London,C=GB" @@ -118,7 +79,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } - cordapps = [] + rpcUsers = [] } node { name "O=Seller,L=London,C=GB" @@ -127,7 +88,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=Buyer,L=New York,C=US" @@ -136,7 +96,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10049") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=Friend,L=Paris,C=FR" @@ -145,14 +104,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10013") adminAddress("localhost:10014") } - rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]] - } -} - -task installQuasar(type: Copy) { - destinationDir rootProject.file("lib") - from(configurations.quasar) { - rename 'quasar-core(.*).jar', 'quasar.jar' } } - diff --git a/Tokens/fungiblehousetoken/contracts/build.gradle b/Tokens/fungiblehousetoken/contracts/build.gradle index c545ebdf..4766a24e 100644 --- a/Tokens/fungiblehousetoken/contracts/build.gradle +++ b/Tokens/fungiblehousetoken/contracts/build.gradle @@ -1,4 +1,7 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -15,12 +18,13 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" // Token SDK dependencies. - cordaCompile "$tokens_release_group:tokens-contracts:$tokens_release_version" -} \ No newline at end of file + cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version" +} diff --git a/Tokens/fungiblehousetoken/contracts/src/main/kotlin/net/corda/samples/tokenizedhouse/contracts/HouseTokenStateContract.kt b/Tokens/fungiblehousetoken/contracts/src/main/kotlin/net/corda/samples/tokenizedhouse/contracts/HouseTokenStateContract.kt index aec5cbaa..5f34f4f9 100644 --- a/Tokens/fungiblehousetoken/contracts/src/main/kotlin/net/corda/samples/tokenizedhouse/contracts/HouseTokenStateContract.kt +++ b/Tokens/fungiblehousetoken/contracts/src/main/kotlin/net/corda/samples/tokenizedhouse/contracts/HouseTokenStateContract.kt @@ -14,7 +14,7 @@ class HouseTokenStateContract : EvolvableTokenContract(), Contract { } override fun additionalCreateChecks(tx: LedgerTransaction) { // Write contract validation logic to be performed while creation of token - val outputState = tx.getOutput(0) as FungibleHouseTokenState + val outputState = tx.outputsOfType()[0] outputState.apply { require(outputState.valuation > 0) {"Valuation must be greater than zero"} } diff --git a/Tokens/fungiblehousetoken/contracts/src/test/kotlin/net/corda/samples/tokenizedhouse/contracts/StateTests.kt b/Tokens/fungiblehousetoken/contracts/src/test/kotlin/net/corda/samples/tokenizedhouse/contracts/StateTests.kt index 4a3c8ec2..68601216 100644 --- a/Tokens/fungiblehousetoken/contracts/src/test/kotlin/net/corda/samples/tokenizedhouse/contracts/StateTests.kt +++ b/Tokens/fungiblehousetoken/contracts/src/test/kotlin/net/corda/samples/tokenizedhouse/contracts/StateTests.kt @@ -1,19 +1,17 @@ package net.corda.samples.tokenizedhouse.contracts import net.corda.samples.tokenizedhouse.states.FungibleHouseTokenState -import net.corda.testing.node.MockServices +import org.junit.Assert.assertEquals import org.junit.Test class StateTests { - private val ledgerServices = MockServices() - //sample State tests @Test @Throws(NoSuchFieldException::class) fun hasConstructionAreaFieldOfCorrectType() { // Does the message field exist? FungibleHouseTokenState::class.java.getDeclaredField("symbol") - assert(FungibleHouseTokenState::class.java.getDeclaredField("symbol").type == String::class.java) + assertEquals(String::class.java, FungibleHouseTokenState::class.java.getDeclaredField("symbol").type) } } \ No newline at end of file diff --git a/Tokens/fungiblehousetoken/gradle.properties b/Tokens/fungiblehousetoken/gradle.properties index c1f11cdb..6942cb0e 100644 --- a/Tokens/fungiblehousetoken/gradle.properties +++ b/Tokens/fungiblehousetoken/gradle.properties @@ -1,4 +1,34 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=fungiblehousetoken Cordapp group=com.fungiblehousetoken version=1.0 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.68.Final + +# Token +tokens_release_group=com.r3.corda.lib.tokens +tokens_release_version=1.2 + +# Confidential Identities (CI) +confidential_id_release_group=com.r3.corda.lib.ci +confidential_id_release_version=1.0 + +spring_boot_version=2.0.2.RELEASE diff --git a/Tokens/fungiblehousetoken/gradle/wrapper/gradle-wrapper.jar b/Tokens/fungiblehousetoken/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Tokens/fungiblehousetoken/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Tokens/fungiblehousetoken/gradle/wrapper/gradle-wrapper.properties b/Tokens/fungiblehousetoken/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Tokens/fungiblehousetoken/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Tokens/fungiblehousetoken/gradlew b/Tokens/fungiblehousetoken/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Tokens/fungiblehousetoken/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Tokens/fungiblehousetoken/gradlew.bat b/Tokens/fungiblehousetoken/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Tokens/fungiblehousetoken/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Tokens/fungiblehousetoken/repositories.gradle b/Tokens/fungiblehousetoken/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Tokens/fungiblehousetoken/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Tokens/fungiblehousetoken/settings.gradle b/Tokens/fungiblehousetoken/settings.gradle index 2514aca2..45f64fa3 100644 --- a/Tokens/fungiblehousetoken/settings.gradle +++ b/Tokens/fungiblehousetoken/settings.gradle @@ -1,3 +1,38 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url "$artifactoryContextUrl/corda-lib" + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file diff --git a/Tokens/fungiblehousetoken/workflows/build.gradle b/Tokens/fungiblehousetoken/workflows/build.gradle index d81f2cbc..cfdb929d 100644 --- a/Tokens/fungiblehousetoken/workflows/build.gradle +++ b/Tokens/fungiblehousetoken/workflows/build.gradle @@ -1,5 +1,8 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,29 +31,27 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. cordapp project(":contracts") // Token SDK dependencies. - cordaCompile "$tokens_release_group:tokens-workflows:$tokens_release_version" + cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version" + cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version" } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Tokens/fungiblehousetoken/workflows/src/integrationTest/kotlin/net/corda/samples/tokenizedhouse/DriverBasedTest.kt b/Tokens/fungiblehousetoken/workflows/src/integrationTest/kotlin/net/corda/samples/tokenizedhouse/DriverBasedTest.kt index dd13eb60..e7c1f021 100644 --- a/Tokens/fungiblehousetoken/workflows/src/integrationTest/kotlin/net/corda/samples/tokenizedhouse/DriverBasedTest.kt +++ b/Tokens/fungiblehousetoken/workflows/src/integrationTest/kotlin/net/corda/samples/tokenizedhouse/DriverBasedTest.kt @@ -7,9 +7,9 @@ import net.corda.testing.driver.DriverDSL import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.driver +import org.junit.Assert.assertEquals import org.junit.Test import java.util.concurrent.Future -import kotlin.test.assertEquals class DriverBasedTest { private val bankA = TestIdentity(CordaX500Name("BankA", "", "GB")) diff --git a/Tokens/fungiblehousetoken/workflows/src/main/kotlin/net/corda/samples/tokenizedhouse/flows/CreateHouseTokenFlow.kt b/Tokens/fungiblehousetoken/workflows/src/main/kotlin/net/corda/samples/tokenizedhouse/flows/CreateHouseTokenFlow.kt index 6a61b3a6..c7b3a787 100644 --- a/Tokens/fungiblehousetoken/workflows/src/main/kotlin/net/corda/samples/tokenizedhouse/flows/CreateHouseTokenFlow.kt +++ b/Tokens/fungiblehousetoken/workflows/src/main/kotlin/net/corda/samples/tokenizedhouse/flows/CreateHouseTokenFlow.kt @@ -8,7 +8,6 @@ import net.corda.core.flows.* import net.corda.core.identity.CordaX500Name import net.corda.core.utilities.ProgressTracker import net.corda.samples.tokenizedhouse.states.FungibleHouseTokenState -import java.math.BigDecimal // ********* // * Flows * diff --git a/Tokens/fungiblehousetoken/workflows/src/main/kotlin/net/corda/samples/tokenizedhouse/flows/GetTokenBalance.kt b/Tokens/fungiblehousetoken/workflows/src/main/kotlin/net/corda/samples/tokenizedhouse/flows/GetTokenBalance.kt index 2238ae98..d76df706 100644 --- a/Tokens/fungiblehousetoken/workflows/src/main/kotlin/net/corda/samples/tokenizedhouse/flows/GetTokenBalance.kt +++ b/Tokens/fungiblehousetoken/workflows/src/main/kotlin/net/corda/samples/tokenizedhouse/flows/GetTokenBalance.kt @@ -23,7 +23,7 @@ class GetTokenBalance(val symbol:String) : FlowLogic() { override fun call():String { //get house states on ledger with uuid as input tokenId val stateAndRef = serviceHub.vaultService.queryBy() - .states.filter { it.state.data.symbol.equals(symbol) }[0] + .states.filter { it.state.data.symbol == symbol }[0] //get the Token State object val evolvableTokenType = stateAndRef.state.data @@ -33,7 +33,7 @@ class GetTokenBalance(val symbol:String) : FlowLogic() { //retrieve amount val amount: Amount = serviceHub.vaultService.tokenBalance(tokenPointer) - return "\n You currently have " + amount.quantity + " " + symbol + " Tokens issued by "+evolvableTokenType.maintainer.name.organisation+"\n"; + return "\n You currently have " + amount.quantity + " " + symbol + " Tokens issued by "+evolvableTokenType.maintainer.name.organisation+"\n" } } diff --git a/Tokens/fungiblehousetoken/workflows/src/main/kotlin/net/corda/samples/tokenizedhouse/flows/IssueHouseTokenFlow.kt b/Tokens/fungiblehousetoken/workflows/src/main/kotlin/net/corda/samples/tokenizedhouse/flows/IssueHouseTokenFlow.kt index 2a78e69c..275554d9 100644 --- a/Tokens/fungiblehousetoken/workflows/src/main/kotlin/net/corda/samples/tokenizedhouse/flows/IssueHouseTokenFlow.kt +++ b/Tokens/fungiblehousetoken/workflows/src/main/kotlin/net/corda/samples/tokenizedhouse/flows/IssueHouseTokenFlow.kt @@ -27,7 +27,7 @@ class IssueHouseTokenFlow(val symbol: String, //get house states on ledger with uuid as input tokenId val stateAndRef = serviceHub.vaultService.queryBy() - .states.filter { it.state.data.symbol.equals(symbol) }[0] + .states.filter { it.state.data.symbol == symbol }[0] //get the RealEstateEvolvableTokenType object val evolvableTokenType = stateAndRef.state.data diff --git a/Tokens/fungiblehousetoken/workflows/src/main/kotlin/net/corda/samples/tokenizedhouse/flows/MoveHouseTokenFlow.kt b/Tokens/fungiblehousetoken/workflows/src/main/kotlin/net/corda/samples/tokenizedhouse/flows/MoveHouseTokenFlow.kt index 4171e852..04a9485b 100644 --- a/Tokens/fungiblehousetoken/workflows/src/main/kotlin/net/corda/samples/tokenizedhouse/flows/MoveHouseTokenFlow.kt +++ b/Tokens/fungiblehousetoken/workflows/src/main/kotlin/net/corda/samples/tokenizedhouse/flows/MoveHouseTokenFlow.kt @@ -26,7 +26,7 @@ class MoveHouseTokenFlow(val symbol: String, override fun call():String { //get house states on ledger with uuid as input tokenId val stateAndRef = serviceHub.vaultService.queryBy() - .states.filter { it.state.data.symbol.equals(symbol) }[0] + .states.filter { it.state.data.symbol == symbol }[0] //get the RealEstateEvolvableTokenType object val evolvableTokenType = stateAndRef.state.data diff --git a/Tokens/fungiblehousetoken/workflows/src/test/kotlin/net/corda/samples/tokenizedhouse/FlowTests.kt b/Tokens/fungiblehousetoken/workflows/src/test/kotlin/net/corda/samples/tokenizedhouse/FlowTests.kt index bcc841f3..ec293be2 100644 --- a/Tokens/fungiblehousetoken/workflows/src/test/kotlin/net/corda/samples/tokenizedhouse/FlowTests.kt +++ b/Tokens/fungiblehousetoken/workflows/src/test/kotlin/net/corda/samples/tokenizedhouse/FlowTests.kt @@ -1,22 +1,22 @@ package net.corda.samples.tokenizedhouse import net.corda.core.identity.CordaX500Name -import net.corda.core.transactions.SignedTransaction import net.corda.samples.tokenizedhouse.flows.CreateHouseTokenFlow import net.corda.samples.tokenizedhouse.flows.IssueHouseTokenFlow import net.corda.samples.tokenizedhouse.states.FungibleHouseTokenState import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.node.* import org.junit.After +import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test import java.util.concurrent.ExecutionException import java.util.concurrent.Future class FlowTests { - private var network: MockNetwork? = null - private var a: StartedMockNode? = null - private var b: StartedMockNode? = null + private lateinit var network: MockNetwork + private lateinit var a: StartedMockNode + private lateinit var b: StartedMockNode @Before fun setup() { @@ -28,45 +28,47 @@ class FlowTests { ), networkParameters = testNetworkParameters(minimumPlatformVersion = 4), notarySpecs = listOf(MockNetworkNotarySpec(CordaX500Name("Notary","London","GB"))) )) - a = network!!.createPartyNode(null) - b = network!!.createPartyNode(null) - network!!.runNetwork() + a = network.createPartyNode(null) + b = network.createPartyNode(null) + network.runNetwork() } @After fun tearDown() { - network!!.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test @Throws(ExecutionException::class, InterruptedException::class) fun houseTokenStateCreation() { - val createFlow = CreateHouseTokenFlow( "NYCHelena",1000000) - val future: Future = a!!.startFlow(createFlow) - network!!.runNetwork() + val createFlow = CreateHouseTokenFlow("NYCHelena", 1000000) + val future: Future = a.startFlow(createFlow) + network.runNetwork() //get house states on ledger with uuid as input tokenId - val (state) = a!!.services.vaultService.queryBy(FungibleHouseTokenState::class.java).states.stream() + val (state) = a.services.vaultService.queryBy(FungibleHouseTokenState::class.java).states.stream() .filter { (state) -> state.data.symbol == "NYCHelena" }.findAny() .orElseThrow { IllegalArgumentException("FungibleHouseTokenState not found from vault") } //get the RealEstateEvolvableTokenType object val (valuation) = state.data - assert(valuation == 1000000) + assertEquals(1000000, valuation) } @Test @Throws(ExecutionException::class, InterruptedException::class) fun houseTokenStateIssuance() { val createFlow = CreateHouseTokenFlow("NYCHelena", 1000000) - val future: Future = a!!.startFlow(createFlow) - network!!.runNetwork() - val issueFlow = IssueHouseTokenFlow("NYCHelena", 20, b!!.info.legalIdentities[0]) - val future2: Future = a!!.startFlow(issueFlow) - network!!.runNetwork() + val future: Future = a.startFlow(createFlow) + network.runNetwork() + val issueFlow = IssueHouseTokenFlow("NYCHelena", 20, b.info.legalIdentities[0]) + val future2: Future = a.startFlow(issueFlow) + network.runNetwork() //get house states on ledger with uuid as input tokenId - val (state) = b!!.services.vaultService.queryBy(FungibleHouseTokenState::class.java).states.stream() + val (state) = b.services.vaultService.queryBy(FungibleHouseTokenState::class.java).states.stream() .filter { (state) -> state.data.symbol == "NYCHelena" }.findAny() .orElseThrow { java.lang.IllegalArgumentException("FungibleHouseTokenState not found from vault") } diff --git a/Tokens/gradle/wrapper/gradle-wrapper.jar b/Tokens/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..41d9927a Binary files /dev/null and b/Tokens/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Tokens/gradle/wrapper/gradle-wrapper.properties b/Tokens/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..aa991fce --- /dev/null +++ b/Tokens/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Tokens/gradlew b/Tokens/gradlew new file mode 100755 index 00000000..1b6c7873 --- /dev/null +++ b/Tokens/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/Tokens/gradlew.bat b/Tokens/gradlew.bat new file mode 100644 index 00000000..107acd32 --- /dev/null +++ b/Tokens/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/Tokens/settings.gradle b/Tokens/settings.gradle new file mode 100644 index 00000000..888f9a8a --- /dev/null +++ b/Tokens/settings.gradle @@ -0,0 +1,5 @@ +includeBuild 'bikemarket' +includeBuild 'dollartohousetoken' +includeBuild 'fungiblehousetoken' +includeBuild 'stockpaydividend' +includeBuild 'tokentofriend' diff --git a/Tokens/stockpaydividend/README.md b/Tokens/stockpaydividend/README.md old mode 100755 new mode 100644 diff --git a/Tokens/stockpaydividend/build.gradle b/Tokens/stockpaydividend/build.gradle index d951bcb6..b2aa50e7 100644 --- a/Tokens/stockpaydividend/build.gradle +++ b/Tokens/stockpaydividend/build.gradle @@ -1,117 +1,73 @@ -buildscript { - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - - //corda_gradle_plugins_version = '4.0.45' - - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - - //token - tokens_release_group = 'com.r3.corda.lib.tokens' - tokens_release_version = '1.2' - - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } - //SDK lib - maven { url 'https://software.r3.com/artifactory/corda-lib' } - //Gradle Plugins - maven { url 'https://repo.gradle.org/gradle/libs-releases' } +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") + cordapp project(':workflows') + cordapp project(':contracts') - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" // Token SDK dependencies. cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version" cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version" } -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { +tasks.register('deployNodes', Cordform) { + /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them + * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand + * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load + * the Corda network bootstrapper. + */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp("$tokens_release_group:tokens-contracts:$tokens_release_version") cordapp("$tokens_release_group:tokens-workflows:$tokens_release_version") cordapp project(':contracts') cordapp project(':workflows') - runSchemaMigration = true + rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] + runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid + //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change + //it to false for quicker project compiling time. } node { name "O=Notary,L=London,C=GB" @@ -121,7 +77,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10033") } - cordapps = [] + rpcUsers = [] } node { name "O=WayneCo,L=SF,C=US" @@ -130,7 +86,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10036") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=Shareholder,L=New York,C=US" @@ -139,7 +94,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10009") adminAddress("localhost:10039") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=Bank,L=Washington DC,C=US" @@ -148,7 +102,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10013") adminAddress("localhost:10043") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } node { name "O=Observer,L=Washington DC,C=US" @@ -157,14 +110,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10016") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } } - -task installQuasar(type: Copy) { - destinationDir rootProject.file("lib") - from(configurations.quasar) { - rename 'quasar-core(.*).jar', 'quasar.jar' - } -} - diff --git a/Tokens/stockpaydividend/contracts/build.gradle b/Tokens/stockpaydividend/contracts/build.gradle index 5f712022..53301b05 100644 --- a/Tokens/stockpaydividend/contracts/build.gradle +++ b/Tokens/stockpaydividend/contracts/build.gradle @@ -1,4 +1,7 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -15,12 +18,13 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // Token SDK dependencies. - cordaCompile "$tokens_release_group:tokens-contracts:$tokens_release_version" + cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version" } \ No newline at end of file diff --git a/Tokens/stockpaydividend/contracts/src/main/kotlin/net/corda/samples/stockpaydividend/contracts/DividendContract.kt b/Tokens/stockpaydividend/contracts/src/main/kotlin/net/corda/samples/stockpaydividend/contracts/DividendContract.kt index 103bb222..f4c77150 100644 --- a/Tokens/stockpaydividend/contracts/src/main/kotlin/net/corda/samples/stockpaydividend/contracts/DividendContract.kt +++ b/Tokens/stockpaydividend/contracts/src/main/kotlin/net/corda/samples/stockpaydividend/contracts/DividendContract.kt @@ -4,6 +4,7 @@ import net.corda.core.contracts.CommandData import net.corda.core.contracts.Contract import net.corda.core.contracts.requireSingleCommand import net.corda.core.contracts.requireThat +import net.corda.core.identity.AbstractParty import net.corda.core.transactions.LedgerTransaction import net.corda.samples.stockpaydividend.states.DividendState import java.security.PublicKey @@ -20,7 +21,7 @@ class DividendContract : Contract { // A transaction is valid if the verify() function of the contract of all the transaction's input and output states // does not throw an exception. override fun verify(tx: LedgerTransaction) { - val command = tx.commands.requireSingleCommand() + val command = tx.commands.requireSingleCommand() val requiredSigners = command.signers when(command.value){ @@ -36,28 +37,28 @@ class DividendContract : Contract { private fun verifyCreate(tx: LedgerTransaction, requiredSigners: List) { requireThat { // Add any validations that may fit - val outputDividends: List = tx.outputsOfType(DividendState::class.java) - "There must be one output dividend.".using(outputDividends.size == 1) + val outputDividends = tx.outputsOfType() + "There must be exactly one output dividend.".using(outputDividends.size == 1) val outputDividend = outputDividends[0] "Company and shareholder of the dividend should not be the same.".using(outputDividend.shareholder != outputDividend.company) - "Both stock shareholder and company must sign the dividend receivable transaction.".using(requiredSigners.containsAll(keysFromParticipants(outputDividend)!!)) + "Both stock shareholder and company must sign the dividend receivable transaction.".using(requiredSigners.containsAll(keysFromParticipants(outputDividend))) } } private fun verifyPay(tx: LedgerTransaction, requiredSigners: List) { requireThat{ - val inputDividends: List = tx.inputsOfType(DividendState::class.java) + val inputDividends = tx.inputsOfType() "There must be one input dividend.".using(inputDividends.size == 1) - val outputDividends: List = tx.outputsOfType(DividendState::class.java) + val outputDividends = tx.outputsOfType() "There should be no output dividends.".using(outputDividends.isEmpty()) val inputDividend = inputDividends[0] - "Both stock shareholder and company must sign the dividend receivable transaction.".using(requiredSigners.containsAll(keysFromParticipants(inputDividend)!!)) + "Both stock shareholder and company must sign the dividend receivable transaction.".using(requiredSigners.containsAll(keysFromParticipants(inputDividend))) } } - private fun keysFromParticipants(dividend: DividendState): Set? { - return dividend.participants.map { it.owningKey }.toSet() + private fun keysFromParticipants(dividend: DividendState): Set { + return dividend.participants.mapTo(LinkedHashSet(), AbstractParty::owningKey) } // Used to indicate the transaction's intent. diff --git a/Tokens/stockpaydividend/contracts/src/main/kotlin/net/corda/samples/stockpaydividend/contracts/StockContract.kt b/Tokens/stockpaydividend/contracts/src/main/kotlin/net/corda/samples/stockpaydividend/contracts/StockContract.kt index be842f5b..6cf80a3f 100644 --- a/Tokens/stockpaydividend/contracts/src/main/kotlin/net/corda/samples/stockpaydividend/contracts/StockContract.kt +++ b/Tokens/stockpaydividend/contracts/src/main/kotlin/net/corda/samples/stockpaydividend/contracts/StockContract.kt @@ -20,7 +20,7 @@ class StockContract : EvolvableTokenContract(),Contract { @Throws(IllegalArgumentException::class) override fun verify(tx: LedgerTransaction) { - val outputState: StockState = tx.getOutput(0) as StockState + val outputState = tx.getOutput(0) as StockState if (!tx.getCommand(0).signers.contains(outputState.issuer.owningKey)) throw IllegalArgumentException("Company Signature Required") // Dispatch based on command. val command = tx.commands.requireSingleCommand() @@ -32,20 +32,20 @@ class StockContract : EvolvableTokenContract(),Contract { override fun additionalCreateChecks(tx: LedgerTransaction) { // Number of outputs is guaranteed as 1 - val createdStockState: StockState = tx.outputsOfType(StockState::class.java)[0] - requireThat{ + val createdStockState = tx.outputsOfType()[0] + requireThat { //Validations when creating a new stock - "Stock symbol must not be empty".using(!createdStockState.symbol.isEmpty()) - "Stock name must not be empty".using(!createdStockState.name.isEmpty()) - "Stock dividend must start with zero".using(createdStockState.dividend.equals(BigDecimal.ZERO)) + "Stock symbol must not be empty".using(createdStockState.symbol.isNotEmpty()) + "Stock name must not be empty".using(createdStockState.name.isNotEmpty()) + "Stock dividend must start with zero".using(createdStockState.dividend == BigDecimal.ZERO) } } override fun additionalUpdateChecks(tx: LedgerTransaction) { // Number of inputs and outputs are guaranteed as 1 - val input: StockState = tx.inputsOfType(StockState::class.java)[0] - val output: StockState = tx.outputsOfType(StockState::class.java)[0] - requireThat{ - //Validations when a stock is updated, ie. AnnounceDividend (UpdateEvolvableToken) + val input = tx.inputsOfType().single() + val output = tx.outputsOfType().single() + requireThat { + //Validations when a stock is updated, i.e. AnnounceDividend (UpdateEvolvableToken) "Stock Symbol must not be changed.".using(input.symbol == output.symbol) "Stock Currency must not be changed.".using(input.currency == output.currency) "Stock Name must not be changed.".using(input.name == output.name) diff --git a/Tokens/stockpaydividend/contracts/src/main/kotlin/net/corda/samples/stockpaydividend/states/StockState.kt b/Tokens/stockpaydividend/contracts/src/main/kotlin/net/corda/samples/stockpaydividend/states/StockState.kt index edc4fdd0..39fe5831 100644 --- a/Tokens/stockpaydividend/contracts/src/main/kotlin/net/corda/samples/stockpaydividend/states/StockState.kt +++ b/Tokens/stockpaydividend/contracts/src/main/kotlin/net/corda/samples/stockpaydividend/states/StockState.kt @@ -3,12 +3,11 @@ package net.corda.samples.stockpaydividend.states import com.r3.corda.lib.tokens.contracts.states.EvolvableTokenType import net.corda.core.contracts.BelongsToContract import net.corda.core.contracts.UniqueIdentifier -import net.corda.core.identity.AbstractParty import net.corda.core.identity.Party import net.corda.core.schemas.StatePersistable import net.corda.samples.stockpaydividend.contracts.StockContract import java.math.BigDecimal -import java.util.* +import java.util.Date // ********* // * State * diff --git a/Tokens/stockpaydividend/contracts/src/test/kotlin/net/corda/samples/stockpaydividend/contracts/ContractTests.kt b/Tokens/stockpaydividend/contracts/src/test/kotlin/net/corda/samples/stockpaydividend/contracts/ContractTests.kt index 7a42b06f..e2c42090 100644 --- a/Tokens/stockpaydividend/contracts/src/test/kotlin/net/corda/samples/stockpaydividend/contracts/ContractTests.kt +++ b/Tokens/stockpaydividend/contracts/src/test/kotlin/net/corda/samples/stockpaydividend/contracts/ContractTests.kt @@ -8,7 +8,7 @@ import net.corda.testing.node.MockServices import net.corda.testing.node.ledger import org.junit.Test import java.math.BigDecimal -import java.util.* +import java.util.Date class ContractTests { private val ledgerServices = MockServices() @@ -18,7 +18,7 @@ class ContractTests { @Test fun `multiple Output Tests`() { val tokenPass = StockState(Operator.party, "TT", "Test Token", - "USD", BigDecimal.valueOf(2.7), BigDecimal.valueOf(0.2), Date(), Date(), UniqueIdentifier() + "USD", BigDecimal.valueOf(2.7), BigDecimal.ZERO, Date(), Date(), UniqueIdentifier() ) val tokenFail = StockState(Operator.party, "", "Test Token", "USD", BigDecimal.valueOf(2.7), BigDecimal.valueOf(0.2), Date(), Date(), UniqueIdentifier() diff --git a/Tokens/stockpaydividend/contracts/src/test/kotlin/net/corda/samples/stockpaydividend/contracts/StateTests.kt b/Tokens/stockpaydividend/contracts/src/test/kotlin/net/corda/samples/stockpaydividend/contracts/StateTests.kt index ce7637b6..3d1775e7 100644 --- a/Tokens/stockpaydividend/contracts/src/test/kotlin/net/corda/samples/stockpaydividend/contracts/StateTests.kt +++ b/Tokens/stockpaydividend/contracts/src/test/kotlin/net/corda/samples/stockpaydividend/contracts/StateTests.kt @@ -1,19 +1,16 @@ package net.corda.samples.stockpaydividend.contracts import net.corda.samples.stockpaydividend.states.StockState -import net.corda.testing.node.MockServices +import org.junit.Assert.assertEquals import org.junit.Test - class StateTests { - private val ledgerServices = MockServices() - //sample State tests @Test @Throws(NoSuchFieldException::class) fun hasConstructionAreaFieldOfCorrectType() { // Does the message field exist? StockState::class.java.getDeclaredField("symbol") - assert(StockState::class.java.getDeclaredField("symbol").type == String::class.java) + assertEquals(String::class.java, StockState::class.java.getDeclaredField("symbol").type) } } \ No newline at end of file diff --git a/Tokens/stockpaydividend/gradle.properties b/Tokens/stockpaydividend/gradle.properties index 9cd982df..041d37f1 100644 --- a/Tokens/stockpaydividend/gradle.properties +++ b/Tokens/stockpaydividend/gradle.properties @@ -1,4 +1,34 @@ +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.java.installations.auto-download=false +org.gradle.caching=false +kotlin.incremental=false + name=Stockpaydividend Cordapp group=com.stockpaydividend version=1.0 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.68.Final + +# Token +tokens_release_group=com.r3.corda.lib.tokens +tokens_release_version=1.2 + +# Confidential Identities (CI) +confidential_id_release_group=com.r3.corda.lib.ci +confidential_id_release_version=1.0 + +spring_boot_version=2.0.2.RELEASE diff --git a/Tokens/stockpaydividend/gradle/wrapper/gradle-wrapper.jar b/Tokens/stockpaydividend/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Tokens/stockpaydividend/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Tokens/stockpaydividend/gradle/wrapper/gradle-wrapper.properties b/Tokens/stockpaydividend/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae01072d..00000000 --- a/Tokens/stockpaydividend/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/Tokens/stockpaydividend/gradlew b/Tokens/stockpaydividend/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Tokens/stockpaydividend/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Tokens/stockpaydividend/gradlew.bat b/Tokens/stockpaydividend/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Tokens/stockpaydividend/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Tokens/stockpaydividend/repositories.gradle b/Tokens/stockpaydividend/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Tokens/stockpaydividend/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Tokens/stockpaydividend/settings.gradle b/Tokens/stockpaydividend/settings.gradle index 2514aca2..45f64fa3 100644 --- a/Tokens/stockpaydividend/settings.gradle +++ b/Tokens/stockpaydividend/settings.gradle @@ -1,3 +1,38 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url "$artifactoryContextUrl/corda-lib" + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' \ No newline at end of file diff --git a/Tokens/stockpaydividend/workflows/build.gradle b/Tokens/stockpaydividend/workflows/build.gradle index c9c6d3b7..86c4fa54 100644 --- a/Tokens/stockpaydividend/workflows/build.gradle +++ b/Tokens/stockpaydividend/workflows/build.gradle @@ -1,5 +1,8 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { targetPlatformVersion corda_platform_version.toInteger() @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,28 +31,27 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. cordapp project(":contracts") // Token SDK dependencies. - cordaCompile "$tokens_release_group:tokens-workflows:$tokens_release_version" + cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version" + cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version" } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/AnnounceDividend.kt b/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/AnnounceDividend.kt index 7ebc82f0..10c68c06 100644 --- a/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/AnnounceDividend.kt +++ b/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/AnnounceDividend.kt @@ -11,7 +11,7 @@ import net.corda.core.node.services.IdentityService import net.corda.samples.stockpaydividend.flows.utilities.QueryUtilities import net.corda.samples.stockpaydividend.states.StockState import java.math.BigDecimal -import java.util.* +import java.util.Date // ********* // * Flows * @@ -33,7 +33,7 @@ class AnnounceDividend(val symbol: String, // Get predefined observers val identityService = serviceHub.identityService - val observers: List = getObserverLegalIdenties(identityService)!! + val observers: List = getObserverLegalIdentities(identityService) val obSessions: MutableList = ArrayList() for (observer in observers) { obSessions.add(initiateFlow(observer)) @@ -41,23 +41,23 @@ class AnnounceDividend(val symbol: String, // Update the stock state and send a copy to the observers eventually val stx = subFlow(UpdateEvolvableTokenFlow(stockStateRef, outputState, listOf(), obSessions)) subFlow(UpdateDistributionListFlow(stx)) - return "Stock ${symbol} has changed dividend percentage to ${dividendPercentage}. ${stx.id}" + return "Stock $symbol has changed dividend percentage to $dividendPercentage. ${stx.id}" } } @InitiatedBy(AnnounceDividend::class) class AnnounceDividendResponder(val counterpartySession: FlowSession) : FlowLogic() { @Suspendable - override fun call():Unit { + override fun call() { // To implement the responder flow, simply call the subflow of UpdateEvolvableTokenFlowHandler return subFlow(UpdateEvolvableTokenFlowHandler(counterpartySession)) } } -fun getObserverLegalIdenties(identityService: IdentityService): List? { - var observers: MutableList = ArrayList() +fun getObserverLegalIdentities(identityService: IdentityService): List { + val observers: MutableList = ArrayList() for (observerName in listOf("Observer", "Shareholder")) { - val observerSet = identityService.partiesFromName(observerName!!, false) + val observerSet = identityService.partiesFromName(observerName, false) if (observerSet.size != 1) { val errMsg = String.format("Found %d identities for the observer.", observerSet.size) throw IllegalStateException(errMsg) diff --git a/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/ClaimDividendReceivable.kt b/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/ClaimDividendReceivable.kt index 6e5c6cff..e11b6e73 100644 --- a/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/ClaimDividendReceivable.kt +++ b/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/ClaimDividendReceivable.kt @@ -17,7 +17,9 @@ import net.corda.samples.stockpaydividend.flows.utilities.QueryUtilities import net.corda.samples.stockpaydividend.states.DividendState import net.corda.samples.stockpaydividend.states.StockState import java.math.BigDecimal -import java.util.* +import java.util.Currency +import java.util.Date +import kotlin.math.pow // ********* // * Flows * @@ -28,6 +30,7 @@ class ClaimDividendReceivable(val symbol: String) : FlowLogic() { @Suspendable override fun call(): String { // Retrieve the stock and pointer val stockPointer: TokenPointer<*> = QueryUtilities.queryStockPointer(symbol, serviceHub) + @Suppress("unchecked_cast") val stockStateRef: StateAndRef = stockPointer.pointer.resolve(serviceHub) as StateAndRef val stockState: StockState = stockStateRef.state.data @@ -78,10 +81,11 @@ class ClaimDividendReceivableResponder(private val holderSession: FlowSession) : // Query the stored state of the company val stockPointer: TokenPointer<*> = QueryUtilities.queryStockPointer(stockState.symbol, serviceHub) + @Suppress("unchecked_cast") val stockStateRef: StateAndRef = stockPointer.pointer.resolve(serviceHub) as StateAndRef // Receives the amount that the shareholder holds - val claimNoticication:ClaimNotification = holderSession.receive(ClaimNotification::class.java).unwrap { it: ClaimNotification-> + val claimNoticication:ClaimNotification = holderSession.receive(ClaimNotification::class.java).unwrap { if(holderStockState.ref.txhash != stockStateRef.ref.txhash){ throw FlowException("StockState does not match with the issuers. Shareholder may not have updated the newest stock state.") }else{ @@ -96,7 +100,8 @@ class ClaimDividendReceivableResponder(private val holderSession: FlowSession) : // Calculate the actual dividend paying to the shareholder val yield: BigDecimal = stockState.dividend.multiply(BigDecimal.valueOf(claimNoticication.amount.quantity)) val dividend = `yield`.multiply(stockState.price).multiply(BigDecimal.valueOf( - Math.pow(10.0, currency.defaultFractionDigits.toDouble()))) + 10.0.pow(currency.defaultFractionDigits.toDouble()) + )) // Create the dividend state val dividendAmount: Amount = Amount(dividend.longValueExact(), dividendTokenType) diff --git a/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/CreateAndIssueStock.kt b/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/CreateAndIssueStock.kt index 8bd3108c..7682c3d7 100644 --- a/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/CreateAndIssueStock.kt +++ b/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/CreateAndIssueStock.kt @@ -16,7 +16,7 @@ import net.corda.core.node.services.IdentityService import net.corda.core.utilities.ProgressTracker import net.corda.samples.stockpaydividend.states.StockState import java.math.BigDecimal -import java.util.* +import java.util.Date // ********* // * Flows * @@ -36,7 +36,7 @@ class CreateAndIssueStock(val symbol: String, // Sample specific - retrieving the hard-coded observers val identityService = serviceHub.identityService - val observers: List = getObserverLegalIdenties(identityService)!! + val observers: List = getObserverLegalIdentities(identityService) // Construct the output StockState val stockState = StockState(ourIdentity, symbol, @@ -66,10 +66,10 @@ class CreateAndIssueStock(val symbol: String, + price + " " + currency + "\nTransaction ID: " + stx.id) } - fun getObserverLegalIdenties(identityService: IdentityService): List? { - var observers: MutableList = ArrayList() + fun getObserverLegalIdentities(identityService: IdentityService): List { + val observers: MutableList = ArrayList() for (observerName in listOf("Observer")) { - val observerSet = identityService.partiesFromName(observerName!!, false) + val observerSet = identityService.partiesFromName(observerName, false) if (observerSet.size != 1) { val errMsg = String.format("Found %d identities for the observer.", observerSet.size) throw IllegalStateException(errMsg) diff --git a/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/MoveStock.kt b/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/MoveStock.kt index 9763da72..3d7bd697 100644 --- a/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/MoveStock.kt +++ b/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/MoveStock.kt @@ -34,7 +34,7 @@ class MoveStock(val symbol: String, //Use built-in flow for move tokens to the recipient //Use built-in flow for move tokens to the recipient - val stx = subFlow(MoveFungibleTokens(amount, recipient)) + val stx = subFlow(MoveFungibleTokens(amount, recipient)) return ("\nIssued " + quantity + " " + symbol + " stocks to " + recipient.name.organisation + ".\nTransaction ID: " + stx.id) } } diff --git a/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/PayDividend.kt b/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/PayDividend.kt index d78b9787..95d1d834 100644 --- a/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/PayDividend.kt +++ b/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/PayDividend.kt @@ -2,10 +2,8 @@ package net.corda.samples.stockpaydividend.flows import co.paralleluniverse.fibers.Suspendable import com.r3.corda.lib.tokens.contracts.states.FungibleToken -import com.r3.corda.lib.tokens.contracts.types.TokenType import com.r3.corda.lib.tokens.selection.database.selector.DatabaseTokenSelection import com.r3.corda.lib.tokens.workflows.flows.move.addMoveTokens -import com.r3.corda.lib.tokens.workflows.types.PartyAndAmount import net.corda.core.contracts.StateAndRef import net.corda.core.contracts.requireThat import net.corda.core.flows.* @@ -17,7 +15,6 @@ import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.ProgressTracker import net.corda.samples.stockpaydividend.contracts.DividendContract import net.corda.samples.stockpaydividend.states.DividendState -import java.util.* import java.util.stream.Collectors // ********* @@ -34,8 +31,7 @@ class PayDividend : FlowLogic>() { //Query the vault for any unconsumed DividendState val stateAndRefs: List> = serviceHub.vaultService.queryBy().states - val transactions: List = ArrayList() - var notes: MutableList = ArrayList() + val notes: MutableList = ArrayList() //For each queried unpaid DividendState, pay off the dividend with the corresponding amount. for (result in stateAndRefs) { val dividendState: DividendState = result.state.data @@ -68,9 +64,9 @@ class PayDividend : FlowLogic>() { // Ask the shareholder to sign the transaction val stx = subFlow(CollectSignaturesFlow(ptx, listOf(holderSession))) - val fstx = subFlow(FinalityFlow(stx, sessions)) + val fstx = subFlow(FinalityFlow(stx, sessions)) notes.add("\nPaid to " + dividendState.shareholder.name.organisation - .toString() + " " + (dividendState.dividendAmount.quantity / 100).toString() + " " + + " " + (dividendState.dividendAmount.quantity / 100).toString() + " " + dividendState.dividendAmount.token.tokenIdentifier + "\nTransaction ID: " + fstx.id) } return notes @@ -89,7 +85,7 @@ class PayDividendResponder(val counterpartySession: FlowSession) : FlowLogic { // Any checkings that the DividendContract is be not able to validate. val outputFiats = stx.tx.outputsOfType(FungibleToken::class.java) - val holderFiats = outputFiats.stream().filter { fiat: FungibleToken -> fiat.holder.equals(ourIdentity) }.collect(Collectors.toList()) + val holderFiats = outputFiats.stream().filter { fiat: FungibleToken -> fiat.holder == ourIdentity }.collect(Collectors.toList()) "One FungibleToken output should be held by Shareholder".using(holderFiats.size == 1) } } diff --git a/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/QueryFlows.kt b/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/QueryFlows.kt index a014b368..5a6b39e3 100644 --- a/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/QueryFlows.kt +++ b/Tokens/stockpaydividend/workflows/src/main/kotlin/net/corda/samples/stockpaydividend/flows/QueryFlows.kt @@ -2,10 +2,8 @@ package net.corda.samples.stockpaydividend.flows import co.paralleluniverse.fibers.Suspendable import com.r3.corda.lib.tokens.contracts.types.TokenPointer -import com.r3.corda.lib.tokens.contracts.types.TokenType import com.r3.corda.lib.tokens.money.FiatCurrency.Companion.getInstance import com.r3.corda.lib.tokens.workflows.utilities.tokenBalance -import net.corda.core.contracts.Amount import net.corda.core.flows.FlowException import net.corda.core.flows.FlowLogic import net.corda.core.flows.InitiatingFlow diff --git a/Tokens/stockpaydividend/workflows/src/test/kotlin/net/corda/samples/stockpaydividend/FlowTests.kt b/Tokens/stockpaydividend/workflows/src/test/kotlin/net/corda/samples/stockpaydividend/FlowTests.kt index 47435233..a8d02166 100644 --- a/Tokens/stockpaydividend/workflows/src/test/kotlin/net/corda/samples/stockpaydividend/FlowTests.kt +++ b/Tokens/stockpaydividend/workflows/src/test/kotlin/net/corda/samples/stockpaydividend/FlowTests.kt @@ -1,12 +1,10 @@ package net.corda.samples.stockpaydividend -import com.google.common.collect.ImmutableList import com.r3.corda.lib.tokens.money.FiatCurrency.Companion.getInstance import com.r3.corda.lib.tokens.workflows.utilities.tokenBalance import net.corda.core.crypto.SecureHash import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party -import net.corda.core.node.NetworkParameters import net.corda.samples.stockpaydividend.flows.* import net.corda.samples.stockpaydividend.states.DividendState import net.corda.samples.stockpaydividend.states.StockState @@ -17,39 +15,42 @@ import net.corda.testing.node.MockNetworkParameters import net.corda.testing.node.StartedMockNode import net.corda.testing.node.TestCordapp import org.junit.After -import org.junit.Assert +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotNull +import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test import java.math.BigDecimal -import java.time.Instant -import java.util.* +import java.util.Calendar +import java.util.Date import java.util.concurrent.ExecutionException +import kotlin.math.pow class FlowTests { - protected var network: MockNetwork? = null - protected var company: StartedMockNode? = null - protected var observer: StartedMockNode? = null - protected var shareholder: StartedMockNode? = null - protected var bank: StartedMockNode? = null - protected var exDate: Date? = null - protected var payDate: Date? = null - - protected var notary: StartedMockNode? = null - protected var notaryParty: Party? = null - - var COMPANY = TestIdentity(CordaX500Name("Company", "TestVillage", "US")) - var SHAREHOLDER = TestIdentity(CordaX500Name("Shareholder", "TestVillage", "US")) - var BANK = TestIdentity(CordaX500Name("Bank", "Rulerland", "US")) - var OBSERVER = TestIdentity(CordaX500Name("Observer", "Rulerland", "US")) - - val STOCK_SYMBOL = "TEST" - val STOCK_NAME = "Test Stock" - val STOCK_CURRENCY = "USD" - val STOCK_PRICE = BigDecimal.valueOf(7.4) - val ISSUING_STOCK_QUANTITY = 2000 - val BUYING_STOCK = java.lang.Long.valueOf(500) - val ISSUING_MONEY = 5000000 - val ANNOUNCING_DIVIDEND = BigDecimal("0.03") + private lateinit var network: MockNetwork + private lateinit var company: StartedMockNode + private lateinit var observer: StartedMockNode + private lateinit var shareholder: StartedMockNode + private lateinit var bank: StartedMockNode + private lateinit var exDate: Date + private lateinit var payDate: Date + + private lateinit var notary: StartedMockNode + private lateinit var notaryParty: Party + + private val COMPANY = TestIdentity(CordaX500Name("Company", "TestVillage", "US")) + private val SHAREHOLDER = TestIdentity(CordaX500Name("Shareholder", "TestVillage", "US")) + private val BANK = TestIdentity(CordaX500Name("Bank", "Rulerland", "US")) + private val OBSERVER = TestIdentity(CordaX500Name("Observer", "Rulerland", "US")) + + private val STOCK_SYMBOL = "TEST" + private val STOCK_NAME = "Test Stock" + private val STOCK_CURRENCY = "USD" + private val STOCK_PRICE = BigDecimal.valueOf(7.4) + private val ISSUING_STOCK_QUANTITY = 2000 + private val BUYING_STOCK = java.lang.Long.valueOf(500) + private val ISSUING_MONEY = 5000000 + private val ANNOUNCING_DIVIDEND = BigDecimal("0.03") @Before fun setup() { @@ -60,12 +61,12 @@ class FlowTests { TestCordapp.findCordapp("com.r3.corda.lib.tokens.workflows") ), networkParameters = testNetworkParameters(minimumPlatformVersion = 4))) - company = network!!.createPartyNode(COMPANY.name) - observer = network!!.createPartyNode(OBSERVER.name) - shareholder = network!!.createPartyNode(SHAREHOLDER.name) - bank = network!!.createPartyNode(BANK.name) - notary = network!!.notaryNodes[0] - notaryParty = notary!!.info.legalIdentities[0] + company = network.createPartyNode(COMPANY.name) + observer = network.createPartyNode(OBSERVER.name) + shareholder = network.createPartyNode(SHAREHOLDER.name) + bank = network.createPartyNode(BANK.name) + notary = network.notaryNodes[0] + notaryParty = notary.info.legalIdentities[0] // Set execution date as tomorrow val c = Calendar.getInstance() @@ -75,30 +76,32 @@ class FlowTests { // Set pay date as the day after tomorrow c.add(Calendar.DATE, 1) payDate = c.time - network!!.startNodes() + network.startNodes() } @After fun tearDown() { - network!!.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } @Test @Throws(ExecutionException::class, InterruptedException::class) fun issueTest() { // Issue Stock - val future = company!!.startFlow(CreateAndIssueStock(STOCK_SYMBOL, STOCK_NAME, STOCK_CURRENCY, STOCK_PRICE, ISSUING_STOCK_QUANTITY, notaryParty!!)) - network!!.runNetwork() + val future = company.startFlow(CreateAndIssueStock(STOCK_SYMBOL, STOCK_NAME, STOCK_CURRENCY, STOCK_PRICE, ISSUING_STOCK_QUANTITY, notaryParty)) + network.runNetwork() val stx = future.get() val stxID = stx.substring(stx.lastIndexOf(" ") + 1) val stxIDHash: SecureHash = SecureHash.parse(stxID) //Check if company and observer of the stock have recorded the transactions - val issuerTx = company!!.services.validatedTransactions.getTransaction(stxIDHash) - val observerTx = observer!!.services.validatedTransactions.getTransaction(stxIDHash) - Assert.assertNotNull(issuerTx) - Assert.assertNotNull(observerTx) - Assert.assertEquals(issuerTx, observerTx) + val issuerTx = company.services.validatedTransactions.getTransaction(stxIDHash) + val observerTx = observer.services.validatedTransactions.getTransaction(stxIDHash) + assertNotNull(issuerTx) + assertNotNull(observerTx) + assertEquals(issuerTx, observerTx) } @@ -106,97 +109,97 @@ class FlowTests { @Throws(ExecutionException::class, InterruptedException::class) fun moveTest() { // Issue Stock - var future = company!!.startFlow(CreateAndIssueStock(STOCK_SYMBOL, STOCK_NAME, STOCK_CURRENCY, STOCK_PRICE, ISSUING_STOCK_QUANTITY, notaryParty!!)) - network!!.runNetwork() + var future = company.startFlow(CreateAndIssueStock(STOCK_SYMBOL, STOCK_NAME, STOCK_CURRENCY, STOCK_PRICE, ISSUING_STOCK_QUANTITY, notaryParty)) + network.runNetwork() future.get() // Move Stock - future = company!!.startFlow(MoveStock(STOCK_SYMBOL, BUYING_STOCK, shareholder!!.info.legalIdentities[0])) - network!!.runNetwork() + future = company.startFlow(MoveStock(STOCK_SYMBOL, BUYING_STOCK, shareholder.info.legalIdentities[0])) + network.runNetwork() val moveTx = future.get() //Retrieve states from receiver - val receivedStockStatesPages = shareholder!!.services.vaultService.queryBy(StockState::class.java).states + val receivedStockStatesPages = shareholder.services.vaultService.queryBy(StockState::class.java).states val receivedStockState = receivedStockStatesPages[0].state.data - val (quantity) = shareholder!!.services.vaultService.tokenBalance(receivedStockState.toPointer(receivedStockState.javaClass)) + val (quantity) = shareholder.services.vaultService.tokenBalance(receivedStockState.toPointer(receivedStockState.javaClass)) //Check - Assert.assertEquals(quantity, java.lang.Long.valueOf(500).toLong()) + assertEquals(quantity, java.lang.Long.valueOf(500).toLong()) //Retrieve states from sender - val remainingStockStatesPages = company!!.services.vaultService.queryBy(StockState::class.java).states + val remainingStockStatesPages = company.services.vaultService.queryBy(StockState::class.java).states val remainingStockState = remainingStockStatesPages[0].state.data - val (quantity1) = company!!.services.vaultService.tokenBalance(remainingStockState.toPointer(remainingStockState.javaClass)) + val (quantity1) = company.services.vaultService.tokenBalance(remainingStockState.toPointer(remainingStockState.javaClass)) //Check - Assert.assertEquals(quantity1, java.lang.Long.valueOf(1500).toLong()) + assertEquals(quantity1, java.lang.Long.valueOf(1500).toLong()) } @Test @Throws(ExecutionException::class, InterruptedException::class) fun announceDividendTest() { // Issue Stock - var future = company!!.startFlow( - CreateAndIssueStock(STOCK_SYMBOL, STOCK_NAME, STOCK_CURRENCY, STOCK_PRICE, ISSUING_STOCK_QUANTITY, notaryParty!!)) - network!!.runNetwork() + var future = company.startFlow( + CreateAndIssueStock(STOCK_SYMBOL, STOCK_NAME, STOCK_CURRENCY, STOCK_PRICE, ISSUING_STOCK_QUANTITY, notaryParty)) + network.runNetwork() future.get() // Move Stock - future = company!!.startFlow(MoveStock(STOCK_SYMBOL, BUYING_STOCK, shareholder!!.info.legalIdentities[0])) - network!!.runNetwork() + future = company.startFlow(MoveStock(STOCK_SYMBOL, BUYING_STOCK, shareholder.info.legalIdentities[0])) + network.runNetwork() future.get() // Announce Dividend - future = company!!.startFlow(AnnounceDividend(STOCK_SYMBOL, ANNOUNCING_DIVIDEND, exDate!!, payDate!!)) - network!!.runNetwork() + future = company.startFlow(AnnounceDividend(STOCK_SYMBOL, ANNOUNCING_DIVIDEND, exDate, payDate)) + network.runNetwork() val announceTxSting = future.get() val stxID = announceTxSting.substring(announceTxSting.lastIndexOf(" ") + 1) val announceTx: SecureHash = SecureHash.parse(stxID) // Retrieve states from sender - val remainingStockStatesPages = company!!.services.vaultService.queryBy(StockState::class.java).states + val remainingStockStatesPages = company.services.vaultService.queryBy(StockState::class.java).states val (_, _, _, _, _, dividend, exDate, payDate) = remainingStockStatesPages[0].state.data - Assert.assertEquals(dividend, ANNOUNCING_DIVIDEND) - Assert.assertEquals(exDate, exDate) - Assert.assertEquals(payDate, payDate) + assertEquals(dividend, ANNOUNCING_DIVIDEND) + assertEquals(exDate, exDate) + assertEquals(payDate, payDate) // Check observer has recorded the same transaction - val issuerTx = company!!.services.validatedTransactions.getTransaction(announceTx) - val observerTx = observer!!.services.validatedTransactions.getTransaction(announceTx) - Assert.assertNotNull(issuerTx) - Assert.assertNotNull(observerTx) - Assert.assertEquals(issuerTx, observerTx) + val issuerTx = company.services.validatedTransactions.getTransaction(announceTx) + val observerTx = observer.services.validatedTransactions.getTransaction(announceTx) + assertNotNull(issuerTx) + assertNotNull(observerTx) + assertEquals(issuerTx, observerTx) } @Test @Throws(ExecutionException::class, InterruptedException::class) fun getStockUpdateTest() { // Issue Stock - var future = company!!.startFlow(CreateAndIssueStock(STOCK_SYMBOL, STOCK_NAME, STOCK_CURRENCY, STOCK_PRICE, ISSUING_STOCK_QUANTITY, notaryParty!!)) - network!!.runNetwork() + var future = company.startFlow(CreateAndIssueStock(STOCK_SYMBOL, STOCK_NAME, STOCK_CURRENCY, STOCK_PRICE, ISSUING_STOCK_QUANTITY, notaryParty)) + network.runNetwork() future.get() // Move Stock - future = company!!.startFlow(MoveStock(STOCK_SYMBOL, BUYING_STOCK, shareholder!!.info.legalIdentities[0])) - network!!.runNetwork() + future = company.startFlow(MoveStock(STOCK_SYMBOL, BUYING_STOCK, shareholder.info.legalIdentities[0])) + network.runNetwork() future.get() // Announce Dividend - future = company!!.startFlow(AnnounceDividend(STOCK_SYMBOL, ANNOUNCING_DIVIDEND, exDate!!, payDate!!)) - network!!.runNetwork() + future = company.startFlow(AnnounceDividend(STOCK_SYMBOL, ANNOUNCING_DIVIDEND, exDate, payDate)) + network.runNetwork() future.get() // Get Stock Update - future = shareholder!!.startFlow(ClaimDividendReceivable(STOCK_SYMBOL)) - network!!.runNetwork() + future = shareholder.startFlow(ClaimDividendReceivable(STOCK_SYMBOL)) + network.runNetwork() future.get() // Checks if the shareholder actually receives the same transaction and updated the stock state (with new dividend) - val issuerStockStateRefs = company!!.services.vaultService.queryBy(StockState::class.java).states + val issuerStockStateRefs = company.services.vaultService.queryBy(StockState::class.java).states val (txhash) = issuerStockStateRefs[0].ref - val holderStockStateRefs = shareholder!!.services.vaultService.queryBy(StockState::class.java).states + val holderStockStateRefs = shareholder.services.vaultService.queryBy(StockState::class.java).states val (txhash1) = holderStockStateRefs[0].ref - Assert.assertEquals(txhash, txhash1) + assertEquals(txhash, txhash1) } @@ -204,100 +207,100 @@ class FlowTests { @Throws(ExecutionException::class, InterruptedException::class) fun claimDividendTest() { // Issue Stock - var future = company!!.startFlow(CreateAndIssueStock(STOCK_SYMBOL, STOCK_NAME, STOCK_CURRENCY, STOCK_PRICE, ISSUING_STOCK_QUANTITY, notaryParty!!)) - network!!.runNetwork() + var future = company.startFlow(CreateAndIssueStock(STOCK_SYMBOL, STOCK_NAME, STOCK_CURRENCY, STOCK_PRICE, ISSUING_STOCK_QUANTITY, notaryParty)) + network.runNetwork() future.get() // Move Stock - future = company!!.startFlow(MoveStock(STOCK_SYMBOL, BUYING_STOCK, shareholder!!.info.legalIdentities[0])) - network!!.runNetwork() + future = company.startFlow(MoveStock(STOCK_SYMBOL, BUYING_STOCK, shareholder.info.legalIdentities[0])) + network.runNetwork() val moveTx = future.get() // Announce Dividend - future = company!!.startFlow(AnnounceDividend(STOCK_SYMBOL, ANNOUNCING_DIVIDEND, exDate!!, payDate!!)) - network!!.runNetwork() + future = company.startFlow(AnnounceDividend(STOCK_SYMBOL, ANNOUNCING_DIVIDEND, exDate, payDate)) + network.runNetwork() future.get() // Shareholder claims Dividend - future = shareholder!!.startFlow(ClaimDividendReceivable(STOCK_SYMBOL)) - network!!.runNetwork() + future = shareholder.startFlow(ClaimDividendReceivable(STOCK_SYMBOL)) + network.runNetwork() val claimTxString = future.get() val stxID = claimTxString.substring(claimTxString.lastIndexOf(" ") + 1) val claimTxID: SecureHash = SecureHash.parse(stxID) // Checks if the dividend amount is correct - val holderDividendPages = shareholder!!.services.vaultService.queryBy(DividendState::class.java).states + val holderDividendPages = shareholder.services.vaultService.queryBy(DividendState::class.java).states val (_, _, _, dividendAmount) = holderDividendPages[0].state.data val fractionalDigit = dividendAmount.token.fractionDigits val yieldAmount = BigDecimal.valueOf(BUYING_STOCK).multiply(ANNOUNCING_DIVIDEND) - val receivingDividend = yieldAmount.multiply(STOCK_PRICE).multiply(BigDecimal.valueOf(Math.pow(10.0, fractionalDigit.toDouble()))) - Assert.assertEquals(dividendAmount.quantity, receivingDividend.toLong()) + val receivingDividend = yieldAmount.multiply(STOCK_PRICE).multiply(BigDecimal.valueOf(10.0.pow(fractionalDigit.toDouble()))) + assertEquals(dividendAmount.quantity, receivingDividend.toLong()) // Check company and shareholder owns the same transaction - val issuerTx = company!!.services.validatedTransactions.getTransaction(claimTxID) - val holderTx = shareholder!!.services.validatedTransactions.getTransaction(claimTxID) - Assert.assertNotNull(issuerTx) - Assert.assertNotNull(holderTx) - Assert.assertEquals(issuerTx, holderTx) + val issuerTx = company.services.validatedTransactions.getTransaction(claimTxID) + val holderTx = shareholder.services.validatedTransactions.getTransaction(claimTxID) + assertNotNull(issuerTx) + assertNotNull(holderTx) + assertEquals(issuerTx, holderTx) } @Test @Throws(ExecutionException::class, InterruptedException::class) fun payDividendTest() { // Issue Money - var future = bank!!.startFlow(IssueMoney(STOCK_CURRENCY, ISSUING_MONEY.toLong(), company!!.info.legalIdentities[0])) - network!!.runNetwork() + var future = bank.startFlow(IssueMoney(STOCK_CURRENCY, ISSUING_MONEY.toLong(), company.info.legalIdentities[0])) + network.runNetwork() future.get() // Issue Stock - future = company!!.startFlow(CreateAndIssueStock(STOCK_SYMBOL, STOCK_NAME, STOCK_CURRENCY, STOCK_PRICE, ISSUING_STOCK_QUANTITY, notaryParty!!)) - network!!.runNetwork() + future = company.startFlow(CreateAndIssueStock(STOCK_SYMBOL, STOCK_NAME, STOCK_CURRENCY, STOCK_PRICE, ISSUING_STOCK_QUANTITY, notaryParty)) + network.runNetwork() future.get() // Move Stock - future = company!!.startFlow(MoveStock(STOCK_SYMBOL, BUYING_STOCK, shareholder!!.info.legalIdentities[0])) - network!!.runNetwork() + future = company.startFlow(MoveStock(STOCK_SYMBOL, BUYING_STOCK, shareholder.info.legalIdentities[0])) + network.runNetwork() future.get() // Announce Dividend - future = company!!.startFlow(AnnounceDividend(STOCK_SYMBOL, ANNOUNCING_DIVIDEND, exDate!!, payDate!!)) - network!!.runNetwork() + future = company.startFlow(AnnounceDividend(STOCK_SYMBOL, ANNOUNCING_DIVIDEND, exDate, payDate)) + network.runNetwork() future.get() // Shareholder claims Dividend - future = shareholder!!.startFlow(ClaimDividendReceivable(STOCK_SYMBOL)) - network!!.runNetwork() + future = shareholder.startFlow(ClaimDividendReceivable(STOCK_SYMBOL)) + network.runNetwork() future.get() //Pay Dividend - val futurePayDiv = company!!.startFlow>(PayDividend()) - network!!.runNetwork() + val futurePayDiv = company.startFlow(PayDividend()) + network.runNetwork() val txList = futurePayDiv.get() // The above test should only have 1 transaction created - Assert.assertEquals(txList.size.toLong(), 1) + assertEquals(txList.size.toLong(), 1) val payDivTxString = txList[0] val stxID = payDivTxString.substring(payDivTxString.lastIndexOf(" ") + 1) val payDivTxID: SecureHash = SecureHash.parse(stxID) // Checks if no Dividend state left unspent in shareholder's and company's vault - val holderDivStateRefs = shareholder!!.services.vaultService.queryBy(DividendState::class.java).states - assert(holderDivStateRefs.isEmpty()) - val issuerDivStateRefs = company!!.services.vaultService.queryBy(DividendState::class.java).states - assert(issuerDivStateRefs.isEmpty()) + val holderDivStateRefs = shareholder.services.vaultService.queryBy(DividendState::class.java).states + assertTrue(holderDivStateRefs.isEmpty()) + val issuerDivStateRefs = company.services.vaultService.queryBy(DividendState::class.java).states + assertTrue(issuerDivStateRefs.isEmpty()) // Validates shareholder has received equivalent fiat currencies of the dividend val fiatTokenType = getInstance(STOCK_CURRENCY) - val (quantity) = shareholder!!.services.vaultService.tokenBalance(fiatTokenType) + val (quantity) = shareholder.services.vaultService.tokenBalance(fiatTokenType) val receivingDividend = BigDecimal.valueOf(BUYING_STOCK).multiply(STOCK_PRICE).multiply(ANNOUNCING_DIVIDEND) - Assert.assertEquals(quantity, receivingDividend.movePointRight(2).toLong()) + assertEquals(quantity, receivingDividend.movePointRight(2).toLong()) // Check company and shareholder owns the same transaction - val issuerTx = company!!.services.validatedTransactions.getTransaction(payDivTxID) - val holderTx = shareholder!!.services.validatedTransactions.getTransaction(payDivTxID) - Assert.assertNotNull(issuerTx) - Assert.assertNotNull(holderTx) - Assert.assertEquals(issuerTx, holderTx) + val issuerTx = company.services.validatedTransactions.getTransaction(payDivTxID) + val holderTx = shareholder.services.validatedTransactions.getTransaction(payDivTxID) + assertNotNull(issuerTx) + assertNotNull(holderTx) + assertEquals(issuerTx, holderTx) } } \ No newline at end of file diff --git a/Tokens/tokentofriend/README.md b/Tokens/tokentofriend/README.md index a86b68b0..57f224d8 100644 --- a/Tokens/tokentofriend/README.md +++ b/Tokens/tokentofriend/README.md @@ -10,7 +10,7 @@ We have built a front end interface to make the interaction easier. Clone the ap ## Running the applications ``` - ./gradlew deployNodes + ../gradlew deployNodes ./build/nodes/runnodes ``` @@ -36,11 +36,11 @@ You should discover the message that was attached in the token. ## Runing in webapp Open a new window and run the blow code for token issuance ``` -./gradlew runOperatoreServer +../gradlew runOperatoreServer ``` To retrieve the token, because most people will run the app locally, by default I have the gradle task to start only one storage node's web server. ``` -./gradlew runUSWest1Server +../gradlew runUSWest1Server ``` After both servers started, go to localhost:10050 to issue a token and localhost:10053 to experience the retrieve. (The reason it is two different site is that communiticating among multiple local server is prohibit by CORS policy. In production environment, we do not need to go to a different site for retrieve.) diff --git a/Tokens/tokentofriend/build.gradle b/Tokens/tokentofriend/build.gradle index b1279927..d74871c4 100644 --- a/Tokens/tokentofriend/build.gradle +++ b/Tokens/tokentofriend/build.gradle @@ -1,126 +1,72 @@ -buildscript { //properties that you need to build the project - - Properties constants = new Properties() - file("$projectDir/../constants.properties").withInputStream { constants.load(it) } - - ext { - corda_release_group = constants.getProperty("cordaReleaseGroup") - corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup") - corda_release_version = constants.getProperty("cordaVersion") - corda_core_release_version = constants.getProperty("cordaCoreVersion") - corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion") - kotlin_version = constants.getProperty("kotlinVersion") - junit_version = constants.getProperty("junitVersion") - quasar_version = constants.getProperty("quasarVersion") - log4j_version = constants.getProperty("log4jVersion") - slf4j_version = constants.getProperty("slf4jVersion") - corda_platform_version = constants.getProperty("platformVersion").toInteger() - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' - //Token - tokens_release_group = 'com.r3.corda.lib.tokens' - tokens_release_version = '1.2' - } - - repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://software.r3.com/artifactory/corda-releases' } - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version" - classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version" - classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version" - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() - - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } - //SDK lib - maven { url 'https://software.r3.com/artifactory/corda-lib' } - //Gradle Plugins - maven { url 'https://repo.gradle.org/gradle/libs-releases' } - +subprojects { //Properties that you need to compile your project (The application) + pluginManager.withPlugin('java') { + java { + toolchain { + languageVersion = of(8) + } + } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(KotlinCompile).configureEach { kotlinOptions { - languageVersion = "1.2" - apiVersion = "1.2" - jvmTarget = "1.8" + languageVersion = '1.2' + apiVersion = '1.2' + jvmTarget = '1.8' javaParameters = true // Useful for reflection. + freeCompilerArgs += [ + '-Xjvm-default=enable' + ] } } - jar { - // This makes the JAR's SHA-256 hash repeatable. - preserveFileTimestamps = false - reproducibleFileOrder = true - } -} - -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.cordformation' -apply plugin: 'net.corda.plugins.quasar-utils' - -sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") + configurations.matching { it.name.endsWith("Classpath") }.configureEach { + resolutionStrategy { + dependencySubstitution { + substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7") + substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}") + } } } } -//Module dependencis dependencies { - // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" + cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version" + cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version" + corda "$corda_release_group:corda:$corda_release_version" // CorDapp dependencies. - cordapp project(":workflows") - cordapp project(":contracts") - - cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}" - cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version" + cordapp project(':workflows') + cordapp project(':contracts') // Token SDK dependencies. cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version" cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version" -} - -//Task to deploy the nodes in order to bootstrap a network -task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { + cordaDriver "$corda_release_group:corda-shell:$corda_release_version" +} +tasks.register('deployNodes', Cordform) { /* This property will load the CorDapps to each of the node by default, including the Notary. You can find them * in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand * the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load * the Corda network bootstrapper. */ nodeDefaults { - projectCordapp { - deploy = false - } cordapp project(':contracts') cordapp project(':workflows') - cordapp("$tokens_release_group:tokens-contracts:$tokens_release_version") - cordapp("$tokens_release_group:tokens-workflows:$tokens_release_version") + cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version" + cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version" + rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid //problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change //it to false for quicker project compiling time. @@ -133,6 +79,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { name "O=Operator,L=London,C=GB" @@ -141,26 +88,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10006") adminAddress("localhost:10046") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } -// node { -// name "O=USEast3,L=New York,C=US" -// p2pPort 10008 -// rpcSettings { -// address("localhost:10009") -// adminAddress("localhost:10049") -// } -// rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] -// } -// node { -// name "O=AsiaEast,L=Beijing,C=CN" -// p2pPort 10011 -// rpcSettings { -// address("localhost:10012") -// adminAddress("localhost:10052") -// } -// rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] -// } node { name "O=USWest1,L=San Diego,C=US" p2pPort 10014 @@ -168,7 +96,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10015") adminAddress("localhost:10055") } - rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]] } - } diff --git a/Tokens/tokentofriend/clients/build.gradle b/Tokens/tokentofriend/clients/build.gradle index c0e32963..fd1b11f7 100644 --- a/Tokens/tokentofriend/clients/build.gradle +++ b/Tokens/tokentofriend/clients/build.gradle @@ -1,16 +1,10 @@ -buildscript { - repositories { - maven { - url = uri("https://plugins.gradle.org/m2/") - } - } - dependencies { - classpath("com.moowork.gradle:gradle-node-plugin:1.3.1") - } -} +import com.moowork.gradle.node.npm.NpmTask -apply plugin: "com.moowork.node" -apply plugin: 'org.springframework.boot' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'org.springframework.boot' + id 'com.moowork.node' +} sourceSets { main { @@ -21,64 +15,64 @@ sourceSets { } dependencies { - - implementation 'com.google.code.gson:gson:2.8.5' + implementation "com.google.code.gson:gson:$gson_version" // Corda dependencies. - compile "$corda_release_group:corda-rpc:$corda_release_version" + implementation "$corda_release_group:corda-rpc:$corda_release_version" // CorDapp dependencies. - compile project(":contracts") - compile project(":workflows") - compile("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { + implementation project(':contracts') + implementation project(':workflows') + implementation("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") { exclude group: "org.springframework.boot", module: "spring-boot-starter-logging" } - compile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}" - compile "org.apache.logging.log4j:log4j-web:${log4j_version}" - compile "org.slf4j:jul-to-slf4j:$slf4j_version" + runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" + runtimeOnly "org.apache.logging.log4j:log4j-web:$log4j_version" } - springBoot { mainClassName = "net.corda.samples.tokentofriend.webserver.ServerKt" } -task copyWebApp(type: Copy) { - from 'src/main/webapp/build' - into 'build/resources/main/static/.' -} - -task appNpmInstall(type: NpmTask) { +def appNpmInstall = tasks.create('appNpmInstall', NpmTask) { description = "Installs all dependencies from package.json" - workingDir = file("${project.projectDir}/src/main/webapp") + workingDir = file("$projectDir/src/main/webapp") args = ["install"] } -task appNpmBuild(type: NpmTask) { +def appNpmBuild = tasks.create('appNpmBuild', NpmTask) { + dependsOn appNpmInstall description = "Builds production version of the webapp" - workingDir = file("${project.projectDir}/src/main/webapp") + workingDir = file("$projectDir/src/main/webapp") args = ["run", "build"] } -appNpmBuild.dependsOn appNpmInstall -copyWebApp.dependsOn appNpmBuild -compileJava.dependsOn copyWebApp +tasks.register('copyWebApp', Copy) { + dependsOn appNpmBuild + from 'src/main/webapp/build' + into 'build/resources/main/static/.' +} + +tasks.named('compileJava', JavaCompile) { + dependsOn copyWebApp +} node { download = true // Set the work directory for unpacking node - workDir = file("${project.buildDir}/nodejs") + workDir = file("$buildDir/nodejs") // Set the work directory for NPM - npmWorkDir = file("${project.buildDir}/npm") + npmWorkDir = file("$buildDir/npm") } /* The Client is the communication channel between the external and the node. This task will help you immediately * execute your rpc methods in the main method of the client.kt. You can somewhat see this as a quick test of making * RPC calls to your nodes. */ -task runOperatorClient(type: JavaExec, dependsOn: assemble) { +tasks.register('runOperatorClient', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.tokentofriend.ClientKt' args 'localhost:10006', 'user1', 'test' @@ -87,7 +81,8 @@ task runOperatorClient(type: JavaExec, dependsOn: assemble) { /* This task will start the springboot server that connects to your node (via RPC connection). All of the http requests * are in the Controller file. You can leave the Server.kt and NodeRPCConnection.kt file untouched for your use. */ -task runOperatoreServer(type: JavaExec, dependsOn: assemble) { +tasks.register('runOperatoreServer', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.tokentofriend.webserver.ServerKt' args '--server.port=10050', '--config.rpc.host=localhost', '--config.rpc.port=10006', '--config.rpc.username=user1', '--config.rpc.password=test' @@ -96,7 +91,8 @@ task runOperatoreServer(type: JavaExec, dependsOn: assemble) { /* This task will start the springboot server that connects to your node (via RPC connection). All of the http requests * are in the Controller file. You can leave the Server.kt and NodeRPCConnection.kt file untouched for your use. */ -task runUSWest1Server(type: JavaExec, dependsOn: assemble) { +tasks.register('runUSWest1Server', JavaExec) { + dependsOn assemble classpath = sourceSets.main.runtimeClasspath main = 'net.corda.samples.tokentofriend.webserver.ServerKt' args '--server.port=10053', '--config.rpc.host=localhost', '--config.rpc.port=10015', '--config.rpc.username=user1', '--config.rpc.password=test' diff --git a/Tokens/tokentofriend/contracts/build.gradle b/Tokens/tokentofriend/contracts/build.gradle index 7cebb47f..c23bee1b 100644 --- a/Tokens/tokentofriend/contracts/build.gradle +++ b/Tokens/tokentofriend/contracts/build.gradle @@ -1,8 +1,11 @@ -apply plugin: 'net.corda.plugins.cordapp' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() contract { name "tokenToFriend Contracts" vendor "Corda Open Source" @@ -12,10 +15,13 @@ cordapp { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" + // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" + // Token SDK dependencies. - cordaCompile "$tokens_release_group:tokens-contracts:$tokens_release_version" + cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version" } diff --git a/Tokens/tokentofriend/contracts/src/test/kotlin/net/corda/samples/tokentofriend/contracts/ContractTests.kt b/Tokens/tokentofriend/contracts/src/test/kotlin/net/corda/samples/tokentofriend/contracts/ContractTests.kt index 4632f376..aa2e4e6c 100644 --- a/Tokens/tokentofriend/contracts/src/test/kotlin/net/corda/samples/tokentofriend/contracts/ContractTests.kt +++ b/Tokens/tokentofriend/contracts/src/test/kotlin/net/corda/samples/tokentofriend/contracts/ContractTests.kt @@ -1,7 +1,5 @@ package net.corda.samples.tokentofriend.contracts -import com.r3.corda.lib.tokens.contracts.commands.EvolvableTokenTypeCommand -import com.r3.corda.lib.tokens.contracts.commands.Update import net.corda.samples.tokentofriend.states.CustomTokenState import net.corda.core.contracts.UniqueIdentifier import net.corda.core.identity.CordaX500Name @@ -12,7 +10,7 @@ import org.junit.Test class ContractTests { private val ledgerServices = MockServices() - val Operator = TestIdentity(CordaX500Name(organisation = "Alice", locality = "TestLand", country = "US")) + private val Operator = TestIdentity(CordaX500Name(organisation = "Alice", locality = "TestLand", country = "US")) @Test fun `issuer and recipient cannot have same email`() { diff --git a/Tokens/tokentofriend/contracts/src/test/kotlin/net/corda/samples/tokentofriend/contracts/StateTests.kt b/Tokens/tokentofriend/contracts/src/test/kotlin/net/corda/samples/tokentofriend/contracts/StateTests.kt index 8eb53516..44069352 100644 --- a/Tokens/tokentofriend/contracts/src/test/kotlin/net/corda/samples/tokentofriend/contracts/StateTests.kt +++ b/Tokens/tokentofriend/contracts/src/test/kotlin/net/corda/samples/tokentofriend/contracts/StateTests.kt @@ -1,8 +1,8 @@ package net.corda.samples.tokentofriend.contracts import net.corda.samples.tokentofriend.states.CustomTokenState -import groovy.util.GroovyTestCase.assertEquals import net.corda.testing.node.MockServices +import org.junit.Assert.assertEquals import org.junit.Test class StateTests { @@ -15,4 +15,4 @@ class StateTests { // Is the message field of the correct type? assertEquals(CustomTokenState::class.java.getDeclaredField("message").type, String::class.java) } -} \ No newline at end of file +} diff --git a/Tokens/tokentofriend/gradle.properties b/Tokens/tokentofriend/gradle.properties index 821429fb..1356e45d 100644 --- a/Tokens/tokentofriend/gradle.properties +++ b/Tokens/tokentofriend/gradle.properties @@ -1,4 +1,30 @@ +kotlin.incremental=false name=Tokentofriend Cordapp group=com.tokentofriend version=1.0 -kotlin.incremental=false \ No newline at end of file + +# Artifactory +artifactoryContextUrl = https://software.r3.com/artifactory + +corda_release_group=net.corda +corda_core_group=net.corda +corda_release_version=4.9 +corda_platform_version=10 +corda_gradle_plugins_version=5.1.0-RC01 +kotlin_plugin_version=1.3.31 +kotlin_version=1.2.71 +junit_version=4.13.2 +quasar_version=0.7.14_r3 +log4j_version=2.17.1 +slf4j_version=1.7.30 +netty_version=4.1.68.Final +gson_version=2.9.0 + +# This version is apparently incompatible with Gradle 7.4 +moowork_node_version=1.3.1 + +# Token +tokens_release_group=com.r3.corda.lib.tokens +tokens_release_version=1.2 + +spring_boot_version=2.0.2.RELEASE diff --git a/Tokens/tokentofriend/gradle/wrapper/gradle-wrapper.jar b/Tokens/tokentofriend/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 99340b4a..00000000 Binary files a/Tokens/tokentofriend/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Tokens/tokentofriend/gradle/wrapper/gradle-wrapper.properties b/Tokens/tokentofriend/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 0188225a..00000000 --- a/Tokens/tokentofriend/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -#Fri Aug 25 12:50:39 BST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip - diff --git a/Tokens/tokentofriend/gradlew b/Tokens/tokentofriend/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/Tokens/tokentofriend/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/Tokens/tokentofriend/gradlew.bat b/Tokens/tokentofriend/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/Tokens/tokentofriend/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/Tokens/tokentofriend/repositories.gradle b/Tokens/tokentofriend/repositories.gradle deleted file mode 100644 index 3198e5c6..00000000 --- a/Tokens/tokentofriend/repositories.gradle +++ /dev/null @@ -1,8 +0,0 @@ -repositories { - mavenLocal() - mavenCentral() - - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } -} diff --git a/Tokens/tokentofriend/runServers.sh b/Tokens/tokentofriend/runServers.sh old mode 100644 new mode 100755 index ba7f172a..18ead108 --- a/Tokens/tokentofriend/runServers.sh +++ b/Tokens/tokentofriend/runServers.sh @@ -1,4 +1,4 @@ #!/bin/sh -./gradlew runOperatoreServer & -./gradlew runUSWest1Server +../gradlew runOperatoreServer & +../gradlew runUSWest1Server diff --git a/Tokens/tokentofriend/settings.gradle b/Tokens/tokentofriend/settings.gradle index 2b08bb58..2468e6d1 100644 --- a/Tokens/tokentofriend/settings.gradle +++ b/Tokens/tokentofriend/settings.gradle @@ -1,3 +1,40 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-releases" + } + gradlePluginPortal() + } + + plugins { + id 'net.corda.plugins.cordapp' version corda_gradle_plugins_version + id 'net.corda.plugins.cordformation' version corda_gradle_plugins_version + id 'net.corda.plugins.quasar-utils' version corda_gradle_plugins_version + id 'org.jetbrains.kotlin.jvm' version kotlin_plugin_version + id 'org.springframework.boot' version spring_boot_version + id 'com.moowork.node' version moowork_node_version + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "$artifactoryContextUrl/corda" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url "$artifactoryContextUrl/corda-lib" + } + maven { + url 'https://repo.gradle.org/gradle/libs-releases' + } + } +} + include 'workflows' include 'contracts' -include 'clients' +//include 'clients' diff --git a/Tokens/tokentofriend/workflows/build.gradle b/Tokens/tokentofriend/workflows/build.gradle index 8a0b905d..21aff446 100644 --- a/Tokens/tokentofriend/workflows/build.gradle +++ b/Tokens/tokentofriend/workflows/build.gradle @@ -1,9 +1,12 @@ -apply plugin: 'net.corda.plugins.cordapp' -apply plugin: 'net.corda.plugins.quasar-utils' +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'net.corda.plugins.cordapp' + id 'net.corda.plugins.quasar-utils' +} cordapp { - targetPlatformVersion corda_platform_version - minimumPlatformVersion corda_platform_version + targetPlatformVersion corda_platform_version.toInteger() + minimumPlatformVersion corda_platform_version.toInteger() workflow { name "tokenToFriend Flows" vendor "Corda Open Source" @@ -13,11 +16,6 @@ cordapp { } sourceSets { - main { - resources { - srcDir rootProject.file("config/dev") - } - } test { resources { srcDir rootProject.file("config/test") @@ -33,27 +31,27 @@ sourceSets { } configurations { - integrationTestCompile.extendsFrom testCompile - integrationTestRuntime.extendsFrom testRuntime + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile "junit:junit:$junit_version" + cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testImplementation "$corda_release_group:corda-node-driver:$corda_release_version" + testImplementation "junit:junit:$junit_version" // Corda dependencies. - cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version" - cordaRuntime "$corda_release_group:corda:$corda_release_version" - testCompile "$corda_release_group:corda-node-driver:$corda_release_version" + cordaProvided "$corda_core_group:corda-core:$corda_release_version" // CorDapp dependencies. cordapp project(":contracts") + // Token SDK dependencies. - cordaCompile "$tokens_release_group:tokens-workflows:$tokens_release_version" + cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version" + cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version" } -task integrationTest(type: Test, dependsOn: []) { +tasks.register('integrationTest', Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath -} \ No newline at end of file +} diff --git a/Tokens/tokentofriend/workflows/src/test/kotlin/net/corda/samples/tokentofriend/FlowTests.kt b/Tokens/tokentofriend/workflows/src/test/kotlin/net/corda/samples/tokentofriend/FlowTests.kt index 7ad6f2b9..02b5055b 100644 --- a/Tokens/tokentofriend/workflows/src/test/kotlin/net/corda/samples/tokentofriend/FlowTests.kt +++ b/Tokens/tokentofriend/workflows/src/test/kotlin/net/corda/samples/tokentofriend/FlowTests.kt @@ -13,10 +13,9 @@ import net.corda.core.node.services.Vault import net.corda.core.node.services.vault.QueryCriteria import net.corda.core.utilities.getOrThrow import net.corda.testing.common.internal.testNetworkParameters -import net.corda.testing.core.singleIdentity import net.corda.testing.node.* -import java.util.* -import kotlin.test.assertEquals +import org.junit.Assert.assertEquals +import java.util.UUID class FlowTests { private lateinit var network: MockNetwork @@ -28,14 +27,17 @@ class FlowTests { @Before fun setup() { - network = MockNetwork(MockNetworkParameters(cordappsForAllNodes = listOf( - TestCordapp.findCordapp("net.corda.samples.tokentofriend.contracts"), - TestCordapp.findCordapp("net.corda.samples.tokentofriend.flows"), - TestCordapp.findCordapp("com.r3.corda.lib.tokens.contracts"), - TestCordapp.findCordapp("com.r3.corda.lib.tokens.workflows") - ), networkParameters = testNetworkParameters(minimumPlatformVersion = 4), - notarySpecs = listOf(MockNetworkNotarySpec(CordaX500Name("Notary","London","GB"))) - )) + network = MockNetwork( + MockNetworkParameters( + cordappsForAllNodes = listOf( + TestCordapp.findCordapp("net.corda.samples.tokentofriend.contracts"), + TestCordapp.findCordapp("net.corda.samples.tokentofriend.flows"), + TestCordapp.findCordapp("com.r3.corda.lib.tokens.contracts"), + TestCordapp.findCordapp("com.r3.corda.lib.tokens.workflows") + ), networkParameters = testNetworkParameters(minimumPlatformVersion = 4), + notarySpecs = listOf(MockNetworkNotarySpec(CordaX500Name("Notary", "London", "GB"))) + ) + ) a = network.createPartyNode() b = network.createPartyNode() c = network.createPartyNode() @@ -46,25 +48,34 @@ class FlowTests { @After fun tearDown() { - network.stopNodes() + if (::network.isInitialized) { + network.stopNodes() + } } + @Test fun `Check the correct message is stored`() { val msg = "Test Message" - val flow = CreateMyToken("Thomas@gmail.com","peter@gmail.com", msg) + val flow = CreateMyToken("Thomas@gmail.com", "peter@gmail.com", msg) val future = a.startFlow(flow) network.runNetwork() val tokenStateID = future.getOrThrow() - val inputCriteria = QueryCriteria.LinearStateQueryCriteria(uuid = listOf(tokenStateID.id),status = Vault.StateStatus.UNCONSUMED) - val storedState = a.services.vaultService.queryBy(CustomTokenState::class.java, criteria = inputCriteria).states.single().state.data + val inputCriteria = QueryCriteria.LinearStateQueryCriteria( + uuid = listOf(tokenStateID.id), + status = Vault.StateStatus.UNCONSUMED + ) + val storedState = a.services.vaultService.queryBy( + CustomTokenState::class.java, + criteria = inputCriteria + ).states.single().state.data assertEquals(storedState.message, msg) } @Test - fun `Check if non fungible token correctly created`(){ + fun `Check if non fungible token correctly created`() { val msg = "Token Creation" - val createTokenflow = CreateMyToken("Thomas@gmail.com","peter@gmail.com", msg) + val createTokenflow = CreateMyToken("Thomas@gmail.com", "peter@gmail.com", msg) val future = a.startFlow(createTokenflow) network.runNetwork() val tokenStateID = future.getOrThrow() @@ -74,22 +85,24 @@ class FlowTests { val resultString = future2.getOrThrow() println(resultString) val subString = resultString.indexOf("Token Id is: ") - val nonfungibleTokenId = resultString.substring(subString+13,resultString.indexOf("Storage Node is:")-1) - println("-"+ nonfungibleTokenId+"-") - val inputCriteria = QueryCriteria.LinearStateQueryCriteria(uuid = listOf(UUID.fromString(nonfungibleTokenId)),status = Vault.StateStatus.UNCONSUMED) - val storedNonFungibleTokenb = b.services.vaultService.queryBy(NonFungibleToken::class.java, criteria = inputCriteria).states - val storedNonFungibleTokenc = c.services.vaultService.queryBy(NonFungibleToken::class.java, criteria = inputCriteria).states - val storedNonFungibleTokend = d.services.vaultService.queryBy(NonFungibleToken::class.java, criteria = inputCriteria).states - val storedNonFungibleTokene = e.services.vaultService.queryBy(NonFungibleToken::class.java, criteria = inputCriteria).states + val nonfungibleTokenId = resultString.substring(subString + 13, resultString.indexOf("Storage Node is:") - 1) + println("-" + nonfungibleTokenId + "-") + val inputCriteria = QueryCriteria.LinearStateQueryCriteria( + uuid = listOf(UUID.fromString(nonfungibleTokenId)), + status = Vault.StateStatus.UNCONSUMED + ) + val storedNonFungibleTokenb = + b.services.vaultService.queryBy(NonFungibleToken::class.java, criteria = inputCriteria).states + val storedNonFungibleTokenc = + c.services.vaultService.queryBy(NonFungibleToken::class.java, criteria = inputCriteria).states + val storedNonFungibleTokend = + d.services.vaultService.queryBy(NonFungibleToken::class.java, criteria = inputCriteria).states + val storedNonFungibleTokene = + e.services.vaultService.queryBy(NonFungibleToken::class.java, criteria = inputCriteria).states - val storedToken = listOf(storedNonFungibleTokenb,storedNonFungibleTokenc,storedNonFungibleTokend,storedNonFungibleTokene) - .filter { it.isNotEmpty() }.single().single().state.data - println("-"+ storedToken.linearId+"-") + val storedToken = listOf(storedNonFungibleTokenb, storedNonFungibleTokenc, storedNonFungibleTokend, storedNonFungibleTokene) + .single { it.isNotEmpty() }.single().state.data + println("-" + storedToken.linearId + "-") assertEquals(storedToken.linearId, UniqueIdentifier(id = UUID.fromString(nonfungibleTokenId))) - } - - - - -} \ No newline at end of file +}