From 0ccfae252fdabd166f2be00f84df73ade08f2195 Mon Sep 17 00:00:00 2001 From: Clinton Date: Tue, 18 Jul 2017 12:34:56 +0100 Subject: [PATCH] POMs generated by publishing are now correct. (#1055) * POMs generated by publishing are now correct. The publish extension now requires an explicit call to configure the publishing instead of waiting until after evaluation. This prevents evaluation order issues with the artifact renaming code that causes the POM to have the original, incorrect, artifact names. * Fixed new test compile issues caused by removal of some dependencies in test utils that caused webserver code to be automatically included in any project also compiling test utils. --- client/jackson/build.gradle | 2 +- client/jfx/build.gradle | 2 +- client/mock/build.gradle | 2 +- client/rpc/build.gradle | 2 +- constants.properties | 2 +- cordform-common/build.gradle | 4 ++++ core/build.gradle | 2 +- finance/build.gradle | 2 +- gradle-plugins/cordformation/build.gradle | 4 ++++ gradle-plugins/publish-utils/README.rst | 2 +- .../plugins/ProjectPublishExtension.groovy | 15 +++++++++++++-- .../net/corda/plugins/PublishTasks.groovy | 18 ++++++------------ gradle-plugins/quasar-utils/build.gradle | 4 ++++ node-api/build.gradle | 2 +- node-schemas/build.gradle | 4 ++-- node/build.gradle | 2 +- node/capsule/build.gradle | 2 +- .../network/AbstractNetworkMapServiceTest.kt | 7 ++++--- samples/attachment-demo/build.gradle | 1 + samples/bank-of-corda-demo/build.gradle | 1 + settings.gradle | 2 +- test-common/build.gradle | 2 +- test-utils/build.gradle | 4 +--- verifier/build.gradle | 2 +- webserver/build.gradle | 2 +- webserver/webcapsule/build.gradle | 3 +-- 26 files changed, 56 insertions(+), 39 deletions(-) diff --git a/client/jackson/build.gradle b/client/jackson/build.gradle index 234f7e1ae0..1457f01bb4 100644 --- a/client/jackson/build.gradle +++ b/client/jackson/build.gradle @@ -31,5 +31,5 @@ jar { } publish { - name = jar.baseName + name jar.baseName } \ No newline at end of file diff --git a/client/jfx/build.gradle b/client/jfx/build.gradle index 5d12e01f56..9c70ee7a04 100644 --- a/client/jfx/build.gradle +++ b/client/jfx/build.gradle @@ -62,5 +62,5 @@ jar { } publish { - name = jar.baseName + name jar.baseName } \ No newline at end of file diff --git a/client/mock/build.gradle b/client/mock/build.gradle index d709d4c911..0c4a2efbb0 100644 --- a/client/mock/build.gradle +++ b/client/mock/build.gradle @@ -30,5 +30,5 @@ jar { } publish { - name = jar.baseName + name jar.baseName } \ No newline at end of file diff --git a/client/rpc/build.gradle b/client/rpc/build.gradle index 6ee29ab387..61159ac74d 100644 --- a/client/rpc/build.gradle +++ b/client/rpc/build.gradle @@ -92,5 +92,5 @@ jar { } publish { - name = jar.baseName + name jar.baseName } diff --git a/constants.properties b/constants.properties index 6993620217..c2aea318ca 100644 --- a/constants.properties +++ b/constants.properties @@ -1,4 +1,4 @@ -gradlePluginsVersion=0.13.2 +gradlePluginsVersion=0.13.3 kotlinVersion=1.1.1 guavaVersion=21.0 bouncycastleVersion=1.57 diff --git a/cordform-common/build.gradle b/cordform-common/build.gradle index 340a4b6ec6..82274e0d09 100644 --- a/cordform-common/build.gradle +++ b/cordform-common/build.gradle @@ -17,3 +17,7 @@ dependencies { // Bouncy Castle: for X.500 distinguished name manipulation compile "org.bouncycastle:bcprov-jdk15on:$bouncycastle_version" } + +publish { + name project.name +} \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle index e7dc4fa641..564780c011 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -98,5 +98,5 @@ jar { } publish { - name = jar.baseName + name jar.baseName } diff --git a/finance/build.gradle b/finance/build.gradle index 3e4cae5813..48fa690b36 100644 --- a/finance/build.gradle +++ b/finance/build.gradle @@ -49,5 +49,5 @@ jar { } publish { - name = jar.baseName + name jar.baseName } \ No newline at end of file diff --git a/gradle-plugins/cordformation/build.gradle b/gradle-plugins/cordformation/build.gradle index 72c778d692..390ea7c8ba 100644 --- a/gradle-plugins/cordformation/build.gradle +++ b/gradle-plugins/cordformation/build.gradle @@ -61,3 +61,7 @@ jar { rename { 'net/corda/plugins/runnodes.jar' } } } + +publish { + name project.name +} diff --git a/gradle-plugins/publish-utils/README.rst b/gradle-plugins/publish-utils/README.rst index 3ca1c2febf..d1657ee5fe 100644 --- a/gradle-plugins/publish-utils/README.rst +++ b/gradle-plugins/publish-utils/README.rst @@ -76,8 +76,8 @@ The project configuration block has the following structure: .. code-block:: text publish { - name = 'non-default-project-name' disableDefaultJar = false // set to true to disable the default JAR being created (e.g. when creating a fat JAR) + name 'non-default-project-name' // Always put this last because it causes configuration to happen } **Artifacts** diff --git a/gradle-plugins/publish-utils/src/main/groovy/net/corda/plugins/ProjectPublishExtension.groovy b/gradle-plugins/publish-utils/src/main/groovy/net/corda/plugins/ProjectPublishExtension.groovy index de5c4dfb90..ee978bdbb8 100644 --- a/gradle-plugins/publish-utils/src/main/groovy/net/corda/plugins/ProjectPublishExtension.groovy +++ b/gradle-plugins/publish-utils/src/main/groovy/net/corda/plugins/ProjectPublishExtension.groovy @@ -1,14 +1,25 @@ package net.corda.plugins class ProjectPublishExtension { + private PublishTasks task + + void setPublishTask(PublishTasks task) { + this.task = task + } + /** - * Use a different name from the current project name for publishing + * Use a different name from the current project name for publishing. + * Set this after all other settings that need to be configured */ - String name + void name(String name) { + task.setPublishName(name) + } + /** * True when we do not want to publish default Java components */ Boolean disableDefaultJar = false + /** * True if publishing a WAR instead of a JAR. Forces disableDefaultJAR to "true" when true */ diff --git a/gradle-plugins/publish-utils/src/main/groovy/net/corda/plugins/PublishTasks.groovy b/gradle-plugins/publish-utils/src/main/groovy/net/corda/plugins/PublishTasks.groovy index f5221ff037..f25e07da6a 100644 --- a/gradle-plugins/publish-utils/src/main/groovy/net/corda/plugins/PublishTasks.groovy +++ b/gradle-plugins/publish-utils/src/main/groovy/net/corda/plugins/PublishTasks.groovy @@ -23,24 +23,17 @@ class PublishTasks implements Plugin { void apply(Project project) { this.project = project + this.publishName = project.name createTasks() createExtensions() createConfigurations() - - 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 setPublishName(String publishName) { + project.logger.info("Changing publishing name from ${project.name} to ${publishName}") + this.publishName = publishName + checkAndConfigurePublishing() } void checkAndConfigurePublishing() { @@ -157,6 +150,7 @@ class PublishTasks implements Plugin { project.extensions.create("bintrayConfig", BintrayConfigExtension) } publishConfig = project.extensions.create("publish", ProjectPublishExtension) + publishConfig.setPublishTask(this) } void createConfigurations() { diff --git a/gradle-plugins/quasar-utils/build.gradle b/gradle-plugins/quasar-utils/build.gradle index e4bba19bcf..7829d47d75 100644 --- a/gradle-plugins/quasar-utils/build.gradle +++ b/gradle-plugins/quasar-utils/build.gradle @@ -12,3 +12,7 @@ dependencies { compile gradleApi() compile localGroovy() } + +publish { + name project.name +} diff --git a/node-api/build.gradle b/node-api/build.gradle index 6bb83dcbf6..c2ba65f9c3 100644 --- a/node-api/build.gradle +++ b/node-api/build.gradle @@ -38,5 +38,5 @@ jar { } publish { - name = jar.baseName + name jar.baseName } diff --git a/node-schemas/build.gradle b/node-schemas/build.gradle index 88a9102a8b..7f015714a1 100644 --- a/node-schemas/build.gradle +++ b/node-schemas/build.gradle @@ -1,7 +1,7 @@ +apply plugin: 'net.corda.plugins.publish-utils' apply plugin: 'kotlin' apply plugin: 'kotlin-kapt' apply plugin: 'idea' -apply plugin: 'net.corda.plugins.publish-utils' apply plugin: 'com.jfrog.artifactory' description 'Corda node database schemas' @@ -33,5 +33,5 @@ jar { } publish { - name = jar.baseName + name jar.baseName } \ No newline at end of file diff --git a/node/build.gradle b/node/build.gradle index b389dfb409..ffbe9df98b 100644 --- a/node/build.gradle +++ b/node/build.gradle @@ -223,5 +223,5 @@ jar { } publish { - name = jar.baseName + name jar.baseName } \ No newline at end of file diff --git a/node/capsule/build.gradle b/node/capsule/build.gradle index fac1f538f5..12de5f404e 100644 --- a/node/capsule/build.gradle +++ b/node/capsule/build.gradle @@ -67,6 +67,6 @@ artifacts { } publish { - name = 'corda' disableDefaultJar = true + name 'corda' } diff --git a/node/src/test/kotlin/net/corda/node/services/network/AbstractNetworkMapServiceTest.kt b/node/src/test/kotlin/net/corda/node/services/network/AbstractNetworkMapServiceTest.kt index 549f52e848..1559a7ea9a 100644 --- a/node/src/test/kotlin/net/corda/node/services/network/AbstractNetworkMapServiceTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/network/AbstractNetworkMapServiceTest.kt @@ -30,13 +30,14 @@ import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNetwork.MockNode import org.assertj.core.api.Assertions.assertThat import org.bouncycastle.asn1.x500.X500Name -import org.eclipse.jetty.util.BlockingArrayQueue import org.junit.After import org.junit.Before import org.junit.Test import java.math.BigInteger import java.security.KeyPair import java.time.Instant +import java.util.* +import java.util.concurrent.LinkedBlockingQueue abstract class AbstractNetworkMapServiceTest { lateinit var mockNet: MockNetwork @@ -222,9 +223,9 @@ abstract class AbstractNetworkMapServiceTest return response } - private fun MockNode.subscribe(): List { + private fun MockNode.subscribe(): Queue { val request = SubscribeRequest(true, network.myAddress) - val updates = BlockingArrayQueue() + val updates = LinkedBlockingQueue() services.networkService.addMessageHandler(PUSH_TOPIC, DEFAULT_SESSION_ID) { message, _ -> updates += message.data.deserialize() } diff --git a/samples/attachment-demo/build.gradle b/samples/attachment-demo/build.gradle index 55be04795d..49d27cbf00 100644 --- a/samples/attachment-demo/build.gradle +++ b/samples/attachment-demo/build.gradle @@ -29,6 +29,7 @@ dependencies { compile project(path: ":node:capsule", configuration: 'runtimeArtifacts') compile project(path: ":webserver:webcapsule", configuration: 'runtimeArtifacts') compile project(':core') + compile project(':webserver') compile project(':test-utils') } diff --git a/samples/bank-of-corda-demo/build.gradle b/samples/bank-of-corda-demo/build.gradle index fd957bbcdc..fce442611c 100644 --- a/samples/bank-of-corda-demo/build.gradle +++ b/samples/bank-of-corda-demo/build.gradle @@ -32,6 +32,7 @@ dependencies { compile project(':client:jfx') compile project(':client:rpc') compile project(':finance') + compile project(':webserver') compile project(':test-utils') // Javax is required for webapis diff --git a/settings.gradle b/settings.gradle index edfef044a8..fef72becbe 100644 --- a/settings.gradle +++ b/settings.gradle @@ -34,4 +34,4 @@ include 'samples:network-visualiser' include 'samples:simm-valuation-demo' include 'samples:notary-demo' include 'samples:bank-of-corda-demo' -include 'cordform-common' +include 'cordform-common' \ No newline at end of file diff --git a/test-common/build.gradle b/test-common/build.gradle index 3a955f1691..11574b8cb6 100644 --- a/test-common/build.gradle +++ b/test-common/build.gradle @@ -5,5 +5,5 @@ jar { } publish { - name = jar.baseName + name jar.baseName } diff --git a/test-utils/build.gradle b/test-utils/build.gradle index f6801db7ef..c1ac72f456 100644 --- a/test-utils/build.gradle +++ b/test-utils/build.gradle @@ -30,10 +30,8 @@ sourceSets { dependencies { compile project(':test-common') - compile project(':finance') compile project(':core') compile project(':node') - compile project(':webserver') compile project(':client:mock') compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" @@ -67,5 +65,5 @@ jar { } publish { - name = jar.baseName + name jar.baseName } diff --git a/verifier/build.gradle b/verifier/build.gradle index e0035ffa33..41ba1988a5 100644 --- a/verifier/build.gradle +++ b/verifier/build.gradle @@ -75,6 +75,6 @@ artifacts { } publish { - name = 'corda-verifier' disableDefaultJar = true + name 'corda-verifier' } diff --git a/webserver/build.gradle b/webserver/build.gradle index 0868a6ec8a..05c2daf185 100644 --- a/webserver/build.gradle +++ b/webserver/build.gradle @@ -72,5 +72,5 @@ jar { } publish { - name = jar.baseName + name jar.baseName } diff --git a/webserver/webcapsule/build.gradle b/webserver/webcapsule/build.gradle index 9cfc1f8e0c..9f5fa8df55 100644 --- a/webserver/webcapsule/build.gradle +++ b/webserver/webcapsule/build.gradle @@ -57,7 +57,6 @@ artifacts { } publish { - name = 'corda-webserver' - publishWar = false // TODO: Use WAR instead of JAR disableDefaultJar = true + name 'corda-webserver' }