From baca7bbd9e230c200d0b2c418a6066ce84702bb7 Mon Sep 17 00:00:00 2001 From: Chris Carini <6374067+ChrisCarini@users.noreply.github.com> Date: Tue, 20 Aug 2024 04:52:20 -0700 Subject: [PATCH] Upgrading IntelliJ from 2024.1.5 to 2024.2.0 (#323) --- .github/workflows/build.yml | 14 +- .github/workflows/compatibility.yml | 4 +- .github/workflows/release.yml | 6 +- .gitignore | 6 +- CHANGELOG.md | 2 + build.gradle | 6 - build.gradle.kts | 3 + buildSrc/build.gradle.kts | 17 + ...standard-jetbrains-plugin-build.gradle.kts | 342 ++++++++++++++++++ build_standard_jetbrains_plugin_build.gradle | 268 -------------- gradle.properties | 47 ++- settings.gradle | 2 - settings.gradle.kts | 2 + 13 files changed, 414 insertions(+), 305 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/src/main/kotlin/build-standard-jetbrains-plugin-build.gradle.kts delete mode 100644 build_standard_jetbrains_plugin_build.gradle delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bce7bca..1850cbf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,13 +54,13 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 timeout-minutes: 1 - # Setup Java 17 environment for the next steps - - name: Setup Java 17 + # Setup Java environment for the next steps + - name: Setup Java uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 timeout-minutes: 5 with: distribution: zulu - java-version: 17 + java-version: 21 cache: gradle # Set environment variables @@ -97,7 +97,7 @@ jobs: # Run IntelliJ Plugin Verifier action using GitHub Action - name: Run Plugin Verifier - run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }} + run: ./gradlew verifyPlugin -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }} # Build plugin with buildPlugin Gradle task and provide the artifact for the next workflow jobs # Requires test job to be passed @@ -117,13 +117,13 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 timeout-minutes: 1 - # Setup Java 17 environment for the next steps - - name: Setup Java 17 + # Setup Java environment for the next steps + - name: Setup Java uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 timeout-minutes: 5 with: distribution: zulu - java-version: 17 + java-version: 21 cache: gradle # Set environment variables diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml index fec68ef..8e6e93b 100644 --- a/.github/workflows/compatibility.yml +++ b/.github/workflows/compatibility.yml @@ -28,11 +28,11 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 timeout-minutes: 1 - - name: Setup Java 17 + - name: Setup Java uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 timeout-minutes: 5 with: - java-version: 17 + java-version: 21 distribution: 'zulu' cache: gradle diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 23050e1..b58f18a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,13 +22,13 @@ jobs: with: ref: ${{ github.event.release.tag_name }} - # Setup Java 17 environment for the next steps - - name: Setup Java 17 + # Setup Java environment for the next steps + - name: Setup Java uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 timeout-minutes: 5 with: distribution: zulu - java-version: 17 + java-version: 21 cache: gradle # Set environment variables diff --git a/.gitignore b/.gitignore index 8fdc3fa..26f4537 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.iws .gradle/ .qodana/ +.shelf/ build/ gradle/ out/ @@ -10,4 +11,7 @@ gradlew* jetbrainsCredentials.gradle private.pem chain.crt -*.DS_Store \ No newline at end of file +*.DS_Store +.idea/ +.installedPlugins/ +.intellijPlatform/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a34dd3..6bcf82c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ### Added ### Changed +- Upgrading IntelliJ from 2024.1.5 to 2024.2.0 +- Changed gradle build to Kotlin DSL (from Groovy DSL) in preparation of `IntelliJ Platform Gradle Plugin 2.0.0`. ### Deprecated diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 0823553..0000000 --- a/build.gradle +++ /dev/null @@ -1,6 +0,0 @@ -apply from: 'build_standard_jetbrains_plugin_build.gradle' - -// Configure CHANGELOG.md - https://github.com/JetBrains/gradle-changelog-plugin -changelog { - repositoryUrl = "https://github.com/ChrisCarini/git-push-reminder-jetbrains-plugin" -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..6daad4c --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,3 @@ +plugins { + id("build-standard-jetbrains-plugin-build") +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..d31b2f2 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + `kotlin-dsl` +} + +repositories { + mavenCentral() + maven { + url = uri("https://plugins.gradle.org/m2/") + } +} + +dependencies { + implementation("org.jetbrains.intellij.platform:intellij-platform-gradle-plugin:2.0.1") + implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:2.2.1") + implementation("com.dorongold.plugins:task-tree:4.0.0") // provides `taskTree` task (e.g. `./gradlew build taskTree`; docs: https://github.com/dorongold/gradle-task-tree) +} + diff --git a/buildSrc/src/main/kotlin/build-standard-jetbrains-plugin-build.gradle.kts b/buildSrc/src/main/kotlin/build-standard-jetbrains-plugin-build.gradle.kts new file mode 100644 index 0000000..a75270a --- /dev/null +++ b/buildSrc/src/main/kotlin/build-standard-jetbrains-plugin-build.gradle.kts @@ -0,0 +1,342 @@ +import org.gradle.plugins.ide.idea.model.IdeaLanguageLevel +import org.jetbrains.changelog.Changelog +import org.jetbrains.changelog.markdownToHTML +import org.jetbrains.intellij.platform.gradle.Constants +import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType +import org.jetbrains.intellij.platform.gradle.TestFrameworkType +import org.jetbrains.intellij.platform.gradle.models.ProductRelease +import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask +import java.util.EnumSet + +fun properties(key: String): String = providers.gradleProperty(key).get() +fun environment(key: String): Provider = providers.environmentVariable(key) +fun extra(key: String): String = project.ext.get(key) as String + +val javaVersion = properties("javaVersion") +val platformBundledPlugins = providers.gradleProperty("platformBundledPlugins") +val platformPlugins = providers.gradleProperty("platformPlugins") +val platformType = properties("platformType") +val platformVersion = properties("platformVersion") +val pluginGroup = properties("pluginGroup") +val pluginName = properties("pluginName") +val pluginRepositoryUrl = properties("pluginRepositoryUrl") +val pluginSinceBuild = properties("pluginSinceBuild") +val pluginUntilBuild = properties("pluginUntilBuild") +val pluginVerifierExcludeFailureLevels = properties("pluginVerifierExcludeFailureLevels") +val pluginVerifierIdeVersions = properties("pluginVerifierIdeVersions") +val pluginVerifierMutePluginProblems = properties("pluginVerifierMutePluginProblems") +val pluginVersion = properties("pluginVersion") +val shouldPublishPlugin = properties("publishPlugin").equals("true") + +plugins { + id("java") + id("idea") + id("org.jetbrains.intellij.platform") + id("org.jetbrains.changelog") + id("com.dorongold.task-tree") +} + +group = pluginGroup +version = pluginVersion + +repositories { + mavenCentral() + + // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html + intellijPlatform { + defaultRepositories() + // `jetbrainsRuntime()` is necessary mostly for EAP/SNAPSHOT releases of IJ so that the IDE pulls the correct JBR + // - https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-jetbrains-runtime.html#obtained-with-intellij-platform-from-maven + val isSnapshot = platformVersion.endsWith("-SNAPSHOT") + if (isSnapshot) { + jetbrainsRuntime() + } + } +} + + +dependencies { + // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html + intellijPlatform { + val isSnapshot = platformVersion.endsWith("-SNAPSHOT") + create( + type = IntelliJPlatformType.fromCode(platformType), + version = platformVersion, + useInstaller = !isSnapshot + ) + + // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace. + plugins(platformPlugins.map { it.split(',') }) + // Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins. + bundledPlugins(platformBundledPlugins.map { it.split(',') }) + + instrumentationTools() + + // `jetbrainsRuntime()` is necessary mostly for EAP/SNAPSHOT releases of IJ so that the IDE pulls the correct JBR + // - https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-jetbrains-runtime.html#obtained-with-intellij-platform-from-maven + if (isSnapshot) { + jetbrainsRuntime() + } + pluginVerifier() + zipSigner() + testFramework(TestFrameworkType.Platform) + } + + testImplementation(group = "junit", name = "junit", version = "4.13.2") + testImplementation("org.testng:testng:7.10.2") + testImplementation("org.mockito:mockito-core:5.12.0") +} + +java { + sourceCompatibility = JavaVersion.toVersion(javaVersion) + targetCompatibility = JavaVersion.toVersion(javaVersion) +} + +idea { + project { + // Set default IntelliJ SDK & language level to the version specified in `gradle.properties` + jdkName = javaVersion + languageLevel = IdeaLanguageLevel(javaVersion) + } +} + +val isNotCI = System.getenv("CI") != "true" +if (isNotCI) { + // The below file (jetbrainsCredentials.gradle) should contain the below: + // project.ext.set("intellijSignPluginCertificateChain", new File("./chain.crt").getText("UTF-8")) + // project.ext.set("intellijSignPluginPrivateKey", new File("./private.pem").getText("UTF-8")) + // project.ext.set("intellijSignPluginPassword", "YOUR_PRIV_KEY_PASSWORD_HERE") + // project.ext.set("intellijPluginPublishToken", "YOUR_TOKEN_HERE") + // + // Because this contains credentials, this file is also included in .gitignore file. + apply(from = "jetbrainsCredentials.gradle") +} +fun resolve(extraKey: String, environmentKey: String): String = + if (isNotCI) extra(extraKey) else environment(environmentKey).getOrElse("DEFAULT_INVALID_$environmentKey") + +val signPluginCertificateChain = resolve("intellijSignPluginCertificateChain", "CERTIFICATE_CHAIN") +val signPluginPrivateKey = resolve("intellijSignPluginPrivateKey", "PRIVATE_KEY") +val signPluginPassword = resolve("intellijSignPluginPassword", "PRIVATE_KEY_PASSWORD") +val publishPluginToken = resolve("intellijPluginPublishToken", "PUBLISH_TOKEN") + +// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html +intellijPlatform { + pluginConfiguration { + name = pluginName + version = 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) + } + } + + val changelog = project.changelog // local variable for configuration cache compatibility + // Get the latest available change notes from the changelog file + changeNotes = providers.provider { pluginVersion }.map { pluginVersion -> + with(changelog) { + renderItem( + (getOrNull(pluginVersion) ?: getUnreleased()).withHeader(false).withEmptySections(false), + Changelog.OutputType.HTML, + ) + } + } + + ideaVersion { + sinceBuild = pluginSinceBuild + untilBuild = pluginUntilBuild + } + + // Vendor information -> https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-pluginConfiguration-vendor + vendor { + name = "Chris Carini" + email = "jetbrains@chriscarini.com" + url = "https://jetbrains.chriscarini.com" + } + } + + signing { + certificateChain = signPluginCertificateChain + privateKey = signPluginPrivateKey + password = signPluginPassword + } + + publishing { + token = publishPluginToken + + // 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/publishing-plugin.html#specifying-a-release-channel + channels = providers.provider { pluginVersion }.map { + listOf(it.substringAfter('-', "").substringBefore('.').lowercase().ifEmpty { "default" }) + } + } + + pluginVerification { + val pluginVerifierMutePluginProblems = pluginVerifierMutePluginProblems + if (pluginVerifierMutePluginProblems.isNotEmpty()) { + logger.lifecycle("Muting the following Plugin Verifier Problems: $pluginVerifierMutePluginProblems") + freeArgs = listOf("-mute", pluginVerifierMutePluginProblems) + } + + fun getFailureLevels(): EnumSet { + val includeFailureLevels = EnumSet.allOf(VerifyPluginTask.FailureLevel::class.java) + val desiredFailureLevels = + pluginVerifierExcludeFailureLevels.split(",").map(String::trim) + .filter(String::isNotEmpty) // Remove empty strings; this happens when user sets nothing (ie, `pluginVerifierExcludeFailureLevels =`) + + desiredFailureLevels.forEach { failureLevel -> + when (failureLevel) { + "ALL" -> return EnumSet.allOf(VerifyPluginTask.FailureLevel::class.java) + "NONE" -> return EnumSet.noneOf(VerifyPluginTask.FailureLevel::class.java) + else -> { + try { + val enumFailureLevel = VerifyPluginTask.FailureLevel.valueOf(failureLevel) + includeFailureLevels.remove(enumFailureLevel) + } catch (ignored: Exception) { + val msg = "Failure Level \"$failureLevel\" is *NOT* valid. Please select from: ${ + EnumSet.allOf(VerifyPluginTask.FailureLevel::class.java) + }." + logger.error(msg) + throw Exception(msg) + } + } + } + } + + return includeFailureLevels + } + + val failureLevels = getFailureLevels() + logger.debug("Using ${failureLevels.size} Failure Levels: $failureLevels") + failureLevel.set(failureLevels) + ides { + logger.lifecycle("Verifying against IntelliJ Platform $platformType $platformVersion") + ide(IntelliJPlatformType.fromCode(platformType), platformVersion) + + recommended() + } + } +} + +// Configure CHANGELOG.md - https://github.com/JetBrains/gradle-changelog-plugin +changelog { + repositoryUrl = pluginRepositoryUrl +} + +tasks { + publishPlugin { + dependsOn(patchChangelog) + enabled = shouldPublishPlugin && providers.provider { pluginRepositoryUrl }.getOrElse("false") == "true" + } + + printProductsReleases { +// // In addition to `IC` (from `platformType`), we also want to verify against `IU`. +// types.set(Arrays.asList(platformType, "IU")) + // Contrary to above, we want to speed up CI, so skip verification of `IU`. + types = listOf(IntelliJPlatformType.fromCode(platformType)) + + // Only get the released versions if we are not targeting an EAP. + val isEAP = pluginVersion.uppercase().endsWith("-EAP") + channels = listOf(if (isEAP) ProductRelease.Channel.EAP else ProductRelease.Channel.RELEASE) + + // Verify against the most recent patch release of the `platformVersion` version + // (ie, if `platformVersion` = 2022.2, and the latest patch release is `2022.2.2`, + // then the `sinceVersion` will be set to `2022.2.2` and *NOT* `2022.2`. + sinceBuild.set(platformVersion) + } + + // Sanity check task to ensure necessary variables are set. + register("checkJetBrainsSecrets") { + doLast { + println("signPluginCertificateChain: ${if (signPluginCertificateChain.isNotEmpty()) "IS" else "is NOT"} set.") + println("signPluginPrivateKey: ${if (signPluginPrivateKey.isNotEmpty()) "IS" else "is NOT"} set.") + println("signPluginPassword: ${if (signPluginPassword.isNotEmpty()) "IS" else "is NOT"} set.") + println("publishPluginToken: ${if (publishPluginToken.isNotEmpty()) "IS" else "is NOT"} set.") + } + } + + // In "IntelliJ Platform Gradle Plugin 2.*", the `listProductsReleases` task no longer exists, but + // instead the `printProductReleases` task does. This task is necessary to take the output of + // `printProductReleases` and write it to a file for use in the `generateIdeVersionsList` task below. + val listProductReleasesTaskName = "listProductsReleases" + register(listProductReleasesTaskName) { + dependsOn(printProductsReleases) + val outputF = layout.buildDirectory.file("listProductsReleases.txt").also { + outputs.file(it) + } + val content = printProductsReleases.flatMap { it.productsReleases }.map { it.joinToString("\n") } + + doLast { + outputF.orNull?.asFile?.writeText(content.get()) + } + } + + // Task to generate the necessary format for `ChrisCarini/intellij-platform-plugin-verifier-action` GitHub Action. + register("generateIdeVersionsList") { + dependsOn(project.tasks.named(listProductReleasesTaskName)) + doLast { + val ideVersionsList = mutableListOf() + + // Include the versions produced from the `listProductsReleases` task. + project.tasks.named(listProductReleasesTaskName).get().outputs.files.singleFile.forEachLine { line -> + ideVersionsList.add("idea" + line.replace("-", ":")) + } + + // Include the versions specified in `gradle.properties` `pluginVerifierIdeVersions` property. + pluginVerifierIdeVersions.split(",").map { it.trim() }.forEach { version -> + listOf("IC", "IU").forEach { type -> + ideVersionsList.add("idea$type:$version") + } + } + + // Write out file with unique pairs of type + version + val outFileWriter = File( + layout.buildDirectory.get().toString(), "intellij-platform-plugin-verifier-action-ide-versions-file.txt" + ).printWriter() + ideVersionsList.distinct().forEach { version -> + outFileWriter.println(version) + } + outFileWriter.close() + } + } + + withType { + options.compilerArgs.addAll( + listOf( + "-Xlint:all", + "-Xlint:-options", + "-Xlint:-rawtypes", + "-Xlint:-processing", + "-Xlint:-path", // Ignore JBR SDK manifest element warnings + "-proc:none", + "-Werror", + "-Xlint:-classfile" + ) + ) + } +} + +val runIdeForUiTests by intellijPlatformTesting.runIde.registering { + 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(Constants.Constraints.LATEST_VERSION) + } +} diff --git a/build_standard_jetbrains_plugin_build.gradle b/build_standard_jetbrains_plugin_build.gradle deleted file mode 100644 index 062cbab..0000000 --- a/build_standard_jetbrains_plugin_build.gradle +++ /dev/null @@ -1,268 +0,0 @@ -import org.jetbrains.changelog.ExtensionsKt -import org.jetbrains.intellij.tasks.ListProductsReleasesTask.Channel -import org.jetbrains.intellij.tasks.RunPluginVerifierTask.FailureLevel - -import java.util.stream.Collectors - -String properties(String key) { return project.findProperty(key).toString() } - -buildscript { - repositories { - mavenCentral() - maven { - url "https://plugins.gradle.org/m2/" - } - } - - dependencies { - classpath 'org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.17.4' - classpath 'org.jetbrains.changelog:org.jetbrains.changelog.gradle.plugin:2.1.0' - classpath 'org.jetbrains.qodana:gradle-qodana-plugin:0.1.13' - classpath 'com.dorongold.plugins:task-tree:4.0.0' // provides `taskTree` task (e.g. `./gradlew build taskTree`; docs: https://github.com/dorongold/gradle-task-tree) - } -} - -apply plugin: IdeaPlugin -apply plugin: JavaPlugin -apply plugin: org.jetbrains.intellij.IntelliJPlugin -apply plugin: org.jetbrains.changelog.ChangelogPlugin -apply plugin: org.jetbrains.qodana.QodanaPlugin -apply plugin: com.dorongold.gradle.tasktree.TaskTreePlugin // provides `taskTree` task (e.g. `./gradlew build taskTree`; docs: https://github.com/dorongold/gradle-task-tree) - - -group properties("pluginGroup") -version properties("pluginVersion") - -repositories { - mavenCentral() -} - -idea { - project { - // Set default IntelliJ SDK & language level to the version specified in `gradle.properties` - jdkName = properties("javaVersion") - languageLevel = properties("javaVersion") - } -} - -intellij { - pluginName.set(properties("pluginName")) - version.set(properties("platformVersion")) - type.set(properties("platformType")) - downloadSources.set(properties("platformDownloadSources").toBoolean()) - - // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. - plugins.set(properties("platformPlugins").length() == 0 ? [] : Arrays.asList(properties("platformPlugins").split(','))) -} - -// Configure CHANGELOG.md - https://github.com/JetBrains/gradle-changelog-plugin -// Note: Use all the defaults. -changelog { -} - -// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin -qodana { - cachePath.set(project.file(".qodana").canonicalPath) - reportPath.set(project.file("build/reports/inspections").canonicalPath) - saveReport.set(true) - showReport.set(System.getenv("QODANA_SHOW_REPORT") == null ? true : System.getenv("QODANA_SHOW_REPORT").toBoolean()) -} - -def getFailureLevels() { - def includeFailureLevels = EnumSet.allOf(FailureLevel) - def desiredFailureLevels = properties('pluginVerifierExcludeFailureLevels'). - split(',')*. - trim(). - // Remove empty strings; this happens when user sets nothing (ie, `pluginVerifierExcludeFailureLevels =`) - findAll { failureLevel -> !failureLevel.equals('') } - - desiredFailureLevels.collect { failureLevel -> - if ('ALL' == failureLevel) { - return EnumSet.allOf(FailureLevel) - } - if ('NONE' == failureLevel) { - return EnumSet.noneOf(FailureLevel) - } - try { - return FailureLevel.valueOf(failureLevel) - } catch (Exception ignored) { - def msg = "Failure Level '${failureLevel}' is *NOT* valid. Please select from: ${EnumSet.allOf(FailureLevel)}." - logger.error(msg) - throw new Exception(msg) - } - }.forEach(failureLevel -> includeFailureLevels.remove(failureLevel)) - - return includeFailureLevels -} - -tasks { - sourceCompatibility = properties("javaVersion") - targetCompatibility = properties("javaVersion") - - patchPluginXml { - version.set(properties("pluginVersion")) - - // Extract the section from README.md and provide for the plugin's manifest - pluginDescription.set( - ExtensionsKt.markdownToHTML( - project.file("README.md").text.lines() - .dropWhile({ String sx -> !sx.equals("") }) - .skip(1) - .takeWhile({ String sx -> !sx.equals("") }) - .collect(Collectors.joining('\n')) - ) - ) - sinceBuild.set(properties('pluginSinceBuild')) - untilBuild.set(properties('pluginUntilBuild')) - - def changeLogForVersion = changelog.getOrNull(properties("pluginVersion")) - changeNotes.set((changeLogForVersion != null ? changeLogForVersion : changelog.getLatest()).toHTML()) - } - - listProductsReleases { -// // In addition to `IC` (from `platformType`), we also want to verify against `IU`. -// types.set(Arrays.asList(properties('platformType'), 'IU')) - // Contrary to above, we want to speed up CI, so skip verification of `IU`. - types.set(Arrays.asList(properties('platformType'))) - - // Only get the released versions if we are not targeting an EAP. - def isEAP = properties("pluginVersion").endsWith('-EAP') - releaseChannels.set([isEAP ? Channel.EAP : Channel.RELEASE]) - - // Verify against the most recent patch release of the `platformVersion` version - // (ie, if `platformVersion` = 2022.2, and the latest patch release is `2022.2.2`, - // then the `sinceVersion` will be set to `2022.2.2` and *NOT* `2022.2`. - sinceVersion.set(properties('platformVersion')) - } - - // Task to generate the necessary format for `ChrisCarini/intellij-platform-plugin-verifier-action` GitHub Action. - task generateIdeVersionsList { - dependsOn('listProductsReleases') - doLast { - def ideVersionsList = []; - - // Include the versions produced from the `listProductsReleases` task. - listProductsReleases.getOutputFile().get().asFile.eachLine { line -> - ideVersionsList.add("idea" + line.replaceAll("-", ":")) - } - - // Include the versions specified in `gradle.properties` `pluginVerifierIdeVersions` property. - properties("pluginVerifierIdeVersions").split(',')*.trim().each { version -> - ['IC', 'IU'].each { type -> - ideVersionsList.add("idea" + type + ":" + version) - } - } - - // Write out file with unique pairs of type + version - def outFileWriter = new File(buildDir, 'intellij-platform-plugin-verifier-action-ide-versions-file.txt').newPrintWriter() - ideVersionsList.unique().each { version -> - outFileWriter.println(version) - } - outFileWriter.close() - } - } - - runPluginVerifier { - // Leave `ideVersions` commented out so that the `listProductsReleases` task will execute. - // If no `ideVersions` is specified, the output from the `listProductsReleases` will be used. - // - // NOTE: I use the `listProductsReleases` task and `generateIdeVersionsList` task for the - // `ChrisCarini/intellij-platform-plugin-verifier-action` GitHub Action to verify on CI. - // ideVersions = Arrays.asList(properties("pluginVerifierIdeVersions").split(',')) - - def failureLevels = getFailureLevels() - logger.debug("Using ${failureLevels.size()} Failure Levels: ${failureLevels}") - failureLevel.set(failureLevels) - } - - // Set the respective compiler arguments to fail the build if there are warnings. - tasks.withType(JavaCompile) { - options.compilerArgs.addAll([ - '-Xlint:all', - '-Xlint:-options', - '-Xlint:-rawtypes', - '-Xlint:-processing', - '-Xlint:-path', // Ignore JBR SDK manifest element warnings - '-proc:none', - '-Werror', - '-Xlint:-classfile' - ]) //ignore warnings from dependencies - } - - if (System.getenv('CI') != "true") { - // The below file (jetbrainsCredentials.gradle) should contain the below: - // project.ext.set("intellijSignPluginCertificateChain", new File('./chain.crt').getText('UTF-8')) - // project.ext.set("intellijSignPluginPrivateKey", new File('./private.pem').getText('UTF-8')) - // project.ext.set("intellijSignPluginPassword", "YOUR_PRIV_KEY_PASSWORD_HERE") - // project.ext.set("intellijPluginPublishToken", "YOUR_TOKEN_HERE") - // - // Because this contains credentials, this file is also included in .gitignore file. - apply from: 'jetbrainsCredentials.gradle' - } - - def signPluginCertificateChain = System.getenv('CI') != "true" ? intellijSignPluginCertificateChain : System.getenv("CERTIFICATE_CHAIN") - def signPluginPrivateKey = System.getenv('CI') != "true" ? intellijSignPluginPrivateKey : System.getenv("PRIVATE_KEY") - def signPluginPassword = System.getenv('CI') != "true" ? intellijSignPluginPassword : System.getenv("PRIVATE_KEY_PASSWORD") - def publishPluginToken = System.getenv('CI') != "true" ? intellijPluginPublishToken : System.getenv("PUBLISH_TOKEN") - - signPlugin { - dependsOn('checkJetBrainsSecrets') - certificateChain.set(signPluginCertificateChain) - privateKey.set(signPluginPrivateKey) - password.set(signPluginPassword) - } - - publishPlugin { - // TODO(ChrisCarini - 2021-10-12) - The `patchChangelog` dependency is not needed, - // because it is taken care of in the `release.yml` file. Follow up with the IJ - // plugin template to see if this is removed / modified in a month or so. -// dependsOn("patchChangelog") - dependsOn('checkJetBrainsSecrets') - token.set(publishPluginToken) - - // 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 - def pluginVersionArray = properties("pluginVersion").split('-') - def releaseChannelArray = (pluginVersionArray.length > 1 ? pluginVersionArray[1] : "default").split('\\.').first() - channels.set(List.of(releaseChannelArray)) - } - - // Sanity check task to ensure necessary variables are set. - task checkJetBrainsSecrets { - doLast { - println "signPluginCertificateChain: " + (signPluginCertificateChain ? "IS" : "is NOT") + " set." - println "signPluginPrivateKey: " + (signPluginPrivateKey ? "IS" : "is NOT") + " set." - println "signPluginPassword: " + (signPluginPassword ? "IS" : "is NOT") + " set." - println "publishPluginToken: " + (publishPluginToken ? "IS" : "is NOT") + " set." - } - } -} - -test { - useTestNG() - useJUnit() -} - -configurations { - provided -} - -dependencies { - provided localGroovy() - provided gradleApi() - - // Gradle Plugins; applied at the top via `apply plugin: ...` - buildscript.configurations.classpath.each { file -> - provided files(file) - } - - testImplementation group: 'junit', name: 'junit', version: '4.13.2' - testImplementation 'org.testng:testng:7.10.2' - testImplementation 'org.mockito:mockito-core:5.12.0' -} - -// Configure IntelliJ to be aware of Groovy and Gradle APIs to allow resolution and code completion of symbols in build.gradle -idea.module { - scopes.PROVIDED.plus += [configurations.provided] -} diff --git a/gradle.properties b/gradle.properties index 7a76646..3c07049 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,23 +1,30 @@ -# IntelliJ Platform Artifacts Repositories -# -> https://www.jetbrains.org/intellij/sdk/docs/reference_guide/intellij_artifacts.html - pluginGroup = com.chriscarini.jetbrains -pluginName = 'Git Push Reminder' -# SemVer format -> https://semver.org -pluginVersion = 2.0.5 +pluginName = Git Push Reminder +pluginRepositoryUrl = https://github.com/ChrisCarini/git-push-reminder-jetbrains-plugin +# Plugin Version in SemVer format -> https://semver.org +# To release a new version of the plugin against an EAP build of IntelliJ, +# the pluginVersion should be suffixed with '-EAP'. This will release the +# plugin to the below JetBrains-hosted plugin repository: +# - https://plugins.jetbrains.com/plugins/eap/list +# Note: You will need to configure the above URL as a custom plugin repository; +# see directions: https://www.jetbrains.com/help/idea/managing-plugins.html#repos +pluginVersion = 2.1.0 ## See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html ## for insight into build numbers and IntelliJ Platform versions. -pluginSinceBuild = 241 -pluginUntilBuild = 241.* +pluginSinceBuild = 242 +pluginUntilBuild = 242.* # Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl # See https://jb.gg/intellij-platform-builds-list for available build versions -pluginVerifierIdeVersions = 2024.1.5,LATEST-EAP-SNAPSHOT +pluginVerifierIdeVersions = 2024.2,LATEST-EAP-SNAPSHOT # Failure Levels: https://github.com/JetBrains/gradle-intellij-plugin/blob/master/src/main/kotlin/org/jetbrains/intellij/tasks/RunPluginVerifierTask.kt # Exclude `NOT_DYNAMIC` Failure Level because we make use of `projectCloseHandler` (in `plugin.xml`) # which is considered to be a non-dynamic feature. pluginVerifierExcludeFailureLevels = NOT_DYNAMIC +# Mute Plugin Problems -> https://github.com/JetBrains/intellij-plugin-verifier?tab=readme-ov-file#check-plugin +# Used to mute (ignore) a comma-seperated list of plugin problems. +pluginVerifierMutePluginProblems = # IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties platformType = IC @@ -25,18 +32,26 @@ platformType = IC # and https://www.jetbrains.com/intellij-repository/snapshots/ # To use/download EAP add '-EAP-SNAPSHOT' to the version, i.e. 'IU-191.6014.8-EAP-SNAPSHOT' # platformVersion = '201.6668.60-EAP-SNAPSHOT' -platformVersion = 2024.1.5 -platformDownloadSources = true +#platformVersion = 2024.1.4 ## 2024.1.4 +#platformVersion = 242.20224.91-EAP-SNAPSHOT ## 2024.2 Beta +#platformVersion = 242.20224.159-EAP-SNAPSHOT ## 2024.2 RC1 +platformVersion = 2024.2 # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html -# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 -platformPlugins = Git4Idea +# Example: platformPlugins = com.jetbrains.php:203.4449.22, org.intellij.scala:2023.3.27@EAP +platformPlugins = +# Example: platformBundledPlugins = com.intellij.java +platformBundledPlugins = Git4Idea # Java language level used to compile sources and to generate the files for # - Java 11 is required since 2020.3 # - Java 17 is required since 2022.2 +# - Java 21 is required since 2024.2 # See https://jb.gg/intellij-platform-versions for details. -javaVersion = 17 +javaVersion = 21 + +# Publish the plugin to the JetBrains Plugin Repository +publishPlugin = true ## # ----- NON JETBRAINS PLUGIN SETTINGS ----- @@ -47,8 +62,8 @@ org.gradle.jvmargs=-Xmx2g # A long-running Gradle process to speed up local builds. # To stop the daemon run 'gradlew --stop' org.gradle.daemon=true -# Lazy configuration of projects speeds up the evaluation of large projects. This is espcially -# useful when invoking a specific project task (e.g. gradlew :environment-variable-settings-summary-plugin:build) +# Lazy configuration of projects speeds up the evaluation of large projects. This is especially +# useful when invoking a specific project task (e.g. gradlew :git-push-reminder-jetbrains-plugin:build) org.gradle.configureondemand=true # Run subproject tasks in parallel. Results in higher CPU usage, but faster builds org.gradle.parallel=true diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index d087efe..0000000 --- a/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = 'git-push-reminder-jetbrains-plugin' - diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..4367a82 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,2 @@ +rootProject.name = "git-push-reminder-jetbrains-plugin" +