From 398cba330b6fde4b76bfe471ef777218b6fd9bc4 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 7 Apr 2020 16:56:54 +0200 Subject: [PATCH] gradle: add support for custom repo to publish to And introduce useSonatype setting to skip the sonatype repos if desired. --- build.gradle | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 8309cadc6..502245fd0 100644 --- a/build.gradle +++ b/build.gradle @@ -134,6 +134,12 @@ allprojects { junitVersion = '5.6.0' powerMockVersion = '2.0.2' commonsIoVersion = '2.6' + if (project.hasProperty("useSonatype")) { + useSonatype = project.getProperty("useSonatype").toBoolean() + } else { + // Default to true + useSonatype = true + } } group = 'org.igniterealtime.smack' sourceCompatibility = JavaVersion.VERSION_1_8 @@ -457,15 +463,30 @@ subprojects { } } repositories { - maven { - url isSnapshot ? sonatypeSnapshotUrl : sonatypeStagingUrl - if (sonatypeCredentialsAvailable) { + if (sonatypeCredentialsAvailable && useSonatype) { + maven { + url isSnapshot ? sonatypeSnapshotUrl : sonatypeStagingUrl credentials { username = sonatypeUsername password = sonatypePassword } } } + // Use + // gradle publish -P customRepoUrl=https://www.igniterealtime.org/archiva/repository/maven -P customRepoUsername=bamboo -P customRepoPassword=hidden -P useSonatype=false + // to deploy to this repo. + if (project.hasProperty("customRepoUrl")) { + maven { + name 'customRepo' + url customRepoUrl + if (project.hasProperty("customRepoUsername")) { + credentials { + username customRepoUsername + password customRepoPassword + } + } + } + } } } rootProject.distributionZip {