2012-04-04 59 views
0

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

我在我的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> 

回答

1

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

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

2

为了摆脱你在你的POM定义属性警告:

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

而且东西放在您的构建像HOMEDRIVE等会让你构建不便于携带。更好的解决方案是创建包含.zip的包,其中包含应用程序的整个配置。

相关问题