maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephan Schroevers (JIRA)" <j...@codehaus.org>
Subject [jira] (MNG-5786) Variable maven.multiModuleProjectDirectory may be set incorrectly
Date Wed, 18 Mar 2015 13:28:18 GMT

    [ https://jira.codehaus.org/browse/MNG-5786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=365350#comment-365350
] 

Stephan Schroevers commented on MNG-5786:
-----------------------------------------

Cool. I opened [PR #40|https://github.com/apache/maven/pull/40].

> Variable maven.multiModuleProjectDirectory may be set incorrectly
> -----------------------------------------------------------------
>
>                 Key: MNG-5786
>                 URL: https://jira.codehaus.org/browse/MNG-5786
>             Project: Maven
>          Issue Type: Bug
>          Components: Bootstrap & Build
>    Affects Versions: 3.3.1
>         Environment: Linux
>            Reporter: Stephan Schroevers
>         Attachments: dummy-project.zip
>
>
> Consider the following sequence of commands, executed using the attached [^dummy-project.zip]:
> {noformat}
> $ cd /tmp/
> $ unzip dummy-project.zip
> Archive:  dummy-project.zip
>    creating: dummy/
>    creating: dummy/.mvn/
>    creating: dummy/project/
>    creating: dummy/project/.mvn/
>   inflating: dummy/project/pom.xml   
> $ cd dummy/project/
> $ mvn help:effective-pom | grep effectiveMultiModuleProjectDirectory
>     <effectiveMultiModuleProjectDirectory>/tmp/dummy</effectiveMultiModuleProjectDirectory>
> {noformat}
> As you can see, the {{maven.multiModuleProjectDirectory}} variable is set to {{/tmp/dummy}},
even though the project is executed from within {{/tmp/dummy/project}}, which itself also
contains a {{.mvn}} directory.
> Based on MNG-5767 and the comments in the [relevant change|https://git-wip-us.apache.org/repos/asf?p=maven.git;a=blobdiff;f=apache-maven/src/bin/mvn;h=26feda4218197811e95390b746e2e002b585dd3b;hp=1ed3024b3fe442dc1e95fef193661abcde298a19;hb=8ed9a1caa8890773b45c6c408a4e40acf4f4b0fd;hpb=ee7dbab69dd87d219031b0715105527cdbf12639],
I suspect this is a bug. The {{find_maven_basedir}} function should test for the presence
of {{.mvn}} before traversing to the current working directory's parent directory.
> Suggested fix:
> {noformat}
> diff --git a/apache-maven/src/bin/mvn b/apache-maven/src/bin/mvn
> index 902de4a..5b6fed4 100755
> --- a/apache-maven/src/bin/mvn
> +++ b/apache-maven/src/bin/mvn
> @@ -199,12 +199,14 @@ fi
>  find_maven_basedir() {
>    local basedir=$(pwd)
>    local wdir=$(pwd)
> -  while [ "$wdir" != '/' ] ; do
> -    wdir=$(cd "$wdir/.."; pwd)
> +  while true ; do
>      if [ -d "$wdir"/.mvn ] ; then
>        basedir=$wdir
>        break
> +    elif [ "$wdir" = '/' ] ; then
> +      break;
>      fi
> +    wdir=$(cd "$wdir/.."; pwd)
>    done
>    echo "${basedir}"
>  }
> {noformat}
> Two notes:
> * I didn't check whether this issue affects {{mvn.cmd}}, as I'm not familiar with Windows
shell scripts and do not have a Windows machine at my disposal.
> * The patch does not simply move the {{wdir}} assignment below the {{if}}-statement,
because that would break the case in which there is a sole {{.mvn}} in the file system root.
(That'd be weird, yes, but allowed.)



--
This message was sent by Atlassian JIRA
(v6.1.6#6162)

Mime
View raw message