1

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

Stephane Grenier
  • 15,527
  • 38
  • 117
  • 192

2 Answers2

2

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
  • 12,815
  • 8
  • 45
  • 68
  • 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&F is called, etc.). To avoid all that, if you do nothing, it will grab the package name and class as the default application name in the menu ;) – Stephane Grenier Jul 06 '09 at 04:03
0

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
  • 15,527
  • 38
  • 117
  • 192