Maven不会复制非java文件 [英] Maven does not copy non-java files
问题描述
我有一个包含以下内容的pom.xml文件:
I have a pom.xml file with the following:
<sourceDirectory>${basedir}/src/main/test</sourceDirectory>
<outputDirectory>${basedir}/src/main/bin </outputDirectory>
内部 $ {basedir} / src / main / test
我有一些不包含任何.java文件的文件夹。当我开始编译时,它们不会被复制到 $ {basedir} / src / main / bin
目录。
Inside ${basedir}/src/main/test
I have some folders which do not contain any .java files. When I start a compilation they are not copied to ${basedir}/src/main/bin
directory.
只移动.java文件(当然编译完成后)并存储在正确的文件夹中。
Only .java files are moved (after compilation of course) and stored on the right folder.
有人帮我解决这个问题而不使用任何插件吗?
Can someone help me to solve this problem without using any plugin ?
我试过
<resources>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/test/scenarios</directory>
<includes>
<include>*.xml</include>
</includes>
<targetPath>${basedir}/src/main/bin/scenarios</targetPath>
</resource>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/test/sut</directory>
<includes>
<include>*.xml</include>
</includes>
<targetPath>${basedir}/src/main/bin/sut</targetPath>
</resource>
</resources>
但它不起作用。有什么问题?
But it does not work. What is wrong?
推荐答案
如果它们不是java文件,你应该把它们移到 src / main / resources
和/或 src / test / resources
目录。这是存储非java文件的maven约定。
If they are not java files you should move them to the src/main/resources
and/or src/test/resources
directory. That's the maven convention for storing the non java files.
您的其他选择是使用 maven-resources -plugin 。
Your other option is to use the maven-resources-plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/test</directory>
<includes>
<include> <the_files_you_want_to_include></include>
</includes>
</resource>
</resources>
您还有另一种选择是使用 maven-antrun-plugin 并执行ant任务手动复制文件。
You have another option is to use the maven-antrun-plugin and execute an ant task to copy the files manually.
这篇关于Maven不会复制非java文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!