Java 2EE and XML Development

Скачать в pdf «Java 2EE and XML Development»


<mkdir dir=»${build.dir}»/>


</target>



.»</echo>



Compiles


target



<target name=»compile» depends=»init, prepare.build.dir»> <echo>Running «compile» target…»</echo>


<javac srcdir=»${src.dir}» destdir=»${build.dir}»


classpathref=»project.class.path» debug=»on» /> <echo>Built ${project.name}…</echo>


</target>    CLASSPATH f


reference


<target name=»run» depends=»compile»>


<echo>Running «run» target…»</echo>


<java classname=»MessagePrinter»


classpathref=»project.class.path» fork=»yes»> <sysproperty key=»message» value=»Hello, world!»/>


<arg value=»message.txt»/>


</java>


</target>



e



This target invokes the JVM on the class MessagePrinter



<target name=»build.task» depends=»compile»> <echo>Running «build.task» target…»</echo> <jar jarfile=»${ant.home}/lib/myTask.jar» basedir=»${build.dir}» excludes=»**/MessagePrinter.class,


**/BuildResultPrinter.class»


/>


</target>



<target name=»run.task» depends=»compile»>


<echo>Running «run.task» target…»</echo>


<mytask message=»Hello from my task!»


filemessageFromTask.txt«/> g Custom task call


</target>



<target name=»build.listener» depends=»compile»> <echo>Running «build.listener» target…»</echo> <jar jarfile=»${ant.home}/lib/myListener.jar» basedir=»${build.dir}» excludes=»**/MessagePrinter*.class»


/>


</target>



</project>


О This root element of the build file defines the project name and base directory from which all other paths in the file will be built. The default=run attribute specifies that the target named run within the project will be invoked by default if no other target is specified on the command line.


e This is a task definition for the custom task we build later, in section C.3. As we will see, there are two ways to make your custom task classes available within an Ant project.


d These are the project target definitions. The depends attribute lists other targets that should be evaluated before this one, allowing you to build a dependency tree among targets. For example, if you invoke Ant to run the compile task,


prompt> ant compile

Скачать в pdf «Java 2EE and XML Development»