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

#911 support intellij 2024.2 by updating gradle version #1053

Open
wants to merge 17 commits into
base: intellij-2024.2-support
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
99 changes: 55 additions & 44 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
plugins {
id 'java'
id 'org.jetbrains.intellij' version '1.17.3'
id 'org.jetbrains.kotlin.jvm' version '1.7.22'
id 'org.jetbrains.intellij.platform' version '2.1.0'
id 'org.jetbrains.kotlin.jvm' version '2.0.20'
}

group 'io.openliberty.tools'
version '24.0.9'

sourceCompatibility = 17
targetCompatibility = 17

def remoteRobotVersion = "0.11.18"
def remoteRobotVersion = "0.11.23"
// To switch to nightly version, append "@nightly" to the version number (i.e. 0.4.1-20240828-013108@nightly)
def lsp4ijVersion = '0.7.0'

allprojects {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }
}

repositories {
mavenCentral()
maven {
Expand Down Expand Up @@ -43,7 +47,9 @@ repositories {
maven {
url = "https://cache-redirector.jetbrains.com/download-pgp-verifier"
}

intellijPlatform {
defaultRepositories()
}
mavenLocal() // TODO remove once Liberty LS is publicly available
}

Expand All @@ -60,7 +66,7 @@ configurations {
// Ensures that the JVM target is set to 17 for all Kotlin compilation tasks, including both main and test sources.
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "17"
jvmTarget = javaVersion
}
}
}
Expand Down Expand Up @@ -97,9 +103,7 @@ dependencies {
testImplementation 'com.intellij.remoterobot:remote-robot:' + remoteRobotVersion
testImplementation 'com.intellij.remoterobot:remote-fixtures:' + remoteRobotVersion
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
testImplementation('com.jetbrains.intellij.maven:maven-test-framework:241.15989.150') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this being removed? This will eventually be updated later, but should be left alone for now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this dependency as jetbrains have introduced new TEST Framework which will automatically include this dependency based on intellij version in our project. This was suggested by jetbrains team here
https://jetbrains-platform.slack.com/archives/C5U8BM1MK/p1730297530842639?thread_ts=1730105939.390899&cid=C5U8BM1MK

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we have confirmed that we can run the unit tests with this dependency removed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, @TrevCraw,

Instead of adding maven-test-framework directly, IntelliJ 2024.2 introduced a way to add this line: testFramework TestFrameworkType.Plugin.Maven.INSTANCE within the intellijPlatform setup under the dependencies tag. This approach ensures that the dependency is downloaded in our project, and the version is determined by the IntelliJ platform version specified.

However, even with this adjustment, unit tests do not work in IntelliJ 2024.2. That said, making this change has been verified to fully support unit tests in IntelliJ 2024.1.

These are the dependencies used in the project, and when removing the direct dependency and instead adding the framework as suggested by JetBrains, maven-test-framework is downloaded correctly.
Screenshot 2024-11-15 at 11 21 57 AM

Thanks,

transitive = false
}

testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.9.2'

Expand Down Expand Up @@ -129,29 +133,47 @@ dependencies {
implementation files(new File(buildDir, 'server')) {
builtBy 'copyDeps'
}
}
intellijPlatform {
// For a full list of IntelliJ IDEA releases please see https://www.jetbrains.com/intellij-repository/releases
create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion"))
bundledPlugins providers.gradleProperty("platformBundledPlugins").orElse("").get().split(',').toList()

def lsp4ij = providers.gradleProperty('useLocal') && providers.gradleProperty('useLocal') == 'true' ?
file("../lsp4ij/build/distributions/LSP4IJ/") :
'com.redhat.devtools.lsp4ij:' + lsp4ijVersion
plugins lsp4ij
pluginVerifier()
zipSigner()
instrumentationTools()
Comment on lines +145 to +147
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why these lines needed to be added?

Copy link
Author

@staicy123 staicy123 Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InstrumentationTools()
When we remove this it will throw error during buildPlugin:
Screenshot 2024-11-11 at 4 47 15 PM
=> The code instrumentation process handled with the instrumentCode task, requires extra dependencies to work and properly adjust the Java bytecode. There's the instrumentationTools() dependencies helper introduced to apply all required dependencies using default configuration
https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#java-runtime
PluginVerifier():
the Plugin Verifier is a tool used to check whether your IntelliJ IDEA plugin is compatible with specific versions of IntelliJ IDEA (or other JetBrains IDEs like PyCharm, WebStorm, etc.). It helps you ensure that your plugin works correctly with different versions of the IDE before releasing it to users, especially when updates to the IDE or your plugin occur.

Why Do You Need It?

When you develop a plugin for an IntelliJ-based IDE, new versions of the IDE might introduce changes that could potentially break the functionality of your plugin. The Plugin Verifier ensures your plugin works with the version(s) of the IDE you intend it to support. It checks for compatibility issues and reports any problems, such as deprecated API usage, missing features, or unsupported changes in the IDE.

Without verifying, your plugin might break when users upgrade to newer versions of the IDE, leading to crashes or broken functionality for them.https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#target-platforms

I am not sure whether we need zipSigner().
Purpose: Plugin Signing is a security feature introduced by JetBrains starting from 2021.2 to protect users from potentially malicious or tampered plugins in the JetBrains Marketplace (and in IntelliJ-based IDEs like IntelliJ IDEA, PyCharm, WebStorm, etc.).

In simple terms, Plugin Signing ensures that the plugin you install on your IDE has not been tampered with and comes from the original developer who created it.
https://plugins.jetbrains.com/docs/intellij/plugin-signing.html


testFramework TestFrameworkType.Platform.INSTANCE
testFramework TestFrameworkType.Plugin.Java.INSTANCE
testFramework TestFrameworkType.Plugin.Maven.INSTANCE
TrevCraw marked this conversation as resolved.
Show resolved Hide resolved
}
}
task copyDeps(type: Copy) {
from configurations.lsp
into new File(buildDir, 'server/server')
rename '^(.*)(-[0-9]+[.[0-9]+]+(-SNAPSHOT)?)(.*)$', '$1$4'
}

runIde {
jvmArgs '--add-exports', 'java.base/jdk.internal.vm=ALL-UNNAMED'
jvmArgumentProviders.add({
[
"--add-exports",
"java.base/jdk.internal.vm=ALL-UNNAMED",
]
} as CommandLineArgumentProvider)
}

intellij {
// For a full list of IntelliJ IDEA releases please see https://www.jetbrains.com/intellij-repository/releases
version = '2024.1.6'
test {
useJUnitPlatform()

def lsp4ij = project.hasProperty('useLocal') && project.property('useLocal') == 'true' ?
file("../lsp4ij/build/distributions/LSP4IJ/") :
'com.redhat.devtools.lsp4ij:' + lsp4ijVersion
plugins = ['java', 'maven', 'gradle-java', 'properties', 'terminal', 'org.jetbrains.idea.maven', 'com.intellij.gradle', lsp4ij]
updateSinceUntilBuild = false
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
}

downloadRobotServerPlugin {
version.set(remoteRobotVersion)
}
Expand All @@ -168,27 +190,15 @@ runIdeForUiTests {
systemProperty "apple.laf.useScreenMenuBar", "false"
}

test {
useJUnitPlatform()

testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
}

tasks {
// Disabling buildSearchableOptions, which runs as part of the buildPlugin task.
// this is to buildSearchableOptions to workaround the "Only one instance of IDEA can be run at a time" problem.
// Per documentation: https://plugins.jetbrains.com/docs/intellij/ide-development-instance.html#the-development-instance-sandbox-directory
buildSearchableOptions {
enabled = false
}
}

patchPluginXml {
changeNotes = """
<h2> 24.0.9 </h2>
intellijPlatform {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is intellijPlatform in three different spots?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here in this doc it's explained https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html#setting-up-intellij-platform to add intellijPlatform in different places as per new updation.
Screenshot 2024-11-11 at 9 04 37 AM

buildSearchableOptions = false
pluginConfiguration {
ideaVersion {
sinceBuild = providers.gradleProperty("pluginSinceBuild")
untilBuild = providers.gradleProperty("pluginUntilBuild")
}
changeNotes = """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did the change notes need to be moved from pathPluginXml to intellijPlatform?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was suggested by jetbrains team to move the patchPluginXml.changeNotes to intellijPlatform.pluginConfiguration.changeNotes
https://jetbrains-platform.slack.com/archives/C5U8BM1MK/p1729610706101729?thread_ts=1729576853.003949&cid=C5U8BM1MK

Copy link
Contributor

@TrevCraw TrevCraw Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. We will need to confirm that this still works correctly when the plugin is uploaded to the marketplace. Can you please open an issue to upload an early version of the plugin to a private repo/stream in the JetBrains marketplace to check that the plugin info and change notes are displayed properly?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I have created the issue for analysing this part here : #1112

<h2> 24.0.9 </h2>
<p>Version 24.0.9 of Liberty Tools for IntelliJ IDEA contains enhancements and fixes. Version 24.0.9 requires IntelliJ IDEA version 2024.1.* ONLY and a minimum of Java 17.</p>
Notable changes:
<ul>
Expand Down Expand Up @@ -326,5 +336,6 @@ patchPluginXml {
<li> First preview release
</ul>
"""
version project.version
version project.version
}
}
13 changes: 13 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
useLocal=false
pluginSinceBuild=241
pluginUntilBuild=242.*

javaVersion=17
javaTargetVersion=17

# Target IntelliJ Community by default
platformType=IC
platformVersion=2024.1.7

# Example: platformBundledPlugins = com.intellij.java
platformBundledPlugins=com.intellij.java, org.jetbrains.idea.maven, com.intellij.gradle, org.jetbrains.plugins.terminal, com.intellij.properties
2 changes: 0 additions & 2 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
<depends>com.intellij.gradle</depends>
<depends>com.redhat.devtools.lsp4ij</depends>

<idea-version since-build="241" until-build="241.*"/>

<extensions defaultExtensionNs="com.intellij">
<toolWindow anchor="right" id="Liberty" icon="/icons/OL_logo_13.svg"
factoryClass="io.openliberty.tools.intellij.LibertyDevToolWindowFactory"/>
Expand Down
Loading