如何发布AAR文件到Apache Archiva与摇篮 [英] How to publish aar file to Apache Archiva with Gradle

查看:322
本文介绍了如何发布AAR文件到Apache Archiva与摇篮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I'm尝试发布所产生的 AAR 文件我的Andr​​oid库,以我的Apache Archiva Maven的服务器,但我haven't设法得到它的工作还没有,因为无论是例子都已经过时 或者他们对于的Java 而非用于机器人

I´m trying to publish the generated aar file of my android library to my Apache Archiva Maven server, but I haven´t manage to get it working yet because either the examples are outdated or they are for java and not for android

注意到,的摇篮例子大部分方法都是去precated后,我发现这个新的文档:

After noticing that most methods of the gradle examples are deprecated, I found this new documentation:

摇篮文档

描述了如何使用新的API,这似乎取代 uploadArchives 发布等等....

Which describes how to use the new API which seems to replace uploadArchives with publishing and so on....

因此​​,这是从来就得到了迄今:

So this is what I´ve got so far:

apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: 'maven-publish'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"


defaultConfig {
    applicationId "com.mycompany.mylibrary"
    minSdkVersion 9
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
lintOptions {
    abortOnError false
}

}


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

task sourceJar(type: Jar) {
    from sourceSets.main.allJava
}

publishing {

publications {
    mavenJava(MavenPublication) {
        groupId 'com.android.mylibrary'
        artifactId 'MyLibrary'
        version '1.0.0'

        from components.java

        artifact sourceJar {
            classifier "sources"
        }
    }
}
repositories {
    maven {
        url "myurl"
        credentials{
            username "user"
            password "password"
        }
    }
}
}

的摇篮东西就像是地狱我。我不知道什么是对,什么是错的,有些事情似乎没有它isn't支持了任何提示要改,这使得它很难解决这些问题......

The Gradle stuff is like the hell for me. I don´t know what is right and what is wrong and some things seem to be changed without any hints that it isn´t supported anymore, which makes it quite difficult to solve these problems...

如何自动生成的AAR文件上传到我的Apache Archiva?

推荐答案

由我自己解决了这个问题。

Solved it by myself

apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: 'maven-publish'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"


repositories {
    mavenCentral()
}

defaultConfig {
    minSdkVersion 9
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}


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

task sourceJar(type: Jar) {
   classifier "source"
}

publishing {
   publications {

       repositories.maven {
           url 'myurl/repositories/myrepo'
           credentials {
               username "user"
               password "password"
           }
       }

       maven(MavenPublication) {
           artifacts {
               groupId 'com.mycompany'
               artifactId 'mylibrary'
               version '1.0'
               artifact 'build/outputs/aar/app-release.aar'
           }
       }
   }

}

这篇关于如何发布AAR文件到Apache Archiva与摇篮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆