Skip to content

Commit 43b455a

Browse files
committed
Update Features samples to use Gradle 7.4.2.
1 parent 7628115 commit 43b455a

File tree

349 files changed

+3478
-7765
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

349 files changed

+3478
-7765
lines changed

Features/attachment-blacklist/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ Before attempting to reach any agreements, you must upload the blacklist as an a
4343
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
4444
project's root folder:
4545

46-
* Unix/Mac OSX: ` ./gradlew uploadBlacklist`
47-
* Windows: `gradlew uploadBlacklist`
46+
* Unix/Mac OSX: ` ../gradlew uploadBlacklist`
47+
* Windows: `..\gradlew uploadBlacklist`
4848

4949
Or by running the `Upload blacklist` run configuration from IntelliJ.
5050

Lines changed: 55 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,85 @@
1-
buildscript {
2-
// ext.kotlin_version = '1.3.31'
3-
Properties constants = new Properties()
4-
file("$projectDir/../constants.properties").withInputStream { constants.load(it) }
5-
6-
ext {
7-
corda_release_group = constants.getProperty("cordaReleaseGroup")
8-
corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup")
9-
corda_release_version = constants.getProperty("cordaVersion")
10-
corda_core_release_version = constants.getProperty("cordaCoreVersion")
11-
corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion")
12-
kotlin_version = constants.getProperty("kotlinVersion")
13-
junit_version = constants.getProperty("junitVersion")
14-
quasar_version = constants.getProperty("quasarVersion")
15-
log4j_version = constants.getProperty("log4jVersion")
16-
slf4j_version = constants.getProperty("slf4jVersion")
17-
corda_platform_version = constants.getProperty("platformVersion").toInteger()
18-
spring_boot_version = '2.0.2.RELEASE'
19-
ext.spring_boot_gradle_plugin_version = '2.0.2.RELEASE'
20-
}
21-
22-
repositories {
23-
mavenLocal()
24-
mavenCentral()
25-
26-
maven { url 'https://software.r3.com/artifactory/corda-releases' }
27-
}
1+
import static org.gradle.jvm.toolchain.JavaLanguageVersion.of
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
import net.corda.plugins.Cordform
284

29-
dependencies {
30-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
31-
classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version"
32-
classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version"
33-
classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version"
34-
classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version"
5+
buildscript {
6+
configurations.classpath {
7+
// FORCE Gradle to use latest SNAPSHOT plugins.
8+
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
359
}
3610
}
3711

38-
allprojects {
39-
apply from: "${rootProject.projectDir}/repositories.gradle"
40-
apply plugin: 'kotlin'
12+
plugins {
13+
id 'org.jetbrains.kotlin.jvm' apply false
14+
id 'net.corda.plugins.cordformation'
15+
id 'base'
16+
}
4117

42-
repositories {
43-
mavenLocal()
18+
subprojects { //Properties that you need to compile your project (The application)
19+
buildscript {
20+
configurations.classpath {
21+
// FORCE Gradle to use latest SNAPSHOT plugins.
22+
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
23+
}
24+
}
4425

45-
mavenCentral()
46-
maven { url 'https://jitpack.io' }
47-
maven { url 'https://software.r3.com/artifactory/corda' }
48-
maven { url 'https://repo.gradle.org/gradle/libs-releases' }
26+
pluginManager.withPlugin('java') {
27+
java {
28+
toolchain {
29+
languageVersion = of(8)
30+
}
31+
}
4932
}
5033

51-
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
34+
tasks.withType(KotlinCompile).configureEach {
5235
kotlinOptions {
53-
languageVersion = "1.2"
54-
apiVersion = "1.2"
55-
jvmTarget = "1.8"
36+
languageVersion = '1.2'
37+
apiVersion = '1.2'
38+
jvmTarget = '1.8'
5639
javaParameters = true // Useful for reflection.
40+
freeCompilerArgs += [
41+
'-Xjvm-default=enable'
42+
]
5743
}
5844
}
5945

60-
jar {
61-
// This makes the JAR's SHA-256 hash repeatable.
62-
preserveFileTimestamps = false
63-
reproducibleFileOrder = true
64-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
65-
}
66-
67-
}
68-
69-
apply plugin: 'net.corda.plugins.cordapp'
70-
apply plugin: 'net.corda.plugins.cordformation'
71-
apply plugin: 'net.corda.plugins.quasar-utils'
72-
73-
sourceSets {
74-
main {
75-
resources {
76-
srcDir rootProject.file("config/dev")
46+
configurations.matching { it.name.endsWith("Classpath") }.configureEach {
47+
resolutionStrategy {
48+
dependencySubstitution {
49+
substitute module('com.fasterxml.jackson.module:jackson-module-kotlin') with module("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7")
50+
substitute module('org.gradle:gradle-tooling-api') with module("org.gradle:gradle-tooling-api:${gradle.gradleVersion}")
51+
}
7752
}
7853
}
7954
}
8055

8156
//Module dependencis
8257
dependencies {
83-
// Corda dependencies.
84-
cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version"
85-
cordaRuntime "$corda_release_group:corda-node-api:$corda_release_version"
86-
cordaRuntime "$corda_release_group:corda:$corda_release_version"
58+
cordaBootstrapper "$corda_release_group:corda-node-api:$corda_release_version"
59+
cordaBootstrapper "org.slf4j:slf4j-simple:$slf4j_version"
60+
corda "$corda_release_group:corda:$corda_release_version"
8761

8862
// CorDapp dependencies.
89-
cordapp project(":workflows")
90-
cordapp project(":contracts")
63+
cordapp project(':workflows')
64+
cordapp project(':contracts')
9165

92-
cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}"
93-
cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}"
94-
cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version"
66+
cordaDriver "$corda_release_group:corda-shell:$corda_release_version"
9567
}
9668

97-
98-
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
69+
tasks.register('deployNodes', Cordform) {
70+
/* This property will load the CorDapps to each of the node by default, including the Notary. You can find them
71+
* in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand
72+
* the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load
73+
* the Corda network bootstrapper.
74+
*/
9975
nodeDefaults {
100-
projectCordapp {
101-
deploy = false
102-
}
10376
cordapp project(':contracts')
10477
cordapp project(':workflows')
105-
106-
runSchemaMigration = true
107-
projectCordapp { deploy = true }
78+
rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
79+
runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid
80+
//problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change
81+
//it to false for quicker project compiling time.
10882
}
109-
11083
node {
11184
name "O=Notary,L=London,C=GB"
11285
notary = [validating: false]
@@ -115,6 +88,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
11588
address("localhost:10003")
11689
adminAddress("localhost:10043")
11790
}
91+
rpcUsers = []
11892
}
11993
node {
12094
name "O=Monogram Bank,L=London,C=GB"
@@ -123,7 +97,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
12397
address("localhost:10006")
12498
adminAddress("localhost:10046")
12599
}
126-
rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
127100
}
128101
node {
129102
name "O=Hiseville Deposit Bank,L=Sao Paulo,C=BR"
@@ -132,7 +105,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
132105
address("localhost:10009")
133106
adminAddress("localhost:10049")
134107
}
135-
rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
136108
}
137109
node {
138110
name "O=George State Bank,L=New York,C=US"
@@ -141,6 +113,5 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
141113
address("localhost:10012")
142114
adminAddress("localhost:10052")
143115
}
144-
rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
145116
}
146117
}

Features/attachment-blacklist/clients/build.gradle

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
apply plugin: 'org.springframework.boot'
2-
apply plugin: 'kotlin'
1+
plugins {
2+
id 'org.jetbrains.kotlin.jvm'
3+
id 'org.springframework.boot'
4+
}
35

46
sourceSets {
57
main {
@@ -11,26 +13,28 @@ sourceSets {
1113

1214
dependencies {
1315
// Corda dependencies.
14-
compile "$corda_release_group:corda-rpc:$corda_release_version"
16+
implementation "$corda_release_group:corda-rpc:$corda_release_version"
1517

1618
// CorDapp dependencies.
17-
compile project(":contracts")
18-
compile project(":workflows")
19+
implementation project(':contracts')
20+
implementation project(':workflows')
21+
implementation project(path: ':contracts', configuration: 'testArtifacts')
1922

20-
compile("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") {
23+
implementation("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") {
2124
exclude group: "org.springframework.boot", module: "spring-boot-starter-logging"
2225
}
2326

24-
compile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}"
25-
compile "org.apache.logging.log4j:log4j-web:${log4j_version}"
26-
compile "org.slf4j:jul-to-slf4j:$slf4j_version"
27+
runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version"
28+
runtimeOnly "org.apache.logging.log4j:log4j-web:$log4j_version"
29+
runtimeOnly "org.slf4j:jul-to-slf4j:$slf4j_version"
2730
}
2831

2932
springBoot {
3033
mainClassName = "net.corda.samples.blacklist.webserver.Server"
3134
}
3235

33-
task uploadBlacklist(type: JavaExec, dependsOn: assemble) {
36+
tasks.register('uploadBlacklist', JavaExec) {
37+
dependsOn assemble
3438
classpath = sourceSets.main.runtimeClasspath
3539
main = 'net.corda.samples.blacklist.clients.ClientKt'
3640
args 'localhost:10006', 'localhost:10009', 'localhost:10012'

Features/attachment-blacklist/clients/src/main/kotlin/net/corda/samples/blacklist/clients/Client.kt

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import net.corda.core.crypto.SecureHash
55
import net.corda.core.messaging.CordaRPCOps
66
import net.corda.core.utilities.NetworkHostAndPort.Companion.parse
77
import net.corda.core.utilities.loggerFor
8-
import net.corda.examples.attachments.ATTACHMENT_EXPECTED_CONTENTS
9-
import net.corda.examples.attachments.ATTACHMENT_FILE_NAME
10-
import net.corda.examples.attachments.BLACKLIST_JAR_PATH
8+
import net.corda.samples.blacklist.BLACKLISTED_PARTIES
9+
import net.corda.samples.blacklist.BLACKLIST_JAR_NAME
10+
import net.corda.samples.blacklist.contracts.AgreementContract.Companion.BLACKLIST_FILE_NAME
1111
import org.slf4j.Logger
12-
import java.io.File
12+
import java.io.FileNotFoundException
1313
import java.util.jar.JarInputStream
1414

1515
/**
@@ -31,26 +31,28 @@ private class UploadBlacklistClient {
3131
val rpcConnection = CordaRPCClient(nodeAddress).start("user1", "test")
3232
val proxy = rpcConnection.proxy
3333

34-
val attachmentHash = uploadAttachment(proxy, BLACKLIST_JAR_PATH)
34+
val attachmentHash = uploadAttachment(proxy, BLACKLIST_JAR_NAME)
3535
logger.info("Blacklist uploaded to node at $nodeAddress")
3636

3737
val attachmentJar = downloadAttachment(proxy, attachmentHash)
3838
logger.info("Blacklist downloaded from node at $nodeAddress")
3939

40-
checkAttachment(attachmentJar, ATTACHMENT_FILE_NAME, ATTACHMENT_EXPECTED_CONTENTS)
40+
checkAttachment(attachmentJar, BLACKLIST_FILE_NAME, BLACKLISTED_PARTIES)
4141
logger.info("Attachment contents checked on node at $nodeAddress")
4242

4343
rpcConnection.notifyServerAndClose()
4444
}
4545
}
46-
}
4746

48-
/**
49-
* Uploads the attachment at [attachmentPath] to the node.
50-
*/
51-
private fun uploadAttachment(proxy: CordaRPCOps, attachmentPath: String): SecureHash {
52-
val attachmentUploadInputStream = File(attachmentPath).inputStream()
53-
return proxy.uploadAttachment(attachmentUploadInputStream)
47+
/**
48+
* Uploads the attachment at [attachmentPath] to the node.
49+
*/
50+
@Suppress("SameParameterValue")
51+
private fun uploadAttachment(proxy: CordaRPCOps, attachmentPath: String): SecureHash {
52+
val attachmentUploadInputStream = javaClass.classLoader.getResourceAsStream(attachmentPath)
53+
?: throw FileNotFoundException("$attachmentPath not found")
54+
return proxy.uploadAttachment(attachmentUploadInputStream)
55+
}
5456
}
5557

5658
/**
@@ -64,10 +66,12 @@ private fun downloadAttachment(proxy: CordaRPCOps, attachmentHash: SecureHash):
6466
/**
6567
* Checks the [expectedFileName] and [expectedContents] of the downloaded [attachmentJar].
6668
*/
69+
@Suppress("SameParameterValue")
6770
private fun checkAttachment(attachmentJar: JarInputStream, expectedFileName: String, expectedContents: List<String>) {
68-
var name = attachmentJar.nextEntry.name
71+
var name: String? = null
6972
while (name != expectedFileName) {
70-
name = attachmentJar.nextEntry.name
73+
val jarEntry = attachmentJar.nextEntry ?: throw FileNotFoundException("$expectedFileName not found")
74+
name = jarEntry.name
7175
}
7276

7377
val contents = attachmentJar.bufferedReader().readLines()
Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
apply plugin: 'net.corda.plugins.cordapp'
1+
plugins {
2+
id 'org.jetbrains.kotlin.jvm'
3+
id 'net.corda.plugins.cordapp'
4+
}
25

36
cordapp {
4-
targetPlatformVersion corda_platform_version
5-
minimumPlatformVersion corda_platform_version
7+
targetPlatformVersion corda_platform_version.toInteger()
8+
minimumPlatformVersion corda_platform_version.toInteger()
69

710
contract {
811
name "Attachment Blacklist"
@@ -12,24 +15,26 @@ cordapp {
1215
}
1316
}
1417

15-
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
16-
kotlinOptions {
17-
languageVersion = "1.2"
18-
apiVersion = "1.2"
19-
jvmTarget = "1.8"
20-
javaParameters = true // Useful for reflection.
18+
configurations {
19+
testArtifacts {
20+
canBeResolved = false
2121
}
2222
}
2323

2424
dependencies {
25-
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
25+
cordaProvided "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
26+
testImplementation "$corda_release_group:corda-node-driver:$corda_release_version"
27+
testImplementation "junit:junit:$junit_version"
2628

2729
// Corda dependencies.
28-
cordaCompile "$corda_release_group:corda-core:$corda_release_version"
29-
testCompile "$corda_release_group:corda-node-driver:$corda_release_version"
30+
cordaProvided "$corda_core_group:corda-core:$corda_release_version"
31+
}
32+
33+
def testJar = tasks.register('testJar', Jar) {
34+
archiveClassifier = 'tests'
35+
from sourceSets.test.output
3036
}
3137

32-
jar {
33-
// CorDapps do not configure a Node's logging.
34-
exclude '**/log4j2*.xml'
38+
artifacts {
39+
testArtifacts testJar
3540
}

Features/attachment-blacklist/contracts/src/main/kotlin/net/corda/samples/blacklist/Constants.kt

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)