Skip to content

Instantly share code, notes, and snippets.

@henrik242
Last active March 8, 2023 01:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henrik242/0ff02b2cda4d24272cda to your computer and use it in GitHub Desktop.
Save henrik242/0ff02b2cda4d24272cda to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -lt 3 ]; then
echo "Usage: maven-deploy-file groupId artifactId version [packaging] [repository]"
exit 1
fi
GROUP=$1
ARTIFACT=$2
VERSION=$3
PACKAGING=jar
REPO=http://mavenproxy.example.com/nexus/content/repositories/some-default-repo
if test -n "$4"; then
PACKAGING=$4
fi
if test -n "$5"; then
REPO=$5
fi
EXEC="mvn deploy:deploy-file -Durl=$REPO -DgroupId=$GROUP -DartifactId=$ARTIFACT -Dversion=$VERSION -Dpackaging=$PACKAGING"
if [ $PACKAGING = "pom" ]; then
if test -s "./$ARTIFACT-$VERSION.pom"; then
EXEC+=" -Dfile=./$ARTIFACT-$VERSION.pom"
else
echo Missing artifact ./$ARTIFACT-$VERSION.pom
exit 1
fi
else
if test -s "./$ARTIFACT-$VERSION.$PACKAGING"; then
EXEC+=" -Dfile=./$ARTIFACT-$VERSION.$PACKAGING"
else
echo Missing artifact ./$ARTIFACT-$VERSION.$PACKAGING
exit 1
fi
if test -s "./$ARTIFACT-$VERSION.pom"; then
EXEC+=" -DpomFile=./$ARTIFACT-$VERSION.pom"
else
EXEC+=" -DgeneratePom=true"
fi
if test -s "./$ARTIFACT-$VERSION-sources.jar"; then
EXEC+=" -Dsources=./$ARTIFACT-$VERSION-sources.jar"
fi
if test -s "./$ARTIFACT-$VERSION-javadoc.jar"; then
EXEC+=" -Djavadoc=./$ARTIFACT-$VERSION-javadoc.jar"
fi
fi
echo -n "About to execute this:
$EXEC
OK? (y/N) "
read i
if [ "$i" = "y" ]; then
$EXEC
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment