How can I make git in Maven?

I am new to both maven and git and wanted to get some help in setting up the project.

Is there a way to define a target in pom to push / pull from git during maven phase binding? For example, can I extract from git during the maven installation phase?

If so, how can this be done? I would appreciate any code examples.

+7
source share
3 answers

Good idea or not, here is how you can do checkout ( pull clone from Github) using Maven. Your pom.xml looks 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, he pulled the code into the target/engesoft . There is probably a way to set it up to put it in another place. Check out the following pages:

+11
source

Instead, use a CI server such as Jenkins during Maven build. It will do a git pull before launching maven, so the build tool can focus on its main purpose: Creating the source code.

It also makes it easier for you, as gravity will only happen when you want it. If you pull all the time, another developer may change something, and you will get errors that you do not expect.

+2
source

scm: checkout goal Vitor refers to a clone, not to pull (a huge difference in Git).

I had to use the exec target to do what you are describing. I also did not want to do the whole clone every time there was an assembly. Instead, I use git reset --hard , and then pull -f origin Release: Release (via exec).

If I find a better way (and there will be one), I will post it here.

+2
source

All Articles