Search code examples
javagitmavenprotocol-buffersmvn-repo

Is there a way to checkout git repository, to certain folder with maven?


I am attempting to automatize download of repository containing only protocol-buffers (with structure), to "resource" folder for later processing.

I need this kind of functionality, to keep my *.proto files separated from c++ and java code, as they are technically not connected with each other (java application is used for debugging).

My desired effect is to at least checkout repo into project — My dreamed effect is to get this repo updated every time I run maven.

BR


Solution

  • EDIT

    After working a lot with such a problem, I found personally that the git submodule might be a solution for you (if you are not using svn).


    Okay, so after googling, I have came across this: maven-scm-plugin, which even from description solves my request.

    To save time for most people I will paste example of usage, to make it work.

    You need to add this to your pom structure:

    <project>
        <scm>
            <connection>scm:git:[YOUR_PROJECT_URL]</connection>
        </scm>
        
        <--! second part -->
    
        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-scm-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.plexus</groupId>
                        <artifactId>plexus-utils</artifactId>
                        <version>2.1</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.maven.scm</groupId>
                        <artifactId>maven-scm-provider-gitexe</artifactId>
                        <version>1.2</version>
                    </dependency>
                </dependencies>
                <version>1.0</version>
                <configuration>
                    <connectionType>connection</connectionType>
                    <!-- YOUR PATH HERE -->
                    <checkoutDirectory>src/main/resources/meta</checkoutDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>tag</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>tag</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
    </project>