Skip to content

Scala library exclusion doesn't work with Scala 3 #544

Open
@sangamon

Description

@sangamon

It looks like neither assembleArtifact := false nor _.withIncludeScala(false) have any effect in Scala 3 projects.

To reproduce, I created a Scala 3 project from scratch via sbt new scala/scala3.g8. (Currently, this yields scala3Version = "3.5.2" and sbt.version=1.10.5.) I create a project/plugins.sbt:

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.3.0")

Adding either

assemblyPackageScala / assembleArtifact := false,

or

assembly / assemblyOption ~= {
      _.withIncludeScala(false)
    },

to the project settings, as described in the docs, doesn't seem to have any effect:

$ sbt clean assembly && jar tfv target/scala-3.5.2/sbtass-assembly-0.1.0-SNAPSHOT.jar | grep 'scala/' | head
[info] welcome to sbt 1.10.5 (Eclipse Adoptium Java 21.0.1)
[...]
[info] Built: [...]/target/scala-3.5.2/sbtass-assembly-0.1.0-SNAPSHOT.jar
[...]
     0 Fri Jan 01 00:00:00 CET 2010 scala/
  1227 Fri Jan 01 00:00:00 CET 2010 scala/$times$colon$.class
  1380 Fri Jan 01 00:00:00 CET 2010 scala/$times$colon.class
  1512 Fri Jan 01 00:00:00 CET 2010 scala/$times$colon.tasty
  3679 Fri Jan 01 00:00:00 CET 2010 scala/CanEqual$.class
  [...]

Explicitly filtering files whose path starts with "scala" works, though, so assembly config options seem to be picked up:

assembly / assemblyMergeStrategy := {
  case PathList(ps @ _*) if ps.headOption == Some("scala") => MergeStrategy.discard
  case x =>
    val oldStrategy = (ThisBuild / assemblyMergeStrategy).value
    oldStrategy(x)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions