Skip to content

Instantly share code, notes, and snippets.

@GMadorell
Created September 21, 2016 09:54
Show Gist options
  • Save GMadorell/f2065c83649115d321ddcac4dfa37f9b to your computer and use it in GitHub Desktop.
Save GMadorell/f2065c83649115d321ddcac4dfa37f9b to your computer and use it in GitHub Desktop.
Bootstrap a scala application structure
#!/bin/bash
set -e
PROJECT_NAME="$1"
SCALA_VERSION="2.11.8"
SCALATEST_VERSION="3.0.0"
echo " . Creating project folder with name: $PROJECT_NAME..."
mkdir $PROJECT_NAME
cd $PROJECT_NAME
echo " . Creating bootstrap files and directories..."
cat > build.sbt << EOF
name := "$PROJECT_NAME"
version := "1.0"
scalaVersion := "$SCALA_VERSION"
libraryDependencies += "org.scalatest" %% "scalatest" % "$SCALATEST_VERSION" % "test"
EOF
mkdir -p "src/main/scala"
mkdir -p "src/main/resources"
mkdir -p "src/test/scala"
mkdir -p "src/test/resources"
cat > .gitignore << EOF
### Scala ###
*.class
*.log
# sbt specific
.cache
.history
.lib/
dist/*
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/
# Scala-IDE specific
.scala_dependencies
.worksheet
# ENSIME specific
.ensime_cache/
.ensime
EOF
echo " . Setting up initial git repo..."
git init > /dev/null
git add .gitignore > /dev/null
git add build.sbt > /dev/null
git commit -m 'Bootstrap repo' > /dev/null
echo " . Setting up intellij files (.idea repo) (this might be slow because dependencies have to be downloaded) ..."
# You need to have the idea plugin in the global SBT's plugins/build.sbt
sbt update gen-idea > /dev/null
echo " . DONE! Happy coding :)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment