Skip to content

Instantly share code, notes, and snippets.

@cb372
Last active April 4, 2019 10:26
Show Gist options
  • Save cb372/e666c384e3ab40c055b2a98532d8d49f to your computer and use it in GitHub Desktop.
Save cb372/e666c384e3ab40c055b2a98532d8d49f to your computer and use it in GitHub Desktop.
Poor man's sbt template. Useful for quickly generating a throwaway sbt project when you just want to try something out.
# stick this in your .bashrc/.zshrc
sbtnew() {
local projectname=$1
local sbtversion=${2:-1.2.8}
local scalaversion=${3:-2.12.8}
cd ~/code
mkdir $projectname
cd $projectname
mkdir project
echo "sbt.version=$sbtversion" > project/build.properties
cat > build.sbt <<EOF
scalaVersion := "$scalaversion"
libraryDependencies ++= Seq(
//"" %% "" % ""
)
EOF
cat > project/plugins.sbt <<EOF
//addSbtPlugin("" %% "" % "")
EOF
}
# use this one if you want the latest versions of sbt and Scala (requires xmllint to be installed)
sbtlatest() {
local projectname=$1
local latestsbt=$(curl -s https://repo1.maven.org/maven2/org/scala-sbt/sbt/maven-metadata.xml | xmllint --xpath '/metadata/versioning/latest/text()' -)
local latestscala=$(curl -s https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/maven-metadata.xml | xmllint --xpath '/metadata/versioning/latest/text()' -)
sbtnew "$projectname" "$latestsbt" "$latestscala"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment