Publish Android aar to artifactory

左心房为你撑大大i 提交于 2021-01-27 05:51:45

问题


I'm stuck with integrating artifactory 3.0.1 plugin with Gradle. I'm using Android Studio 1.0 so I'm guessing that I'm on Gradle 2.0. Any examples on publishing to artifactory using the 3.0.1 plugin would be highly helpful.

Thanks in advance


回答1:


Publishing to Artifactory is just a configuration task. You just need to configure two plugins, com.jfrog.artifactory and maven-publish, and run artifactoryPublish Gradle's task. But... let's explain it by code, to ease copypasting :·)

At your library's build.gradle:

apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'

publishing {
    publications {
        aar(MavenPublication) {
            groupId 'com.fewlaps.something' //put here your groupId
            artifactId 'productname' //put here your artifactId
            version '7.42.0' //put here your library version

            // Tell maven to prepare the generated "*.aar" file for publishing
            artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
        }
    }
}

artifactory {
    contextUrl = 'https://your-artifactory-host.com/artifactory'
    publish {
        repository {
            repoKey = "libs-release-local"
            username = "username"
            password = "password"
        }
        defaults {
            // Tell the Artifactory Plugin which artifacts should be published to Artifactory.
            publications('aar')
        }
    }
}

And then, run ./gradlew artifactoryPublish

In addition, if you want to upload the artifact everytime you push a tag to GitHub, add this code to your .travis.yml

deploy:
  - provider: script
    script: ./gradlew artifactoryPublish
    skip_cleanup: true
    on:
      tags: true

If it doesn't launch a build for the tag when you push a tag to GitHub, check that you're building vX.X.X tags on Travis:

# Build only master and "vX.X.X" tags to prevent flooding Travis machines
branches:
  only:
    - master
    - /^v\d+\.\d+\.\d+$/



回答2:


JFrog publishes a fully functional example of publishing aar to Artifactory. Here you go. Select the version of plugin you work with and look for aar example.



来源:https://stackoverflow.com/questions/27684789/publish-android-aar-to-artifactory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!