Skip to content

Instantly share code, notes, and snippets.

@ouyi
Last active February 25, 2019 13:10
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 ouyi/7c64b7a9b83014b714a440be302504c6 to your computer and use it in GitHub Desktop.
Save ouyi/7c64b7a9b83014b714a440be302504c6 to your computer and use it in GitHub Desktop.
Frequently used Maven commands
# --- Maven ---
# Skip test execution
mvn package -DskipTests
# Skip test compilation
mvn package -Dmaven.test.skip=true
# Retrieve the project version
mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec
mvn org.apache.maven.plugins:maven-help-plugin:evaluate -Dexpression=project.version | grep -v '^\['
# Dependency tree
mvn dependency:tree | grep -E 'commons.*fileupload'
# Set up mvnw
mvn -N io.takari:maven:wrapper
# Force a particular maven version:
mvn -N io.takari:maven:wrapper -Dmaven=3.5.4
# Add the new files to Git:
git add .mvn/ mvnw*
git commit -m "Add mvnw"
# Count artifactory packages matching given path and naming patterns
REMOTE_PACKAGE_COUNT=$(curl -s "https://${ARTIFACTORY}/artifactory/api/search/artifact?name=${PACKAGE_FILENAME}&repos=${ARTIFACTORY_ROOT}" | jq ".results | map(select(.uri | test(\"${ARTIFACTORY_PATH}.*${PACKAGE_FILENAME}\"))) | length")
if [ "$REMOTE_PACKAGE_COUNT" -ne 0 ]; then
echo "Package already exits at target path"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment