Tuesday, 15 February 2011

scala - How to have sbt multi-project builds configure setting for subprojects? -



scala - How to have sbt multi-project builds configure setting for subprojects? -

i have sbt (0.13.1) project bunch of subprojects. generating eclipse project configurations using sbteclipse. projects have scala source files, want remove generated src/java folders.

i can accomplish (redundantly) adding next build.sbt of each subproject:

unmanagedsourcedirectories in compile := (scalasource in compile).value :: nil unmanagedsourcedirectories in test := (scalasource in test).value :: nil

i tried adding above configuration root build.sbt eclipse command still generated java source folders.

is there way specify configuration 1 time (in root build.sbt) , have flow downwards each subproject?

you define settings unscoped , reuse them

val onlyscalasources = seq( unmanagedsourcedirectories in compile := seq((scalasource in compile).value), unmanagedsourcedirectories in test := seq((scalasource in test).value) ) val project1 = project.in( file( "project1" ) .settings(onlyscalasources: _*) val project2 = project.in( file( "project2" ) .settings(onlyscalasources: _*)

you create simple plugin (untested code)

object onlyscalasources extends autoplugin { override def trigger = allrequirements override lazy val projectsettings = seq( unmanagedsourcedirectories in compile := seq((scalasource in compile).value), unmanagedsourcedirectories in test := seq((scalasource in test).value) ) }

more details creating plugins in plugins documentation

scala sbt sbteclipse

No comments:

Post a Comment