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.4k stars 270 forks source link

dependency transitive issue in coding phase and running phase #1657

Open Vanco opened 2 weeks ago

Vanco commented 2 weeks ago

What happened?

I have a multi-module plugin project where one plugin project depends on the other. Let's simplify the scenario:

muti-plugin is the root gradle project. it has two subproject, plugin-base and plugin-ext. the project plugin-base export some extention point, and when published, it contain four jars in the final zip.

    └── plugin-base
        └── lib
             │   batik-all-1.17.jar
             │   plugin-base-1.0-SNAPSHOT-instrumented.jar
             │   xml-apis-ext-1.3.04.jar
             │   xmlgraphics-commons-2.9.jar

the project plugin-ext depends on plugin-base, and make use the extention point, when published, it contain one jar in the final zip.

plugin-ext
        └── lib
            │   plugin-ext-1.0-SNAPSHOT-instrumented.jar
configuration in build.gradle.kts

plugin-base/build.gradle.kts

plugins {
    id("java")
    id("org.jetbrains.kotlin.jvm") version "1.9.23"
    id("org.jetbrains.intellij.platform") version "2.0.0-beta7"
}

group = "vanstudio"
version = "1.0-SNAPSHOT"

repositories {
    maven("https://maven.aliyun.com/repository/public")
    maven("https://maven.aliyun.com/repository/gradle-plugin")
    mavenCentral()
    intellijPlatform {
        defaultRepositories()
    }
}

dependencies {
    implementation("org.apache.xmlgraphics:batik-all:1.17") {
        exclude("xml-apis")
        exclude("commons-io")
        exclude("commons-logging")
    }
    implementation("xml-apis:xml-apis-ext:1.3.04")
    intellijPlatform {
        intellijIdeaCommunity("2024.1.1")
        bundledPlugins("com.intellij.java")
        instrumentationTools()
    }
}

intellijPlatform {
    buildSearchableOptions = false
    sandboxContainer = File(providers.environmentVariable("HOME").get() + "/.sandbox")
}

plugin-ext/build.gradle.kts

plugins {
    id("java")
    id("org.jetbrains.kotlin.jvm") version "1.9.23"
    id("org.jetbrains.intellij.platform") version "2.0.0-beta7"
}

group = "vanstudio"
version = "1.0-SNAPSHOT"

repositories {
    maven("https://maven.aliyun.com/repository/public")
    maven("https://maven.aliyun.com/repository/gradle-plugin")
    mavenCentral()
    intellijPlatform {
        defaultRepositories()
        localPlatformArtifacts()
    }
}

dependencies {
    intellijPlatform {
        intellijIdeaCommunity("2024.1.1")
        bundledPlugins("com.intellij.java")
        localPlugin(project(":plugin-base"))
        instrumentationTools()
    }
}

intellijPlatform {
    buildSearchableOptions = false
    sandboxContainer = File(providers.environmentVariable("HOME").get() + "/.sandbox")
}
issue one: dependency transitive lost in coding phase

In the coding phase, the jars batik-all-1.17.jar, xml-apis-ext-1.3.04.jar, xmlgraphics-commons-2.9.jar should be visible in project plugin-ext, but in the version from 2.0.0-beta3 to 2.0.0-bata7, the transitive dependencies jars are lost.

issue two: dependent plugin plugin-base has wrong structure when unzip into sandbox in running phase

When run project plugin-ext by command gradle :plugin-ext:runIde, there should have both plugin plugin-base and plugin plugin-ext deployed into sandbox in correct structure like:

.IntelliJIDEAx0/
└── plugins
    └── plugin-base
        └── lib
             │   batik-all-1.17.jar
             │   plugin-base-1.0-SNAPSHOT-instrumented.jar
             │   xml-apis-ext-1.3.04.jar
             │   xmlgraphics-commons-2.9.jar
    └── plugin-ext
        └── lib
            │   plugin-ext-1.0-SNAPSHOT-instrumented.jar

but in the version from 2.0.0-beta3 to 2.0.0-bata7, the plugin-base deployed in wrong structure, by put four jars direct under plugins directory:

.IntelliJIDEAx0/
└── plugins
             │   batik-all-1.17.jar
             │   plugin-base-1.0-SNAPSHOT-instrumented.jar
             │   xml-apis-ext-1.3.04.jar
             │   xmlgraphics-commons-2.9.jar

in this way, the jars batik-all-1.17.jar, xml-apis-ext-1.3.04.jar, xmlgraphics-commons-2.9.jar are trade as single jar idea plugin, but it is not. and the plugin-base-1.0-SNAPSHOT-instrumented.jar has plugin.xml in it, looks like a single jar idea plugin, but it missing dependent jars. this is totally wrong.

Relevant log output or stack trace

No response

Steps to reproduce

I attached the muti-plugin demo project code for demonstrate both of thease bugs. muti-plugin.zip

Gradle IntelliJ Plugin version

2.0.0-beta7

Gradle version

8.6

Operating System

None

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

No response