1
- import scala .scalanative .sbtplugin .ScalaNativePluginInternal .nativeWorkdir
2
1
import scala .sys .process ._
3
- import java .nio .file .Path
2
+
3
+ addCommandAlias(" verify" , " ; ^test:compile ; ^test ; ^scripted ; docs/makeSite" )
4
+
5
+ val Versions = new {
6
+ val scala210 = " 2.10.6"
7
+ val scala211 = " 2.11.12"
8
+ val scala212 = " 2.12.6"
9
+ val sbt013 = " 0.13.17"
10
+ val sbt1 = " 1.1.6"
11
+ }
4
12
5
13
inThisBuild(
6
14
Def .settings(
7
15
organization := " org.scalanative.bindgen" ,
8
16
version := " 0.2-SNAPSHOT" ,
9
- scalaVersion := " 2.11.12" ,
10
17
scalacOptions ++= Seq (
11
18
" -deprecation" ,
12
19
" -unchecked" ,
@@ -20,10 +27,18 @@ inThisBuild(
20
27
git.remoteRepo := scmInfo.value.get.connection.replace(" scm:git:" , " " )
21
28
))
22
29
23
- val tests = project
24
- .in(file(" tests" ))
30
+ val root = project(" scala-native-bindgen" )
31
+ .in(file(" ." ))
32
+ .aggregate(
33
+ tests,
34
+ samples,
35
+ tools,
36
+ sbtPlugin,
37
+ docs
38
+ )
39
+
40
+ lazy val tests = project(" tests" )
25
41
.dependsOn(tools)
26
- .aggregate(samples)
27
42
.settings(
28
43
fork in Test := true ,
29
44
javaOptions in Test += {
@@ -38,10 +53,11 @@ val tests = project
38
53
libraryDependencies += " org.scalatest" %% " scalatest" % " 3.0.5" % Test
39
54
)
40
55
41
- lazy val samples = project
56
+ lazy val samples = project( " samples " )
42
57
.in(file(" tests/samples" ))
43
58
.enablePlugins(ScalaNativePlugin )
44
59
.settings(
60
+ scalaVersion := Versions .scala211,
45
61
libraryDependencies += " com.lihaoyi" %%% " utest" % " 0.6.3" % " test" ,
46
62
testFrameworks += new TestFramework (" utest.runner.Framework" ),
47
63
nativeLinkStubs := true ,
@@ -91,19 +107,45 @@ lazy val samples = project
91
107
}
92
108
)
93
109
94
- lazy val tools = project in file(" tools" )
110
+ lazy val tools = project(" tools" )
111
+
112
+ lazy val sbtPlugin = project(" sbt-scala-native-bindgen" , ScriptedPlugin )
113
+ .dependsOn(tools)
114
+ .settings(
115
+ Keys .sbtPlugin := true ,
116
+ scriptedLaunchOpts += s " -Dplugin.version= ${version.value}" ,
117
+ scriptedLaunchOpts += {
118
+ val rootDir = (ThisBuild / baseDirectory).value
119
+ s " -Dbindgen.path= $rootDir/bindgen/target/scala-native-bindgen "
120
+ },
121
+ publishLocal := publishLocal.dependsOn(tools / publishLocal).value
122
+ )
95
123
96
- lazy val docs = project
97
- .in(file(" docs" ))
124
+ lazy val docs = project(" docs" )
98
125
.enablePlugins(GhpagesPlugin , ParadoxSitePlugin , ParadoxMaterialThemePlugin )
99
126
.settings(
100
127
paradoxProperties in Paradox ++= Map (
101
128
" github.base_url" -> scmInfo.value.get.browseUrl.toString
102
129
),
103
130
ParadoxMaterialThemePlugin .paradoxMaterialThemeSettings(Paradox ),
104
- paradoxMaterialTheme in Paradox := {
105
- (paradoxMaterialTheme in Paradox ).value
131
+ Paradox / paradoxMaterialTheme := {
132
+ (Paradox / paradoxMaterialTheme ).value
106
133
.withRepository(scmInfo.value.get.browseUrl.toURI)
107
134
.withColor(" indigo" , " indigo" )
108
135
}
109
136
)
137
+
138
+ def project (name : String , plugged : AutoPlugin * ) = {
139
+ val unplugged = Seq (ScriptedPlugin ).filterNot(plugged.toSet)
140
+ Project (id = name, base = file(name))
141
+ .disablePlugins(unplugged : _* )
142
+ .settings(
143
+ crossSbtVersions := List (Versions .sbt013, Versions .sbt1),
144
+ scalaVersion := {
145
+ (pluginCrossBuild / sbtBinaryVersion).value match {
146
+ case " 0.13" => Versions .scala210
147
+ case _ => Versions .scala212
148
+ }
149
+ }
150
+ )
151
+ }
0 commit comments