Skip to content

Commit

Permalink
fix bug that "Can not find task bundleDebugAar". #84
Browse files Browse the repository at this point in the history
  • Loading branch information
kezong committed Dec 15, 2020
1 parent 0f82e05 commit 210c4a5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
8 changes: 3 additions & 5 deletions source/src/main/groovy/com/kezong/fataar/FatAarPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,10 @@ class FatAarPlugin implements Plugin<Project> {
private Collection<ResolvedArtifact> dealUnResolveArtifacts(Configuration configuration, LibraryVariant variant, Collection<ResolvedArtifact> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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<File> fileFactory = new Factory<File>() {
@Override
File create() {
Expand Down Expand Up @@ -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) {
Expand Down
16 changes: 8 additions & 8 deletions source/src/main/groovy/com/kezong/fataar/VariantProcessor.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -80,36 +80,36 @@ class VariantProcessor {

private static void printEmbedArtifacts(Collection<ResolvedArtifact> artifacts,
Collection<ResolvedDependency> dependencies) {
Collection<String> artifactNames = artifacts.stream().map { it.name }.collect()
Collection<String> 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) {
return
}

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

0 comments on commit 210c4a5

Please sign in to comment.