Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

checking out a Git repository and switch to a specific branch using Maven SCM

I would like to use Maven to checkout a Git repository. In our specific use-case this makes sense as this Git Repository contain files that we need to include in out build process.

Due to the nature of projects it is likely that the Git repository has different branches. So a simple: scm:git:[email protected]:myproject/project.git

Will not work as this will checkout master. I would like for example branch "3.0V3"

Is there a way I can specify which branch Maven will checkout?

like image 309
seba.wagner Avatar asked Feb 28 '13 04:02

seba.wagner


1 Answers

You can use <scmVersion> and <scmVersionType> properties of maven scm plugin to achieve this.

 <scm>
    <developerConnection>scm:git:url</developerConnection>
  </scm>
 ...

 <build>
    <plugins>
        ...
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-scm-plugin</artifactId>
          <version>1.8.1</version>
          <configuration>
              <connectionType>developerConnection</connectionType>
              <scmVersion>branch-name</scmVersion>
              <scmVersionType>branch</scmVersionType>
          </configuration>
        </plugin>
    </plugins>
    ...
  </build>
  ...
</project>
like image 101
Raghuram Avatar answered Nov 16 '22 07:11

Raghuram