2

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>

2 Answers2

0

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

Dan Moldovan
  • 371
  • 3
  • 3
0

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?

Community
  • 1
  • 1
zlinks
  • 1,037
  • 2
  • 16
  • 26
  • Thanks it helped me. What I understood from the above is first I will run mvn scm:checkout and pull the repository and then run mvn tomcat7:deploy to build and deploy. Or is it enough if I just run mvn clean install. – user3072043 Mar 06 '14 at 16:00
  • Haven't tried with a server application so I can't be sure. – zlinks Mar 06 '14 at 23:12
  • I tried the mvn scm:checkout command but its throwing me the error fatal: read error: Invalid argument fatal: error in sideband demultiplexer. But i'm able to pull, fetch and checkout from my remote repository using tortoise Git. But through maven facing the above error. – user3072043 Mar 07 '14 at 06:49
  • Tried to do a little verification test but my git command line tools are corrupt. I am stuck at ''git' is not recognized as an internal or external...'. Also check here (it's for a release though): [maven-tips-and-tricks-using-github](http://blog.sonatype.com/2009/09/maven-tips-and-tricks-using-github/) – zlinks Mar 07 '14 at 09:57
  • This one might also be helpful [github-maven-example](https://github.com/kevinsawicki/github-maven-example) – zlinks Mar 07 '14 at 11:29