intellij-platform-gradle-plugin icon indicating copy to clipboard operation
intellij-platform-gradle-plugin copied to clipboard

Take testFramework artifacts directly from Maven repository

Open chashnikov opened this issue 4 years ago • 5 comments

Currently gradle-intellij-plugin adds testFramework*.jar artifacts from the IDE distribution to the dependencies. However these JARs are available as separate artifact in IntelliJ artifacts repository for some time already. So we plan to remove them to reduce size of the distribution. In order to provide smooth migration for the plugin developers, it makes sense to automatically include com.jetbrains.intellij.platform:test-framework to testCompile dependencies.

chashnikov avatar Apr 17 '20 11:04 chashnikov

It's now relevant for GoLand as well. A user needs to do the following to get a relevant test framework.

repositories {
    maven("https://cache-redirector.jetbrains.com/intellij-dependencies")
}
dependencies {
    testImplementation("com.jetbrains.intellij.go:go-test-framework:GOLAND-212-SNAPSHOT") {
        exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
        exclude("org.jetbrains.kotlin", "kotlin-reflect")
        exclude("com.jetbrains.rd", "rd-core")
        exclude("com.jetbrains.rd", "rd-swing")
        exclude("com.jetbrains.rd", "rd-framework")
    }
}

It'd be nice to do it automatically for them.

artspb avatar May 20 '21 11:05 artspb

com.jetbrains.intellij.go doesn't seem to be a directory under https://cache-redirector.jetbrains.com/intellij-dependencies

tamj0rd2 avatar Dec 21 '22 19:12 tamj0rd2

@tamj0rd2 What are you trying to achieve?

artspb avatar Dec 22 '22 12:12 artspb

Related issue: although lib/testFramework.jar is correctly excluded from the production runtime classpath after https://github.com/JetBrains/gradle-intellij-plugin/commit/a10955810, it still exists on the compile classpath. This makes it easy to get NoClassDefFoundError at runtime. You can reproduce this by referencing com.intellij.testFramework.PlatformTestUtil from some production sources in a plugin.

Let me know if you'd like a separate issue filed for this.

gharrma avatar Feb 28 '23 22:02 gharrma

Let me know if you'd like a separate issue filed for this.

@gharrma I think it's better to create a separate issue about that.

chashnikov avatar Apr 06 '23 09:04 chashnikov

With the IntelliJ Platform Gradle Plugin 2.0, the testFramework.jar bundled with IDEs is no longer attached to the project — it may be even removed from the distribution in the future. A new approach is introduced, which requires specifying an explicit dependency on the Test Framework in the project dependencies, like:

repositories {
  mavenCentral()

  intellijPlatform {
    defaultRepositories()
  }
}

dependencies {
  intellijPlatform {
    intellijIdeaCommunity("...")

    testFramework(TestFrameworkType.JUnit4)
  }

  // other dependencies, e.g., 3rd-party libraries
}

The testFramework helper method is a shorthand for adding Test Framework to the project (JUnit4 or JUnit5 platform variants), but also plugin/technology-specific variants, like Java, Maven, ReSharper, etc.

See Dependencies Extension and TestFrameworkType type for more details.

hsz avatar Mar 14 '24 20:03 hsz