aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala-sbt-1.0/Compat.scala
blob: ca7cf43e55a60eea74884bd32417e7cf6e3b8c08 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * sbt-boilerplate is distributed under the 2-Clause BSD license. See the LICENSE file in the root
 * of the repository.
 *
 * Copyright (c) 2012-2016 Johannes Rudolph
 */
package spray.boilerplate

import sbt._
import Keys._
import sbt.internal.io.Source

object Compat {
  private val boilerplateSourceDirectories = settingKey[Seq[File]]("Directories containing boilerplate template sources.")
  private val inputFilter = """.*\.template""".r

  def allPaths(f: File) = f.allPaths

  def watchSourceSettings = Def.settings {
    Seq(
      watchSources in Defaults.ConfigGlobal ++= boilerplateSourceDirectories.value map { dir =>
        new Source(
          dir,
          new NameFilter {
            override def accept(name: String): Boolean = inputFilter.pattern.matcher(name).matches()
          },
          NothingFilter)
      }
    )
  }
}