[maven-repo-helper] 03/03: Added the --relocate option to mh_installpom

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Wed Jun 29 21:22:38 UTC 2016


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to branch master
in repository maven-repo-helper.

commit 0a30b6033433048d43df8eef94a553dab7b8ede3
Author: Emmanuel Bourg <ebourg at apache.org>
Date:   Wed Jun 29 19:39:02 2016 +0200

    Added the --relocate option to mh_installpom
---
 debian/changelog           |  1 +
 doc/ref/mh_installpom.rst  |  1 +
 doc/ref/mh_installpom.txt  |  1 +
 src/main/bin/mh_installjar |  2 +-
 src/main/bin/mh_installpom | 41 ++++++++++++++++++++++++++++++++++++++++-
 5 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 4a82cdd..657d4f7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,6 @@
 maven-repo-helper (1.8.13) UNRELEASED; urgency=medium
 
+  * Added the --relocate option to mh_installpom
   * Reduced the size of the poms installed in /usr/share/maven-repo by removing
     the non-functional elements (licenses, scm, developers, contributors,
     issueManagement, mailingLists, inceptionYear, url, organization).
diff --git a/doc/ref/mh_installpom.rst b/doc/ref/mh_installpom.rst
index aab9b23..0557620 100644
--- a/doc/ref/mh_installpom.rst
+++ b/doc/ref/mh_installpom.rst
@@ -41,6 +41,7 @@ Options:
     -s --no-rules: don't apply any rules for converting versions, do not even convert versions to the default 'debian' version
     --no-publish-used-rule: don't publish the rule used to transform a POM's own attributes in debian.mavenRules
     --keep-elements=<elem1,elem2>: keep the elements listed here even if they are normally removed by the clean operation. Such elements are build,reports,reporting,prerequisites,profiles.
+    --relocate=<groupId>:<artifactId>:<version>: relocate the specified artifact toward the one being installed.
     -m<repo root>--maven-repo=<repo root>: location of the Maven repository, used to force the versions of the Maven plugins used in the current POM file with the versions found in the repository
     -v --verbose: show more information while running
     -n --no-act: don't actually do anything, just print the results
diff --git a/doc/ref/mh_installpom.txt b/doc/ref/mh_installpom.txt
index 7cb600b..4fc4f7c 100644
--- a/doc/ref/mh_installpom.txt
+++ b/doc/ref/mh_installpom.txt
@@ -34,6 +34,7 @@ Options:
     -s --no-rules: don't apply any rules for converting versions, do not even convert versions to the default 'debian' version
     --no-publish-used-rule: don't publish the rule used to transform a POM's own attributes in debian.mavenRules
     --keep-elements=<elem1,elem2>: keep the elements listed here even if they are normally removed by the clean operation. Such elements are build,reports,reporting,prerequisites,profiles.
+    --relocate=<groupId>:<artifactId>:<version>: relocate the specified artifact toward the one being installed.
     -m<repo root>--maven-repo=<repo root>: location of the Maven repository, used to force the versions of the Maven plugins used in the current POM file with the versions found in the repository
     -v --verbose: show more information while running
     -n --no-act: don't actually do anything, just print the results
diff --git a/src/main/bin/mh_installjar b/src/main/bin/mh_installjar
index 8393832..87a3267 100644
--- a/src/main/bin/mh_installjar
+++ b/src/main/bin/mh_installjar
@@ -80,7 +80,7 @@ syntax()
 }
 
 # The following elements are options which just need to be ignored: no-parent has-package-version keep-elements ignore-pom
-ARGS="p package e set-version r rules l java-lib n usj-name i j usj-version s no-usj-versionless d dest-jar c classifier v verbose n no-act skip-clean-pom no-parent has-package-version keep-elements ignore-pom" parseargs "$@"
+ARGS="p package e set-version r rules l java-lib n usj-name i j usj-version s no-usj-versionless d dest-jar c classifier v verbose n no-act skip-clean-pom no-parent has-package-version keep-elements ignore-pom relocate" parseargs "$@"
 
 if [ "$ARGC" -lt "2" ]; then
    syntax
diff --git a/src/main/bin/mh_installpom b/src/main/bin/mh_installpom
index 2e62c66..345a73d 100644
--- a/src/main/bin/mh_installpom
+++ b/src/main/bin/mh_installpom
@@ -73,6 +73,8 @@ syntax()
    echo -e "\t--keep-elements=<elem1,elem2>: keep the elements listed here"
    echo -e "\t  even if they are normally removed by the clean operation."
    echo -e "\t  Such elements are build,reports,reporting,prerequisites,profiles."
+   echo -e "\t--relocate=<groupId>:<artifactId>:<version>: relocate the specified"
+   echo -e "\t  artifact toward the one being installed."
    echo -e "\t-m<repo root>--maven-repo=<repo root>: location of the Maven repository,"
    echo -e "\t  used to force the versions of the Maven plugins used in the current"
    echo -e "\t  POM file with the versions found in the repository"
@@ -85,7 +87,7 @@ syntax()
 }
 
 # The following elements are options which just need to be ignored: artifact java-lib usj-name usj-version no-usj-versionless dest-jar classifier
-ARGS="p package o no-parent k keep-pom-version e set-version r rules u published-rules i ignore-rules c clean-ignore-rules s no-rules no-publish-used-rule v verbose n no-act m maven-repo h has-package-version keep-elements artifact java-lib usj-name usj-version no-usj-versionless dest-jar ignore-pom classifier" parseargs "$@"
+ARGS="p package o no-parent k keep-pom-version e set-version r rules u published-rules i ignore-rules c clean-ignore-rules s no-rules no-publish-used-rule v verbose n no-act m maven-repo h has-package-version keep-elements artifact java-lib usj-name usj-version no-usj-versionless dest-jar ignore-pom classifier relocate" parseargs "$@"
 
 if [ "$ARGC" -lt "1" ]; then
    syntax
@@ -109,6 +111,7 @@ POM="${ARGV[0]}"
 IGNORE_POM=$(getarg ignore-pom)
 HAS_PACKAGE_VERSION=$(getarg h has-package-version)
 KEEP_ELEMENTS=$(getarg keep-elements)
+RELOCATE=$(getarg relocate)
 
 if [ -z "$PUBLISHED_RULES" ]; then
     if [ -f debian/maven.publishedRules ]; then
@@ -170,3 +173,39 @@ if [[ "${version}" != "${debianVersion}" ]]; then
 
     install -m 644 -D debian/.mh/${artifactId}-${debianVersion}.pom debian/${PACKAGE}/usr/share/maven-repo/${groupPath}/${artifactId}/${debianVersion}/${artifactId}-${debianVersion}.pom
 fi
+
+if [[ ! -z "$RELOCATE" ]]; then
+    relocatedGAV=(${RELOCATE//:/ })
+
+    relocatedGroupId=${relocatedGAV[0]}
+    relocatedArtifactId=${relocatedGAV[1]}
+    relocatedVersion=${relocatedGAV[2]}
+    if [[ -z "${relocatedVersion}" ]]; then
+        relocatedVersion=debian
+    fi
+
+    relocatedGroupPath=$(echo $relocatedGroupId | tr . / )
+
+    relocatedPomPath=debian/${PACKAGE}/usr/share/maven-repo/${relocatedGroupPath}/${relocatedArtifactId}/${relocatedVersion}
+    relocatedPom=${relocatedPomPath}/${relocatedArtifactId}-${relocatedVersion}.pom
+
+    mkdir -p ${relocatedPomPath}
+
+    cat >> ${relocatedPom} << EOF
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>${relocatedGroupId}</groupId>
+  <artifactId>${relocatedArtifactId}</artifactId>
+  <version>${relocatedVersion}</version>
+  <distributionManagement>
+    <relocation>
+      <groupId>${groupId}</groupId>
+      <artifactId>${artifactId}</artifactId>
+      <version>${debianVersion}</version>
+    </relocation>
+  </distributionManagement>
+</project>
+EOF
+
+    chmod 644 ${relocatedPom}
+fi

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/maven-repo-helper.git



More information about the pkg-java-commits mailing list