I have a maven project which creates a war file and this should be deployed to a bundled wildfly server via wildfly:run
.
That works so far, but I need to create a datasource before deploying.
I have tried to bind the add-resource goal to different phases like deploy, install or package. None of them worked.
What is wrong?
An idea would be to use the wildfly:start
attach an execution to add the datasource and deploy the application, but I don't know how.
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<executions>
<execution>
<id>add-datasource</id>
<phase>deploy</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<address>subsystem=datasources,data-source=java:jboss/testDB</address>
<resources>
<resource>
<properties>
<jndi-name>java:jboss/testDB</jndi-name>
<enabled>true</enabled>
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
<driver-class>org.h2.Driver</driver-class>
<driver-name>h2</driver-name>
<user-name>sa</user-name>
<password>sa</password>
</properties>
</resource>
</resources>
</configuration>
</execution>
</executions>
My solution is to use the run goal and the beforeDeployment goal: