Maven SCM (moved to ASF)
  1. Maven SCM (moved to ASF)
  2. SCM-695

Mvn release plugin problems with too many - in name

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Blocker Blocker
    • Resolution: Unresolved
    • Affects Version/s: 1.7
    • Fix Version/s: None
    • Component/s: maven-scm-provider-git
    • Labels:
      None
    • Environment:
    • Complexity:
      Intermediate
    • Number of attachments :
      1

      Description

      Have maven problems with modules containing too many "-"?
      I have projects that are named:

      globalpom-groovy/
      globalpom-groovy/globalpom-groovy/pom.xml < parent pom
      globalpom-groovy/globalpom-groovy-izpack/pom.xml
      globalpom-groovy/globalpom-groovy-izpack-snglejar/pom.xml
      globalpom-groovy/globalpom-groovy-testutils/pom.xml
      

      But if I do mvn release:prepare inside of globalpom-groovy/globalpom-groovy/, then I get the error:

      [INFO] Executing: /bin/sh -c cd 
      /mnt/read/projects/com.anrisoftware/globalpom/globalpom-groovy/globalpom-
      groovy && git add -- pom.xml -izpack/pom.xml -izpack-singlejar/pom.xml -
      testutils/pom.xml
      [INFO] Working directory: 
      /mnt/read/projects/com.anrisoftware/globalpom/globalpom-groovy/globalpom-
      groovy
      [INFO] 
      ------------------------------------------------------------------------
      [INFO] Reactor Summary:
      [INFO] 
      [INFO] Global POM Groovy ................................. FAILURE [12.365s]
      [INFO] Global POM Groovy IzPack .......................... SKIPPED
      [INFO] Global POM Groovy IzPack Single Jar ............... SKIPPED
      [INFO] Global POM Groovy Test Utilities .................. SKIPPED
      [INFO] 
      ------------------------------------------------------------------------
      [INFO] BUILD FAILURE
      [INFO] 
      ------------------------------------------------------------------------
      [INFO] Total time: 13.066s
      [INFO] Finished at: Sat Jan 21 15:45:50 CET 2012
      [INFO] Final Memory: 12M/152M
      [INFO] 
      ------------------------------------------------------------------------
      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-
      plugin:2.0:prepare (default-cli) on project globalpom-groovy: Unable to commit 
      files
      [ERROR] Provider message:
      [ERROR] The git-add command failed.
      [ERROR] Command output:
      [ERROR] fatal: pathspec 'globalpom-groovy/-izpack/pom.xml' did not match any 
      files
      

      Of course that's wrong 'globalpom-groovy/-izpack/pom.xml' should be
      '../globalpom-groovy-izpack/pom.xml', or something like that.

        Issue Links

          Activity

          Hide
          Kristian Rosenvold added a comment -

          A little testing seems to indicate this is probably within the release plugin

          Show
          Kristian Rosenvold added a comment - A little testing seems to indicate this is probably within the release plugin
          Hide
          Kristian Rosenvold added a comment -

          I created a small sample project at https://github.com/krosenvold/multimodule-test.git where I try to reconstruct this issue, but I am unable to reproduce it. Please fork the repo on github (and adjust the scm url) and try to reproduce your problem on this controlled sample

          Show
          Kristian Rosenvold added a comment - I created a small sample project at https://github.com/krosenvold/multimodule-test.git where I try to reconstruct this issue, but I am unable to reproduce it. Please fork the repo on github (and adjust the scm url) and try to reproduce your problem on this controlled sample
          Hide
          Robert Scholte added a comment -

          [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:prepare (default-cli) on project globalpom-groovy: Unable to commit files

          First try to lock the version of the maven-release-plugin to a more recent (or latest) version, for instance 2.3.2, which will pick up scm-1.7.
          This would also explain why Kristian is not able to reproduce this.

          Show
          Robert Scholte added a comment - [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:prepare (default-cli) on project globalpom-groovy: Unable to commit files First try to lock the version of the maven-release-plugin to a more recent (or latest) version, for instance 2.3.2, which will pick up scm-1.7. This would also explain why Kristian is not able to reproduce this.
          Hide
          Sven Kubiak added a comment -

          As we had the exact same issue, I think the problem is not the plugin, rather the project structure.

          Not Working:
          /project/parent/pom.xml
          /project/submodule-1/pom.xml
          /project/submodule-2/pom.xml

          We have changed to the following project structure and no everything is working fine.

          /project/pom.xml
          /project/submodule-1/pom.xml
          /project/submodule-2/pom.xml

          As shown in the example from Kristian.

          Show
          Sven Kubiak added a comment - As we had the exact same issue, I think the problem is not the plugin, rather the project structure. Not Working: /project/parent/pom.xml /project/submodule-1/pom.xml /project/submodule-2/pom.xml We have changed to the following project structure and no everything is working fine. /project/pom.xml /project/submodule-1/pom.xml /project/submodule-2/pom.xml As shown in the example from Kristian.
          Hide
          Matthieu Lecoutre added a comment - - edited

          Reproduced with latest version of the release plugin at this time

          • maven-release-plugin:2.4.1
          • maven-scm-plugin:1.8.1
          • git version 1.8.3.msysgit.0
          • Maven 3.0.4 (not the last one, but will not change anything i assumed)
          • windows environment

          L:\data\gitrepo\mqbuffer\

          my modules names:
          [INFO] mqbuffer
          [INFO] mqbuffer-properties
          [INFO] mqbuffer-coordination
          [INFO] mqbuffer-business
          [INFO] mqbuffer-web
          [INFO] mqbuffer-ear
          [INFO] mqbuffer-api
          [INFO] mqbuffer-cleaner

          UPDATE of my first remark
          I've done some additional tests.

          and i've changed folder's names of my modules (keeping the same artifactId, only change the folder)

          mqbuffer-properties becoming mqbufferProperties and other modules on the same model

          the behaviour the the "git add cmd" is similar and just keep the second word EVEN if i don't use - the name
          [INFO] [INFO]
          [INFO] [INFO] mqbuffer .......................................... SUCCESS [0.422s]
          [INFO] [INFO] mqbuffer-properties ............................... SUCCESS [1.594s]
          [INFO] [INFO] mqbuffer-coordination ............................. SUCCESS [4.643s]
          [INFO] [INFO] mqbuffer-business ................................. SUCCESS [8.691s]
          [INFO] [INFO] mqbuffer-web ...................................... SUCCESS [17.804s]
          [INFO] [INFO] mqbuffer-ear ...................................... SUCCESS [1.985s]
          [INFO] [INFO] mqbuffer-api ...................................... SUCCESS [2.563s]
          [INFO] [INFO] mqbuffer-cleaner .................................. SUCCESS [1.829s]
          [INFO] [INFO] ------------------------------------------------------------------------
          [INFO] [INFO] BUILD SUCCESS
          [INFO] [INFO] ------------------------------------------------------------------------
          [INFO] [INFO] Total time: 39.922s
          [INFO] [INFO] Finished at: Tue Jul 30 14:18:18 CEST 2013
          [INFO] [INFO] Final Memory: 9M/23M
          [INFO] [INFO] ------------------------------------------------------------------------
          [INFO] Checking in modified POMs...
          [INFO] Executing: cmd.exe /X /C "git add – pom.xml Properties\pom.xml Coordination\pom.xml Business\pom.xml Web\pom.xml Ear\pom.xml Api\pom.xml Cleaner\pom.xml"
          [INFO] Working directory: L:\data\gitrepo\mqbuffer\mqbuffer
          [INFO] ------------------------------------------------------------------------

          i've forked the https://github.com/olamy/maven-scm projet in order to create a test to reproduce the error, but i'm not sure this a clear mirror of the apache version.
          if i don't make any mistake, we should have a loop per file to add in the git repository on windows environment already in the 1.8 version

          org.apache.maven.scm.provider.git.gitexe.command.add.GitAddCommand.java
             private AddScmResult executeAddFileSet( ScmFileSet fileSet )
                  throws ScmException
              {
                  File workingDirectory = fileSet.getBasedir();
                  List<File> files = fileSet.getFileList();
          
                  // command line can be too long for windows so add files individually (see SCM-697)
                  if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
                  {
                      for ( File file : files )
                      {
                          AddScmResult result = executeAddFiles( workingDirectory, Collections.singletonList( file ) );
          
                          if ( result != null )
                          {
                              return result;
                          }
                      }
                  }
          // ...
          

          if i use now a no flat structure as the previous comment says, everything works fine.

          Executing: cmd.exe /X /C "git add – pom.xml mqbuffer-properties\pom.xml mqbuffer-coordination\pom.xml mqbuffer-business\pom.xml mqbuffer-web\pom.xml mqbuffer-ear\pom.xml mqbuffer-api\pom.xml mqbuffer-cleaner\pom.xml"

          Show
          Matthieu Lecoutre added a comment - - edited Reproduced with latest version of the release plugin at this time maven-release-plugin:2.4.1 maven-scm-plugin:1.8.1 git version 1.8.3.msysgit.0 Maven 3.0.4 (not the last one, but will not change anything i assumed) windows environment L:\data\gitrepo\mqbuffer\ my modules names: [INFO] mqbuffer [INFO] mqbuffer-properties [INFO] mqbuffer-coordination [INFO] mqbuffer-business [INFO] mqbuffer-web [INFO] mqbuffer-ear [INFO] mqbuffer-api [INFO] mqbuffer-cleaner UPDATE of my first remark I've done some additional tests. and i've changed folder's names of my modules (keeping the same artifactId, only change the folder) mqbuffer-properties becoming mqbufferProperties and other modules on the same model the behaviour the the "git add cmd" is similar and just keep the second word EVEN if i don't use - the name [INFO] [INFO] [INFO] [INFO] mqbuffer .......................................... SUCCESS [0.422s] [INFO] [INFO] mqbuffer-properties ............................... SUCCESS [1.594s] [INFO] [INFO] mqbuffer-coordination ............................. SUCCESS [4.643s] [INFO] [INFO] mqbuffer-business ................................. SUCCESS [8.691s] [INFO] [INFO] mqbuffer-web ...................................... SUCCESS [17.804s] [INFO] [INFO] mqbuffer-ear ...................................... SUCCESS [1.985s] [INFO] [INFO] mqbuffer-api ...................................... SUCCESS [2.563s] [INFO] [INFO] mqbuffer-cleaner .................................. SUCCESS [1.829s] [INFO] [INFO] ------------------------------------------------------------------------ [INFO] [INFO] BUILD SUCCESS [INFO] [INFO] ------------------------------------------------------------------------ [INFO] [INFO] Total time: 39.922s [INFO] [INFO] Finished at: Tue Jul 30 14:18:18 CEST 2013 [INFO] [INFO] Final Memory: 9M/23M [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Checking in modified POMs... [INFO] Executing: cmd.exe /X /C "git add – pom.xml Properties \pom.xml Coordination \pom.xml Business \pom.xml Web \pom.xml Ear \pom.xml Api \pom.xml Cleaner \pom.xml" [INFO] Working directory: L:\data\gitrepo\mqbuffer\mqbuffer [INFO] ------------------------------------------------------------------------ i've forked the https://github.com/olamy/maven-scm projet in order to create a test to reproduce the error, but i'm not sure this a clear mirror of the apache version. if i don't make any mistake, we should have a loop per file to add in the git repository on windows environment already in the 1.8 version org.apache.maven.scm.provider.git.gitexe.command.add.GitAddCommand.java private AddScmResult executeAddFileSet( ScmFileSet fileSet ) throws ScmException { File workingDirectory = fileSet.getBasedir(); List<File> files = fileSet.getFileList(); // command line can be too long for windows so add files individually (see SCM-697) if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { for ( File file : files ) { AddScmResult result = executeAddFiles( workingDirectory, Collections.singletonList( file ) ); if ( result != null ) { return result; } } } // ... if i use now a no flat structure as the previous comment says, everything works fine. Executing: cmd.exe /X /C "git add – pom.xml mqbuffer-properties\pom.xml mqbuffer-coordination\pom.xml mqbuffer-business\pom.xml mqbuffer-web\pom.xml mqbuffer-ear\pom.xml mqbuffer-api\pom.xml mqbuffer-cleaner\pom.xml"
          Hide
          David SPORN added a comment -

          _This is a copy of my comment on the issue MRELEASE-701 _

          Found the root cause :

          • module : 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 :

          GitCommandLineUtils#addTarget( Commandline cl, List<File> files )
              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 );
                  }
              }
          

          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.

          Show
          David SPORN added a comment - _This is a copy of my comment on the issue MRELEASE-701 _ Found the root cause : module : 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 : GitCommandLineUtils#addTarget( Commandline cl, List<File> files ) 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 ); } } 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.
          Hide
          David SPORN added a comment -

          Sent a pull request to fix

          Show
          David SPORN added a comment - Sent a pull request to fix
          Hide
          David SPORN added a comment -

          Rebased my pull request

          Show
          David SPORN added a comment - Rebased my pull request

            People

            • Assignee:
              Unassigned
              Reporter:
              Erwin Mueller
            • Votes:
              3 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated: