From 0fc2a80176ee04760037db6c8c7ed18e034a63b9 Mon Sep 17 00:00:00 2001 From: Nick Rayburn <52075362+nrayburn-tech@users.noreply.github.com> Date: Tue, 8 Oct 2024 22:54:28 -0500 Subject: [PATCH 1/3] Migrate to v2 of the intellij gradle plugin --- .github/workflows/build.yml | 42 +++---- .github/workflows/release.yml | 4 +- .github/workflows/run-ui-tests.yml | 6 +- .gitignore | 1 + .run/Run IDE for UI Tests.run.xml | 25 ---- .run/Run Qodana.run.xml | 30 ----- .run/Run Tests.run.xml | 1 + .run/Run Verifications.run.xml | 4 +- build.gradle.kts | 149 +++++++++++++++-------- gradle.properties | 5 +- gradle/libs.versions.toml | 14 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle.kts | 2 +- 13 files changed, 136 insertions(+), 149 deletions(-) delete mode 100644 .run/Run IDE for UI Tests.run.xml delete mode 100644 .run/Run Qodana.run.xml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 56df5dc..33d5fde 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,6 +20,10 @@ on: # Trigger the workflow on any pull request pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: # Prepare environment and build the plugin @@ -38,7 +42,7 @@ jobs: # Validate wrapper - name: Gradle Wrapper Validation - uses: gradle/wrapper-validation-action@v3.4.0 + uses: gradle/actions/wrapper-validation@v3 # Set up Java environment for the next steps - name: Setup Java @@ -49,9 +53,7 @@ jobs: # Setup Gradle - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - with: - gradle-home-cache-cleanup: true + uses: gradle/actions/setup-gradle@v4 # Set environment variables - name: Export Properties @@ -69,8 +71,6 @@ jobs: echo "$CHANGELOG" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - ./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier - # Build plugin - name: Build plugin run: ./gradlew buildPlugin @@ -88,7 +88,7 @@ jobs: # Store already-built plugin as an artifact for downloading - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ steps.artifact.outputs.filename }} path: ./build/distributions/content/*/* @@ -113,9 +113,7 @@ jobs: # Setup Gradle - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - with: - gradle-home-cache-cleanup: true + uses: gradle/actions/setup-gradle@v4 # Run tests - name: Run Tests @@ -124,7 +122,7 @@ jobs: # Collect Tests Result of failed tests - name: Collect Tests Result if: ${{ failure() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: tests-result path: ${{ github.workspace }}/build/reports/tests @@ -156,6 +154,9 @@ jobs: # Check out current repository - name: Fetch Sources uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit + fetch-depth: 0 # a full history is required for pull request analysis # Set up Java environment for the next steps - name: Setup Java @@ -166,7 +167,7 @@ jobs: # Run Qodana inspections - name: Qodana - Code Inspection - uses: JetBrains/qodana-action@v2024.1.5 + uses: JetBrains/qodana-action@v2024.2 with: cache-default-branch-only: true @@ -197,25 +198,23 @@ jobs: # Setup Gradle - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - with: - gradle-home-cache-cleanup: true + uses: gradle/actions/setup-gradle@v4 # Cache Plugin Verifier IDEs - name: Setup Plugin Verifier IDEs Cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }} # Run Verify Plugin task and IntelliJ Plugin Verifier tool - name: Run Plugin Verification tasks - run: ./gradlew runPluginVerifier -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }} + run: ./gradlew verifyPlugin -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }} # Collect Plugin Verifier Result - name: Collect Plugin Verifier Result if: ${{ always() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: pluginVerifier-result path: ${{ github.workspace }}/build/reports/pluginVerifier @@ -235,13 +234,6 @@ jobs: - name: Fetch Sources uses: actions/checkout@v4 - # Set up Java environment for the next steps - - name: Setup Java - uses: actions/setup-java@v4 - with: - distribution: zulu - java-version: 17 - # Remove old release drafts by using the curl request for the available releases with a draft flag - name: Remove Old Release Drafts env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0d48e56..767e7c0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,9 +33,7 @@ jobs: # Setup Gradle - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - with: - gradle-home-cache-cleanup: true + uses: gradle/actions/setup-gradle@v4 # Set environment variables - name: Export Properties diff --git a/.github/workflows/run-ui-tests.yml b/.github/workflows/run-ui-tests.yml index 05e483b..c924cb9 100644 --- a/.github/workflows/run-ui-tests.yml +++ b/.github/workflows/run-ui-tests.yml @@ -44,9 +44,7 @@ jobs: # Setup Gradle - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - with: - gradle-home-cache-cleanup: true + uses: gradle/actions/setup-gradle@v4 # Run IDEA prepared for UI testing - name: Run IDE @@ -54,7 +52,7 @@ jobs: # Wait for IDEA to be started - name: Health Check - uses: jtalk/url-health-check-action@v3 + uses: jtalk/url-health-check-action@v4 with: url: http://127.0.0.1:8082 max-attempts: 15 diff --git a/.gitignore b/.gitignore index e2e5d94..ffabde6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .gradle .idea +.intellijPlatform .qodana build diff --git a/.run/Run IDE for UI Tests.run.xml b/.run/Run IDE for UI Tests.run.xml deleted file mode 100644 index ee99b7e..0000000 --- a/.run/Run IDE for UI Tests.run.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - true - true - false - false - - - \ No newline at end of file diff --git a/.run/Run Qodana.run.xml b/.run/Run Qodana.run.xml deleted file mode 100644 index c92f33c..0000000 --- a/.run/Run Qodana.run.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - true - true - false - false - - - \ No newline at end of file diff --git a/.run/Run Tests.run.xml b/.run/Run Tests.run.xml index 132d9ad..f281bdc 100644 --- a/.run/Run Tests.run.xml +++ b/.run/Run Tests.run.xml @@ -19,6 +19,7 @@ true true false + true diff --git a/.run/Run Verifications.run.xml b/.run/Run Verifications.run.xml index 3a8d688..4d38797 100644 --- a/.run/Run Verifications.run.xml +++ b/.run/Run Verifications.run.xml @@ -11,7 +11,7 @@ - \ No newline at end of file + diff --git a/build.gradle.kts b/build.gradle.kts index 80b0b53..4842d71 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ import org.jetbrains.changelog.Changelog import org.jetbrains.changelog.markdownToHTML +import org.jetbrains.intellij.platform.gradle.TestFrameworkType fun properties(key: String) = providers.gradleProperty(key) fun environment(key: String) = providers.environmentVariable(key) @@ -7,9 +8,10 @@ fun environment(key: String) = providers.environmentVariable(key) plugins { id("java") // Java support alias(libs.plugins.kotlin) // Kotlin support - id("org.jetbrains.intellij") version "1.17.3" - + alias(libs.plugins.intelliJPlatform) // 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 } group = properties("pluginGroup").get() @@ -17,18 +19,35 @@ version = properties("pluginVersion").get() // Configure project's dependencies repositories { - maven(url = "https://maven.aliyun.com/repository/central") - maven(url = "https://maven.aliyun.com/repository/public") - maven(url = "https://maven.aliyun.com/repository/gradle-plugin") - maven(url = "https://maven.aliyun.com/repository/gradle-core") + 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 are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog dependencies { -// implementation(libs.annotations) + testImplementation(libs.junit) + + // IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html + intellijPlatform { + create(properties("platformType"), properties("platformVersion")) + + // Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins. + bundledPlugins(properties("platformBundledPlugins").map { it.split(',') }) + + // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace. + plugins(properties("platformPlugins").map { it.split(',') }) + + instrumentationTools() + pluginVerifier() + zipSigner() + testFramework(TestFrameworkType.Platform) + } } -// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+. kotlin { @Suppress("UnstableApiUsage") jvmToolchain { @@ -37,41 +56,20 @@ 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") - - // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. - plugins = properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) } -} - -// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin -changelog { - groups.empty() - repositoryUrl = properties("pluginRepositoryUrl") -} - - -tasks { - wrapper { - gradleVersion = properties("gradleVersion").get() - } - - patchPluginXml { +// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html +intellijPlatform { + pluginConfiguration { 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 { + description = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { val start = "" val end = "" - with (it.lines()) { + with(it.lines()) { if (!containsAll(listOf(start, end))) { - throw GradleException("Plugin description section not found in README.md:\n$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) } @@ -82,33 +80,86 @@ tasks { changeNotes = properties("pluginVersion").map { pluginVersion -> with(changelog) { renderItem( - (getOrNull(pluginVersion) ?: getUnreleased()) - .withHeader(false) + (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") + ideaVersion { + sinceBuild = properties("pluginSinceBuild") + untilBuild = properties("pluginUntilBuild") + } } - signPlugin { + signing { certificateChain = environment("CERTIFICATE_CHAIN") privateKey = environment("PRIVATE_KEY") password = environment("PRIVATE_KEY_PASSWORD") } - publishPlugin { - dependsOn("patchChangelog") + publishing { token = environment("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 = properties("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") +} + +// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration +kover { + reports { + total { + xml { + onCheck = true + } + } + } +} + +tasks { + wrapper { + gradleVersion = properties("gradleVersion").get() + } + + publishPlugin { + dependsOn(patchChangelog) + } +} + +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() + } + } } } diff --git a/gradle.properties b/gradle.properties index 63319bc..4fd32de 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,9 +17,11 @@ platformVersion = 2023.3.2 # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html # Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 platformPlugins = +# Example: platformBundledPlugins = com.intellij.java +platformBundledPlugins = # Gradle Releases -> https://github.com/gradle/gradle/releases -gradleVersion = 8.5 +gradleVersion = 8.10.2 # Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib kotlin.stdlib.default.dependency = false @@ -32,4 +34,3 @@ org.gradle.caching = true # Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment systemProp.org.gradle.unsafe.kotlin.assignment = true - diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2721513..4c2f43f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,20 +1,20 @@ [versions] # libraries -annotations = "24.1.0" +junit = "4.13.2" # plugins -kotlin = "1.9.24" changelog = "2.2.1" -gradleIntelliJPlugin = "1.17.3" -qodana = "0.1.13" -kover = "0.8.1" +intelliJPlatform = "2.1.0" +kotlin = "1.9.25" +kover = "0.8.3" +qodana = "2024.2.3" [libraries] -annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" } +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" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1af9e09..df97d72 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.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle.kts b/settings.gradle.kts index 57313d0..3d0963d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0" + id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" } rootProject.name = "oxc-intellij-plugin" From 8aa028feced20c91f653969f4e931d88fe128ce5 Mon Sep 17 00:00:00 2001 From: Nick Rayburn <52075362+nrayburn-tech@users.noreply.github.com> Date: Wed, 9 Oct 2024 00:25:43 -0500 Subject: [PATCH 2/3] Change plugin name --- src/main/resources/META-INF/plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 7eacde8..2ccc6ed 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -1,7 +1,7 @@ com.github.iwanabethatguy.oxcintellijplugin - oxc-intellij-plugin + Oxc iwanabethatguy com.intellij.modules.ultimate From 6acaa940d9ad0a4e6c31dda3bed9a7879284edc2 Mon Sep 17 00:00:00 2001 From: Nick Rayburn <52075362+nrayburn-tech@users.noreply.github.com> Date: Wed, 9 Oct 2024 00:25:58 -0500 Subject: [PATCH 3/3] Update plugin compatible versions --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 4fd32de..ec90ce7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,8 +7,8 @@ pluginRepositoryUrl = https://github.com/IWANABETHATGUY/oxc-intellij-plugin pluginVersion = 0.0.1 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html -pluginSinceBuild = 223 -pluginUntilBuild = 233.* +pluginSinceBuild = 233 +pluginUntilBuild = 242.* # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension platformType = IU