Pill: Attach asm sources
This commit is contained in:
@@ -18,6 +18,9 @@ val intellijSeparateSdks: Boolean by rootProject.extra
|
||||
val installIntellijCommunity = !intellijUltimateEnabled || intellijSeparateSdks
|
||||
val installIntellijUltimate = intellijUltimateEnabled
|
||||
|
||||
val platformBaseVersion = intellijVersion.substringBefore('.', "").takeIf { it.isNotEmpty() }
|
||||
?: error("Invalid IDEA version $intellijVersion")
|
||||
|
||||
logger.info("intellijUltimateEnabled: $intellijUltimateEnabled")
|
||||
|
||||
logger.info("intellijVersion: $intellijVersion")
|
||||
@@ -48,11 +51,15 @@ repositories {
|
||||
}
|
||||
maven { setUrl("$intellijRepo/$intellijReleaseType") }
|
||||
maven { setUrl("https://plugins.jetbrains.com/maven") }
|
||||
ivy {
|
||||
artifactPattern("https://raw.github.com/JetBrains/intellij-community/[revision]/lib/src/[artifact].zip")
|
||||
}
|
||||
}
|
||||
|
||||
val intellij by configurations.creating
|
||||
val intellijUltimate by configurations.creating
|
||||
val sources by configurations.creating
|
||||
val `asm-shaded-sources` by configurations.creating
|
||||
val `jps-standalone` by configurations.creating
|
||||
val `jps-build-test` by configurations.creating
|
||||
val `intellij-core` by configurations.creating
|
||||
@@ -76,6 +83,7 @@ dependencies {
|
||||
}
|
||||
}
|
||||
sources("com.jetbrains.intellij.idea:ideaIC:$intellijVersion:sources@jar")
|
||||
`asm-shaded-sources`("asmsources:asm-src:$platformBaseVersion@zip")
|
||||
`jps-standalone`("com.jetbrains.intellij.idea:jps-standalone:$intellijVersion")
|
||||
`jps-build-test`("com.jetbrains.intellij.idea:jps-build-test:$intellijVersion")
|
||||
`intellij-core`("com.jetbrains.intellij.idea:intellij-core:$intellijVersion")
|
||||
@@ -138,6 +146,8 @@ val copyIntellijSdkSources by tasks.creating {
|
||||
|
||||
val copyJpsBuildTest by tasks.creating { configureExtractFromConfigurationTask(`jps-build-test`) { it.singleFile } }
|
||||
|
||||
val copyAsmShadedSources by tasks.creating { configureExtractFromConfigurationTask(`asm-shaded-sources`) { it.singleFile } }
|
||||
|
||||
val unzipNodeJSPlugin by tasks.creating { configureExtractFromConfigurationTask(`plugins-NodeJS`) { zipTree(it.singleFile) } }
|
||||
|
||||
fun writeIvyXml(moduleName: String, fileName: String, jarFiles: FileCollection, baseDir: File, sourcesJar: File?) {
|
||||
@@ -159,7 +169,7 @@ fun writeIvyXml(moduleName: String, fileName: String, jarFiles: FileCollection,
|
||||
}
|
||||
|
||||
val prepareIvyXmls by tasks.creating {
|
||||
dependsOn(unzipIntellijCore, unzipJpsStandalone, copyIntellijSdkSources, copyJpsBuildTest)
|
||||
dependsOn(unzipIntellijCore, unzipJpsStandalone, copyIntellijSdkSources, copyJpsBuildTest, copyAsmShadedSources)
|
||||
|
||||
val intellijSdkDir = File(repoDir, intellij.name)
|
||||
val intellijUltimateSdkDir = File(repoDir, intellijUltimate.name)
|
||||
@@ -176,7 +186,7 @@ val prepareIvyXmls by tasks.creating {
|
||||
outputs.file(File(repoDir, "${intellijUltimate.name}.ivy.xml"))
|
||||
}
|
||||
|
||||
val flatDeps = listOf(`intellij-core`, `jps-standalone`, `jps-build-test`)
|
||||
val flatDeps = listOf(`intellij-core`, `jps-standalone`, `jps-build-test`, `asm-shaded-sources`)
|
||||
flatDeps.forEach {
|
||||
inputs.dir(File(repoDir, it.name))
|
||||
outputs.file(File(repoDir, "${it.name}.ivy.xml"))
|
||||
|
||||
@@ -99,15 +99,18 @@ class JpsCompatibleRootPlugin : Plugin<Project> {
|
||||
|
||||
private lateinit var projectDir: File
|
||||
private lateinit var platformVersion: String
|
||||
private lateinit var platformBaseNumber: String
|
||||
private lateinit var platformDir: File
|
||||
|
||||
private fun pill(project: Project) {
|
||||
projectDir = project.projectDir
|
||||
platformVersion = project.extensions.extraProperties.get("versions.intellijSdk").toString()
|
||||
platformBaseNumber = platformVersion.substringBefore(".", "").takeIf { it.isNotEmpty() }
|
||||
?: error("Invalid platform version: $platformVersion")
|
||||
platformDir = File(projectDir, "buildSrc/prepare-deps/intellij-sdk/build/repo/kotlin.build.custom.deps/$platformVersion")
|
||||
|
||||
val jpsProject = parse(project, ParserContext(dependencyMappers))
|
||||
.mapLibraries(attachPlatformSources(platformVersion))
|
||||
.mapLibraries(this::attachPlatformSources, this::attachAsmSources)
|
||||
|
||||
val files = render(jpsProject, getProjectLibraries(jpsProject))
|
||||
|
||||
@@ -211,7 +214,7 @@ class JpsCompatibleRootPlugin : Plugin<Project> {
|
||||
workspaceFile.writeText(postProcessedXml)
|
||||
}
|
||||
|
||||
private fun attachPlatformSources(platformVersion: String) = fun(library: PLibrary): PLibrary {
|
||||
private fun attachPlatformSources(library: PLibrary): PLibrary {
|
||||
val platformSourcesJar = File(platformDir, "sources/ideaIC-$platformVersion-sources.jar")
|
||||
|
||||
if (library.classes.any { it.startsWith(platformDir) }) {
|
||||
@@ -221,6 +224,17 @@ class JpsCompatibleRootPlugin : Plugin<Project> {
|
||||
return library
|
||||
}
|
||||
|
||||
private fun attachAsmSources(library: PLibrary): PLibrary {
|
||||
val asmSourcesJar = File(platformDir, "asm-shaded-sources/asm-src-$platformBaseNumber.jar")
|
||||
val asmAllJar = File(platformDir, "intellij/lib/asm-all.jar")
|
||||
|
||||
if (library.classes.any { it == asmAllJar }) {
|
||||
return library.attachSource(asmSourcesJar)
|
||||
}
|
||||
|
||||
return library
|
||||
}
|
||||
|
||||
private fun PProject.mapLibraries(vararg mappers: (PLibrary) -> PLibrary): PProject {
|
||||
fun mapLibrary(root: POrderRoot): POrderRoot {
|
||||
val dependency = root.dependency
|
||||
|
||||
Reference in New Issue
Block a user