Commit 45d4ccba authored by Administrator's avatar Administrator

Fixes and simplifies WildFly execution with Maven

The configuration to execute WildFly using Maven commands was causing
problems in Windows environments.

This problem has been fixed by upgrading the plugin version, which
implied rebuilding its configuration. As part of this change, the
configuration was also simplified, and now starting the application and
redeploying it is faster.

In addition, submodules that do not require WildFly to run the tests
no longer copy it. This reduces the execution time.
parent 629c2222
...@@ -199,6 +199,12 @@ This will launch the complete construction cycle without running the tests, star ...@@ -199,6 +199,12 @@ This will launch the complete construction cycle without running the tests, star
**Important**: You shouldn't have a local WildFly instance running or Maven will not be able to start its own WildFly and will try to deploy the application in the running instance. This will cause changes to the WildFly configuration that may leave it in an unstable state. **Important**: You shouldn't have a local WildFly instance running or Maven will not be able to start its own WildFly and will try to deploy the application in the running instance. This will cause changes to the WildFly configuration that may leave it in an unstable state.
Once WildFly is running, you can quickly redeploy the application (typically after making some changes) by executing the following command:
```bash
mvn install wildfly:deploy-only -DskipTests=true
```
To stop the WildFly launched you can execute the following command: To stop the WildFly launched you can execute the following command:
```bash ```bash
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>es.uvigo.esei.xcs</groupId> <groupId>es.uvigo.esei.xcs</groupId>
...@@ -43,6 +44,23 @@ ...@@ -43,6 +44,23 @@
<groupId>org.jacoco</groupId> <groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
</plugin> </plugin>
<!-- Disables both plugins to avoid WildFly download for testing-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>es.uvigo.esei.xcs</groupId> <groupId>es.uvigo.esei.xcs</groupId>
...@@ -8,10 +9,10 @@ ...@@ -8,10 +9,10 @@
</parent> </parent>
<artifactId>ear</artifactId> <artifactId>ear</artifactId>
<packaging>ear</packaging> <packaging>ear</packaging>
<name>EAR</name> <name>EAR</name>
<description>XCS Sample - EAR</description> <description>XCS Sample - EAR</description>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>es.uvigo.esei.xcs</groupId> <groupId>es.uvigo.esei.xcs</groupId>
...@@ -36,7 +37,7 @@ ...@@ -36,7 +37,7 @@
<type>war</type> <type>war</type>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
...@@ -64,13 +65,31 @@ ...@@ -64,13 +65,31 @@
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.wildfly.plugins</groupId> <groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId> <artifactId>wildfly-maven-plugin</artifactId>
<configuration> <configuration>
<skip>false</skip> <skip>false</skip>
<filename>${project.parent.artifactId}-${project.version}.${project.packaging}</filename> <filename>
</configuration> ${project.parent.artifactId}-${project.version}.${project.packaging}</filename>
</plugin> </configuration>
</plugin>
<!-- Disables both plugins to avoid WildFly download for testing-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
<maven.resources.plugin.version>3.3.1</maven.resources.plugin.version> <maven.resources.plugin.version>3.3.1</maven.resources.plugin.version>
<maven.source.plugin.version>3.3.0</maven.source.plugin.version> <maven.source.plugin.version>3.3.0</maven.source.plugin.version>
<maven.surefire.plugin.version>3.1.2</maven.surefire.plugin.version> <maven.surefire.plugin.version>3.1.2</maven.surefire.plugin.version>
<wildfly.maven.plugin.version>1.2.2.Final</wildfly.maven.plugin.version> <wildfly.maven.plugin.version>2.1.0.Final</wildfly.maven.plugin.version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>
...@@ -92,11 +92,11 @@ ...@@ -92,11 +92,11 @@
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId> <groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-bom</artifactId> <artifactId>shrinkwrap-resolver-bom</artifactId>
<version>${shrinkwrap.resolver.bom.version}</version> <version>${shrinkwrap.resolver.bom.version}</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jboss.arquillian.selenium</groupId> <groupId>org.jboss.arquillian.selenium</groupId>
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
<!-- Modules --> <!-- Modules -->
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
...@@ -655,6 +655,13 @@ ...@@ -655,6 +655,13 @@
<profile> <profile>
<id>wildfly-mysql-run</id> <id>wildfly-mysql-run</id>
<dependencies>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
...@@ -676,135 +683,69 @@ ...@@ -676,135 +683,69 @@
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.wildfly.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId> <artifactId>wildfly-maven-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<id>unpack</id> <id>start-wildfly</id>
<phase>process-test-classes</phase> <phase>install</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> <goals>
<goal>copy</goal> <goal>start</goal>
</goals> </goals>
<configuration> <configuration>
<artifactItems> <add-user>
<artifactItem> <users>
<groupId>com.mysql</groupId> <user>
<artifactId>mysql-connector-j</artifactId> <username>wildfly-admin</username>
<type>jar</type> <password>xcsadmin</password>
<overWrite>false</overWrite> <applicationUser>false</applicationUser>
<outputDirectory>${project.build.directory}/wildfly-${wildfly.version}/standalone/deployments</outputDirectory> </user>
</artifactItem> </users>
</artifactItems> </add-user>
</configuration> </configuration>
</execution> </execution>
<execution> <execution>
<id>copy-mysql-for-execution</id> <id>add-mysql</id>
<phase>process-test-classes</phase> <phase>install</phase>
<goals> <goals>
<goal>copy</goal> <goal>deploy-artifact</goal>
</goals> </goals>
<configuration> <configuration>
<artifactItems> <groupId>com.mysql</groupId>
<artifactItem> <artifactId>mysql-connector-j</artifactId>
<groupId>com.mysql</groupId> <name>mysql-connector-j-${mysql.connector.java.version}.jar</name>
<artifactId>mysql-connector-j</artifactId>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
<destFileName>mysql-connector-j-${mysql.connector.java.version}.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration> </configuration>
<!-- This JAR will be used for executing the Wildfly server -->
</execution> </execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution> <execution>
<id>copy-wildfly-resources</id> <id>configure-wildfly</id>
<phase>process-test-classes</phase> <phase>install</phase>
<goals> <goals>
<goal>copy-resources</goal> <goal>execute-commands</goal>
</goals> </goals>
<configuration> <configuration>
<outputDirectory>${project.build.directory}/wildfly-${wildfly.version}/standalone/configuration</outputDirectory> <batch>true</batch>
<resources> <commands>
<resource> <command>data-source add --jndi-name=java:jboss/datasources/xcs --name=xcs-sample --jta=true --use-ccm=true
<directory>src/test/resources-wildfly-embedded-mysql</directory> --connection-url=jdbc:mysql://localhost:3306/xcs?useJDBCCompliantTimezoneShift=true&amp;useLegacyDatetimeCode=false&amp;serverTimezone=Europe%2FMadrid --driver-name=mysql-connector-j-${mysql.connector.java.version}.jar
<include>standalone.xml</include> --user-name=xcs --password=xcs</command>
</resource> <command>/core-service=management/security-realm=RemotingRealm:add</command>
</resources> <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>
</configuration> </configuration>
</execution> </execution>
</executions>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<before-deployment>
<batch />
<commands>
<command>deploy ${project.build.directory}/mysql-connector-j-${mysql.connector.java.version}.jar</command>
<command>data-source add --jndi-name=java:jboss/datasources/xcs --name=xcs-sample --jta=true --use-ccm=true
--connection-url=jdbc:mysql://localhost:3306/xcs?useJDBCCompliantTimezoneShift=true&amp;useLegacyDatetimeCode=false&amp;serverTimezone=Europe%2FMadrid --driver-name=mysql-connector-j-${mysql.connector.java.version}.jar
--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>
</users>
</add-user>
</configuration>
<executions>
<execution> <execution>
<id>start-wildfly</id> <id>deploy-wildfly</id>
<phase>install</phase> <phase>install</phase>
<goals> <goals>
<goal>start</goal>
<goal>deploy-only</goal> <goal>deploy-only</goal>
</goals> </goals>
</execution> </execution>
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>es.uvigo.esei.xcs</groupId> <groupId>es.uvigo.esei.xcs</groupId>
...@@ -34,4 +35,25 @@ ...@@ -34,4 +35,25 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<!-- Disables both plugins to avoid WildFly download for testing-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>
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