Sam
Sam

Reputation: 21

Ant jar task - include package but exclude sub-packages

I have a project with src package structure like below:

project
  -src
    -org.my.service
      A.java
      B.java
    -org.my.service.system
      C.java
      D.java

I am trying the below ant

<jar destfile="myjar.jar" basedir="../bin">
    <include name="**" />
    <include name="org/my/service/*" />
    <exclude name="org/my/service/**" />
</jar>

My built jar is excluding the service package altogether.

I want the jar to include A and B but exclude C and D. I am looking for a generic solution. The sub-packages will increase with time.

Upvotes: 0

Views: 777

Answers (1)

Rao
Rao

Reputation: 21359

In this case you can just keep on exclude as system package is not required and remove other two include.

So here goes the jar task:

<jar destfile="myjar.jar" basedir="../bin">
    <exclude name="org/my/service/system/**" />
</jar>

Upvotes: 1

Related Questions