-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.sbt
140 lines (126 loc) · 3.9 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
134
135
136
137
138
139
140
import bintray.Keys._
lazy val `sbt-mustache` = project
.in(file("."))
.aggregate(generator, api, plugin)
.settings(commonSettings:_*)
.settings(crossScala:_*)
.settings(noPublish:_*)
//Compiles and Renders Mustache html templates
lazy val api = project
.in(file("api"))
.settings(commonSettings: _*)
.settings(crossScala: _*)
.settings(publishMaven: _*)
.settings(
name := "sbt-mustache-api",
libraryDependencies ++= Seq(
scalaTest(scalaBinaryVersion.value),
logger(),
"com.github.spullara.mustache.java" % "compiler" % "0.8.15"
),
initLoggerInTests()
)
//Handles generation of Scala files from Mustache html templates
lazy val generator = project
.in(file("generator"))
.dependsOn(api)
.settings(commonSettings: _*)
.settings(crossScala: _*)
.settings(publishMaven: _*)
.settings(
name := "sbt-mustache-generator",
libraryDependencies ++= Seq(
scalaCompiler(scalaVersion.value),
scalaTest(scalaBinaryVersion.value),
logger(),
"org.scala-sbt" % "io" % "0.13.5"
),
fork in run := true,
initLoggerInTests()
)
lazy val plugin = project
.in(file("plugin"))
.dependsOn(generator)
.settings(commonSettings: _*)
.settings(crossScala: _*)
.settings(publishSbtPlugin: _*)
.settings(scriptedSettings: _*)
.settings(
name := "sbt-mustache",
scriptedLaunchOpts += ("-Dproject.version=" + version.value),
scriptedLaunchOpts += "-XX:MaxPermSize=256m",
scriptedBufferLog := false,
sbtPlugin := true,
resourceGenerators in Compile <+= generateVersionFile
)
def commonSettings = {
Seq(
organization := "io.michaelallen.mustache",
version := "0.3-SNAPSHOT",
scalaVersion := sys.props.get("scala.version").getOrElse("2.10.4"),
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8"),
resolvers += Resolver.mavenLocal
)
}
def noPublish = Seq(
publish := {},
publishLocal := {},
publishTo := Some(Resolver.file("no-publish", crossTarget.value / "no-publish"))
)
def publishSbtPlugin = bintrayPublishSettings ++ Seq(
publishMavenStyle := false,
repository in bintray := "sbt-plugins",
bintrayOrganization in bintray := None,
licenses := Seq("MIT" -> url("http://opensource.org/licenses/MIT"))
)
def publishMaven = bintrayPublishSettings ++ Seq(
publishMavenStyle := true,
repository in bintray := "maven",
bintrayOrganization in bintray := None,
homepage := Some(url("https://github.com/michaeldfallen/sbt-mustache")),
licenses := Seq("MIT" -> url("http://opensource.org/licenses/MIT")),
pomExtra := {
<scm>
<url>https://github.com/michaeldfallen/sbt-mustache</url>
<connection>scm:git:[email protected]:michaeldfallen/sbt-mustache.git</connection>
</scm>
<developers>
<developer>
<id>michaeldfallen</id>
<name>Michael Allen</name>
<url>https://github.com/michaeldfallen</url>
</developer>
</developers>
},
pomIncludeRepository := { _ => false }
)
def generateVersionFile = Def.task {
val version = (Keys.version in api).value
val file = (resourceManaged in Compile).value / "mustache.version.properties"
val content = s"mustache.api.version=$version"
IO.write(file, content)
Seq(file)
}
def crossScala = Seq(
crossScalaVersions := Seq("2.10.4"),
unmanagedSourceDirectories in Compile += {
(sourceDirectory in Compile).value / ("scala-" + scalaBinaryVersion.value)
}
)
def scalaCompiler(version: String) = {
"org.scala-lang" % "scala-compiler" % version
}
def scalaTest(version: String) = version match {
case "2.10" => "org.scalatest" %% "scalatest" % "2.2.0" % "test"
}
def logger() = {
"ch.qos.logback" % "logback-classic" % "1.0.1"
}
def initLoggerInTests() = {
testOptions in Test += Tests.Setup(classLoader =>
classLoader
.loadClass("org.slf4j.LoggerFactory")
.getMethod("getLogger", classLoader.loadClass("java.lang.String"))
.invoke(null, "ROOT")
)
}