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

时间:2011-08-04 08:13:20

标签: git maven git-submodules

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

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

感谢。

2 个答案:

答案 0 :(得分:21)

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

<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>

答案 1 :(得分: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>

我的update.sh包含:

#!/bin/bash
git submodule update --init
git submodule foreach git submodule update --init
相关问题