Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

init()

  • Loading branch information...
commit 5a6d375bb982ebbc9b6e31e5631fd41d0a3f348e 0 parents
Marko Elezović authored
9 .gitignore
@@ -0,0 +1,9 @@
+.cache
+.classpath
+.project
+.scala_dependencies
+.settings
+target
+.target
+
+sbt-launch-*.jar
26 LICENSE
@@ -0,0 +1,26 @@
+Copyright (c) 2011, Element d.o.o.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+3. Neither the name of the Element d.o.o. nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
1  README
@@ -0,0 +1 @@
+XSBT Batch and Bash creator
4 code/continuous-compilation.bat
@@ -0,0 +1,4 @@
+@echo off
+
+echo Entering continuous compilation loop ...
+call "%~dp0\sbt.bat" --loop --no-jrebel %* ~compile
4 code/continuous-compilation.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+echo Entering continuous compilation loop ...
+`dirname $0`/sbt.sh --loop --no-jrebel "$@" ~compile
4 code/format.bat
@@ -0,0 +1,4 @@
+@echo off
+
+echo Formatting code via scalariform ...
+call "%~dp0\sbt.bat" --no-jrebel %* scalariform-format
5 code/format.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+echo Formatting code via scalariform ...
+echo Firing up the Scala REPL ...
+`dirname $0`/sbt.sh --no-jrebel "$@" scalariform-format
4 code/open-console.bat
@@ -0,0 +1,4 @@
+@echo off
+
+echo Firing up the Scala REPL ...
+call "%~dp0\sbt.bat" %* console
4 code/open-console.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+echo Firing up the Scala REPL ...
+`dirname $0`/sbt.sh "$@" console
5 code/prepare-workspace.bat
@@ -0,0 +1,5 @@
+@echo off
+
+echo Performing dependency update for all projects ...
+echo Will also create Eclipse .project and .classpath files ...
+call "%~dp0\sbt.bat" --no-jrebel %* update eclipse
5 code/prepare-workspace.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+echo Performing dependency update for all projects ...
+echo Will also create Eclipse .project and .classpath files ...
+`dirname $0`/sbt.sh --no-jrebel "$@" update eclipse
120 code/project/Build.scala
@@ -0,0 +1,120 @@
+import sbt._
+import Keys._
+
+import Helpers._
+import Dependencies._
+
+object XsbtBatsh extends Build {
+ lazy val root = Project(
+ "XSBT-BatSh",
+ file("."),
+ settings =
+ Default.settings :+
+ libDeps(
+ //test
+ scalaTest
+ )
+ )
+}
+
+// ---------------------------------------------------------------------------
+
+object Default {
+ val settings =
+ Defaults.defaultSettings ++
+ Resolvers.settings ++
+ Publishing.settings ++
+ Format.settings ++ Seq(
+ organization := "hr.element.etb",
+ crossScalaVersions := Seq("2.9.1", "2.9.0-1", "2.9.0", "2.8.2", "2.8.1"),
+ scalaVersion <<= (crossScalaVersions) { versions => versions.head },
+ scalacOptions := Seq("-unchecked", "-deprecation", "-optimise", "-encoding", "UTF8"),
+ javacOptions := Seq("-deprecation", "-encoding", "UTF-8", "-source", "1.6", "-target", "1.6")
+ )
+}
+
+// ---------------------------------------------------------------------------
+
+object Dependencies {
+ // Testing
+ val scalaTest = "org.scalatest" %% "scalatest" % "1.6.1" % "test"
+}
+
+// ---------------------------------------------------------------------------
+
+object Repositories {
+ val ElementNexus = "Element Nexus" at "http://maven.element.hr/nexus/content/groups/public/"
+ val ElementReleases = "Element Releases" at "http://maven.element.hr/nexus/content/repositories/releases/"
+ val ElementSnapshots = "Element Snapshots" at "http://maven.element.hr/nexus/content/repositories/snapshots/"
+}
+
+object Resolvers {
+ import Repositories._
+
+ val settings = Seq(
+ resolvers := Seq(ElementNexus, ElementReleases, ElementSnapshots),
+ externalResolvers <<= resolvers map { rs =>
+ Resolver.withDefaultResolvers(rs, mavenCentral = false, scalaTools = false)
+ }
+ )
+}
+
+object Publishing {
+ import Repositories._
+
+ val settings = Seq(
+ publishTo <<= (version) { version => Some(
+ if (version.endsWith("SNAPSHOT")) ElementSnapshots else ElementReleases
+ )},
+ credentials += Credentials(Path.userHome / ".publish" / "element.credentials"),
+ publishArtifact in (Compile, packageDoc) := false
+ )
+}
+
+// ---------------------------------------------------------------------------
+
+object Format {
+ // Scalariform plugin
+ import com.typesafe.sbtscalariform._
+ import ScalariformPlugin._
+ import scalariform.formatter.preferences._
+
+ ScalariformKeys.preferences := FormattingPreferences()
+ .setPreference(AlignParameters, false)
+ .setPreference(AlignSingleLineCaseStatements, false)
+ .setPreference(AlignSingleLineCaseStatements.MaxArrowIndent, 40)
+ .setPreference(CompactControlReadability, true)
+ .setPreference(CompactStringConcatenation, false)
+ .setPreference(DoubleIndentClassDeclaration, true)
+ .setPreference(FormatXml, false)
+ .setPreference(IndentLocalDefs, false)
+ .setPreference(IndentPackageBlocks, false)
+ .setPreference(IndentSpaces, 2)
+ .setPreference(IndentWithTabs, false)
+ .setPreference(MultilineScaladocCommentsStartOnFirstLine, true)
+ .setPreference(PlaceScaladocAsterisksBeneathSecondAsterisk, true)
+ .setPreference(PreserveDanglingCloseParenthesis, false)
+ .setPreference(PreserveSpaceBeforeArguments, false)
+ .setPreference(RewriteArrowSymbols, false)
+ .setPreference(SpaceBeforeColon, false)
+ .setPreference(SpaceInsideBrackets, false)
+ .setPreference(SpaceInsideParentheses, false)
+ .setPreference(SpacesWithinPatternBinders, true)
+
+ lazy val settings =
+ ScalariformPlugin.defaultScalariformSettings
+}
+
+// ---------------------------------------------------------------------------
+
+object Helpers {
+ implicit def depToFunSeq(m: ModuleID) = Seq((_: String) => m)
+ implicit def depFunToSeq(fm: String => ModuleID) = Seq(fm)
+ implicit def depSeqToFun(mA: Seq[ModuleID]) = mA.map(m => ((_: String) => m))
+
+ def libDeps(deps: (Seq[String => ModuleID])*) = {
+ libraryDependencies <++= scalaVersion( sV =>
+ for (depSeq <- deps; dep <- depSeq) yield dep(sV)
+ )
+ }
+}
22 code/project/plugins.sbt
@@ -0,0 +1,22 @@
+// +-------------------------------------------------------------------------------------+
+// | SBT Eclipse (https://github.com/typesafehub/sbteclipse) |
+// | Creates .project and .classpath files for easy Eclipse project imports |
+// | |
+// | See also: Eclipse downloads (http://www.eclipse.org/downloads/) |
+// | See also: Scala IDE downloads (http://download.scala-ide.org/) |
+// +-------------------------------------------------------------------------------------+
+
+resolvers += Classpaths.typesafeResolver
+
+addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.0.0-M3")
+
+// +-------------------------------------------------------------------------------------+
+// | SBT Scalariform (https://github.com/typesafehub/sbt-scalariform) |
+// | Performs source code formatting |
+// | |
+// | See also: Scalariform reference (http://mdr.github.com/scalariform/) |
+// +-------------------------------------------------------------------------------------+
+
+resolvers += Classpaths.typesafeResolver
+
+addSbtPlugin("com.typesafe.sbtscalariform" % "sbtscalariform" % "0.3.0")
BIN  code/project/strap/gruj_vs_sbt-launch-0.11.2.jar
Binary file not shown
4 code/publish.bat
@@ -0,0 +1,4 @@
+@echo off
+
+echo Will cross-publish project to the maven server
+call "%~dp0sbt.bat" --no-jrebel %* +publish
4 code/publish.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+echo Will cross-publish project to the maven server
+`dirname $0`/sbt.sh --no-jrebel "$@" +publish
75 code/sbt.bat
@@ -0,0 +1,75 @@
+@echo off
+setlocal
+pushd
+cd "%~dp0"
+
+set JVM_PARAMS=-Xss2m -Xmx712m -XX:MaxPermSize=256m -XX:+CMSClassUnloadingEnabled
+
+set LIFT_RUN_MODE=-Drun.mode=development
+set TRY_JREBEL=true
+set LOG_LEVEL=
+set NO_PAUSE=false
+set DO_LOOP=false
+
+:PARSER_LOOP
+if "%~1"=="" goto :PARSER_END
+
+if "%~1"=="--prod" (
+ set LIFT_RUN_MODE=-Drun.mode=production
+ goto :PARSER_CONTINUE
+)
+
+if "%~1"=="--debug" (
+ set LOG_LEVEL="set logLevel:=Level.Debug"
+ goto :PARSER_CONTINUE
+)
+
+if "%~1"=="~lift" (
+ set SBT_PARAMS=%SBT_PARAMS% container:start ~compile container:stop
+ set JREBEL_PLUGINS=%JREBEL_PLUGINS% -Drebel.lift_plugin=true
+ goto :PARSER_CONTINUE
+)
+
+if "%~1"=="--no-jrebel" (
+ set TRY_JREBEL=false
+ goto :PARSER_CONTINUE
+)
+
+if "%~1"=="--loop" (
+ set DO_LOOP=true
+ goto :PARSER_CONTINUE
+)
+
+if "%~1"=="--no-pause" (
+ set NO_PAUSE=true
+ goto :PARSER_CONTINUE
+)
+
+set SBT_PARAMS=%SBT_PARAMS% %1
+
+:PARSER_CONTINUE
+shift
+goto :PARSER_LOOP
+:PARSER_END
+
+set JVM_PARAMS=%JVM_PARAMS% %LIFT_RUN_MODE%
+if %TRY_JREBEL%.==true. (
+ if exist "%JREBEL_HOME%\jrebel.jar" set JVM_PARAMS=%JVM_PARAMS% -noverify -javaagent:"%JREBEL_HOME%\jrebel.jar" %JREBEL_PLUGINS%
+)
+
+set GRUJ_PATH=project\strap\gruj_vs_sbt-launch-0.11.2.jar
+set RUN_CMD=java %JVM_PARAMS% -jar %GRUJ_PATH% %LOG_LEVEL% %SBT_PARAMS%
+
+:RUN_LOOP
+%RUN_CMD%
+
+if %DO_LOOP%.==true. (
+ if %NO_PAUSE%.==false. (
+ echo Press Enter to continue or Press CTRL+C to exit!
+ pause
+ )
+ goto :RUN_LOOP
+)
+
+popd
+endlocal
70 code/sbt.sh
@@ -0,0 +1,70 @@
+#!/bin/bash
+cd `dirname $0`
+
+## START JVM PARAMS
+JVM_PARAMS="-Xss2m -Xmx712m -XX:MaxPermSize=256m -XX:+CMSClassUnloadingEnabled"
+
+LIFT_RUN_MODE="-Drun.mode=development"
+TRY_JREBEL=true
+LOG_LEVEL=
+NO_PAUSE=false
+DO_LOOP=false
+
+while [ -n "$*" ]
+do
+ case "$1" in
+ "--debug")
+ echo "Setting debug mode"
+ LOG_LEVEL="\"set logLevel:=Level.Debug\""
+ ;;
+ "--prod")
+ echo "Set Lift mode to Production"
+ LIFT_RUN_MODE="-Drun.mode=production"
+ ;;
+ "~lift")
+ echo "Firing up Jetty ..."
+ SBT_PARAMS="$SBT_PARAMS container:start ~compile container:stop"
+ JREBEL_PLUGINS="$JREBEL_PLUGINS -Drebel.lift_plugin=true"
+ ;;
+ "--no-jrebel")
+ echo "Disabling JRebel for faster compilation"
+ TRY_JREBEL=false
+ ;;
+ "--loop")
+ echo "Will run SBT in loop mode"
+ DO_LOOP=true
+ ;;
+ "--no-pause")
+ echo "Will not pause in loop mode"
+ NO_PAUSE=true
+ ;;
+ *)
+ SBT_PARAMS="$SBT_PARAMS \"$1\""
+ ;;
+ esac
+ shift
+
+done
+
+JVM_PARAMS="$JVM_PARAMS $LIFT_RUN_MODE"
+if $TRY_JREBEL && [ -n "$JREBEL_HOME" ] && [ -f $JREBEL_HOME/jrebel.jar ]; then
+ JVM_PARAMS="$JVM_PARAMS -noverify -javaagent:$JREBEL_HOME/jrebel.jar $JREBEL_PLUGINS"
+fi
+
+GRUJ_PATH="project/strap/gruj_vs_sbt-launch-0.11.2.jar"
+RUN_CMD="java $JVM_PARAMS -jar $GRUJ_PATH $LOG_LEVEL $SBT_PARAMS"
+
+LOOPING=true
+while $LOOPING
+do
+ eval "$RUN_CMD"
+
+ if ! $DO_LOOP ; then
+ LOOPING=false
+ else
+ if ! $NO_PAUSE ; then
+ echo "Press Enter to continue or Press CTRL+C to exit!"
+ read
+ fi
+ fi
+done
5 code/src/main/scala/hr/element/etb/batsh/EntryPoint.scala
@@ -0,0 +1,5 @@
+package hr.element.etb.batsh
+
+object EntryPoint extends App {
+ println("Aloha.")
+}
4 code/test-loop.bat
@@ -0,0 +1,4 @@
+@echo off
+
+echo Entering continuous test loop ...
+call "%~dp0\sbt.bat" --loop %* ~test
4 code/test-loop.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+echo Entering continuous test loop ...
+`dirname $0`/sbt.sh --loop "$@" ~test
Please sign in to comment.
Something went wrong with that request. Please try again.