我如何在Maven中做一个git pull? [英] How can I do a git pull in Maven?
问题描述
我对maven和git都很陌生,希望在设置一个项目时得到一些帮助。
有没有一种方法可以在pom中定义一个目标在链接到maven阶段时从git推/拉?例如,我可以在maven安装阶段从git中取出吗?
如果是,那该如何实现?我很感激任何代码示例。
好主意或不好,这里是您如何做结帐( pull 从Github中克隆)使用Maven。你的pom.xml如下所示:
< project xmlns =http://maven.apache.org/POM /4.0.0xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation =http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">
< modelVersion> 4.0.0< / modelVersion>
< groupId> br.com.javamagazine< / groupId>
< artifactId> engesoft< / artifactId>
<包装>战争< / packaging>
< version> 0.0.1-SNAPSHOT< / version>
< name> engesoft Maven Webapp< / name>
< url> http://maven.apache.org< / url>
< scm>
< connection> scm:git:git://github.com/vitorsouza/EngeSoft.git< / connection>
< developerConnection> scm:git:https://vitorsouza@github.com/vitorsouza/EngeSoft.git< / developerConnection>
< url> https://github.com/vitorsouza/EngeSoft< / url>
< / scm>
< / project>
然后使用 mvn scm:checkout
。当我运行它时,它将代码拉到文件夹 target / engesoft
。可能有一种方法可以将其配置到其他位置。查看以下页面:
I'm new to both maven and git and wanted to get some help in setting a project.
Is there a way to define a goal in the pom to push/pull from git during linked to a maven phase? For example, can I pull from git during the maven install phase?
If yes, how can that be accomplished? I would appreciate any code examples.
Good idea or not, here's how you could do a checkout (pull clone from Github) using Maven. Have your pom.xml look like this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.javamagazine</groupId>
<artifactId>engesoft</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>engesoft Maven Webapp</name>
<url>http://maven.apache.org</url>
<scm>
<connection>scm:git:git://github.com/vitorsouza/EngeSoft.git</connection>
<developerConnection>scm:git:https://vitorsouza@github.com/vitorsouza/EngeSoft.git</developerConnection>
<url>https://github.com/vitorsouza/EngeSoft</url>
</scm>
</project>
Then use mvn scm:checkout
. When I ran this, it pulled the code to folder target/engesoft
. There's probably a way to configure it to place it somewhere else. Check out the following pages:
这篇关于我如何在Maven中做一个git pull?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!