diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e633dcf..930e937 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,12 @@ jobs: steps: - name: Checkout project sources uses: actions/checkout@v3 + # Set up Java environment for the next steps + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 17 - name: Setup Gradle uses: gradle/gradle-build-action@v2 - name: Run build with Gradle Wrapper diff --git a/README.md b/README.md index d802214..d9bbf3b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/kcl-lang/intellij-kcl/ci.yml) +[![JetBrains Plugin Version](https://img.shields.io/jetbrains/plugin/v/io.kusionstack.kcl)](https://plugins.jetbrains.com/plugin/23378-kcl) # KCL Plugin for IntelliJ IDEA @@ -31,8 +33,15 @@ This extension provides many coding assistance based on Language Server Protocol + **Code Action:** Quick fix for some errors + **InlayHint:** Hint for variable type, function and schema args +![image](./docs/img/preview.png) + + Other useful features such as diagnostics and testing are in developing. +## Requirements ++ Intellij IDEA 2023.2 or more recent ++ Java JDK (or JRE) 17 or more recent + ## Ask for help If the plugin isn't working as you expect, please reach out to us by filing an issue. diff --git a/build.gradle.kts b/build.gradle.kts index 6b37595..f37e4c2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,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.intelliJPlatformGradlePlugin) // IntelliJ Platform Gradle Plugin alias(libs.plugins.changelog) // Gradle Changelog Plugin alias(libs.plugins.qodana) // Gradle Qodana Plugin alias(libs.plugins.kover) // Gradle Kover Plugin @@ -21,60 +21,45 @@ version = properties("pluginVersion").get() // Configure project's dependencies repositories { mavenCentral() + intellijPlatform { + defaultRepositories() + } } // Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog dependencies { -// implementation(libs.annotations) -} -// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+. -kotlin { - jvmToolchain(17) -} + val type = properties("platformType") + val version = properties("platformVersion") + intellijPlatform { + create(type, version) -// 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") - updateSinceUntilBuild.set(false) + // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace. + plugins(providers.gradleProperty("platformPlugins").map { it.split(',') }) - // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. - plugins = properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) } -} + // Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins. + bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') }) -// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin -changelog { - groups.empty() - repositoryUrl = properties("pluginRepositoryUrl") -} + instrumentationTools() + } -// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin -qodana { - cachePath = provider { file(".qodana").canonicalPath } - reportPath = provider { file("build/reports/inspections").canonicalPath } - saveReport = true - showReport = environment("QODANA_SHOW_REPORT").map { it.toBoolean() }.getOrElse(false) -} -// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration -kover.xmlReport { - onCheck = true } -tasks { - wrapper { - gradleVersion = properties("gradleVersion").get() - } +// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+. +kotlin { + jvmToolchain(17) +} - patchPluginXml { - version = properties("pluginVersion") - sinceBuild = properties("pluginSinceBuild") - // untilBuild = properties("pluginUntilBuild") +// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html +intellijPlatform { + pluginConfiguration { + name = properties("pluginName") + version = properties("platformVersion") // Extract the section from README.md and provide for the plugin's manifest - pluginDescription = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { + + description = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { val start = "" val end = "" @@ -98,17 +83,41 @@ tasks { ) } } + + ideaVersion { + sinceBuild = providers.gradleProperty("pluginSinceBuild") + } } - // 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") +} + +// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin +changelog { + groups.empty() + repositoryUrl = properties("pluginRepositoryUrl") +} + +// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin +qodana { + cachePath = provider { file(".qodana").canonicalPath } + reportPath = provider { file("build/reports/inspections").canonicalPath } + saveReport = true + showReport = environment("QODANA_SHOW_REPORT").map { it.toBoolean() }.getOrElse(false) +} + +// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration +kover.xmlReport { + onCheck = true +} + +tasks { + wrapper { + gradleVersion = properties("gradleVersion").get() } + + // Configure UI tests plugin + signPlugin { certificateChain = environment("CERTIFICATE_CHAIN") privateKey = environment("PRIVATE_KEY") diff --git a/docs/img/preview.png b/docs/img/preview.png new file mode 100644 index 0000000..8dc5176 Binary files /dev/null and b/docs/img/preview.png differ diff --git a/gradle.properties b/gradle.properties index ee109bc..8120ef7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,10 +16,12 @@ platformVersion = 2023.3.3 # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html # Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 -platformPlugins = com.redhat.devtools.lsp4ij:0.4.0 +platformBundledPlugins = + +platformPlugins = com.redhat.devtools.lsp4ij:0.6.0 # Gradle Releases -> https://github.com/gradle/gradle/releases -gradleVersion = 8.1 +gradleVersion = 8.10.2 # Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib kotlin.stdlib.default.dependency = false diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5d529b2..8022e2f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,10 +3,10 @@ annotations = "24.0.1" # plugins -dokka = "1.8.10" +dokka = "1.9.24" kotlin = "1.8.20" changelog = "2.0.0" -gradleIntelliJPlugin = "1.15.0" +intelliJPlatformGradlePlugin = "2.1.0" qodana = "0.1.13" kover = "0.6.1" @@ -16,7 +16,7 @@ annotations = { group = "org.jetbrains", name = "annotations", version.ref = "an [plugins] changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } -gradleIntelliJPlugin = { id = "org.jetbrains.intellij", version.ref = "gradleIntelliJPlugin" } +intelliJPlatformGradlePlugin = { id = "org.jetbrains.intellij.platform", version.ref = "intelliJPlatformGradlePlugin" } 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" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0c85a1f..5c40527 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/test/kotlin/io/kusionstack/kcl/MyPluginTest.kt b/src/test/kotlin/io/kusionstack/kcl/MyPluginTest.kt deleted file mode 100644 index 3d61c9a..0000000 --- a/src/test/kotlin/io/kusionstack/kcl/MyPluginTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -package io.kusionstack.kcl - -import com.intellij.ide.highlighter.XmlFileType -import com.intellij.psi.xml.XmlFile -import com.intellij.testFramework.TestDataPath -import com.intellij.testFramework.fixtures.BasePlatformTestCase -import com.intellij.util.PsiErrorElementUtil - -@TestDataPath("\$CONTENT_ROOT/src/test/testData") -class MyPluginTest : BasePlatformTestCase() { - - fun testProjectService() { - assertNotSame(1, 2) - } - - override fun getTestDataPath() = "src/test/testData" -}