Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit ce835a2

Browse files
author
TATSUNO Yasuhiro
authored
Merge pull request #29 from exoego/simplify-build
Simplify build settings
2 parents 51c6022 + d86a535 commit ce835a2

File tree

3 files changed

+154
-149
lines changed

3 files changed

+154
-149
lines changed

build.sbt

Lines changed: 26 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,52 @@
1-
import sbt.url
2-
import sbtrelease.ReleaseStateTransformations._
3-
4-
val scalatestVersion = "3.0.8"
5-
val scalacticVersion = "3.0.8"
6-
val enableIfVersion = "1.1.7"
7-
81
organization in ThisBuild := "net.exoego"
92

10-
lazy val commonSettings = Seq(
11-
autoCompilerPlugins := true,
12-
scalacOptions ++= Seq(
13-
"-deprecation",
14-
"-unchecked",
15-
"-feature",
16-
"-language:implicitConversions",
17-
"-Xlint"
18-
),
19-
scalacOptions in Compile in compile ++= Seq(
20-
"-Xfatal-warnings"
21-
),
22-
scalacOptions in Compile in doc ++= Seq(
23-
"-Xfatal-warnings",
24-
"-no-link-warnings"
25-
),
26-
autoAPIMappings := true
27-
)
28-
lazy val commonScalaJsSettings = Seq(
29-
scalacOptions += "-P:scalajs:sjsDefinedByDefault",
30-
scalaJSModuleKind := ModuleKind.CommonJSModule,
31-
logBuffered in Test := true
32-
)
33-
lazy val commonMacroParadiseSetting = Seq(
34-
Compile / scalacOptions ++= {
35-
CrossVersion.partialVersion(scalaVersion.value) match {
36-
case Some((2, n)) if n >= 13 => "-Ymacro-annotations" :: Nil
37-
case _ => Nil
38-
}
39-
},
40-
libraryDependencies ++= {
41-
CrossVersion.partialVersion(scalaVersion.value) match {
42-
case Some((2, n)) if n >= 13 => Nil
43-
case _ => compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full) :: Nil
44-
}
45-
}
46-
)
47-
val nonPublishingSetting = Seq(
48-
skip in publish := true,
49-
publishArtifact := false,
50-
publish := {},
51-
publishLocal := {}
52-
)
53-
543
lazy val root = (project in file("."))
554
.aggregate(core, current, nodejs_v8)
56-
.settings(commonSettings)
57-
.settings(publishingSettings)
58-
.settings(nonPublishingSetting)
5+
.settings(MySettings.commonSettings)
6+
.settings(MySettings.publishingSettings)
7+
.settings(MySettings.nonPublishingSetting)
598
.settings(
60-
name := "scala-js-nodejs-all"
9+
name := "scala-js-nodejs"
6110
)
6211

6312
lazy val core = (project in file("./core"))
6413
.enablePlugins(ScalaJSPlugin)
65-
.settings(commonSettings)
66-
.settings(commonScalaJsSettings)
67-
.settings(publishingSettings)
14+
.settings(MySettings.commonSettings)
15+
.settings(MySettings.commonScalaJsSettings)
16+
.settings(MySettings.publishingSettings)
6817
.settings(
6918
name := "scala-js-nodejs-core",
70-
libraryDependencies ++= Seq(
71-
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
72-
"org.scalatest" %%% "scalatest" % scalatestVersion % "test"
73-
)
19+
libraryDependencies ++= Dependencies.core.value
7420
)
7521

7622
lazy val compilerSwitches = (project in file("./compiler-switches"))
77-
.settings(commonSettings)
78-
.settings(nonPublishingSetting)
23+
.settings(MySettings.commonSettings)
24+
.settings(MySettings.nonPublishingSetting)
7925
.settings(
80-
libraryDependencies ++= Seq(
81-
"org.scala-lang" % "scala-reflect" % scalaVersion.value
82-
)
26+
libraryDependencies += Dependencies.scalaReflect.value
8327
)
8428

8529
lazy val current = (project in file("./app/current"))
8630
.enablePlugins(ScalaJSPlugin)
87-
.settings(commonSettings)
88-
.settings(commonScalaJsSettings)
89-
.settings(commonMacroParadiseSetting)
90-
.settings(publishingSettings)
31+
.settings(MySettings.commonSettings)
32+
.settings(MySettings.commonScalaJsSettings)
33+
.settings(MySettings.commonMacroParadiseSetting)
34+
.settings(MySettings.publishingSettings)
9135
.settings(
9236
scalacOptions ++= Seq(
9337
"-Xmacro-settings:nodeJs12.5.0"
9438
),
9539
name := "scala-js-nodejs-v12",
96-
libraryDependencies ++= Seq(
97-
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
98-
"org.scalactic" %% "scalactic" % scalacticVersion,
99-
"org.scalatest" %%% "scalatest" % scalatestVersion % "test",
100-
"com.thoughtworks.enableIf" %% "enableif" % enableIfVersion
101-
)
40+
libraryDependencies ++= Dependencies.app.value
10241
)
10342
.dependsOn(core, compilerSwitches)
10443

10544
lazy val nodejs_v10 = (project in file("./app/nodejs-v10"))
10645
.enablePlugins(ScalaJSPlugin)
107-
.settings(commonSettings)
108-
.settings(commonScalaJsSettings)
109-
.settings(commonMacroParadiseSetting)
110-
.settings(publishingSettings)
46+
.settings(MySettings.commonSettings)
47+
.settings(MySettings.commonScalaJsSettings)
48+
.settings(MySettings.commonMacroParadiseSetting)
49+
.settings(MySettings.publishingSettings)
11150
.settings(
11251
unmanagedSourceDirectories in Compile += (baseDirectory in current).value / "src" / "main" / "scala",
11352
scalacOptions ++= Seq(
@@ -116,21 +55,16 @@ lazy val nodejs_v10 = (project in file("./app/nodejs-v10"))
11655
name := "scala-js-nodejs-v10",
11756
description := "NodeJS v10.16.0 API for Scala.js",
11857
homepage := Some(url("https://github.com/exoego/scala-js-nodejs")),
119-
libraryDependencies ++= Seq(
120-
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
121-
"org.scalactic" %% "scalactic" % scalacticVersion,
122-
"org.scalatest" %%% "scalatest" % scalatestVersion % "test",
123-
"com.thoughtworks.enableIf" %% "enableif" % enableIfVersion
124-
)
58+
libraryDependencies ++= Dependencies.app.value
12559
)
12660
.dependsOn(core, compilerSwitches)
12761

12862
lazy val nodejs_v8 = (project in file("./app/nodejs-v8"))
12963
.enablePlugins(ScalaJSPlugin)
130-
.settings(commonSettings)
131-
.settings(commonScalaJsSettings)
132-
.settings(commonMacroParadiseSetting)
133-
.settings(publishingSettings)
64+
.settings(MySettings.commonSettings)
65+
.settings(MySettings.commonScalaJsSettings)
66+
.settings(MySettings.commonMacroParadiseSetting)
67+
.settings(MySettings.publishingSettings)
13468
.settings(
13569
unmanagedSourceDirectories in Compile += (baseDirectory in current).value / "src" / "main" / "scala",
13670
scalacOptions ++= Seq(
@@ -139,63 +73,6 @@ lazy val nodejs_v8 = (project in file("./app/nodejs-v8"))
13973
name := "scala-js-nodejs-v8",
14074
description := "NodeJS v8.16.0 API for Scala.js",
14175
homepage := Some(url("https://github.com/exoego/scala-js-nodejs")),
142-
libraryDependencies ++= Seq(
143-
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
144-
"org.scalactic" %% "scalactic" % scalacticVersion,
145-
"org.scalatest" %%% "scalatest" % scalatestVersion % "test",
146-
"com.thoughtworks.enableIf" %% "enableif" % enableIfVersion
147-
)
76+
libraryDependencies ++= Dependencies.app.value
14877
)
14978
.dependsOn(core, compilerSwitches)
150-
151-
lazy val publishingSettings = Seq(
152-
licenses := Seq("APL2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
153-
scmInfo := Some(
154-
ScmInfo(
155-
url("https://github.com/exoego/scala-js-nodejs"),
156-
"scm:git:[email protected]:exoego/scala-js-nodejs.git"
157-
)
158-
),
159-
homepage := scmInfo.value.map(_.browseUrl),
160-
developers := List(
161-
Developer(
162-
id = "exoego",
163-
name = "TATSUNO Yasuhiro",
164-
email = "[email protected]",
165-
url = url("https://www.exoego.net")
166-
)
167-
),
168-
publishMavenStyle := true,
169-
publishArtifact in Test := false,
170-
publishArtifact in (Compile, packageDoc) := true,
171-
publishArtifact in (Compile, packageSrc) := true,
172-
publishArtifact in packageDoc := true,
173-
pomIncludeRepository := { _ =>
174-
false
175-
},
176-
publishTo := Some(
177-
if (isSnapshot.value)
178-
Opts.resolver.sonatypeSnapshots
179-
else
180-
Opts.resolver.sonatypeStaging
181-
),
182-
publishConfiguration := publishConfiguration.value.withOverwrite(false),
183-
publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true),
184-
releaseIgnoreUntrackedFiles := true,
185-
releaseProcess := Seq[ReleaseStep](
186-
checkSnapshotDependencies,
187-
inquireVersions,
188-
runClean,
189-
runTest,
190-
setReleaseVersion,
191-
commitReleaseVersion,
192-
tagRelease,
193-
releaseStepCommandAndRemaining("+publishSigned"),
194-
setNextVersion,
195-
commitNextVersion,
196-
releaseStepCommand("sonatypeReleaseAll")
197-
)
198-
)
199-
200-
// loads the Scalajs-io root project at sbt startup
201-
onLoad in Global := (Command.process("project root", _: State)) compose (onLoad in Global).value

project/Dependencies.scala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sbt._
2+
import sbt.Keys._
3+
import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._
4+
5+
object Dependencies {
6+
7+
val scalaReflect = Def.setting("org.scala-lang" % "scala-reflect" % scalaVersion.value)
8+
9+
val core = Def.setting(
10+
Seq(
11+
scalaReflect.value,
12+
"org.scalatest" %%% "scalatest" % "3.0.8" % "test"
13+
)
14+
)
15+
16+
val app = Def.setting(
17+
Seq(
18+
scalaReflect.value,
19+
"org.scalatest" %%% "scalatest" % "3.0.8" % "test",
20+
"com.thoughtworks.enableIf" %% "enableif" % "1.1.7"
21+
)
22+
)
23+
}

project/MySettings.scala

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import org.scalajs.sbtplugin.ScalaJSPlugin.AutoImport.{ModuleKind, scalaJSModuleKind}
2+
import sbt._
3+
import sbt.Keys._
4+
import sbtrelease.ReleasePlugin.autoImport._
5+
import sbtrelease.ReleaseStateTransformations._
6+
7+
object MySettings {
8+
9+
lazy val commonSettings = Seq(
10+
autoCompilerPlugins := true,
11+
scalacOptions ++= Seq(
12+
"-deprecation",
13+
"-unchecked",
14+
"-feature",
15+
"-language:implicitConversions",
16+
"-Xlint"
17+
),
18+
scalacOptions in Compile in compile ++= Seq(
19+
"-Xfatal-warnings"
20+
),
21+
scalacOptions in Compile in doc ++= Seq(
22+
"-Xfatal-warnings",
23+
"-no-link-warnings"
24+
),
25+
autoAPIMappings := true
26+
)
27+
28+
lazy val commonScalaJsSettings = Seq(
29+
scalacOptions += "-P:scalajs:sjsDefinedByDefault",
30+
scalaJSModuleKind := ModuleKind.CommonJSModule,
31+
logBuffered in Test := true
32+
)
33+
34+
lazy val commonMacroParadiseSetting = Seq(
35+
Compile / scalacOptions ++= {
36+
CrossVersion.partialVersion(scalaVersion.value) match {
37+
case Some((2, n)) if n >= 13 => "-Ymacro-annotations" :: Nil
38+
case _ => Nil
39+
}
40+
},
41+
libraryDependencies ++= {
42+
CrossVersion.partialVersion(scalaVersion.value) match {
43+
case Some((2, n)) if n >= 13 => Nil
44+
case _ => compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full) :: Nil
45+
}
46+
}
47+
)
48+
49+
lazy val nonPublishingSetting = Seq(
50+
skip in publish := true,
51+
publishArtifact := false,
52+
publish := {},
53+
publishLocal := {}
54+
)
55+
56+
lazy val publishingSettings = Seq(
57+
licenses := Seq("APL2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
58+
scmInfo := Some(
59+
ScmInfo(
60+
url("https://github.com/exoego/scala-js-nodejs"),
61+
"scm:git:[email protected]:exoego/scala-js-nodejs.git"
62+
)
63+
),
64+
homepage := scmInfo.value.map(_.browseUrl),
65+
developers := List(
66+
Developer(
67+
id = "exoego",
68+
name = "TATSUNO Yasuhiro",
69+
email = "[email protected]",
70+
url = url("https://www.exoego.net")
71+
)
72+
),
73+
publishMavenStyle := true,
74+
publishArtifact in Test := false,
75+
publishArtifact in (Compile, packageDoc) := true,
76+
publishArtifact in (Compile, packageSrc) := true,
77+
publishArtifact in packageDoc := true,
78+
pomIncludeRepository := { _ =>
79+
false
80+
},
81+
publishTo := Some(
82+
if (isSnapshot.value)
83+
Opts.resolver.sonatypeSnapshots
84+
else
85+
Opts.resolver.sonatypeStaging
86+
),
87+
publishConfiguration := publishConfiguration.value.withOverwrite(false),
88+
publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true),
89+
releaseIgnoreUntrackedFiles := true,
90+
releaseProcess := Seq[ReleaseStep](
91+
checkSnapshotDependencies,
92+
inquireVersions,
93+
runClean,
94+
runTest,
95+
setReleaseVersion,
96+
commitReleaseVersion,
97+
tagRelease,
98+
releaseStepCommandAndRemaining("+publishSigned"),
99+
setNextVersion,
100+
commitNextVersion,
101+
releaseStepCommand("sonatypeReleaseAll")
102+
)
103+
)
104+
105+
}

0 commit comments

Comments
 (0)