mirror of https://github.com/sbt/sbt.git
Creation configuration starting to take shape.
This commit is contained in:
parent
0920f5dda8
commit
6c679d457f
|
|
@ -17,8 +17,8 @@ BASE=$(abspath $BINDIR/..)
|
|||
|
||||
declare -a args
|
||||
TEMPLATE="simple"
|
||||
SCALA_VERSION="2.9.0"
|
||||
PROJECT_VERSION="0.0.1"
|
||||
SCALA_VERSION="2.9.1"
|
||||
PROJECT_VERSION="0.1"
|
||||
DO_GITHUB=
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
|
|
@ -112,81 +112,8 @@ build.scala.versions=$SCALA_VERSION
|
|||
project.initialize=false
|
||||
EOF
|
||||
|
||||
# cat > src/main/scala/Main.scala <<EOF
|
||||
# package $PACKAGE
|
||||
#
|
||||
# object Main {
|
||||
# def main(args: Array[String]): Unit = ()
|
||||
# }
|
||||
# EOF
|
||||
|
||||
cat > src/test/scala/${SPEC_CLASS}.scala <<EOF
|
||||
package $PACKAGE
|
||||
|
||||
import org.specs._
|
||||
|
||||
class ${SPEC_CLASS} extends Specification {
|
||||
"A skeletal specification" should {
|
||||
"do little beyond creating a skeleton" >> {
|
||||
1 mustEqual 1
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
FILE=project/build/${PROJECT_CLASS}.scala
|
||||
if [[ $TEMPLATE == "fancy" ]]; then
|
||||
cp $BASE/src/template/Libraries.scala project/build
|
||||
cp $BASE/src/template/Repositories.scala project/build
|
||||
cp $BASE/src/template/Plugins.scala project/plugins
|
||||
|
||||
cat > $FILE <<EOF
|
||||
import sbt._
|
||||
|
||||
class ${PROJECT_CLASS}(info: ProjectInfo) extends DefaultProject(info) with Libraries {
|
||||
// ...
|
||||
}
|
||||
EOF
|
||||
else
|
||||
cat > $FILE <<EOF
|
||||
import sbt._
|
||||
|
||||
class ${PROJECT_CLASS}(info: ProjectInfo) extends DefaultProject(info) with ProjectSupport {
|
||||
|
||||
}
|
||||
|
||||
EOF
|
||||
|
||||
cat $BASE/src/main/resources/$TEMPLATE.scala >> $FILE
|
||||
cp $BASE/src/template/Plugins.scala project/plugins
|
||||
fi
|
||||
|
||||
ln -s $FILE
|
||||
|
||||
cat > .gitignore <<EOF
|
||||
/${PROJECT_CLASS}.scala
|
||||
target
|
||||
/project/boot
|
||||
/project/plugins
|
||||
lib_managed
|
||||
src_managed
|
||||
/ext
|
||||
EOF
|
||||
|
||||
git init
|
||||
git add .gitignore project src
|
||||
git add -f project/plugins/Plugins.scala
|
||||
git commit -m "Initial Import for ${PROJECT_CC} (autogenerated by sbt-setup)."
|
||||
createGitRepo
|
||||
sbt update package test
|
||||
|
||||
if [[ $DO_GITHUB ]]; then
|
||||
GIT_URL="git@github.com:$(githubUser)/$PROJECT.git"
|
||||
echo Creating $GIT_URL
|
||||
hub create
|
||||
git config --local --add branch.master.remote origin
|
||||
git config --local --add branch.master.merge refs/heads/master
|
||||
git push origin master
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Ready to roll in $PWD"
|
||||
|
|
|
|||
40
bin/util.sh
40
bin/util.sh
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
|
||||
function camelCase () {
|
||||
camelCase () {
|
||||
# pretty sad having to resort to this in 2011
|
||||
SED=""
|
||||
if [ -f /usr/local/bin/gsed ]; then
|
||||
|
|
@ -10,13 +10,45 @@ function camelCase () {
|
|||
SED=sed
|
||||
fi
|
||||
|
||||
echo $1 | $SED -e 's/[-_]\([a-z]\)/\u\1/g' | $SED -e 's/^./\u&/;'
|
||||
echo "$1" | $SED -e 's/[-_]\([a-z]\)/\u\1/g' | $SED -e 's/^./\u&/;'
|
||||
}
|
||||
|
||||
function githubUser () {
|
||||
githubUser () {
|
||||
echo $(git config --global github.user)
|
||||
}
|
||||
|
||||
function githubToken () {
|
||||
githubToken () {
|
||||
echo $(git config --global github.token)
|
||||
}
|
||||
|
||||
createGithub () {
|
||||
which hub && { echo "You need hub for this." ; return }
|
||||
|
||||
local project="$1"
|
||||
local git_url="git@github.com:$(git config --global github.user)/$project.git"
|
||||
|
||||
echo Creating $git_url
|
||||
hub create
|
||||
git config --local --add branch.master.remote origin
|
||||
git config --local --add branch.master.merge refs/heads/master
|
||||
git push origin master
|
||||
fi
|
||||
|
||||
createGitIgnore () {
|
||||
cat > .gitignore <<EOM
|
||||
target
|
||||
/project/boot
|
||||
/project/plugins
|
||||
lib_managed
|
||||
src_managed
|
||||
/ext
|
||||
EOM
|
||||
}
|
||||
|
||||
createGitRepo () {
|
||||
createGitIgnore
|
||||
git init
|
||||
git add .gitignore project src
|
||||
git add -f project/plugins/Plugins.scala
|
||||
git commit -m "Initial Import."
|
||||
}
|
||||
|
|
|
|||
33
bin/xsbt
33
bin/xsbt
|
|
@ -1,15 +1,36 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
|
||||
sbt_jar=/soft/inst/sbt/xsbt-launch.jar
|
||||
declare -r script_name="$(basename $BASH_SOURCE)"
|
||||
declare -r sbt_jar=/soft/inst/sbt/xsbt-launch.jar
|
||||
|
||||
jvm_opts_standard="-XX:+CMSClassUnloadingEnabled -XX:ReservedCodeCacheSize=1g"
|
||||
jvm_opts_memory="-XX:MaxPermSize=512m -Xmx4g -Xss4m"
|
||||
|
||||
# get completion if present
|
||||
[[ -f .sbt_completion.sh ]] && source .sbt_completion.sh
|
||||
|
||||
java $JAVA_OPTS \
|
||||
$SBT_OPTS \
|
||||
-XX:+CMSClassUnloadingEnabled \
|
||||
-XX:ReservedCodeCacheSize=1g \
|
||||
-XX:MaxPermSize=512m -Xmx4g -Xss4m \
|
||||
usage () {
|
||||
cat <<EOM
|
||||
Usage: $script_name [options]
|
||||
|
||||
--create creates a new project
|
||||
--28 latest release of scala 2.8.x
|
||||
--29 latest release of scala 2.9.x
|
||||
--version <version> project initial version
|
||||
EOM
|
||||
}
|
||||
|
||||
# no args
|
||||
[[ $# -gt 0 ]] || { usage ; exit 1; }
|
||||
|
||||
# run
|
||||
java \
|
||||
$JAVA_OPTS \
|
||||
$jvm_opts_standard \
|
||||
$jvm_opts_memory \
|
||||
$SBT_OPTS \
|
||||
-jar "$sbt_jar" \
|
||||
"$@"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,26 @@ import Keys._
|
|||
import Load.{ BuildStructure, StructureIndex }
|
||||
import scala.collection.{ mutable, immutable }
|
||||
|
||||
object TemplateBuild extends Build {
|
||||
trait SbtCreateConfig {
|
||||
def name: String
|
||||
def organization: String
|
||||
def version: String
|
||||
def scalaVersion: String
|
||||
}
|
||||
object SbtCreateConfig {
|
||||
private def prop(propName: String, alt: String) = System.getProperty(propName) match {
|
||||
case null => alt
|
||||
case value => value
|
||||
}
|
||||
implicit def defaultProjectConfig = new SbtCreateConfig {
|
||||
def name = prop("sbt-create.name", "project-name-here")
|
||||
def organization = prop("sbt-create.organization", "your.organization.here")
|
||||
def version = prop("sbt-create.version", "0.1")
|
||||
def scalaVersion = prop("sbt-create.scalaVersion", "2.9.0-1")
|
||||
}
|
||||
}
|
||||
|
||||
class TemplateBuild(implicit sbtCreateConfig: SbtCreateConfig) extends Build {
|
||||
// BuildStructure contains:
|
||||
// units: Map[URI, LoadedBuildUnit]
|
||||
// root: URI
|
||||
|
|
@ -96,3 +115,5 @@ object TemplateBuild extends Build {
|
|||
state tap (_.sortedKeys map (_.label) show)
|
||||
}
|
||||
}
|
||||
|
||||
object TemplateBuild extends TemplateBuild { }
|
||||
|
|
|
|||
Loading…
Reference in New Issue