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

David SPORN commented on MRELEASE-701:
--------------------------------------

Found the root cause :

* *dependency :* maven-scm-provider-gitexe-1.9.2.jar
* *package :* org.apache.maven.scm.provider.git.gitexe.command
* *Class#function :* GitCommandLineUtils#addTarget( Commandline cl, List<File> 
files ), around line 57

In this function, file names are processed to remove a common prefix, that is 
the path of the working directory :
{code:title=GitCommandLineUtils#addTarget( Commandline cl, List<File> files 
)|borderStyle=solid}
    public static void addTarget( Commandline cl, List<File> files )
    {
        if ( files == null || files.isEmpty() )
        {
            return;
        }
        final File workingDirectory = cl.getWorkingDirectory();
        try
        {
            final String canonicalWorkingDirectory = 
workingDirectory.getCanonicalPath();
            for ( File file : files )
            {
                String relativeFile = file.getPath();
                
                final String canonicalFile = file.getCanonicalPath();
                if ( canonicalFile.startsWith( canonicalWorkingDirectory ) )
                {
                    // so we can omit the starting characters
                    relativeFile = canonicalFile.substring( 
canonicalWorkingDirectory.length() );

                    if ( relativeFile.startsWith( File.separator ) )
                    {
                        relativeFile = relativeFile.substring( 
File.separator.length() );
                    }
                }

                // no setFile() since this screws up the working directory!
                cl.createArg().setValue( relativeFile );
            }
        }
        catch ( IOException ex )
        {
            throw new IllegalArgumentException( "Could not get canonical paths 
for workingDirectory = "
                + workingDirectory + " or files=" + files, ex );
        }
    }
{code}

This behaviour works well with a project organisation that follows maven 
convention, but in the case of a flat organisation and projects folder names 
being the name of the parent project + prefix, we get the observed result.

> maven:prepare failed with GIT SCM in multimodule project with quite same name
> -----------------------------------------------------------------------------
>
>                 Key: MRELEASE-701
>                 URL: https://jira.codehaus.org/browse/MRELEASE-701
>             Project: Maven Release Plugin
>          Issue Type: Bug
>          Components: Git, prepare
>    Affects Versions: 2.2.1
>         Environment: Windows, Maven 3, GIT
>            Reporter: jurevert
>            Priority: Minor
>
> In multimodule projects have directory tree like :
> {code}
> SampleProject
> |-- pom.xml (Modules : SampleProjectEAR,SampleProjectWeb,SampleProjectCommons)
> SampleProjectEAR
> |-- pom.xml (Parent : SampleProject pom.xml)
> SampleProjectWeb
> |-- pom.xml (Parent : SampleProject pom.xml)
> SampleProjectCommons
> |-- pom.xml (Parent : SampleProject pom.xml)
> {code}
> While running :
> {code}
> mvn release:prepare
> {code}
> GIT will try to commit files under but the erroe bellow appear :
> {code}
> build 11-Aug-2011 11:04:42    [INFO] --- maven-release-plugin:2.2.1:prepare 
> (default-cli) @ WelcomTutorial ---
> build 11-Aug-2011 11:04:44    [INFO] Resuming release from phase 
> 'scm-commit-release'
> build 11-Aug-2011 11:04:44    [INFO] Checking in modified POMs...
> build 11-Aug-2011 11:04:44    [INFO] Executing: /bin/sh -c cd 
> /app/DINB/bamboo-agent-home/xml-data/build-dir/WTUT-RELEASE-JOB1/SampleProject
>  && git add -- pom.xml Commons/pom.xml Web/pom.xml EAR/pom.xml
> [...]
> build 11-Aug-2011 11:04:44    [INFO] SampleProject 
> .................................... FAILURE [1.734s]
> [...]
> build 11-Aug-2011 11:04:44    [INFO] BUILD FAILURE
> [...]
> build 11-Aug-2011 11:04:44    [ERROR] Failed to execute goal 
> org.apache.maven.plugins:maven-release-plugin:2.2.1:prepare (default-cli) on 
> project SampleProject: Unable to commit files
> {code}
> The problem is that GIT is trying to add files :
> *Commons/pom.xml Web/pom.xml EAR/pom.xml*
> instead of
> [Path]/SampleProjectCommons/pom.xml [Path]/SampleProjectCommonsWeb/pom.xml 
> [Path]/SampleProjectCommonsEAR/pom.xml
> If you rename the project *SampleProject*, the BUILD is succeed.
> Julien



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

Reply via email to