build.gradle.kts (93 lines of code) (raw):
import org.jetbrains.intellij.platform.gradle.ProductMode
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
fun properties(key: String) = project.findProperty(key).toString()
plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "2.2.0"
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij.platform") version "2.7.0"
// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "2.2.0"
}
group = properties("pluginGroup")
version = properties("pluginVersion")
// Configure project's dependencies
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
}
dependencies {
testImplementation("io.mockk:mockk:1.14.3") {
exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core-jvm")
}
testImplementation("junit:junit:4.13.2")
intellijPlatform {
val type = providers.gradleProperty("platformType")
val version = project.provider {
providers.gradleProperty("platformVersion").get() + providers.gradleProperty("platformBranch").get()
}
create(type, version) {
useInstaller = false
productMode = ProductMode.MONOLITH
}
testFramework(TestFrameworkType.Platform)
bundledPlugins(properties("platformBundledPlugins").toPlugins())
bundledModules(properties("platformBundledModules").toPlugins())
}
}
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
version.set(properties("pluginVersion"))
groups.set(emptyList())
}
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(providers.gradleProperty("javaVersion").get()))
}
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(providers.gradleProperty("javaVersion").get()))
}
}
tasks {
withType<JavaCompile>().configureEach {
val javaVersion = properties("javaVersion")
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
wrapper {
gradleVersion = properties("gradleVersion")
}
patchPluginXml {
version = properties("pluginVersion")
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")) ?: getLatest()
}, 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())
}
}
private fun String.toPlugins(): List<String> = split(',')
.map(String::trim)
.filter(String::isNotEmpty)