diff --git a/source/src/main/groovy/com/kezong/fataar/FatAarPlugin.groovy b/source/src/main/groovy/com/kezong/fataar/FatAarPlugin.groovy index 6819ed5f..93c19fbe 100644 --- a/source/src/main/groovy/com/kezong/fataar/FatAarPlugin.groovy +++ b/source/src/main/groovy/com/kezong/fataar/FatAarPlugin.groovy @@ -133,12 +133,10 @@ class FatAarPlugin implements Plugin { private Collection dealUnResolveArtifacts(Configuration configuration, LibraryVariant variant, Collection artifacts) { def artifactList = new ArrayList() configuration.resolvedConfiguration.firstLevelModuleDependencies.each { dependency -> - boolean match = false - artifacts.each { artifact -> - if (dependency.moduleName == artifact.name) { - match = true - } + def match = artifacts.any { artifact -> + dependency.moduleName == artifact.moduleVersion.id.name } + if (!match) { def flavorArtifact = FlavorArtifact.createFlavorArtifact(project, variant, dependency) if (flavorArtifact != null) { diff --git a/source/src/main/groovy/com/kezong/fataar/FlavorArtifact.groovy b/source/src/main/groovy/com/kezong/fataar/FlavorArtifact.groovy index 108da0f5..9469c518 100644 --- a/source/src/main/groovy/com/kezong/fataar/FlavorArtifact.groovy +++ b/source/src/main/groovy/com/kezong/fataar/FlavorArtifact.groovy @@ -30,6 +30,7 @@ class FlavorArtifact { try { bundleProvider = getBundleTask(artifactProject, variant) } catch (Exception ignore) { + FatUtils.logError("[$variant.name]Can not resove :$unResolvedArtifact.moduleName") return null } @@ -38,8 +39,8 @@ class FlavorArtifact { } ModuleVersionIdentifier identifier = createModuleVersionIdentifier(unResolvedArtifact) - DefaultIvyArtifactName artifactName = createArtifactName(unResolvedArtifact) File artifactFile = createArtifactFile(artifactProject, bundleProvider.get()) + DefaultIvyArtifactName artifactName = createArtifactName(artifactFile) Factory fileFactory = new Factory() { @Override File create() { @@ -69,8 +70,8 @@ class FlavorArtifact { ) } - private static DefaultIvyArtifactName createArtifactName(ResolvedDependency unResolvedArtifact) { - return new DefaultIvyArtifactName(unResolvedArtifact.getModuleName(), "aar", "") + private static DefaultIvyArtifactName createArtifactName(File artifactFile) { + return new DefaultIvyArtifactName(artifactFile.getName(), "aar", "") } private static ComponentArtifactIdentifier createComponentIdentifier(final File artifactFile) { diff --git a/source/src/main/groovy/com/kezong/fataar/VariantProcessor.groovy b/source/src/main/groovy/com/kezong/fataar/VariantProcessor.groovy index 39fed06d..f9bf35c7 100644 --- a/source/src/main/groovy/com/kezong/fataar/VariantProcessor.groovy +++ b/source/src/main/groovy/com/kezong/fataar/VariantProcessor.groovy @@ -80,14 +80,14 @@ class VariantProcessor { private static void printEmbedArtifacts(Collection artifacts, Collection dependencies) { - Collection artifactNames = artifacts.stream().map { it.name }.collect() + Collection moduleNames = artifacts.stream().map { it.moduleVersion.id.name }.collect() dependencies.each { dependency -> - if (!artifactNames.contains(dependency.moduleName)) { + if (!moduleNames.contains(dependency.moduleName)) { return } ResolvedArtifact self = dependency.allModuleArtifacts.find { module -> - module.name == dependency.moduleName + module.moduleVersion.id.name == dependency.moduleName } if (self == null) { @@ -95,21 +95,21 @@ class VariantProcessor { } FatUtils.logAnytime("[embed detected][$self.type]${self.moduleVersion.id}") - artifactNames.remove(self.name) + moduleNames.remove(self.moduleVersion.id.name) dependency.allModuleArtifacts.each { artifact -> - if (!artifactNames.contains(artifact.name)) { + if (!moduleNames.contains(artifact.moduleVersion.id.name)) { return } if (artifact != self) { FatUtils.logAnytime(" - [embed detected][transitive][$artifact.type]${artifact.moduleVersion.id}") - artifactNames.remove(artifact.name) + moduleNames.remove(artifact.moduleVersion.id.name) } } } - artifactNames.each { name -> - ResolvedArtifact artifact = artifacts.find { it.name == name } + moduleNames.each { name -> + ResolvedArtifact artifact = artifacts.find { it.moduleVersion.id.name == name } if (artifact != null) { FatUtils.logAnytime("[embed detected][$artifact.type]${artifact.moduleVersion.id}") }