سؤال

How can I get the sbt-eclipse plugin to ignore adding/creating the src/main/java and src/test/java to the eclipse .classpath?

I dont have these folders and when I run >eclipse the eclipse-sbt-plugin creates those folders and adds to eclipse .classpath.

build.sbt file

name := "myproject"

version := "1.0"

scalaVersion := "2.10.1"

resolvers += "google-api-services" at "http://google-api-client-libraries.appspot.com/mavenrepo"

libraryDependencies += "org.scalatest" %% "scalatest" % "1.9.1" % "test"

libraryDependencies += "junit" % "junit" % "4.10" % "test"

libraryDependencies += "com.novocode" % "junit-interface" % "0.10-M1" % "test"

EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.Unmanaged, EclipseCreateSrc.Source, EclipseCreateSrc.Resource)

projects/plugins.sbt file

resolvers += Classpaths.typesafeResolver

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.2.0")

Thanks.

هل كانت مفيدة؟

المحلول

This is the default behavior of sbt to have javaSources and scalaSources in classpath. Them being in eclipse is just a consequence.

It can be changed with (for only java project):

unmanagedSourceDirectories in Compile := (javaSource in Compile).value :: Nil

or (for only scala project)

unmanagedSourceDirectories in Compile := (scalaSource in Compile).value :: Nil

or just remove them all

unmanagedSourceDirectories in Compile := Nil

You can do it like this:

unmanagedSourceDirectories in Test <<= (sourceDirectory){ src => src / "somerandompathfortestsources" :: Nil}

To see what they are (in sbt console):

show unmanagedSourceDirectories
show sources
...

To see what makes them:

inspect unmanagedSourceDirectories
...

More about: http://www.scala-sbt.org/0.13.0/docs/Detailed-Topics/Java-Sources.html

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top