JetBrains / intellij-platform-gradle-plugin

Gradle plugin for building plugins for IntelliJ-based IDEs
https://plugins.jetbrains.com/docs/intellij/gradle-prerequisites.html
Apache License 2.0
1.44k stars 272 forks source link

Rider test-framework is missing on build #1793

Open jezzsantos opened 1 month ago

jezzsantos commented 1 month ago

What happened?

Since upgrading from 1.16.1 to 2.1.0, and upgrading to 2024.1 of Rider, I am unable to compile and run my tests. image

I am unable to import com.jetbrains.rider.test.base.BaseTestWithSolution; and use the BaseTestWithSolution type.

I know a bunch has changed with this new version, becuase this type used to exist in the testFramework,jar in com.jetbrains:riderRD:2023.3 image

That jar file is no longer loaded by gradle for some reason. I have done what I see mentioned in the docs to my gradle file, but I have had no luck importing that type.

Here is the top of my build.gradle (groovy) file:

import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.changelog.Changelog
import org.jetbrains.intellij.platform.gradle.TestFrameworkType

import java.text.SimpleDateFormat

plugins {
    id 'java'
    id 'org.jetbrains.intellij.platform' version "${intellijPluginVersion}"
    id 'org.jetbrains.changelog' version '2.0.0'
    id 'me.filippov.gradle.jvm.wrapper' version '0.14.0'
}

apply plugin: 'org.jetbrains.changelog'

group "${thisPluginGroup}"
version "${thisPluginVersion}"

java {
    sourceCompatibility = JavaVersion.VERSION_17
}

repositories {
    maven { setUrl("https://cache-redirector.jetbrains.com/maven-central") }

    intellijPlatform {
        defaultRepositories()
        jetbrainsRuntime()
    }
}

dependencies {
    implementation 'com.google.code.gson:gson:2.10'
    implementation 'com.microsoft.azure:applicationinsights-core:2.6.4'

    intellijPlatform {
        jetbrainsRuntime()
        def version = providers.gradleProperty("platformVersion").get()
        rider(version)
        instrumentationTools()

        testFramework TestFrameworkType.Bundled.INSTANCE
    }

    testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
    testImplementation 'org.mockito:mockito-core:4.8.0'
    testImplementation 'org.testng:testng:7.7.0'
    testRuntimeOnly 'org.junit.support:testng-engine:1.0.4'
}

Relevant log output or stack trace

No response

Steps to reproduce

Rider plugin Upgrade intellijplugin from 1.16.1 to 2.1.0 Upgrade Gradle from 8.5 to 8.10.2 Upgrade platformVersion from 2023.3 to 2024.1

Gradle IntelliJ Plugin version

2.1.0

Gradle version

8.10.2

Operating System

Windows

Link to build, i.e. failing GitHub Action job

No response

AlexanderBartash commented 1 month ago

Does the jar exist? Related code can be found here:

https://github.com/JetBrains/intellij-platform-gradle-plugin/blob/a4e556c9e1162466f8c0fa7d042462661b835f49/src/main/kotlin/org/jetbrains/intellij/platform/gradle/extensions/IntelliJPlatformDependenciesHelper.kt#L502

jezzsantos commented 1 month ago

Thx @AlexanderBartash Sorry, it's not obvious to me where to look. Can you direct me? (I am on Windows)

just for the record my test task list declared like this, which I am not confident is correct for version 2.0 of the intellij plugin


tasks {
    wrapper {
        gradleVersion = "${gradleVersion}"
    }

    publishPlugin {
        token.set(System.getenv("ORG_GRADLE_PROJECT_intellijPublishToken"))
        channels.set(List.of(("${thisPluginVersion}".split("-").length > 1) ? "${thisPluginVersion}".split("-")[1] : "default"))
        var versionExists = changelog.has("${thisPluginVersion}")
        if (versionExists) {
            patchPluginXml.changeNotes.set(changelog.renderItem(
                    changelog
                            .get("${thisPluginVersion}")
                            .withHeader(false)
                            .withEmptySections(false),
                    Changelog.OutputType.HTML
            ))
        }
    }

    patchPluginXml {
        changeNotes.set(changelog.renderItem(
                changelog
                        .getUnreleased()
                        .withHeader(false)
                        .withEmptySections(false),
                Changelog.OutputType.HTML
        ))
    }

    test {
        systemProperty "LOCAL_ENV_RUN", "true" //For use with 'BaseTestWithSolution' and TestNG
        useJUnitPlatform()
        minHeapSize = "512m"
        maxHeapSize = "1024m"
        testLogging {
            showStandardStreams = true
            exceptionFormat = TestExceptionFormat.FULL
        }
    }

    runIde {
        autoReload = false
        maxHeapSize = "2G"
    }
}

full code can be found here: https://github.com/jezzsantos/automate.plugin-rider/blob/main/build.gradle

AlexanderBartash commented 1 month ago

@jezzsantos See https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-types.html#TestFrameworkType

Using Bundled
The Bundled type should not be used unless it is necessary, like in the case of [Rider](https://plugins.jetbrains.com/docs/intellij/rider.html), as its test-framework is not published as an artifact.

Btw, not sure if you saw this https://github.com/JetBrains/intellij-platform-plugin-template may be useful.

AlexanderBartash commented 1 month ago

I guess this plugin still could log a warning or something, would save you time.

jezzsantos commented 1 month ago

Thanks @AlexanderBartash Sorry, none of what you have given here has helped. I believe I should be using testFramework TestFrameworkType.Bundled.INSTANCE since this is a Rider plugin, unless I am mistaken.?

Do you think I have structured the test task properly for version 2.10. of the plugin? here in: https://github.com/jezzsantos/automate.plugin-rider/blob/main/build.gradle

AlexanderBartash commented 1 month ago

@jezzsantos According to this documentation https://github.com/JetBrains/intellij-platform-gradle-plugin/issues/1793#issuecomment-2409476513 the missing jar is expected behavior. I have never tried to create any plugins for Rider, but if that is so, most likely you should try to use testFramework(TestFrameworkType.Platform) or other option.

hsz commented 1 month ago

It turned out that Rider doesn't distribute the testFramework.jar with the Rider installers. Investigating.

AlexanderBartash commented 1 month ago

The fix https://github.com/jezzsantos/automate.plugin-rider/pull/53/files