5

我想使用 Maven 来签出 Git 存储库。在我们的特定用例中,这是有道理的,因为这个 Git 存储库包含我们需要包含在构建过​​程中的文件。

由于项目的性质,Git 存储库可能具有不同的分支。这么简单:scm:git:git@github.example.com:myproject/project.git

将不起作用,因为这将结帐大师。我想例如分支“3.0V3”

有没有办法可以指定 Maven 将签出哪个分支?

4

1 回答 1

9

您可以使用maven scm 插件<scmVersion>的和<scmVersionType>属性来实现这一点。

 <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>
于 2013-02-28T06:45:19.677 回答