I have an Ant task that creates an HTML report. Is it possible to load that report automatically in a browser from the Ant task? If so, is it possible to do so in a user-independent way or would it require the use of custom user properties?
Thanks,
Paul
I used <script>
with javascript:
<property name="mydirectory" location="target/report"/>
<script language="javascript"><![CDATA[
location = "file:///"+project.getProperty("mydirectory").toString().replaceAll("\\\\","/")+"/index.html";
java.awt.Desktop.getDesktop().browse(java.net.URI.create(location));
]]></script>
There is an independent way, like we do in java:
Desktop.getDesktop.open(new File("file.html")) ?
I see no exit without ant optional tasks. From all the scripts beanshell looks most lightweight and does not require any new knowledge. So I did it this way:
<property name="bshJar" value="
C:\lang\java\bsh-1.3.0.jar:
C:\lang\java\bsf.jar:
C:\lang\java\commons-logging-1.1.1.jar" />
<script manager="bsf" language="beanshell" classpath="${bshJar}">
java.awt.Desktop.getDesktop().open(
new java.io.File("c:\\temp\\1\\stackoverflow\\DVD FAQ.htm"));
</script>
And this is an answer about getting script
task running. However javascript
language is indeed a better option, as it needs no classpath
(and no manager
) in JDK 6. And the code inside remains the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With