Skip to content

Commit

Permalink
Fix usage of plugin in Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
voczi authored and mikehardy committed Jun 27, 2024
1 parent cd49e7f commit 300e123
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,18 @@ internal fun File.classesSequence(): Sequence<Pair<String, File>> {
.filter { it.extension == "class" }
.filterNot { "META-INF" in it.name }
.sortedBy { it.invariantSeparatorsPath }
.map { it.absolutePath.removePrefix(prefix).removePrefix("/") to it }
.map {
// zip specification "4.4.17.1 file name: (Variable)" items:
it.absolutePath
// "The name of the file, with optional relative path.
// The path stored MUST NOT contain a drive or
// device letter, or a leading slash"
.removePrefix(prefix)
.removePrefix(File.separator)
// "All slashes MUST be forward slashes '/' as opposed
// to backwards slashes '\' for compatibility"
.replace(File.separator, "/") to it
}
}

/** Extracts classes from the target [jar] into this archive. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ internal class KeeperFunctionalTest {
projectDir.generatedChild("ExternalStagingAndroidTest/inferredKeepRules.pro")
assertThat(generatedRules.readText().trim())
.isEqualTo(
EXPECTED_TRACE_REFERENCES_CONFIG.map { indentRules(it.key, it.value) }.joinToString("\n")
EXPECTED_TRACE_REFERENCES_CONFIG.map { indentRules(it.key, it.value) }
.joinToString(System.lineSeparator())
)

// Finally - verify our rules were included in the final minification execution.
Expand Down Expand Up @@ -292,7 +293,11 @@ private val EXPECTED_TRACE_REFERENCES_CONFIG: Map<String, List<String>?> =
private fun indentRules(header: String, content: List<String>?) =
if (content == null) header
else {
"$header {\n${content.joinToString("\n") { " $it" }}\n}"
"$header {" +
System.lineSeparator() +
content.joinToString(System.lineSeparator()) { " $it" } +
System.lineSeparator() +
"}"
}

@Language("PROGUARD")
Expand Down Expand Up @@ -399,7 +404,10 @@ private fun buildGradleFile(
id 'com.slack.keeper'
}
java { toolchain { languageVersion.set(JavaLanguageVersion.of(21)) } }
// Ideally we use toolchains for a known version; this fails on windows w/WindowsRegistry access issues
// See: https://github.com/gradle/native-platform/issues/274
// So we will just rely on environment JDK
//java { toolchain { languageVersion.set(JavaLanguageVersion.of(21)) } }
tasks.withType(KotlinCompile).configureEach { compilerOptions { jvmTarget.set(JvmTarget.JVM_11) } }
Expand Down Expand Up @@ -480,7 +488,7 @@ private fun buildGradleFile(
}
dependencies {
${extraDependencies.entries.joinToString("\n") { " ${it.key} ${it.value}" }}
${extraDependencies.entries.joinToString(System.lineSeparator()) { " ${it.key} ${it.value}" }}
}
"""
.trimIndent()
Expand Down

0 comments on commit 300e123

Please sign in to comment.