MarteJ
asked on
Compileing with ant - classpath not set
Hi,
I'm new to ant. When running a specific target ( <target name="settings">) which prints out some parameters in the file (no compilation), the whole file is obviously checked for errors. The building fails:
taskdef class com.sun.tools.xjc.XJCTask cannot be found
This is the part that creates the error (JAXB specific):
<taskdef name="xjc" classname="com.sun.tools.x jc.XJCTask ">
</taskdef>
<target name="jaxbcodegeneration">
<!-- generate the Java content classes from the schema file-->
<echo message="Compiling the schema file..."/>
<xjc schema="${bsl.src}/schema. xsd" target="${bsl.src}" package="somedir.jaxbcode" />
</target>
If I do setenv CLASSPATH to the neccesary path for com.sun.tools.xjc.XJCTask, then running 'ant settings' works fine.
The reason is that the classpath is not set until a later state in the building process (before the compilation starts). How can I set the classpath in the build.xml file (don't want to do it manually), to avoid this error. Is calling another xml file with the elements above from within this build.xml a better solution. What is the syntax for that?
Thanks for any help!!
I'm new to ant. When running a specific target ( <target name="settings">) which prints out some parameters in the file (no compilation), the whole file is obviously checked for errors. The building fails:
taskdef class com.sun.tools.xjc.XJCTask cannot be found
This is the part that creates the error (JAXB specific):
<taskdef name="xjc" classname="com.sun.tools.x
</taskdef>
<target name="jaxbcodegeneration">
<!-- generate the Java content classes from the schema file-->
<echo message="Compiling the schema file..."/>
<xjc schema="${bsl.src}/schema.
</target>
If I do setenv CLASSPATH to the neccesary path for com.sun.tools.xjc.XJCTask,
The reason is that the classpath is not set until a later state in the building process (before the compilation starts). How can I set the classpath in the build.xml file (don't want to do it manually), to avoid this error. Is calling another xml file with the elements above from within this build.xml a better solution. What is the syntax for that?
Thanks for any help!!
One more suggestion.
<property name="classpath" location="your_classes_loc ation"/>
...
<classpath>
<pathelement path="${classpath}"/>
</classpath>
...
Regards!
<property name="classpath" location="your_classes_loc
...
<classpath>
<pathelement path="${classpath}"/>
</classpath>
...
Regards!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you both for taking the time to help me!!! Everything compiles now!
Sorry vk33, I didn't get your code to work.
Sorry vk33, I didn't get your code to work.
You can specify your classpath in build.xml like this:
<taskdef name="xjc" classname="com.sun.tools.x
<classpath>
<pathelement location="lib/jaxb.jar"/>
</classpath>
</taskdef>
Replace pathelement with something appropriate and it should work.
Good luck!