From f13a21cc6c3c221041a8056dd0c8c8b6c9456f87 Mon Sep 17 00:00:00 2001 From: Clinton Alexander Date: Tue, 27 Sep 2016 14:37:19 +0100 Subject: [PATCH 1/9] Can now publish corda to local repo with gradle publishToMavenLocal --- build.gradle | 3 ++- contracts/build.gradle | 22 ++++++++++++++++++++++ core/build.gradle | 24 +++++++++++++++++++++++- node/build.gradle | 22 ++++++++++++++++++++++ 4 files changed, 69 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index b2215b4c97..e5cd97eb1d 100644 --- a/build.gradle +++ b/build.gradle @@ -34,6 +34,7 @@ apply plugin: 'application' apply plugin: 'project-report' apply plugin: QuasarPlugin apply plugin: 'com.github.ben-manes.versions' +apply plugin: 'maven-publish' allprojects { apply plugin: 'java' @@ -243,4 +244,4 @@ task installTemplateNodes(dependsOn: 'buildCordaJAR') << { into "${buildDir}/nodes" } -} +} \ No newline at end of file diff --git a/contracts/build.gradle b/contracts/build.gradle index 9b506ea682..c484f5638a 100644 --- a/contracts/build.gradle +++ b/contracts/build.gradle @@ -27,3 +27,25 @@ sourceSets { } } } + +task sourceJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + +publishing { + publications { + contracts(MavenPublication) { + from components.java + artifactId 'contracts' + + artifact sourceJar + artifact javadocJar + } + } +} \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle index 2f060971a7..ae7c06a063 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -84,4 +84,26 @@ dependencies { compile "org.bouncycastle:bcpkix-jdk15on:${bouncycastle_version}" } -quasarScan.dependsOn('classes') +task sourceJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + +publishing { + publications { + core(MavenPublication) { + from components.java + artifactId 'core' + + artifact sourceJar + artifact javadocJar + } + } +} + +quasarScan.dependsOn('classes') \ No newline at end of file diff --git a/node/build.gradle b/node/build.gradle index 9de44530bf..a2f3ee9d12 100644 --- a/node/build.gradle +++ b/node/build.gradle @@ -141,4 +141,26 @@ quasarScan.dependsOn('classes', ':core:classes', ':contracts:classes') task integrationTest(type: Test) { testClassesDir = sourceSets.integrationTest.output.classesDir classpath = sourceSets.integrationTest.runtimeClasspath +} + +task sourceJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + +publishing { + publications { + node(MavenPublication) { + from components.java + artifactId 'node' + + artifact sourceJar + artifact javadocJar + } + } } \ No newline at end of file From 4cdb4352b6680bb6c529bf3f4e11d8aff043ea8a Mon Sep 17 00:00:00 2001 From: Clinton Alexander Date: Wed, 28 Sep 2016 13:46:00 +0100 Subject: [PATCH 2/9] Added corda capsule to output of publish. --- build.gradle | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/build.gradle b/build.gradle index e5cd97eb1d..14254a4b86 100644 --- a/build.gradle +++ b/build.gradle @@ -244,4 +244,21 @@ task installTemplateNodes(dependsOn: 'buildCordaJAR') << { into "${buildDir}/nodes" } +} + +task cordaJar(type: Jar, dependsOn: 'buildCordaJAR') { + classifier = 'sources' + from buildCordaJAR.outputs.getFiles() +} + +// TODO: Rename capsule to "corda" +publishing { + publications { + corda(MavenPublication) { + from components.java + artifactId 'corda' + + artifact buildCordaJAR + } + } } \ No newline at end of file From 4c79a74a8bb865244ff71ef4dfe7b9affeab8b5f Mon Sep 17 00:00:00 2001 From: Clinton Alexander Date: Wed, 28 Sep 2016 15:24:24 +0100 Subject: [PATCH 3/9] Only corda capsule is published to maven now. --- build.gradle | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 14254a4b86..4a20108633 100644 --- a/build.gradle +++ b/build.gradle @@ -246,19 +246,13 @@ task installTemplateNodes(dependsOn: 'buildCordaJAR') << { } -task cordaJar(type: Jar, dependsOn: 'buildCordaJAR') { - classifier = 'sources' - from buildCordaJAR.outputs.getFiles() -} - // TODO: Rename capsule to "corda" publishing { publications { corda(MavenPublication) { - from components.java artifactId 'corda' - artifact buildCordaJAR + artifact "${buildDir}/libs/corda.jar" } } } \ No newline at end of file From 25d10376de9dff0794fe0299a139a97b965b6319 Mon Sep 17 00:00:00 2001 From: Clinton Alexander Date: Wed, 28 Sep 2016 18:27:11 +0100 Subject: [PATCH 4/9] Now using the output of the buildCordaJAR target directly. --- build.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 4a20108633..72a6e668f4 100644 --- a/build.gradle +++ b/build.gradle @@ -246,13 +246,12 @@ task installTemplateNodes(dependsOn: 'buildCordaJAR') << { } -// TODO: Rename capsule to "corda" publishing { publications { corda(MavenPublication) { artifactId 'corda' - artifact "${buildDir}/libs/corda.jar" + artifact buildCordaJAR } } } \ No newline at end of file From 9a4cc04eb5d1ecee6c2a181920e1ba46bf8084cc Mon Sep 17 00:00:00 2001 From: Clinton Alexander Date: Thu, 29 Sep 2016 14:53:28 +0100 Subject: [PATCH 5/9] Moved source and javadoc publish tasks into a default publish tasks plugin. --- buildSrc/build.gradle | 2 ++ .../main/groovy/DefaultPublishTasks.groovy | 20 +++++++++++++++++++ contracts/build.gradle | 11 +--------- core/build.gradle | 12 +---------- node/build.gradle | 12 +---------- 5 files changed, 25 insertions(+), 32 deletions(-) create mode 100644 buildSrc/src/main/groovy/DefaultPublishTasks.groovy diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 2f036797bc..225d2b829e 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -1,3 +1,5 @@ +apply plugin: 'maven' + repositories { mavenCentral() } diff --git a/buildSrc/src/main/groovy/DefaultPublishTasks.groovy b/buildSrc/src/main/groovy/DefaultPublishTasks.groovy new file mode 100644 index 0000000000..140aeefaba --- /dev/null +++ b/buildSrc/src/main/groovy/DefaultPublishTasks.groovy @@ -0,0 +1,20 @@ +import org.gradle.api.* +import org.gradle.api.tasks.bundling.Jar +import org.gradle.api.tasks.javadoc.Javadoc + +/** + * A utility plugin that when applied will automatically create source and javadoc publishing tasks + */ +class DefaultPublishTasks implements Plugin { + void apply(Project project) { + project.task("sourceJar", type: Jar, dependsOn: project.classes) { + classifier = 'sources' + from project.sourceSets.main.allSource + } + + project.task("javadocJar", type: Jar, dependsOn: project.javadoc) { + classifier = 'javadoc' + from project.javadoc.destinationDir + } + } +} diff --git a/contracts/build.gradle b/contracts/build.gradle index c484f5638a..2d585d8d04 100644 --- a/contracts/build.gradle +++ b/contracts/build.gradle @@ -1,5 +1,6 @@ apply plugin: 'kotlin' apply plugin: CanonicalizerPlugin +apply plugin: DefaultPublishTasks repositories { mavenLocal() @@ -28,16 +29,6 @@ sourceSets { } } -task sourceJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - publishing { publications { contracts(MavenPublication) { diff --git a/core/build.gradle b/core/build.gradle index ae7c06a063..f75d0df4e6 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,7 +1,7 @@ apply plugin: 'kotlin' apply plugin: QuasarPlugin // Applying the maven plugin means this will get installed locally when running "gradle install" -apply plugin: 'maven' +apply plugin: DefaultPublishTasks buildscript { repositories { @@ -84,16 +84,6 @@ dependencies { compile "org.bouncycastle:bcpkix-jdk15on:${bouncycastle_version}" } -task sourceJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - publishing { publications { core(MavenPublication) { diff --git a/node/build.gradle b/node/build.gradle index a2f3ee9d12..104208501a 100644 --- a/node/build.gradle +++ b/node/build.gradle @@ -1,5 +1,6 @@ apply plugin: 'kotlin' apply plugin: QuasarPlugin +apply plugin: DefaultPublishTasks repositories { mavenLocal() @@ -16,7 +17,6 @@ repositories { //noinspection GroovyAssignabilityCheck configurations { - // we don't want isolated.jar in classPath, since we want to test jar being dynamically loaded as an attachment runtime.exclude module: 'isolated' @@ -143,16 +143,6 @@ task integrationTest(type: Test) { classpath = sourceSets.integrationTest.runtimeClasspath } -task sourceJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - publishing { publications { node(MavenPublication) { From 6a669b6aad0b798f2702d3352a745aa733195260 Mon Sep 17 00:00:00 2001 From: Clinton Alexander Date: Thu, 29 Sep 2016 14:55:23 +0100 Subject: [PATCH 6/9] Added a line that was accidentally removed. --- core/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/core/build.gradle b/core/build.gradle index f75d0df4e6..5f643a1866 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,6 +1,7 @@ apply plugin: 'kotlin' apply plugin: QuasarPlugin // Applying the maven plugin means this will get installed locally when running "gradle install" +apply plugin 'maven' apply plugin: DefaultPublishTasks buildscript { From 3612bee6f7c73bd90b760d9d6cf8e37276c55ba2 Mon Sep 17 00:00:00 2001 From: Clinton Alexander Date: Thu, 29 Sep 2016 14:55:59 +0100 Subject: [PATCH 7/9] Fixed a syntax error in gradle file. --- core/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/build.gradle b/core/build.gradle index 5f643a1866..86b7942e2a 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,7 +1,7 @@ apply plugin: 'kotlin' apply plugin: QuasarPlugin // Applying the maven plugin means this will get installed locally when running "gradle install" -apply plugin 'maven' +apply plugin: 'maven' apply plugin: DefaultPublishTasks buildscript { From 1a87faf224ed8c8c727dff8b001a829d9f133762 Mon Sep 17 00:00:00 2001 From: Clinton Alexander Date: Wed, 5 Oct 2016 10:46:46 +0100 Subject: [PATCH 8/9] Corda JAR now publishes without -capsule at the end. --- build.gradle | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 72a6e668f4..93cb377580 100644 --- a/build.gradle +++ b/build.gradle @@ -243,7 +243,6 @@ task installTemplateNodes(dependsOn: 'buildCordaJAR') << { filter(org.apache.tools.ant.filters.FixCrLfFilter.class, eol: org.apache.tools.ant.filters.FixCrLfFilter.CrLf.newInstance("lf")) into "${buildDir}/nodes" } - } publishing { @@ -251,7 +250,9 @@ publishing { corda(MavenPublication) { artifactId 'corda' - artifact buildCordaJAR + artifact buildCordaJAR { + classifier "" + } } } } \ No newline at end of file From 4d213698df779bbafbee66f40b442257f625c5fa Mon Sep 17 00:00:00 2001 From: Clinton Alexander Date: Wed, 5 Oct 2016 11:35:12 +0100 Subject: [PATCH 9/9] Updated docs to document building against Corda. --- docs/source/creating-a-cordapp.rst | 34 +++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/source/creating-a-cordapp.rst b/docs/source/creating-a-cordapp.rst index 87d2b7b3eb..1c81c9a5ee 100644 --- a/docs/source/creating-a-cordapp.rst +++ b/docs/source/creating-a-cordapp.rst @@ -77,4 +77,36 @@ This command line will start the debugger on port 5005 and pause the process awa .. _CordaPluginRegistry: api/com.r3corda.core.node/-corda-plugin-registry/index.html .. _ServiceHubInternal: api/com.r3corda.node.services.api/-service-hub-internal/index.html -.. _ServiceHub: api/com.r3corda.node.services.api/-service-hub/index.html \ No newline at end of file +.. _ServiceHub: api/com.r3corda.node.services.api/-service-hub/index.html + +Building Against Corda +---------------------- + +.. warning:: This feature is subject to rapid change + +Corda now supports publishing to Maven local to build against it. To publish to Maven local run the following in the +root directory of Corda + +.. code-block:: shell + + ./gradlew publishToMavenLocal + +This will publish corda-$version.jar, contracts-$version.jar, core-$version.jar and node-$version.jar to the +group com.r3corda. You can now depend on these as you normally would a Maven dependency. + +In Gradle you can depend on these by adding/modifying your build.gradle file to contain the following: + +.. code-block:: groovy + + repositories { + mavenLocal() + ... other repositories here ... + } + + dependencies { + compile "com.r3corda:core:$corda_version" + compile "com.r3corda:contracts:$corda_version" + compile "com.r3corda:node:$corda_version" + compile "com.r3corda:corda:$corda_version" + ... other dependencies here ... + }