I have 2 lib modules : library
, library2
, and use android-maven-publish to publish my multi-modules android project with multi-productFlavors
build.gradle
in library:
apply plugin: 'com.android.library'
apply plugin: 'digital.wup.android-maven-publish'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "runner"
productFlavors {
sit {
dimension "runner"
}
dev {
dimension "runner"
}
uat {
dimension "runner"
}
prd {
dimension "runner"
}
}
}
dependencies {
...
implementation project(':android-library2')
}
apply from: '../publish.gradle'
build.gradle
in library2:
apply plugin: 'com.android.library'
apply plugin: 'digital.wup.android-maven-publish'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "runner"
productFlavors {
sit {
dimension "runner"
}
dev {
dimension "runner"
}
uat {
dimension "runner"
}
prd {
dimension "runner"
}
}
}
dependencies {
...
}
apply from: '../publish.gradle'
publish.gradle:
publishing.publications() {
android.libraryVariants.all { variant ->
"maven$project.archivesBaseName${variant.name.capitalize()}Aar"(MavenPublication) {
from components.findByName("android${variant.name.capitalize()}")
groupId 'com.android.saleshelp'
artifactId project.archivesBaseName + "-${variant.name.capitalize()}"
version android.defaultConfig.versionName
}
}
}
publishing.repositories {
mavenLocal()
}
when I run task publish
in library, I got the following error:
* What went wrong:
Could not determine the dependencies of task ':android-library2:publishMavenandroid-library2SitReleaseAarPublicationToMavenLocalRepository'.
> Publishing is not able to resolve a dependency on a project with multiple publications that have different coordinates.
Found the following publications in project ':android-library':
- Maven publication 'mavenandroid-libraryPrdDebugAar' with coordinates com.cestbon.android.saleshelp:android-library-PrdDebug:1.0
- Maven publication 'mavenandroid-libraryPrdReleaseAar' with coordinates com.cestbon.android.saleshelp:android-library-PrdRelease:1.0
- Maven publication 'mavenandroid-libraryDevDebugAar' with coordinates com.cestbon.android.saleshelp:android-library-DevDebug:1.0
- Maven publication 'mavenandroid-libraryDevReleaseAar' with coordinates com.cestbon.android.saleshelp:android-library-DevRelease:1.0
- Maven publication 'mavenandroid-libraryUatDebugAar' with coordinates com.cestbon.android.saleshelp:android-library-UatDebug:1.0
- Maven publication 'mavenandroid-libraryUatReleaseAar' with coordinates com.cestbon.android.saleshelp:android-library-UatRelease:1.0
- Maven publication 'mavenandroid-librarySitDebugAar' with coordinates com.cestbon.android.saleshelp:android-library-SitDebug:1.0
- Maven publication 'mavenandroid-librarySitReleaseAar' with coordinates com.cestbon.android.saleshelp:android-library-SitRelease:1.0
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
If I removed apply from: '../publish.gradle'
in build.gradle
of library2, task :library:publish
can be run successfully. But because of I want to publish library2
independently, so library2
must apply from: '../publish.gradle'
How can I do for this error? Thanks.
Environment: gradle 4.4 ~ 4.9-rc1
alias 'test'
in the MavenPublication block, without success. I do have the property in DefaultMavenPublication since i use gradle 4.10.1. Could use an hint! – Doubles