Maven:将文件从工作空间复制到目标之外的文件夹

时间:2012-04-04 16:32:03

标签: maven maven-resources-plugin

在构建期间,我需要将5个properties文件从我的项目工作区src/main/resources/my复制到文件夹C:\my(我在Windows 7上开发)。 C:\my存在但空洞。

我在我的pom.xml文件中使用以下代码,但不复制文件。

在构建期间,我没有收到任何错误,但我得到以下输出:

[INFO] --- maven-resources-plugin:2.5:copy-resources (copy-my-resources) @ my-webapp ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 5 resources

请注意,它没有像复制成功时通常那样说[INFO] Copying 5 resources to somewhere

但是,文件根本不会复制到C:\my

你能看到我的xml代码应该改变什么吗?

以下是相关代码:

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-resources-plugin</artifactId>
    <version>2.5</version>
    <executions>
            <execution>
                    <id>copy-my-resources</id>

                    <phase>process-resources</phase>

                    <goals>
                            <goal>copy-resources</goal>
                    </goals>
                    <configuration>

                            <!-- overwrite! -->
                            <overwrite>true</overwrite>

                            <outputDirectory>${env.HOMEDRIVE}/my</outputDirectory>
                            <resources>
                                    <resource>
                                            <directory>src/main/resources/my</directory>
                                            <filtering>false</filtering>
                                            <includes>
                                                <include>**/*.properties</include>
                                            </includes>
                                    </resource>
                            </resources>
                    </configuration>
            </execution>
    </executions>
</plugin>

2 个答案:

答案 0 :(得分:2)

要摆脱警告,你必须在你的pom中定义一个属性:

<properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

此外,在您的构建中放置一些内容,如家用驱动器等,将使您的构建不可移植。更好的解决方案是创建类似.zip的包,其中包含应用程序的整个配置。

答案 1 :(得分:1)

您可以run mvn -X ...命令从所有插件获取更详细的调试输出。

还要确保定义$ {env.HOMEDRIVE}属性并且$ {env.HOMEDRIVE} /我的文件夹存在。