diff --git a/build.gradle.kts b/build.gradle.kts index cf3ddf8..0f05424 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,6 +3,7 @@ import org.jetbrains.changelog.markdownToHTML import org.jetbrains.grammarkit.tasks.GenerateLexerTask import org.jetbrains.grammarkit.tasks.GenerateParserTask import org.jetbrains.kotlin.gradle.internal.ensureParentDirsCreated +import org.jetbrains.intellij.platform.gradle.TestFrameworkType fun properties(key: String) = providers.gradleProperty(key) @@ -11,7 +12,7 @@ fun environment(key: String) = providers.environmentVariable(key) plugins { id("java") // Java support alias(libs.plugins.kotlin) // Kotlin support - alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin + alias(libs.plugins.intelliJPlatform) // Gradle IntelliJ Plugin alias(libs.plugins.changelog) // Gradle Changelog Plugin alias(libs.plugins.qodana) // Gradle Qodana Plugin alias(libs.plugins.kover) // Gradle Kover Plugin @@ -25,6 +26,11 @@ version = properties("pluginVersion").get() repositories { mavenLocal() mavenCentral() + + // IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html + intellijPlatform { + defaultRepositories() + } } dependencies { @@ -34,6 +40,22 @@ dependencies { implementation("com.bybutter.sisyphus:sisyphus-grpc:2.1.22") implementation("com.bybutter.sisyphus:sisyphus-jackson-protobuf:2.1.22") implementation("io.grpc:grpc-netty:1.65.0") + + // IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html + intellijPlatform { + create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion")) + + // Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins. + bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') }) + + // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace. + plugins(providers.gradleProperty("platformPlugins").map { it.split(',') }) + + instrumentationTools() + pluginVerifier() + zipSigner() + testFramework(TestFrameworkType.Platform) + } } // Set the JVM language level used to build the project. @@ -44,20 +66,68 @@ kotlin { } } -// Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html -intellij { - pluginName = properties("pluginName") - version = properties("platformVersion") - type = properties("platformType") +// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html +intellijPlatform { + pluginConfiguration { + version = providers.gradleProperty("pluginVersion") + + // Extract the section from README.md and provide for the plugin's manifest + description = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { + val start = "" + val 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) + } + } - // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. - plugins = properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) } + val changelog = project.changelog // local variable for configuration cache compatibility + // Get the latest available change notes from the changelog file + changeNotes = providers.gradleProperty("pluginVersion").map { pluginVersion -> + with(changelog) { + renderItem( + (getOrNull(pluginVersion) ?: getUnreleased()) + .withHeader(false) + .withEmptySections(false), + Changelog.OutputType.HTML, + ) + } + } + + ideaVersion { + sinceBuild = providers.gradleProperty("pluginSinceBuild") + untilBuild = providers.gradleProperty("pluginUntilBuild") + } + } + + signing { + certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN") + privateKey = providers.environmentVariable("PRIVATE_KEY") + password = providers.environmentVariable("PRIVATE_KEY_PASSWORD") + } + + publishing { + token = providers.environmentVariable("PUBLISH_TOKEN") + // The 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 = providers.gradleProperty("pluginVersion").map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) } + } + + pluginVerification { + ides { + recommended() + } + } } // Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin changelog { groups.empty() - repositoryUrl = properties("pluginRepositoryUrl") + repositoryUrl = providers.gradleProperty("pluginRepositoryUrl") } // Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration @@ -76,53 +146,6 @@ tasks { gradleVersion = properties("gradleVersion").get() } - patchPluginXml { - version = properties("pluginVersion") - sinceBuild = properties("pluginSinceBuild") - untilBuild = properties("pluginUntilBuild") - - // Extract the section from README.md and provide for the plugin's manifest - pluginDescription = - providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { - val start = "" - val 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) - } - } - - val changelog = project.changelog // local variable for configuration cache compatibility - // Get the latest available change notes from the changelog file - changeNotes = - properties("pluginVersion").map { pluginVersion -> - with(changelog) { - renderItem( - (getOrNull(pluginVersion) ?: getUnreleased()) - .withHeader(false) - .withEmptySections(false), - Changelog.OutputType.HTML, - ) - } - } - } - - // Configure UI tests plugin - // Read more: https://github.com/JetBrains/intellij-ui-test-robot - runIdeForUiTests { - systemProperty("robot-server.port", "8082") - systemProperty("ide.mac.message.dialogs.as.sheets", "false") - systemProperty("jb.privacy.policy.text", "") - systemProperty("jb.consents.confirmation.enabled", "false") - } - - runIde { - jvmArguments.add("-Didea.ProcessCanceledException=disabled") - } - generateLexer { sourceFile = layout.projectDirectory.file("src/main/grammar/protobuf.flex") targetOutputDir = @@ -154,7 +177,7 @@ tasks { } prepareSandbox { - val file = layout.buildDirectory.file("idea-sandbox/config/disabled_plugins.txt").get().asFile + val file = sandboxConfigDirectory.file("disabled_plugins.txt").get().asFile doLast { file.ensureParentDirsCreated() file.writeText( @@ -164,20 +187,11 @@ tasks { }, ) } + } publishPlugin { - dependsOn("patchChangelog") - token = environment("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 = - properties("pluginVersion").map { - listOf( - it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }, - ) - } + dependsOn(patchChangelog) } compileKotlin { @@ -192,3 +206,24 @@ sourceSets { } } } + +intellijPlatformTesting { + runIde { + register("runIdeForUiTests") { + task { + jvmArgumentProviders += CommandLineArgumentProvider { + listOf( + "-Drobot-server.port=8082", + "-Dide.mac.message.dialogs.as.sheets=false", + "-Djb.privacy.policy.text=", + "-Djb.consents.confirmation.enabled=false", + ) + } + } + + plugins { + robotServerPlugin() + } + } + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 639f41f..e0c8ebf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,23 +2,34 @@ pluginGroup=io.kanro.idea.plugin.protobuf pluginName=IntelliJ Protobuf Language Plugin pluginRepositoryUrl=https://github.com/devkanro/intellij-protobuf-plugin + # SemVer format -> https://semver.org -pluginVersion=2.0.1 +pluginVersion=2.0.2 + # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild=241 -pluginUntilBuild=242.* +pluginUntilBuild=243.* + # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension platformType=IU -platformVersion=2024.1 +platformVersion=2024.3.1.1 + # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html -# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 -platformPlugins=com.intellij.java, org.jetbrains.kotlin, org.intellij.plugins.markdown, org.jetbrains.plugins.go:241.14494.240, com.jetbrains.restClient:241.14494.150, com.intellij.grpc:241.14494.150 +# Example: platformPlugins = com.jetbrains.php:203.4449.22, org.intellij.scala:2023.3.27@EAP +platformPlugins=org.jetbrains.plugins.go:243.22562.218, com.jetbrains.restClient:243.23654.19, com.intellij.grpc:243.23654.44 +# Example: platformBundledPlugins = com.intellij.java +platformBundledPlugins=com.intellij.java, org.jetbrains.kotlin, org.intellij.plugins.markdown + # Gradle Releases -> https://github.com/gradle/gradle/releases -gradleVersion=8.7 +gradleVersion = 8.10.2 + # Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib -kotlin.stdlib.default.dependency=false +kotlin.stdlib.default.dependency = false + # Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html -org.gradle.configuration-cache=true +org.gradle.configuration-cache = true + # Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html -org.gradle.caching=true +org.gradle.caching = true + kotlin.daemon.jvmargs=-Xmx16G \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d4f195a..6d3672f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,22 +1,22 @@ [versions] # libraries -exampleLibrary = "24.1.0" +junit = "4.13.2" # plugins -kotlin = "2.0.0" changelog = "2.2.1" -gradleIntelliJPlugin = "1.17.4" -qodana = "2024.1.5" -kover = "0.8.2" +intelliJPlatform = "2.1.0" +kotlin = "2.1.0" +kover = "0.8.3" +qodana = "2024.2.3" grammarkit = "2022.3.2.2" [libraries] -exampleLibrary = { group = "com.example", name = "exampleLibrary", version.ref = "exampleLibrary" } +junit = { group = "junit", name = "junit", version.ref = "junit" } [plugins] changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } -gradleIntelliJPlugin = { id = "org.jetbrains.intellij", version.ref = "gradleIntelliJPlugin" } +intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "intelliJPlatform" } kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" } qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" } -grammarkit = { id = "org.jetbrains.grammarkit", version.ref = "grammarkit" } +grammarkit = { id = "org.jetbrains.grammarkit", version.ref = "grammarkit" } \ No newline at end of file diff --git a/src/main/kotlin/io/kanro/idea/plugin/protobuf/lang/reference/ProtobufSymbolReferenceContributor.kt b/src/main/kotlin/io/kanro/idea/plugin/protobuf/lang/reference/ProtobufSymbolReferenceContributor.kt deleted file mode 100644 index 14af4ed..0000000 --- a/src/main/kotlin/io/kanro/idea/plugin/protobuf/lang/reference/ProtobufSymbolReferenceContributor.kt +++ /dev/null @@ -1,43 +0,0 @@ -package io.kanro.idea.plugin.protobuf.lang.reference - -// -// class ProtobufSymbolReferenceContributor : PsiReferenceContributor() { -// override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) { -// registrar.registerReferenceProvider( -// PlatformPatterns.psiElement(ProtobufSymbolReferenceHost::class.java), -// ProtobufSymbolReferenceProvider, -// ) -// } -// } -// -// object ProtobufSymbolReferenceProvider : PsiReferenceProvider() { -// override fun getReferencesByElement( -// element: PsiElement, -// context: ProcessingContext, -// ): Array { -// element as ProtobufSymbolReferenceHost -// return CachedValuesManager.getCachedValue(element) { -// val hover = -// element.referencesHover() -// ?: return@getCachedValue CachedValueProvider.Result.create( -// PsiReference.EMPTY_ARRAY, -// PsiModificationTracker.MODIFICATION_COUNT, -// ) -// val symbol = hover.symbol() -// if (!hover.absolutely() && symbol.componentCount == 1 && BuiltInType.isBuiltInType(symbol.firstComponent!!)) { -// return@getCachedValue CachedValueProvider.Result.create( -// PsiReference.EMPTY_ARRAY, -// PsiModificationTracker.MODIFICATION_COUNT, -// ) -// } -// var reference: ProtobufTypeNameReference? = null -// val result = -// symbol.components.reversed().mapIndexed { index, name -> -// ProtobufTypeNameReference(element, hover, symbol.componentCount - 1 - index, reference).apply { -// reference = this -// } -// }.toTypedArray() -// CachedValueProvider.Result.create(result, PsiModificationTracker.MODIFICATION_COUNT) -// } -// } -// } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index f454219..563adae 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -130,9 +130,6 @@ instance="io.kanro.idea.plugin.protobuf.lang.settings.ProtobufSettingsConfigurable"/> -