JetBrains / sbt-idea-plugin

Develop IntelliJ plugins with Scala and SBT
Apache License 2.0
95 stars 26 forks source link

can't packageLibraryMappings for multiple versions of the same library #110

Open unkarjedy opened 2 years ago

unkarjedy commented 2 years ago
  1. open Scala Plugin project
  2. go to runtimeDependencies project definition
  3. in packageLibraryMappings add
        Dependencies.scala3SbtBridge_300 -> Some("lib/jps/scala3-sbt-bridge-3.0.0.jar"),
        Dependencies.scala3SbtBridge_302 -> Some("lib/jps/scala3-sbt-bridge-3.0.2.jar"),
    val scala3SbtBridge_300 = "org.scala-lang" % "scala3-sbt-bridge" % "3.0.0"
    val scala3SbtBridge_302 = "org.scala-lang" % "scala3-sbt-bridge" % "3.0.2-RC1-bin-SNAPSHOT"

    (I have a locally-published version of scala3-sbt-bridge 3.0.2, published from dotty repository)

    val runtime: Seq[ModuleID] = Seq(
    sbtLaunch,
    compilerBridgeSources_2_10,
    compilerBridgeSources_2_11,
    compilerBridgeSources_2_13,
    scala3SbtBridge_300,
    scala3SbtBridge_302,
    )
  4. reimport the project, see that scala-plugin-for-ultimate\.idea\artifacts\scalaUltimate.xml only contains item for one artifact:
    <element id="archive" name="scala3-sbt-bridge-3.0.2.jar">
    <element id="extracted-dir" path="...\.ivy2\local\org.scala-lang\scala3-sbt-bridge\3.0.2-RC1-bin-SNAPSHOT\jars\scala3-sbt-bridge.jar" path-in-jar="/" />
    </element>

    so packaged Scala plugin will contain only one jar

unkarjedy commented 2 years ago

I tracked down the bug to org.jetbrains.sbtidea.packaging.structure.sbtImpl.SbtPackageProjectData.cp: it contains deduplicated entries, which only contains single version of scala3-sbt-bridge library. Looks like it comes from sbt behaviour: it evicts libraries in managedClasspath which is passed to SbtPackageProjectData.cp

I stopped my investigation, cause I am already too far from my original task. For now, I use a hack: create a new runtimeDependencies2 project with it's own mapping for 3.0.2 version