Last active
September 13, 2024 07:42
-
-
Save manfredk/a791109a02cc68155f042a146ffcd711 to your computer and use it in GitHub Desktop.
List all available maven goals in project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
mvn help:effective-pom 2>/dev/null | \ | |
grep -i -E '^ *<' | \ | |
sed -e 's/ xmlns.*=".*"//g' | \ | |
xmlstarlet sel -t -n -o "Plugin[:phase:goal]" -n \ | |
-o "---------------------------------------------------" -n \ | |
-m "/project/build/plugins/plugin" -v "artifactId" -n \ | |
-m "executions/execution" -v "../../artifactId" -o ":" -v "phase" -o ":" -m "goals" -v "goal" -n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mvn_list_goals.sh
This command is to be executed in a maven project folder, where the project pom resides.
List the effective pom (including all inherited entries)
supress stderr output
keep only lines which contain a match for the extended regex given, having zero or more blanks and a lower-than sign at the beginning
stream edit the output of grep, adding the commands in the sed-script to the edit expressions used when processing the input stream. The script is a substitute following the syntax
s/regex/replacement/flags
and effectively deletes all (flag/g
) found xml namespace attributes as matched by the regex/ xmlns.*=".*"/
, because replacement is empty (//
). Eliminating the namespace from the xml is important for the subsequent xml-processing, since xmlstarlet is picky about proper namespacing of xml tags.process the output of sed, which is clean xml and xslt - transform it into a list of maven-plugins, phases and goals available in the current project.
example output: