如何获取Maven版本来克隆git子模块?

pxyaymoc  于 2023-05-05  发布在  Git
关注(0)|答案(2)|浏览(87)

我有一个Maven项目,其中链接了一些git子模块。在我执行release:prepare或:perform之前,一切都很正常,这些目标执行的clean checkout不包含子模块(换句话说,git clone不是递归的)。我找不到一个合适的方法来配置Maven,让它使用--recursive选项调用git clone。
我想使用scm提供者配置(http://maven.apache.org/scm/git.html)或者直接在pom.xml中配置发布插件,但无法使其工作。
谢谢

4nkexdtk

4nkexdtk1#

下面是相同的解决方案,但没有脚本:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <inherited>false</inherited> <!-- only execute these in the parent -->
    <executions>
        <execution>
            <id>git submodule update</id>
            <phase>initialize</phase>
            <configuration>
                <executable>git</executable>
                <arguments>
                    <argument>submodule</argument>
                    <argument>update</argument>
                    <argument>--init</argument>
                    <argument>--recursive</argument>
                </arguments>
            </configuration>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
</plugin>
68bkxrlz

68bkxrlz2#

我添加了以下插件:

<!-- This is a workaround to get submodules working with the maven release plugin -->
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.1</version>
    <executions>
        <execution>
            <phase>initialize</phase>
            <id>invoke build</id>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <executable>git</executable>
        <arguments>
           <argument>submodule</argument>
           <argument>update</argument>
           <argument>--init</argument>
           <argument>--recursive</argument>
        </arguments>
    </configuration>
</plugin>

相关问题