cobertura maven插件和cassandra maven插件导致cassandra.rpcPort不同

cobertura maven插件和cassandra maven插件导致cassandra.rpcPort不同,maven,maven-cobertura-plugin,build-helper-maven-plugin,Maven,Maven Cobertura Plugin,Build Helper Maven Plugin,我在pom.xml中有以下配置 <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.8</version> <executions&g

我在pom.xml中有以下配置

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.8</version>
            <executions>
                <execution>
                    <id>reserve-network-port</id>
                    <goals>
                        <goal>reserve-network-port</goal>
                    </goals>
                    <phase>process-resources</phase>
                    <configuration>
                        <portNames>
                            <portName>cassandra.rpcPort</portName>
                            <portName>cassandra.jmxPort</portName>
                            <portName>cassandra.storagePort</portName>
                            <portName>cassandra.stopPort</portName>
                        </portNames>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12</version>
            <executions>
                <execution>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <enableAssertions>true</enableAssertions>
                        <excludes>
                            <exclude>none</exclude>
                        </excludes>
                        <includes>
                            <include>**/integration/**/*Test.java</include>
                        </includes>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cassandra-maven-plugin</artifactId>
            <version>1.2.1-1</version>
            <executions>
                <execution>
                    <id>start-cassandra</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>start</goal>
                    </goals>
                </execution>
                <execution>
                    <id>stop-cassandra</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>2.5.1</version>
            <executions>
                <execution>
                    <phase>test</phase>
                    <goals>
                        <goal>cobertura</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <formats>
                    <format>html</format>
                    <format>xml</format>
                </formats>
            </configuration>
        </plugin>

     <testResources>
        <testResource>
            <directory>src/test/resources</directory>
            <includes>
                <include>*.*</include>
            </includes>
            <filtering>true</filtering>
        </testResource>
     </testResources>
然后当cobertura跑的时候

[INFO] Reserved port 60319 for cassandra.rpcPort
[INFO] Reserved port 60320 for cassandra.jmxPort
[INFO] Reserved port 60321 for cassandra.storagePort
[INFO] Reserved port 60322 for cassandra.stopPort
cassandra maven插件生成一个target/cassandra/conf/cassandra.yaml文件,其中rpc_port:60315是源端口,而不是来自cobertura的端口。但是,属性文件具有由cobertura生成的端口的值

如果我禁用了cobertura插件,那么一切都会成功运行。有人知道如何回避这个问题吗

谢谢和问候
Tin

好的,我已经解决了这个问题,将buildhelpermaven插件移动到preparepackage阶段,并添加了以下内容

<plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.7</version>
                <executions>
                    <execution>
                        <id>copy-test-resources</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.basedir}/src/test/resources</directory>
                                    <includes>
                                        <include>*.properties</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
这样,cobertura插件已经完成,网络端口只扫描/保留一次。希望这能对将来的人有所帮助

<plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.7</version>
                <executions>
                    <execution>
                        <id>copy-test-resources</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.basedir}/src/test/resources</directory>
                                    <includes>
                                        <include>*.properties</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>