-
Notifications
You must be signed in to change notification settings - Fork 2
/
LibraryPlugin.scala
64 lines (54 loc) · 2.01 KB
/
LibraryPlugin.scala
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
package xyz.driver.sbt
import com.typesafe.sbt.GitPlugin
import com.typesafe.sbt.SbtGit.git
import java.time.Instant
import sbt.Keys._
import sbt._
import sbt.plugins.JvmPlugin
/** Common settings for a library, Driver style. */
object LibraryPlugin extends AutoPlugin {
override def requires = JvmPlugin
object autoImport {
val release = taskKey[Unit]("Deprecated placeholder to release process.")
}
import autoImport._
lazy val repositorySettings: Seq[Setting[_]] = Seq(
resolvers += "releases" at "https://drivergrp.jfrog.io/drivergrp/releases",
resolvers += "snapshots" at "https://drivergrp.jfrog.io/drivergrp/snapshots"
)
lazy val publicationSettings: Seq[Setting[_]] = Seq(
organization := "xyz.driver",
publishTo := {
val jfrog = "https://drivergrp.jfrog.io/drivergrp/"
if (isSnapshot.value)
Some("snapshots-timestamp" at jfrog + "snapshots;build.timestamp=" + Instant.now().toEpochMilli)
else Some("releases" at jfrog + "releases")
},
skip in publish := false
)
// Get version from git unless a VERSION environment variable is set
lazy val versionSettings: Seq[Setting[_]] = sys.env.get("VERSION") match {
case None =>
GitPlugin.autoImport.versionWithGit ++ Seq(
git.useGitDescribe := true, // get version from git
git.baseVersion := "0.0.0" // this version is used for new projects without any commits
)
case Some(v) =>
Seq(
version := v
)
}
override def buildSettings: Seq[sbt.Setting[_]] = versionSettings ++ Seq(
skip in publish := true
)
override def projectSettings: Seq[Def.Setting[_]] = repositorySettings ++ publicationSettings ++ Seq(
javacOptions ++= Seq("-target", "1.8"),
crossScalaVersions := List("2.12.7"),
scalaVersion := crossScalaVersions.value.last,
release := {
throw new MessageOnlyException(
"Releasing is no longer supported. Please push a tag in the format v[0-9].* " +
"to have CI build and publish a new version.")
}
)
}