Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Maven release to clone git submodules?

I've got a Maven project with some git submodules linked. Everything works fine until I do a release:prepare or :perform, the clean checkout these targets perform does not contain the submodules (or in other words, git clone is not recursive). I could not find a proper way to configure Maven to call git clone with the --recursive option.

I was thinking of using the scm provider configuration (http://maven.apache.org/scm/git.html) or simply to configure the release plugin directly in the pom.xml, but couldn't get it to work.

Thanks.

like image 983
Mihi Avatar asked Aug 04 '11 08:08

Mihi


2 Answers

Here's the same solution but without a script:

<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>
like image 123
user3173994 Avatar answered Sep 28 '22 11:09

user3173994


I just added the following plugin:

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

And my update.sh contains:

#!/bin/bash
git submodule update --init
git submodule foreach git submodule update --init
like image 43
Jotschi Avatar answered Sep 28 '22 13:09

Jotschi