Maven 排除文件夹不工作

Maven exclude folder not working

我的 pom 文件包含如下代码: 我需要的地方应该排除在构建项目时生成给定文件 在构建项目时应该排除生成给定文件夹(包括所有子文件夹和文件)本身。

<profile>
    <id>nets</id>
    <properties>
        <ulysses.menu>ldms-menu.properties</ulysses.menu>
        <approval.workflow>false</approval.workflow>
        <mail.useldap>false</mail.useldap>
        <mail.latize.usesmtp>false</mail.latize.usesmtp>
        <ulysses.base.uri>http://data.latize.com/nets</ulysses.base.uri>
        <!-- lee.menu>nets-menu.properties</lee.menu >
        <lee.ftl>nets.ftl</lee.ftl>
        <path.has.lee>nets</path.has.lee>
        <kiwi.pages.startup>core/nets/summary.html</kiwi.pages.startup>
        <project.exclude.core.files>**/marmotta/platform/core/services/triplestore/*SesameServiceImpl*.*</project.exclude.core.files-->
        <project.exclude.core.files>**/ihg*.*</project.exclude.core.files>
        <project.exclude.core.folder>**/web/ihg/**</project.exclude.core.folder>
    </properties>
</profile>

...
<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <excludes>
                    <!--excludes native sesame implementation-->
                    <!--exclude>**/PrimarySesameServiceImpl*.*</exclude>
                    <exclude>**/ApprovalSesameServiceImpl*.*</exclude>
                    <exclude>**/SesameServiceImpl*.*</exclude-->

                    <!--excludes GraphDB sesame implementation -->
                    <!--exclude>**/GraphDBPrimarySesameServiceImpl*.*</exclude>
                    <exclude>**/GraphDBApprovalSesameServiceImpl*.*</exclude>
                    <exclude>**/GraphDBSesameServiceImpl*.*</exclude-->

                    <exclude>${project.exclude.core.files}</exclude>
                </excludes>
                <resource>
                    <directory>${project.exclude.core.folder}</directory>
                    <excludes>
                        <exclude>*.*</exclude>
                    </excludes>
                </resource>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>test-jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

此处从 ihg 开始的文件排除有效,但文件夹 ihg 未被排除。我不知道在这种情况下如何排除文件夹。

maven-jar-plugin 中进行了简短的尝试。假设我有这样的东西:

foo-proj
  + src
    + main
      + resources
        + foo
          - foo.txt
        + bar
          - bar.txt

我可以通过以下方式从结果 jar 中排除 foo

<plugin>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <excludes>
            <exclude>**/foo/**</exclude>
        </excludes>
    </configuration>
</plugin>

您可以参考:Maven - exclude folder from build

简而言之

尝试

<exclude>**/foo/**</exclude>

它将排除 foo 作为文件夹