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

Target IntelliJ 2024.2 and JDK 21 #53

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@ jobs:

steps:
- name: Git checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: JDK setup
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
distribution: 'zulu'
java-version: 11.0.7
distribution: zulu
java-version: 21.0.3

- name: Build and test
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 # v2.4.2
with:
arguments: build
- name: Gradle setup
uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda # v3.4.2

- name: Gradle build
run: ./gradlew build
env:
CI: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ build/
/.idea/uiDesigner.xml
/.idea/*.iml
/.idea/modules.xml
/.intellijPlatform
2 changes: 1 addition & 1 deletion agent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repositories {
mavenCentral()
}

java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
java.toolchain.languageVersion.set(JavaLanguageVersion.of(21))

tasks.jar {
archiveFileName.set("agent.jar")
Expand Down
146 changes: 69 additions & 77 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,114 +15,92 @@
*/

import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.intellij.tasks.PrepareSandboxTask
import org.jetbrains.intellij.tasks.RunPluginVerifierTask
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.intellij.platform.gradle.tasks.PrepareSandboxTask
import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.util.*

plugins {
id("java")
id("org.jetbrains.intellij").version("1.15.0")
id("org.jetbrains.kotlin.jvm").version("1.9.0")
id("org.jetbrains.intellij.platform").version("2.0.0-beta7")
id("org.jetbrains.kotlin.jvm").version("1.9.24")
}

val isCI = System.getenv("CI") != null
val isRelease = project.findProperty("release") != null
val versionSuffix = if (isRelease) "" else "-SNAPSHOT"
val tokenProperty = "plugins.repository.token"

group = "com.google.idea.perf"
version = "1.3.1$versionSuffix"

repositories {
mavenCentral()
}

java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
java.toolchain.languageVersion.set(JavaLanguageVersion.of(21))

tasks.withType<KotlinCompile> {
kotlinOptions {
languageVersion = "1.7"
apiVersion = "1.7" // Should match the Kotlin stdlib version in IntelliJ.
jvmTarget = "17" // Should match the JetBrains Runtime.
// allWarningsAsErrors = true
languageVersion = "1.9"
apiVersion = "1.9" // Should match the Kotlin stdlib version in IntelliJ.
jvmTarget = "21" // Should match the JetBrains Runtime.
allWarningsAsErrors = true
}
}

// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
pluginName.set("ide-perf")
version.set("232.8660.185")
downloadSources.set(!isCI)
updateSinceUntilBuild.set(false) // So that we can leave the until-build blank.
}
// See https://github.com/JetBrains/intellij-platform-gradle-plugin.
intellijPlatform {
buildSearchableOptions = false // This task is too slow.
autoReload = false // Auto-reload does not work well for this plugin currently.

pluginConfiguration {
version = project.version.toString()
ideaVersion {
sinceBuild = "242" // Should be tested occasionally (see runPluginVerifier).
untilBuild = provider { null } // So that we can leave the until-build blank.
}
changeNotes = """
<ul>
<li>Fixed compatibility with IntelliJ EAP build 232.5150.116.</li>
</ul>
""".trimIndent()
}

tasks.buildSearchableOptions {
// Disable the (slow) 'buildSearchableOptions' task; we don't need it yet anyway.
enabled = false
}
publishing {
token = project.findProperty(tokenProperty) as? String
}

tasks.patchPluginXml {
// Should be tested occasionally (see runPluginVerifier).
sinceBuild.set("223")
// Should describe changes in the latest release only.
changeNotes.set(
"""
<ul>
<li>Fixed compatibility with IntelliJ EAP build 232.5150.116.</li>
</ul>
""".trimIndent()
)
}
// Note: the plugin verifier does not run by default in a normal build.
// Instead, you have to run it explicitly with: ./gradlew verifyPlugin
verifyPlugin {
ides.recommended()
downloadDirectory = layout.buildDirectory.dir("pluginVerifier/ides")

// Note: the plugin verifier does not run by default in a normal build.
// Instead you have to run it explicitly with: ./gradlew runPluginVerifier
tasks.runPluginVerifier {
downloadDir.set("$buildDir/pluginVerifier/ides")

// See https://www.jetbrains.com/idea/download/other.html or
// https://jb.gg/intellij-platform-builds-list for the list of platform versions.
ideVersions.set(
listOf(
"223.8836.41", // Should match the since-build from plugin.xml.
"231.9392.1",
intellij.version.get(), // We check the current version too for deprecations, etc.
val suppressedFailures = listOf(
VerifyPluginTask.FailureLevel.EXPERIMENTAL_API_USAGES, // TODO: VfsStatTreeTable uses JBTreeTable.
VerifyPluginTask.FailureLevel.INTERNAL_API_USAGES, // See CachedValueEventConsumer.
VerifyPluginTask.FailureLevel.DEPRECATED_API_USAGES, // Using PropertiesComponent.getValues.
)
)

val suppressedFailures = listOf(
RunPluginVerifierTask.FailureLevel.EXPERIMENTAL_API_USAGES, // TODO: VfsStatTreeTable uses JBTreeTable.
RunPluginVerifierTask.FailureLevel.INTERNAL_API_USAGES, // See CachedValueEventConsumer.
RunPluginVerifierTask.FailureLevel.DEPRECATED_API_USAGES, // Using PropertiesComponent.getValues.
)
failureLevel.set(EnumSet.copyOf(RunPluginVerifierTask.FailureLevel.ALL - suppressedFailures))

// Suppress false-positive NoSuchClassErrors; they are caused by the agent being
// loaded in the boot classloader rather than the plugin classloader.
externalPrefixes.set(listOf("com.google.idea.perf.agent"))
failureLevel = VerifyPluginTask.FailureLevel.ALL - suppressedFailures

// Suppress false-positive NoSuchClassErrors; they are caused by the agent being
// loaded in the boot classloader rather than the plugin classloader.
externalPrefixes = listOf("com.google.idea.perf.agent")
}
}

val javaAgent: Configuration by configurations.creating

tasks.withType<PrepareSandboxTask> {
// Copy agent artifacts into the plugin home directory.
val agentDir = "${pluginName.get()}/agent"
from(javaAgent) { into(agentDir) }
from(javaAgent) { into("ide-perf/agent") }
}

tasks.publishPlugin {
val tokenProp = "plugins.repository.token"
val theToken = project.findProperty(tokenProp) as? String
token.set(theToken)
doFirst {
check(isRelease) { "Must do a release build when publishing the plugin" }
checkNotNull(theToken) { "Must specify an upload token via -P$tokenProp" }
checkNotNull(token.get()) { "Must specify an upload token via -P$tokenProperty" }
}
}

tasks.runIde {
// Disable auto-reload until we make sure it works correctly for this plugin.
autoReloadPlugins.set(false)

// Always enable assertions.
jvmArgs("-ea")

Expand All @@ -142,9 +120,6 @@ tasks.test {
testLogging.exceptionFormat = TestExceptionFormat.FULL
testLogging.showStandardStreams = isCI
enableAgent()

// Workaround for IDEA-325466 and https://github.com/JetBrains/gradle-intellij-plugin/issues/1433.
jvmArgs("-Djava.awt.headless=true")
}

fun JavaForkOptions.enableAgent() {
Expand All @@ -160,19 +135,36 @@ fun JavaForkOptions.enableAgent() {
}
}

repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
}

dependencies {
intellijPlatform {
// See task 'printProductsReleases' for available IntelliJ versions.
intellijIdeaCommunity("242.18071.24") // IntelliJ 2024.2 EAP 6.
pluginVerifier()
instrumentationTools()
testFramework(TestFrameworkType.Platform)
}

javaAgent(project(":agent", "runtimeElements"))
compileOnly(project(":agent")) // 'compileOnly' because it is put on the bootclasspath later.

implementation("org.ow2.asm:asm:9.4")
implementation("org.ow2.asm:asm-util:9.4")
implementation("org.ow2.asm:asm-commons:9.4")
implementation("org.ow2.asm:asm:9.7")
implementation("org.ow2.asm:asm-util:9.7")
implementation("org.ow2.asm:asm-commons:9.7")

testImplementation("org.jetbrains.kotlin:kotlin-test:1.7.21")
testImplementation("junit:junit:4.13.2")
testImplementation("com.google.truth:truth:1.1.3")
testImplementation("com.google.truth.extensions:truth-java8-extension:1.1.3")

// Workaround for https://youtrack.jetbrains.com/issue/IJPL-157292.
testRuntimeOnly("org.opentest4j:opentest4j:1.3.0")

// For simplicity, we assume all 'compileOnly' dependencies should be 'testCompileOnly' as well.
configurations.testCompileOnly.get().extendsFrom(configurations.compileOnly.get())
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
8 changes: 4 additions & 4 deletions src/main/java/com/google/idea/perf/AgentLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ import com.google.idea.perf.agent.AgentMain
import com.google.idea.perf.tracer.TracerClassFileTransformer
import com.google.idea.perf.tracer.TracerHookImpl
import com.google.idea.perf.agent.TracerTrampoline
import com.intellij.execution.process.OSProcessUtil
import com.intellij.ide.plugins.PluginManagerCore
import com.intellij.notification.Notification
import com.intellij.notification.NotificationType
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.extensions.PluginId
import com.intellij.util.io.isFile
import com.sun.tools.attach.VirtualMachine
import java.lang.instrument.Instrumentation
import kotlin.io.path.isRegularFile
import kotlin.system.measureTimeMillis

// Things to improve:
Expand Down Expand Up @@ -107,9 +106,10 @@ object AgentLoader {
val agentDir = plugin.pluginPath.resolve("agent")

val javaAgent = agentDir.resolve("agent.jar")
check(javaAgent.isFile()) { "Could not find agent.jar at $javaAgent" }
check(javaAgent.isRegularFile()) { "Could not find agent.jar at $javaAgent" }

val vm = VirtualMachine.attach(OSProcessUtil.getApplicationPid())
val pid = ProcessHandle.current().pid()
val vm = VirtualMachine.attach(pid.toString())
try {
vm.loadAgent(javaAgent.toAbsolutePath().toString())
}
Expand Down