Я пытаюсь настроить скрипт Gradle моего модуля так, чтобы при запуске assembleDebug
или assembleRelease
он копировал артефакты зависимостей (Jar и Aar) в выходную папку сборки.
This вот что я попробовал:
configurations {
embed
embed.canBeConsumed = true
embed.canBeResolved = true
api.extendsFrom(embed)
}
afterEvaluate {
tasks.findAll { task ->
if (task.name.startsWith('assemble')) {
task.doLast {
copy {
android.libraryVariants.all { variant ->
from configurations.embed
into "$buildDir" + '/outputs/libs'
}
}
}
}
}
}
dependencies {
embed project(':base:android') // Android module
}
Но потом, когда я запускаю assembleRelease
, Gradle говорит мне, что он не может решить
* What went wrong:
Execution failed for task ':my-lib:assembleRelease'.
> Could not resolve all files for configuration ':my-lib:embed'.
> Could not resolve project :base:android.
Required by:
project :my-lib
> Cannot choose between the following variants of project :base:android:
- debugRuntimeElements
- releaseRuntimeElements
All of them match the consumer attributes:
- Variant 'debugRuntimeElements' capability app.base:android:
- Unmatched attributes:
- Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required.
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
- Found org.gradle.usage 'java-runtime' but wasn't required.
- Variant 'releaseRuntimeElements' capability app.base:android:
- Unmatched attributes:
- Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required.
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
- Found org.gradle.usage 'java-runtime' but wasn't required.
Как я могу сделать так, чтобы мой build.gradle скрипт передаст соответствующий вариант сборки в задачу зависимости?