git - 使用 Maven SCM 检查 Git 存储库并切换到特定分支

标签 git maven version-control

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

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

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

有没有一种方法可以指定 Maven 将 check out 哪个分支?

最佳答案

您可以使用 <scmVersion><scmVersionType> maven scm plugin 的属性实现这一目标。

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

关于git - 使用 Maven SCM 检查 Git 存储库并切换到特定分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15127403/

相关文章:

git - 压缩包含 merge 提交的前几十个 git 提交

git - 管道和瓷器命令是什么?

git - SVN 到 GIT 迁移给出错误:No refs in common

svn - 比较 TortoiseSVN 中两个分支之间的文件

git - 有没有办法让 git-push 具有交互性?

eclipse - 如何比较 Eclipse 中 git 的两个修订版本?

testing - 如何在 Selenium ui 测试期间交换模拟服务?

java - 从 Windows 运行时出现 Phoenix CsvBulkLoadTool 错误

Maven 查找属性用法

svn - 我是否需要定期调用 svnadmin pack