2

I am using JAXB 2.1.2 with the MOXy implementation. To build my web app I am using Ant 1.7.1 and I am also using the

package-info.java 

class to specify namespace stuff.

All runs fine, except the package-info.java does not get compiled. in the build directory, there is no expected package-info.class at the dedicated directory (with my domain classes).

How can I force Ant to also compile the package-info.java class?

I read about Ant's limitation here but I can't believe that this has not been resolved? http://ant.apache.org/manual/Tasks/javac.html

Thanks

bdoughan
  • 147,609
  • 23
  • 300
  • 400
basZero
  • 4,129
  • 9
  • 51
  • 89
  • I am currently investigating the following "trick": as of the javac limitation in ant, it only compiles the package-info if the java file is newer than the target directory where the class file gets copied to. I now try to do a with ANT right before the compile, maybe that helps. – basZero Feb 02 '11 at 17:14
  • However, I wonder how other projects to solve this issue when they have to use the package-info.java (e.g. MOXy uses that file to declare namespace prefix values) – basZero Feb 02 '11 at 17:16

1 Answers1

2

In the meanwhile I found a workaround myself, so this works fine but only if you compile twice (somehow the target folder where the class file gets stored to must be older than the package-info.java file): Instead of these ant commands in my build.xml:

<mkdir dir="${realm.classes.dir}"/>
<javac srcdir="${realm.java.dir}" destdir="${realm.classes.dir}"
  classpathref="classpath"
  encoding="${javac.encoding}"
  debug="true"
/>

I had to use the additional command:

<mkdir dir="${realm.classes.dir}"/>
<touch>
  <fileset dir="${realm.java.dir}" includes="**/package-info.java"/>
</touch>
<javac srcdir="${realm.java.dir}" destdir="${realm.classes.dir}"
  classpathref="classpath"
  encoding="${javac.encoding}"
  debug="true"
/>

If you have a better solution, let me know!

basZero
  • 4,129
  • 9
  • 51
  • 89
  • I'm using ANT 1.8.2 via Jenkins, and the package-info.java are compiled but no package-info.class files are generated. I also tried the mentioned solution but without success, any hint's. – Alex Nov 16 '11 at 00:41
  • Did you build it twice? Otherwise the workaround does not work. – basZero Nov 22 '11 at 12:42