Skip to content

Commit

Permalink
Handle empty assets and res directories (#182)
Browse files Browse the repository at this point in the history
Fixes #182
  • Loading branch information
arunkumar9t2 committed Nov 20, 2024
1 parent 7ec4cc2 commit 9b04391
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import java.util.Optional;
import java.util.stream.Collectors;

import javax.annotation.Nullable;

public class ResourceMerger {
private static final StdLogger STD_LOGGER = new StdLogger(StdLogger.Level.WARNING);

Expand All @@ -37,10 +39,12 @@ public static ParsedAndroidData emptyAndroidData() {

public static void merge(final boolean isBinary,
final List<SourceSet> sourceSets,
final File outputDir,
@Nullable final File outputDir,
final File mergeManifest) throws IOException {
mergeManifests(isBinary, sourceSets, mergeManifest);
mergeResources(sourceSets, outputDir, mergeManifest);
if (outputDir != null) {
mergeResources(sourceSets, outputDir, mergeManifest);
}
}

private static void mergeResources(final List<SourceSet> sourceSets, final File outputDir, final File manifest) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,19 @@ class ResourceMergerCommand : CliktCommand() {

override fun run() {
val sourceSets = sourceSets.map { arg -> SourceSet.from(target, arg) }
val outputPath = commonPath(*outputs.toTypedArray()).split("/res/").first()
val outputDir = File(outputPath).apply {
deleteRecursively()
parentFile?.mkdirs()
}
val outputDir = if (outputs.isNotEmpty()) {
val outputPath = commonPath(*outputs.toTypedArray()).split("/res/").first()
File(outputPath).apply {
deleteRecursively()
parentFile?.mkdirs()
}
} else null
ResourceMerger.merge(
/* isBinary = */ binary,
/* sourceSets = */ sourceSets,
/* outputDir = */ outputDir,
/* mergeManifest = */ mergedManifestOutput
)
OutputFixer.process(outputDir = outputDir, declaredOutputs = outputs)
outputDir?.let { OutputFixer.process(outputDir = it, declaredOutputs = outputs) }
}
}

0 comments on commit 9b04391

Please sign in to comment.