Skip to content

Commit

Permalink
Intellij Platform Plugin migration - runIde task works
Browse files Browse the repository at this point in the history
  • Loading branch information
whimet committed Dec 25, 2024
1 parent 9c12671 commit 428dae9
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 50 deletions.
133 changes: 87 additions & 46 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.changelog.date
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType

fun properties(key: String) = project.findProperty(key).toString()

Expand All @@ -11,11 +12,12 @@ plugins {
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "2.0.0-Beta2"
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
id("org.jetbrains.intellij") version "1.16.1"
id("org.jetbrains.intellij.platform") version "2.2.0"
id("org.jetbrains.intellij.platform.migration") version "2.2.0"
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
id("org.jetbrains.changelog") version "1.3.1"
// detekt linter - read more: https://detekt.github.io/detekt/gradle.html
id("io.gitlab.arturbosch.detekt") version "1.21.0"
id("io.gitlab.arturbosch.detekt") version "1.23.6"
// ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle
id("org.jlleitschuh.gradle.ktlint") version "11.0.0"
id("groovy")
Expand All @@ -30,9 +32,16 @@ version = properties("pluginVersion")
// Configure project's dependencies
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
flatDir { dirs("lib") }
}
dependencies {
intellijPlatform {
create(properties("platformType"), properties("platformVersion"))
bundledPlugins(listOf("com.intellij.java", "org.intellij.intelliLang"))
}
// https://mvnrepository.com/artifact/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer
implementation("com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer")
// compile "org.jetbrains:markdown:${markdownParserVersion}"
Expand All @@ -51,17 +60,49 @@ dependencies {
}
// Configure gradle-intellij-plugin plugin.
// Read more: https://github.com/JetBrains/gradle-intellij-plugin
intellij {
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))
downloadSources.set(properties("platformDownloadSources").toBoolean())
updateSinceUntilBuild.set(false) // don't write information of current IntelliJ build into plugin.xml, instead use information from patchPluginXml
intellijPlatform {
pluginConfiguration {
name = properties("pluginName")
version = properties("pluginVersion")

description = File(projectDir, "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) }

changeNotes = changelog.getLatest().toHTML()

ideaVersion {
sinceBuild = properties("pluginSinceBuild")
}
}

pluginVerification {
ides {
ide(IntelliJPlatformType.IntellijIdeaCommunity, properties("pluginVerifierIdeVersions").split(',').map(String::trim).filter(String::isNotEmpty)[0])
}
}

publishing {
token = System.getenv("PUBLISH_TOKEN")
channels = listOf(if ("true" == System.getenv("PRE_RELEASE")) "EAP" else "default")
}

// pluginName.set(properties("pluginName"))
// version.set(properties("platformVersion"))
// type.set(properties("platformType"))
// downloadSources.set(properties("platformDownloadSources").toBoolean())
// updateSinceUntilBuild.set(false) // don't write information of current IntelliJ build into plugin.xml, instead use information from patchPluginXml

// Plugin Dependencies:
// https://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_dependencies.html
//
plugins.set(listOf("com.intellij.java", "org.intellij.intelliLang"))
// plugins.set(listOf("com.intellij.java", "org.intellij.intelliLang"))
}

// Configure detekt plugin.
Expand Down Expand Up @@ -128,44 +169,44 @@ tasks {
withType<Detekt> {
jvmTarget = "11"
}
patchPluginXml {
version.set(properties("pluginVersion"))
sinceBuild.set((properties("pluginSinceBuild")))
// untilBuild(pluginUntilBuild) --> don't set "untilBuild" to allow new versions to use existing plugin without changes until breaking API changes are known

// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription.set(
provider {
File(projectDir, "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.getLatest().toHTML()
}
)
}

runPluginVerifier {
ideVersions.set(properties("pluginVerifierIdeVersions").split(',').map(String::trim).filter(String::isNotEmpty))
}
// patchPluginXml {
// version.set(properties("pluginVersion"))
// sinceBuild.set((properties("pluginSinceBuild")))
// // untilBuild(pluginUntilBuild) --> don't set "untilBuild" to allow new versions to use existing plugin without changes until breaking API changes are known
//
// // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
// pluginDescription.set(
// provider {
// File(projectDir, "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.getLatest().toHTML()
// }
// )
// }

publishPlugin {
dependsOn("patchChangelog")
token.set(System.getenv("PUBLISH_TOKEN"))
// if release is marked as a pre-release in the GitHub release, push it to EAP
channels.set(listOf(if ("true" == System.getenv("PRE_RELEASE")) "EAP" else "default"))
}
// runPluginVerifier {
// ideVersions.set(properties("pluginVerifierIdeVersions").split(',').map(String::trim).filter(String::isNotEmpty))
// }
//
// publishPlugin {
// dependsOn("patchChangelog")
// token.set(System.getenv("PUBLISH_TOKEN"))
// // if release is marked as a pre-release in the GitHub release, push it to EAP
// channels.set(listOf(if ("true" == System.getenv("PRE_RELEASE")) "EAP" else "default"))
// }
changelog {
version.set(properties("pluginVersion"))
header.set(provider { "[${project.version}] - ${date()}" })
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ markdownParserVersion = 0.1.23

pluginGroup = org.jetbrains.plugins.template
pluginName = zenuml
pluginVersion = 2024.12.23
pluginVersion = 2024.12.25
pluginSinceBuild = 233

# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
# See https://jb.gg/intellij-platform-builds-list for available build versions.
pluginVerifierIdeVersions = 2023.3
pluginVerifierIdeVersions = 2024.1

platformType = IC
platformVersion = 2023.3
platformVersion = 2024.1
platformDownloadSources = true

# Opt-out flag for bundling Kotlin standard library.
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 428dae9

Please sign in to comment.