Maven SCM plugin and relative paths

2019-08-17 01:28发布

问题:

My directory structure looks somewhat like this:

  • .git
  • src
    • parent
      • pom.xml
    • submodule
      • pom.xml
      • addme.product

My pom looks like this:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">


    <scm>
    <developerConnection>scm:git:file://../../.git</developerConnection>
  </scm>


    <modelVersion>4.0.0</modelVersion>
    <groupId>grp</groupId>
    <artifactId>artif</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>


    <modules>
      <module>../submodule</module>     
    </modules>

    </properties>

    <build>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <localCheckout>true</localCheckout>
                    <preparationGoals>
                        org.eclipse.tycho:tycho-versions-plugin:${tycho-version}:update-eclipse-metadata 
                        org.apache.maven.plugins:maven-scm-plugin:1.9.5:add 
                        <!-- org.apache.maven.plugins:maven-scm-plugin:1.9.5:checkin -->
                    </preparationGoals>
                    <completionGoals>
                        org.eclipse.tycho:tycho-versions-plugin:${tycho-version}:update-eclipse-metadata 
                        org.apache.maven.plugins:maven-scm-plugin:1.9.5:add 
                        <!-- org.apache.maven.plugins:maven-scm-plugin:1.9.5:checkin -->
                    </completionGoals>
                </configuration>
           </plugin>
            <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-scm-plugin</artifactId>
               <version>1.9.5</version>
               <executions>
                 <execution>
                   <id>default-cli</id>
                   <goals>
                     <goal>add</goal>
                     <goal>checkin</goal>
                   </goals>
                   <configuration>
                     <includes>**/META-INF/MANIFEST.MF,**/feature.xml,**/*.product</includes>
                     <excludes>**/target/**</excludes>
                   <message>Changing the version to reflect the pom versions for the release</message>
                   <basedir>${project.basedir}/../..</basedir>
                   <workingDirectory>${project.basedir}/../..</workingDirectory>
                   </configuration>
                 </execution>
               </executions>
             </plugin>
        </plugins>

</project>

When I run mvn release:prepare, I get an error saying that

[ERROR] fatal: pathspec 'src\parent\src\submodule\addme.product' did not match any files

So, the plugin finds the files it should add, but when creating the command line doesn't respect the correct root directory. How do I fix this, without changing the location of the parent pom?

回答1:

I ran into a similar problem (my root POM had a parent configuration POM, which was located in a subfolder). I was only able to solve this by creating a "proper" POM and folder hierarchy, meaning:

  • Root POM should be located in the project root folder
  • Submodlues should be subfolders of the project root folder and the folder structure should be reflected in the of the POMs
  • Source folders should be individual subfolders of the modules