You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Robert Patrick (JIRA)" <ji...@apache.org> on 2016/09/06 03:11:20 UTC

[jira] [Commented] (MNG-5889) .mvn directory should be picked when using --file

    [ https://issues.apache.org/jira/browse/MNG-5889?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15466256#comment-15466256 ] 

Robert Patrick commented on MNG-5889:
-------------------------------------

Pretty simple to fix the shell script to find the --file argument, if present, and set the MAVEN_PROJECTBASEDIR accordingly:

(quote)
--- a/apache-maven/src/bin/mvn
+++ b/apache-maven/src/bin/mvn
@@ -121,7 +121,7 @@ fi
 # first directory with .mvn subdirectory is considered project base directory
 find_maven_basedir() {
 (
-  basedir="`pwd`"
+  basedir=`find_file_argument_basedir "$@"`
   wdir="`pwd`"
   while [ "$wdir" != '/' ] ; do
     if [ -d "$wdir"/.mvn ] ; then
@@ -134,6 +134,26 @@ find_maven_basedir() {
 )
 }

+find_file_argument_basedir() {
+(
+  basedir="`pwd`"
+
+  found_file_switch=0
+  for arg in "$@"; do
+    if [ ${found_file_switch} -eq 1 ]; then
+      if [ -f ${arg} ]; then
:+        basedir=$(dirname $(readlink -f "${arg}"))
+      fi
+      break
+    fi
+    if [ "$arg" == "-f" -o "$arg" == "--file" ]; then
+      found_file_switch=1
+    fi
+  done
+  echo "${basedir}"
+)
+}
+
 # concatenates all lines of a file
 concat_lines() {
   if [ -f "$1" ]; then
@@ -141,7 +161,7 @@ concat_lines() {
   fi
 }

-MAVEN_PROJECTBASEDIR="${MAVEN_BASEDIR:-`find_maven_basedir`}"
+MAVEN_PROJECTBASEDIR="${MAVEN_BASEDIR:-`find_maven_basedir "$@"`}"
 MAVEN_OPTS="`concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config"` $MAVEN_OPTS"


 # For Cygwin, switch project base directory path to Windows format before
(quote) 

> .mvn directory should be picked when using --file
> -------------------------------------------------
>
>                 Key: MNG-5889
>                 URL: https://issues.apache.org/jira/browse/MNG-5889
>             Project: Maven
>          Issue Type: Improvement
>          Components: Bootstrap & Build
>    Affects Versions: 3.3.3
>            Reporter: Daniel Spilker
>
> The {{.mvn}} directory is not picked up when using the {{--file}} switch to build a project from outside of the multi-module root.
> Example:
> * the module root is {{/foo/bar}}
> * {{.mvn}} is located at {{/foo/bar/.mvn}}
> * current directory is {{/foo}}
> * Maven is invoked with {{mvn --file bar/module/pom.xml}}
> I would expect the {{.mvn}} directory detection to start at the directory of the POM selected by {{--file}} and then go through the parent directories.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)