commit d6ef20efd4a5209214a8020fb19581021c72c4ae
Author: Mikolaj Izdebski <mizdebsk(a)redhat.com>
Date: Wed Mar 6 10:56:55 2013 +0100
Update mvn-* scripts to be compatible with XMvn 0.4.0
scripts/mvn-alias | 24 ++++++++++++++---
scripts/mvn-build | 27 ++++++++-----------
scripts/mvn-file | 19 +++++++++++---
scripts/mvn-package | 13 +++++++--
scripts/xmvn_config_editor.sh | 57 +++++++++++++++++++++++++++++++----------
5 files changed, 100 insertions(+), 40 deletions(-)
---
diff --git a/scripts/mvn-alias b/scripts/mvn-alias
index 88d778c..3301cd6 100755
--- a/scripts/mvn-alias
+++ b/scripts/mvn-alias
@@ -35,13 +35,29 @@ if [ $# -lt 2 ]; then
exit 1
fi
-pattern="$1" shift
+IFS=: read -a pattern <<<"$1"
+shift
+aliases=
while [ $# -gt 0 ]; do
- echo "export
XMVN_INSTALL_DEPMAPS=\"\$XMVN_INSTALL_DEPMAPS\"'$pattern
-$1
-'" >>.xmvnrc
+ IFS=: read -a alias <<<"$1"
shift
+ aliases="$aliases
+ <alias>
+ <groupId>${alias[0]}</groupId>
+ <artifactId>${alias[1]}</artifactId>
+ <version>${alias[2]}</version>
+ </alias>"
done
+xml="<artifact>
+ <groupId>${pattern[0]}</groupId>
+ <artifactId>${pattern[1]}</artifactId>
+ <version>${pattern[2]}</version>
+ </artifact>
+ <aliases>$aliases
+ </aliases>"
+
+. scripts/xmvn_config_editor.sh
+_write_xmvn_config "%mvn_alias macro" "artifactManagement"
"rule" "$xml"
exit 0
diff --git a/scripts/mvn-build b/scripts/mvn-build
index eee9e60..4ee1459 100755
--- a/scripts/mvn-build
+++ b/scripts/mvn-build
@@ -30,8 +30,8 @@
#
# Authors: Mikolaj Izdebski <mizdebsk(a)redhat.com>
-# For now enable debugging by default.
-export XMVN_DEBUG=1
+. ./scripts/xmvn_config_editor.sh
+
need_arg()
{
@@ -87,9 +87,7 @@ pre_goals=
post_goals=
if [ -n "$RPM_PACKAGE_NAME" ]; then
- export XMVN_INSTALL_NAME="$RPM_PACKAGE_NAME"
-else
- export XMVN_INSTALL_NAME=$(basename "$PWD")
+ _write_xmvn_config "%mvn_build macro (default)"
"installerSettings" "packageName" "$RPM_PACKAGE_NAME"
fi
while [ $# -gt 0 ]; do
@@ -99,7 +97,8 @@ while [ $# -gt 0 ]; do
break
;;
-d|--xmvn-debug)
- export XMVN_DEBUG=1
+ _write_xmvn_config "%mvn_build macro (--xmvn-debug option)"
"resolverSettings" "debug" "true"
+ _write_xmvn_config "%mvn_build macro (--xmvn-debug option)"
"installerSettings" "debug" "true"
;;
-f|--force|--skip-tests)
base_goal=package
@@ -130,11 +129,12 @@ while [ $# -gt 0 ]; do
;;
-v|--compat-version)
need_arg "$@"
- export XMVN_INSTALL_VERSIONS="$XMVN_INSTALL_VERSIONS,$2"
+ echo "$0: Option: $1 is not supported for now." >&2
shift
;;
-X|--debug)
- export XMVN_DEBUG=1
+ _write_xmvn_config "%mvn_build macro (--debug option)"
"resolverSettings" "debug" "true"
+ _write_xmvn_config "%mvn_build macro (--debug option)"
"installerSettings" "debug" "true"
debug=-X
;;
*)
@@ -146,14 +146,11 @@ while [ $# -gt 0 ]; do
done
-if [ -f .xmvnrc ]; then
- . ./.xmvnrc
-fi
-
if $singleton; then
- export XMVN_INSTALL_LAYOUT="$XMVN_INSTALL_LAYOUT"':{*}
-@1
-'
+ _write_xmvn_config "%mvn_build macro (--singleton option)"
"artifactManagement" "rule" "<artifact>
+ <artifactId>{*}</artifactId>
+ </artifact>
+ <targetPackage>@1</targetPackage>"
fi
diff --git a/scripts/mvn-file b/scripts/mvn-file
index 93cc8da..8323cbc 100755
--- a/scripts/mvn-file
+++ b/scripts/mvn-file
@@ -35,13 +35,24 @@ if [ $# -lt 2 ]; then
exit 1
fi
-pattern="$1" shift
+IFS=: read -a pattern <<<"$1"
+shift
+files=
while [ $# -gt 0 ]; do
- echo "export XMVN_INSTALL_FILES=\"\$XMVN_INSTALL_FILES\"'$pattern
-$1
-'" >>.xmvnrc
+ files="$files
+ <file>$1</file>"
shift
done
+xml="<artifact>
+ <groupId>${pattern[0]}</groupId>
+ <artifactId>${pattern[1]}</artifactId>
+ <version>${pattern[2]}</version>
+ </artifact>
+ <files>$files
+ </files>"
+
+. scripts/xmvn_config_editor.sh
+_write_xmvn_config "%mvn_file macro" "artifactManagement"
"rule" "$xml"
exit 0
diff --git a/scripts/mvn-package b/scripts/mvn-package
index fa3dc6b..e6f0d8d 100755
--- a/scripts/mvn-package
+++ b/scripts/mvn-package
@@ -35,8 +35,15 @@ if [ $# -ne 2 ]; then
exit 1
fi
-echo "export XMVN_INSTALL_LAYOUT=\"\$XMVN_INSTALL_LAYOUT\"'$1
-$2
-'" >>.xmvnrc
+IFS=: read -a pattern <<<"$1"
+xml="<artifact>
+ <groupId>${pattern[0]}</groupId>
+ <artifactId>${pattern[1]}</artifactId>
+ <version>${pattern[2]}</version>
+ </artifact>
+ <targetPackage>$2</targetPackage>"
+
+. scripts/xmvn_config_editor.sh
+_write_xmvn_config "%mvn_package macro" "artifactManagement"
"rule" "$xml"
exit 0
diff --git a/scripts/xmvn_config_editor.sh b/scripts/xmvn_config_editor.sh
index 5b9964e..204e785 100644
--- a/scripts/xmvn_config_editor.sh
+++ b/scripts/xmvn_config_editor.sh
@@ -31,23 +31,52 @@
# Authors: Mikolaj Izdebski <mizdebsk(a)redhat.com>
-# Create skeleton XMvn reactor configuration file if it doesn't exist
-# yet.
-_xmvn_init_config()
+# Write XMvn reactor configuration file.
+# $1 - name of the macro or script that generated the config file
+# (for documentation purposes only)
+# $2 - 2nd leven major XML tag name (eg. resolverSettings)
+# $3 - 3rd level minor XML tag name (eg. jarRepositories)
+# $4 (optional) - 4th level micro XML tag name (eg. repository)
+# $5 (or $4 if micro tag is not specified) - XML contents
+_write_xmvn_config()
{
- mkdir -p .xmvn
- if ! [[ -e .xmvn/reactor-configuration.xml ]]; then
- cat >.xmvn/reactor-configuration.xml <<EOF
+ mkdir -p .xmvn/config.d
+
+ # index := ++index_file
+ local index_file=.xmvn/javapackages-rule-index
+ local index=$(($(cat $index_file 2>/dev/null || :) + 1))
+ echo $index >$index_file
+
+ # Write common header
+ cat >.xmvn/config.d/javapackages-config-$index.xml <<EOF
<?xml version="1.0" encoding="US-ASCII"?>
-<configuration>
- <artifactManagement>
- <artifactManagement>
- </artifactManagement>
- </artifactManagement>
- <installerSettings>
- <packageName>${RPM_PACKAGE_NAME}</packageName>
- </installerSettings>
+<!-- XMvn configuration file generated with $1
+ from maven-local package (part of javapackages-tools). -->
+<configuration
xmlns="http://fedorahosted.org/xmvn/CONFIG/0.4.0">
+EOF
+
+ if [[ $# -eq 4 ]]; then
+ cat >>.xmvn/config.d/javapackages-config-$index.xml <<EOF
+ <$2>
+ <$3>
+ $4
+ </$3>
+ </$2>
+</configuration>
+EOF
+ elif [[ $# -eq 5 ]]; then
+ cat >>.xmvn/config.d/javapackages-config-$index.xml <<EOF
+ <$2>
+ <$3>
+ <$4>
+ $5
+ </$4>
+ </$3>
+ </$2>
</configuration>
EOF
+ else
+ echo "_write_xmvn_config(): Requires either 4 or 5 arguments"
+ exit 1
fi
}