From 3e83093987501af77b8fec2b7f0224a65323eac5 Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Fri, 10 Mar 2017 13:58:06 +0000 Subject: [PATCH 1/2] Add webserver Capsule configuration Add Capsule configuration for the webserver JAR, so that the classes-only `webserver.jar` is published as well as the full fat `corda-webserver.jar`. This is required for running the tutorial/template from IntelliJ. --- build.gradle | 4 +- docs/source/example-code/build.gradle | 2 +- node/webserver/build.gradle | 48 +------------ node/webserver/capsule/build.gradle | 91 ++++++++++++++++++++++++ samples/attachment-demo/build.gradle | 2 +- samples/bank-of-corda-demo/build.gradle | 2 +- samples/irs-demo/build.gradle | 2 +- samples/network-visualiser/build.gradle | 2 +- samples/raft-notary-demo/build.gradle | 2 +- samples/simm-valuation-demo/build.gradle | 2 +- samples/trader-demo/build.gradle | 2 +- settings.gradle | 1 + 12 files changed, 104 insertions(+), 56 deletions(-) create mode 100644 node/webserver/capsule/build.gradle diff --git a/build.gradle b/build.gradle index fba4305d3e..53e179e65a 100644 --- a/build.gradle +++ b/build.gradle @@ -119,7 +119,7 @@ dependencies { compile project(':node') compile "com.google.guava:guava:$guava_version" runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') } task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) { @@ -185,7 +185,7 @@ bintrayConfig { projectUrl = 'https://github.com/corda/corda' gpgSign = true gpgPassphrase = System.getenv('CORDA_BINTRAY_GPG_PASSPHRASE') - publications = ['client', 'core', 'corda', 'corda-webserver', 'finance', 'node', 'node-schemas', 'test-utils', 'jackson'] + publications = ['client', 'core', 'corda', 'corda-webserver', 'finance', 'node', 'node-schemas', 'test-utils', 'jackson', 'webserver'] license { name = 'Apache-2.0' url = 'https://www.apache.org/licenses/LICENSE-2.0' diff --git a/docs/source/example-code/build.gradle b/docs/source/example-code/build.gradle index 89cd1976ff..f0534edc17 100644 --- a/docs/source/example-code/build.gradle +++ b/docs/source/example-code/build.gradle @@ -49,7 +49,7 @@ dependencies { } runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') } mainClassName = "net.corda.docs.ClientRpcTutorialKt" diff --git a/node/webserver/build.gradle b/node/webserver/build.gradle index 036aa9a6ad..9650a28b51 100644 --- a/node/webserver/build.gradle +++ b/node/webserver/build.gradle @@ -1,10 +1,9 @@ apply plugin: 'kotlin' apply plugin: 'java' apply plugin: 'net.corda.plugins.publish-utils' -apply plugin: 'us.kirchmeier.capsule' // TODO: Break dependency on node and move to another location such as a submodule of client. -description 'Corda webserver module' +description 'Corda node web server' repositories { mavenLocal() @@ -18,7 +17,6 @@ repositories { configurations { integrationTestCompile.extendsFrom testCompile integrationTestRuntime.extendsFrom testRuntime - runtimeArtifacts } sourceSets { @@ -75,46 +73,4 @@ dependencies { task integrationTest(type: Test) { testClassesDir = sourceSets.integrationTest.output.classesDir classpath = sourceSets.integrationTest.runtimeClasspath -} - -publish { - name = 'corda-webserver' - publishWar = false // TODO: Use WAR instead of JAR - disableDefaultJar = true -} - -task buildWebserverJar(type: FatCapsule) { - applicationClass 'net.corda.webserver.WebServer' - archiveName "corda-webserver-${corda_version}.jar" - applicationSource = files(project.tasks.findByName('jar'), '../build/classes/main/CordaCaplet.class', 'config/dev/log4j2.xml') - from 'NOTICE' // Copy CDDL notice - - capsuleManifest { - applicationVersion = corda_version - javaAgents = ["quasar-core-${quasar_version}-jdk8.jar"] - systemProperties['visualvm.display.name'] = 'Corda Webserver' - systemProperties['corda.version'] = corda_version - minJavaVersion = '1.8.0' - // This version is known to work and avoids earlier 8u versions that have bugs. - minUpdateVersion['1.8'] = '102' - caplets = ['CordaCaplet'] - - // JVM configuration: - // - Constrain to small heap sizes to ease development on low end devices. - // - Switch to the G1 GC which is going to be the default in Java 9 and gives low pause times/string dedup. - // - // If you change these flags, please also update Driver.kt - jvmArgs = ['-Xmx200m', '-XX:+UseG1GC'] - } - - manifest { - attributes('Corda-Version': corda_version) - } -} - -artifacts { - runtimeArtifacts buildWebserverJar - publish buildWebserverJar { - classifier "" - } -} +} \ No newline at end of file diff --git a/node/webserver/capsule/build.gradle b/node/webserver/capsule/build.gradle new file mode 100644 index 0000000000..ef081d5eb0 --- /dev/null +++ b/node/webserver/capsule/build.gradle @@ -0,0 +1,91 @@ +/** + * This build.gradle exists to publish our capsule (executable fat jar) to maven. It cannot be placed in the + * node project because the bintray plugin cannot publish two modules from one project. + */ +apply plugin: 'net.corda.plugins.publish-utils' +apply plugin: 'us.kirchmeier.capsule' + +description 'Corda node web server capsule' + +repositories { + mavenLocal() + mavenCentral() + maven { + url 'http://oss.sonatype.org/content/repositories/snapshots' + } + jcenter() + maven { + url 'https://dl.bintray.com/kotlin/exposed' + } +} + +configurations { + runtimeArtifacts +} + +// Force the Caplet to target Java 6. This ensures that running 'java -jar corda.jar' on any Java 6 VM upwards +// will get as far as the Capsule version checks, meaning that if your JVM is too old, you will at least get +// a sensible error message telling you what to do rather than a bytecode version exception that doesn't. +// If we introduce .java files into this module that need Java 8+ then we will have to push the caplet into +// its own module so its target can be controlled individually, but for now this suffices. +sourceCompatibility = 1.6 +targetCompatibility = 1.6 + +sourceSets { + test { + resources { + srcDir "../../../config/test" + } + } + main { + resources { + srcDir "../../../config/dev" + } + } +} + +dependencies { + compile project(':node:webserver') +} + +task buildWebserverJar(type: FatCapsule) { + applicationClass 'net.corda.webserver.WebServer' + archiveName "corda-webserver-${corda_version}.jar" + applicationSource = files(project.tasks.findByName('jar'), '../build/classes/main/CordaCaplet.class', 'config/dev/log4j2.xml') + from 'NOTICE' // Copy CDDL notice + + capsuleManifest { + applicationVersion = corda_version + javaAgents = ["quasar-core-${quasar_version}-jdk8.jar"] + systemProperties['visualvm.display.name'] = 'Corda Webserver' + systemProperties['corda.version'] = corda_version + minJavaVersion = '1.8.0' + // This version is known to work and avoids earlier 8u versions that have bugs. + minUpdateVersion['1.8'] = '102' + caplets = ['CordaCaplet'] + + // JVM configuration: + // - Constrain to small heap sizes to ease development on low end devices. + // - Switch to the G1 GC which is going to be the default in Java 9 and gives low pause times/string dedup. + // + // If you change these flags, please also update Driver.kt + jvmArgs = ['-Xmx200m', '-XX:+UseG1GC'] + } + + manifest { + attributes('Corda-Version': corda_version) + } +} + +artifacts { + runtimeArtifacts buildWebserverJar + publish buildWebserverJar { + classifier "" + } +} + +publish { + name = 'corda-webserver' + publishWar = false // TODO: Use WAR instead of JAR + disableDefaultJar = true +} \ No newline at end of file diff --git a/samples/attachment-demo/build.gradle b/samples/attachment-demo/build.gradle index bcc0480780..2f794d1e64 100644 --- a/samples/attachment-demo/build.gradle +++ b/samples/attachment-demo/build.gradle @@ -46,7 +46,7 @@ dependencies { // Corda integration dependencies runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') compile project(':core') compile project(':test-utils') diff --git a/samples/bank-of-corda-demo/build.gradle b/samples/bank-of-corda-demo/build.gradle index ecdcb39273..54e28af97f 100644 --- a/samples/bank-of-corda-demo/build.gradle +++ b/samples/bank-of-corda-demo/build.gradle @@ -46,7 +46,7 @@ dependencies { // Corda integration dependencies runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') compile project(':core') compile project(':client') compile project(':node') diff --git a/samples/irs-demo/build.gradle b/samples/irs-demo/build.gradle index 2a3ef1b15e..5c067cdef5 100644 --- a/samples/irs-demo/build.gradle +++ b/samples/irs-demo/build.gradle @@ -49,7 +49,7 @@ dependencies { // Corda integration dependencies runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') compile project(':core') compile project(':finance') compile project(':node:webserver') diff --git a/samples/network-visualiser/build.gradle b/samples/network-visualiser/build.gradle index bfb7fc9efa..95cb0aaf7a 100644 --- a/samples/network-visualiser/build.gradle +++ b/samples/network-visualiser/build.gradle @@ -22,7 +22,7 @@ dependencies { // Corda integration dependencies runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') compile project(':core') compile project(':finance') testCompile project(':test-utils') diff --git a/samples/raft-notary-demo/build.gradle b/samples/raft-notary-demo/build.gradle index c6f17db1a2..364c01744d 100644 --- a/samples/raft-notary-demo/build.gradle +++ b/samples/raft-notary-demo/build.gradle @@ -46,7 +46,7 @@ dependencies { // Corda integration dependencies runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') compile project(':core') compile project(':client') compile project(':node') diff --git a/samples/simm-valuation-demo/build.gradle b/samples/simm-valuation-demo/build.gradle index 18b4a68104..d22a291e3a 100644 --- a/samples/simm-valuation-demo/build.gradle +++ b/samples/simm-valuation-demo/build.gradle @@ -54,7 +54,7 @@ dependencies { // Corda integration dependencies runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') compile project(':core') compile project(':node') compile project(':node:webserver') diff --git a/samples/trader-demo/build.gradle b/samples/trader-demo/build.gradle index 2d5422d4f5..ef9f0e58de 100644 --- a/samples/trader-demo/build.gradle +++ b/samples/trader-demo/build.gradle @@ -46,7 +46,7 @@ dependencies { // Corda integration dependencies runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') compile project(':core') compile project(':finance') compile project(':test-utils') diff --git a/settings.gradle b/settings.gradle index d177b9b923..4c4c35d1ff 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,6 +8,7 @@ include 'node-schemas' include 'node' include 'node:capsule' include 'node:webserver' +include 'node:webserver:capsule' include 'client' include 'client:jackson' include 'experimental' From 20282b5d53348f2197c339e5d0c6dda0cc9d8608 Mon Sep 17 00:00:00 2001 From: Clinton Alexander Date: Tue, 14 Mar 2017 12:00:36 +0000 Subject: [PATCH 2/2] Renamed webserver capsule to webcapsule module to avoid clashes with the node capsule --- build.gradle | 2 +- docs/source/example-code/build.gradle | 2 +- .../kapt/main/net/corda/node/services/vault/schemas/Models.java | 2 +- node/webserver/{capsule => webcapsule}/build.gradle | 0 samples/attachment-demo/build.gradle | 2 +- samples/bank-of-corda-demo/build.gradle | 2 +- samples/irs-demo/build.gradle | 2 +- samples/network-visualiser/build.gradle | 2 +- samples/raft-notary-demo/build.gradle | 2 +- samples/simm-valuation-demo/build.gradle | 2 +- samples/trader-demo/build.gradle | 2 +- settings.gradle | 2 +- 12 files changed, 11 insertions(+), 11 deletions(-) rename node/webserver/{capsule => webcapsule}/build.gradle (100%) diff --git a/build.gradle b/build.gradle index 53e179e65a..2c74fa2f43 100644 --- a/build.gradle +++ b/build.gradle @@ -119,7 +119,7 @@ dependencies { compile project(':node') compile "com.google.guava:guava:$guava_version" runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:webcapsule", configuration: 'runtimeArtifacts') } task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) { diff --git a/docs/source/example-code/build.gradle b/docs/source/example-code/build.gradle index f0534edc17..49c2069d4c 100644 --- a/docs/source/example-code/build.gradle +++ b/docs/source/example-code/build.gradle @@ -49,7 +49,7 @@ dependencies { } runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:webcapsule", configuration: 'runtimeArtifacts') } mainClassName = "net.corda.docs.ClientRpcTutorialKt" diff --git a/node-schemas/build/generated/source/kapt/main/net/corda/node/services/vault/schemas/Models.java b/node-schemas/build/generated/source/kapt/main/net/corda/node/services/vault/schemas/Models.java index 199b5265ac..663119bef1 100644 --- a/node-schemas/build/generated/source/kapt/main/net/corda/node/services/vault/schemas/Models.java +++ b/node-schemas/build/generated/source/kapt/main/net/corda/node/services/vault/schemas/Models.java @@ -8,9 +8,9 @@ import javax.annotation.Generated; @Generated("io.requery.processor.EntityProcessor") public class Models { public static final EntityModel VAULT = new EntityModelBuilder("vault") + .addType(VaultStatesEntity.$TYPE) .addType(VaultTxnNoteEntity.$TYPE) .addType(VaultCashBalancesEntity.$TYPE) - .addType(VaultStatesEntity.$TYPE) .build(); private Models() { diff --git a/node/webserver/capsule/build.gradle b/node/webserver/webcapsule/build.gradle similarity index 100% rename from node/webserver/capsule/build.gradle rename to node/webserver/webcapsule/build.gradle diff --git a/samples/attachment-demo/build.gradle b/samples/attachment-demo/build.gradle index 2f794d1e64..19f0a05a3a 100644 --- a/samples/attachment-demo/build.gradle +++ b/samples/attachment-demo/build.gradle @@ -46,7 +46,7 @@ dependencies { // Corda integration dependencies runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:webcapsule", configuration: 'runtimeArtifacts') compile project(':core') compile project(':test-utils') diff --git a/samples/bank-of-corda-demo/build.gradle b/samples/bank-of-corda-demo/build.gradle index 54e28af97f..b6dbfdfbbb 100644 --- a/samples/bank-of-corda-demo/build.gradle +++ b/samples/bank-of-corda-demo/build.gradle @@ -46,7 +46,7 @@ dependencies { // Corda integration dependencies runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:webcapsule", configuration: 'runtimeArtifacts') compile project(':core') compile project(':client') compile project(':node') diff --git a/samples/irs-demo/build.gradle b/samples/irs-demo/build.gradle index 5c067cdef5..11222e2f76 100644 --- a/samples/irs-demo/build.gradle +++ b/samples/irs-demo/build.gradle @@ -49,7 +49,7 @@ dependencies { // Corda integration dependencies runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:webcapsule", configuration: 'runtimeArtifacts') compile project(':core') compile project(':finance') compile project(':node:webserver') diff --git a/samples/network-visualiser/build.gradle b/samples/network-visualiser/build.gradle index 95cb0aaf7a..97bbda8538 100644 --- a/samples/network-visualiser/build.gradle +++ b/samples/network-visualiser/build.gradle @@ -22,7 +22,7 @@ dependencies { // Corda integration dependencies runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:webcapsule", configuration: 'runtimeArtifacts') compile project(':core') compile project(':finance') testCompile project(':test-utils') diff --git a/samples/raft-notary-demo/build.gradle b/samples/raft-notary-demo/build.gradle index 364c01744d..7e043643a7 100644 --- a/samples/raft-notary-demo/build.gradle +++ b/samples/raft-notary-demo/build.gradle @@ -46,7 +46,7 @@ dependencies { // Corda integration dependencies runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:webcapsule", configuration: 'runtimeArtifacts') compile project(':core') compile project(':client') compile project(':node') diff --git a/samples/simm-valuation-demo/build.gradle b/samples/simm-valuation-demo/build.gradle index d22a291e3a..6712d91ef5 100644 --- a/samples/simm-valuation-demo/build.gradle +++ b/samples/simm-valuation-demo/build.gradle @@ -54,7 +54,7 @@ dependencies { // Corda integration dependencies runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:webcapsule", configuration: 'runtimeArtifacts') compile project(':core') compile project(':node') compile project(':node:webserver') diff --git a/samples/trader-demo/build.gradle b/samples/trader-demo/build.gradle index ef9f0e58de..ea3cb45ec9 100644 --- a/samples/trader-demo/build.gradle +++ b/samples/trader-demo/build.gradle @@ -46,7 +46,7 @@ dependencies { // Corda integration dependencies runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts') - runtime project(path: ":node:webserver:capsule", configuration: 'runtimeArtifacts') + runtime project(path: ":node:webserver:webcapsule", configuration: 'runtimeArtifacts') compile project(':core') compile project(':finance') compile project(':test-utils') diff --git a/settings.gradle b/settings.gradle index 4c4c35d1ff..8055c23454 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,7 +8,7 @@ include 'node-schemas' include 'node' include 'node:capsule' include 'node:webserver' -include 'node:webserver:capsule' +include 'node:webserver:webcapsule' include 'client' include 'client:jackson' include 'experimental'