sbt / sbt-eclipse

Plugin for sbt to create Eclipse project definitions
Apache License 2.0
716 stars 168 forks source link

Wrong defaults for CrossProject builds in EclipseKeys.eclipseOutput #330

Open Bathtor opened 7 years ago

Bathtor commented 7 years ago

There appears to be an issue with shared sources in ScalaJS crossProject builds with Eclipse.

Consider a standard setup of

lazy val test = crossProject.in(file(".")).
  settings(
    name := "Test",
    EclipseKeys.useProjectId := true
  ).
  jvmSettings(
    libraryDependencies += "org.scala-js" %% "scalajs-stubs" % scalaJSVersion % "provided"
  ).
  jsSettings(
    libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "0.9.1"
  )

If I import into eclipse like this, Eclipse finds the shared folders, but it sets their output folders to the source folder. See (from .classpath in the JS project):

  <classpathentry kind="src" path="src/main/scala"/>
  <classpathentry kind="src" path="src/main/resources"/>
  <classpathentry kind="src" path="src/test/scala"/>
  <classpathentry kind="src" path="src/test/resources"/>
  <classpathentry output="-Users-lkroll-Documents-Programming-test-shared-src-main-scala" kind="src" path="-Users-lkroll-Documents-Programming-test-shared-src-main-scala"/>
  <classpathentry output="-Users-lkroll-Documents-Programming-test-shared-src-test-scala" kind="src" path="-Users-lkroll-Documents-Programming-test-shared-src-test-scala"/>

When I set eclipseOutput manually to some other folder, it generates the correct output, as seen below.

lazy val test = crossProject.in(file(".")).
  settings(
    name := "Test",
    EclipseKeys.useProjectId := true,
    EclipseKeys.eclipseOutput := Some("./etarget")
  ).
  jvmSettings(
    libraryDependencies += "org.scala-js" %% "scalajs-stubs" % scalaJSVersion % "provided"
  ).
  jsSettings(
    libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "0.9.1"
  )
<classpathentry output="./etarget" kind="src" path="src/main/scala"/>
  <classpathentry output="./etarget" kind="src" path="src/main/resources"/>
  <classpathentry output="./etarget" kind="src" path="src/test/scala"/>
  <classpathentry output="./etarget" kind="src" path="src/test/resources"/>
  <classpathentry output="./etarget" kind="src" path="-Users-lkroll-Documents-Programming-test-shared-src-main-scala"/>
  <classpathentry output="./etarget" kind="src" path="-Users-lkroll-Documents-Programming-test-shared-src-test-scala"/>

I don't know how sbt-eclipse decides what output path to default to when eclipseOutput is None, but at least in this case it's not the right thing. This might, of course, be an issue on the ScalaJS plugin side, I don't know.

Edit: Sorry forgot to write versions:

Blaisorblade commented 6 years ago

Possibly affected by fix to #352 (in https://github.com/sbt/sbteclipse/pull/355/files) since that's also about eclipseOutput defaults?

Bathtor commented 6 years ago

I just tried with sbteclipse 5.2.4 (which I think includes that commit) and the issue still persists.