This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes how to run mvn commands using ms bat file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "how to run mvn commands using ms bat file" Watch "how to run mvn commands using ms bat file" New topic
Author

how to run mvn commands using ms bat file

Reshma Reddy
Ranch Hand

Joined: Dec 21, 2006
Posts: 197
Hi All,

I am trying to run 2 mvn commands using ms bat file, but getting error.
I have create bat file in below mvn location

C:\apps\apache-maven-2.2.0\bin

this file contains:

call mvn clean
echo Exit Code = %ERRORLEVEL%
if not "%ERRORLEVEL%" == "0" exit /b

call mvn package
echo Exit Code = %ERRORLEVEL%
if not "%ERRORLEVEL%" == "0" exit /b

I am trying to run my bat file but getting error.



Can any one tell what is the wrong
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10240
    
168

As the message says, when you run the mvn command (from within the .bat file) you should be in a folder which corresponds to a Maven project (i.e. there should be a pom.xml in that folder).

[My Blog] [JavaRanch Journal]
Reshma Reddy
Ranch Hand

Joined: Dec 21, 2006
Posts: 197
Jai,

I have moved my bat file to project location now it is working.
is it possible to run tomcat server after finishing mvn commands?

Thanks
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5838
    
    7

Rather than moving the BAT file, you could have added the -f option to the mvn command and specified the location of the pom.xml file.

And yes, you can run Tomcat after running mvn, just add it to the bat file. (But that answer is much to simplistic, did you mean something else?)


JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to run mvn commands using ms bat file