6

I created a new Android library module inside of my project as a test library. It's a simple module with one class with one static method that returns a string. I have Artifactory server running locally and want to push my Android lib/module to it. I generated the Gradle script and gradle properties from Artifactory web interface. My build.gradle in my testLib module now looks like this:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'

}

/////

buildscript {
    repositories {
        maven {
            url 'http://localhost:8081/artifactory/plugins-release'
            credentials {
                username = "${artifactory_user}"
                password = "${artifactory_password}"
            }
        }

    }
    dependencies {
        //Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1"
    }
}

allprojects {
    apply plugin: "com.jfrog.artifactory"

}

artifactory {
    contextUrl = "${artifactory_contextUrl}"   //The base Artifactory URL if not overridden by the publisher/resolver
    publish {
        repository {
            repoKey = 'libs-release-local'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true

        }
    }
    resolve {
        repository {
            repoKey = 'libs-release'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true

        }
    }
}

After I added that, I ran the ./gradlew artifactoryPublish command. It says BUILD SUCCESSFUL. I then go to artifactory web app to the repository browser and I look under libs-release-local and it has an artifact count of 0. What am I doing wrong?

EGHDK
  • 17,818
  • 45
  • 129
  • 204
  • Never worked with local AARs before, but I used this guy to help figure out how this stuff works. Maybe it'll help you? https://github.com/blundell/release-android-library – Ifrit Aug 24 '15 at 17:34
  • Thanks for the link, but I haven't been able to use that repo to my advantage... =( – EGHDK Aug 24 '15 at 18:34

2 Answers2

4

Found a working example here: http://jeroenmols.github.io/blog/2015/08/06/artifactory/

EGHDK
  • 17,818
  • 45
  • 129
  • 204
1

You need to apply the maven-publish plugin in the build.gradle file of your Android module and add a publishing { ... } block in there which makes the module publishable. Secondly, you need to specify in the artifactory { ... } block of your project's root-level build.gradle file what is to be published.

See this StackOverflow thread for an example of how to do this for an Android library project:

Gradle Artifactory Plugin - How to publish artifacts from multiple modules in a project?

Community
  • 1
  • 1
Adil Hussain
  • 30,049
  • 21
  • 112
  • 147