Maven – Start Jetty Server by Ant task using maven-antrun-plugin

I have the following shell script to start the Jetty Server in my portable web application in Windows.

start java -DSTOP.PORT=8080 -DSTOP.KEY=stop_jetty -jar start.jar


It will prompt a new cmd window for the Jetty console. So i want to run this shell script during the pre-integration-test life cycle of the Maven project such that a testable webapp instance is started up before the integration test begins. Therefore, i make use of the maven-antrun-plugin in the pom and run this shell script by the <exec> Ant task. Unfortunately, the Maven build console hangs after the jetty server is started as it tries to wait for the shell script to be completed.

Finally, the problem is solved after adding the spawn attributes in the <exec> task which makes the Ant task run in background. The following is a sample of the maven-antrun-plugin configuration.

					<!-- Start 8081 jetty -->
					<exec dir="<jetty_path>" executable="cmd.exe" spawn="true">
						<arg value="/c"/>
						<arg value="start_jetty.bat"/>


Done =)



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.