2

How can I use a custom standalone.xml when running wildfly-maven-plugin:start (not just adding datasources, drivers,...)?

Using wildfly-maven-plugin-1.0.2.Final:

<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.0.2.Final</version>
...
<execution>
    <id>pre-integration-phase</id>
    <phase>pre-integration-test</phase>
    <goals>
        <goal>start</goal>
        <goal>deploy</goal>
    </goals>
</execution>
...

I have tried using maven-resources-plugin for copying resources (standalone.xml) in wildfly configuration folder, but it seems that wildfly:start overwrites and deletes every (other) file in Wildfly (configuration) directory.

This task is used for jenkins integration testing, thats why I need jboss running just when testing is in progress.

Aparna Chaudhary
  • 1,325
  • 8
  • 10
Zigac
  • 1,551
  • 1
  • 16
  • 27

1 Answers1

7

You can unpack the WildFly installation and then set jbossHome configuration element in wildfly-maven-plugin.

Example configuration:

    <version.wildfly>8.2.0.Final</version.wildfly>
    <jboss.home>${project.build.directory}/wildfly-${version.wildfly}</jboss.home>
    <server.config>standalone.xml</server.config>


        <!-- Unpack the distribution -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>unpack-wildfly</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                    <inherited>false</inherited>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>org.wildfly</groupId>
                                <artifactId>wildfly-dist</artifactId>
                                <version>${version.wildfly}</version>
                                <type>zip</type>
                                <overWrite>false</overWrite>
                                <outputDirectory>${project.build.directory}</outputDirectory>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <!-- Copy server configuration -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>${version.plugin.resources}</version>
            <executions>
                <execution>
                    <id>copy-standalone-xml</id>
                    <phase>generate-test-sources</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${jboss.home}/standalone/configuration</outputDirectory>
                        <resources>
                            <resource>
                                <directory>src/main/resources</directory>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <!-- WildFly plugin to deploy war -->
        <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <version>${version.wildfly.maven.plugin}</version>
            <configuration>
                <jbossHome>${jboss.home}</jbossHome>
                <serverConfig>${server.config}</serverConfig>
            </configuration>
            <executions>
                <execution>
                    <id>pre-integration-phase</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>start</goal>
                        <goal>deploy</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
Aparna Chaudhary
  • 1,325
  • 8
  • 10