Re-added the capsule file. Fixed deploy with another publish option.

This commit is contained in:
Clinton Alexander 2016-12-06 15:25:38 +00:00
parent a0d5426ced
commit 41b0b6c0b1
4 changed files with 127 additions and 16 deletions

View File

@ -0,0 +1,12 @@
package net.corda.plugins
class ProjectPublishExtension {
/**
* Use a different name from the current project name for publishing
*/
String name
/**
* True when we do not want to publish default Java components
*/
Boolean disableDefaultJar = false
}

View File

@ -18,6 +18,8 @@ import net.corda.plugins.bintray.*
*/
class PublishTasks implements Plugin<Project> {
Project project
String publishName
ProjectPublishExtension publishConfig
void apply(Project project) {
this.project = project
@ -25,37 +27,50 @@ class PublishTasks implements Plugin<Project> {
createTasks()
createExtensions()
createConfigurations()
checkAndConfigurePublishing()
project.afterEvaluate {
configurePublishingName()
checkAndConfigurePublishing()
}
}
void configurePublishingName() {
if(publishConfig.name != null) {
project.logger.info("Changing publishing name for ${project.name} to ${publishConfig.name}")
publishName = publishConfig.name
} else {
publishName = project.name
}
}
void checkAndConfigurePublishing() {
project.logger.info("Checking whether to publish ${project.name}")
project.logger.info("Checking whether to publish $publishName")
def bintrayConfig = project.rootProject.extensions.findByType(BintrayConfigExtension.class)
if((bintrayConfig != null) && (bintrayConfig.publications) && (bintrayConfig.publications.findAll { it == project.name }.size() > 0)) {
if((bintrayConfig != null) && (bintrayConfig.publications) && (bintrayConfig.publications.findAll { it == publishName }.size() > 0)) {
configurePublishing(bintrayConfig)
}
}
void configurePublishing(BintrayConfigExtension bintrayConfig) {
project.afterEvaluate {
project.logger.info("Configuring bintray for ${project.name}")
configureMavenPublish(bintrayConfig)
configureBintray(bintrayConfig)
}
project.logger.info("Configuring bintray for ${publishName}")
configureMavenPublish(bintrayConfig)
configureBintray(bintrayConfig)
}
void configureMavenPublish(BintrayConfigExtension bintrayConfig) {
project.apply([plugin: 'maven-publish'])
project.publishing.publications.create(project.name, MavenPublication) {
from project.components.java
project.publishing.publications.create(publishName, MavenPublication) {
if(!publishConfig.disableDefaultJar) {
from project.components.java
}
groupId project.group
artifactId project.name
artifactId publishName
artifact project.tasks.sourceJar
artifact project.tasks.javadocJar
project.configurations.publish.artifacts.each {
println("Adding artifact: $it")
project.logger.debug("Adding artifact: $it")
delegate.artifact it
}
@ -69,7 +84,7 @@ class PublishTasks implements Plugin<Project> {
pom.withXml {
asNode().children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
name project.name
name publishName
description project.description
url config.projectUrl
scm {
@ -100,10 +115,10 @@ class PublishTasks implements Plugin<Project> {
def bintray = project.extensions.findByName("bintray")
bintray.user = bintrayConfig.user
bintray.key = bintrayConfig.key
bintray.publications = [ project.name ]
bintray.publications = [ publishName ]
bintray.dryRun = bintrayConfig.dryRun ?: false
bintray.pkg.repo = bintrayConfig.repo
bintray.pkg.name = project.name
bintray.pkg.name = publishName
bintray.pkg.userOrg = bintrayConfig.org
bintray.pkg.licenses = bintrayConfig.licenses
bintray.pkg.version.gpg.sign = bintrayConfig.gpgSign ?: false
@ -130,6 +145,7 @@ class PublishTasks implements Plugin<Project> {
if(project == project.rootProject) {
project.extensions.create("bintrayConfig", BintrayConfigExtension)
}
publishConfig = project.extensions.create("publish", ProjectPublishExtension)
}
void createConfigurations() {

83
node/capsule/build.gradle Normal file
View File

@ -0,0 +1,83 @@
/**
* 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 standalone node'
repositories {
mavenLocal()
mavenCentral()
maven {
url 'http://oss.sonatype.org/content/repositories/snapshots'
}
jcenter()
maven {
url 'https://dl.bintray.com/kotlin/exposed'
}
}
configurations {
runtimeArtifacts.extendsFrom runtime
}
// 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')
}
task buildCordaJAR(type: FatCapsule, dependsOn: [':node:jar', 'buildCertSigningRequestUtilityJAR']) {
applicationClass 'net.corda.node.MainKt'
archiveName "corda-${corda_version}.jar"
applicationSource = files(project.tasks.findByName('jar'), 'build/classes/main/CordaCaplet.class', 'config/dev/log4j2.xml')
capsuleManifest {
appClassPath = ["jolokia-agent-war-${project.rootProject.ext.jolokia_version}.war"]
javaAgents = ["quasar-core-${quasar_version}-jdk8.jar"]
minJavaVersion = '1.8.0'
caplets = ['CordaCaplet']
}
}
task buildCertSigningRequestUtilityJAR(type: FatCapsule, dependsOn: [':node:jar']) {
applicationClass 'net.corda.node.utilities.certsigning.CertificateSignerKt'
archiveName 'certSigningRequestUtility.jar'
capsuleManifest {
systemProperties['log4j.configuration'] = 'log4j2.xml'
minJavaVersion = '1.8.0'
}
}
artifacts {
runtimeArtifacts buildCordaJAR
publish buildCordaJAR {
classifier ""
}
}
publish {
name = 'corda'
disableDefaultJar = true
}

View File

@ -5,7 +5,7 @@ include 'finance'
include 'finance:isolated'
include 'core'
include 'node'
include 'node:corda'
include 'node:capsule'
include 'client'
include 'experimental'
include 'experimental:sandbox'