From 525d9bc596e50a58ab1064c6fbacc19d9427e429 Mon Sep 17 00:00:00 2001 From: Jezz Santos Date: Sat, 19 Oct 2024 11:38:54 +1300 Subject: [PATCH] Migrated to kotlin gradle --- .idea/kotlinc.xml | 6 + build.gradle | 134 --------------- build.gradle.kts | 157 ++++++++++++++++++ gradle.properties | 5 +- gradle/libs.versions.toml | 12 ++ gradle/wrapper/gradle-wrapper.properties | 4 +- settings.gradle | 20 --- settings.gradle.kts | 25 +++ .../ui/toolwindows/AutomateToolWindow.java | 16 +- 9 files changed, 215 insertions(+), 164 deletions(-) create mode 100644 .idea/kotlinc.xml delete mode 100644 build.gradle create mode 100644 build.gradle.kts create mode 100644 gradle/libs.versions.toml delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..4cb7457 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 31351b8..0000000 --- a/build.gradle +++ /dev/null @@ -1,134 +0,0 @@ -import org.gradle.api.tasks.testing.logging.TestExceptionFormat -import org.jetbrains.changelog.Changelog -import org.jetbrains.intellij.platform.gradle.TestFrameworkType - -import java.text.SimpleDateFormat - -plugins { - id 'java' - id 'org.jetbrains.intellij.platform' version "${intellijPluginVersion}" - id 'org.jetbrains.changelog' version '2.0.0' - id 'me.filippov.gradle.jvm.wrapper' version '0.14.0' -} - -apply plugin: 'org.jetbrains.changelog' - -group "${thisPluginGroup}" -version "${thisPluginVersion}" - -java { - sourceCompatibility = JavaVersion.VERSION_17 -} - -repositories { - maven { setUrl("https://cache-redirector.jetbrains.com/maven-central") } - - intellijPlatform { - defaultRepositories() - } -} - -dependencies { - implementation 'com.google.code.gson:gson:2.10' - // HACK: we need to stay on this older version of AppInsights for as long as possible - //noinspection GradlePackageUpdate - implementation 'com.microsoft.azure:applicationinsights-core:2.6.4' - - intellijPlatform { - def version = providers.gradleProperty("platformVersion").get() - rider(version) - pluginVerifier() - zipSigner() - instrumentationTools() - - testFramework TestFrameworkType.Bundled.INSTANCE - } - - testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0' - testImplementation 'org.mockito:mockito-core:4.8.0' - testImplementation 'org.testng:testng:7.7.0' - testRuntimeOnly 'org.junit.support:testng-engine:1.0.4' -} - -intellijPlatform { - instrumentCode = true - pluginConfiguration { - version "${thisPluginVersion}" - ideaVersion { - sinceBuild = "${pluginSinceBuild}" - untilBuild = "${pluginUntilBuild}" - } - } - pluginVerification { - ides { - recommended() - } - } -} - -changelog { - version = "${thisPluginVersion}" - path = "${project.projectDir}/CHANGELOG.md" - header = "[${-> version.get()}] - ${new SimpleDateFormat("yyyy-MM-dd").format(new Date())}" - headerParserRegex = ~/(\d+\.\d+\.\d+[\-\w]*)/ - introduction = """ - All notable changes to this project are documented in this file. - -> The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - """.stripIndent() - itemPrefix = "-" - keepUnreleasedSection = true - unreleasedTerm = "[Unreleased]" - groups = ["Notes", "Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"] - lineSeparator = "\n" - combinePreReleases = true -} - -tasks { - wrapper { - gradleVersion = "${gradleVersion}" - } - - publishPlugin { - token.set(System.getenv("ORG_GRADLE_PROJECT_intellijPublishToken")) - channels.set(List.of(("${thisPluginVersion}".split("-").length > 1) ? "${thisPluginVersion}".split("-")[1] : "default")) - var versionExists = changelog.has("${thisPluginVersion}") - if (versionExists) { - patchPluginXml.changeNotes.set(changelog.renderItem( - changelog - .get("${thisPluginVersion}") - .withHeader(false) - .withEmptySections(false), - Changelog.OutputType.HTML - )) - } - } - - patchPluginXml { - changeNotes.set(changelog.renderItem( - changelog - .getUnreleased() - .withHeader(false) - .withEmptySections(false), - Changelog.OutputType.HTML - )) - } - - test { - systemProperty "LOCAL_ENV_RUN", "true" //For use with 'BaseTestWithSolution' and TestNG - useJUnitPlatform() - minHeapSize = "512m" - maxHeapSize = "1024m" - testLogging { - showStandardStreams = true - exceptionFormat = TestExceptionFormat.FULL - } - } - - runIde { - autoReload = false - maxHeapSize = "2G" - } -} - diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..c1b0e76 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,157 @@ +import org.gradle.api.tasks.testing.logging.TestExceptionFormat +import org.jetbrains.changelog.Changelog +import org.jetbrains.changelog.date +import org.jetbrains.intellij.platform.gradle.TestFrameworkType + +plugins { + + id("java") + alias(libs.plugins.kotlin) + id("org.jetbrains.intellij.platform") + alias(libs.plugins.changelog) + alias(libs.plugins.jvmwrapper) +} + +group = providers.gradleProperty("thisPluginGroup").get() +version = providers.gradleProperty("thisPluginVersion").get() + +// Set the JVM language level used to build the project. +kotlin { + jvmToolchain(17) +} + +repositories { + maven { setUrl("https://cache-redirector.jetbrains.com/maven-central") } + + intellijPlatform { + defaultRepositories() + jetbrainsRuntime() + } +} + +dependencies { + implementation("com.google.code.gson:gson:2.10") + //noinspection GradlePackageUpdate + implementation("com.microsoft.azure:applicationinsights-core:2.6.4") // HACK: we need to stay on this older version of AppInsights for as long as possible + + intellijPlatform { + val platformVer: String = providers.gradleProperty("platformVersion").get() + rider(platformVer) + jetbrainsRuntime() + pluginVerifier() + zipSigner() + instrumentationTools() + + testFramework(TestFrameworkType.Bundled) + } +} + +intellijPlatform { + instrumentCode = true + pluginConfiguration { + val plugInVer: String = providers.gradleProperty("thisPluginVersion").get() + version = plugInVer + ideaVersion { + sinceBuild = providers.gradleProperty("pluginSinceBuild") + untilBuild = providers.gradleProperty("pluginUntilBuild") + } + } + pluginVerification { + ides { + recommended() + } + } +} + +changelog { + val plugInVer: String = providers.gradleProperty("thisPluginVersion").get() + version.set(plugInVer) + path.set(file("CHANGELOG.md").canonicalPath) + header.set(provider { "[${version.get()}] - ${date("yyyy-MM-dd")}" }) + headerParserRegex.set("""(\d+\.\d+\.\d+[\-\w]*)""".toRegex()) + introduction.set( + """ + All notable changes to this project are documented in this file. + +> The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + """.trimIndent() + ) + itemPrefix.set("-") + keepUnreleasedSection.set(true) + unreleasedTerm.set("[Unreleased]") + groups.set(listOf("Notes", "Added", "Changed", "Deprecated", "Removed", "Fixed", "Security")) + lineSeparator.set("\n") + combinePreReleases.set(true) +} + +tasks { + + wrapper { + val gradleVer: String = providers.gradleProperty("gradleVersion").get() + gradleVersion = gradleVer + } + + publishPlugin { + dependsOn("patchChangelog") + val plugInVer: String = providers.gradleProperty("thisPluginVersion").get() + val items: String = if (plugInVer.split("-").size > 1) + plugInVer.split("-")[1] + else + "default" + token.set(System.getenv("ORG_GRADLE_PROJECT_intellijPublishToken")) + channels.set(listOf(items)) + } + + patchPluginXml { + val plugInVer: String = providers.gradleProperty("thisPluginVersion").get() + val versionExists = changelog.has(plugInVer) + if (versionExists) { + changeNotes.set(provider { + changelog.renderItem( + changelog + .get(plugInVer) + .withHeader(false) + .withEmptySections(false), + Changelog.OutputType.HTML + ) + } + ) + } else { + changeNotes.set(provider { + changelog.renderItem( + changelog + .getUnreleased() + .withHeader(false) + .withEmptySections(false), + Changelog.OutputType.HTML + ) + } + ) + } + } + + test { + dependencies { + testImplementation("org.junit.jupiter:junit-jupiter:5.9.0") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.0") + testImplementation("org.mockito:mockito-core:4.8.0") + testImplementation("org.testng:testng:7.7.0") + testRuntimeOnly("org.junit.support:testng-engine:1.0.4") + } + + systemProperty("LOCAL_ENV_RUN", "true") //For use with 'BaseTestWithSolution' and TestNG + useJUnitPlatform() + minHeapSize = "512m" + maxHeapSize = "1024m" + testLogging { + showStandardStreams = true + exceptionFormat = TestExceptionFormat.FULL + } + } + + runIde { + autoReload = false + maxHeapSize = "2G" + } +} + diff --git a/gradle.properties b/gradle.properties index 3a0a712..d7d4169 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,4 +11,7 @@ intellijPluginVersion=2.1.0 # Gradle Releases -> https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html#requirements gradleVersion=8.10.2 # Other properties -> https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-gradle-properties.html -org.jetbrains.intellij.platform.downloadSources=false \ No newline at end of file +org.jetbrains.intellij.platform.downloadSources=false +# Kotlin 1.4 will bundle the stdlib dependency by default, causing problems with the version bundled with the IDE +# https://blog.jetbrains.com/kotlin/2020/07/kotlin-1-4-rc-released/#stdlib-default +kotlin.stdlib.default.dependency=false \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..3b42a50 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,12 @@ +[versions] +kotlin = "1.9.25" # https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library +changelog = "2.2.1" +jvmwrapper = "0.14.0" + +[libraries] +kotlin = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" } + +[plugins] +changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } +kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +jvmwrapper = { id = "me.filippov.gradle.jvm.wrapper", version.ref = "jvmwrapper" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 15de902..ed4eae9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionUrl=https\://cache-redirector.jetbrains.com/services.gradle.org/distributions/gradle-8.10.2-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index e39d199..0000000 --- a/settings.gradle +++ /dev/null @@ -1,20 +0,0 @@ -pluginManagement { - repositories { - maven { url "https://cache-redirector.jetbrains.com/plugins.gradle.org" } - } - resolutionStrategy { - eachPlugin { - // Gradle maps a plugin dependency to Maven coordinates: - // '{plugin.id}:{plugin.id}.gradle.plugin:version' -> '{groupId}:{artifactId}:{version}' - // HACK: Mapping does not work for: 'com.jetbrains.rdgen - if (requested.id.id == "com.jetbrains.rdgen") { - useModule("com.jetbrains.rd:rd-gen:${requested.version}") - } - } - } -} - -rootProject.name = 'automate' - - - diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..d71d334 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,25 @@ +pluginManagement { + val intellijPluginVersion: String by settings + + plugins { + id("org.jetbrains.intellij.platform").version(intellijPluginVersion) // so that we can read the version from gradle.properties + } + + repositories { + maven { setUrl("https://cache-redirector.jetbrains.com/plugins.gradle.org") } + + } + + resolutionStrategy { + eachPlugin { + // Gradle has to map a plugin dependency to Maven coordinates - '{groupId}:{artifactId}:{version}'. It tries + // to do use '{plugin.id}:{plugin.id}.gradle.plugin:version'. + // This doesn't work for rdgen, so we provide some help + if (requested.id.id == "com.jetbrains.rdgen") { + useModule("com.jetbrains.rd:rd-gen:${requested.version}") + } + } + } +} + +rootProject.name = "automate" \ No newline at end of file diff --git a/src/main/java/jezzsantos/automate/plugin/infrastructure/ui/toolwindows/AutomateToolWindow.java b/src/main/java/jezzsantos/automate/plugin/infrastructure/ui/toolwindows/AutomateToolWindow.java index efa4a50..39a1d93 100644 --- a/src/main/java/jezzsantos/automate/plugin/infrastructure/ui/toolwindows/AutomateToolWindow.java +++ b/src/main/java/jezzsantos/automate/plugin/infrastructure/ui/toolwindows/AutomateToolWindow.java @@ -2,7 +2,7 @@ import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.ActionPlaces; -import com.intellij.openapi.actionSystem.ActionToolbar; +import com.intellij.openapi.actionSystem.toolbarLayout.ToolbarLayoutStrategy; import com.intellij.openapi.project.Project; import com.intellij.openapi.wm.ToolWindow; import com.jetbrains.rider.settings.codeCleanup.TreeActionsGroup; @@ -43,12 +43,6 @@ public AutomateToolWindow(@NotNull Project project, @NotNull ToolWindow toolwind this.init(); } - @NotNull - public JPanel getContent() { - - return this.mainPanel; - } - @Override public void dispose() { @@ -61,12 +55,18 @@ public void dispose() { } } + @NotNull + public JPanel getContent() { + + return this.mainPanel; + } + private void createUIComponents() { this.tree = new AutomateTree(this.project); this.toolbar = new AutomateToolbar(this.project, this.tree, ActionPlaces.TOOLWINDOW_CONTENT, true); this.toolbar.setTargetComponent(this.mainPanel); - this.toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY); + this.toolbar.setLayoutStrategy(ToolbarLayoutStrategy.NOWRAP_STRATEGY); this.cliLogsPane = new CliLogsPane(this.project); }