From c05fd11467e9c302ecbcb1ff4967b3d4d353f8f7 Mon Sep 17 00:00:00 2001 From: Danno Ferrin Date: Mon, 8 Feb 2021 10:55:01 -0700 Subject: [PATCH] Add Artifactory Publishing (#1886) To prepare for the Bintray shutdown add publication to the hyperledger's artifactory instance to the build. Signed-off-by: Danno Ferrin --- .circleci/config.yml | 2 +- CHANGELOG.md | 1 + build.gradle | 67 ++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a0f220dfd7..1cc20fd390 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -230,7 +230,7 @@ jobs: - run: name: Publish command: | - ./gradlew --no-daemon bintrayUpload + ./gradlew --no-daemon artifactoryPublish bintrayUpload publishDocker: executor: besu_executor_med diff --git a/CHANGELOG.md b/CHANGELOG.md index 4efd6a360a..4f38d0fec2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Additions and Improvements * Added `besu_transaction_pool_transactions` to the reported metrics, counting the mempool size [\#1869](https://github.com/hyperledger/besu/pull/1869) +* Distributions and maven artifacts have been moved off of bintray [\#1886](https://github.com/hyperledger/besu/pull/1886) ### Bug Fixes diff --git a/build.gradle b/build.gradle index afad904766..cdea3f152b 100644 --- a/build.gradle +++ b/build.gradle @@ -23,10 +23,12 @@ plugins { id 'com.diffplug.spotless' version '5.9.0' id 'com.github.ben-manes.versions' version '0.36.0' id 'com.github.hierynomus.license' version '0.15.0' + id 'com.jfrog.artifactory' version '4.20.0' id 'com.jfrog.bintray' version '1.8.5' id 'io.spring.dependency-management' version '1.0.10.RELEASE' id 'me.champeau.gradle.jmh' version '0.5.0' apply false id 'net.ltgt.errorprone' version '1.3.0' + id 'maven-publish' } if (!JavaVersion.current().java11Compatible) { @@ -122,7 +124,7 @@ allprojects { repositories { jcenter() mavenCentral() - mavenLocal() + maven { url "https://hyperledger.jfrog.io/hyperledger/besu-maven" } maven { url "https://hyperledger-org.bintray.com/besu-repo" } maven { url "https://consensys.bintray.com/pegasys-repo" } maven { url "https://consensys.bintray.com/consensys" } @@ -281,7 +283,7 @@ task checkMavenCoordinateCollisions { doLast { def coordinates = [:] getAllprojects().forEach { - if (it.properties.containsKey('publishing')) { + if (it.properties.containsKey('publishing') && it.jar?.enabled) { def coordinate = it.publishing?.publications[0].coordinates if (coordinates.containsKey(coordinate)) { throw new GradleException("Duplicate maven coordinates detected, ${coordinate} is used by " + @@ -365,6 +367,7 @@ subprojects { } if (sourceSetIsPopulated("main") || sourceSetIsPopulated("testSupport")) { + apply plugin: 'com.jfrog.artifactory' apply plugin: 'com.jfrog.bintray' apply plugin: 'maven-publish' @@ -416,6 +419,27 @@ subprojects { pkg = bintrayPackage } + + def artifactoryUser = project.hasProperty('artifactoryUser') ? project.property('artifactoryUser') : System.getenv('ARTIFACTORY_USER') + def artifactoryKey = project.hasProperty('artifactoryApiKey') ? project.property('artifactoryApiKey') : System.getenv('ARTIFACTORY_KEY') + def artifactoryRepo = System.getenv('ARTIFACTORY_REPO') ?: 'besu-maven' + def artifactoryOrg = System.getenv('ARTIFACTORY_ORG') ?: 'hyperledger' + + artifactory { + contextUrl = "https://hyperledger.jfrog.io/${artifactoryOrg}" + publish { + repository { + repoKey = "${artifactoryRepo}" + username = artifactoryUser + password = artifactoryKey + } + defaults { + publications('mavenJava') + publishArtifacts = true + publishPom = true + } + } + } } tasks.withType(Test) { @@ -549,6 +573,45 @@ distZip { } } +publishing { + publications { + distArtifactory(MavenPublication) { + groupId (version.contains('SNAPSHOT') ? 'SNAPSHOT' : '.') + version = project.version + artifactId = 'besu-distribution' + artifact("$buildDir/distributions/besu-${project.version}.zip") + artifact("$buildDir/distributions/besu-${project.version}.tar.gz") { + extension = 'tar.gz' + } + } + } +} + +def artifactoryUser = project.hasProperty('artifactoryUser') ? project.property('artifactoryUser') : System.getenv('ARTIFACTORY_USER') +def artifactoryKey = project.hasProperty('artifactoryApiKey') ? project.property('artifactoryApiKey') : System.getenv('ARTIFACTORY_KEY') +def artifactoryOrg = System.getenv('ARTIFACTORY_ORG') ?: 'hyperledger' + +artifactory { + contextUrl = "https://hyperledger.jfrog.io/${artifactoryOrg}" + publish { + repository { + repoKey = "besu-binaries" + username = artifactoryUser + password = artifactoryKey + } + defaults { + publications('distArtifactory') + publishArtifacts = true + publishPom = false + } + } +} + +artifactoryPublish { + dependsOn distTar + dependsOn distZip +} + def dockerVariants = [ "openjdk-11", "graalvm",