Skip to content

Instantly share code, notes, and snippets.

@ouyi
Last active Feb 25, 2019
Embed
What would you like to do?
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