GithubHelp home page GithubHelp logo

sbttemplate's Introduction

Scala Project Template

License GitHub version

This is a handy starting point for Scala/Java console apps built with SBT. Projects are built with Scala 2.13, and has been tested with Oracle Java 8, OpenJDK 8 & OpenJDK 11. Uncomment one line to build with Scala 2.12 instead. The scala_2_11 branch builds projects for Scala 2.11.

This project is licensed with CC0, which puts this project into the public domain. Please delete the LICENSE file for any projects you create based on this template project, unless you want them to be in the public domain as well.

For more information about this project and SBT, see the SBT Project Setup lecture on ScalaCourses.com.

sbtTemplate Bash command

Copy this to a directory on the path (like /usr/local/bin/), and call it sbtTemplate:

#!/bin/bash

# Clones sbtTemplate and starts a new SBT project
# Optional argument specifies name of directory to place the new project into

DIR=sbtTemplate
if [ "$1" ]; then DIR="$1"; fi
git clone https://github.com/mslinn/sbtTemplate.git "$DIR"
cd "$DIR"
rm -rf .git
git init
echo "Please edit README.md, build.sbt and publish.sbt right away"
echo "After you create the remote repository, type this:"
echo "git branch -u origin/master"
echo "git add -A"
echo "git commit -m "Initial checkin""
echo "git push"

Make the bash script executable:

$ chmod a+x /usr/local/bin/sbtTemplate

To create a new SBT project, run the script.

$ sbtTemplate my-new-project

Using GitHub?

GitHub Pages

sbtTemplate sets up the GitHub pages branch for your new project. Before you can use it, edit build.sbt and change this line so your GitHub user id and project name are substituted for the placeholders yourGithubId and my-new-project:

git.remoteRepo := "[email protected]:yourGithubId/my-new-project.git"

Now you can publish the Scaladoc for your project with this command:

sbt ";doc ;ghpagesPushSite"

The Scaladoc will be available at a URL of the form:

http://yourGithubId.github.io/my-new-project/latest/api/index.html

Try Hub!

With hub and sbtTemplate you can create a new SBT project and a matching GitHub project with only two commands. The setup documented below will supply your GitHub username and password, and will only prompt your for your 2-factor-authentication (2FA) token each time you run it if you set up your GitHub account to use 2FA.

Install Hub

Install Hub on Mac OS:

$ brew install hub

Install Hub on Linux:

$ sudo -H pip install hub

Put your GitHub login credentials in ~/.bash_profile or ~/.profile. Also alias hub as git (hub also executes git commands):

export GITHUB_USER=yourGithubUserName
export GITHUB_PASSWORD=yourPassword
alias git=hub

Reload ~/.bash_profile

$ source `~/.bash_profile`

... or reload ~/.profile

$ source `~/.profile`

Using sbtTemplate with Hub

Create a new SBT project and create a new GitHub project, which hub automatically adds as a git remote:

$ sbtTemplate bigBadProject
$ git create -d "Project description"
two-factor authentication code: 881078
Updating origin
created repository: mslinn/bigBadProject

Now check in the new project:

$ git add -A && git commit -m "Initial checkin" && git push -u origin master

Running the Program

The bin/run Bash script assembles this project into a fat jar and runs it. Sample usage, which runs the Hello entry point in src/main/scala/Hello.scala:

$ bin/run Hello

The -j option forces a rebuild of the fat jar. Use it after modifying the source code.

$ bin/run -j Hello

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.