Skip to content
Open
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 build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ plugins {
kotlin("jvm")
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
// Adding plugins used in multiple places to the classpath for centralized version control
id("com.gradleup.shadow") version "8.3.9" apply false
id("com.gradleup.shadow") version "9.3.1" apply false
id("org.jetbrains.dokka") version "1.9.20" apply false
id("com.android.lint") version "8.13.0" apply false
}
Expand Down
4 changes: 4 additions & 0 deletions kotlin-analysis-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ tasks.withType<ShadowJar>().configureEach {
exclude("kotlin/**")
exclude("kotlinx/coroutines/**")
archiveClassifier.set("")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
mergeServiceFiles()
filesMatching("META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
}

abstract class ValidateShadowJar : DefaultTask() {
Expand Down
26 changes: 18 additions & 8 deletions symbol-processing-aa-embeddable/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowCopyAction.Companion.CONSTANT_TIME_FOR_ZIP_ENTRIES
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer
import com.github.jengelman.gradle.plugins.shadow.transformers.ResourceTransformer
import com.github.jengelman.gradle.plugins.shadow.transformers.TransformerContext
import org.apache.tools.zip.ZipEntry
import org.apache.tools.zip.ZipOutputStream
import org.gradle.jvm.tasks.Jar
import java.io.InputStreamReader
import java.util.zip.ZipFile

evaluationDependsOn(":kotlin-analysis-api")
Expand Down Expand Up @@ -66,15 +66,15 @@ val prefixesToRelocate = listOf(
Pair(it, "ksp." + it)
}

class AAServiceTransformer : Transformer {
class AAServiceTransformer : ResourceTransformer {
private val entries = HashMap<String, String>()

// Names of extension points needs to be relocated, because ShadowJar does that, too.
private val regex = Regex("\"((org\\.jetbrains\\.kotlin\\.|com\\.intellij\\.).+)\"")

override fun canTransformResource(element: FileTreeElement): Boolean {
return element.name.startsWith("META-INF/analysis-api/") ||
element.name == "META-INF/extensions/compiler.xml"
return element.relativePath.pathString.startsWith("META-INF/analysis-api/") ||
element.relativePath.pathString == "META-INF/extensions/compiler.xml"
Comment on lines +76 to +77

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return element.relativePath.pathString.startsWith("META-INF/analysis-api/") ||
element.relativePath.pathString == "META-INF/extensions/compiler.xml"
return element.path.startsWith("META-INF/analysis-api/") ||
element.path == "META-INF/extensions/compiler.xml"

}

override fun getName(): String {
Expand All @@ -88,7 +88,7 @@ class AAServiceTransformer : Transformer {
override fun modifyOutputStream(os: ZipOutputStream, preserveFileTimestamps: Boolean) {
fun putOneEntry(path: String, content: String) {
val entry = ZipEntry(path)
entry.time = TransformerContext.getEntryTimestamp(preserveFileTimestamps, entry.time)
entry.time = if (preserveFileTimestamps) entry.time else CONSTANT_TIME_FOR_ZIP_ENTRIES
os.putNextEntry(entry)
os.write(content.toByteArray())
os.closeEntry()
Expand Down Expand Up @@ -120,12 +120,12 @@ class AAServiceTransformer : Transformer {

override fun transform(context: TransformerContext) {
val path = context.path
val content = InputStreamReader(context.`is`).readText()
val content = context.inputStream.reader().readText()
entries[path] = content
}
}

tasks.withType(ShadowJar::class.java).configureEach {
tasks.withType<ShadowJar>().configureEach {
archiveClassifier.set("")
// ShadowJar picks up the `compile` configuration by default and pulls stdlib in.
// Therefore, specifying another configuration instead.
Expand All @@ -151,7 +151,17 @@ tasks.withType(ShadowJar::class.java).configureEach {
excludeEfficiently("org.checkerframework.checker.nullness.qual.Nullable")
}
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
mergeServiceFiles()
filesMatching(
listOf(
"META-INF/services/**",
"META-INF/analysis-api/",
"META-INF/extensions/compiler.xml",
)
) {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
exclude("META-INF/compiler.version")
exclude("META-INF/*.kotlin_module")
exclude("javax/**")
Expand Down
Loading