tags:

views:

807

answers:

2

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

+1  A: 

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.

aberrant80
This can work too, but it's possible to have more than one Object starting with the same string that you don't want to include. Btw, the reason for the default package has to do with how the Application is named in the main menu for the Mac OS. Long story short you can do a System.setProperty(...) but it's cumbersome and has some other rules (for example when the L)
Stephane Grenier
A: 

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

Stephane Grenier