Opening a url in the default browser with Ant
posted by Chris
on Jan 04, 2012 at 18:15
I've Been playing with Ant, Jenkins and MXUnit recently and when I run the build in eclipse i thought it would be nice if it could open up the test results for me.
Here's an ant macro to open a url in your default browser, only works on Windows though, sorry.
<macrodef name="openInBrowser">
<attribute name="url"/>
<sequential>
<exec dir="${basedir}" executable="rundll32.exe">
<arg line="url.dll, FileProtocolHandler"/>
<arg line="@{url}"/>
</exec>
</sequential>
</macrodef>
Then in the target you can call it
<target name="openTestResults">
<echo message="Opening test results in default browser" />
<openInBrowser url="http://${test.host}/tests/output/html/index.html"/>
</target>
Categories:
Comments