shuniar
shuniar

Reputation: 2622

ant javac exclude everything not included

I am trying to write a build script for a REST service which sits on top of our existing business logic layer, however, I only want to include the minimal amount of sources to keep the service small and only contain what it absolutely needs.

Below is my current compile target. I am able to either include everything or nothing. I assume I am making a simple mistake I can't seem to spot or find online.

<target name="compile">
    <mkdir dir="${build.classes.dir}"/>
    <javac source="1.6"
           target="1.6"
           encoding="UTF-8"
           debug="true"
           debuglevel="lines,vars,source"
           srcdir="${basedir}"
           destdir="${build.classes.dir}"
           includeAntRuntime="false">
        <src>
            <dirset dir="${src.eai.dir}" errorOnMissingDir="true">
                <include name="common/vo/MyPojo.java"/>
                <include name="common/SomeException.java"/>
            </dirset>
            <dirset dir="${src.ets.dir}" errorOnMissingDir="true">
                <include name="common/vo/AnotherPojo.java" />
                <include name="price/vo/YetAnotherPojo.java" />
                <include name="price/vo/OneMorePojo.java" />
            </dirset>
            <dirset dir="${src.java.dir}" errorOnMissingDir="true">
                <include name="java"/>
            </dirset>
        </src>
        <!-- this line ignores everything, without it it includes everything -->
        <exclude name="**/*.java"/>
        <classpath refid="classpath"/>
    </javac>
</target>

Is there a way to only include the files specified above?

Upvotes: 0

Views: 812

Answers (2)

Yogendra Singh
Yogendra Singh

Reputation: 34367

In place of exclude, try include and list your java files separated with comma(,) e.g:

<include name="common/vo/MyPojo.java,common/SomeException.java,common/vo/AnotherPojo.java,price/vo/YetAnotherPojo.java" />

Upvotes: 1

matt b
matt b

Reputation: 139921

Don't set both the srcdir attribute and the nested <src> element, as I imagine Ant is simply combining the two.

Upvotes: 0

Related Questions