mirror of https://github.com/sbt/sbt.git
Merge pull request #276 from exoego/fix-4833-print-sbtVersion
Add -V|-version to print sbtVersion.
This commit is contained in:
commit
10693a800a
|
|
@ -10,6 +10,7 @@ Usage: sbt [options]
|
||||||
|
|
||||||
-h | -help print this message
|
-h | -help print this message
|
||||||
-v | -verbose this runner is chattier
|
-v | -verbose this runner is chattier
|
||||||
|
-V | -version print the version of mothership sbt
|
||||||
-d | -debug set sbt log level to debug
|
-d | -debug set sbt log level to debug
|
||||||
-no-colors disable ANSI color codes
|
-no-colors disable ANSI color codes
|
||||||
-sbt-create start sbt even if current directory contains no sbt project
|
-sbt-create start sbt even if current directory contains no sbt project
|
||||||
|
|
|
||||||
|
|
@ -79,4 +79,14 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions {
|
||||||
()
|
()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test("sbt -V|-version should print sbtVersion") {
|
||||||
|
val out = sbtProcessWithOpts("-version", "", "").!!.trim
|
||||||
|
val expectedVersion = "^sbt version in this project: \\d\\.\\d+\\.\\d+\\S*$"
|
||||||
|
assert(out.matches(expectedVersion))
|
||||||
|
|
||||||
|
val out2 = sbtProcessWithOpts("-V", "", "").!!.trim
|
||||||
|
assert(out2.matches(expectedVersion))
|
||||||
|
()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ The current directory is assumed to be the project.
|
||||||
Show help options.
|
Show help options.
|
||||||
.IP "-v, -verbose"
|
.IP "-v, -verbose"
|
||||||
turn up the noise
|
turn up the noise
|
||||||
|
.IP "-V, -version"
|
||||||
|
print the version of mothership sbt
|
||||||
.IP "-d, -debug"
|
.IP "-d, -debug"
|
||||||
set sbt log level to debug
|
set sbt log level to debug
|
||||||
.IP -no-colors
|
.IP -no-colors
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ declare -a java_args
|
||||||
declare -a scalac_args
|
declare -a scalac_args
|
||||||
declare -a sbt_commands
|
declare -a sbt_commands
|
||||||
declare -a sbt_options
|
declare -a sbt_options
|
||||||
|
declare -a print_sbt_version
|
||||||
declare java_cmd=java
|
declare java_cmd=java
|
||||||
declare java_version
|
declare java_version
|
||||||
declare init_sbt_version=_to_be_replaced
|
declare init_sbt_version=_to_be_replaced
|
||||||
|
|
@ -375,14 +376,19 @@ run() {
|
||||||
addJava "-Dsbt.cygwin=true"
|
addJava "-Dsbt.cygwin=true"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# run sbt
|
if [[ $print_sbt_version ]]; then
|
||||||
execRunner "$java_cmd" \
|
# print sbtVersion
|
||||||
$(get_gc_opts) \
|
execRunner "$java_cmd" -jar "$sbt_jar" "sbtVersion" | tail -1 | sed -e 's/\[info\]/sbt version in this project:/g'
|
||||||
${java_args[@]} \
|
else
|
||||||
${sbt_options[@]} \
|
# run sbt
|
||||||
-jar "$sbt_jar" \
|
execRunner "$java_cmd" \
|
||||||
"${sbt_commands[@]}" \
|
$(get_gc_opts) \
|
||||||
"${residual_args[@]}"
|
${java_args[@]} \
|
||||||
|
${sbt_options[@]} \
|
||||||
|
-jar "$sbt_jar" \
|
||||||
|
"${sbt_commands[@]}" \
|
||||||
|
"${residual_args[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
|
|
||||||
|
|
@ -405,6 +411,7 @@ Usage: `basename "$0"` [options]
|
||||||
|
|
||||||
-h | --help print this message
|
-h | --help print this message
|
||||||
-v | --verbose this runner is chattier
|
-v | --verbose this runner is chattier
|
||||||
|
-V | --version print the version of mothership sbt
|
||||||
-d | --debug set sbt log level to debug
|
-d | --debug set sbt log level to debug
|
||||||
--no-colors disable ANSI color codes
|
--no-colors disable ANSI color codes
|
||||||
--color=auto|always|true|false|never
|
--color=auto|always|true|false|never
|
||||||
|
|
@ -441,7 +448,7 @@ Usage: `basename "$0"` [options]
|
||||||
are prepended to the runner args
|
are prepended to the runner args
|
||||||
/etc/sbt/sbtopts if this file exists, it is prepended to the runner args
|
/etc/sbt/sbtopts if this file exists, it is prepended to the runner args
|
||||||
-Dkey=val pass -Dkey=val directly to the java runtime
|
-Dkey=val pass -Dkey=val directly to the java runtime
|
||||||
-J-X pass option -X directly to the java runtime
|
-J-X pass option -X directly to the java runtime
|
||||||
(-J is stripped)
|
(-J is stripped)
|
||||||
-S-X add -X to sbt's scalacOptions (-S is stripped)
|
-S-X add -X to sbt's scalacOptions (-S is stripped)
|
||||||
|
|
||||||
|
|
@ -464,7 +471,7 @@ process_my_args () {
|
||||||
done
|
done
|
||||||
|
|
||||||
# Now, ensure sbt version is used.
|
# Now, ensure sbt version is used.
|
||||||
[[ "${sbt_version}XXX" != "XXX" ]] && addJava "-Dsbt.version=$sbt_version"
|
[[ "${sbt_version}XXX" != "XXX" ]] && addJava "-Dsbt.version=$sbt_version"
|
||||||
|
|
||||||
# Confirm a user's intent if the current directory does not look like an sbt
|
# Confirm a user's intent if the current directory does not look like an sbt
|
||||||
# top-level directory and neither the -sbt-create option nor the "new"
|
# top-level directory and neither the -sbt-create option nor the "new"
|
||||||
|
|
@ -512,6 +519,7 @@ process_args () {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h|-help) usage; exit 1 ;;
|
-h|-help) usage; exit 1 ;;
|
||||||
-v|-verbose) verbose=1 && shift ;;
|
-v|-verbose) verbose=1 && shift ;;
|
||||||
|
-V|-version) print_sbt_version=1 && shift ;;
|
||||||
-d|-debug) debug=1 && addSbt "-debug" && shift ;;
|
-d|-debug) debug=1 && addSbt "-debug" && shift ;;
|
||||||
|
|
||||||
-ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;;
|
-ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue