commit 9b83bfdb6db2696728537056ff43967333b17b70 Author: Mikolaj Izdebski mizdebsk@redhat.com Date: Mon Jul 30 14:49:04 2012 +0200
Implement %pom_add_plugin
macros.fjava | 28 ++++++++++++++++++++++++++-- scripts/pom_editor.sh | 10 ++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) --- diff --git a/macros.fjava b/macros.fjava index 5969e26..21337b2 100644 --- a/macros.fjava +++ b/macros.fjava @@ -330,9 +330,9 @@ fi \
# %pom_add_dep[_mgmt] - add dependency to POM file # -# Usage: %pom_add_dep groupId:artifactId[:version:[scope]] [POM location] \ +# Usage: %pom_add_dep groupId:artifactId[:version[:scope]] [POM location] \ # [extra XML] -# %pom_add_dep_mgmt groupId:articId[:version:[scope]] [POM location] \ +# %pom_add_dep_mgmt groupId:articId[:version[:scope]] [POM location] \ # [extra XML] # # These macros patch specified POM file adding a dependency on given version of @@ -356,3 +356,27 @@ fi \ } %pom_add_dep_mgmt() %{expand: %{__pom_call}add_dep_mgmt %* } + + +# %pom_add_plugin - add plugin invocation to POM file +# +# Usage: %pom_add_plugin groupId:artifactId[:version] [POM location] \ +# [extra XML] +# +# This macro patches specified POM file adding plugin invocation of given +# groupId and artifactId. +# +# groupId and artifactId are identifiers of Maven plugin artifact of which +# invocation is to be added. groupId may be ommited, in which case value of +# "org.apache.maven.plugins" is used as default. artifactId must be +# specified. If version is not specified then default value of "any" is used. +# +# POM location can be either a full path to the POM file, or a path to the +# directory containing pom.xml. If POM location is not given then pom.xml from +# current working directory is used. +# +# Extra XML is additional XML code to be added into the <plugin> node. This +# parameter can be ommited, in which case no extra XML is appended. +# +%pom_add_plugin() %{expand: %{__pom_call}add_plugin %* +} diff --git a/scripts/pom_editor.sh b/scripts/pom_editor.sh index 5be153f..9cd3756 100644 --- a/scripts/pom_editor.sh +++ b/scripts/pom_editor.sh @@ -202,6 +202,7 @@ _pom_inject_gaid() BEGIN { FS=":" }
{ + if (!$1) { $1="org.apache.maven.plugins" } print "<groupId>" $1 "</groupId>" print "<artifactId>" $2 "</artifactId>" if (!$3) { $3="any" } @@ -302,3 +303,12 @@ pom_add_dep_mgmt() _pom_inject_gaid "pom:project/pom:dependencyManagement" "${1}" "${2}" "dependency" "${3}" set -x } + + +pom_add_plugin() +{ + set +x + _pom_initialize + _pom_inject_gaid "pom:project/pom:build/pom:plugins" "${1}" "${2}" "plugin" "${3}" + set -x +}
java-sig-commits@lists.fedoraproject.org