1

I've used sbt-eclipse in the past to successfully import a simple sbt project into eclipse. I'm now trying to leverage the CrossProject mechanism of sbt to use the Scala-JS environment (makes 2 subprojects in sbt--one for Javascript and one for JVM code). The recommendation (see SBT docs link here) is to add the setting 'EclipseKeys.useProjectId := true' in the build.sbt file to support importing (now) 2 projects into one eclipse project. I then give the 'eclipse' command in a running SBT session to create my eclipse project and then launch eclipse and attempt to import this new project. When I do this, the import dialog wizard in eclipse does show me two sub-projects, but when I try to finish the import, eclipse complains that the project already exists and I get two strange looking links in my eclipse project that seem to do nothing.

What is the correct procedure for getting a CrossProject sbt build into eclipse?

bjenkins001
  • 141
  • 1
  • 9
  • Could you try this again after cleaning your sbt build and your eclipse? If that really doesn't work, it is a problem. – gzm0 Jul 10 '15 at 16:56
  • When I do this, I get the error message "/SJSTut already exists" when importing. Am I missing something? – bjenkins001 Jul 10 '15 at 19:55
  • It seems that your sbt did not pick up the `useProjectId` setting (if you didn't add it, the error is expected). Did you `reload` sbt? – gzm0 Jul 10 '15 at 20:12
  • @gzm0 Adding `EclipseKeys.useProjectId :- true` does not help. It does not use the project id, but continues to use the main project setting name, so, again, I have 2 projects with the same name. Do you happen to have a simple test `build.sbt` file that works as expected? – bjenkins001 Jul 11 '15 at 18:51
  • Oh... that is bad... What version of the eclipse plugin are you using? – gzm0 Jul 13 '15 at 20:49

1 Answers1

0

Ok, so it seems eclipse did not like that I had only one 'name' for the project that was in the shared settings area of the build.sbt I had this:

lazy val sp = crossProject.in(file(".")).
settings(
  version := "0.1",
  name := "SJSTut",
  scalaVersion := "2.11.7"
).
jvmSettings(
  // Add JVM-specific settings here
  libraryDependencies ++= Seq(...)
).
jsSettings(
  // Add JS-specific settings here
  libraryDependencies ++= Seq(...)
)

and what I should have done was this:

lazy val sp = crossProject.in(file(".")).
settings(
  version := "0.1",
  scalaVersion := "2.11.7"
).
jvmSettings(
  // Add JVM-specific settings here
  name := "SJSTutJVM",
  libraryDependencies ++= Seq(...)
).
jsSettings(
  // Add JS-specific settings here
  name := "SJSTutJS",
  libraryDependencies ++= Seq(...)
)

Note the removal of the 'name' assignment from settings and instead, placements into both the jvmSettings and jsSettings area with uniquely different names.

Now I'm able to pull this into eclipse (as 2 separate projects). If anyone else has a better setup, I'd love to hear about it.

sjrd
  • 21,805
  • 2
  • 61
  • 91
bjenkins001
  • 141
  • 1
  • 9
  • 2
    The problem with doing this, is that since you have different names now, the projects will be published under different artifact names. – gzm0 Jul 10 '15 at 16:56