Skip to content

Instantly share code, notes, and snippets.

@benhutchison
Last active August 29, 2015 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benhutchison/5e8e3a8d29eace84006f to your computer and use it in GitHub Desktop.
Save benhutchison/5e8e3a8d29eace84006f to your computer and use it in GitHub Desktop.
Script to init a new Scala JS/JVM cross-built project with an Intellij friendly layout. After running, just Open the directory in Intellij and Import. Uses https://github.com/lihaoyi/utest#jscrossbuild
#!/bin/bash
[ $# -eq 0 ] && { echo "Usage: $0 <projectName>"; exit 1; }
PROJECT=$1
echo "Creating project in ./$PROJECT"
mkdir -p $PROJECT/{js,jvm,project}
mkdir -p $PROJECT/shared/src/{main,test}/{scala,resources}
cd $PROJECT
ln -s ../shared js/shared; ln -s ../shared jvm/shared
cat > project/plugin.sbt <<EOF
addSbtPlugin("org.scala-lang.modules.scalajs" % "scalajs-sbt-plugin" % "0.5.5")
addSbtPlugin("com.lihaoyi" % "utest-js-plugin" % "0.2.4")
EOF
cat > project/Build.scala <<EOF
import sbt._
import Keys._
import utest.jsrunner._
object Build extends sbt.Build{
lazy val cross = new JsCrossBuild(
name := "$PROJECT",
version := "0.1",
scalaVersion := "2.11.2"
)
lazy val root = cross.root
lazy val js = cross.js
lazy val jvm = cross.jvm
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment