Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start and configure a WildFly server and deploy the app using wildfly-maven-plugin in 1 maven run

I want to have a way to run maven so that it will:

  • start a WildFly server instance in standalone mode (wildfly:run)
  • deploy the hsqldb driver
  • add a datasource
  • deploy the application

The problem is that:

  • wildfly:run blocks so no other maven goals can be executed
  • the server instance must be running before it can be configured or an app can be deployed (daaa)

A possible work around that comes to my mind is:

  • wildfly:start
  • configure the server and deploy the app
  • block until the user presses CTRL-C, is there a maven plugin that does that?
like image 392
Adam Siemion Avatar asked Sep 13 '14 09:09

Adam Siemion


People also ask

How do I deploy an application to the WildFly server?

Log into your instance of Wildfly and, from the main page, click Start (under Deployments — Figure 1). Accessing the Deployment tool in the Wildfly web-based interface. On the resulting page, drag the helloworld. war file into the Deployment pane on the left side (Figure 2).


1 Answers

You can use the parameter beforeDeployment of the run goal (source):

<plugin>
    <groupId>org.wildfly.plugins</groupId>
    <artifactId>wildfly-maven-plugin</artifactId>
    <configuration>
        <beforeDeployment>
            <commands>
                <command>data-source add --jndi-name=java:jboss/datasources/OracleDS --name=testDB --connection-url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1 --driver-name=h2 --user-name=sa --password=sa</command>
            </commands>
        </beforeDeployment>
    </configuration>
</plugin>

If you need additional libraries for your database driver you can do something like that (source):

module add --name=org.postgres --resources=/tmp/postgresql-9.3-1101.jdbc41.jar --dependencies=javax.api,javax.transaction.api
/subsystem=datasources/jdbc-driver=postgres:add(driver-name="postgres",driver-module-name="org.postgres",driver-class-name=org.postgresql.Driver)
like image 116
CSchulz Avatar answered Nov 13 '22 22:11

CSchulz