in src/main/kotlin/org/jetbrains/intellij/platform/gradle/providers/CoroutinesJavaAgentValueSource.kt [69:98]
override fun obtain(): File {
val platformPath = parameters.intelliJPlatformConfiguration.platformPath()
val productInfo = platformPath.productInfo()
val urls = collectIntelliJPlatformJars(productInfo, platformPath).map { it.toUri().toURL() }.toTypedArray()
val fqn = URLClassLoader(urls).use {
fqns.values.firstNotNullOfOrNull { fqn -> it.runCatching { loadClass(fqn) }.getOrNull() }
}?.name
val targetFile = parameters.targetDirectory.map {
val filename = fqns.entries.first { entry -> entry.value == fqn }.key
it.file(filename).asFile
}.get()
if (!targetFile.exists()) {
val manifest = Manifest(
"""
Manifest-Version: 1.0
Premain-Class: $fqn
Can-Retransform-Classes: true
Multi-Release: true
""".trimIndent().byteInputStream(),
)
targetFile.createNewFile()
JarOutputStream(targetFile.outputStream(), manifest).close()
}
return targetFile
}