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

Transitive dependencies of a intellijPlatformPluginModule are lost #1655

Closed
abrooksv opened this issue Jun 14, 2024 · 8 comments
Closed

Transitive dependencies of a intellijPlatformPluginModule are lost #1655

abrooksv opened this issue Jun 14, 2024 · 8 comments
Labels
Milestone

Comments

@abrooksv
Copy link
Contributor

abrooksv commented Jun 14, 2024

What happened?

Using intellijPlatformPluginModule on a module that brings in 3rd party libs causes the lips to be lost when building the final zip

Relevant log output or stack trace

No response

Steps to reproduce

  • Have moduleA depend on a 3rd party jar such as Commonmark
  • Have top level project use intellijPlatformPluginModule(project(":moduleA"))
  • Run :buildPlugin, see Zip contain the merged moduleA's jar into the composedJar, but the zip is missing the commonmark jar as a sibling jar (since composeJar isn't supposed to do any shadowing on 3rd party libs)

Doing the following works-ish by bringing in the transitive deps:

    implementation(project(":moduleA")) {
        intellijPlatformPluginModule(this)
    }

but it composes the jar from moduleA and includes the moduleA-base.jar into the Zip which seems incorrect as well

Gradle IntelliJ Plugin version

2.0.0-beta7

Gradle version

8.8

Operating System

None

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

No response

@abrooksv abrooksv added the bug label Jun 14, 2024
@YannCebron YannCebron added this to the 2.0 milestone Jul 1, 2024
@hsz
Copy link
Member

hsz commented Jul 12, 2024

@abrooksv could you please verify it once again with 2.0.0-beta9?

@abrooksv
Copy link
Contributor Author

Yes, it is still broken

@hsz
Copy link
Member

hsz commented Jul 12, 2024

I have just verified that on my local, and it seems to be working just fine.

The folowing is required to be present in the root module:

dependencies {
    intellijPlatform {
        implementation(project(":module")) {
            pluginModule(this)
        }
    }
}

The implementation(project(":module")) part is adding your module to the implementation configuration, and with pluginModule (AKA intellijPlatformPluginModule) you just mark this dependency as to-be-bundled within the main Jar.

With that, the :module Jar is consumed into the : Jar archive, and all :module transitive dependencies are present in the lib directory.
The root jar is also properly composed with the final jar, not the -base one.

@abrooksv
Copy link
Contributor Author

abrooksv commented Jul 12, 2024

I hacked your test to show it being broken, seems to only be in certain usage configuration:

Subject: [PATCH] Example of broken
---
Index: src/integrationTest/resources/multi-module/submodule/build.gradle.kts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/integrationTest/resources/multi-module/submodule/build.gradle.kts b/src/integrationTest/resources/multi-module/submodule/build.gradle.kts
--- a/src/integrationTest/resources/multi-module/submodule/build.gradle.kts	(revision 63cd4ed561e78735d0413200f7139bbc71014cf0)
+++ b/src/integrationTest/resources/multi-module/submodule/build.gradle.kts	(date 1720820382923)
@@ -28,3 +28,7 @@
         instrumentationTools()
     }
 }
+
+intellijPlatform {
+    instrumentCode = false
+}
\ No newline at end of file
Index: src/integrationTest/resources/multi-module/base/build.gradle.kts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/integrationTest/resources/multi-module/base/build.gradle.kts b/src/integrationTest/resources/multi-module/base/build.gradle.kts
--- a/src/integrationTest/resources/multi-module/base/build.gradle.kts	(revision 63cd4ed561e78735d0413200f7139bbc71014cf0)
+++ b/src/integrationTest/resources/multi-module/base/build.gradle.kts	(date 1720822114919)
@@ -37,4 +37,5 @@
 
 intellijPlatform {
     buildSearchableOptions = false
+    instrumentCode = false
 }
Index: src/integrationTest/resources/multi-module/ext/build.gradle.kts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/integrationTest/resources/multi-module/ext/build.gradle.kts b/src/integrationTest/resources/multi-module/ext/build.gradle.kts
--- a/src/integrationTest/resources/multi-module/ext/build.gradle.kts	(revision 63cd4ed561e78735d0413200f7139bbc71014cf0)
+++ b/src/integrationTest/resources/multi-module/ext/build.gradle.kts	(date 1720822124273)
@@ -27,8 +27,10 @@
         instrumentationTools()
 
         localPlugin(project(":base"))
-        pluginModule(implementation(project(":submodule")))
+//        pluginModule(implementation(project(":submodule")))
     }
+
+    intellijPlatformPluginModule(project(":submodule"))
 
     implementation(project(":raw"))
     implementation("org.jetbrains:markdown:0.7.3")
@@ -36,4 +38,5 @@
 
 intellijPlatform {
     buildSearchableOptions = false
+    instrumentCode = false
 }
Index: src/integrationTest/kotlin/org/jetbrains/intellij/platform/gradle/MultiModuleIntegrationTest.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/integrationTest/kotlin/org/jetbrains/intellij/platform/gradle/MultiModuleIntegrationTest.kt b/src/integrationTest/kotlin/org/jetbrains/intellij/platform/gradle/MultiModuleIntegrationTest.kt
--- a/src/integrationTest/kotlin/org/jetbrains/intellij/platform/gradle/MultiModuleIntegrationTest.kt	(revision 63cd4ed561e78735d0413200f7139bbc71014cf0)
+++ b/src/integrationTest/kotlin/org/jetbrains/intellij/platform/gradle/MultiModuleIntegrationTest.kt	(date 1720821902097)
@@ -3,6 +3,8 @@
 package org.jetbrains.intellij.platform.gradle
 
 import org.jetbrains.intellij.platform.gradle.Constants.Tasks
+import java.nio.file.FileSystems
+import kotlin.io.path.listDirectoryEntries
 import kotlin.test.Test
 
 class MultiModuleIntegrationTest : IntelliJPlatformIntegrationTestBase(
@@ -11,8 +13,18 @@
 
     @Test
     fun `ext plugin uses base plugin from zip distribution`() {
-        build(":ext:" + Tasks.BUILD_PLUGIN, projectProperties = defaultProjectProperties) {
-
+        build(
+            gradleVersion = gradleVersion,
+            fail = false,
+            assertValidConfigurationCache = false,
+            ":ext:" + Tasks.BUILD_PLUGIN,
+            projectProperties = defaultProjectProperties,
+        ) {
+            val pluginZip = dir.resolve("ext/build/distributions/ext.zip")
+            FileSystems.newFileSystem(pluginZip, emptyMap<String, Any>()).use { zipFile ->
+                val files = zipFile.getPath("ext/lib").listDirectoryEntries()
+                println("Files: $files")
+            }
         }
     }
 }

TL;DR:
pluginModule(implementation(project(":submodule"))) works

Configuration cache entry stored.
Files: [ext/lib/markdown-jvm-0.7.3.jar, ext/lib/ext.jar, ext/lib/raw.jar, ext/lib/kotlin-stdlib-2.0.0.jar, ext/lib/annotations-13.0.jar, ext/lib/annotation-desktop-1.8.0-alpha01.jar, ext/lib/dummy-0.1.2.jar]
> Task :integrationTest

intellijPlatformPluginModule(project(":submodule")) is broken

BUILD SUCCESSFUL in 8s
33 actionable tasks: 33 executed
Configuration cache entry stored.
Files: [ext/lib/markdown-jvm-0.7.3.jar, ext/lib/ext.jar, ext/lib/raw.jar, ext/lib/kotlin-stdlib-2.0.0.jar, ext/lib/annotations-13.0.jar, ext/lib/annotation-desktop-1.8.0-alpha01.jar]
> Task :integrationTest

Notice that dummy-0.1.2.jar is missing

@hsz
Copy link
Member

hsz commented Jul 12, 2024

intellijPlatformPluginModule(project(":submodule")) is broken

It's expected to be broken as you're not supposed to use it alone without implementation!

@abrooksv
Copy link
Contributor Author

Can I go hide in shame now?

@hsz
Copy link
Member

hsz commented Jul 12, 2024

The intellijPlatformPluginModule() configuration (or its alias: intellijPlatform { pluginModule() }) is just a marker to highlight what dependencies should be consumed into the main jar (without their transitive dependencies).
You still need to add such dependencies to the implementation() configuration to make them present in the actual compilation classpath.

And please don't worry about that — this is new and confusing. The documentation still doesn't cover that scenario - that'll be properly described next week.

@abrooksv
Copy link
Contributor Author

Ok, I think we can close this then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants