Skip to content

Commit

Permalink
WIP moving most of our build logic into a Mill build.sc
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Jun 8, 2019
1 parent 28e1b1e commit 6b262dc
Show file tree
Hide file tree
Showing 57 changed files with 117 additions and 127 deletions.
36 changes: 10 additions & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,15 @@
language: scala

script:
- sbt ++2.11.12 readme/run
- sbt ++$TRAVIS_SCALA_VERSION scalatagsJVM/test scalatagsJS/test

scala:
- 2.11.12
- 2.12.8
- 2.13.0-M5
sudo: required
dist: trusty
addons:
apt:
update: true

jdk:
- oraclejdk8
- openjdk11

env:
- SCALAJS_VERSION="0.6.26"
- SCALAJS_VERSION="1.0.0-M6

sudo: false

# cache stuff, hopefully shortening build times
cache:
directories:
- $HOME/.ivy2
- $HOME/.sbt/boot
- $HOME/.sbt/launchers
- $HOME/.coursier
before_cache:
- find $HOME/.sbt -name "*.lock" | xargs rm
- find $HOME/.ivy2 -name "ivydata-*.properties" | xargs rm
script:
- curl -L -o ~/bin/mill https://github.com/lihaoyi/mill/releases/download/0.4.0/0.4.0-12-102ddf && chmod +x ~/bin/mill
- curl https://raw.githubusercontent.com/scala-native/scala-native/master/scripts/travis_setup.sh | bash -x
- export PATH=~/bin/mill:$PATH
- mill __.test
89 changes: 0 additions & 89 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,92 +1,3 @@
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}

scalaVersion := "2.11.12"

resolvers in ThisBuild += Resolver.sonatypeRepo("releases")

lazy val scalatags = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.settings(
organization := "com.lihaoyi",
name := "scalatags",
scalaVersion := "2.11.12",

autoCompilerPlugins := true,
libraryDependencies ++= Seq(
//"com.lihaoyi" %% "acyclic" % "0.2.0" % "provided",
"com.lihaoyi" %%% "utest" % "0.6.9" % "test",
"com.lihaoyi" %%% "sourcecode" % "0.1.7",
"org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
"org.scala-lang.modules" %% "scala-xml" % "1.2.0" % "test"
),
//addCompilerPlugin("com.lihaoyi" %% "acyclic" % "0.2.0"),
testFrameworks += new TestFramework("utest.runner.Framework"),
// Sonatype
version := _root_.scalatags.Constants.version,
publishTo := Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2"),

pomExtra :=
<url>https://github.com/lihaoyi/scalatags</url>
<licenses>
<license>
<name>MIT license</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
</license>
</licenses>
<scm>
<url>git://github.com/lihaoyi/scalatags.git</url>
<connection>scm:git://github.com/lihaoyi/scalatags.git</connection>
</scm>
<developers>
<developer>
<id>lihaoyi</id>
<name>Li Haoyi</name>
<url>https://github.com/lihaoyi</url>
</developer>
</developers>
)
.jvmSettings(
crossScalaVersions := Seq("2.12.8", "2.13.0")
)
.jsSettings(
crossScalaVersions := Seq("2.12.8", "2.13.0"),
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "0.9.7"
),
jsEnv := new org.scalajs.jsenv.nodejs.JSDOMNodeJSEnv(),
scalacOptions ++= (if (isSnapshot.value) Seq.empty else Seq({
val a = baseDirectory.value.toURI.toString.replaceFirst("[^/]+/?$", "")
val g = "https://raw.githubusercontent.com/lihaoyi/scalatags"
s"-P:scalajs:mapSourceURI:$a->$g/${version.value}/scalatags/"
}))
)
.nativeSettings(
crossScalaVersions := Seq("2.11.12"),
nativeLinkStubs := true
)


// Needed, so sbt finds the projects
lazy val scalatagsJVM = scalatags.jvm
lazy val scalatagsJS = scalatags.js
lazy val scalatagsNative = scalatags.native

lazy val example = project.in(file("example"))
.dependsOn(scalatagsJS)
.enablePlugins(ScalaJSPlugin)
.settings(
scalaVersion := "2.12.8",
scalacOptions ++= Seq(
"-deprecation", // warning and location for usages of deprecated APIs
"-feature", // warning and location for usages of features that should be imported explicitly
"-unchecked", // additional warnings where generated code depends on assumptions
"-Xlint", // recommended additional warnings
"-Xcheckinit", // runtime error when a val is not initialized due to trait hierarchies (instead of NPE somewhere else)
"-Ywarn-adapted-args", // Warn if an argument list is modified to match the receiver
"-Ywarn-value-discard", // Warn when non-Unit expression results are unused
"-Ywarn-inaccessible",
"-Ywarn-dead-code"
)
)

lazy val readme = scalatex.ScalatexReadme(
projectId = "readme",
Expand Down
107 changes: 107 additions & 0 deletions build.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import mill._, scalalib._, scalajslib._, scalanativelib._, publish._


trait ScalatagsPublishModule extends PublishModule {
def artifactName = "scalatags"

def publishVersion = "0.7.1"

def pomSettings = PomSettings(
description = artifactName(),
organization = "com.lihaoyi",
url = "https://github.com/lihaoyi/scalatags",
licenses = Seq(License.MIT),
scm = SCM(
"git://github.com/lihaoyi/scalatags.git",
"scm:git://github.com/lihaoyi/scalatags.git"
),
developers = Seq(
Developer("lihaoyi", "Li Haoyi", "https://github.com/lihaoyi")
)
)
}

trait Common extends CrossScalaModule {
def millSourcePath = super.millSourcePath / offset
def ivyDeps = Agg(
ivy"com.lihaoyi::sourcecode::0.1.7",
)
def compileIvyDeps = Agg(
ivy"org.scala-lang:scala-reflect:${scalaVersion()}",
)
def offset: os.RelPath = os.rel
def sources = T.sources(
super.sources()
.flatMap(source =>
Seq(
PathRef(source.path / os.up / source.path.last),
PathRef(source.path / os.up / os.up / source.path.last),
)
)
)
}

trait CommonTestModule extends ScalaModule with TestModule {
def millSourcePath = super.millSourcePath / os.up
def crossScalaVersion: String
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.9",
ivy"org.scala-lang.modules::scala-xml:1.2.0",
)
def offset: os.RelPath = os.rel
def testFrameworks = Seq("utest.runner.Framework")
def sources = T.sources(
super.sources()
.++(CrossModuleBase.scalaVersionPaths(crossScalaVersion, s => millSourcePath / s"src-$s" ))
.flatMap(source =>
Seq(
PathRef(source.path / os.up / "test" / source.path.last),
PathRef(source.path / os.up / os.up / "test" / source.path.last),
)
)
.distinct
)
}


object scalatags extends Module {
object jvm extends Cross[JvmScalatagsModule]("2.12.8", "2.13.0")
class JvmScalatagsModule(val crossScalaVersion: String)
extends Common with ScalaModule with ScalatagsPublishModule {

object test extends Tests with CommonTestModule{
def crossScalaVersion = JvmScalatagsModule.this.crossScalaVersion
}
}

object js extends Cross[JSScalatagsModule](("2.12.8", "0.6.26"), ("2.13.0", "0.6.28"))
class JSScalatagsModule(val crossScalaVersion: String, crossJSVersion: String)
extends Common with ScalaJSModule with ScalatagsPublishModule {
def scalaJSVersion = crossJSVersion
def ivyDeps = super.ivyDeps() ++ Agg(
ivy"org.scala-js::scalajs-dom::0.9.7"
)
def offset = os.up
object test extends Tests with CommonTestModule{
def offset = os.up
def crossScalaVersion = JSScalatagsModule.this.crossScalaVersion
}
}

object native extends Cross[NativeScalatagsModule](("2.11.12", "0.3.8"))
class NativeScalatagsModule(val crossScalaVersion: String, crossScalaNativeVersion: String)
extends Common with ScalaNativeModule with ScalatagsPublishModule {
def scalaNativeVersion = crossScalaNativeVersion
def offset = os.up
object test extends Tests with CommonTestModule{
def offset = os.up
def crossScalaVersion = NativeScalatagsModule.this.crossScalaVersion
}
}
}

object example extends ScalaJSModule{
def scalaVersion = "2.12.8"
def scalaJSVersion = "0.6.26"
def moduleDeps = Seq(scalatags.js("2.12.8", "0.6.26"))
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 0 additions & 12 deletions project/build.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
addSbtPlugin("com.lihaoyi" % "scalatex-sbt-plugin" % "0.3.11")

val scalaJSVersion =
Option(System.getenv("SCALAJS_VERSION")).getOrElse("0.6.28")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)

addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.2.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.4")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.8")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "0.6.0")

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 6b262dc

Please sign in to comment.