Skip to content

Commit 8b0699b

Browse files
authored
Migrate to org.jetbrains.intellij.platform v2.0.0 (#5657)
* Migrate to org.jetbrains.intellij.platform v2.0.0 * Move more configuration to intellijPlatform {} instead of customizing tasks * Fix verifyPlugin * Move dependencies before intellijPlatform so verifyPlugin works * Move dependencies back at the bottom and add pluginVerifier() dependencies * Add testFramework() to dependencies * Bump to 2.0.0-beta1 * Add .intellijPlatform to .gitignore * Fix testFramework and toml plugin * Fix plugin name in descriptor * Add zipSigner() to dependencies * Add a runLocalIde task that uses the apolloIntellijPlugin.ideDir property * Update intellij-platform-plugin to 2.0.0-beta2 * Bump intellij-platform-gradle-plugin to 2.0.0-beta3 * Bump intellij-platform-gradle-plugin to 2.0.0-beta4 * Bump intellij-platform-gradle-plugin to 2.0.0-beta5 * Bump intellij-platform-gradle-plugin to 2.0.0-beta6 * Use project.provider instead of Callable in registerCheckVersionsTask to avoid a ConcurrentModificationException * Revert calling project.provider instead of Callable in registerCheckVersionsTask * Bump intellij-platform-gradle-plugin to 2.0.0-beta7 * Bump intellij-platform-gradle-plugin to 2.0.0-beta8 * Bump intellij-platform-gradle-plugin to 2.0.0-beta9 * Try to fix using a local IDE * Bump intellij-platform-gradle-plugin to 2.0.0-rc1
1 parent 6b16509 commit 8b0699b

File tree

8 files changed

+124
-116
lines changed

8 files changed

+124
-116
lines changed

.github/workflows/pr.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
- name: Fetch Sources
106106
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
107107

108-
# Setup Java 11 environment for the next steps
108+
# Setup Java environment for the next steps
109109
- name: Setup Java
110110
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 #v4.2.1
111111
with:
@@ -124,7 +124,7 @@ jobs:
124124
echo "::set-output name=version::$VERSION"
125125
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
126126
127-
./gradlew :intellij-plugin:listProductsReleases # prepare list of IDEs for Plugin Verifier
127+
./gradlew :intellij-plugin:printProductsReleases # prepare list of IDEs for Plugin Verifier
128128
129129
# Trigger code generation in test project, as the plugin's tests depend on it
130130
- name: Test project codegen
@@ -151,7 +151,7 @@ jobs:
151151

152152
# Run Verify Plugin task and IntelliJ Plugin Verifier tool
153153
- name: Run Plugin Verification tasks
154-
run: ./gradlew :intellij-plugin:runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
154+
run: ./gradlew :intellij-plugin:verifyPlugin -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
155155

156156
# Collect Plugin Verifier Result
157157
- name: Collect Plugin Verifier Result

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ package-lock.json
4949

5050
# IntelliJ plugin
5151
intellij-plugin/mockJDK
52+
.intellijPlatform

.idea/runConfigurations/Run_IntelliJ_plugin.xml

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build-logic/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencies {
3232
implementation(libs.kotlinx.serialization.json)
3333
implementation(libs.poet.java)
3434
implementation(libs.poet.kotlin)
35-
implementation(libs.intellij.plugin)
35+
implementation(libs.intellij.platform.plugin)
3636
implementation(libs.intellij.changelog)
3737
implementation(libs.androidx.lint.gradle.plugin)
3838
implementation(libs.kotlin.plugin.compose)

gradle/libraries.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ http4k-bom = "org.http4k:http4k-bom:5.8.0.0"
116116
http4k-core = { module = "org.http4k:http4k-core" }
117117
http4k-server-undertow = { module = "org.http4k:http4k-server-undertow" }
118118
http4k-server-jetty = { module = "org.http4k:http4k-server-jetty" }
119-
intellij-plugin = "org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.17.0"
119+
intellij-platform-plugin = "org.jetbrains.intellij.platform:intellij-platform-gradle-plugin:2.0.0-rc1"
120120
intellij-changelog = "org.jetbrains.intellij.plugins:gradle-changelog-plugin:2.0.0"
121121
jetbrains-annotations = { group = "org.jetbrains", name = "annotations", version.ref = "jetbrains-annotations" }
122122
junit = { group = "junit", name = "junit", version.ref = "junit" }

gradle/repositories.gradle.kts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ listOf(pluginManagement.repositories, dependencyResolutionManagement.repositorie
2424
includeModule("com.github.ben-manes", "gradle-versions-plugin")
2525
includeModule("com.gradle", "develocity-gradle-plugin")
2626

27-
// For org.jetbrains.intellij
28-
includeModule("org.jetbrains.intellij", "org.jetbrains.intellij.gradle.plugin")
29-
includeModule("org.jetbrains.intellij.plugins", "gradle-intellij-plugin")
27+
// For org.jetbrains.intellij.platform
3028
includeModule("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext", "gradle-idea-ext")
3129

3230
// For org.jetbrains.changelog
3331
includeModule("org.jetbrains.changelog", "org.jetbrains.changelog.gradle.plugin")
3432
includeModule("org.jetbrains.intellij.plugins", "gradle-changelog-plugin")
33+
34+
// For org.jetbrains.intellij.platform
35+
includeModule("org.jetbrains.intellij.platform", "intellij-platform-gradle-plugin")
3536
}
3637
}
3738
}

intellij-plugin/build.gradle.kts

Lines changed: 106 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
22
import org.gradle.api.tasks.testing.logging.TestLogEvent
33
import org.jetbrains.changelog.markdownToHTML
4-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
4+
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
5+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
56
import java.net.URL
67
import java.text.SimpleDateFormat
78
import java.util.Date
89

910
fun properties(key: String) = project.findProperty(key).toString()
1011

12+
fun isSnapshotBuild() = System.getenv("IJ_PLUGIN_SNAPSHOT").toBoolean()
13+
14+
1115
plugins {
1216
id("org.jetbrains.kotlin.jvm")
13-
id("org.jetbrains.intellij")
17+
id("org.jetbrains.intellij.platform")
1418
alias(libs.plugins.apollo.published)
1519
}
1620

@@ -21,6 +25,10 @@ repositories {
2125
// Uncomment this one to use the Kotlin "dev" repository
2226
// maven { url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/") }
2327
mavenCentral()
28+
29+
intellijPlatform {
30+
defaultRepositories()
31+
}
2432
}
2533

2634
group = properties("pluginGroup")
@@ -36,109 +44,40 @@ fun getSnapshotVersionSuffix(): String {
3644
// Set the JVM language level used to build project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+.
3745
kotlin {
3846
jvmToolchain {
39-
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(properties("javaVersion").toInt()))
47+
languageVersion = JavaLanguageVersion.of(17)
4048
}
4149
}
4250

43-
// Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
44-
intellij {
45-
pluginName.set(properties("pluginName"))
46-
version.set(properties("platformVersion"))
47-
type.set(properties("platformType"))
48-
49-
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
50-
plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty))
51-
52-
// Uncomment to use a local repository e.g. for testing not yet published versions of the GraphQL plugin
53-
// pluginsRepositories {
54-
// maven("file://${System.getProperty("user.home")}/.m2/repository")
55-
// // Note: using 2 repositories doesn't work currently - see https://github.com/JetBrains/gradle-intellij-plugin/issues/1292
56-
// // marketplace()
57-
// }
58-
}
59-
6051
val apolloDependencies = configurations.create("apolloDependencies").apply {
6152
listOf(":apollo-annotations", ":apollo-api", ":apollo-runtime").forEach {
6253
dependencies.add(project.dependencies.project(it, "jvmApiElements"))
6354
}
6455
}
6556

6657
tasks {
67-
withType<KotlinCompile> {
68-
kotlinOptions {
58+
withType<KotlinCompilationTask<*>> {
59+
compilerOptions {
6960
freeCompilerArgs = listOf("-Xcontext-receivers")
7061
}
7162
}
7263

73-
patchPluginXml {
74-
pluginId.set(properties("pluginId"))
75-
version.set(project.version.toString())
76-
sinceBuild.set(properties("pluginSinceBuild"))
77-
untilBuild.set(properties("pluginUntilBuild"))
78-
79-
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
80-
pluginDescription.set(
81-
projectDir.resolve("README.md").readText().lines().run {
82-
val start = "<!-- Plugin description -->"
83-
val end = "<!-- Plugin description end -->"
84-
85-
if (!containsAll(listOf(start, end))) {
86-
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
87-
}
88-
subList(indexOf(start) + 1, indexOf(end))
89-
}.joinToString("\n").run { markdownToHTML(this) }
90-
)
91-
92-
changeNotes.set(
93-
if (isSnapshotBuild()) {
94-
"Weekly snapshot builds contain the latest changes from the <code>main</code> branch."
95-
} else {
96-
"See the <a href=\"https://github.com/apollographql/apollo-kotlin/releases/tag/v${project.version}\">release notes</a>."
97-
}
98-
)
99-
}
100-
101-
// Configure UI tests plugin
102-
// Read more: https://github.com/JetBrains/intellij-ui-test-robot
103-
runIdeForUiTests {
104-
systemProperty("robot-server.port", "8082")
105-
systemProperty("ide.mac.message.dialogs.as.sheets", "false")
106-
systemProperty("jb.privacy.policy.text", "<!--999.999-->")
107-
systemProperty("jb.consents.confirmation.enabled", "false")
108-
109-
// Enables debug logging for the plugin
110-
systemProperty("idea.log.debug.categories", "Apollo")
111-
}
112-
113-
runIde {
114-
// Enables debug logging for the plugin
115-
systemProperty("idea.log.debug.categories", "Apollo")
116-
117-
// Disable hiding frequent exceptions in logs (annoying for debugging). See com.intellij.idea.IdeaLogger.
118-
systemProperty("idea.logger.exception.expiration.minutes", "0")
119-
120-
// Use a custom IntelliJ installation. Set this property in your local ~/.gradle/gradle.properties file.
64+
val runLocalIde by intellijPlatformTesting.runIde.registering {
65+
// Use a custom IJ/AS installation. Set this property in your local ~/.gradle/gradle.properties file.
12166
// (for AS, it should be something like '/Applications/Android Studio.app/Contents')
12267
// See https://plugins.jetbrains.com/docs/intellij/android-studio.html#configuring-the-plugin-gradle-build-script
123-
if (project.hasProperty("apolloIntellijPlugin.ideDir")) {
124-
ideDir.set(file(project.property("apolloIntellijPlugin.ideDir")!!))
68+
providers.gradleProperty("apolloIntellijPlugin.ideDir").orNull?.let {
69+
localPath = file(it)
12570
}
12671

127-
// Uncomment to disable internal mode - see https://plugins.jetbrains.com/docs/intellij/enabling-internal.html
128-
// systemProperty("idea.is.internal", "false")
129-
}
72+
task {
73+
// Enables debug logging for the plugin
74+
systemProperty("idea.log.debug.categories", "Apollo")
13075

131-
signPlugin {
132-
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
133-
privateKey.set(System.getenv("PRIVATE_KEY"))
134-
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
135-
}
76+
// Disable hiding frequent exceptions in logs (annoying for debugging). See com.intellij.idea.IdeaLogger.
77+
systemProperty("idea.logger.exception.expiration.minutes", "0")
13678

137-
publishPlugin {
138-
token.set(System.getenv("PUBLISH_TOKEN"))
139-
if (isSnapshotBuild()) {
140-
// Read more: https://plugins.jetbrains.com/docs/intellij/publishing-plugin.html#specifying-a-release-channel
141-
channels.set(listOf("snapshots"))
79+
// Uncomment to disable internal mode - see https://plugins.jetbrains.com/docs/intellij/enabling-internal.html
80+
// systemProperty("idea.is.internal", "false")
14281
}
14382
}
14483

@@ -164,7 +103,9 @@ tasks.register("downloadMockJdk") {
164103
val rtJar = mockJdkRoot.resolve("java/mockJDK-1.7/jre/lib/rt.jar")
165104
if (!rtJar.exists()) {
166105
rtJar.parentFile.mkdirs()
167-
rtJar.writeBytes(URL("https://github.com/JetBrains/intellij-community/raw/master/java/mockJDK-1.7/jre/lib/rt.jar").openStream().readBytes())
106+
rtJar.writeBytes(URL("https://github.com/JetBrains/intellij-community/raw/master/java/mockJDK-1.7/jre/lib/rt.jar").openStream()
107+
.readBytes()
108+
)
168109
}
169110
}
170111
}
@@ -177,19 +118,6 @@ tasks.test.configure {
177118
systemProperty("idea.home.path", mockJdkRoot.relativeTo(project.projectDir).path)
178119
}
179120

180-
dependencies {
181-
implementation(project(":apollo-gradle-plugin-external"))
182-
implementation(project(":apollo-ast"))
183-
implementation(project(":apollo-tooling"))
184-
implementation(project(":apollo-normalized-cache-sqlite"))
185-
implementation(libs.sqlite.jdbc)
186-
implementation(libs.apollo.runtime.published)
187-
runtimeOnly(libs.slf4j.simple)
188-
testImplementation(libs.google.testparameterinjector)
189-
}
190-
191-
fun isSnapshotBuild() = System.getenv("IJ_PLUGIN_SNAPSHOT").toBoolean()
192-
193121
apollo {
194122
service("apolloDebugServer") {
195123
packageName.set("com.apollographql.ijplugin.apollodebugserver")
@@ -207,3 +135,82 @@ tasks.configureEach {
207135
enabled = false
208136
}
209137
}
138+
139+
// IntelliJ Platform Gradle Plugin configuration
140+
// See https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-pluginConfiguration
141+
intellijPlatform {
142+
pluginConfiguration {
143+
id.set(properties("pluginId"))
144+
name.set(properties("pluginName"))
145+
version.set(project.version.toString())
146+
ideaVersion {
147+
sinceBuild = properties("pluginSinceBuild")
148+
untilBuild = properties("pluginUntilBuild")
149+
}
150+
// Extract the <!-- Plugin description --> section from README.md and provide it to the plugin's manifest
151+
description.set(
152+
projectDir.resolve("README.md").readText().lines().run {
153+
val start = "<!-- Plugin description -->"
154+
val end = "<!-- Plugin description end -->"
155+
156+
if (!containsAll(listOf(start, end))) {
157+
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
158+
}
159+
subList(indexOf(start) + 1, indexOf(end))
160+
}.joinToString("\n").run { markdownToHTML(this) }
161+
)
162+
changeNotes.set(
163+
if (isSnapshotBuild()) {
164+
"Weekly snapshot builds contain the latest changes from the <code>main</code> branch."
165+
} else {
166+
"See the <a href=\"https://github.com/apollographql/apollo-kotlin/releases/tag/v${project.version}\">release notes</a>."
167+
}
168+
)
169+
}
170+
171+
signing {
172+
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
173+
privateKey.set(System.getenv("PRIVATE_KEY"))
174+
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
175+
}
176+
177+
publishing {
178+
token.set(System.getenv("PUBLISH_TOKEN"))
179+
if (isSnapshotBuild()) {
180+
// Read more: https://plugins.jetbrains.com/docs/intellij/publishing-plugin.html#specifying-a-release-channel
181+
channels.set(listOf("snapshots"))
182+
}
183+
}
184+
185+
verifyPlugin {
186+
ides {
187+
recommended()
188+
}
189+
}
190+
}
191+
192+
dependencies {
193+
intellijPlatform {
194+
val localIdeDir = providers.gradleProperty("apolloIntellijPlugin.ideDir").orNull
195+
if (localIdeDir != null) {
196+
local(localIdeDir)
197+
} else {
198+
create(type = properties("platformType"), version = properties("platformVersion"))
199+
}
200+
201+
bundledPlugins(properties("platformBundledPlugins").split(',').map(String::trim).filter(String::isNotEmpty))
202+
plugins(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty))
203+
instrumentationTools()
204+
pluginVerifier()
205+
testFramework(TestFrameworkType.Plugin.Java)
206+
zipSigner()
207+
}
208+
implementation(project(":apollo-gradle-plugin-external"))
209+
implementation(project(":apollo-ast"))
210+
implementation(project(":apollo-tooling"))
211+
implementation(project(":apollo-normalized-cache-sqlite"))
212+
implementation(libs.sqlite.jdbc)
213+
implementation(libs.apollo.runtime.published)
214+
runtimeOnly(libs.slf4j.simple)
215+
testImplementation(libs.google.testparameterinjector)
216+
}

intellij-plugin/gradle.properties

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# IntelliJ Platform Artifacts Repositories
22
# -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html
33
pluginGroup=com.apollographql
4-
pluginName=apollo-intellij-plugin
4+
pluginName=Apollo GraphQL
55
pluginId=com.apollographql.ijplugin
66
pluginRepositoryUrl=https://github.com/apollographql/apollo-kotlin
77

@@ -17,16 +17,14 @@ platformType=IC
1717
# Corresponds to AS Iguana 2023.2.1 -> https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html
1818
# and https://developer.android.com/studio/archive (more up to date)
1919
# See also https://plugins.jetbrains.com/docs/intellij/android-studio.html
20-
platformVersion=232.10227.8
20+
platformVersion=2023.2.5
2121

2222

2323
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
24-
# To find the version of a plugin relative to the platoform version, see the plugin's page on the Marketplace,
24+
# To find the version of a plugin relative to the platform version, see the plugin's page on the Marketplace,
2525
# e.g. for the toml plugin: https://plugins.jetbrains.com/plugin/8195-toml/versions/stable
26-
platformPlugins=com.intellij.java, org.jetbrains.kotlin, com.intellij.gradle, com.intellij.lang.jsgraphql:4.0.2, org.toml.lang, org.jetbrains.android
27-
28-
# JVM language level used to build project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+.
29-
javaVersion=17
26+
platformBundledPlugins=com.intellij.java, org.jetbrains.kotlin, com.intellij.gradle, org.jetbrains.android, org.toml.lang
27+
platformPlugins=com.intellij.lang.jsgraphql:4.0.2
3028

3129
# Opt-out flag for bundling Kotlin standard library.
3230
# See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.

0 commit comments

Comments
 (0)