diff --git a/build.sbt b/build.sbt index d902956..f6f43d8 100644 --- a/build.sbt +++ b/build.sbt @@ -3,6 +3,8 @@ import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._ resolvers += Resolver.sonatypeRepo("releases") resolvers += Resolver.sonatypeRepo("snapshots") +enablePlugins(ScalaJSPlugin) + val commonSettings = Seq( organization := "com.github.kenbot", scalaVersion in ThisBuild := "2.13.0", @@ -12,41 +14,60 @@ val commonSettings = Seq( scalacOptions in (Test, console) -= "-Ywarn-unused:imports" ) -lazy val goggles = project.in(file(".")) +lazy val goggles = crossProject(JSPlatform, JVMPlatform) + .crossType(CrossType.Pure) + .withoutSuffixFor(JVMPlatform) + .in(file(".")) .settings(moduleName := "goggles") .settings(commonSettings) .settings(noPublishSettings) .aggregate(dslProject, macrosProject) .dependsOn(dslProject, macrosProject) -lazy val macrosProject = (project in file("macros")).settings( - commonSettings, - libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value, - libraryDependencies += "com.github.julien-truffaut" %% "monocle-core" % monocleVersion, - libraryDependencies ++= specs2Deps, - publishSettings, - moduleName := "goggles-macros", - scalacOptions += "-Yrangepos", - scalacOptions += "-language:experimental.macros" -) +lazy val macrosProject = crossProject(JSPlatform, JVMPlatform) + .crossType(CrossType.Pure) + .withoutSuffixFor(JVMPlatform) + .in(file("macros")) + .settings( + commonSettings, + libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value, + monocleDeps, + specs2Deps, + moduleName := "goggles-macros", + scalacOptions += "-Yrangepos", + scalacOptions += "-language:experimental.macros" + ) + .jvmSettings( + publishSettings + ) + .jsSettings( + noPublishSettings, + test in Test := streams.value.log.warn( + "JSPlatform tests disabled in macrosProject since macros are JVM compile-time feature." + ) + ) -val specs2Version = "4.6.0" +val specs2Version = "4.10.3" val specs2Deps = Seq( - "org.specs2" %% "specs2-core" % specs2Version % "test", - "org.specs2" %% "specs2-scalacheck" % specs2Version % "test" + libraryDependencies += "org.specs2" %%% "specs2-core" % specs2Version % "test", + libraryDependencies += "org.specs2" %%% "specs2-scalacheck" % specs2Version % "test" ) -val monocleVersion = "1.6.0-RC1" +val monocleVersion = "1.7.3" val monocleDeps = Seq( - "com.github.julien-truffaut" %% "monocle-core" % monocleVersion + libraryDependencies += "com.github.julien-truffaut" %%% "monocle-core" % monocleVersion ) -lazy val dslProject = (project in file("dsl")). - dependsOn(macrosProject). - settings( +lazy val dslProject = crossProject(JSPlatform, JVMPlatform) + .crossType(CrossType.Pure) + .withoutSuffixFor(JVMPlatform) + .in(file("dsl")) + .dependsOn(macrosProject) + .settings( commonSettings, - libraryDependencies ++= monocleDeps, - libraryDependencies ++= specs2Deps, + monocleDeps, + specs2Deps, + initialCommandSettings, publishSettings, moduleName := "goggles-dsl", scalacOptions += "-Yrangepos", @@ -68,7 +89,7 @@ val publishSettings = Seq( if (isSnapshot.value) Some("snapshots" at nexus + "content/repositories/snapshots") else - Some("releases" at nexus + "service/local/staging/deploy/maven2") + Some("releases" at nexus + "service/local/staging/deploy/maven2") }, sonatypeProfileName := "com.github.kenbot", publishArtifact in Test := false, @@ -109,10 +130,11 @@ val publishSettings = Seq( ) ) -initialCommands in dslProject := "import goggles._;" - -initialCommands in (dslProject, Test) := """ +lazy val initialCommandSettings = Seq( + initialCommands := "import goggles._;", + initialCommands in Test := """ import goggles._; import Fixture._; import testdsl._; """ +) diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 0000000..7577c47 --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,2 @@ +install: + - sbt '+ publishM2' diff --git a/project/plugins.sbt b/project/plugins.sbt index 798e40a..0e8270b 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,5 @@ -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1") -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.5") -addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.11") +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.2.0") +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1") +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.5") +addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.11")