Se usi già Kotlin Gradle DSL, l'alternativa all'utilizzo in questo modo:
Ecco la mia struttura del progetto
|-root
|----- app
|--------- libs // I choose to store the aar here
|-------------- my-libs-01.aar
|-------------- my-libs-02.jar
|--------- build.gradle.kts // app module gradle
|----- common-libs // another aar folder/directory
|----------------- common-libs-01.aar
|----------------- common-libs-02.jar
|----- build.gradle.kts // root gradle
Mio app/build.gradle.kts
- Utilizzando un approccio semplice con
fileTree
// android related config above omitted...
dependencies {
// you can do this to include everything in the both directory
// Inside ./root/common-libs & ./root/app/libs
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar", "*.aar"))))
implementation(fileTree(mapOf("dir" to "../common-libs", "include" to listOf("*.jar", "*.aar"))))
}
- Utilizzando lo stesso approccio come il recupero dal repository Maven locale / remoto con
flatDirs
// android related config above omitted...
repositories {
flatDir {
dirs = mutableSetOf(File("libs"), File("../common-libs")
}
}
dependencies {
implementation(group = "", name = "my-libs-01", ext = "aar")
implementation(group = "", name = "my-libs-02", ext = "jar")
implementation(group = "", name = "common-libs-01", ext = "aar")
implementation(group = "", name = "common-libs-02", ext = "jar")
}
L' group
era necessario, a causa della sua obbligatoria (/ non facoltativo ha valore di default) in Kotlin implementation
, vedere sotto:
// Filename: ReleaseImplementationConfigurationAccessors.kt
package org.gradle.kotlin.dsl
fun DependencyHandler.`releaseImplementation`(
group: String,
name: String,
version: String? = null,
configuration: String? = null,
classifier: String? = null,
ext: String? = null,
dependencyConfiguration: Action<ExternalModuleDependency>? = null
)
Disclaimer: la differenza con l' flatDirs
approccio n. 1 e n. 2, ancora non ne so molto, potresti voler modificare / commentare questa risposta.
Riferimenti:
- https://stackoverflow.com/a/56828958/3763032
- https://github.com/gradle/gradle/issues/9272