Search code examples
scalareflectionsbtsbteclipse

How can I have an optional Sbt setting?


There is a project shared with multiple participants. Some participants installed a global sbteclipse at ~/.sbt/0.13/plugins/plugins.sbt, while other participants didn't.

I want to put some sbt settings in the project's build.sbt, like:

EclipseKeys.createSrc := EclipseCreateSrc.Unmanaged + EclipseCreateSrc.Managed + EclipseCreateSrc.Source

I wish to apply these settings only for those participants who have installed a global sbteclipse, and do not affect others.

How can I achieve that?


Solution

  • I have tried to use some complex settings like:

    try {
      Class.forName("com.typesafe.sbteclipse.plugin.EclipsePlugin$EclipseKeys").getMethod("createSrc").invoke(null).asInstanceOf[SettingKey[_]] := ...
    catch {
      case e: Exception => Seq.empty : SettingsDefinition
    }
    

    I am still looking for a better solution.