task allows showing a url in a browser (cross platform) <project name="test"> <target name="test"> <browse url="http://www.google.com"/> </target> </project>
Created attachment 16110 [details] [PATCH]Browse Task
Created attachment 16111 [details] add the taskdef to the properties file
I'm not sure this an ideal solution 1. it makes assumptions about the order of browser in unix 2. it rejects all other platforms. 3. malformed urls should be turned into build exceptions at the time of setting, for proper diagnostics 4. its not really the thing automated builds do, though test result display is a good case for it. I do occasionally open browsers in my build file for test results, but just <exec> "open", having a bit of code to open a browser on every os (on windows an exe to calls ShellExecuteEx() on the path, linux a script to run mozilla). This is the way to do x-platform, but only by relying on native code.
I like this one personally. It is true that the code is "rustic". It will always be possible to make this task more complex by adding attributes or nested elements to execute specific commands on specific operating systems. We are using already something similar as a macro in a lot of our build files where I work, in order to view various HTML reports in developer builds.
FWIW, NetBeans actually defines a special task for in-VM scripts, <nbbrowse>. Used for test results, Javadoc, and some other things (when you run the 'interactive' variant of the target). The NB version picks up the web browser as defined in IDE settings but it would be nice for there to be a standard task to do this. The patch should be made to use JDK 6's java.awt.Desktop class if it is available, which neatly bypasses all the platform-specific code and ought to behave more accurately to boot. String os = System.getProperty("os.name").toLowerCase(); will cause OS detection to fail for Turkish and Azeri users of Windows and misc. Unix. Use toLowerCase(Locale.ENGLISH) instead.