Skip to content

Commit

Permalink
Use File APIs when comparing paths in the AggregatedPackagesTransform.
Browse files Browse the repository at this point in the history
Using file APIs allows for platform-agnostic path comparisons where as File#parent() returns a String which will contain path separators that are OS specific and will fail to match with the known aggregated packages path that use UNIX-based file separator '/'. Specifically this fixes an issue for Windows users whose file separators are '\'. Note that JarEntry path matching is String based but well formatted Jar files (which are Zip files) regardless of the host OS use forward slashes as path separator.

Fixes #2695

RELNOTES=Fix an issue where `enableAggregatingTask` would not correctly generate Hilt classes when compiling in a dev environment with Windows OS.
PiperOrigin-RevId: 381877388
  • Loading branch information
danysantiago authored and Dagger Team committed Jun 28, 2021
1 parent e3334ff commit 12ea23f
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ abstract class AggregatedPackagesTransform : TransformAction<TransformParameters
outputs.file(JAR_NAME).outputStream().use { tmpOutputStream.writeTo(it) }
}
} else if (file.isClassFile()) {
val parentDirectory = file.parent
val parentDirectory = file.parentFile
val match = AGGREGATED_PACKAGES.any { aggregatedPackage ->
parentDirectory.endsWith(aggregatedPackage)
}
Expand Down

0 comments on commit 12ea23f

Please sign in to comment.