diff --git a/Features/attachment-blacklist/README.md b/Features/attachment-blacklist/README.md index bd1b517a..4c139f63 100644 --- a/Features/attachment-blacklist/README.md +++ b/Features/attachment-blacklist/README.md @@ -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..4ccc9062 100644 --- a/Features/attachment-blacklist/build.gradle +++ b/Features/attachment-blacklist/build.gradle @@ -1,112 +1,85 @@ -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' } - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform - 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" +buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - repositories { - mavenLocal() +subprojects { //Properties that you need to compile your project (The application) + buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } + } - mavenCentral() - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } + 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 +88,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 +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=Hiseville Deposit Bank,L=Sao Paulo,C=BR" @@ -132,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=George State Bank,L=New York,C=US" @@ -141,6 +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/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..46345ddc 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-SNAPSHOT +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..5bb7ec88 100644 --- a/Features/attachment-blacklist/settings.gradle +++ b/Features/attachment-blacklist/settings.gradle @@ -1,4 +1,36 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-dev" + } + 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..93b9fbfa 100644 --- a/Features/attachment-sendfile/build.gradle +++ b/Features/attachment-sendfile/build.gradle @@ -1,102 +1,85 @@ -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' } - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform - 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" +buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - 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) + buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } } + 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 +88,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] } node { @@ -114,7 +98,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 +107,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..e892e44d 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-SNAPSHOT +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..70c08db7 100644 --- a/Features/attachment-sendfile/settings.gradle +++ b/Features/attachment-sendfile/settings.gradle @@ -1,2 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-dev" + } + 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..85aa9a1f 100644 --- a/Features/confidentialIdentity-whistleblower/build.gradle +++ b/Features/confidentialIdentity-whistleblower/build.gradle @@ -1,131 +1,86 @@ -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() +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform - 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" +buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' - - repositories { - mavenLocal() +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - 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) + buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } } - tasks.withType(JavaCompile) { - options.compilerArgs << "-parameters" // Required for shell commands. + 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 +89,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 +99,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 +108,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..b7807e88 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-SNAPSHOT +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/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..70c08db7 100644 --- a/Features/confidentialIdentity-whistleblower/settings.gradle +++ b/Features/confidentialIdentity-whistleblower/settings.gradle @@ -1,2 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-dev" + } + 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..b7bdd75b 100644 --- a/Features/contractsdk-recordplayers/build.gradle +++ b/Features/contractsdk-recordplayers/build.gradle @@ -1,112 +1,83 @@ -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 + +buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } } -allprojects { // Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - repositories { - mavenLocal() +subprojects { //Properties that you need to compile your project (The application) + buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } + } - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } + 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 +91,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 +100,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 +109,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 +117,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..32b7f17a 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-SNAPSHOT +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..1d542e37 100644 --- a/Features/contractsdk-recordplayers/settings.gradle +++ b/Features/contractsdk-recordplayers/settings.gradle @@ -1,3 +1,39 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-dev" + } + 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..e34bbb6a 100644 --- a/Features/cordaService-autopayroll/build.gradle +++ b/Features/cordaService-autopayroll/build.gradle @@ -1,123 +1,84 @@ -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 + +buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - repositories { - mavenLocal() +subprojects { //Properties that you need to compile your project (The application) + buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } + } - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } + 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 +87,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 +96,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 +104,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..8942fab3 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-SNAPSHOT +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..70c08db7 100644 --- a/Features/cordaService-autopayroll/settings.gradle +++ b/Features/cordaService-autopayroll/settings.gradle @@ -1,2 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-dev" + } + 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..01694520 100644 --- a/Features/customlogging-yocordapp/build.gradle +++ b/Features/customlogging-yocordapp/build.gradle @@ -1,122 +1,84 @@ -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 + +buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - repositories { - mavenLocal() +subprojects { //Properties that you need to compile your project (The application) + buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } + } - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } + 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 +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" @@ -134,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" @@ -143,7 +105,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..f9ea2674 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-SNAPSHOT +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..70c08db7 100644 --- a/Features/customlogging-yocordapp/settings.gradle +++ b/Features/customlogging-yocordapp/settings.gradle @@ -1,2 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-dev" + } + 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..6268c007 100644 --- a/Features/customquery-carinsurance/build.gradle +++ b/Features/customquery-carinsurance/build.gradle @@ -1,114 +1,94 @@ -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() +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' +buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } +} - repositories { - mavenLocal() - mavenCentral() +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - maven { url 'https://software.r3.com/artifactory/corda-releases' } +subprojects { //Properties that you need to compile your project (The application) + buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } } - 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('java') { + java { + toolchain { + languageVersion = of(8) + } + } } -} - -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' } + 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 +98,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] cordapps.clear() } node { @@ -127,7 +108,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 +117,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..37c6e799 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-SNAPSHOT +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..25ff2dc7 100644 --- a/Features/customquery-carinsurance/settings.gradle +++ b/Features/customquery-carinsurance/settings.gradle @@ -1,3 +1,39 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-dev" + } + 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..5335ac1e 100644 --- a/Features/dockerform-yocordapp/build.gradle +++ b/Features/dockerform-yocordapp/build.gradle @@ -1,155 +1,77 @@ -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 + +buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - repositories { - mavenLocal() +subprojects { //Properties that you need to compile your project (The application) + buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } + } - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } + 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 +85,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 +111,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..712d85ee 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-SNAPSHOT +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..70c08db7 100644 --- a/Features/dockerform-yocordapp/settings.gradle +++ b/Features/dockerform-yocordapp/settings.gradle @@ -1,3 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-dev" + } + 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..01694520 100644 --- a/Features/encumbrance-avatar/build.gradle +++ b/Features/encumbrance-avatar/build.gradle @@ -1,109 +1,81 @@ -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' } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } +} - 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' +subprojects { //Properties that you need to compile your project (The application) + buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } + } - repositories { - mavenLocal() - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } + 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 +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" @@ -124,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" @@ -133,7 +105,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..548672a6 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-SNAPSHOT +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..70c08db7 100644 --- a/Features/encumbrance-avatar/settings.gradle +++ b/Features/encumbrance-avatar/settings.gradle @@ -1,3 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-dev" + } + 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/oracle-primenumber/gradle/wrapper/gradle-wrapper.properties b/Features/gradle/wrapper/gradle-wrapper.properties similarity index 92% rename from Features/oracle-primenumber/gradle/wrapper/gradle-wrapper.properties rename to Features/gradle/wrapper/gradle-wrapper.properties index 674bdda0..aa991fce 100644 --- a/Features/oracle-primenumber/gradle/wrapper/gradle-wrapper.properties +++ b/Features/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/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/confidentialIdentity-whistleblower/gradlew.bat b/Features/gradlew.bat similarity index 66% rename from Features/confidentialIdentity-whistleblower/gradlew.bat rename to Features/gradlew.bat index f9553162..107acd32 100644 --- a/Features/confidentialIdentity-whistleblower/gradlew.bat +++ b/Features/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/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..6021926f 100644 --- a/Features/notarychange-iou/build.gradle +++ b/Features/notarychange-iou/build.gradle @@ -1,103 +1,84 @@ -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 + +buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - repositories { - mavenLocal() +subprojects { //Properties that you need to compile your project (The application) + buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } + } - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } + 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 +88,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 +98,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 +106,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 +114,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..88771837 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-SNAPSHOT +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..70c08db7 100644 --- a/Features/notarychange-iou/settings.gradle +++ b/Features/notarychange-iou/settings.gradle @@ -1,3 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-dev" + } + 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..f8934ccc 100644 --- a/Features/observableStates-tradereporting/build.gradle +++ b/Features/observableStates-tradereporting/build.gradle @@ -1,122 +1,84 @@ -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 + +buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - repositories { - mavenLocal() +subprojects { //Properties that you need to compile your project (The application) + buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } + } - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } + 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 +88,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 +122,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..55c5daa0 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-SNAPSHOT +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..70c08db7 100644 --- a/Features/observableStates-tradereporting/settings.gradle +++ b/Features/observableStates-tradereporting/settings.gradle @@ -1,3 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-dev" + } + 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..4379e0c0 100644 --- a/Features/oracle-primenumber/build.gradle +++ b/Features/oracle-primenumber/build.gradle @@ -1,118 +1,85 @@ -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() +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform - 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" +buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - repositories { - mavenLocal() +subprojects { //Properties that you need to compile your project (The application) + buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } + } - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } + 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 +88,7 @@ task deployNodesKotlin(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } - cordapps = [] + rpcUsers = [] } node { @@ -131,9 +98,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 +107,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..f0daca01 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-SNAPSHOT +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/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..70c08db7 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-dev" + } + 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..053511c6 100644 --- a/Features/postgres-cordapp/build.gradle +++ b/Features/postgres-cordapp/build.gradle @@ -1,113 +1,82 @@ -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 + +buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } } -allprojects { //Properties that you need to compile your project (The application) - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - repositories { - mavenLocal() +subprojects { //Properties that you need to compile your project (The application) + buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } + } - mavenCentral() - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://jitpack.io' } + 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 +90,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10011") adminAddress("localhost:10021") } + rpcUsers = [] } node { @@ -132,11 +102,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 +118,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..e3ed2ddb 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-SNAPSHOT +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..5bb7ec88 100644 --- a/Features/postgres-cordapp/settings.gradle +++ b/Features/postgres-cordapp/settings.gradle @@ -1,3 +1,36 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-dev" + } + 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..be7ce527 100644 --- a/Features/queryableState-carinsurance/build.gradle +++ b/Features/queryableState-carinsurance/build.gradle @@ -1,114 +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() +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform - //springboot - spring_boot_version = '2.0.2.RELEASE' - spring_boot_gradle_plugin_version = '2.0.2.RELEASE' +buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } +} - repositories { - mavenLocal() - mavenCentral() +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - maven { url 'https://software.r3.com/artifactory/corda-releases' } +subprojects { //Properties that you need to compile your project (The application) + buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } } - 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('java') { + java { + toolchain { + languageVersion = of(8) + } + } } -} - -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' } + 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 +96,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } + rpcUsers = [] cordapps.clear() } node { @@ -127,7 +106,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 +115,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..ad0ce112 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-SNAPSHOT +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..25ff2dc7 100644 --- a/Features/queryableState-carinsurance/settings.gradle +++ b/Features/queryableState-carinsurance/settings.gradle @@ -1,3 +1,39 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-dev" + } + 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..59593df2 100644 --- a/Features/referenceStates-sanctionsBody/build.gradle +++ b/Features/referenceStates-sanctionsBody/build.gradle @@ -1,103 +1,84 @@ -buildscript { - 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 - 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() +buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } +} - repositories { - mavenCentral() +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - maven { - url 'https://software.r3.com/artifactory/corda-releases' +subprojects { //Properties that you need to compile your project (The application) + buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } - 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" - } -} - -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' } + 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 +89,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..c06b5747 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-SNAPSHOT +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..058f01b9 100644 --- a/Features/referenceStates-sanctionsBody/settings.gradle +++ b/Features/referenceStates-sanctionsBody/settings.gradle @@ -1,2 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-dev" + } + 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..aaf29530 100644 --- a/Features/schedulableState-heartbeat/build.gradle +++ b/Features/schedulableState-heartbeat/build.gradle @@ -1,103 +1,81 @@ -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() - } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform - 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" +buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } } -allprojects { - apply from: "${rootProject.projectDir}/repositories.gradle" - apply plugin: 'kotlin' +plugins { + id 'org.jetbrains.kotlin.jvm' apply false + id 'net.corda.plugins.cordformation' + id 'base' +} - repositories { - mavenLocal() +subprojects { //Properties that you need to compile your project (The application) + buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } + } - mavenCentral() - maven { url 'https://jitpack.io' } - maven { url 'https://software.r3.com/artifactory/corda' } - maven { url 'https://repo.gradle.org/gradle/libs-releases' } + 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 +86,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { address("localhost:10003") adminAddress("localhost:10043") } - cordapps = [] } node { @@ -118,7 +95,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..71701414 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-SNAPSHOT +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..058f01b9 100644 --- a/Features/schedulableState-heartbeat/settings.gradle +++ b/Features/schedulableState-heartbeat/settings.gradle @@ -1,2 +1,35 @@ +pluginManagement { + repositories { + maven { + url "$artifactoryContextUrl/corda-dev" + } + 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..c82ab370 100644 --- a/Features/state-reissuance/build.gradle +++ b/Features/state-reissuance/build.gradle @@ -1,98 +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' - //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' } +import static org.gradle.jvm.toolchain.JavaLanguageVersion.of +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import net.corda.plugins.Cordform + +buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } +} - 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' +subprojects { //Properties that you need to compile your project (The application) + buildscript { + configurations.classpath { + // FORCE Gradle to use latest SNAPSHOT plugins. + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } + } - 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' } + 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 +72,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 +89,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 +102,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 +111,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 +119,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 +127,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..82aac638 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-SNAPSHOT +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..7e9e15bf 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-dev" + } + 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 +}