我有一个项目,这个目录如何将Maven项目中的特定文件打包到战争中的特定目录?
src/main/texts
在这个目录中我有很多Ø文件类型,例如,* .TXT,*将该.cvs等
我要生成一个战争我需要这个目录的只有* .txt文件在战争中的特定目录,POF例如:
war/files/*.txt
什么Maven插件,我可以用它来做到这一点? 将“src/main/texts”的所有* .txt文件打包到战争目录“files”中。
我有一个项目,这个目录如何将Maven项目中的特定文件打包到战争中的特定目录?
src/main/texts
在这个目录中我有很多Ø文件类型,例如,* .TXT,*将该.cvs等
我要生成一个战争我需要这个目录的只有* .txt文件在战争中的特定目录,POF例如:
war/files/*.txt
什么Maven插件,我可以用它来做到这一点? 将“src/main/texts”的所有* .txt文件打包到战争目录“files”中。
请参阅maven war插件的“添加和过滤外部Web资源”。 检查Maven文档here
样品插件配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>src/main/texts</directory>
<!-- the default value is ** -->
<includes>
<include>**/*.txt</include>
</includes>
<targetPath>war/files</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
移动这些文件到单独的目录,并添加以下到您的配置:
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>TheFolderYouHavedecided<directory>
</resource>
</webResources>
</configuration>
或者其他方式将是确定您喜欢的文件夹:
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>src/main/texts<directory>
<includes>
<include>**/*.txt</include>
</includes>
<targetPath>war/files</targetPath>
</resource>
</webResources>
</configuration>
我建议重新考虑您的项目结构以及放置哪些零件的位置。
http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html