build.gradle.kts (91 lines of code) (raw):
import org.gradle.kotlin.dsl.support.kotlinCompilerOptions
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
fun properties(key: String) = project.findProperty(key).toString()
plugins {
id("java") // Java support
alias(libs.plugins.kotlin) // Kotlin support
alias(libs.plugins.intelliJPlatform) // IntelliJ Platform Gradle Plugin
alias(libs.plugins.changelog) // Gradle Changelog Plugin
alias(libs.plugins.qodana) // Gradle Qodana Plugin
id("me.filippov.gradle.jvm.wrapper") version "0.14.0"
}
group = properties("pluginGroup")
version = properties("pluginVersion")
// Configure project's dependencies
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
jetbrainsRuntime()
}
}
dependencies {
intellijPlatform {
rider(properties("platformVersion")) {
useInstaller = false
}
bundledPlugin("com.jetbrains.rider-cpp")
jetbrainsRuntime()
}
}
intellijPlatform {
pluginConfiguration {
// name = providers.gradleProperty("pluginName")
}
}
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
version.set(properties("pluginVersion"))
path.set(file("CHANGELOG.md").canonicalPath)
itemPrefix.set("-")
keepUnreleasedSection.set(true)
unreleasedTerm.set("[Unreleased]")
groups.set(listOf("Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"))
lineSeparator.set("\n")
}
// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
//qodana {
// cachePath.set(projectDir.resolve(".qodana").canonicalPath)
// reportPath.set(projectDir.resolve("build/reports/inspections").canonicalPath)
// saveReport.set(true)
// showReport.set(System.getenv("QODANA_SHOW_REPORT").toBoolean())
//}
kotlin {
jvmToolchain(21)
}
tasks {
// Set the JVM compatibility versions
properties("javaVersion").let {
withType<JavaCompile> {
sourceCompatibility = it
targetCompatibility = it
}
}
wrapper {
gradleVersion = properties("gradleVersion")
}
patchPluginXml {
sinceBuild.set(properties("pluginSinceBuild"))
untilBuild.set(properties("pluginUntilBuild"))
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription.set(
projectDir.resolve("README.md").readText().lines().run {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"
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").run { markdownToHTML(this) }
)
// Get the latest available change notes from the changelog file
changeNotes.set(provider {
changelog.renderItem(
changelog.run{
getOrNull(properties("pluginVersion")) ?: getUnreleased()
}
.withHeader(false)
.withEmptySections(false),
Changelog.OutputType.HTML
)
})
}
signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}
publishPlugin {
dependsOn("patchChangelog")
token.set(System.getenv("PUBLISH_TOKEN"))
// pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
// channels.(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first()))
}
}