[英]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
My src/main/resources
looks like following 我的
src/main/resources
如下所示
resources/
|-- to.be.packaged.inside.jar
|-- to.be.packaged/
| |-- also
|-- conf/
|-- application.properties
|-- log4j.properties
Now, I want to exclude the whole conf folder from being packaged in the JAR (but placed in the target folder). 现在,我想将整个conf文件夹从打包在JAR中排除(但放在目标文件夹中)。
I tried the following configuration to maven-jar-plugin 我尝试了以下配置到maven-jar-plugin
<excludes>
<exclude>conf/*</exclude>
</excludes>
However, this still packages an empty conf folder inside the JAR. 但是,这仍然在JAR中打包了一个空的conf文件夹 。 How do I exclude the folder and the content ?
如何排除文件夹和内容 ?
With conf/*
you're only excluding the matching files, it doesn't match the conf
directory. 使用
conf/*
您仅排除匹配的文件,它与conf
目录不匹配。 By added <exclude>conf</exclude>
the directory will be excluded as well. 通过添加
<exclude>conf</exclude>
该目录也将被排除。
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 (ie
<project-root>/conf
), which also means a cleaner pom because you don't have to exclude resources. 我希望conf-directory是project-root中的目录(即
<project-root>/conf
),这也意味着可以使用pom,因为您不必排除资源。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.