Skip to content

Commit

Permalink
Update Features samples to use Gradle 7.4.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisr3 committed Apr 11, 2022
1 parent 4159e8e commit 300a675
Show file tree
Hide file tree
Showing 349 changed files with 3,478 additions and 7,765 deletions.
4 changes: 2 additions & 2 deletions Features/attachment-blacklist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
139 changes: 55 additions & 84 deletions Features/attachment-blacklist/build.gradle
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"]]]
}
}
24 changes: 14 additions & 10 deletions Features/attachment-blacklist/clients/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
apply plugin: 'org.springframework.boot'
apply plugin: 'kotlin'
plugins {
id 'org.jetbrains.kotlin.jvm'
id 'org.springframework.boot'
}

sourceSets {
main {
Expand All @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand All @@ -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)
}
}

/**
Expand All @@ -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<String>) {
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()
Expand Down
35 changes: 20 additions & 15 deletions Features/attachment-blacklist/contracts/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
}

This file was deleted.

Loading

0 comments on commit 300a675

Please sign in to comment.