forked from playframework/twirl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sbt
More file actions
125 lines (111 loc) · 4.1 KB
/
build.sbt
File metadata and controls
125 lines (111 loc) · 4.1 KB
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
import Dependencies._
import sbtcrossproject.crossProject
import org.scalajs.jsenv.nodejs.NodeJSEnv
// Binary compatibility is this version
val previousVersion: Option[String] = Some("1.5.0")
val ScalaTestVersion = "3.1.4"
val ScalaXmlVersion = "1.3.0"
val ScalaParserCombinatorsVersion = "1.1.2"
val mimaSettings = Seq(
mimaPreviousArtifacts := previousVersion.map(organization.value %% name.value % _).toSet
)
// Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed
dynverTagPrefix in ThisBuild := ""
// Sanity-check: assert that version comes from a tag (e.g. not a too-shallow clone)
// https://github.com/dwijnand/sbt-dynver/#sanity-checking-the-version
Global / onLoad := (Global / onLoad).value.andThen { s =>
val v = version.value
if (dynverGitDescribeOutput.value.hasNoTags)
throw new MessageOnlyException(
s"Failed to derive version from git tags. Maybe run `git fetch --unshallow`? Version: $v"
)
s
}
lazy val twirl = project
.in(file("."))
.disablePlugins(MimaPlugin)
.settings(
crossScalaVersions := Nil, // workaround so + uses project-defined variants
publish / skip := true
)
.aggregate(apiJvm, apiJs, parser, compiler, plugin)
lazy val nodeJs = {
if (System.getProperty("NODE_PATH") != null)
new NodeJSEnv(NodeJSEnv.Config().withExecutable(System.getProperty("NODE_PATH")))
else
new NodeJSEnv()
}
lazy val api = crossProject(JVMPlatform, JSPlatform)
.in(file("api"))
.enablePlugins(Common, Playdoc, Omnidoc, PublishLibrary)
.configs(Docs)
.settings(
mimaSettings,
name := "twirl-api",
jsEnv := nodeJs,
// hack for GraalVM, see: https://github.com/scala-js/scala-js/issues/3673
// and https://github.com/playframework/twirl/pull/339
testFrameworks := List(
new TestFramework(
"org.scalatest.tools.Framework",
"org.scalatest.tools.ScalaTestFramework"
)
),
libraryDependencies += "org.scala-lang.modules" %%% "scala-xml" % ScalaXmlVersion,
libraryDependencies += "org.scalatest" %%% "scalatest" % ScalaTestVersion % "test",
)
lazy val apiJvm = api.jvm
lazy val apiJs = api.js
lazy val parser = project
.in(file("parser"))
.enablePlugins(Common, Omnidoc, PublishLibrary)
.settings(
mimaSettings,
name := "twirl-parser",
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % ScalaParserCombinatorsVersion % "optional",
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test",
libraryDependencies += "org.scalatest" %%% "scalatest" % ScalaTestVersion % "test",
)
lazy val compiler = project
.in(file("compiler"))
.enablePlugins(Common, Omnidoc, PublishLibrary)
.dependsOn(apiJvm, parser % "compile;test->test")
.settings(
mimaSettings,
name := "twirl-compiler",
libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value,
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % ScalaParserCombinatorsVersion % "optional",
fork in run := true,
)
lazy val plugin = project
.in(file("sbt-twirl"))
.enablePlugins(PublishSbtPlugin, SbtPlugin)
.dependsOn(compiler)
.settings(
name := "sbt-twirl",
organization := "com.typesafe.sbt",
scalaVersion := Scala212,
libraryDependencies += "org.scalatest" %%% "scalatest" % ScalaTestVersion % "test",
resourceGenerators in Compile += generateVersionFile.taskValue,
scriptedDependencies := {
scriptedDependencies.value
publishLocal
.all(
ScopeFilter(
inDependencies(compiler)
)
)
.value
},
mimaFailOnNoPrevious := false,
)
// Version file
def generateVersionFile =
Def.task {
val version = (Keys.version in apiJvm).value
val file = (resourceManaged in Compile).value / "twirl.version.properties"
val content = s"twirl.api.version=$version"
IO.write(file, content)
Seq(file)
}
addCommandAlias("validateCode", ";headerCheckAll;+scalafmtCheckAll;scalafmtSbtCheck")