How to publish jars to multiple artifactory?

Viewed 53

I am trying to publish the same jar to 2 different jfrog artifactory.

My build.gradle is:

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release"
  }
}

apply plugin: "com.jfrog.artifactory"
apply plugin: 'java'
apply plugin: 'base'
apply plugin: 'maven-publish'
apply plugin: 'eclipse'
apply from: "${rootProject.projectDir}/gradle/properties.gradle"


artifactory {
        contextUrl = "${artifactory_contextUrl_1}"
        resolve {
                repository {
                        repoKey = "${artifactory_resolve_repo_1}"
                        username = "${artifactory_user_1}"
                        password = "${artifactory_password_1}"
                }
        }
    publish {
        repository {
            repoKey = "${artifactory_publish_repo_1}"
            username = "${artifactory_user_1}"
            password = "${artifactory_password_1}"
        }
        defaults { publications('mavenJava') }
    }
}

artifactory {
    contextUrl = "${artifactory_contextUrl_2}"
    resolve {
        repository {
            repoKey = "${artifactory_resolve_repo_2}"
            username = "${artifactory_user_2}"
            password = "${artifactory_password_2}"
           
        }
    }
    publish {
        repository {
            repoKey = "${artifactory_publish_repo_2}"
            username = "${artifactory_user_2}"
            password = "${artifactory_password_2}" 
            
        }
        defaults {
            publishBuildInfo = false
            publications('mavenJava')
        }
    }

}


subprojects {
        // copy libs to root build/libs
        apply from: "${rootProject.projectDir}/gradle/utils/java/copy-libs-to-root.gradle"
        apply plugin: "com.jfrog.artifactory"
        apply plugin: 'java'
        apply plugin: 'base'
        apply plugin: 'maven-publish'
        apply plugin: 'eclipse'
        ext.componentName = "${project.name}"
        eclipse.project.name = ext.componentName
        version = '0.0.1'

        repositories {
                mavenLocal()
        }

        jar {
                manifest {
                        attributes  'Specification-Title': "${baseName}",
                                    'Specification-Version': version,
                                    'Implementation-Title': "${baseName}",
                                    'Implementation-Version': version,
                                    'Bundle-Version': version
                }
        }

}


project(':common-utils:opensearch-sdk') {
    ext.componentDescription = 'common-utils'
    apply plugin: 'java'
    apply plugin: 'eclipse'
    publishing {
        publications {
              mavenJava(MavenPublication) {
                    groupId = "com.example.app"
                  from components.java
              }
         }
    }
}

When I try to deploy artifacts using

 ./gradlew :common-utils:opensearch-sdk:build :common-utils:opensearch-sdk:artifactoryPublish

opensearch-sdk-1.0.jar is getting deployed only to artifactory_contextUrl_2.

Looks like artifactory_contextUrl_1 configuration is getting overwritten by artifactory_contextUrl_2.

0 Answers
Related