#!/bin/bash

if [ $# -ne 4 ]; then
    echo "give"
    echo "  groupId"
    echo "  artifactId"
    echo "  version"
    echo "  snapshot or release"
    exit 1
fi

GROUP_ID=$1
ARTIFACT_ID=$2
VERSION=$3
RELEASE_TYPE=$4

JAR=`pwd`/target/${ARTIFACT_ID}-${VERSION}.jar

if [ ${RELEASE_TYPE} == "snapshot" ]; then
   URL=https://repository.jboss.org/nexus/content/repositories/snapshots/
else
   URL=https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/
fi

JAR=`pwd`/target/${ARTIFACT_ID}-${VERSION}.jar

echo Deploying ${JAR}

mvn deploy:deploy-file -Dfile=${JAR} -DgroupId=${GROUP_ID} -DartifactId=${ARTIFACT_ID} -Dpackaging=jar -Dversion=${VERSION} \
  -DrepositoryId=jboss-${4}s-repository -Durl=${URL} -DgeneratePom=false