echo " -p <maven_params>"
echo " -a <artifact_id>"
echo " -c <classifier>"
+ echo " -f <pom file>"
echo " -g <group_id>"
echo " -v <version>"
}
;;
f)
local pom_file="$OPTARG"
- echo "pom-file: $pom_file"
- echo "ERROR: pom_file is currently unimplemented."
- exit 1
;;
g)
local group_id="$OPTARG"
exit 1
fi
- # Until we implement the -f <pom-file> parameter assume that group_id must
- # be passed.
- if [ -z "$group_id" ]; then
- echo "ERROR: group_id must be defined. Please pass -g <group_id>."
- exit 1
- fi
-
################
# Start script #
################
params+=("$mvn_params")
fi
- local file_type
- if [[ "$file" == *.tar.gz ]]; then
- file_type="tar.gz"
+ if [ ! -z "$pom_file" ]; then
+ params+=("-DpomFile=\"$pom_file\"")
else
- file_type="${file##*.}"
- fi
- params+=("-Dtype=\"$file_type\"")
+ # Ensure groupId is passed when -f <pom-file> parameter is not used
+ if [ -z "$group_id" ]; then
+ echo "ERROR: group_id must be defined. Please pass -g <group_id>."
+ exit 1
+ fi
+
+ local file_type
+ if [[ "$file" == *.tar.gz ]]; then
+ file_type="tar.gz"
+ else
+ file_type="${file##*.}"
+ fi
+ params+=("-Dtype=\"$file_type\"")
+ params+=("-Dpackaging=\"$file_type\"")
+
+ case "$file_type" in
+ deb )
+ if hash dpkg 2>/dev/null; then
+ echo "dpkg command is available."
+
+ # If user does not provide artifact_id and / or version then parse
+ # information from file.
+ if [ -z "$artifact_id" ]; then
+ artifact_id=$(dpkg -I "$file" | grep ' Package: ' | sed 's/^[ \t]*Package:[ \t]*//')
- case "$file_type" in
- deb )
- if hash dpkg 2>/dev/null; then
- echo "dpkg command is available."
+ fi
+ if [ -z "$version" ]; then
+ version=$(dpkg -I "$file" | grep ' Version: ' | sed 's/^[ \t]*Version:[ \t]*//')
+ fi
+ else
+ echo "dpkg command is not available."
- # If user does not provide artifact_id and / or version then parse
- # information from file.
- if [ -z "$artifact_id" ]; then
- artifact_id=$(dpkg -I "$file" | grep ' Package: ' | sed 's/^[ \t]*Package:[ \t]*//')
+ basefile=$(basename -s .deb "$file")
+ # If user does not provide artifact_id and / or version then parse
+ # information from file.
+ if [ -z "$artifact_id" ]; then
+ artifact_id=$(echo "$basefile" | cut -f 1 -d '_')
+ fi
+ if [ -z "$version" ]; then
+ version=$(echo "$basefile" | cut -f 2- -d '_')
+ fi
fi
- if [ -z "$version" ]; then
- version=$(dpkg -I "$file" | grep ' Version: ' | sed 's/^[ \t]*Version:[ \t]*//')
- fi
- else
- echo "dpkg command is not available."
+ ;;
- basefile=$(basename -s .deb "$file")
+ rpm )
+ if hash rpm 2>/dev/null; then
+ echo "rpm command is available."
- # If user does not provide artifact_id and / or version then parse
- # information from file.
- if [ -z "$artifact_id" ]; then
- artifact_id=$(echo "$basefile" | cut -f 1 -d '_')
- fi
- if [ -z "$version" ]; then
- version=$(echo "$basefile" | cut -f 2- -d '_')
- fi
- fi
- ;;
+ # If user does not provide artifact_id and / or version then parse
+ # information from file.
+ if [ -z "$artifact_id" ]; then
+ artifact_id=$(rpm -qp --queryformat="%{name}" "$file")
+ fi
+ if [ -z "$version" ]; then
+ if grep -qE '\.s(rc\.)?rpm' <<<"$file"; then
+ rpmrelease=$(rpm -qp --queryformat="%{release}.src" "$file")
+ else
+ rpmrelease=$(rpm -qp --queryformat="%{release}.%{arch}" "$file")
+ fi
+
+ version=$(rpm -qp --queryformat="%{version}" "$file")
+ version+="-$rpmrelease"
+ fi
+ else
+ echo "rpm command is not available."
- rpm )
- if hash rpm 2>/dev/null; then
- echo "rpm command is available."
+ basefile=$(basename -s .rpm "$file")
- # If user does not provide artifact_id and / or version then parse
- # information from file.
- if [ -z "$artifact_id" ]; then
- artifact_id=$(rpm -qp --queryformat="%{name}" "$file")
- fi
- if [ -z "$version" ]; then
- if grep -qE '\.s(rc\.)?rpm' <<<"$file"; then
- rpmrelease=$(rpm -qp --queryformat="%{release}.src" "$file")
- else
- rpmrelease=$(rpm -qp --queryformat="%{release}.%{arch}" "$file")
+ # If user does not provide artifact_id and / or version then parse
+ # information from file.
+ if [ -z "$artifact_id" ]; then
+ artifact_id=$(echo "$basefile" | rev | cut -f 3- -d '-' | rev)
+ fi
+ if [ -z "$version" ]; then
+ version=$(echo "$basefile" | rev | cut -f 1 -d '-' | rev)
fi
-
- version=$(rpm -qp --queryformat="%{version}" "$file")
- version+="-$rpmrelease"
fi
- else
- echo "rpm command is not available."
+ ;;
+
+ jar|tar.gz|war )
- basefile=$(basename -s .rpm "$file")
+ basefile=$(basename -s ".$file_type" "$file")
# If user does not provide artifact_id and / or version then parse
# information from file.
if [ -z "$artifact_id" ]; then
- artifact_id=$(echo "$basefile" | rev | cut -f 3- -d '-' | rev)
+ artifact_id=$(echo "$basefile" | rev | cut -f 2- -d '-' | rev)
fi
if [ -z "$version" ]; then
version=$(echo "$basefile" | rev | cut -f 1 -d '-' | rev)
fi
- fi
- ;;
+ ;;
- * )
- echo "ERROR: Unrecognized file type \"$file_type\"." 1>&2
- exit 1
- ;;
- esac
+ * )
+ echo "ERROR: Unrecognized file type \"$file_type\"." 1>&2
+ exit 1
+ ;;
+ esac
- params+=("-DgroupId=\"$group_id\"")
- params+=("-DartifactId=\"$artifact_id\"")
- params+=("-Dversion=\"$version\"")
+ params+=("-DgroupId=\"$group_id\"")
+ params+=("-DartifactId=\"$artifact_id\"")
+ params+=("-Dversion=\"$version\"")
- if [ ! -z "$classifier" ]; then
- params+=("-Dclassifier=\"$classifier\"")
+ if [ ! -z "$classifier" ]; then
+ params+=("-Dclassifier=\"$classifier\"")
+ fi
fi
# Disable the Maven transfer output.