Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to org.jetbrains.intellij.platform v2.0.0 #5657

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
- name: Fetch Sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1

# Setup Java 11 environment for the next steps
# Setup Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 #v4.0.0
with:
Expand All @@ -123,7 +123,7 @@ jobs:
echo "::set-output name=version::$VERSION"
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"

./gradlew :intellij-plugin:listProductsReleases # prepare list of IDEs for Plugin Verifier
./gradlew :intellij-plugin:printProductsReleases # prepare list of IDEs for Plugin Verifier

# Trigger code generation in test project, as the plugin's tests depend on it
- name: Test project codegen
Expand All @@ -150,7 +150,7 @@ jobs:

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

# Collect Plugin Verifier Result
- name: Collect Plugin Verifier Result
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ package-lock.json

# IntelliJ plugin
intellij-plugin/mockJDK
.intellijPlatform
5 changes: 3 additions & 2 deletions .idea/runConfigurations/Run_IntelliJ_plugin.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {
implementation(libs.kotlinx.serialization.json)
implementation(libs.poet.java)
implementation(libs.poet.kotlin)
implementation(libs.intellij.plugin)
implementation(libs.intellij.platform.plugin)
implementation(libs.intellij.changelog)
implementation(libs.androidx.lint.gradle.plugin)
implementation(libs.kotlin.plugin.compose)
Expand Down
2 changes: 1 addition & 1 deletion gradle/libraries.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ http4k-bom = "org.http4k:http4k-bom:5.8.0.0"
http4k-core = { module = "org.http4k:http4k-core" }
http4k-server-undertow = { module = "org.http4k:http4k-server-undertow" }
http4k-server-jetty = { module = "org.http4k:http4k-server-jetty" }
intellij-plugin = "org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.17.0"
intellij-platform-plugin = "org.jetbrains.intellij.platform:intellij-platform-gradle-plugin:2.0.0-beta5"
intellij-changelog = "org.jetbrains.intellij.plugins:gradle-changelog-plugin:2.0.0"
jetbrains-annotations = { group = "org.jetbrains", name = "annotations", version.ref = "jetbrains-annotations" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
Expand Down
7 changes: 4 additions & 3 deletions gradle/repositories.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ listOf(pluginManagement.repositories, dependencyResolutionManagement.repositorie
includeModule("com.github.ben-manes", "gradle-versions-plugin")
includeModule("com.gradle", "develocity-gradle-plugin")

// For org.jetbrains.intellij
includeModule("org.jetbrains.intellij", "org.jetbrains.intellij.gradle.plugin")
includeModule("org.jetbrains.intellij.plugins", "gradle-intellij-plugin")
// For org.jetbrains.intellij.platform
includeModule("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext", "gradle-idea-ext")

// For org.jetbrains.changelog
includeModule("org.jetbrains.changelog", "org.jetbrains.changelog.gradle.plugin")
includeModule("org.jetbrains.intellij.plugins", "gradle-changelog-plugin")

// For org.jetbrains.intellij.platform
includeModule("org.jetbrains.intellij.platform", "intellij-platform-gradle-plugin")
}
}
}
Expand Down
192 changes: 97 additions & 95 deletions intellij-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.intellij.platform.gradle.tasks.CustomRunIdeTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import java.net.URL
import java.text.SimpleDateFormat
import java.util.Date

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

fun isSnapshotBuild() = System.getenv("IJ_PLUGIN_SNAPSHOT").toBoolean()


plugins {
id("org.jetbrains.kotlin.jvm")
id("org.jetbrains.intellij")
id("org.jetbrains.intellij.platform")
alias(libs.plugins.apollo.published)
}

Expand All @@ -21,6 +26,10 @@ repositories {
// Uncomment this one to use the Kotlin "dev" repository
// maven { url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/") }
mavenCentral()

intellijPlatform {
defaultRepositories()
}
}

group = properties("pluginGroup")
Expand All @@ -36,103 +45,34 @@ fun getSnapshotVersionSuffix(): String {
// Set the JVM language level used to build project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+.
kotlin {
jvmToolchain {
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(properties("javaVersion").toInt()))
languageVersion = JavaLanguageVersion.of(17)
}
}

// Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij {
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty))

// Uncomment to use a local repository e.g. for testing not yet published versions of the GraphQL plugin
// pluginsRepositories {
// maven("file://${System.getProperty("user.home")}/.m2/repository")
// // Note: using 2 repositories doesn't work currently - see https://github.com/JetBrains/gradle-intellij-plugin/issues/1292
// // marketplace()
// }
}

tasks {
withType<KotlinCompile> {
kotlinOptions {
withType<KotlinCompilationTask<*>> {
compilerOptions {
freeCompilerArgs = listOf("-Xcontext-receivers")
}
}

patchPluginXml {
pluginId.set(properties("pluginId"))
version.set(project.version.toString())
sinceBuild.set(properties("pluginSinceBuild"))
untilBuild.set(properties("pluginUntilBuild"))

// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription.set(
projectDir.resolve("README.md").readText().lines().run {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

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").run { markdownToHTML(this) }
)

changeNotes.set(
if (isSnapshotBuild()) {
"Weekly snapshot builds contain the latest changes from the <code>main</code> branch."
} else {
"See the <a href=\"https://github.com/apollographql/apollo-kotlin/releases/tag/v${project.version}\">release notes</a>."
}
)
}

// 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", "<!--999.999-->")
systemProperty("jb.consents.confirmation.enabled", "false")

// Enables debug logging for the plugin
systemProperty("idea.log.debug.categories", "Apollo")
}

runIde {
withType<CustomRunIdeTask> {
// Enables debug logging for the plugin
systemProperty("idea.log.debug.categories", "Apollo")

// Disable hiding frequent exceptions in logs (annoying for debugging). See com.intellij.idea.IdeaLogger.
systemProperty("idea.logger.exception.expiration.minutes", "0")

// Use a custom IntelliJ installation. Set this property in your local ~/.gradle/gradle.properties file.
// (for AS, it should be something like '/Applications/Android Studio.app/Contents')
// See https://plugins.jetbrains.com/docs/intellij/android-studio.html#configuring-the-plugin-gradle-build-script
if (project.hasProperty("apolloIntellijPlugin.ideDir")) {
ideDir.set(file(project.property("apolloIntellijPlugin.ideDir")!!))
}

// Uncomment to disable internal mode - see https://plugins.jetbrains.com/docs/intellij/enabling-internal.html
// systemProperty("idea.is.internal", "false")
}

signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}

publishPlugin {
token.set(System.getenv("PUBLISH_TOKEN"))
if (isSnapshotBuild()) {
// Read more: https://plugins.jetbrains.com/docs/intellij/publishing-plugin.html#specifying-a-release-channel
channels.set(listOf("snapshots"))
val runLocalIde by registering(CustomRunIdeTask::class) {
// Use a custom IJ/AS installation. Set this property in your local ~/.gradle/gradle.properties file.
// (for AS, it should be something like '/Applications/Android Studio.app/Contents')
// See https://plugins.jetbrains.com/docs/intellij/android-studio.html#configuring-the-plugin-gradle-build-script
providers.gradleProperty("apolloIntellijPlugin.ideDir").orNull?.let {
localPath = file(it)
}
}

Expand All @@ -157,7 +97,9 @@ tasks.register("downloadMockJdk") {
val rtJar = mockJdkRoot.resolve("java/mockJDK-1.7/jre/lib/rt.jar")
if (!rtJar.exists()) {
rtJar.parentFile.mkdirs()
rtJar.writeBytes(URL("https://github.com/JetBrains/intellij-community/raw/master/java/mockJDK-1.7/jre/lib/rt.jar").openStream().readBytes())
rtJar.writeBytes(URL("https://github.com/JetBrains/intellij-community/raw/master/java/mockJDK-1.7/jre/lib/rt.jar").openStream()
.readBytes()
)
}
}
}
Expand All @@ -170,19 +112,6 @@ tasks.test.configure {
systemProperty("idea.home.path", mockJdkRoot.relativeTo(project.projectDir).path)
}

dependencies {
implementation(project(":apollo-gradle-plugin-external"))
implementation(project(":apollo-ast"))
implementation(project(":apollo-tooling"))
implementation(project(":apollo-normalized-cache-sqlite"))
implementation(libs.sqlite.jdbc)
implementation(libs.apollo.runtime.published)
runtimeOnly(libs.slf4j)
testImplementation(libs.google.testparameterinjector)
}

fun isSnapshotBuild() = System.getenv("IJ_PLUGIN_SNAPSHOT").toBoolean()

apollo {
service("apolloDebug") {
packageName.set("com.apollographql.apollo3.debug")
Expand All @@ -200,3 +129,76 @@ tasks.configureEach {
enabled = false
}
}

// IntelliJ Platform Gradle Plugin configuration
// See https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-pluginConfiguration
intellijPlatform {
pluginConfiguration {
id.set(properties("pluginId"))
name.set(properties("pluginName"))
version.set(project.version.toString())
ideaVersion {
sinceBuild = properties("pluginSinceBuild")
untilBuild = properties("pluginUntilBuild")
}
// Extract the <!-- Plugin description --> section from README.md and provide it to the plugin's manifest
description.set(
projectDir.resolve("README.md").readText().lines().run {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

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").run { markdownToHTML(this) }
)
changeNotes.set(
if (isSnapshotBuild()) {
"Weekly snapshot builds contain the latest changes from the <code>main</code> branch."
} else {
"See the <a href=\"https://github.com/apollographql/apollo-kotlin/releases/tag/v${project.version}\">release notes</a>."
}
)
}

signing {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}

publishing {
token.set(System.getenv("PUBLISH_TOKEN"))
if (isSnapshotBuild()) {
// Read more: https://plugins.jetbrains.com/docs/intellij/publishing-plugin.html#specifying-a-release-channel
channels.set(listOf("snapshots"))
}
}

verifyPlugin {
ides {
recommended()
}
}
}

dependencies {
intellijPlatform {
create(type = properties("platformType"), version = properties("platformVersion"))
bundledPlugins(properties("platformBundledPlugins").split(',').map(String::trim).filter(String::isNotEmpty))
plugins(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty))
instrumentationTools()
pluginVerifier()
testFramework(TestFrameworkType.Plugin.Java)
zipSigner()
}
implementation(project(":apollo-gradle-plugin-external"))
implementation(project(":apollo-ast"))
implementation(project(":apollo-tooling"))
implementation(project(":apollo-normalized-cache-sqlite"))
implementation(libs.sqlite.jdbc)
implementation(libs.apollo.runtime.published)
runtimeOnly(libs.slf4j)
testImplementation(libs.google.testparameterinjector)
}
12 changes: 5 additions & 7 deletions intellij-plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# IntelliJ Platform Artifacts Repositories
# -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html
pluginGroup=com.apollographql
pluginName=apollo-intellij-plugin
pluginName=Apollo GraphQL
pluginId=com.apollographql.ijplugin
pluginRepositoryUrl=https://github.com/apollographql/apollo-kotlin

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


# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# To find the version of a plugin relative to the platoform version, see the plugin's page on the Marketplace,
# To find the version of a plugin relative to the platform version, see the plugin's page on the Marketplace,
# e.g. for the toml plugin: https://plugins.jetbrains.com/plugin/8195-toml/versions/stable
platformPlugins=com.intellij.java, org.jetbrains.kotlin, com.intellij.gradle, com.intellij.lang.jsgraphql:4.0.2, org.toml.lang, org.jetbrains.android

# JVM language level used to build project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+.
javaVersion=17
platformBundledPlugins=com.intellij.java, org.jetbrains.kotlin, com.intellij.gradle, org.jetbrains.android, org.toml.lang
platformPlugins=com.intellij.lang.jsgraphql:4.0.2

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