我试图发布我的
Android库的生成的aar文件到我的Apache Archiva Maven服务器,但我没有办法让它工作,因为这些例子已经过时了
或者他们是为java而不是为android
或者他们是为java而不是为android
注意到大多数gradle示例的方法已被弃用,我发现这个新的文档:
其中描述了如何使用新的API,这似乎取代uploadArchives与发布等等….
所以这是我到目前为止
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的东西就像是我的地狱.我不知道什么是正确的,什么是错误的,有些事情似乎没有改变,没有任何提示,它不再被支持,这使得很难解决这些问题?
解决方法
自己解决了
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' } } } }