Maven wildfly-maven-plugin 自定义 standalone.xml

Maven wildfly-maven-plugin custom standalone.xml

当 运行 wildfly-maven-plugin:start(不仅仅是添加数据源、驱动程序等)时,我如何使用自定义 standalone.xml?

使用 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>
...

我尝试使用 maven-resources-plugin 复制 wildfly 配置文件夹中的资源 (standalone.xml),但似乎 wildfly:start 覆盖并删除了每个Wildfly(配置)目录中的(其他)文件。

此任务用于 jenkins 集成测试,这就是为什么我需要 jboss 运行 就在测试正在进行时。

您可以解压 WildFly 安装,然后在 wildfly-maven-plugin 中设置 jbossHome 配置元素。

示例配置:

    <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>