0

Is there any possibility to open a browser with a tab to localhost:8080/index.html when running mvn wildfly-swarm:run?

I would appreciate your answer!

GC268DM
  • 403
  • 7
  • 15

1 Answers1

1

You could use a combination of groovy and the java.awt.Desktop class (around since Java 1.6) to open whatever URL you wish:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.gmavenplus</groupId>
            <artifactId>gmavenplus-plugin</artifactId>
            <version>1.5</version>
            <executions>
                <execution>
                    <phase>install</phase>
                    <goals>
                        <goal>execute</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <scripts>
                    <script>
                    <![CDATA[
                        import java.awt.Desktop
                        import java.net.URI
                        Desktop.getDesktop().browse(new URI("http://www.example.com"))
                    ]]>
                    </script>
                </scripts>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-all</artifactId>
                    <!-- any version of Groovy \>= 1.5.0 should work here -->
                    <version>2.4.7</version>
                    <scope>runtime</scope>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

(This was tested on OSX, but since the java Desktop class is being used, should be cross-platform)

Ashutosh Jindal
  • 18,501
  • 4
  • 62
  • 91