Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pluginPublish = { module = "com.gradle.publish:plugin-publish-plugin", version.r

androidx-gradlePluginLints = "androidx.lint:lint-gradle:1.0.0"
# Dummy to get renovate updates, the version is used in rootProject build.gradle with spotless.
ktfmt = "com.facebook:ktfmt:0.63"
ktfmt = "com.facebook:ktfmt:0.64"

junit-bom = "org.junit:junit-bom:6.1.0"
assertk = "com.willowtreeapps.assertk:assertk:0.28.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,24 @@ sealed class SnippetExecutable : Executable {
projectRoot.addSubProject("api", apiScript)

val (imports, withoutImports) = importsExtractor(snippet)
val mainScript =
buildString {
append(imports)
append(lineSeparator)
// All buildscript {} blocks must appear before any plugins {} blocks in the script.
if (withoutImports.contains("buildscript {")) {
append(withoutImports)
} else {
if (!withoutImports.contains("plugins {")) {
append(pluginsBlock)
append(lineSeparator)
}
append(withoutImports)
}
append(lineSeparator)
append(assembleDependsOn)
val mainScript = buildString {
append(imports)
append(lineSeparator)
// All buildscript {} blocks must appear before any plugins {} blocks in the script.
if (withoutImports.contains("buildscript {")) {
append(withoutImports)
} else {
if (!withoutImports.contains("plugins {")) {
append(pluginsBlock)
append(lineSeparator)
}
.trimIndent()
append(withoutImports)
}
append(lineSeparator)
append(assembleDependsOn)
append(lineSeparator)
}
.trimIndent()
projectRoot.addSubProject("main", mainScript)
projectRoot.resolve("main/foo.jar").createFile().also {
// Dummy JAR file to ensure the project can be built.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,19 @@ class RelocationTest : BasePluginTest() {
.trimIndent()
)
val entryPrefix = relocationPrefix.replace('.', '/')
val relocatedEntries =
buildSet {
addAll(
junitEntries
.map { "$entryPrefix/$it" }
.filterNot { it.startsWith("$entryPrefix/META-INF/") }
)
var parent = entryPrefix
while (parent.isNotEmpty()) {
add("$parent/")
parent = parent.substringBeforeLast('/', "")
}
}
.toTypedArray()
val relocatedEntries = buildSet {
addAll(
junitEntries
.map { "$entryPrefix/$it" }
.filterNot { it.startsWith("$entryPrefix/META-INF/") }
)
var parent = entryPrefix
while (parent.isNotEmpty()) {
add("$parent/")
parent = parent.substringBeforeLast('/', "")
}
}
.toTypedArray()

val result = runWithSuccess(shadowJarPath, infoArgument)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,18 @@ fun Assert<JarPath>.containsOnly(vararg entries: String) = toEntries().containsO
* Ensures the JAR contains exactly the specified entries, including duplicates, in any order. Used
* alone, without [containsAtLeast] or [containsNone].
*/
fun Assert<JarPath>.containsExactlyInAnyOrder(vararg entries: String) =
transform { actual ->
ZipInputStream(actual.path.inputStream()).use { jarInput ->
val allEntries = mutableListOf<String>()
while (true) {
val entry = jarInput.nextEntry ?: break
allEntries.add(entry.name)
jarInput.closeEntry()
}
allEntries
}
fun Assert<JarPath>.containsExactlyInAnyOrder(vararg entries: String) = transform { actual ->
ZipInputStream(actual.path.inputStream()).use { jarInput ->
val allEntries = mutableListOf<String>()
while (true) {
val entry = jarInput.nextEntry ?: break
allEntries.add(entry.name)
jarInput.closeEntry()
}
.containsExactlyInAnyOrder(*entries)
allEntries
}
}
.containsExactlyInAnyOrder(*entries)

private fun Assert<JarPath>.toEntries() = transform { actual ->
actual.entries().toList().map { it.name }
Expand Down