From 292c4ebeeb341498b29f953f4d5aa864c6df50b8 Mon Sep 17 00:00:00 2001 From: Matthew B White Date: Thu, 22 Jul 2021 13:20:50 +0100 Subject: [PATCH] Update the build.gradle for publishing The updated versions of gradle appear to require a slightly different way of publishing. Based on a local empirical test, these changes appear to be sound Signed-off-by: Matthew B White --- ci/azure-pipelines.yml | 4 ++-- fabric-chaincode-protos/build.gradle | 14 +++----------- fabric-chaincode-shim/build.gradle | 14 +++++++------- gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml index 47e32d1b..078c16f7 100644 --- a/ci/azure-pipelines.yml +++ b/ci/azure-pipelines.yml @@ -198,8 +198,8 @@ stages: inputs: secureFile: secring.gpg - script: | - ./gradlew -Psigning.keyId=${SIGNING_ID} -Psigning.password=${SIGNING_PASSWORD} -Psigning.secretKeyRingFile=${KEYRING_FILE} -PossrhUsername=${OSSRH_USER} -PossrhPassword=${OSSRH_PASSWORD} publishMavenPublicationToReleaseRepository - ./gradlew -Psigning.keyId=${SIGNING_ID} -Psigning.password=${SIGNING_PASSWORD} -Psigning.secretKeyRingFile=${KEYRING_FILE} -PossrhUsername=${OSSRH_USER} -PossrhPassword=${OSSRH_PASSWORD} publishMavenPublicationToSnapshotRepository + ./gradlew -Psigning.keyId=${SIGNING_ID} -Psigning.password=${SIGNING_PASSWORD} -Psigning.secretKeyRingFile=${KEYRING_FILE} -PossrhUsername=${OSSRH_USER} -PossrhPassword=${OSSRH_PASSWORD} publishAllPublicationsToReleaseRepository + ./gradlew -Psigning.keyId=${SIGNING_ID} -Psigning.password=${SIGNING_PASSWORD} -Psigning.secretKeyRingFile=${KEYRING_FILE} -PossrhUsername=${OSSRH_USER} -PossrhPassword=${OSSRH_PASSWORD} publishAllPublicationsToSnapshotRepository env: SIGNING_ID: $(JAR-Signing-Id) SIGNING_PASSWORD: $(JAR-Signing-Password) diff --git a/fabric-chaincode-protos/build.gradle b/fabric-chaincode-protos/build.gradle index 345b2bda..7bdaacbc 100644 --- a/fabric-chaincode-protos/build.gradle +++ b/fabric-chaincode-protos/build.gradle @@ -114,10 +114,6 @@ if (JavaVersion.current().isJava8Compatible()) { } } -task javadocJar(type: Jar) { - classifier = 'javadoc' - from javadoc -} publishing { @@ -224,11 +220,7 @@ signing { } } -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -artifacts { - archives javadocJar, sourcesJar +java { + withJavadocJar() + withSourcesJar() } diff --git a/fabric-chaincode-shim/build.gradle b/fabric-chaincode-shim/build.gradle index e6aaaeaf..23bce998 100644 --- a/fabric-chaincode-shim/build.gradle +++ b/fabric-chaincode-shim/build.gradle @@ -223,10 +223,6 @@ if (JavaVersion.current().isJava8Compatible()) { } } -task javadocJar(type: Jar) { - classifier = 'javadoc' - from javadoc -} publishing { publications { @@ -333,18 +329,22 @@ signing { } } +// Need to specify the sourcesJar task BEFORE the java{withSourcesJar()} so that it picks up the duplicatesStratergy +// otherwise this fails with a duplicates error. +// (see https://github.com/gradle/gradle/issues/17236) + task sourcesJar(type: Jar) { duplicatesStrategy = 'include' classifier = 'sources' from sourceSets.main.allSource } -artifacts { - archives javadocJar, sourcesJar +java { + withJavadocJar() + withSourcesJar() } - build.dependsOn licenseCheck // setup more detailed test output formats diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f371643e..05679dc3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists