diff --git a/example/build.gradle b/example/build.gradle index 05da4663..679f72f8 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -9,7 +9,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:3.6.1' - classpath 'com.kezong:fat-aar:1.2.13' + classpath 'com.kezong:fat-aar:1.2.15' } } diff --git a/source/src/main/groovy/com/kezong/fataar/ConfigurationDependencyResolutionListener.groovy b/source/src/main/groovy/com/kezong/fataar/ConfigurationDependencyResolutionListener.groovy index 0a54dc6a..bb5e6757 100644 --- a/source/src/main/groovy/com/kezong/fataar/ConfigurationDependencyResolutionListener.groovy +++ b/source/src/main/groovy/com/kezong/fataar/ConfigurationDependencyResolutionListener.groovy @@ -4,6 +4,7 @@ import org.gradle.api.Project import org.gradle.api.artifacts.Configuration import org.gradle.api.artifacts.DependencyResolutionListener import org.gradle.api.artifacts.ResolvableDependencies +import org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency class ConfigurationDependencyResolutionListener implements DependencyResolutionListener { @@ -19,7 +20,17 @@ class ConfigurationDependencyResolutionListener implements DependencyResolutionL @Override void beforeResolve(ResolvableDependencies resolvableDependencies) { configuration.dependencies.each { dependency -> - project.dependencies.add('compileOnly', dependency) + if (dependency instanceof DefaultProjectDependency) { + if (dependency.targetConfiguration == null) { + dependency.targetConfiguration = "default" + } + // support that the module can be indexed in Android Studio 4.0.0 + DefaultProjectDependency dependencyClone = dependency.copy() + dependencyClone.targetConfiguration = null; + project.dependencies.add('compileOnly', dependencyClone) + } else { + project.dependencies.add('compileOnly', dependency) + } } project.gradle.removeListener(this) }