“ MVN测试”是否不将src / test / resources的内容复制到输出目录?

时间:2018-07-24 15:44:51

标签: maven

数据文件已在src/test/resources下更新。我原本以为

mvn test

该数据文件的最新版本将被复制到输出目录-${PROJECT_ROOT}/target/scala-2.11/test-classes/中。但是那没有发生。相反,有必要运行

mvn package

用于要同步的数据文件。有什么方法-只需调用mvn package(由于源文件没有更改,这比所需的工作要多得多)-将输出目录与当前源资源同步?

pom.xml的输出目录是:

<outputDirectory>target/scala-${scala.binary.version}/classes</outputDirectory>
 <testOutputDirectory>target/scala-${scala.binary.version}/test-classes</testOutputDirectory>

mvn test不会将工件复制到任何地方。

这是pom.xml的核心测试和包装相关部分。

<packaging>jar</packaging>

<build>
    <outputDirectory>target/scala-${scala.binary.version}/classes</outputDirectory>
    <testOutputDirectory>target/scala-${scala.binary.version}/test-classes</testOutputDirectory>
    <!--<resources>-->
      <!--<resource>-->
        <!--<directory>src/test/resources</directory>-->
        <!--<targetPath>.</targetPath>-->
        <!--<includes>-->
          <!--<include>**/*</include>-->
        <!--</includes>-->
      <!--</resource>-->
    <!--</resources>-->
    <plugins>
        <plugin>
            <groupId>net.alchim31.maven</groupId>
            <artifactId>scala-maven-plugin</artifactId>
            <version>3.2.2</version>
            <configuration>
                <scalaCompatVersion>${scala.binary.version}</scalaCompatVersion>
                <scalaVersion>${scala.version}</scalaVersion>
                <sourceDir>src/main/scala</sourceDir>
                <args>
                    <arg>-unchecked</arg>
                    <arg>-deprecation</arg>
                    <arg>-feature</arg>
                    <arg>-Xmacro-settings:materialize-derivations</arg>
                </args>
                <jvmArgs>
                    <jvmArg>-Xms64m</jvmArg>
                    <jvmArg>-Xmx1024m</jvmArg>
                </jvmArgs>
            </configuration>
            <executions>
                <execution>
                    <id>scala-compile-first</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>add-source</goal>
                        <goal>compile</goal>
                    </goals>
                </execution>
                <execution>
                    <id>scala-test-compile</id>
                    <phase>process-test-resources</phase>
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.4</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <createDependencyReducedPom>false</createDependencyReducedPom>
                        <minimizeJar>false</minimizeJar>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <skipTests>true</skipTests>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest-maven-plugin</artifactId>
            <version>2.0.0</version>
            <configuration>
                <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                <junitxml>.</junitxml>
                <filereports>WDF TestSuite.txt</filereports>
                <parallel>false</parallel>
            </configuration>
            <executions>
                <execution>
                    <id>test</id>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <suffixes>(?&lt;!Integration)(Test|Spec)</suffixes>
                        <stdout>G</stdout>
                    </configuration>
                </execution>
                <execution>
                    <id>integration-test</id>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <suffixes>(?&lt;=Integration)(Test|Spec)</suffixes>
                    </configuration>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>

0 个答案:

没有答案