Skip to content

Instantly share code, notes, and snippets.

@favila
Created April 10, 2026 22:01
Show Gist options
  • Select an option

  • Save favila/e4644c250ff5f19c0834cea7418232c3 to your computer and use it in GitHub Desktop.

Select an option

Save favila/e4644c250ff5f19c0834cea7418232c3 to your computer and use it in GitHub Desktop.
mvn-copy: copy a pom and jar to a local repo easily
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -eq 1 ]]; then
pom="${1}.pom"
jar="${1}.jar"
elif [[ $# -eq 2 ]]; then
pom="$1"
jar="$2"
else
echo "Usage: mvn-copy <prefix> | mvn-copy <pom> <jar>" >&2
exit 1
fi
if [[ ! -f "$pom" ]]; then
echo "Error: pom file not found: $pom" >&2
exit 1
fi
if [[ ! -f "$jar" ]]; then
echo "Error: jar file not found: $jar" >&2
exit 1
fi
mvn install:install-file -q -Dfile="$jar" -DpomFile="$pom"
echo '${project.groupId}/${project.artifactId} "${project.version}"' \
| mvn help:evaluate -q -DforceStdout -f "$pom"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment