Skip to content

Commit

Permalink
support that the module can be indexed in AS 4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kezong committed Jun 9, 2020
1 parent 1daaaaa commit 996bdfa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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)
}
Expand Down

0 comments on commit 996bdfa

Please sign in to comment.