forked from scala-tsi/scala-tsi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sbt
More file actions
130 lines (122 loc) · 4.57 KB
/
build.sbt
File metadata and controls
130 lines (122 loc) · 4.57 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
126
127
128
129
130
import sbt.Keys.scalacOptions
lazy val commonSettings = Seq(
organization := "nl.codestar",
version := "0.2.0-SNAPSHOT",
scalaVersion := "2.12.10",
//crossScalaVersions := Seq("2.12.10", "2.13.0"),
crossScalaVersions := Seq("2.12.10"),
compilerOptions,
//expandMacros, // Uncomment to view code generated by macro
scalafmtOnCompile := true, // format code on compile
)
/* Settings to publish to maven central */
lazy val publishSettings = Seq(
publishMavenStyle := true,
publishTo := Some(if (isSnapshot.value) Opts.resolver.sonatypeSnapshots else Opts.resolver.sonatypeStaging),
credentials += (sys.env.get("MAVEN_CENTRAL_USER") match {
case Some(user) => Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", user, sys.env("MAVEN_CENTRAL_PASSWORD"))
case None => Credentials(Path.userHome / ".ivy2" / ".nl-codestar-maven-central-credentials")
}),
licenses := Seq("MIT" -> url("https://github.com/code-star/scala-tsi/blob/master/LICENSE")),
homepage := Some(url("https://github.com/code-star/scala-tsi")),
scmInfo := Some(ScmInfo(url("https://github.com/code-star/scala-tsi"), "scm:git@github.com:code-star/scala-tsi.git")),
developers := List(
Developer(
id = "dhoepelman",
name = "David Hoepelman",
email = "992153+dhoepelman@users.noreply.github.com",
url = url("https://github.com/dhoepelman")
),
Developer(id = "donovan", name = "Donovan de Kuiper", email = "donovan.de.kuiper@ordina.nl", url = url("https://github.com/Hayena"))
)
) ++
// CI-only settings, enabled if $CI env variable is set to "true"
sys.env
.get("CI")
.collect({
case "true" =>
Seq(
usePgpKeyHex("6044257F427C2854A6F9A0C211A02377A6DD0E59"),
pgpSecretRing := file(".circleci/circleci.key.asc"),
pgpPublicRing := file(".circleci/circleci.pub.asc"),
pgpPassphrase := sys.env.get("GPG_passphrase").map(_.toCharArray)
)
})
.getOrElse(Seq())
lazy val compilerOptions = scalacOptions := Seq(
//"-Xsource:2.13",
"-unchecked",
"-feature",
"-deprecation",
"-Xlint",
"-encoding",
"UTF8",
"-target:jvm-1.8",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Ywarn-dead-code",
"-Ywarn-unused:params,-implicits",
"-language:experimental.macros"
) ++ (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) => Seq()
case Some((2, 12)) =>
Seq(
"-Yno-adapted-args",
"-Xfuture"
)
case _ => throw new IllegalArgumentException(s"Unconfigured scala version ${scalaVersion.value}")
})
lazy val expandMacros = scalacOptions += "-Ymacro-debug-lite"
//
lazy val `scala-tsi-macros` = (project in file("macros"))
.settings(
commonSettings,
name := "scala-tsi-macros",
description := "Macros for scala-tsi",
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value,
libraryDependencies += "com.avsystem.commons" %% "commons-macros" % "1.40.1",
// Disable publishing
publish := {},
publishLocal := {},
skip in publish := true
)
lazy val `scala-tsi` = (project in file("."))
.settings(commonSettings)
.settings(publishSettings)
.settings(
name := "scala-tsi",
description := "Generate Typescript interfaces from your scala classes",
libraryDependencies ++= Seq(
// testing framework
"org.scalatest" %% "scalatest" % "3.0.8" % "test",
"com.avsystem.commons" %% "commons-core" % "1.40.1",
)
)
// Depend and include the macro project, instead of having to publish a separate macro project
.dependsOn(`scala-tsi-macros` % "compile-internal, test-internal")
.settings(
// Add dependencies from the macro project
libraryDependencies ++= (`scala-tsi-macros` / libraryDependencies).value,
// include the macro classes and resources in the main jar
mappings in (Compile, packageBin) ++= mappings
.in(`scala-tsi-macros`, Compile, packageBin)
.value,
// include the macro sources in the main source jar
mappings in (Compile, packageSrc) ++= mappings
.in(`scala-tsi-macros`, Compile, packageSrc)
.value
)
lazy val `sbt-scala-tsi` = (project in file("plugin"))
.enablePlugins(SbtTwirl, BuildInfoPlugin)
.settings(commonSettings)
.settings(publishSettings)
.settings(
name := "sbt-scala-tsi",
description := "SBT plugin to generate Typescript interfaces from your scala classes as part of your build",
sbtPlugin := true,
buildInfoKeys := Seq[BuildInfoKey](version),
buildInfoPackage := "sbt.info",
// sbt 1 uses scala 2.12
scalaVersion := "2.12.10",
crossScalaVersions := Seq("2.12.10")
)