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

seb*_*ner 5 git version-control maven

我想使用Maven来检查Git存储库.在我们的特定用例中,这有意义,因为这个Git存储库包含我们需要包含在构建过​​程中的文件.

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

不会工作,因为这将结帐主人.我想例如分支"3.0V3"

有没有办法可以指定哪个分支Maven会结账?

Rag*_*ram 9

您可以使用<scmVersion><scmVersionType>性能的Maven插件单片机来实现这一目标.

 <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>
Run Code Online (Sandbox Code Playgroud)

  • @SteveCohen.如果你不想改变`pom.xml`,可以将`-DscmVersionType`和`-DscmVersion`作为命令行参数传递给你的`mvn scm:update`或类似的任务. (3认同)