Reputation: 135
I have an application with 2 modules:
Web JSF (WAR deployed on Tomcat)
REST Services (WAR deployed on Wildfly)
For integration tests I use maven plugins:
maven failsafe plugin
fabric8 maven plugin
My tests source code and resources are located in both applications src/integration-test/java.
In integration tests phase fabric8 builds Wildfly docker image, copies built articact (REST Services WAR), starts container and runs tests. It works correctly.
But... I would like to configure maven to deploy 2 applications ( Web JSF WAR artifact and REST Services WAR) and run integration tests from JSF WAR/src/integration-test/java. Using fabric8 plugin its easy to build and run Tomcat and Wildfly containers but I cant find how to deploy 2 different artifacts from different maven modules. Maybe do you have any idea?
Best regards, MJ.
Upvotes: 1
Views: 595
Reputation: 2374
io.fabric8 docker-maven-plugin supports multiple images. You can create a module responsible for running the integration tests. This module will depend on 2 WAR artifacts you've mentioned in the question.
<dependencies>
<dependency>
<groupId>com.your.maven.group.here</groupId>
<artifactId>your-maven-artifact</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
<dependency>
...
</dependency>
</dependencies>
Then you can setup necessary containers using io.fabric8. Here is an example from my project (some details are removing for sake of simplicity and conciseness of the answer). The example is not about Tomcat and Wildfly but just to illustrate the idea.
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<images>
<image>
....
</image>
<image>
<name>my-admin-site</name>
<alias>admin-ux</alias>
<build>
<from>jetty</from>
<ports>
<port>8080</port>
</ports>
<runCmds>
<run>mkdir -p /run/jetty /tmp/jetty</run>
<run>chmod -R 1777 /tmp</run>
<run>chown -R jetty:jetty /var/lib/jetty /run/jetty /tmp/jetty</run>
</runCmds>
<assembly>
<mode>dir</mode>
<basedir>/var/lib/jetty</basedir>
<inline xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2">
<id>my-admin-ux</id>
<dependencySets>
<dependencySet>
<includes>
<include>com.your.maven.group.here:your-maven-artifact:war</include>
</includes>
<outputDirectory>./webapps</outputDirectory>
<outputFileNameMapping>myAdminSite.war</outputFileNameMapping>
</dependencySet>
</dependencySets>
<files>
<file>
<source>src/main/docker/admin-ux/resources/service.properties</source>
<outputDirectory>./resources</outputDirectory>
</file>
</files>
</inline>
<user>jetty:jetty</user>
</assembly>
</build>
<run>
<ports>
<port>10540:8080</port>
</ports>
<links>
<link>zookeeper:zookeeper</link>
</links>
</run>
</image>
<image>
.....
</image>
</images>
</configuration>
</plugin>
Upvotes: 1