问题描述
我正在尝试将我的 android 库生成的 aar 文件发布到我的 Apache Archiva Maven 服务器,但我还没有设法让它工作,因为两个例子都已经过时了或者它们用于 java 而不是用于 android
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 outdatedor they are for java and not for android
在注意到 gradle 示例的大多数方法都已弃用后,我找到了这个新文档:
After noticing that most methods of the gradle examples are deprecated, I found this new documentation:
它描述了如何使用新的 API,它似乎用 publishing 替换了 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"
}
}
}
}
Gradle 的东西对我来说简直就是地狱.我不知道什么是对什么是错,有些东西似乎改变了,没有任何提示不再支持,这使得解决这些问题非常困难......
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?
推荐答案
自己解决了
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'
}
}
}
}
这篇关于如何使用 Gradle 将 aar 文件发布到 Apache Archiva的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!