The other day, I installed Maven on my OSX machine (previous entry) and I started using it in my Eclipse projects (mostly Dynamic Web Projects). Maven really helped me clean up my Jar file conflicts. Now that I have my jar files all cleaned up, I want to export them into a WAR file. So, how do you generate a WAR file from Eclipse that is based upon your definitions in pom.xml?
Well you can right-click on your project and go Run As --> Maven Build...
In the next window, you'll see a box labelled "Goals:". There are keywords you can type in here. If you type "package", it will look in your pom.xml for any directions you've typed for creating JAR or WAR files. Here is a StackOverflow thread where one of the replies shows how to pull in the Maven WAR plugin.
So, edit your pom.xml to include the Maven War Plugin stuff (which gives teh path to web.xml). Then, Run As --> Maven Build, and type "package" into the Goals: box. Then you'll see some Build information in your console, and, hopefully, you can look inside your "target" folder in your project (remember to hit Refresh in Eclipse!) and you should see the war file that has been assembled for you.
This link at Aykut Akın's Blog shows some screenshots to give a broad overview of how I did it.
I am accustomed to doing this with ANT, so I have a few kinks to work out to make sure the .class files and .jsp files and so on all end up in the correct place!
No comments:
Post a Comment