diff --git a/.gitignore b/.gitignore index 1e05f3d3..3649d728 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ build/ venv/ tmp/ + +# IntelliJ Platform Gradle Plugin +.intellijPlatform/ diff --git a/build.gradle.kts b/build.gradle.kts index e9c4c0e7..fe319cfb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,17 +2,36 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.KotlinVersion import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -fun config(name: String) = project.findProperty(name).toString() - -val ideaVersion = config("ideaVersion") - repositories { mavenCentral() + intellijPlatform { + defaultRepositories() + } } +val pluginName = "intellij-micropython" + plugins { kotlin("jvm") version "1.9.25" - id("org.jetbrains.intellij") version "1.17.4" + id("org.jetbrains.intellij.platform") version "2.0.1" +} + +dependencies { + intellijPlatform { + val type = project.property("platformType").toString() + val version = project.property("platformVersion").toString() + val pythonPlugin = project.property("pythonPlugin").toString() + + create(type, version, useInstaller = false) + + bundledPlugin("org.jetbrains.plugins.terminal") + + when (type) { + "PC" -> bundledPlugin("PythonCore") + "PY" -> bundledPlugin("Pythonid") + else -> plugin(pythonPlugin) + } + } } java { @@ -20,19 +39,15 @@ java { targetCompatibility = JavaVersion.VERSION_17 } -intellij { - version = ideaVersion - pluginName = "intellij-micropython" - updateSinceUntilBuild = false +intellijPlatform { + pluginConfiguration { + name = pluginName + } + instrumentCode = false - plugins.add("terminal") - if (ideaVersion.contains("PC")) { - plugins.add("python-ce") - } else if (ideaVersion.contains("PY")) { - plugins.add("python") - } else { - plugins.add(config("pythonPlugin")) + publishing { + token = project.property("publishToken").toString() } } @@ -44,27 +59,11 @@ tasks { apiVersion = KotlinVersion.KOTLIN_1_9 } } - val copyStubs = register("copyStubs") { - dependsOn("prepareSandbox") - from(projectDir) { + prepareSandbox { + from("$rootDir") { + into(pluginName) include("typehints/") include("scripts/") } - into("${intellij.sandboxDir.get()}/plugins/intellij-micropython") - } - buildSearchableOptions { - dependsOn(copyStubs) - } - buildPlugin { - dependsOn(copyStubs) - } - verifyPlugin { - dependsOn(copyStubs) - } - runIde { - dependsOn(copyStubs) - } - publishPlugin { - token = config("publishToken") } } diff --git a/gradle.properties b/gradle.properties index 92289d69..e876d84c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,6 @@ version=1.4.5-2024.1 -ideaVersion=PC-241-EAP-SNAPSHOT +platformType=PC +platformVersion=241-EAP-SNAPSHOT pythonPlugin=PythonCore:241.18034.55 publishToken=token