diff --git a/build.gradle b/build.gradle index c4478eac3f..befd2a0ece 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' @@ -251,5 +252,16 @@ 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 { + publications { + corda(MavenPublication) { + artifactId 'corda' + + artifact buildCordaJAR { + classifier "" + } + } + } +} \ No newline at end of file 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 9b506ea682..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() @@ -27,3 +28,15 @@ sourceSets { } } } + +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 6eef9feb06..208e2d82c5 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -2,6 +2,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 { @@ -87,4 +88,16 @@ dependencies { compile "org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final" } -quasarScan.dependsOn('classes') +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/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 ... + } diff --git a/node/build.gradle b/node/build.gradle index 532db0a56f..3f9755876a 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' @@ -145,4 +145,16 @@ quasarScan.dependsOn('classes', ':core:classes', ':contracts:classes') task integrationTest(type: Test) { testClassesDir = sourceSets.integrationTest.output.classesDir classpath = sourceSets.integrationTest.runtimeClasspath +} + +publishing { + publications { + node(MavenPublication) { + from components.java + artifactId 'node' + + artifact sourceJar + artifact javadocJar + } + } } \ No newline at end of file