chore: move plugin stuff back into separate subproject

Putting it in the root project breaks the devkit plugin
This commit is contained in:
FalsePattern 2024-07-04 14:48:49 +02:00
parent e71b780185
commit e7be7e1ae8
Signed by: falsepattern
GPG key ID: E930CDEC50C50E23
10 changed files with 127 additions and 114 deletions

View file

@ -38,9 +38,11 @@ val clionVersion = properties("clionVersion").get()
val clionPlugins = listOf("com.intellij.clion", "com.intellij.cidr.lang", "com.intellij.cidr.base", "com.intellij.nativeDebug") val clionPlugins = listOf("com.intellij.clion", "com.intellij.cidr.lang", "com.intellij.cidr.base", "com.intellij.nativeDebug")
val lsp4jVersion = "0.21.1" val lsp4jVersion = "0.21.1"
val lsp4ijVersion = "0.0.2" val lsp4ijVersion = "0.3.0-20240702-174041"
val lsp4ijDepString = "${if (lsp4ijVersion.contains("-")) "nightly." else ""}com.jetbrains.plugins:com.redhat.devtools.lsp4ij:$lsp4ijVersion" val lsp4ijNightly = lsp4ijVersion.contains("-")
val lsp4ijDepString = "${if (lsp4ijNightly) "nightly." else ""}com.jetbrains.plugins:com.redhat.devtools.lsp4ij:$lsp4ijVersion"
val lsp4ijPluginString = "com.redhat.devtools.lsp4ij:$lsp4ijVersion${if (lsp4ijNightly) "@nightly" else ""}"
val lsp4ijDep: DependencyHandler.() -> Unit = { val lsp4ijDep: DependencyHandler.() -> Unit = {
intellijPlatformPluginDependency(lsp4ijDepString) intellijPlatformPluginDependency(lsp4ijDepString)
@ -138,7 +140,6 @@ allprojects {
dependsOn("generateGrammars") dependsOn("generateGrammars")
} }
} }
} }
configure<JavaPluginExtension> { configure<JavaPluginExtension> {
@ -187,6 +188,9 @@ project(":zig") {
dependencies { dependencies {
implementation(project(":common")) implementation(project(":common"))
lsp4ijDep() lsp4ijDep()
intellijPlatform {
plugin(lsp4ijPluginString)
}
} }
tasks { tasks {
generateLexer { generateLexer {
@ -246,140 +250,149 @@ project(":zon") {
} }
} }
dependencies { project(":plugin") {
implementation(project(":zig")) dependencies {
implementation(project(":project")) implementation(project(":common"))
implementation(project(":zon")) implementation(project(":zig"))
implementation(project(":debugger")) implementation(project(":project"))
implementation(project(":zon"))
implementation(project(":debugger"))
intellijPlatform {
zipSigner()
pluginVerifier()
plugin(lsp4ijPluginString)
}
}
intellijPlatform { intellijPlatform {
zipSigner() pluginConfiguration {
pluginVerifier() name = properties("pluginName")
when (baseIDE) { description = providers.fileContents(rootProject.layout.projectDirectory.file("README.md")).asText.map {
"idea" -> intellijIdeaCommunity(ideaVersion) val start = "<!-- Plugin description -->"
"clion" -> clion(clionVersion) val end = "<!-- Plugin description end -->"
}
plugin("com.redhat.devtools.lsp4ij:$lsp4ijVersion")
}
}
intellijPlatform { with(it.lines()) {
pluginConfiguration { if (!containsAll(listOf(start, end))) {
name = properties("pluginName") throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
description = providers.fileContents(rootProject.layout.projectDirectory.file("README.md")).asText.map { }
val start = "<!-- Plugin description -->" subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML)
val end = "<!-- Plugin description end -->"
with(it.lines()) {
if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
} }
subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML) }
changeNotes = pluginVersion().map { pluginVersion ->
with(rootProject.changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
.withHeader(false)
.withEmptySections(false),
Changelog.OutputType.HTML,
)
}
}
version = pluginVersionFull()
}
signing {
certificateChainFile = rootProject.file("secrets/chain.crt")
privateKeyFile = rootProject.file("secrets/private.pem")
password = environment("PRIVATE_KEY_PASSWORD")
}
verifyPlugin {
ides {
ide(IntelliJPlatformType.IntellijIdeaCommunity, ideaVersion)
ide(IntelliJPlatformType.IntellijIdeaUltimate, ideaVersion)
ide(IntelliJPlatformType.CLion, clionVersion)
} }
} }
changeNotes = pluginVersion().map { pluginVersion -> }
with(rootProject.changelog) {
renderItem( // Include the generated files in the source set
(getOrNull(pluginVersion) ?: getUnreleased())
.withHeader(false) // Collects all jars produced by compilation of project modules and merges them into singe one.
.withEmptySections(false), // We need to put all plugin manifest files into single jar to make new plugin model work
Changelog.OutputType.HTML, val mergePluginJarTask = task<Jar>("mergePluginJars") {
) duplicatesStrategy = DuplicatesStrategy.FAIL
archiveBaseName.set("ZigBrains")
exclude("META-INF/MANIFEST.MF")
exclude("**/classpath.index")
val pluginLibDir by lazy {
val sandboxTask = tasks.prepareSandbox.get()
sandboxTask.destinationDir.resolve("${project.extensionProvider.map { it.projectName }.get()}/lib")
}
val pluginJars by lazy {
pluginLibDir.listFiles().orEmpty().filter { it.isPluginJar() }
}
destinationDirectory.set(project.layout.dir(provider { pluginLibDir }))
doFirst {
for (file in pluginJars) {
from(zipTree(file))
} }
} }
version = pluginVersionFull()
}
signing {
certificateChainFile = rootProject.file("secrets/chain.crt")
privateKeyFile = rootProject.file("secrets/private.pem")
password = environment("PRIVATE_KEY_PASSWORD")
}
verifyPlugin {
ides {
ide(IntelliJPlatformType.IntellijIdeaCommunity, ideaVersion)
ide(IntelliJPlatformType.IntellijIdeaUltimate, ideaVersion)
ide(IntelliJPlatformType.CLion, clionVersion)
}
}
}
// Include the generated files in the source set doLast {
delete(pluginJars)
// Collects all jars produced by compilation of project modules and merges them into singe one.
// We need to put all plugin manifest files into single jar to make new plugin model work
val mergePluginJarTask = task<Jar>("mergePluginJars") {
duplicatesStrategy = DuplicatesStrategy.FAIL
archiveBaseName.set("ZigBrains")
exclude("META-INF/MANIFEST.MF")
exclude("**/classpath.index")
val pluginLibDir by lazy {
val sandboxTask = tasks.prepareSandbox.get()
sandboxTask.destinationDir.resolve("${project.extensionProvider.map { it.projectName }.get()}/lib")
}
val pluginJars by lazy {
pluginLibDir.listFiles().orEmpty().filter { it.isPluginJar() }
}
destinationDirectory.set(project.layout.dir(provider { pluginLibDir }))
doFirst {
for (file in pluginJars) {
from(zipTree(file))
} }
} }
doLast { tasks {
delete(pluginJars) runIde {
dependsOn(mergePluginJarTask)
enabled = true
}
prepareSandbox {
finalizedBy(mergePluginJarTask)
enabled = true
}
buildSearchableOptions {
dependsOn(mergePluginJarTask)
}
verifyPlugin {
dependsOn(mergePluginJarTask)
enabled = true
}
verifyPluginProjectConfiguration {
enabled = true
}
signPlugin {
enabled = true
}
verifyPluginSignature {
dependsOn(signPlugin)
}
buildPlugin {
enabled = true
}
} }
} }
tasks { tasks {
runIde {
dependsOn(mergePluginJarTask)
enabled = true
}
prepareSandbox {
finalizedBy(mergePluginJarTask)
enabled = true
}
buildSearchableOptions {
dependsOn(mergePluginJarTask)
}
verifyPlugin {
dependsOn(mergePluginJarTask)
enabled = true
}
verifyPluginProjectConfiguration {
enabled = true
}
signPlugin {
enabled = true
}
verifyPluginSignature {
dependsOn(signPlugin)
}
buildPlugin {
enabled = true
}
generateLexer { generateLexer {
enabled = false enabled = false
} }
generateParser { generateParser {
enabled = false enabled = false
} }
} }
dependencies {
intellijPlatform {
when (baseIDE) {
"idea" -> intellijIdeaCommunity(ideaVersion)
"clion" -> clion(clionVersion)
}
}
}
fun distFile(it: String) = layout.buildDirectory.file("dist/ZigBrains-${pluginVersion().get()}-$it-signed.zip") fun distFile(it: String) = layout.buildDirectory.file("dist/ZigBrains-${pluginVersion().get()}-$it-signed.zip")
publishVersions.forEach { publishVersions.forEach {

View file

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1 KiB

View file

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

Before

Width:  |  Height:  |  Size: 858 B

After

Width:  |  Height:  |  Size: 858 B

View file

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB