Question

When I:

<javac srcdir="${src}" destdir="${build.classes.dir}" classpathref="classpath">
    <include name="ObjectInDefaultPackage"/>
    <include name="com/mypackage/**"/>
</javac>

It will no longer add compile and add the class ObjectInDefaultPackage that's in the default package (ie. it's not packaged, it's sitting on the man ${src} directory). If I remove the includes it adds it fine, but once I set at least one include/exclude, I can no longer find a way to add it.

If I do:

<javac srcdir="${src}" destdir="${build.classes.dir}" classpathref="classpath">
</javac>

Then it compiles the ObjectInDefaultPackage...

Was it helpful?

Solution

Use this:

<include name="ObjectInDefaultPackage*"/>
<include name="com/mypackage/**"/>

Without slashes, Ant will search in the target directory, which is src. Or use *.java.

It's not recommended to have classes in the default package though.

OTHER TIPS

I just discovered the issue. Stupid mistake. It's what happens when you're so use to dealing with wildcards for so long.

The answer is:

<javac srcdir="${src}" destdir="${build.classes.dir}" classpathref="classpath">
    <include name="ObjectInDefaultPackage.java"/>
    <include name="com/mypackage/**"/>
</javac>

Notice ObjectInDefaultPackage has been changed to ObjectInDefaultPackage**.java**

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top