[Gradle] buildPlugin packages maven test scoped deps : 550K plugin jar becomes 20M

Answered

Hi all,

My plugin uses a locally built maven dependency - call it dependency D. Everything compiles just fine and the different Gradle classpath entries (compileClasspath, ...) look as I would expect (having used Maven so far).

Unfortunately the plugin jar created by the buildPlugin task packages ALL the maven test dependencies of dependency D. The resulting jar is therefore way too big with 20MB where it could be much less. I have no experience with Gradle and am therefore wondering whether there is a way avoid this. Is this behaviour specific to the buildPlugin task, is there some Gradle-way to alter this? Any pointer would be much appreciated. The relevant version info can be found below - I used the latest version as found in the documentation.

Regards,

Johan

 

plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.3.72"
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
id("org.jetbrains.intellij") version "0.4.21"
}
5 comments
Comment actions Permalink

Johan, can you please share the full Gradle configuration? 

0
Comment actions Permalink

Hi Jakub,

Looking at it now I wonder whether the name of my Maven dep my.dependency.:lib:1.0-SNAPSHOT conflicts with the Gradle definition. Is that my Gradle-newbie mistake?

Regards,

Joha

 

plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.3.72"
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
id("org.jetbrains.intellij") version "0.4.21"
}

group = "my.dependency.lib"
version = "1.0-SNAPSHOT"

repositories {
mavenCentral()
mavenLocal()
jcenter()
maven {
url = uri("https://dl.bintray.com/jetbrains/intellij-third-party-dependencies/")
}
}

dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation("com.jetbrains.intellij.platform:jps-build:193.5964")
implementation("my.dependency.lib:1.0-SNAPSHOT"){
exclude(group = "commons-collections", module = "commons-collections")
}
}

// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version = "2019.3.4"
}
tasks {
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
}
tasks.getByName<org.jetbrains.intellij.tasks.PatchPluginXmlTask>("patchPluginXml") {
changeNotes("""
Add change notes here.<br>
<em>most HTML tags may be used</em>""")
}
0
Comment actions Permalink

So the jar file in the build/libs/ directory is fine. But the zip file in build/distributions/ is way too big. It contains all the rest including the jps jars. Or is this not the place to look for the plugin's zip file? Is that my mistake? In the DevKit days it was just matter of "Preparing All Plugin modules for delpoyment".

In the meanwhile I tired:

  •  I changed the group in de Gradle file with no effect
  • Update to intellij { version = "2020.1" } still no difference

Regards,

Johan

0
Comment actions Permalink

Johan, sorry for the late reply. Have you tried to add a dependency to the java plugin in your Gradle configuration instead of adding the dependency to JPS manually?

intellij {
  version = '2020.1'
  plugins = ['java']
}

For more details, please check the Modules Specific to Functionality section in our docs.

<depends>com.intellij.java</depends>

is also necessary as you already know.

 

The point of not attaching the JPS manually is that you have it already provided with the SDK 2020.1 (which is 193.6911.18). Attaching it again with another version: 193.5964 forces the Gradle plugin to explicitly bundle it within your output artifact.

0
Comment actions Permalink

Many thanks  for your Jakub!

Best regards,

Johan

0

Please sign in to leave a comment.