tags:

views:

489

answers:

4

When I run the ant file in verbose mode, I got an error like the one below. Does anyone have any ideas what is going wrong? I am new to this

antlib:org.apache.tools.ant] Could not load definitions from resource org/apach
e/tools/ant/antlib.xml. It could not be found.
Override ignored for property "java.home"
BUILD FAILED
Target "build..xml" does not exist in the project "MYPROJECT".
        at org.apache.tools.ant.Project.tsort(Project.java:1821)
        at org.apache.tools.ant.Project..topoSort(Project.java:1729)
        at org.apache.tools.ant.Project.topoSort(Project.java:1692)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
        at org.apache.tools.ant.Main.runBuild(Main.java:698)
        at org.apache.tools.ant.Main.startAnt(Main.java:199)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Total time: 1 second

this is my build.xml

<property name="build.home" value="build/jsp" />

<property name="tomcat.home" location="../Tomcat 5.0/" />

<path id="project.class.path">

 <fileset dir="./lib/">

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

 </fileset>

</path>



<target name="reltag">

 <tstamp>

  <format property="now" pattern="d MMM yyyy HH:mm" />

 </tstamp>

 <property name="reltag" value="Built date: ${now}" />

</target>



<target name="dev" depends="compile" description="Builds for development">

 <mkdir dir="jsp/WEB-INF/lib" />

 <mkdir dir="jsp/WEB-INF/classes" />

 <copy todir="jsp/WEB-INF/lib">

  <fileset dir="lib">

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

  </fileset>

 </copy>

 <copy todir="jsp/WEB-INF/classes">

  <fileset dir="classes">

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

  </fileset>

 </copy>

</target>



<target name="compile" depends="myproject-gen,reltag">

 <copy file="setup/Version.java.template" tofile="java/myproject/Version.java" overwrite="true">

  <filterset>

   <filter token="VERSION" value="${reltag}" />

  </filterset>

 </copy>

 <mkdir dir="classes" />

 <depend srcdir="java" destdir="classes" cache="depcache" />

 <javac srcdir="java" destdir="classes">

  <classpath refid="project.class.path" />

 </javac>

</target>



<target name="myproject-gen" description="Generates torque classes and SQL for myproject">

 <!-- generate the java files -->

 <ant dir="torque" target="om" />

 <antcall target="myproject-sql-mysql" />

</target>



<!-- generate the schema.sql script for MySQL -->

<target name="myproject-sql-mysql" depends="myproject-sql-mysql-check" unless="mysql.schema.up.to.date">

 <echo message="Generating SQL file for MySQL" />

 <ant dir="torque" target="sql">

  <property name="torque.database" value="mysql" />

  <property name="torque.runOnlyOnSchemaChange" value="false" />

 </ant>

 <move file="sql/gen/myproject-schema.sql" tofile="sql/gen/myproject-schema-mysql.sql" overwrite="true" />

 <copy file="sql/gen/myproject-schema-mysql.sql" tofile="jsp/admin/database.sql" overwrite="true"/>

 <copy file="sql/init.sql" tofile="jsp/admin/init.sql" overwrite="true" />

</target>

<!-- check if we need to generate the sql file -->

<target name="myproject-sql-mysql-check">

 <uptodate property="mysql.schema.up.to.date" targetfile="sql/gen/myproject-schema-mysql.sql" srcfile="torque/myproject-schema.xml" />

</target>



<target name="myproject-war" depends="compile-jsp">

 <mkdir dir="build" />

 <jar destfile="build/myproject.war" basedir="build/jsp" />

</target>









<target name="prepare_for_war_file">

 <mkdir dir="build\jsp-classes\org\apache\jsp" />

 <!--

 <move todir="${build.home}/WEB-INF/classes/org/apache/jsp">

      <fileset dir="${build.home}">

   <include name="*.jsp"/>

   </fileset>

 </move> 

 -->

 <!-- copy everything which is not a jsp to admin directory -->

 <copy tofile="${build.home}/admin/database.sql">

  <fileset file="sql/gen/*-schema-mysql.sql" />

 </copy>

 <copy file="sql/init.sql" todir="${build.home}/admin" />



 <mkdir dir="${build.home}/pdb_files" />

 <!-- copy images directory -->

 <copy todir="${build.home}/images">

  <fileset dir="jsp/images" />

 </copy>



 <copy todir="${build.home}/hand">

  <fileset dir="jsp/hand" />

 </copy>

 <!-- copy javascript directory -->

 <copy todir="${build.home}/javascript">

  <fileset dir="jsp/javascript" />

 </copy>

 <!-- copy META-INF directory -->

 <copy todir="${build.home}/META-INF">

  <fileset dir="jsp/META-INF" />

 </copy>

 <!-- copy stylesheet directory -->

 <copy todir="${build.home}/stylesheet">

  <fileset dir="jsp/stylesheet" />

 </copy>





 <!-- copy WEB-INF directory  -->



 <copy todir="${build.home}/WEB-INF/classes/">

  <fileset dir="classes/" includes="**" />

 </copy>

 <copy todir="${build.home}/WEB-INF/lib">

  <fileset dir="lib" includes="*.*" excludes="Cabwiz" />

 </copy>





 <!-- copy license and properties -->

 <!--<copy file="WebContent/myproject.license" todir="${build.home}"/> -->

 <copy file="jsp/myproject.properties" todir="${build.home}" />



 <!-- move jsp classes to the correct package structure so war file will work when deployed -->



 <move todir="${build.home}/WEB-INF/classes/org/apache/jsp">

  <fileset dir="${build.home}" includes="**/*.class" excludes="WEB-INF/**" />

 </move>



 <antcall target="create-web_XML">

 </antcall>

</target>













<target name="create-web_XML">

 <loadfile property="generated.web.xml" srcFile="jsp/WEB-INF/generated_web.xml" />

 <copy file="jsp/WEB-INF/web_template.xml" tofile="jsp/WEB-INF/web.xml.deployable" overwrite="true">

  <filterset begintoken="&lt;!--" endToken="--&gt;">

   <filter token="GENERATED_WEB_XML" value="${generated.web.xml}" />

  </filterset>

 </copy>

 <copy file="jsp/WEB-INF/web.xml.deployable" tofile="build/jsp/WEB-INF/web.xml" />

</target>







<target name="compile-jsp" depends="dev">







 <antcall target="prepare_for_war_file">

 </antcall>



 <property environment="env" />

 <taskdef classname="org.apache.jasper.JspC" name="jasper2">

  <classpath id="jspc.classpath">

   <pathelement location="${java.home}/../lib/tools.jar" />

   <fileset dir="${env.tomcat.home}/bin2">

    <include name="*.jar" />

   </fileset>

   <fileset dir="${env.tomcat.home}/server/lib">

    <include name="*.jar" />

   </fileset>

   <fileset dir="${env.tomcat.home}/common/lib">

    <include name="*.jar" />

   </fileset>

  </classpath>

 </taskdef>



 <mkdir dir="java/jsp-src" />

 <jasper2 validateXml="false" package="org.apache.jsp" uriroot="jsp" webXmlFragment="jsp/WEB-INF/generated_web.xml" outputDir="java/jsp-src" />

 <jspc srcdir="jsp" destdir="java/jsp-src">

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

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

 </jspc>



 <mkdir dir="build/jsp-classes" />

 <property environment="env" />

 <javac destdir="build/jsp/WEB-INF/classes" optimize="off" debug="on" failonerror="true" srcdir="java/jsp-src" excludes="**/*.smap">

  <classpath>

   <pathelement location="classes" />

   <fileset dir="lib">

    <include name="*.jar" />

   </fileset>

   <pathelement location="${env.tomcat.home}/common/classes" />

   <fileset dir="${env.tomcat.home}/common/lib">

    <include name="*.jar" />

   </fileset>

   <pathelement location="${env.tomcat.home}/shared/classes" />

   <fileset dir="${env.tomcat.home}/shared/lib">

    <include name="*.jar" />

   </fileset>

   <fileset dir="${env.tomcat.home}/bin">

    <include name="*.jar" />

   </fileset>

  </classpath>

  <include name="**" />

  <!--<exclude name="**/includes/*menu_jsp.java" />-->

 </javac>

</target>











<target name="clean" description="Deletes the java/classes dir and torque base objects">

 <delete dir="classes" />

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

 <delete>

  <fileset file="build/*" />

 </delete>

 <delete dir="java/myproject/torque/map" />

 <delete dir="java/jsp-src" />

 <delete dir="jsp/WEB-INF/classes" />

 <delete dir="jsp/WEB-INF/lib" />

 <delete>

  <fileset dir="java/myproject/torque" includes="Base*.java" />

 </delete>

 <touch file="torque/myproject-schema.xml" />

</target>

A: 
  1. Probably you don't have environment variable ANT_HOME set properly
  2. It seems that you are calling Ant like this: "ant build..xml". If your ant script has name build.xml you need to specify only a target in command line. For example: "ant target1".
wheleph
I set ant_home in the enviornment variable and i called the ant like ant -verbose build.xml. I am getting the same error.
You don't have to give script's name. Call it like this "ant -verbose" and show the output here.
wheleph
ok ok I am sorry I was giving the build.xml. I will try wiith the target now.thanx :)
oh okay i will do it thanx
but when i gave ant verbose. i got BUILD FAILEDTarget "verbose" does not exist in the project "MYPROJECT"
You've missed dash. Call like this: ant -verbose
wheleph
yeah it was mt typing mistake.I put - also
A: 

Looks like you called it 'ant build..xml'. ant automatically choose a file build.xml in the current directory, so it is enough to call 'ant' (if a default-target is defined) or 'ant target' (the target named target will be called).

With the call 'ant -p' you get a list of targets defined in your build.xml.

Edit: In the comment is shown the call 'ant -verbose build.xml'. To be correct, this has to be called as 'ant -verbose'. The file build.xml in the current directory will be used automatically. If it is needed to explicitly specify the buildfile (because it's name isn't build.xml for example), you have to specify the buildfile with the '-f'-option: 'ant -verbose -f build.xml'. I hope this helps.

Mnementh
i called "ant -verbose build.xml".
let me try that.thanx
I think that ant -p only displays targets that have a description defined.
braveterry
@braveterry: That's right, -p only displays targets with a defined description. Normally that is used to make targets 'public' and the others private. As a creator of buildfiles you often need targets for internal use, but the user don't need to know of them. If you are curios: 'ant -p -v' displays all targets, also these without a description.
Mnementh
A: 

<property name="build.home" value="build/jsp" />

<property name="tomcat.home" location="../Tomcat 5.0/" />

<path id="project.class.path">

 <fileset dir="./lib/">

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

 </fileset>

</path>



<target name="reltag">

 <tstamp>

  <format property="now" pattern="d MMM yyyy HH:mm" />

 </tstamp>

 <property name="reltag" value="Built date: ${now}" />

</target>



<target name="dev" depends="compile" description="Builds for development">

 <mkdir dir="jsp/WEB-INF/lib" />

 <mkdir dir="jsp/WEB-INF/classes" />

 <copy todir="jsp/WEB-INF/lib">

  <fileset dir="lib">

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

  </fileset>

 </copy>

 <copy todir="jsp/WEB-INF/classes">

  <fileset dir="classes">

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

  </fileset>

 </copy>

</target>



<target name="compile" depends="myproject-gen,reltag">

 <copy file="setup/Version.java.template" tofile="java/myproject/Version.java" overwrite="true">

  <filterset>

   <filter token="VERSION" value="${reltag}" />

  </filterset>

 </copy>

 <mkdir dir="classes" />

 <depend srcdir="java" destdir="classes" cache="depcache" />

 <javac srcdir="java" destdir="classes">

  <classpath refid="project.class.path" />

 </javac>

</target>



<target name="myproject-gen" description="Generates torque classes and SQL for myproject">

 <!-- generate the java files -->

 <ant dir="torque" target="om" />

 <antcall target="myproject-sql-mysql" />

</target>



<!-- generate the schema.sql script for MySQL -->

<target name="myproject-sql-mysql" depends="myproject-sql-mysql-check" unless="mysql.schema.up.to.date">

 <echo message="Generating SQL file for MySQL" />

 <ant dir="torque" target="sql">

  <property name="torque.database" value="mysql" />

  <property name="torque.runOnlyOnSchemaChange" value="false" />

 </ant>

 <move file="sql/gen/myproject-schema.sql" tofile="sql/gen/myproject-schema-mysql.sql" overwrite="true" />

 <copy file="sql/gen/myproject-schema-mysql.sql" tofile="jsp/admin/database.sql" overwrite="true"/>

 <copy file="sql/init.sql" tofile="jsp/admin/init.sql" overwrite="true" />

</target>

<!-- check if we need to generate the sql file -->

<target name="myproject-sql-mysql-check">

 <uptodate property="mysql.schema.up.to.date" targetfile="sql/gen/myproject-schema-mysql.sql" srcfile="torque/myproject-schema.xml" />

</target>



<target name="myproject-war" depends="compile-jsp">

 <mkdir dir="build" />

 <jar destfile="build/myproject.war" basedir="build/jsp" />

</target>









<target name="prepare_for_war_file">

 <mkdir dir="build\jsp-classes\org\apache\jsp" />

 <!--

 <move todir="${build.home}/WEB-INF/classes/org/apache/jsp">

      <fileset dir="${build.home}">

   <include name="*.jsp"/>

   </fileset>

 </move> 

 -->

 <!-- copy everything which is not a jsp to admin directory -->

 <copy tofile="${build.home}/admin/database.sql">

  <fileset file="sql/gen/*-schema-mysql.sql" />

 </copy>

 <copy file="sql/init.sql" todir="${build.home}/admin" />



 <mkdir dir="${build.home}/pdb_files" />

 <!-- copy images directory -->

 <copy todir="${build.home}/images">

  <fileset dir="jsp/images" />

 </copy>



 <copy todir="${build.home}/hand">

  <fileset dir="jsp/hand" />

 </copy>

 <!-- copy javascript directory -->

 <copy todir="${build.home}/javascript">

  <fileset dir="jsp/javascript" />

 </copy>

 <!-- copy META-INF directory -->

 <copy todir="${build.home}/META-INF">

  <fileset dir="jsp/META-INF" />

 </copy>

 <!-- copy stylesheet directory -->

 <copy todir="${build.home}/stylesheet">

  <fileset dir="jsp/stylesheet" />

 </copy>





 <!-- copy WEB-INF directory  -->



 <copy todir="${build.home}/WEB-INF/classes/">

  <fileset dir="classes/" includes="**" />

 </copy>

 <copy todir="${build.home}/WEB-INF/lib">

  <fileset dir="lib" includes="*.*" excludes="Cabwiz" />

 </copy>





 <!-- copy license and properties -->

 <!--<copy file="WebContent/myproject.license" todir="${build.home}"/> -->

 <copy file="jsp/myproject.properties" todir="${build.home}" />



 <!-- move jsp classes to the correct package structure so war file will work when deployed -->



 <move todir="${build.home}/WEB-INF/classes/org/apache/jsp">

  <fileset dir="${build.home}" includes="**/*.class" excludes="WEB-INF/**" />

 </move>



 <antcall target="create-web_XML">

 </antcall>

</target>













<target name="create-web_XML">

 <loadfile property="generated.web.xml" srcFile="jsp/WEB-INF/generated_web.xml" />

 <copy file="jsp/WEB-INF/web_template.xml" tofile="jsp/WEB-INF/web.xml.deployable" overwrite="true">

  <filterset begintoken="&lt;!--" endToken="--&gt;">

   <filter token="GENERATED_WEB_XML" value="${generated.web.xml}" />

  </filterset>

 </copy>

 <copy file="jsp/WEB-INF/web.xml.deployable" tofile="build/jsp/WEB-INF/web.xml" />

</target>







<target name="compile-jsp" depends="dev">







 <antcall target="prepare_for_war_file">

 </antcall>



 <property environment="env" />

 <taskdef classname="org.apache.jasper.JspC" name="jasper2">

  <classpath id="jspc.classpath">

   <pathelement location="${java.home}/../lib/tools.jar" />

   <fileset dir="${env.tomcat.home}/bin2">

    <include name="*.jar" />

   </fileset>

   <fileset dir="${env.tomcat.home}/server/lib">

    <include name="*.jar" />

   </fileset>

   <fileset dir="${env.tomcat.home}/common/lib">

    <include name="*.jar" />

   </fileset>

  </classpath>

 </taskdef>



 <mkdir dir="java/jsp-src" />

 <jasper2 validateXml="false" package="org.apache.jsp" uriroot="jsp" webXmlFragment="jsp/WEB-INF/generated_web.xml" outputDir="java/jsp-src" />

 <jspc srcdir="jsp" destdir="java/jsp-src">

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

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

 </jspc>



 <mkdir dir="build/jsp-classes" />

 <property environment="env" />

 <javac destdir="build/jsp/WEB-INF/classes" optimize="off" debug="on" failonerror="true" srcdir="java/jsp-src" excludes="**/*.smap">

  <classpath>

   <pathelement location="classes" />

   <fileset dir="lib">

    <include name="*.jar" />

   </fileset>

   <pathelement location="${env.tomcat.home}/common/classes" />

   <fileset dir="${env.tomcat.home}/common/lib">

    <include name="*.jar" />

   </fileset>

   <pathelement location="${env.tomcat.home}/shared/classes" />

   <fileset dir="${env.tomcat.home}/shared/lib">

    <include name="*.jar" />

   </fileset>

   <fileset dir="${env.tomcat.home}/bin">

    <include name="*.jar" />

   </fileset>

  </classpath>

  <include name="**" />

  <!--<exclude name="**/includes/*menu_jsp.java" />-->

 </javac>

</target>











<target name="clean" description="Deletes the java/classes dir and torque base objects">

 <delete dir="classes" />

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

 <delete>

  <fileset file="build/*" />

 </delete>

 <delete dir="java/myproject/torque/map" />

 <delete dir="java/jsp-src" />

 <delete dir="jsp/WEB-INF/classes" />

 <delete dir="jsp/WEB-INF/lib" />

 <delete>

  <fileset dir="java/myproject/torque" includes="Base*.java" />

 </delete>

 <touch file="torque/myproject-schema.xml" />

</target>

I added this to your original post.
Thomas Owens
This is not the complete buildfile. I'm missing the root-tag (project). There is defined the default-target.
Mnementh
<project name="MYPROJECT" default="dev" basedir=".">. this is the first line of my build.xml file and earlier I wronly copied the file. I edited it with the correct one. plz check
Thank you very much for adding it to my orginal post :)
but thats the wrong post:(. can you replace it with the correct one plz ,or can you tell how you did it.
hi i have edited that
+1  A: 

Try reading the manual.

yeah I tried that but... not working
This part: http://ant.apache.org/manual/running.html
Zac Thompson