aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-10-31 16:27:09 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-11-01 19:58:08 +0100
commitf743a82f560a2b1da4bc1b5f3236c4226fa6a9ab (patch)
treee10a6c9db89e7fbae53ffcc0a1e080467a3a961e
parent302938d3671048ebc4fd397e4cf6f8f0beed0579 (diff)
downloadapp.sh-f743a82f560a2b1da4bc1b5f3236c4226fa6a9ab.tar.gz
app.sh-f743a82f560a2b1da4bc1b5f3236c4226fa6a9ab.tar.bz2
app.sh-f743a82f560a2b1da4bc1b5f3236c4226fa6a9ab.tar.xz
app.sh-f743a82f560a2b1da4bc1b5f3236c4226fa6a9ab.zip
app-resolver-maven: Adding support for artifacts with classifier.
-rwxr-xr-xlibexec/app-resolver-maven43
-rwxr-xr-xtest/app-resolver-maven.bats27
2 files changed, 60 insertions, 10 deletions
diff --git a/libexec/app-resolver-maven b/libexec/app-resolver-maven
index ec1ad6b..4e21c4b 100755
--- a/libexec/app-resolver-maven
+++ b/libexec/app-resolver-maven
@@ -12,6 +12,8 @@ usage_text() {
echo "usage: $usage_app init -r <repo> <maven url>"
echo "usage: $usage_app resolve-version"
echo "usage: $usage_app download-version -v <version> -f <download target>"
+ echo "Maven url can be one of: <group id>:<artifact id>:<version> and"
+ echo "<group id>:<artifact id>:<classifier>:<version>"
}
slash() {
@@ -122,6 +124,7 @@ xmlstarlet() {
resolve_version() {
local group_id=`app-conf get maven.group_id`
local artifact_id=`app-conf get maven.artifact_id`
+ local classifier=`app-conf get app.classifier`
local version=`app-conf get app.version`
repo=`app-conf get maven.repo`
@@ -199,15 +202,17 @@ download_version() {
repo=`app-conf get maven.repo`
group_id=`app-conf get maven.group_id`
artifact_id=`app-conf get maven.artifact_id`
+ classifier=`app-conf get maven.classifier`
version=`app-conf get app.version`
group_id_slash=`slash $group_id`
base_path=$group_id_slash/$artifact_id/$version
+ file_name=$artifact_id-$resolved_version${classifier:+-}$classifier.zip
mkdir -p .app/cache/$base_path
- l=.app/cache/$base_path/$artifact_id-$resolved_version.zip
- r=$repo/$base_path/$artifact_id-$resolved_version.zip
+ l=.app/cache/$base_path/$file_name
+ r=$repo/$base_path/$file_name
echo "Downloading $group_id:$artifact_id:$resolved_version..."
get $r $l
@@ -236,17 +241,35 @@ init() {
x=${x//:/ }
set -- $x
- if [[ $# != 3 || $1 == "" || $2 == "" || $3 == "" ]]
- then
- usage "Invalid Maven coordinates: $coordinates"
- fi
-
- group_id=$1
- artifact_id=$2
- version=$3
+ case $# in
+ 3)
+ if [[ $1 == "" || $2 == "" || $3 == "" ]]
+ then
+ usage "Invalid Maven coordinates: $coordinates"
+ fi
+ group_id=$1; shift
+ artifact_id=$1; shift
+ classifier=
+ version=$1; shift
+ ;;
+ 4)
+ if [[ $1 == "" || $2 == "" || $3 == "" || $4 == "" ]]
+ then
+ usage "Invalid Maven coordinates: $coordinates"
+ fi
+ group_id=$1; shift
+ artifact_id=$1; shift
+ classifier=$1; shift
+ version=$1; shift
+ ;;
+ *)
+ usage "Invalid Maven coordinates: $coordinates"
+ ;;
+ esac
app-conf set maven.group_id "$group_id"
app-conf set maven.artifact_id "$artifact_id"
+ [[ ! -z $classifier ]] && app-conf set maven.classifier "$classifier"
app-conf set app.version "$version"
}
diff --git a/test/app-resolver-maven.bats b/test/app-resolver-maven.bats
new file mode 100755
index 0000000..e5a5474
--- /dev/null
+++ b/test/app-resolver-maven.bats
@@ -0,0 +1,27 @@
+#!/usr/bin/env bats
+# vim: set filetype=sh:
+
+load utils
+
+@test "plain init" {
+ mkdir .app
+ app resolver-maven init my-group:my-artifact:1.0-SNAPSHOT
+ app cat-conf
+ eq '${lines[0]}' "app.version=1.0-SNAPSHOT"
+ eq '${lines[1]}' "maven.artifact_id=my-artifact"
+ eq '${lines[2]}' "maven.group_id=my-group"
+ eq '${lines[3]}' "maven.repo=http://repo1.maven.org"
+ eq '${#lines[*]}' 4
+}
+
+@test "init with classifier" {
+ mkdir .app
+ app resolver-maven init my-group:my-artifact:app:1.0-SNAPSHOT
+ app cat-conf
+ eq '${lines[0]}' "app.version=1.0-SNAPSHOT"
+ eq '${lines[1]}' "maven.artifact_id=my-artifact"
+ eq '${lines[2]}' "maven.classifier=app"
+ eq '${lines[3]}' "maven.group_id=my-group"
+ eq '${lines[4]}' "maven.repo=http://repo1.maven.org"
+ eq '${#lines[*]}' 5
+}