From a5e6e21b3d5da267dfd3f26dcc7b6e8430e93061 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Fri, 9 Feb 2024 13:49:18 -0500 Subject: [PATCH] Apply `artifactory` only if `maven-publish` plugin --- utils/spring-artifactory-init.gradle | 76 ++++++++++++++-------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/utils/spring-artifactory-init.gradle b/utils/spring-artifactory-init.gradle index 660df09..454c6e8 100644 --- a/utils/spring-artifactory-init.gradle +++ b/utils/spring-artifactory-init.gradle @@ -22,51 +22,51 @@ allprojects { apply plugin: org.jfrog.gradle.plugin.artifactory.ArtifactoryPlugin - artifactory { - publish { - contextUrl = System.getenv('ARTIFACTORY_URL') - repository { - repoKey = System.getenv('ARTIFACTORY_REPOSITORY') - username = System.getenv('ARTIFACTORY_USERNAME') - password = System.getenv('ARTIFACTORY_PASSWORD') - } - defaults { - publications 'mavenJava' - def zipArtifactProps = - ['zip.name' : project.name, - 'zip.displayname': project.description, - 'zip.deployed' : 'false'] - properties { - mavenJava zipArtifactProps, '*:*:*:*@zip' - mavenJava 'zip.type': 'docs', '*:*:*:docs@zip' - mavenJava 'zip.type': 'dist', '*:*:*:dist@zip' + afterEvaluate { + pluginManager.withPlugin('maven-publish') { + artifactory { + publish { + contextUrl = System.getenv('ARTIFACTORY_URL') + repository { + repoKey = System.getenv('ARTIFACTORY_REPOSITORY') + username = System.getenv('ARTIFACTORY_USERNAME') + password = System.getenv('ARTIFACTORY_PASSWORD') + } + defaults { + publications 'mavenJava' + def zipArtifactProps = + ['zip.name' : project.name, + 'zip.displayname': project.description, + 'zip.deployed' : 'false'] + properties { + mavenJava zipArtifactProps, '*:*:*:*@zip' + mavenJava 'zip.type': 'docs', '*:*:*:docs@zip' + mavenJava 'zip.type': 'dist', '*:*:*:dist@zip' + } + } + publishForkCount = 10 } - } - publishForkCount = 10 - } - - buildInfo { - setProject(System.getenv('ARTIFACTORY_BUILD_PROJECT')) - setBuildName(System.getenv('ARTIFACTORY_BUILD_NAME')) - setBuildNumber(System.getenv('ARTIFACTORY_BUILD_NUMBER')) - setBuildUrl(System.getenv('ARTIFACTORY_BUILD_URL')) - setAgentName(System.getenv('ARTIFACTORY_USER_AGENT_NAME')) - setAgentVersion(System.getenv('ARTIFACTORY_USER_AGENT_VERSION')) - setVcsRevision(System.getenv('ARTIFACTORY_VCS_REVISION')) - setVcsUrl(System.getenv('ARTIFACTORY_VCS_URL')) - setArtifactoryPluginVersion('4.33.12') - } - clientConfig.connectionRetries = 4 - clientConfig.insecureTls = false - } + buildInfo { + setProject(System.getenv('ARTIFACTORY_BUILD_PROJECT')) + setBuildName(System.getenv('ARTIFACTORY_BUILD_NAME')) + setBuildNumber(System.getenv('ARTIFACTORY_BUILD_NUMBER')) + setBuildUrl(System.getenv('ARTIFACTORY_BUILD_URL')) + setAgentName(System.getenv('ARTIFACTORY_USER_AGENT_NAME')) + setAgentVersion(System.getenv('ARTIFACTORY_USER_AGENT_VERSION')) + setVcsRevision(System.getenv('ARTIFACTORY_VCS_REVISION')) + setVcsUrl(System.getenv('ARTIFACTORY_VCS_URL')) + setArtifactoryPluginVersion('4.33.12') + } + clientConfig.connectionRetries = 4 + clientConfig.insecureTls = false + } - afterEvaluate { - pluginManager.withPlugin('maven-publish') { tasks.named('artifactoryPublish') { enabled(true) } + if (!ossrhUrl && gpgPassphrase && gpgPrivateKey) { signing { useInMemoryPgpKeys(gpgPrivateKey, gpgPassphrase)