-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
executable file
·133 lines (124 loc) · 4.29 KB
/
build.sbt
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
* re-organized as per the new recommendations of sbt 0.13
*/
lazy val commonSettings = Seq(
organization := "com.github.manojo",
version := "0.1-SNAPSHOT",
scalaVersion := "2.11.2",
scalaOrganization := "org.scala-lang.virtualized",
scalacOptions ++= Seq(
"-Yvirtualize",
//"-optimize",
"-deprecation",
"-feature",
"-language:higherKinds",
"-language:implicitConversions"
//"-Yinline-warnings"
)
) ++ publishSettings ++ publishableSettings
//implicit logging
//scalacOptions in ThisBuild += "-Xlog-implicits"
lazy val root = (project in file(".")).
settings(commonSettings: _*).
settings(
name := "staged-fold-fusion",
libraryDependencies ++= Seq(
"com.github.manojo" %% "lms" % "0.1-SNAPSHOT",
"com.github.manojo" % "lms-utils_2.11" % "0.1-SNAPSHOT",
"com.github.manojo" % "lms-testutils_2.11" % "0.1-SNAPSHOT" % "test"
),
resolvers += Resolver.sonatypeRepo("snapshots"),
/**
* tests are not thread safe
* this applies to all lms tests that write
* to a file, and do diff tests
*/
parallelExecution in Test := false
)
/**
* We are able to publish this thing!
*/
lazy val publishSettings = Seq(
publishMavenStyle := true,
publishOnlyWhenOnMaster := publishOnlyWhenOnMasterImpl.value,
publishTo <<= version { v: String =>
val nexus = "https://oss.sonatype.org/"
if (v.trim.endsWith("SNAPSHOT"))
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
pomIncludeRepository := { x => false },
publishArtifact in Compile := false,
publishArtifact in Test := false,
pomExtra := (
<url>https://github.com/manojo/staged-fold-fusion</url>
<inceptionYear>2015</inceptionYear>
<licenses>
<license>
<name>MIT</name>
<url>https://github.com/manojo/staged-fold-fusion/blob/master/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>git:github.com/manojo/staged-fold-fusion.git</url>
<connection>scm:git:git://github.com/manojo/staged-fold-fusion.git</connection>
</scm>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/manojo/staged-fold-fusion/issues</url>
</issueManagement>
),
publishArtifact in (Compile, packageDoc) := false
)
lazy val publishOnlyWhenOnMaster = taskKey[Unit](
"publish task for Travis (don't publish when building pull requests, only publish" +
"when the build is triggered by merge into master)")
def publishOnlyWhenOnMasterImpl = Def.taskDyn {
import scala.util.Try
val travis = Try(sys.env("TRAVIS")).getOrElse("false") == "true"
val pr = Try(sys.env("TRAVIS_PULL_REQUEST")).getOrElse("false") != "false"
val branch = Try(sys.env("TRAVIS_BRANCH")).getOrElse("??")
val snapshot = version.value.trim.endsWith("SNAPSHOT")
(travis, pr, branch, snapshot) match {
case (true, false, "master", true) => publish
case _ => Def.task ()
}
}
lazy val publishableSettings = Seq(
publishArtifact in Compile := true,
publishArtifact in Test := false,
credentials ++= {
val mavenSettingsFile = System.getenv("MAVEN_SETTINGS_FILE")
if (mavenSettingsFile != null) {
println("Loading Sonatype credentials from " + mavenSettingsFile)
try {
import scala.xml._
val settings = XML.loadFile(mavenSettingsFile)
def readServerConfig(key: String) = (settings \\ "settings" \\ "servers" \\ "server" \\ key).head.text
Some(Credentials(
"Sonatype Nexus Repository Manager",
"oss.sonatype.org",
readServerConfig("username"),
readServerConfig("password")
))
} catch {
case ex: Exception =>
println("Failed to load Maven settings from " + mavenSettingsFile + ": " + ex)
None
}
} else {
for {
realm <- sys.env.get("SCALAMETA_MAVEN_REALM")
domain <- sys.env.get("SCALAMETA_MAVEN_DOMAIN")
user <- sys.env.get("SCALAMETA_MAVEN_USER")
password <- sys.env.get("SCALAMETA_MAVEN_PASSWORD")
} yield {
println("Loading Sonatype credentials from environment variables")
Credentials(realm, domain, user, password)
}
}
}.toList
)
defaultScalariformSettings