Using Ant, how do I open a file in a browser?

2019-01-25 12:52发布

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

标签: ant
8条回答
贼婆χ
2楼-- · 2019-01-25 13:23

One way to do this is to invoke your favorite browser with the filename. If you have Ant execute

firefox "file:///G:/Report.html"

it will launch Firefox with that file.

查看更多
你好瞎i
3楼-- · 2019-01-25 13:24

Try using Ant's exec task to execute a system command.

http://ant.apache.org/manual/Tasks/exec.html

An example from that document:

<property name="browser" location="C:/Program Files/Internet Explorer/iexplore.exe"/>
<property name="file" location="ant/docs/manual/index.html"/>

<exec executable="${browser}" spawn="true">
    <arg value="${file}"/>
</exec>
查看更多
登录 后发表回答