Commit c4d17fa9 authored by Administrator's avatar Administrator

Allows both application execution and deployment with Maven

The previous Maven configuration included a WildFly Maven plugin
configuration in the H2 and MySQL profiles that allowed the application
execution directly from Maven (with the mvn wildfly:start wildfly:deploy
command). As this configuration included a custom WildFly deployment
configuration (that modified the standalone.xml of the WildFly where the
application will be deployed), the mvn wildfly:deploy couldn't be used
to deploy the application in a local WildFly instance.

This commit adds a new profile (wildfly-mysql-run) that can be used to
execute the application directly from Maven (with the mvn install
command). The custom WildFly plugin configuration has been removed from
the other profiles, allowing users to normally deploy the application in
a running WildFly instances.

Instructions on how to use the profiles for application execution and
deployment can be found in the README.md file.
parent 667186e4
This diff is collapsed.
...@@ -399,7 +399,7 @@ ...@@ -399,7 +399,7 @@
</interface> </interface>
</interfaces> </interfaces>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="0"> <socket-binding-group name="standard-sockets" default-interface="public" port-offset="10000">
<socket-binding name="management-http" interface="management" port="9990"/> <socket-binding name="management-http" interface="management" port="9990"/>
<socket-binding name="management-https" interface="management" port="9993"/> <socket-binding name="management-https" interface="management" port="9993"/>
<socket-binding name="ajp" port="8009"/> <socket-binding name="ajp" port="8009"/>
......
...@@ -408,7 +408,7 @@ ...@@ -408,7 +408,7 @@
</interface> </interface>
</interfaces> </interfaces>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="0"> <socket-binding-group name="standard-sockets" default-interface="public" port-offset="10000">
<socket-binding name="management-http" interface="management" port="9990"/> <socket-binding name="management-http" interface="management" port="9990"/>
<socket-binding name="management-https" interface="management" port="9993"/> <socket-binding name="management-https" interface="management" port="9993"/>
<socket-binding name="ajp" port="8009"/> <socket-binding name="ajp" port="8009"/>
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
<configuration> <configuration>
<property name="jbossHome">target/wildfly-${wildfly.version}</property> <property name="jbossHome">target/wildfly-${wildfly.version}</property>
<property name="modulePath">target/wildfly-${wildfly.version}/modules</property> <property name="modulePath">target/wildfly-${wildfly.version}/modules</property>
<property name="managementPort">19990</property>
</configuration> </configuration>
<protocol type="Servlet 3.0">
<property name="port">18080</property>
</protocol>
</container> </container>
</arquillian> </arquillian>
\ No newline at end of file
...@@ -474,58 +474,153 @@ ...@@ -474,58 +474,153 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<before-deployment>
<batch/>
<commands>
<command>data-source add --jndi-name=java:jboss/datasources/xcs --name=xcs-sample --jta=true --use-ccm=true --connection-url=jdbc:h2:mem:xcs;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE --driver-name=h2 --user-name=xcs --password=xcs</command>
<command>/core-service=management/security-realm=RemotingRealm:add</command>
<command>/core-service=management/security-realm=RemotingRealm/authentication=jaas:add(name="AppRealmLoopThrough")</command>
<command>/subsystem=remoting/http-connector=http-remoting-connector:write-attribute(name="security-realm", value="RemotingRealm")</command>
<command>/subsystem=security/security-domain=AppRealmLoopThrough:add(cache-type=default)</command>
<command>/subsystem=security/security-domain=AppRealmLoopThrough/authentication=classic:add(login-modules=[{"code"=>"Client", "flag" => "required", "module-options" => [("multi-threaded" => "true")]}])</command>
<command>/subsystem=security/security-domain=xcs-sample-security-domain:add</command>
<command>/subsystem=security/security-domain=xcs-sample-security-domain/authentication=classic:add(login-modules=[{"code"=>"Database", "flag" => "required", "module-options" => [("dsJndiName" => "java:jboss/datasources/xcs"),("principalsQuery" => "SELECT password FROM User WHERE login=?"),("rolesQuery" => "SELECT role, 'Roles' FROM User WHERE login=?"),("hashAlgorithm" => "MD5"),("hashEncoding" => "hex"),("ignorePasswordCase" => "true")]}])</command>
</commands>
</before-deployment>
<after-deployment>
<commands>
<command>:reload</command>
</commands>
</after-deployment>
<add-user>
<users>
<user>
<username>wildfly-admin</username>
<password>xcsadmin</password>
<applicationUser>false</applicationUser>
</user>
<user>
<username>admin</username>
<password>adminpass</password>
<applicationUser>true</applicationUser>
<groups>ADMIN</groups>
</user>
<user>
<username>owner</username>
<password>ownerpass</password>
<applicationUser>true</applicationUser>
<groups>OWNER</groups>
</user>
</users>
</add-user>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
</profile> </profile>
<profile> <profile>
<id>wildfly-embedded-mysql</id> <id>wildfly-embedded-mysql</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-embedded</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-embedded</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
<testResource>
<directory>src/test/resources-wildfly-embedded-mysql</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkCount>1</forkCount>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<mysql.version>${mysql.connector.java.version}</mysql.version>
<wildfly.version>${wildfly.version}</wildfly.version>
<arquillian.launch>wildfly-embedded</arquillian.launch>
</systemPropertyVariables>
<redirectTestOutputToFile>false</redirectTestOutputToFile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>process-test-classes</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-dist</artifactId>
<version>${wildfly.version}</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>target</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
<execution>
<id>copy-mysql</id>
<phase>process-test-classes</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/wildfly-${wildfly.version}/standalone/deployments</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
<execution>
<id>copy-mysql-for-execution</id>
<phase>process-test-classes</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
<destFileName>mysql-connector-java-${mysql.connector.java.version}.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
<!-- This JAR will be used for executing the Wildfly server -->
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-wildfly-resources</id>
<phase>process-test-classes</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/wildfly-${wildfly.version}/standalone/configuration</outputDirectory>
<resources>
<resource>
<directory>src/test/resources-wildfly-embedded-mysql</directory>
<include>standalone.xml</include>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>wildfly-mysql-run</id>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.wildfly</groupId> <groupId>org.wildfly</groupId>
...@@ -692,6 +787,16 @@ ...@@ -692,6 +787,16 @@
</users> </users>
</add-user> </add-user>
</configuration> </configuration>
<executions>
<execution>
<id>start-wildfly</id>
<phase>install</phase>
<goals>
<goal>start</goal>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
......
...@@ -399,7 +399,7 @@ ...@@ -399,7 +399,7 @@
</interface> </interface>
</interfaces> </interfaces>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="0"> <socket-binding-group name="standard-sockets" default-interface="public" port-offset="10000">
<socket-binding name="management-http" interface="management" port="9990"/> <socket-binding name="management-http" interface="management" port="9990"/>
<socket-binding name="management-https" interface="management" port="9993"/> <socket-binding name="management-https" interface="management" port="9993"/>
<socket-binding name="ajp" port="8009"/> <socket-binding name="ajp" port="8009"/>
......
...@@ -408,7 +408,7 @@ ...@@ -408,7 +408,7 @@
</interface> </interface>
</interfaces> </interfaces>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="0"> <socket-binding-group name="standard-sockets" default-interface="public" port-offset="10000">
<socket-binding name="management-http" interface="management" port="9990"/> <socket-binding name="management-http" interface="management" port="9990"/>
<socket-binding name="management-https" interface="management" port="9993"/> <socket-binding name="management-https" interface="management" port="9993"/>
<socket-binding name="ajp" port="8009"/> <socket-binding name="ajp" port="8009"/>
......
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
<configuration> <configuration>
<property name="jbossHome">target/wildfly-${wildfly.version}</property> <property name="jbossHome">target/wildfly-${wildfly.version}</property>
<property name="modulePath">target/wildfly-${wildfly.version}/modules</property> <property name="modulePath">target/wildfly-${wildfly.version}/modules</property>
<property name="managementPort">19990</property>
</configuration> </configuration>
<protocol type="Servlet 3.0">
<property name="port">18080</property>
</protocol>
</container> </container>
</arquillian> </arquillian>
\ No newline at end of file
...@@ -399,7 +399,7 @@ ...@@ -399,7 +399,7 @@
</interface> </interface>
</interfaces> </interfaces>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="0"> <socket-binding-group name="standard-sockets" default-interface="public" port-offset="10000">
<socket-binding name="management-http" interface="management" port="9990"/> <socket-binding name="management-http" interface="management" port="9990"/>
<socket-binding name="management-https" interface="management" port="9993"/> <socket-binding name="management-https" interface="management" port="9993"/>
<socket-binding name="ajp" port="8009"/> <socket-binding name="ajp" port="8009"/>
......
...@@ -408,7 +408,7 @@ ...@@ -408,7 +408,7 @@
</interface> </interface>
</interfaces> </interfaces>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="0"> <socket-binding-group name="standard-sockets" default-interface="public" port-offset="10000">
<socket-binding name="management-http" interface="management" port="9990"/> <socket-binding name="management-http" interface="management" port="9990"/>
<socket-binding name="management-https" interface="management" port="9993"/> <socket-binding name="management-https" interface="management" port="9993"/>
<socket-binding name="ajp" port="8009"/> <socket-binding name="ajp" port="8009"/>
......
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
<configuration> <configuration>
<property name="jbossHome">target/wildfly-${wildfly.version}</property> <property name="jbossHome">target/wildfly-${wildfly.version}</property>
<property name="modulePath">target/wildfly-${wildfly.version}/modules</property> <property name="modulePath">target/wildfly-${wildfly.version}/modules</property>
<property name="managementPort">19990</property>
</configuration> </configuration>
<protocol type="Servlet 3.0">
<property name="port">18080</property>
</protocol>
</container> </container>
</arquillian> </arquillian>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment