[sbteclipse] Skip some source entries in the Eclipse project

167 views
Skip to first unread message

Vlad Ureche

unread,
Feb 7, 2012, 8:34:19 PM2/7/12
to simple-b...@googlegroups.com
[cross-posting from scala-tools mailing list]

Hello everyone,

I have a newbie question about sbteclipse: In the project I am working on, there are Scala sources but no Java sources at all. Is there a way to configure sbteclipse not to generate project source entries for Java?
The things I tried, without success:
 - setting the javaSources in {Compile. Test} to Nil -- the setting expects a java.io.File, and will only settle for that
 - messing with the sbteclipse createSrc setting, which either selects all sources or none

Is there a way to instruct sbteclipse to skip the Java sources in the Eclipse project?

Thanks,
Vlad

Heiko Seeberger

unread,
Feb 8, 2012, 12:07:38 AM2/8/12
to simple-b...@googlegroups.com
Vlad,

Your tries were not too bad ;-)

EclipseKey.createSrc is of no use here, but the sbt settings will help. You already spotted javaSources, but that cannot be "nilled", as it is no sequence. If you look at the result of 

> inspect java-source                 
[info] Setting: java.io.File = /Users/heiko/tmp/test/src/main/java
[info] Description:
[info] Default Java source directory.
[info] Provided by:
[info] {file:/Users/heiko/tmp/test/}default-f3fb6c/compile:java-source
[info] Dependencies:
[info] compile:source-directory
[info] Reverse dependencies:
[info] compile:unmanaged-source-directories

you will see that there is a reverse dependency on unmanagedSourceDirectories. Let's inspect this one:

> inspect unmanaged-source-directories
[info] Setting: scala.collection.Seq[java.io.File] = List(/Users/heiko/tmp/test/src/main/scala, /Users/heiko/tmp/test/src/main/java)
[info] Description:
[info] Unmanaged source directories, which contain manually created sources.
[info] Provided by:
[info] {file:/Users/heiko/tmp/test/}default-f3fb6c/compile:unmanaged-source-directories
[info] Dependencies:
[info] compile:scala-source
[info] compile:java-source

All right, this is a Seq[File] and it is initialized with the results from scalaSource and javaSource. All we have to do is get rid of the latter. Add the following settings to your ~/.sbt/build.sbt to get rid of Java source forever, or add it to your project settings, if you don't want to be that bad against good old Java:

// Get rid of java source directories in compile
unmanagedSourceDirectories in Compile <<= (scalaSource in Compile)(Seq(_))

// Get rid of java source directories in test
unmanagedSourceDirectories in Test <<= (scalaSource in Test)(Seq(_))

Cheers
Heiko

--

Heiko Seeberger
Twitter: hseeberger
Blog: heikoseeberger.name
Company: Typesafe - The software stack for applications that scale
Author of Durchstarten mit Scala, a German tutorial-style Scala book


--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To post to this group, send email to simple-b...@googlegroups.com.
To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.

Vlad Ureche

unread,
Feb 8, 2012, 7:09:56 AM2/8/12
to simple-b...@googlegroups.com

Thanks a lot Heiko, it all makes sense now that you explained how to track dependencies!

Cheers,
Vlad
Reply all
Reply to author
Forward
0 new messages