aboutsummaryrefslogtreecommitdiff
path: root/project/Bintray.scala.notyet
blob: 5ed9953d9da5f3aa5c0de6e5925cc2673c0fcd20 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package flow

import sbt._
import sbt.Keys._
import ch.jodersky.sbt.jni.plugins.JniPackaging
import ch.jodersky.sbt.jni.plugins.JniPackaging.autoImport._
import bintray._
import bintray.BintrayPlugin.autoImport._

/** Custom bintray tasks. */
object CustomBintray extends AutoPlugin {

  override def requires = JniPackaging && BintrayPlugin
  override def trigger = allRequirements

  object autoImport {

    val unmanagedNativeZip = taskKey[File](
      "Packages unmanaged native libraries in a zip file."
    )

    val publishNativeZip = taskKey[Unit](
      "Signs and publishes native zip files to a generic bintray repository."
    )

  }
  import autoImport._

  lazy val settings: Seq[Setting[_]] = Seq(

    unmanagedNativeZip := {
      val out = target.value / (name.value + "-native.zip")

      val files: Seq[File] = unmanagedNativeDirectories.value flatMap {dir =>
        (dir ** "*").get.filter(_.isFile)
      }
      val baseDirectories: Seq[File] = unmanagedNativeDirectories.value

      val mappings: Seq[(File,String)] = files pair Path.relativeTo(baseDirectories)

      IO.zip(mappings, out)
      out
    },


    publishNativeZip := {
      val credsFile = bintrayCredentialsFile.value
      val btyOrg = bintrayOrganization.value
      val repoName = "generic"

      val zip = unmanagedNativeZip.value

      Bintray.withRepo(credsFile, btyOrg, repoName, prompt = false) { repo =>
        repo.upload(
          "flow",
          version.value,
          zip.name,
          zip,
          streams.value.log
        )
      }
    }

  )

  override def projectSettings = inConfig(Compile)(settings)

}