You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Klaus <kl...@vommond.de> on 2006/03/13 14:27:13 UTC

Calling an from my own applocation

Hi,

 

I have a problem calling ant from my own application. As lonag as I just
call the standard ant task, there is no problem. But if I want to use some
external tasks, like jaxb etc. ant craches while execution. The entire
application is packed into one single jar file. This jar-file contains the
necessary libs. If a check the properties of the ant project in my code, I
see that "java.class.path" is set to myApplication.jar. If tried to change
this properties, but it did'nt change anything!

 

Here is my code:

 

Project ant = new Project();

ProjectHelper helper = new ProjectHelperImpl();

ant.init();

helper.parse(ant, new File("build.xml")); 

ant.executeTarget("generate-hybrid-config");

 

<?xml version="1.0"?>

<project name="BUILD HERBIE 4 INSTALL" default="prepare" basedir=".">

            

            <property name="ant.lib"
value="${basedir}/lib/ant" />

            <property name="app.lib"
value="${basedir}/lib" />

            <property name="hybrid.lib"
value="${basedir}/lib-hybrid" />

            

            <path id="project.lib">               

                        <fileset dir="${app.lib}" >

                            <include name="**/*.jar" />

                                   <exclude name="ant/**/*" />

                        </fileset>

                        <fileset dir="${hybrid.lib}">

                                   <include name="**/*.jar" />

                        </fileset>

            </path>

                        

            <path id="ant.lib.path">

                        <fileset dir="${ant.lib}">

                                   <include name="**/*.jar" />

                        </fileset>

                        <fileset dir="${app.lib}">

                                   <include name="**/*.jar" />

                        </fileset>

                        <fileset dir="${hybrid.lib}">

                                   <include name="**/*.jar" />

                        </fileset>

            </path>

            

            

            <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask"
classpathref="ant.lib.path" />

 

            <property name="build" value="${basedir}/build-ant"/>     

            

            

            <property name="jaxb.xsd"
value="${basedir}/web/WEB-INF/herbie-config.xsd" />

            <property name="build.jaxb"
value="${build}/jaxb" />

 

            <property name="hybrid.xsd"
value="${basedir}/answer/web/WEB-INF/semantic-config.xsd" />

            <property name="build.hybrid.jaxb"
value="${build}/jaxb-hybird" />

            

            <target name="clean">

                        <delete dir="${build}" />

            </target>

            

            <target name="generate"

                        description="Generate valueobject-classes with
JAXB">

                        <xjc target="${build.jaxb}"

                                   schema="${jaxb.xsd}"
removeoldoutput="yes">

                                     <produces dir="${build.jaxb}" />

                        </xjc>

            </target>

 

            <target name="generate-hybrid-config" 

                        description="Generate valueobject-classes with
JAXB">

                        <xjc target="${build.hybrid.jaxb}"

                             schema="${hybrid.xsd}" removeoldoutput="yes">

                                    <produces dir="${build.hybrid.jaxb}" />

                        </xjc>

            </target>

</project>

 

 

Thank you

 

Klaus