Maven: copy file from workspace to folder which is

2019-08-27 21:11发布

During build, I need to copy 5 properties files from my project workspace src/main/resources/my, to the folder C:\my (I develop on Windows 7). C:\my exists but empty.

I am using the following code in my pom.xml file, but the files are not copied.

During the build, I do not get any error, but I am getting the following output:

[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

Pay attention, that it does not say [INFO] Copying 5 resources to somewhere as it usually does when the copy is successful.

However, the files are not copied to C:\my at all.

Could you see what I should change in my xml code?

Here is the relevant code:

<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条回答
Evening l夕情丶
2楼-- · 2019-08-27 21:50

To get rid of the warning you have to define a property in your pom:

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

Furthermore putting something in your build like a homedrive etc. will make your build not portable. Better solution would be to create package like .zip which contains the whole configuration for your application.

查看更多
爷、活的狠高调
3楼-- · 2019-08-27 21:51

You can run mvn -X ... command to get more detailed debug output from all plugins.

Also make sure that ${env.HOMEDRIVE} property is defined and ${env.HOMEDRIVE}/my folder exists.

查看更多
登录 后发表回答