如何让Maven发布克隆git子模块?

Mih*_*ihi 13 git maven git-submodules

我有一个链接了一些git子模块的Maven项目.一切正常,直到我发布:准备或:执行,这些目标执行的干净检查不包含子模块(换句话说,git clone不是递归的).我找不到一个正确的方法来配置Maven使用--recursive选项调用git clone.

我正在考虑使用scm提供程序配置(http://maven.apache.org/scm/git.html)或只是直接在pom.xml中配置发布插件,但无法使其工作.

谢谢.

小智 22

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

<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>
Run Code Online (Sandbox Code Playgroud)


Jot*_*chi 13

我刚刚添加了以下插件:

<!-- 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>build/bin/update.sh</executable>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

我的update.sh包含:

#!/bin/bash
git submodule update --init
git submodule foreach git submodule update --init
Run Code Online (Sandbox Code Playgroud)

  • 而不是update.sh你可以使用"git submodule update --init --recursive" (11认同)