aboutsummaryrefslogtreecommitdiff
path: root/project/nativefat.scala.disabled
blob: e1cfcd3c77b477ab7a1f072f3345d7cdcc595e81 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import sbt._
import Keys._
import NativeKeys._
import java.io.File
import scala.collection.mutable.HashSet

object NativeFatKeys {

  val NativeFat = config("nativeFat")


}

object NativeFatDefaults {
  import NativeFatKeys._

  def highest(files: Seq[File], separator: String) = {
    files.sortBy{f =>
      f.getName.split(separator) match {
        case Array(name, version) => version
        case _ => throw new RuntimeException("Error parsing file version string: " + f.getName)
      }
    }.last
  }

  val gen =  taskKey[Seq[File]]("")

  val genImpl = Def.task {
    val resDir = (resourceManaged).value
    val binDir = nativeTargetDirectory.value
    val binarises = nativeLink.value

    val resources = for ((_, binary) <- binarises) yield {
      val relative = (binary relativeTo binDir).get.getPath
      val resource = resDir / "native" / relative
      IO.copyFile(binary, resource)
      resource
   }
   resources.toSeq
  }

  val settings = Seq(
    gen := genImpl.value,
    resourceGenerators in NativeFat := Seq(genImpl)
  )

}