我一直试图将项目上传到Maven存储库失败。这是我的项目结构:
_root
|_ lib1 (aar)
|_ lib2 (aar)
|_ javalib (jar)
问题是当我启动uploadArchives任务时,我没有创建pom.xml。
这似乎是由于我的口味(当我移除口味时效果很好),而且我不知道如何解决此问题。
我真的需要尝试各种口味。。。欢迎任何帮助;)
这是我的build.gradle文件:
根 :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
ext.versionName = "$System.properties.version"
configure(subprojects) {
apply plugin: 'maven'
group = 'com.test.build'
version = project.versionName
uploadArchives {
repositories {
mavenDeployer {
repository(url: "http://localhost:8081/content/repositories/test/") {
authentication(userName: "admin", password: "admin123")
}
}
}
}
}
allprojects {
repositories {
jcenter()
}
}
lib1:
apply plugin: 'com.android.library'
android {
publishNonDefault true
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName project.versionName
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
prod{}
intg{}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
intgCompile project(path: ':lib2', configuration: 'intgRelease')
prodCompile project(path: ':lib2', configuration: 'prodRelease')
}
lib2:
apply plugin: 'com.android.library'
android {
publishNonDefault true
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName project.versionName
}
buildTypes {
debug {
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
prod{}
intg{}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(path: ':javalib')
}
javalib:
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
最佳答案
我终于找到了解决我问题的答案:
这是不可能的,但是有一天可能会做到:
请参阅有关文档:
http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-Publication
我通过以下解决方案解决了这个问题:
// default publication is production which will be published without env name
publishNonDefault true
defaultPublishConfig "productionRelease"
if (android.productFlavors.size() > 0) {
android.libraryVariants.all { variant ->
// Publish a main artifact, otherwise the maven pom is not generated
if (android.publishNonDefault && variant.name == android.defaultPublishConfig) {
def bundleTask = tasks["bundle${name.capitalize()}"]
artifacts {
archives(bundleTask.archivePath) {
classifier null
builtBy bundleTask
}
}
}
}
}
我对此不满意,但它现在可以做...