Maven,从打包的jar中排除资源文件夹 [英] Maven, exclude folder of resources from packaged jar
问题描述
我正在尝试为我的应用程序实现以下分发,并且我正在关注这个问题作为指导方针
I'm trying to achieve the following distribution for my application, and I'm following this question as guideline
dist/
|-- application-1.0.jar
|-- conf/
|-- application.properties
|-- log4j.properties
|-- lib/
|-- *.jar
我的 src / main / resources
如下所示
resources/
|-- to.be.packaged.inside.jar
|-- to.be.packaged/
| |-- also
|-- conf/
|-- application.properties
|-- log4j.properties
现在,我想排除整个 conf 文件夹被打包在JAR中(但放在目标文件夹中)。
Now, I want to exclude the whole conf folder from being packaged in the JAR (but placed in the target folder).
我尝试了以下配置 maven-jar-plugin
<excludes>
<exclude>conf/*</exclude>
</excludes>
但是,这仍然会在JAR中打包一个空的conf文件夹。如何排除文件夹和内容?
However, this still packages an empty conf folder inside the JAR. How do I exclude the folder and the content?
推荐答案
使用 conf / *
您只排除匹配的文件,它与 conf
目录不匹配。添加< exclude> conf< / exclude>
该目录也将被排除。
With conf/*
you're only excluding the matching files, it doesn't match the conf
directory. By added <exclude>conf</exclude>
the directory will be excluded as well.
但是,你应该问问自己:这些文件应该在类路径上可用吗?我希望conf目录是项目根目录中的一个目录(即< project-root> / conf
),这也意味着一个更清洁的pom因为你不喜欢不必排除资源。
However, you should ask yourself: should these files be available on the classpath? I would expect the conf-directory to be a directory in the project-root (i.e. <project-root>/conf
), which also means a cleaner pom because you don't have to exclude resources.
这篇关于Maven,从打包的jar中排除资源文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!