diff options
author | Pacien TRAN-GIRARD | 2015-01-22 20:58:09 +0100 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2015-01-22 20:58:09 +0100 |
commit | 2f6780969318c08c7a0a0e8e52a7dad33ff53786 (patch) | |
tree | 893d9356b0fd02b40124712bfa88128f02cd7b53 | |
download | minibay-2f6780969318c08c7a0a0e8e52a7dad33ff53786.tar.gz |
Bootstrap Play Scala project
-rw-r--r-- | .gitignore | 15 | ||||
-rw-r--r-- | LICENSE | 8 | ||||
-rw-r--r-- | README | 4 | ||||
-rwxr-xr-x | activator | 334 | ||||
-rwxr-xr-x | activator-launch-1.2.12.jar | bin | 0 -> 1188338 bytes | |||
-rwxr-xr-x | activator.bat | 227 | ||||
-rw-r--r-- | app/controllers/Application.scala | 12 | ||||
-rw-r--r-- | app/views/index.scala.html | 7 | ||||
-rw-r--r-- | app/views/main.scala.html | 15 | ||||
-rw-r--r-- | build.sbt | 14 | ||||
-rw-r--r-- | conf/application.conf | 62 | ||||
-rw-r--r-- | conf/routes | 9 | ||||
-rw-r--r-- | project/build.properties | 4 | ||||
-rw-r--r-- | project/plugins.sbt | 18 | ||||
-rw-r--r-- | public/images/favicon.png | bin | 0 -> 687 bytes | |||
-rw-r--r-- | public/javascripts/hello.js | 3 | ||||
-rw-r--r-- | public/stylesheets/main.css | 0 | ||||
-rw-r--r-- | test/ApplicationSpec.scala | 30 | ||||
-rw-r--r-- | test/IntegrationSpec.scala | 24 |
19 files changed, 786 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8570daf --- /dev/null +++ b/.gitignore | |||
@@ -0,0 +1,15 @@ | |||
1 | logs | ||
2 | project/project | ||
3 | project/target | ||
4 | target | ||
5 | tmp | ||
6 | .history | ||
7 | dist | ||
8 | /.idea | ||
9 | /*.iml | ||
10 | /out | ||
11 | /.idea_modules | ||
12 | /.classpath | ||
13 | /.project | ||
14 | /RUNNING_PID | ||
15 | /.settings | ||
@@ -0,0 +1,8 @@ | |||
1 | This software is licensed under the Apache 2 license, quoted below. | ||
2 | |||
3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with | ||
4 | the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. | ||
5 | |||
6 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an | ||
7 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific | ||
8 | language governing permissions and limitations under the License. \ No newline at end of file | ||
@@ -0,0 +1,4 @@ | |||
1 | This is your new Play application | ||
2 | ================================= | ||
3 | |||
4 | This file will be packaged with your application, when using `activator dist`. | ||
diff --git a/activator b/activator new file mode 100755 index 0000000..59c131b --- /dev/null +++ b/activator | |||
@@ -0,0 +1,334 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | ### ------------------------------- ### | ||
4 | ### Helper methods for BASH scripts ### | ||
5 | ### ------------------------------- ### | ||
6 | |||
7 | realpath () { | ||
8 | ( | ||
9 | TARGET_FILE="$1" | ||
10 | |||
11 | cd $(dirname "$TARGET_FILE") | ||
12 | TARGET_FILE=$(basename "$TARGET_FILE") | ||
13 | |||
14 | COUNT=0 | ||
15 | while [ -L "$TARGET_FILE" -a $COUNT -lt 100 ] | ||
16 | do | ||
17 | TARGET_FILE=$(readlink "$TARGET_FILE") | ||
18 | cd $(dirname "$TARGET_FILE") | ||
19 | TARGET_FILE=$(basename "$TARGET_FILE") | ||
20 | COUNT=$(($COUNT + 1)) | ||
21 | done | ||
22 | |||
23 | if [ "$TARGET_FILE" == "." -o "$TARGET_FILE" == ".." ]; then | ||
24 | cd "$TARGET_FILE" | ||
25 | TARGET_FILEPATH= | ||
26 | else | ||
27 | TARGET_FILEPATH=/$TARGET_FILE | ||
28 | fi | ||
29 | |||
30 | # make sure we grab the actual windows path, instead of cygwin's path. | ||
31 | if ! is_cygwin; then | ||
32 | echo "$(pwd -P)/$TARGET_FILE" | ||
33 | else | ||
34 | echo $(cygwinpath "$(pwd -P)/$TARGET_FILE") | ||
35 | fi | ||
36 | ) | ||
37 | } | ||
38 | |||
39 | # TODO - Do we need to detect msys? | ||
40 | |||
41 | # Uses uname to detect if we're in the odd cygwin environment. | ||
42 | is_cygwin() { | ||
43 | local os=$(uname -s) | ||
44 | case "$os" in | ||
45 | CYGWIN*) return 0 ;; | ||
46 | *) return 1 ;; | ||
47 | esac | ||
48 | } | ||
49 | |||
50 | # This can fix cygwin style /cygdrive paths so we get the | ||
51 | # windows style paths. | ||
52 | cygwinpath() { | ||
53 | local file="$1" | ||
54 | if is_cygwin; then | ||
55 | echo $(cygpath -w $file) | ||
56 | else | ||
57 | echo $file | ||
58 | fi | ||
59 | } | ||
60 | |||
61 | # Make something URI friendly | ||
62 | make_url() { | ||
63 | url="$1" | ||
64 | local nospaces=${url// /%20} | ||
65 | if is_cygwin; then | ||
66 | echo "/${nospaces//\\//}" | ||
67 | else | ||
68 | echo "$nospaces" | ||
69 | fi | ||
70 | } | ||
71 | |||
72 | # Detect if we should use JAVA_HOME or just try PATH. | ||
73 | get_java_cmd() { | ||
74 | if [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then | ||
75 | echo "$JAVA_HOME/bin/java" | ||
76 | else | ||
77 | echo "java" | ||
78 | fi | ||
79 | } | ||
80 | |||
81 | echoerr () { | ||
82 | echo 1>&2 "$@" | ||
83 | } | ||
84 | vlog () { | ||
85 | [[ $verbose || $debug ]] && echoerr "$@" | ||
86 | } | ||
87 | dlog () { | ||
88 | [[ $debug ]] && echoerr "$@" | ||
89 | } | ||
90 | execRunner () { | ||
91 | # print the arguments one to a line, quoting any containing spaces | ||
92 | [[ $verbose || $debug ]] && echo "# Executing command line:" && { | ||
93 | for arg; do | ||
94 | if printf "%s\n" "$arg" | grep -q ' '; then | ||
95 | printf "\"%s\"\n" "$arg" | ||
96 | else | ||
97 | printf "%s\n" "$arg" | ||
98 | fi | ||
99 | done | ||
100 | echo "" | ||
101 | } | ||
102 | |||
103 | exec "$@" | ||
104 | } | ||
105 | addJava () { | ||
106 | dlog "[addJava] arg = '$1'" | ||
107 | java_args=( "${java_args[@]}" "$1" ) | ||
108 | } | ||
109 | addApp () { | ||
110 | dlog "[addApp] arg = '$1'" | ||
111 | sbt_commands=( "${app_commands[@]}" "$1" ) | ||
112 | } | ||
113 | addResidual () { | ||
114 | dlog "[residual] arg = '$1'" | ||
115 | residual_args=( "${residual_args[@]}" "$1" ) | ||
116 | } | ||
117 | addDebugger () { | ||
118 | addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1" | ||
119 | } | ||
120 | addConfigOpts () { | ||
121 | dlog "[addConfigOpts] arg = '$*'" | ||
122 | for item in $* | ||
123 | do | ||
124 | addJava "$item" | ||
125 | done | ||
126 | } | ||
127 | # a ham-fisted attempt to move some memory settings in concert | ||
128 | # so they need not be messed around with individually. | ||
129 | get_mem_opts () { | ||
130 | local mem=${1:-1024} | ||
131 | local meta=$(( $mem / 4 )) | ||
132 | (( $meta > 256 )) || meta=256 | ||
133 | (( $meta < 1024 )) || meta=1024 | ||
134 | |||
135 | # default is to set memory options but this can be overridden by code section below | ||
136 | memopts="-Xms${mem}m -Xmx${mem}m" | ||
137 | if [[ "${java_version}" > "1.8" ]]; then | ||
138 | extmemopts="-XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=${meta}m" | ||
139 | else | ||
140 | extmemopts="-XX:PermSize=64m -XX:MaxPermSize=${meta}m" | ||
141 | fi | ||
142 | |||
143 | if [[ "${java_opts}" == *-Xmx* ]] || [[ "${java_opts}" == *-Xms* ]] || [[ "${java_opts}" == *-XX:MaxPermSize* ]] || [[ "${java_opts}" == *-XX:ReservedCodeCacheSize* ]] || [[ "${java_opts}" == *-XX:MaxMetaspaceSize* ]]; then | ||
144 | # if we detect any of these settings in ${java_opts} we need to NOT output our settings. | ||
145 | # The reason is the Xms/Xmx, if they don't line up, cause errors. | ||
146 | memopts="" | ||
147 | extmemopts="" | ||
148 | fi | ||
149 | |||
150 | echo "${memopts} ${extmemopts}" | ||
151 | } | ||
152 | require_arg () { | ||
153 | local type="$1" | ||
154 | local opt="$2" | ||
155 | local arg="$3" | ||
156 | if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then | ||
157 | die "$opt requires <$type> argument" | ||
158 | fi | ||
159 | } | ||
160 | is_function_defined() { | ||
161 | declare -f "$1" > /dev/null | ||
162 | } | ||
163 | |||
164 | # If we're *not* running in a terminal, and we don't have any arguments, then we need to add the 'ui' parameter | ||
165 | detect_terminal_for_ui() { | ||
166 | [[ ! -t 0 ]] && [[ "${#residual_args}" == "0" ]] && { | ||
167 | addResidual "ui" | ||
168 | } | ||
169 | # SPECIAL TEST FOR MAC | ||
170 | [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]] && [[ "${#residual_args}" == "0" ]] && { | ||
171 | echo "Detected MAC OSX launched script...." | ||
172 | echo "Swapping to UI" | ||
173 | addResidual "ui" | ||
174 | } | ||
175 | } | ||
176 | |||
177 | # Processes incoming arguments and places them in appropriate global variables. called by the run method. | ||
178 | process_args () { | ||
179 | while [[ $# -gt 0 ]]; do | ||
180 | case "$1" in | ||
181 | -h|-help) usage; exit 1 ;; | ||
182 | -v|-verbose) verbose=1 && shift ;; | ||
183 | -d|-debug) debug=1 && shift ;; | ||
184 | -mem) require_arg integer "$1" "$2" && app_mem="$2" && shift 2 ;; | ||
185 | -jvm-debug) | ||
186 | if echo "$2" | grep -E ^[0-9]+$ > /dev/null; then | ||
187 | addDebugger "$2" && shift | ||
188 | else | ||
189 | addDebugger 9999 | ||
190 | fi | ||
191 | shift ;; | ||
192 | -java-home) require_arg path "$1" "$2" && java_cmd="$2/bin/java" && shift 2 ;; | ||
193 | -D*) addJava "$1" && shift ;; | ||
194 | -J*) addJava "${1:2}" && shift ;; | ||
195 | *) addResidual "$1" && shift ;; | ||
196 | esac | ||
197 | done | ||
198 | |||
199 | is_function_defined process_my_args && { | ||
200 | myargs=("${residual_args[@]}") | ||
201 | residual_args=() | ||
202 | process_my_args "${myargs[@]}" | ||
203 | } | ||
204 | } | ||
205 | |||
206 | # Actually runs the script. | ||
207 | run() { | ||
208 |