-
Notifications
You must be signed in to change notification settings - Fork 1k
Packages including "scala-library" in its name cannot be imported by other projects. #7511
Copy link
Copy link
Closed
Description
steps
Trying to create a package with a name including the string scala-library in it, results in a failure when trying to use that package from another project.
Details
A "library" project defined as
// build.sbt
import sbt.file
lazy val root =
Project(id = "my-scala-library", base = file("."))
.settings(
name := "my-scala-library-that-fails",
scalaVersion := "2.13.12",
organization := "com.myorg",
)with just one file
// src/main/scala/com/myorg/Lib.scala
package com.myorg
object Lib {
def MyFunc() = 1
}and a project trying to use it
// build.sbt
import sbt.file
lazy val foo =
Project(id = "foo", base = file("."))
.settings(
name := "foo",
organization := "com.myorg",
scalaVersion := "2.13.12",
libraryDependencies ++= Seq(
"com.myorg" %% "my-scala-library-that-fails" % "0.1.0-SNAPSHOT",
),
resolvers += Resolver.mavenLocal
)// src/main/scala/foo/Foo.scala
package foo
import com.myorg.Lib
object Foo {
def main(args: Array[String]) = {
println(Lib.MyFunc())
}
}And running
sbt publishM2
on the library, and
sbt compile
on the consumer results in a failure
problem
❯ sbt compile
[info] welcome to sbt 1.9.9 (Homebrew Java 21.0.2)
[info] loading project definition from .../consumer/project
[info] loading settings for project foo from build.sbt ...
[info] set current project to foo (in build file:.../consumer/)
[info] Executing in batch mode. For better performance use sbt's shell
[info] compiling 1 Scala source to .../consumer/target/scala-2.13/classes ...
[error] .../consumer/src/main/scala/foo/Foo.scala:3:12: object myorg is not a member of package com
[error] import com.myorg.Lib
[error] ^
[error] .../consumer/src/main/scala/foo/Foo.scala:7:13: not found: value Lib
[error] println(Lib.MyFunc())
[error] ^
[error] two errors found
[error] (Compile / compileIncremental) Compilation failed
expectation
I'm able to import symbols from the package
notes
I tried looking if this behavior is intended, and could not find anything.
If the package name for the library is something else like my-scala-lib-that-fails, then it works without a problem.
Reactions are currently unavailable