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

feat: Gradle 2.x plugin SDK-based build #761

Closed
wants to merge 6 commits into from

Conversation

SCWells72
Copy link
Contributor

This updates the build to be based on the Gradle 2.x plugin SDK. The buildPlugin, test, and runIde tasks all run perfectly, but the custom release process -- and perhaps some other functionality -- will need to restored for this to have full parity with the current Gradle 1.x-based build.

This was accomplished by creating a brand new plugin project from the template as a peer to the existing one and migrating from the current project into the new one until the aforementioned Gradle tasks ran successfully, then updating the original project with those changes resulting in the branch in this PR.

@angelozerr and @sbouchet, this should be a viable foundation upon which to restore the missing functionality and get LSP4IJ moved into a current plugin build model.

@sbouchet sbouchet self-assigned this Jan 24, 2025
@sbouchet
Copy link
Contributor

@SCWells72 thanks for this new one ! i'm looking at it right now.

Copy link
Contributor

Choose a reason for hiding this comment

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

don't think this file is necessary.
where it's coming from ?

Copy link
Contributor

Choose a reason for hiding this comment

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

We usually don't push our gradle run configurations. please add a gitignore rule for them.

Copy link
Contributor

Choose a reason for hiding this comment

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

This file is also new. as it's linked with legals, we should request our legal team to review it.
i suggest to simply remove it from now.

import org.jetbrains.intellij.tasks.RunPluginVerifierTask.VerificationReportsFormats.*
import org.jetbrains.intellij.tasks.RunPluginVerifierTask.FailureLevel.*

fun properties(key: String) = providers.gradleProperty(key)
Copy link
Contributor

Choose a reason for hiding this comment

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

please leave those 3 function here, for history reasons ( still used below )

plugins {
java // Java support
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to change this one, this is strictly equivalent.

alias(libs.plugins.changelog) // Gradle Changelog Plugin
alias(libs.plugins.testLogger) // Nice test logs
Copy link
Contributor

Choose a reason for hiding this comment

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

please keep testlogger plugin to provide nice tests output ( diffcult to read without it ) .
also, remove qodana as it's not used by our extensio nto review idea inspections.

alias(libs.plugins.kover) // Gradle Kover Plugin
jacoco // Code coverage
Copy link
Contributor

Choose a reason for hiding this comment

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

@angelozerr @fbricon : will it be a sonarqube review in the future for lsp4ij ? is yes, jacoco is needed.
if not, this can be removed.

}

group = prop("pluginGroup")
Copy link
Contributor

Choose a reason for hiding this comment

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

revert to use above functions..


val lsp4jVersion = prop("lsp4jVersion")
val flexmarkVersion = prop("flexmarkVersion")
Copy link
Contributor

Choose a reason for hiding this comment

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

please also revert those versions that are still used the same way.


// Configure project's dependencies
repositories {
mavenLocal()
Copy link
Contributor

Choose a reason for hiding this comment

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

ok this one is tricky, but the way we declare repositories are important. first we use mavenCentral to resolve our snapshot, because we can install locally-built third parties for example.
we had issues in the past not doing so.

defaultRepositories()
}

mavenLocal()
maven { url = uri("https://repository.jboss.org/nexus/content/repositories/snapshots") }
maven { url = uri("https://repository.jboss.org/nexus/content/groups/public") }
maven { url = uri("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies") }
Copy link
Contributor

Choose a reason for hiding this comment

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

this line can be safely removed because it's actually included in the default intellij platform repository declaration above.

val lsp: Configuration by configurations.creating
// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
dependencies {
testImplementation(libs.junit)
Copy link
Contributor

Choose a reason for hiding this comment

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

please move this to the bottom along with other testimplementations

compileClasspath += sourceSets.main.get().output
compileClasspath += configurations.testImplementation.get()
runtimeClasspath += compileClasspath + sourceSets.test.get().output
instrumentationTools()
Copy link
Contributor

Choose a reason for hiding this comment

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

when runnig locally a build, there is a warning about this usage :
w: file:///home/sbouchet/IdeaProjects/lsp4ij/build.gradle.kts:51:9: 'instrumentationTools(): Unit' is deprecated. Calling instrumentationTools() is no longer necessary.

@SCWells72
Copy link
Contributor Author

@sbouchet apologies if I didn't explain the purpose of this PR clearly. It's not intended for direct merge. It's really a proof-of-concept for the migration to a Gradle 2.x-based build for whoever will be doing that work. Anything that can be used from it, please do so. But I don't have the ability to verify things like the plugin publishing process and such so someone who does will need to take it from here. Again, sorry if that wasn't clear.

dependencies {
implementation("org.zeroturnaround:zt-zip:1.14")
implementation("org.jsoup:jsoup:1.17.1")
val lsp4jVersion = providers.gradleProperty("lsp4jVersion").get()
Copy link
Contributor

@sbouchet sbouchet Jan 24, 2025

Choose a reason for hiding this comment

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

please revert this to use previous identical mechanism.

// Required by lsp4j as the version from IJ is incompatible
implementation("com.google.code.gson:gson:2.10.1")

val flexmarkVersion = providers.gradleProperty("flexmarkVersion").get()
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above.

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins = properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) }
}
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
Copy link
Contributor

Choose a reason for hiding this comment

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

@angelozerr @fbricon below is an addition to use README and CHANGELOG files contents to populate plugin description, made manually for now. is it something we want to do ?

isDownloadSources = true
ideaVersion {
sinceBuild = providers.gradleProperty("pluginSinceBuild")
untilBuild = providers.gradleProperty("pluginUntilBuild")
Copy link
Contributor

Choose a reason for hiding this comment

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

there is no such property. please use
untilBuild = provider { null }

testImplementation {
isCanBeResolved = true

publishing {
Copy link
Contributor

Choose a reason for hiding this comment

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

please revert to:

    publishPlugin {
        token = environment("PUBLISH_TOKEN")
        channels = properties("channel").map { listOf(it) }
    }

runtimeClasspath {
exclude(group = "org.slf4j", module = "slf4j-api")
signing {
certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN")
Copy link
Contributor

Choose a reason for hiding this comment

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

please revert to:

    signPlugin {
        certificateChain = environment("CERTIFICATE_CHAIN")
        privateKey = environment("PRIVATE_KEY")
        password = environment("PRIVATE_KEY_PASSWORD")
    }

showFailedStandardStreams = true
logLevel = LogLevel.LIFECYCLE
pluginVerification {
ides {
Copy link
Contributor

Choose a reason for hiding this comment

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

please revert to:

        failureLevel = listOf(INVALID_PLUGIN, COMPATIBILITY_PROBLEMS, MISSING_DEPENDENCIES )
        verificationReportsFormats = listOf(MARKDOWN, HTML)
        ides {
            recommended()
        }

also, the imports will need to be

import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask.FailureLevel.*
import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask.VerificationReportsFormats.*

repositoryUrl = properties("pluginRepositoryUrl")
}

tasks.withType<Test> {
Copy link
Contributor

Choose a reason for hiding this comment

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

please revert this block ( because of the system property to disable telemetry )

runPluginVerifier {
failureLevel = listOf(INVALID_PLUGIN, COMPATIBILITY_PROBLEMS, MISSING_DEPENDENCIES )
verificationReportsFormats = listOf(MARKDOWN, HTML)
gradleVersion = providers.gradleProperty("gradleVersion").get()
Copy link
Contributor

Choose a reason for hiding this comment

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

please revert to previous same call

untilBuild = properties("pluginUntilBuild")
//TODO inject changelog into plugin.xml change-notes
publishPlugin {
dependsOn(patchChangelog)
Copy link
Contributor

Choose a reason for hiding this comment

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

see above for generating changelog automatically.

# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType=IC
platformVersion=2023.2

Copy link
Contributor

Choose a reason for hiding this comment

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

for now, please still use the same version, then we'ell update to some new version later on.

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion=8.5
gradleVersion=8.10.2
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above, please still use gradle 8.5 ( supported with intellij gradle plugin 2.X )

kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" }
Copy link
Contributor

Choose a reason for hiding this comment

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

please fix acordingly with gradle.kts file.

}

rootProject.name = "lsp4ij"
rootProject.name = "LSP4IJ"
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to capitalize. please revert

@@ -176,7 +176,7 @@ L
<depends optional="true">com.redhat.devtools.intellij.telemetry</depends>
<depends optional="true" config-file="plugin-json.xml">com.intellij.modules.json</depends>
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="232.*"/>
<idea-version since-build="233.*"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a need to update this version ?

@sbouchet
Copy link
Contributor

@SCWells72 nice work ! sorry i did lots of comments but we will try at first to build with the same gradle and target versions, to check that the produced contents are identical.

also, for the remaning workflows, there is some changes that need to be accomplished:
IJ-latest.yml needs a task on the gradle file
IJ.yml with verification need to change from
./gradlew runPluginVerifier -Dplugin.verifier.home.dir=~/.pluginVerifier
to
./gradlew verifyPlugin -Dplugin.verifier.home.dir=~/.pluginVerifier

@SCWells72 SCWells72 marked this pull request as draft January 24, 2025 16:01
@SCWells72
Copy link
Contributor Author

SCWells72 commented Jan 24, 2025

@SCWells72 nice work !

Hi, @sbouchet. I tried to shoot you a note much earlier in this review but it doesn't look like you saw it:

#761 (comment)

As stated there, I'm not planning to take this PR forward myself. Apologies for any confusion around that. I should have opened this as a draft PR and made that more clear. But of course the review feedback is mostly stuff that needs to happen to get this ready anyway.

I say "mostly" because there are a few things that you commented on that warrant some additional explanation:

  • Regarding the change in since-build from 232 to 233, that was actually the main motivation for the move to a Gradle 2.x-based build. There are breaking JetBrains plugin SDK changes -- specifically with the TextMate Bundles plugin -- between 2023.2 and 2023.3+ that require LSP4IJ to move up the minimum supported version for certain features to be implemented without having to resort to things like reflection. So once this work is done, instead of supporting 2023.2+, it will support 2023.3+.
  • Regarding the change from lsp4ij to LSP4IJ in settings.gradle.kts, without that change, the resulting plugin distribution file name uses lsp4ij instead of LSP4IJ. That was the only way I could see to end up with the correct name.
  • As you noted, I also noticed that the plugin contents did not match completely. Some changes should be fine, e.g., the change from instrumented-lsp4ij-*.jar to lsp4ij-*.jar for the .jar inside of the .zip as that's not terribly important to users, but the way that the change notes are composed in the resulting plugin.xml file isn't correct. As you pointed out, the goal should be that, in the end, the only differences between a Gradle 1.x build-based distribution and a Gradle 2.x build-based distribution should be intentional or a side-effect of the differences between the two build systems that have no net effect on the actual distribution from an end user's perspective.

I think those were the main things. Hopefully that helps, and please let me know if you have any other questions or concerns. Otherwise I'll turn this over to you or whoever else will be doing this actual switch.

@sbouchet
Copy link
Contributor

Thanks for the explanations, i'll work on this early next week, probably by forking your PR.

@SCWells72
Copy link
Contributor Author

Superseded by #783.

@SCWells72 SCWells72 closed this Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants