-1

My pom file has code something like below: Where I need that should exclude generating given files at the time of building project while should exclude generating the given folder (including all subfolders & files) itself while building project.

<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>

Here file exclusion starting from ihg is working, but folder ihg is not getting excluded. I have no idea how can I exclude folder in this case.

Pratik Shah
  • 89
  • 3
  • 10
  • iirc, `project.exclude.core.folders` are not built-in properties in Maven. You should show us how you are using these properties. – Adrian Shum Mar 23 '15 at 09:12
  • @AdrianShum: In this case, how can I exclude folder in my code hierarchy? I am new to POM – Pratik Shah Mar 23 '15 at 09:17
  • What do you mean by "exclude"? Excluding from Java compiler? Excluding from resource bundling? be specific please. In brief, try to understand which plugin is dealing with your source code you want to exclude, and find answer from its project page – Adrian Shum Mar 23 '15 at 09:26
  • @AdrianShum: I just don't want to create those files at the time of building my project – Pratik Shah Mar 23 '15 at 09:28
  • Can you try to read the comments again? You are missing the most important point. No one know how to exclude unless you give information on what are those source code. – Adrian Shum Mar 23 '15 at 09:29
  • @AdrianShum: Hi, sry. I have provided much clearer details. Please let me know if still something is missing. – Pratik Shah Mar 23 '15 at 09:35
  • http://maven.apache.org/plugins/maven-jar-plugin/jar-mojo.html There seems no configuration for `resource`. Can you make sure you have the correct config? And, it will be good if you can give some info on the related directory structure and what you are trying to include/exclude – Adrian Shum Mar 23 '15 at 09:39
  • Make separate modules in maven to make a separation of concern. Implementations should be separated from interfaces. Furthermore why are you trying to create a `test-jar`? – khmarbaise Mar 23 '15 at 10:19

2 Answers2

2

Have had a brief try in maven-jar-plugin. Assume I have something like this:

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

I can exclude foo from the result jar by:

<plugin>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <excludes>
            <exclude>**/foo/**</exclude>
        </excludes>
    </configuration>
</plugin>
Adrian Shum
  • 38,812
  • 10
  • 83
  • 131
2

You can refer: Maven - exclude folder from build

In short

Try

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

It will EXCLUDE foo as a folder

Community
  • 1
  • 1
Pratik Shah
  • 89
  • 3
  • 10