Question

I'm a newbie to both Git and Maven.

I need help in building a war file through maven buy getting the maven project in git repository.

Currently i have the maven project in the local git repository and i'm running the mvn tomcat7:deploy command on the project root directory to bulid and deploy it on the tomcat server and i succeded in that.

But i wanted to know how to get the maven project from remote git repository and update the local git repository and build the war file.

My current POM.xml is like this

 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.4</version>
    <configuration>
      <source>1.6</source>
      <target>1.6</target>
    </configuration>
  </plugin>
    <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.0</version>
    <configuration>
      <url>http://localhost:8080/manager/text</url>
      <server>TomcatServer</server>   
      <path>/Test</path>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.4</version>
    <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
 </plugin>
   <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
         <version>1.2</version>
        <executions>
         <execution>
            <phase>validate</phase>
            <goals>
                <goal>create</goal>
            </goals>
         </execution>
        </executions>
        <configuration>
            <docheck>true</docheck>
            <doupdate>true</doupdate>
            <shortrevisionlength>5</shortrevisionlength>
         </configuration>
     </plugin>
  <dependencies>  
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>

   <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.9</version>
    </dependency>
   </dependencies>
   <scm>
        <connection>scm:git:git://ServerIP/Repository</connection>
        <developerConnection>scm:git:git://ServerIP/Repository</developerConnection>
        <url>scm:git:git://ServerIP/Repository</url>
   </scm>
Was it helpful?

Solution

You mean that when for example you do a mvn clean install you want everything to be done by maven in one step. That is, not only have maven to build and deploy your code, but also have it pull the latest version of your code from git and then build, deploy.

If that is the case then have a look here: How can I do a git pull in Maven?

OTHER TIPS

If you run mvn clean install you should find the .war in the 'target' folder

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top