Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to run mvn commands using ms bat file

 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic