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.

1 Answer 1

8

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.