I am beginner and its Java legacy applications,I am trying to build this application using Ant but its getting build only with java version 6 but when i build it with java 8 version i am getting below Error can some one suggest me please?
I am unable to resolve it since 2 weeks please suggest some one.
build.xml
<project name="CDMWeb" default="cdmwebweblogic.war" basedir=".">
<!-- ========================================================================================= -->
<!-- CDMWeb APPLICATION ANT BUILD FILE -->
<!-- ========================================================================================= -->
<!-- ***************************************************************** -->
<!-- #author : Muhammad Azeem -->
<!-- #date : 10/16/2008 -->
<!-- #description : Ant Build file for CDMWeb Application. -->
<!-- ***************************************************************** -->
<!-- ============================= START CDMWeb BUILD =================================== -->
<property environment="env" />
<import file="resource/apache-beehive-1.0.2\beehive-imports.xml"/>
<import file="resource/apache-beehive-1.0.2\ant\beehive-tools.xml"/>
<property name="build.dir" location="build"/>
<property name="libs" value="web/WEB-INF/lib"/>
<property name="webapp.dir" location="${basedir}/web"/>
<property name="web.dir" location="${basedir}/web"/>
<property name="tmp.sourcegen.dir" value=".tmpbeansrc"/>
<property name="dist.dir" location="${basedir}/dist"/>
<property name="exploded.dir" location="${dist.dir}/CDMWeb.war"/>
<property name="mqapp.dir" location="${build.dir}/mqapp.war"/>
<property name="explodedmqwebapp.dir" location="${exploded.dir}/MQWeb.war/"/>
<!-- BGW RT interface related Properties -->
<property name="bgw.final.dir" location="${exploded.dir}/WEB-INF/lib" />
<property name="bgw.dir" location="src/bgw"/>
<property name="bgw.build.dir" location="${build.dir}/bgw"/>
<property name="bgw.stager" location="${bgw.dir}/BGWStager"/>
<property name="bgw.stager.generated" location="${bgw.stager}/generated"/>
<property name="bgw.extractor" location="${bgw.dir}/BGWEventExtractor"/>
<property name="bgw.sqlrunner" location="${bgw.dir}/SqlRunner"/>
<property name="bgw.build.stager.dir" location="${bgw.build.dir}/stager"/>
<property name="bgw.build.extractor.dir" location="${bgw.build.dir}/extractor"/>
<property name="bgw.build.extractor.dir" location="${bgw.build.dir}/sqlrunner"/>
<property name="bgw.stager.notification.pkg.name" value="com.verizon.vi.bgw.notification"/>
<property name="bgw.stager.notification.pkg.dir" value="${bgw.stager.generated}/com/verizon/vi/bgw/notification"/>
<!-- Define the classpath used to build the BGW Stager and extractor app -->
<property name="bgw.stager.classpath" value="lib/mail.jar lib/ifxjdbc.jar lib/cem_client.jar lib/cdm_data_dictionary.jar lib/ojdbc6_11.2.0.3.jar"/>
<property name="bgw.extractor.classpath" value="lib/jaas.jar lib/jtds.jar lib/mail.jar lib/ifxjdbc.jar lib/cem_client.jar lib/log4j.jar lib/jta-spec1_0_1.jar lib/jms.jar lib/bgw_vi.jar lib/namespace.jar lib/cdm_data_dictionary.jar lib/BaaisIntfUtils.jar lib/weblogic.jar"/>
<property name="bgw.sqlrunner.classpath" value="lib/ifxjdbc.jar lib/log4j.jar lib/ojdbc6_11.2.0.3.jar"/>
<!-- Define the classpath used to build the app -->
<path id="app.classpath">
<fileset dir="${libs}">
<include name="*.jar"/>
</fileset>
</path>
<path id="webapp.classpath">
<pathelement location="${servlet-api.jar}"/>
<pathelement location="${jsp-api.jar}"/>
<pathelement location="${build.dir}/WEB-INF/classes"/>
<fileset dir="${libs}">
<include name="*.jar"/>
</fileset>
</path>
<path id="webapp.sourcepath">
<pathelement location="${web.dir}"/>
<pathelement location="${web.dir}/src"/>
</path>
<taskdef name="xjc" classpathref="app.classpath" classname="com.sun.tools.xjc.XJCTask"></taskdef>
<target name="clean">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
</target>
<target name="init">
<mkdir dir="${build.dir}/WEB-INF/classes"/>
</target>
<target name="compile.dbgen">
<echo message="[ * --- Compiling dbgen --- * ]"/>
<javac destdir="${build.dir}/WEB-INF/classes" classpathref="app.classpath" debug="on" debuglevel="lines,source">
<src path="dbgen/src"/>
</javac>
</target>
<target name="compile.src">
<echo message="[ * --- Compiling src --- * ]"/>
<javac destdir="${build.dir}/WEB-INF/classes" classpathref="app.classpath" debug="on" debuglevel="lines,source">
<src path="src/com"/>
</javac>
</target>
<target name="compile.web">
<echo message="[ * --- Compiling web --- * ]"/>
<javac destdir="${build.dir}/WEB-INF/classes" classpathref="app.classpath" debug="on" debuglevel="lines,source">
<src path="web/src"/>
</javac>
</target>
<target name="compile.all" depends="init,compile.dbgen,compile.src,compile.web">
<echo message="[ * --- Compiled dbgen,src,web --- * ]"/>
</target>
<target name="copy.web">
<copy todir="${build.dir}/WEB-INF/lib">
<fileset dir="web/WEB-INF/lib">
<include name="*.*"/>
<exclude name="weblogic.jar"/>
</fileset>
</copy>
<copy todir="${build.dir}/WEB-INF">
<fileset dir="web/WEB-INF">
<include name="*.*"/>
</fileset>
</copy>
<copy todir="${build.dir}">
<fileset dir="web">
<include name="*.*"/>
</fileset>
</copy>
<copy todir="${build.dir}">
<fileset dir="web">
<include name="**/*.*"/>
<exclude name="src/**"/>
</fileset>
</copy>
<copy todir="${build.dir}/WEB-INF/classes">
<fileset dir="resource">
<include name="*.properties"/>
<include name="*.xml"/>
</fileset>
</copy>
<copy todir="${build.dir}/WEB-INF">
<fileset dir="resource/beans">
<include name="cdm*.xml"/>
</fileset>
</copy>
</target>
<target name="deploy-beehive" description="Copy the Beehive Page Flow rutime into the target webapp">
<deploy-netui webappDir="${build.dir}"/>
</target>
<target name="compile.jpf" depends="deploy-beehive" description="Build the webapp">
<available property="webapp.dir.available" file="${webapp.dir}" type="dir"/>
<fail unless="webapp.dir.available" message="Can't find the webapp directory ${webapp.dir}"/>
<!-- compile JPFs -->
<echo>Building Page Flows</echo>
<build-pageflows srcdir="${basedir}/web"
webcontentdir="${web.dir}"
destdir="${build.dir}/WEB-INF/classes"
tempdir="${build.dir}/${tmp.sourcegen.dir}"
sourcepathref="webapp.sourcepath"
classpathref="webapp.classpath"/>
</target>
<target name="build" depends="compile.all,copy.web,compile.jpf">
</target>
<target name="buildwar" depends="build" description="Builds a compressed WAR file that can be deployed to Tomcat application container">
<echo message="[ * --- Creating WAR file for Deployment into Tomcat--- * ]"/>
<mkdir dir="${dist.dir}"/>
<war destfile="${dist.dir}/CDMWeb.war" webxml="${build.dir}/WEB-INF/web.xml">
<fileset dir="${build.dir}">
<exclude name="WEB-INF/web.xml"/>
</fileset>
</war>
</target>
<target name="cdmweb.war" depends="clean,init,build,buildwar">
</target>
<!-- ===================== BGW Stager and Extractor Build - BEGIN ======================= -->
<target name="bgw.build" depends="bgw.init,bgw.build.stager,bgw.build.extractor,bgw.build.sqlrunner,copy.bgw,bgw.clean">
<echo message="[ * --- Created BGWStager.jar and BGWEventExtractor.jar Successfully...."/>
</target>
<!-- Creation of BGW Stager and extractor related directories -->
<target name="bgw.init">
<mkdir dir="${bgw.stager.generated}"/>
<mkdir dir="${bgw.build.dir}"/>
<mkdir dir="${bgw.build.stager.dir}"/>
<mkdir dir="${bgw.build.extractor.dir}"/>
<mkdir dir="${bgw.build.sqlrunner.dir}"/>
<mkdir dir="${dist.dir}"/>
</target>
<!-- Clean up of BGW Stager and extractor related directories -->
<target name="bgw.clean">
<delete dir="${bgw.stager.generated}"/>
<delete dir="${bgw.build.dir}"/>
<delete dir="${bgw.build.stager.dir}"/>
<delete dir="${bgw.build.extractor.dir}"/>
<delete dir="${bgw.build.sqlrunner.dir}"/>
<!-- If this causes issues may need to move the orginal dest -->
<delete file="${dist.dir}/BGWStager.jar"/>
<delete file="${dist.dir}/BGWEventExtractor.jar"/>
<delete file="${dist.dir}/SqlRunner.jar"/>
</target>
<!-- XJC for creating Java classes for BGW Notification schema -->
<target name="bgw.compile.schema.prepare">
<echo message="Started XJC Compilation of BGW Notification" />
<xjc schema="${bgw.stager}/xml-resources/jaxb/BGWNotification/bgwNotification.xsd" package="${bgw.stager.notification.pkg.name}" destdir="${bgw.stager.generated}">
<produces dir="${bgw.stager.notification.pkg.dir}" />
</xjc>
</target>
<!-- Compilation of Generated BGW Notification Java Classes. -->
<target name="bgw.compile.schema" depends="bgw.compile.schema.prepare">
<echo message="Started Compiling generated BGW Notification" />
<javac destdir="${bgw.build.stager.dir}" classpathref="app.classpath" debug="on" debuglevel="lines,source">
<src path="${bgw.stager.generated}"/>
</javac>
</target>
<!-- BGW Stager Soruces Compilation -->
<target name="bgw.compile.stager" depends="bgw.compile.schema">
<echo message="[ * --- Compiling BGW Stager --- * ]"/>
<javac destdir="${bgw.build.stager.dir}" classpathref="app.classpath" classpath="${bgw.build.stager.dir}" debug="on" debuglevel="lines,source">
<src path="${bgw.stager}/src"/>
</javac>
</target>
<!-- BGW Stager Build -->
<target name="bgw.build.stager" depends="bgw.compile.stager">
<echo message="[ * --- Preparing BGW Stager jar --- * ]"/>
<jar jarfile="${dist.dir}/BGWStager.jar"
basedir="${bgw.build.stager.dir}">
<include name="**/*.class"/>
<manifest>
<attribute name="Main-class" value="com.verizon.vi.bgw.stager.StagerMain"/>
<attribute name="Class-Path" value="${bgw.stager.classpath}"/>
</manifest>
</jar>
</target>
<!-- BGW extractor Soruces Compilation -->
<target name="bgw.compile.extractor">
<echo message="[ * --- Compiling extractor --- * ]"/>
<javac destdir="${bgw.build.extractor.dir}" classpathref="app.classpath" debug="on" debuglevel="lines,source">
<src path="${bgw.extractor}/src"/>
</javac>
</target>
<!-- BGW extractor Build -->
<target name="bgw.build.extractor" depends="bgw.compile.extractor">
<echo message="[ * --- Preparing BGW extractor jar --- * ]"/>
<jar jarfile="${dist.dir}/BGWEventExtractor.jar"
basedir="${bgw.build.extractor.dir}">
<include name="**/*.class"/>
<manifest>
<attribute name="Main-class" value="com.verizon.vi.bgweventextractor.ExtractorMain"/>
<attribute name="Class-Path" value="${bgw.extractor.classpath}"/>
</manifest>
</jar>
</target>
<!-- BGW SQLRunner Soruces Compilation -->
<target name="bgw.compile.sqlrunner">
<echo message="[ * --- Compiling extractor --- * ]"/>
<javac destdir="${bgw.build.sqlrunner.dir}" classpathref="app.classpath" debug="on" debuglevel="lines,source">
<src path="${bgw.sqlrunner}/src"/>
</javac>
</target>
<!-- BGW extractor Build -->
<target name="bgw.build.sqlrunner" depends="bgw.compile.sqlrunner">
<echo message="[ * --- Preparing BGW SQLRunner --- * ]"/>
<jar jarfile="${dist.dir}/SqlRunner.jar"
basedir="${bgw.build.sqlrunner.dir}">
<include name="**/*.class"/>
<manifest>
<attribute name="Main-class" value="sqlrunner.SqlMain"/>
<attribute name="Class-Path" value="${bgw.sqlrunner.classpath}"/>
</manifest>
</jar>
</target>
<target name="copy.bgw">
<copy todir="${bgw.final.dir}">
<fileset dir="${dist.dir}">
<include name="*.jar"/>
</fileset>
</copy>
</target>
<target name="cdmwebweblogic.war" depends="clean,init,buildweblogic,buildweblogicwar,mqweblogicapp.war,bgw.build">
</target>
<target name="buildweblogic" depends="compile.all,copyweblogic.web,compile.jpf">
</target>
<target name="copyweblogic.web">
<copy todir="${build.dir}/WEB-INF/lib">
<fileset dir="web/WEB-INF/lib">
<include name="*.*"/>
<exclude name="weblogic.jar"/>
</fileset>
</copy>
<copy todir="${build.dir}/WEB-INF">
<fileset dir="web/WEB-INF">
<include name="*.*"/>
</fileset>
</copy>
<!--<move file="${build.dir}/WEB-INF/web_weblogic.xml" tofile="${build.dir}/WEB-INF/web.xml"/>-->
<echo>
web.xml:Replacing cdm-app-context.xml with cdm-app-context_weblogic.xml
</echo>
<replace file="${build.dir}/WEB-INF/web.xml" token="cdm-app-context.xml" value="cdm-app-context_weblogic.xml"/>
<copy todir="${build.dir}">
<fileset dir="web">
<include name="*.*"/>
</fileset>
</copy>
<copy todir="${build.dir}">
<fileset dir="web">
<include name="**/*.*"/>
<exclude name="src/**"/>
</fileset>
</copy>
<copy todir="${build.dir}/WEB-INF/classes">
<fileset dir="resource">
<include name="*.properties"/>
<exclude name="jndi.properties"/>
<exclude name="*.xml"/>
</fileset>
</copy>
<copy todir="${build.dir}/WEB-INF">
<fileset dir="resource/beans">
<include name="cdm*.xml"/>
</fileset>
</copy>
</target>
<target name="buildweblogicwar" depends="buildweblogic" description="Builds a exploded WAR Directory that can be deployed to Weblogic application container">
<echo message="[ * --- Creating Exploded WAR Directory for Deployment into Weblogic--- * ]"/>
<mkdir dir="${exploded.dir}"/>
<copy todir="${exploded.dir}">
<fileset dir="${build.dir}">
<include name="**/*.*"/>
</fileset>
</copy>
</target>
<!-- ============================= Above enclosed tasks are for Weblogic alone =================================== -->
<target name="usage" description="Print usage information for this build file">
<echo>
To Create the CDM web deployment WAR:ant cdmweb.war
The WAR gets created in dist directory.
Once the webapp is built, it's ready to deploy onto your application container.
</echo>
</target>
<target name="mqweblogicapp.war" depends="buildmqweblogicwar">
</target>
<target name="mqwebapp.war" depends="buildmqwar">
</target>
<target name="buildmq" depends="cleanmq,initmq,compile.mq,copy.mq">
<echo message="[ * --- Compiled compile.mq --- * ]"/>
</target>
<target name="initmq">
<mkdir dir="${mqapp.dir}/WEB-INF/classes"/>
</target>
<target name="cleanmq">
<delete dir="${mqapp.dir}"/>
</target>
<target name="copy.mq">
<mkdir dir="${mqapp.dir}/WEB-INF/lib"/>
<copy todir="${mqapp.dir}/WEB-INF/lib">
<fileset dir="web/WEB-INF/lib">
<include name="connector.jar"/>
<include name="jta.jar"/>
<include name="com.ibm.mq.jar"/>
<include name="com.ibm.mqjms.jar"/>
<include name="dhbcore.jar"/>
<include name="log4j-1.2.15.jar"/>
</fileset>
</copy>
<copy todir="${mqapp.dir}/WEB-INF/classes">
<fileset dir="resource">
<include name="mq.properties"/>
</fileset>
</copy>
<copy todir="${mqapp.dir}/WEB-INF">
<fileset dir="web/WEB-INF">
<include name="web_mq.xml"/>
</fileset>
</copy>
<move file="${mqapp.dir}/WEB-INF/web_mq.xml" tofile="${mqapp.dir}/WEB-INF/web.xml"/>
</target>
<target name="compile.mq">
<echo message="[ * --- Compiling mq related classes--- * ]"/>
<javac destdir="${mqapp.dir}/WEB-INF/classes" includes = "com/vzb/ions/common/mq/*.java" classpathref="app.classpath" debug="on" debuglevel="lines,source">
<src path="src"/>
</javac>
</target>
<target name="buildmqwar" depends="buildmq" description="Builds a compressed WAR file that can be deployed to Tomcat application container">
<echo message="[ * --- Creating MQ WAR file for Deployment into Tomcat--- * ]"/>
<mkdir dir="${dist.dir}"/>
<war destfile="${dist.dir}/MQWeb.war" webxml="${mqapp.dir}/WEB-INF/web.xml">
<fileset dir="${mqapp.dir}">
<exclude name="WEB-INF/web.xml"/>
</fileset>
</war>
</target>
<target name="buildmqweblogicwar" depends="buildmq" description="Builds a exploded WAR Directory that can be deployed to Weblogic application container">
<echo message="[ * --- Creating Exploded MQWeb.WAR Directory for Deployment into Weblogic--- * ]"/>
<mkdir dir="${explodedmqwebapp.dir}"/>
<copy todir="${explodedmqwebapp.dir}">
<fileset dir="${mqapp.dir}">
<include name="**/*.*"/>
</fileset>
</copy>
</target>
</project>
beehive-tools.xml
<apt srcdir="#{srcdir}"
destdir="#{destdir}"
gendir="#{tempdir}"
classpathref="_pageflow.build.classpath"
sourcepathref="#{sourcepathref}"
srcExtensions="*.jpf,*.jpfs,*.app,*.jsfb,*.java"
processorOptions="web.content.root=#{webcontentdir}"
debug="true"
nocompile="#{nocompile}"/>//This line i am getting error
<delete dir="#{tempdir}"/>
BUILD FAILED
C:\Spring Boot\Jagan Apps\vi_cdm\build.xml:145: The following error occurred while executing this line:
C:\Spring Boot\Jagan Apps\vi_cdm\resource\apache-beehive-1.0.2\ant\beehive-tools.xml:148: Error running apt compiler
I answered this in your other question : How to run ant apt task on java 1.8 version
Essentially apt doesn't exist in java8; only in 5-7. This is documented on ant's apt documentation page...
Just make sure that the jar file that is required for your custom annotation processor stuff is in the classpath; and javac will execute it appropriately.
<javac source="${javac.version}" target="${javac.version}" destdir="${classes.build.dir}" srcdir="${src.dir}" debug="on" debuglevel="source,lines">
<classpath>
<!-- make sure this has "my-annotation-processor.jar" -->
<path refid="main.classpath"/>
</classpath>
</javac>
Related
I am trying to configure the ANT for TEstNG but with problems
<project basedir="." default="build" name="Ant Play">
<property name="classes.dir" value="bin" />
<property name="report.dir" value="test-output" />
<path id="classpath">
<fileset dir=".">
<include name="**/*.jar"/>
</fileset>
<pathelement path="${basedir}\${classes.dir}"/>
</path>
<target name="init">
<mkdir dir="${classes.dir}"/>
<copy includeemptydirs="false" todir="${classes.dir}">
<fileset dir="src">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${classes.dir}"/>
</target>
<target depends="clean" name="cleanall"/>
<target depends="build-project" name="build"/>
<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}"/>
<javac debug="true" includeantruntime="false" destdir="${classes.dir}">
<src path="src"/>
<classpath refid="classpath"/>
</javac>
</target>
<target depends="build" name="runTests" description="Running tests" >
<echo>Running Tests...</echo>
<taskdef resource="testngtasks" classpathref="classpath"/>
<testng outputDir="${report.dir}"
haltonfailure="true"
useDefaultListeners="false"
listeners="org.uncommons.reportng.HTMLReporter"
classpathref="classpath">
<xmlfileset dir="${basedir}" includes="testng.xml"/>
<!--<classfileset dir="${classes.dir}" includes="**/*.class" />-->
</testng>
</target>
</project>
But it refuse to get classpath
I get ................../.../.../lib does not exist.
I do not have lib in my project at all
How to change the classpath? And which folder it should be?
Thanks!
I found the solution
Created manually lib folder>>>Copied to lib all needed Jars>>> added these jars to path
and it worked
I have a war file and a Tomcat server. I'd like to put the war file into the Tomcat server using AntInstaller and I want the server subsequently restarted.
Is it possible? Can anybody help me to do this?
You need to create user in tomcat-users.xml
<?xml version="1.0"?>
<tomcat-users>
<role rolename="dbadmin"/>
<role rolename="manager"/>
<user username="BruceP" password="bwperry" roles="dbadmin,manager"/>
<user username="JillH" password="jhayward" roles="manager"/>
</tomcat-users>
Create the build.properties file
appserver.home=c:\\apache-tomcat-7.0.19
appserver.lib=${appserver.home}/lib
deploy.path=${appserver.home}/webapps
tomcat.manager.url=http://www.localhost.com:8080/manager
tomcat.manager.username=username
tomcat.manager.password=secret
Create the build.xml file
<?xml version="1.0"?>
<project name="fax" basedir="." default="usage">
<property file="build.properties"/>
<property name="src.dir" value="src"/>
<property name="web.dir" value="war"/>
<property name="javadoc.dir" value="doc"/>
<property name="build.dir" value="${web.dir}/WEB-INF/classes"/>
<property name="name" value="fax"/>
<path id="master-classpath">
<fileset dir="${web.dir}/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<pathelement path="${build.dir}"/>
</path>
<target name="javadoc">
<javadoc packagenames="faxapp.*" sourcepath="${src.dir}"
destdir="doc" version="true" windowtitle="Fax Application">
<doctitle><![CDATA[<h1>= Fax Application
=</h1>]]></doctitle>
<bottom><![CDATA[Copyright © 2011. All
Rights Reserved.]]></bottom>
<group title="util packages" packages="faxapp.util.*"/>
<group title="web packages" packages="faxapp.web.*"/>
<group title="data packages"
packages="faxapp.entity.*:faxapp.dao.*"/>
</javadoc>
</target>
<target name="usage">
<echo message=""/>
<echo message="${name} build file"/>
<echo message="-----------------------------------"/>
<echo message=""/>
<echo message="Available targets are:"/>
<echo message=""/>
<echo message="deploy --> Deploy application
as directory"/>
<echo message="deploywar --> Deploy application
as a WAR file"/>
<echo message=""/>
</target>
<target name="build" description="Compile main
source tree java files">
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}" source="1.5"
target="1.5" debug="true"
deprecation="false" optimize="false" failonerror="true">
<src path="${src.dir}"/>
<classpath refid="master-classpath"/>
</javac>
</target>
<target name="deploy" depends="build"
description="Deploy application">
<copy todir="${deploy.path}/${name}"
preservelastmodified="true">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</copy>
</target>
<target name="deploywar" depends="build"
description="Deploy application as a WAR file">
<war destfile="${name}.war"
webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</war>
<copy todir="${deploy.path}" preservelastmodified="true">
<fileset dir=".">
<include name="*.war"/>
</fileset>
</copy>
</target>
<target name="clean" description="Clean output directories">
<delete>
<fileset dir="${build.dir}">
<include name="**/*.class"/>
</fileset>
</delete>
</target>
<!-- ============================================================ -->
<!-- Tomcat tasks -->
<!-- ============================================================ -->
<path id="catalina-ant-classpath">
<!-- We need the Catalina jars for Tomcat -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar"/>
</fileset>
</path>
<taskdef name="install"
classname="org.apache.catalina.ant.InstallTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="reload"
classname="org.apache.catalina.ant.ReloadTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="list"
classname="org.apache.catalina.ant.ListTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="start"
classname="org.apache.catalina.ant.StartTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="stop"
classname="org.apache.catalina.ant.StopTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<target name="reload" description="Reload application in Tomcat">
<reload url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
Ant tasks
InstallTask --Installs a web application. Class Name: org.apache.catalina.ant.InstallTask
ReloadTask -- Reload a web application. Class Name: org.apache.catalina.ant.ReloadTask
ListTask -- Lists all web applications. Class Name: org.apache.catalina.ant.ListTask
StartTask -- Starts a web application. Class Name: org.apache.catalina.ant.StartTask
StopTask -- Stops a web application. Class Name: org.apache.catalina.ant.StopTask
I am trying to use ant + ivy together.
This is what I have done so far. I have just the ant file build.xml, which I edited, to download ivy jar file.
<?xml version="1.0"?>
<project name="spring" basedir="." default="usage" xmlns:ivy="antlib:org.apache.ivy.ant" >
<property file="build.properties"/>
<property name="src.dir" value="src"/>
<property name="web.dir" value="war"/>
<property name="build.dir" value="${web.dir}/WEB-INF/classes"/>
<property name="name" value="ivy"/>
<path id="master-classpath">
<fileset dir="${web.dir}/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<!-- We need the servlet API classes: -->
<!-- * for Tomcat 5/6 use servlet-api.jar -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="servlet*.jar"/>
</fileset>
<pathelement path="${build.dir}"/>
</path>
<target name="usage">
<echo message=""/>
<echo message="${name} build file"/>
<echo message="-----------------------------------"/>
<echo message=""/>
<echo message="Available targets are:"/>
<echo message=""/>
<echo message="build --> Build the application"/>
<echo message="deploy --> Deploy application as directory"/>
<echo message="deploywar --> Deploy application as a WAR file"/>
<echo message="install --> Install application in Tomcat"/>
<echo message="reload --> Reload application in Tomcat"/>
<echo message="start --> Start Tomcat application"/>
<echo message="stop --> Stop Tomcat application"/>
<echo message="list --> List Tomcat applications"/>
<echo message=""/>
</target>
<target name="build" description="Compile main source tree java files">
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}" source="1.5" target="1.5" debug="true"
deprecation="false" optimize="false" failonerror="true" includeantruntime="false">
<src path="${src.dir}"/>
<classpath refid="master-classpath"/>
</javac>
</target>
<target name="deploy" depends="build" description="Deploy application">
<copy todir="${deploy.path}/${name}" preservelastmodified="true">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</copy>
</target>
<target name="deploywar" depends="build" description="Deploy application as a WAR file">
<war destfile="${name}.war"
webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</war>
<copy todir="${deploy.path}" preservelastmodified="true">
<fileset dir=".">
<include name="${name}.war"/>
</fileset>
</copy>
</target>
<target name="clean" description="Clean output directories">
<delete>
<fileset dir="${build.dir}">
<include name="**/*.class"/>
</fileset>
</delete>
</target>
<!-- ============================================================== -->
<!-- Tomcat tasks - remove these if you don't have Tomcat installed -->
<!-- ============================================================== -->
<path id="catalina-ant-classpath">
<!-- We need the Catalina jars for Tomcat -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar"/>
</fileset>
</path>
<taskdef name="install" classname="org.apache.catalina.ant.DeployTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="list" classname="org.apache.catalina.ant.ListTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<target name="install" description="Install application in Tomcat">
<install url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"
war="${name}"/>
</target>
<target name="reload" description="Reload application in Tomcat">
<reload url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="start" description="Start Tomcat application">
<start url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="stop" description="Stop Tomcat application">
<stop url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="list" description="List Tomcat applications">
<list url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"/>
</target>
<!-- End Tomcat tasks -->
<!-- Ivy settings start-->
<target name="-download-ivy" unless="skip.download">
<!-- download Ivy from web site so that it can be used even without any special installation -->
<echo message="installing ivy..."/>
<get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true"/>
</target>
<!-- Ivy settings end-->
</project>
This is my build.properties:
# Ant properties for building the springapp
appserver.home=C:/apache-tomcat-7.0.20
# for Tomcat 5 use $appserver.home}/server/lib
# for Tomcat 6 use $appserver.home}/lib
appserver.lib=C:/apache-tomcat-7.0.20/lib
deploy.path=C:/apache-tomcat-7.0.20/webapps
tomcat.manager.url=http://localhost:8080/manager
tomcat.manager.username=tomcat
tomcat.manager.password=s3cret
ivy.install.version=2.2.0
ivy.jar.file=${lib.build.dir}/ivy-${ivy.install.version}.jar
When I try to deploy my war file and -download-ivy with ant, I get following error in eclipse:
Buildfile: C:\Users\Jansu\workspace\HelloWorld\build.xml
build:
deploywar:
-download-ivy:
[echo] installing ivy...
[get] Getting: http://repo1.maven.org/maven2/org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar
[get] To: C:\Users\Jansu\workspace\HelloWorld\${lib.build.dir}\ivy-2.2.0.jar
[get] Error getting http://repo1.maven.org/maven2/org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar to C:\Users\Jansu\workspace\HelloWorld\${lib.build.dir}\ivy-2.2.0.jar
BUILD FAILED
C:\Users\Jansu\workspace\HelloWorld\build.xml:153: java.io.FileNotFoundException: C:\Users\Jansu\workspace\HelloWorld\${lib.build.dir}\ivy-2.2.0.jar (The system cannot find the path specified)
Total time: 1 second
What could be the problem? The address http://repo1.maven.org/maven2/org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar exists, I could download from there manually.
According to the log, the problem is that lib.build.dir definition is missing in your build.properties file. So in order to fix this problem, you should :
add the definition of lib.build.dir in your build.properties,
create this dir at the beginning of the -download-ivy target (<mkdir dir="${lib.build.dir}" />).
Buildfile: /.../build.xml
build:
buildtests:
tests:
BUILD FAILED
/.../build.xml:43: Problem: failed to create task or type junit
Cause: Could not load a dependent class org/apache/tools/ant/Task
It is not enough to have Ant's optional JARs
you need the JAR files that the optional tasks depend upon.
Ant's optional task dependencies are listed in the manual.
Action: Determine what extra JAR files are needed, and place them in one of:
-/Applications/eclipse/plugins/org.apache.ant_1.7.1.v20090120-1145/lib
-/Users/cjwalsh/.ant/lib
-a directory added on the command line with the -lib argument
Do not panic, this is a common problem.
The commonest cause is a missing JAR.
This is not a bug; it is a configuration problem
Total time: 512 milliseconds
... and I've checked all the recommended directories, and yet I still keep getting this build failure. The specific JAR 'ant.jar', which I've looked into, has the class 'Task', and it is in the '/Applications/eclipse/plugins/org.apache.ant_1.7.1.v20090120-1145/lib' directory. Do I need to manually add this classpath to my build.xml as well? Here is my build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="springapp" basedir="." default="build">
<property file="build.properties"></property>
<property name="src.dir" value="src"></property>
<property name="web.dir" value="war"></property>
<property name="build.dir" value="${web.dir}/WEB-INF/classes"></property>
<property name="name" value="springapp"></property>
<property name="test.dir" value="test"></property>
<path id="master-classpath">
<fileset dir="${web.dir}/WEB-INF/lib">
<include name="*.jar" />
</fileset>
<fileset dir="${appserver.lib}">
<include name="servlet*.jar"></include>
</fileset>
<pathelement path="${build.dir}"></pathelement>
</path>
<target name="build" description="Compile main source tree java files">
<mkdir dir="${build.dir}" />
<javac destdir="${build.dir}" source="1.5" target="1.5" debug="true" deprecation="false" optimize="false"
failonerror="true">
<src path="${src.dir}" />
<classpath refid="master-classpath" />
</javac>
</target>
<target name="buildtests" description="Compile test tree java files">
<mkdir dir="${build.dir}" />
<javac destdir="${build.dir}" source="1.5" target="1.5" debug="true"
deprecation="false" optimize="false" failonerror="true">
<src path="${test.dir}"></src>
<classpath refid="master-classpath"></classpath>
</javac>
</target>
<target name="tests" depends="build, buildtests" description="Run tests">
<junit printsummary="on" fork="false" haltonfailure="false" failureproperty="tests.failed"
showoutput="true">
<classpath refid="master-classpath"></classpath>
<formatter type="brief" usefile="false" />
<batchtest>
<fileset dir="${build.dir}">
<include name="**/*Tests.*" />
</fileset>
</batchtest>
</junit>
<fail if="tests.failed">
tests.failed=${tests.failed}
***********************************************************************
***********************************************************************
**** One or more tests failed! Check the output ... ***************
***********************************************************************
***********************************************************************
</fail>
</target>
<target name="deploy" depends="build" description="Deploy the application">
<copy todir="${deploy.path}/${name}" preservelastmodified="true">
<fileset dir="${web.dir}">
<include name="**/*.*" />
</fileset>
</copy>
</target>
<target name="deploywar" depends="build" description="Deploy application as WAR file">
<war destfile="${name}.war" webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${web.dir}">
<include name="**/*.*"></include>
</fileset>
</war>
<copy todir="${deploy.path}" preservelastmodified="true">
<fileset dir=".">
<include name="*.war"></include>
</fileset>
</copy>
</target>
<path id="catalina-ant-classpath">
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar"></include>
</fileset>
</path>
<taskdef name="install" classname="org.apache.catalina.ant.InstallTask">
<classpath refid="catalina-ant-classpath"></classpath>
</taskdef>
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
<classpath refid="catalina-ant-classpath"></classpath>
</taskdef>
<taskdef name="list" classname="org.apache.catalina.ant.ListTask">
<classpath refid="catalina-ant-classpath" />
</taskdef>
<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
<classpath refid="catalina-ant-classpath"></classpath>
</taskdef>
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
<classpath refid="catalina-ant-classpath"></classpath>
</taskdef>
<target name="install" description="Install application in Tomcat">
<install url="${tomcat.manager.url}" username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"
war="${name}" />
</target>
<target name="reload" description="Reload applicatio in Tomcat">
<reload url="${tomcat.manager.url}" username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}" />
</target>
<target name="start" description="Start tomcat application">
<start url="${tomcat.manager.url}" username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}" />
</target>
<target name="stop" description="Stop Tomcat application">
<stop url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}" />
</target>
<target name="list" description="List Tomcat applications">
<list url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}" />
</target>
</project>
Are you starting ant from within Eclipse?
Please check in the menu {Run | External Tools Configuration...} that the Classpath tab contains "Ant Home". After expanding, does it point to valid files?
Hey guys I've been trying all day to get an ant file to automatically build my project. The file (appended below) was on a web page I found and is pretty thorough.
My problem is that it works as long as I don't run the "clean" target. Once the I run the "clean" target the "test" target ceases to work. I get NoClassFound errors on all test classes. Even though it worked earlier.
I'm working on a Macbook (10.5.8) using the latest version of eclipse. This error occurs running the file from eclipse and from a terminal using Ant version 1.7.1
I modified the file slightly to adapt it to my file structure which is as follows:
src/
packageA.packageB/
ClassA.java
...
ClassN.java
unittests/
packageA.packageB/
AllClassTests.java
ClassATest.java
...
ClassNTest.java
lib/
junit-4.7.jar
The ant file is:
<project name="SampleJUnitTests" default="dist" basedir=".">
<description>
DataTypes Build File
</description>
<!-- set global properties for this build -->
<property name="project_name" value="DataTypes"/>
<property name="src" location="src"/>
<property name="build" location="bin"/>
<property name="dist" location="dist"/>
<property name="lib" location="lib"/>
<property name="reports" location="reports"/>
<property name="tests" location="unittests"/>
<property name="tmp" location="tmp_file"/>
<!-- the names of various distributable files -->
<property name="jar_name" value="${project_name}.jar"/>
<property name="war_name" value="${project_name}.war"/>
<!-- top level targets -->
<target name="compile" depends="init" description="compile the source code " >
<javac srcdir="${src}" destdir="${build}">
<classpath>
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javac>
</target>
<target name="dist" depends="compile" description="generate the distributable files " >
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<jar jarfile="${dist}/${jar_name}" basedir="${build}"/>
</target>
<target name="clean" description="clean up" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${dist}"/>
<delete dir="${reports}"/>
<delete dir="${tmp}"/>
</target>
<target name="run-tests" depends="compile" description="run your test suite" >
<junit printsummary="yes" haltonfailure="no" showoutput="yes" tempdir="${tmp}">
<classpath>
<pathelement path="${build}"/>
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
<batchtest fork="yes" todir="${reports}/raw/">
<formatter type="xml"/>
<fileset dir="${tests}">
<include name="**/*.java"/>
<exclude name="**/All*Tests.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name ="test" depends="run-tests">
<junitreport todir="${reports}">
<fileset dir="${reports}/raw/">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${reports}\html\"/>
</junitreport>
</target>
<target name ="run" depends="" description="if this project can be run, run it" >
</target>
<!-- supporting targets -->
<target name="init" description="initialize the build environment" >
<!-- Create the time stamp -->
<tstamp/>
<!-- Create directory structures -->
<mkdir dir="${build}"/>
<mkdir dir="${lib}"/>
<mkdir dir="${dist}/lib"/>
<mkdir dir="${reports}"/>
<mkdir dir="${reports}/raw/"/>
<mkdir dir="${reports}/html/"/>
<mkdir dir="${tmp}"/>
</target>
<target name="all" depends="clean, test">
</target>
I give up and hope that someone can shine a light on my problem.
Thanks a lot!
You haven't got any Ant target which builds the test classes. You could do this as part of the compile target if you wanted:
<target name="compile" depends="init" description="compile the source code " >
<javac srcdir="${src}" destdir="${build}">
<classpath>
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javac>
<javac srcdir="${tests}" destdir="${build}">
<classpath>
<pathelement path="${build}"/>
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javac>
</target>