-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaven-check-pom-xml
More file actions
executable file
·27 lines (25 loc) · 1.2 KB
/
maven-check-pom-xml
File metadata and controls
executable file
·27 lines (25 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash
# A hook to check for any error in a pom.xml file
set -TCEeuo pipefail
# validate the project is correct and all necessary information is available
# https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
if ! ./mvnw validate -Dorg.slf4j.simpleLogger.defaultLogLevel=warn; then
echo "mvn validate command failed"
exit 1
fi
# Unfortunately, missing version is a warning, not an error
EFFECTIVE_POM=/tmp/effective-pom.xml
# No warning, no error
# We filter out also the lines:
# Downloaded from central: https://repo.maven.apache
# Downloading from central: https://repo.maven.apache (This second line was a human error. It seems that the term is downloaded, not downloading)
# Grep returns always true
# Note that the option `--no-transfer-progress` may discard the `downloaded and downloading` console output
if ! LOG=$(./mvnw help:effective-pom --no-transfer-progress --batch-mode -Dorg.slf4j.simpleLogger.defaultLogLevel=warn -Doutput="$EFFECTIVE_POM" | (grep --invert-match -e "^Download" || true)); then
printf 'Error mvn effective command failed\n%s' "$LOG"
exit 1
fi
if [ "$LOG" != "" ]; then
printf 'Error or warning seen in pom.xml file:\n%s' "$LOG"
exit 1
fi