Skip to content

Instantly share code, notes, and snippets.

@mkotsbak
Last active January 29, 2018 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkotsbak/23c15ceb1fac058d6f223ee93c2b6865 to your computer and use it in GitHub Desktop.
Save mkotsbak/23c15ceb1fac058d6f223ee93c2b6865 to your computer and use it in GitHub Desktop.
Script to upload all .jar and .pom files in a directory tree
#!/usr/bin/env bash
MVN_BIN=/[maven_dir]/bin/mvn
REP_ID=repository_id
REP_URL=http://repository_url/
INPUT_DIR=$1 # Where jar and pom files are located
DRY_RUN=false
POMS=`find $INPUT_DIR -name *.pom`
for POM in $POMS; do
echo Pom: $POM
JAR=`echo $POM | sed s/\.pom$/.jar/`
echo Jar: $JAR
# If there is no jar, just deploy the pom file
if [ -f $JAR ]; then
FILE_PARAM=$JAR
else
FILE_PARAM=$POM
fi
CMD="$MVN_BIN deploy:deploy-file -DpomFile=$POM -Dfile=$FILE_PARAM -DrepositoryId=$REP_ID -Durl=$REP_URL"
if [ "$DRY_RUN" = false ]; then
echo Running: $CMD
$CMD
else
echo Cmd to run: $CMD
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment