Maven不会复制资源文件

时间:2018-02-21 14:08:05

标签: maven

我有一个maven web应用程序项目,它遵循maven标准目录布局,所以我的资源文件放在src / main / resources /中。

由于这符合标准,我希望maven在构建期间自动将资源文件添加到Web应用程序的/ WEB-INF / classes,但不会复制任何文件。

我必须将以下行添加到pom文件的build部分以让maven复制文件:

<resources>
    <resource>
        <directory>src/main/resources/</directory>
    </resource>
</resources>

我的问题是:这应该是必要的吗?

我想知道我使用的任何构建部分插件是否会以某种方式干扰资源的复制。是否有任何已知的插件可以执行此操作?

我的pom文件的构建部分在这里:

<build>
    <resources>
        <resource>
            <directory>src/main/resources/</directory>
        </resource>
    </resources>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <includes>
                    <include>${tests.to.include}</include>
                </includes>
                <excludes>
                    <exclude>${tests.to.exclude}</exclude>
                </excludes>
             </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.20.1</version>
            <configuration>
                <includes>
                    <include>**/ITSelenium*.java</include>
                </includes>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.12</version>
            <executions>
                <execution>
                    <id>add extra source directories</id>
                    <phase>generate-sources</phase>
                    <goals><goal>add-source</goal></goals>
                    <configuration>
                        <sources>
                            <source>${project.basedir}/generated/src/main/java</source>
                        </sources>
                    </configuration>
                </execution>

                <execution>
                    <id>add extra test directories</id>
                    <phase>generate-test-sources</phase>
                    <goals><goal>add-test-source</goal></goals>
                    <configuration>
                        <sources>
                            <source>${project.basedir}/generated/src/test/java</source>
                        </sources>
                    </configuration>
                </execution>

                <execution>
                    <id>add integration test sources</id>
                    <phase>generate-test-sources</phase>
                    <goals>
                        <goal>add-test-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>${project.basedir}/src/it/java</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <warName>res</warName>
                <webResources>
                    <resource>
                        <filtering>true</filtering>
                        <directory>${project.basedir}/src/main/webapp</directory>
                    </resource>
                </webResources>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.sonarsource.scanner.maven</groupId>
            <artifactId>sonar-maven-plugin</artifactId>
            <version>3.4.0.905</version>
        </plugin>

    </plugins>
</build>

非常感谢任何帮助或信息。

0 个答案:

没有答案