Reputation: 455
I have been using maven projects in hudson quite successfully for some time. However this time I need to build an eclipse dynamic web project that is usually built within eclipse and then the war is exported to production. How can I build this project in hudson.
Thanks in advance!
Upvotes: 2
Views: 1760
Reputation: 20961
If you're familiar with Maven, I suggest you use the m2e-wtp
plugin -- that way you can use both Maven and WTP for your web app. It should be somehwhere in the m2e catalogue (Window > Preferences > Maven) now that m2e moved to the Eclipse Foundation, check Maven/Tomcat Projects In Eclipse Indigo/3.7 for more.
If you already have a Dynamic Web Project in Eclipse, you'll probably have to move around a bunch of folders to arrange them in the structure Maven expects:
src/
main/
java/ -- your Java source files (servlets, actions, ...)
resources/ -- your resource files (struts.xml, log4j.xml, NOT web.xml)
webapp/ -- your web root (previously WTP's WebContent/)
WEB-INF/ -- your WEB-INFt (web.xml)
test/
java/ -- your Java test cases
resources/ -- your test resource files
pom.xml
Set the <packaging>
to war
so Maven knows that it should put your dependencies into WEB-INF/lib/
and build a WAR.
As for dependenices, you'll probably need the Servlet API:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version><!-- change version as needed -->
<scope>provided</scope><!-- Mind the scope!-->
</dependency>
Pay attentation to the provided
scope: The Servlet spec prohibits web apps to bring their own Servlet API JAR along in WEB-INF/lib
and conforming web containers will refuse to load your web app in that case (they will provide the JAR themselves in the version they support).
It's probably best to start by right-clicking on the Dynamic Web Project and go Maven > Convert to Maven project, then move the folders as shown above and then go through all the warnings the m2e and m2e-wtp plugins throw at you (most offer a quickfix).
Upvotes: 4