Closed DavidPerezIngeniero closed 3 months ago
The issue you're encountering with the _3
suffix being appended to your Java subproject (e.g., oda
) likely arises because SBT is trying to resolve dependencies for a Scala version that is not relevant to your Java subprojects.
Here are steps to resolve this:
Define Java Subprojects Correctly: Make sure to define your Java subprojects without any Scala settings. You can do this by ensuring they do not have a Scala version defined and by specifying the projects as pure Java.
Set Up Dependencies Properly: Ensure that your Scala subproject depends on the Java subprojects without appending the Scala version suffix.
Here is an example build.sbt
that shows how to define and configure such a setup:
build.sbt
lazy val root = (project in file("."))
.aggregate(myScalaProject, oda)
.settings(
name := "root",
version := "0.1.0-SNAPSHOT"
)
lazy val myScalaProject = (project in file("myScalaProject"))
.settings(
name := "myScalaProject",
version := "0.1.0-SNAPSHOT",
scalaVersion := "2.13.8",
libraryDependencies ++= Seq(
// Add your Scala dependencies here
)
)
.dependsOn(oda)
lazy val oda = (project in file("oda"))
.settings(
name := "oda",
version := "0.1.0-SNAPSHOT",
crossPaths := false // This disables Scala version suffix
)
oda/build.sbt
Since oda
is a pure Java project, it should not require any special Scala configuration.
name := "oda"
version := "0.1.0-SNAPSHOT"
crossPaths := false
myScalaProject/build.sbt
For the Scala subproject, make sure it properly depends on the Java subproject without adding a Scala version suffix.
name := "myScalaProject"
version := "0.1.0-SNAPSHOT"
scalaVersion := "2.13.8"
libraryDependencies ++= Seq(
// Add your Scala dependencies here
)
dependsOn(oda)
After setting up your build.sbt
files as above, run the following commands in your SBT shell to clean and reload the project:
sbt clean reload
By properly configuring the cross paths and dependencies, SBT should not append the _3
suffix to your Java projects, and the migration should proceed without errors related to Scala version suffixes.
As pointed out by @Vinaypraba1998 the workaround is to set crossPaths := false
in your Java project.
I'd like to migrate a SBT project that has one Scala subproject that depends on several Java projects with no Scala.
For example
oda
is a Java subproject, and i see complains like:when running:
Why ithe _3 suffix is added to a project that doesn't use Scala at all? Any workaround please?