How To Write Build.Xml Together With Operate Gear Upwardly Inward Apache Ant

How To Write Build.Xml Together With Operate Gear Upwardly Inward Apache Ant - Hallo sahabat BEST LEARNING JAVA, Pada Artikel yang anda baca kali ini dengan judul How To Write Build.Xml Together With Operate Gear Upwardly Inward Apache Ant, kami telah mempersiapkan artikel ini dengan baik untuk anda baca dan ambil informasi didalamnya. mudah-mudahan isi postingan Artikel ant tutorials, yang kami tulis ini dapat anda pahami. baiklah, selamat membaca.

Judul : How To Write Build.Xml Together With Operate Gear Upwardly Inward Apache Ant
link : How To Write Build.Xml Together With Operate Gear Upwardly Inward Apache Ant

Baca juga


How To Write Build.Xml Together With Operate Gear Upwardly Inward Apache Ant

This is the minute article on Apache ANT tutorials for beginners series As I bring e'er said that I similar the curt , clear in addition to concise tutorial which tells most few concept but inward a clear in addition to concise trend in addition to pose weight on fundamentals . I effort to adopt same theory piece writing my spider web log postal service piece writing my sense coupled alongside the concept which is of import for a software developer indicate of view.

Here I am answering approximately of the basic questions related to installing emmet , running emmet , creating a build.XML file , debugging build.xml inward the illustration of whatever lawsuit .

These questions bring been asked yesteryear my students piece instruction them JAVA in addition to related technology  inward my early on career.

How do I run ant?
To run you lot demand to download emmet in addition to install on your machine , in addition to thence create environs variable ANT_HOME in addition to include ANT_HOME/bin into your PATH similar below.

In Windows path=%path%;%ANT_HOME%/bin
In Linux    PATH =${PATH}:${ANT_Home}/bin


Now you lot tin opened upwards ascendency prompt in addition to type ant.

If you lot larn this output, agency emmet binaries is non inward your path

C:\Documents in addition to Settings>ant
'ant' is non recognized equally an internal or external command,operable programme or batch file.

Otherwise, you lot volition larn output which volition complain most construct file if it doesn’t exist.
  
    C:\Documents in addition to Settings>ant
    Buildfile: build.xml does non exist!
    Build failed



How do I write build.xml file?
Apache ANT tutorials for beginners serial How to write build.xml in addition to run construct inward Apache ANThere is a sample build.xml you lot only demand to know of import chemical factor e.g. projection ,target ,property in addition to occupation in addition to the social club inward which unlike target gets executed to start alongside basic construct procedure.

<?xml version="1.0"?>
<project name="test" default="all" basedir=".">
  <property name="src"   value="src"/>
  <property name="build" value="build"/>
  <property name="lib"   value="lib"/>

<target name="all" depends="clean, compile" description="Builds the whole project">
    <echo>Doing all</echo>
  </target>

<target name="Clean" description="Removes previous build">
    <delete verbose="true">
      <fileset dir="${build}"/>
    </delete>
  </target>

<target name="compile" depends="clean" description="compile whole project">
    <echo>compile ${ant.project.name} </echo>
    <copy file="${src}/splashscreen.jpeg" tofile="${build}/splashscreen.jpeg"/>
    <javac srcdir="${src}" destdir="${build}" includes="Test.java"/>
  </target>
</project>


lets run across what nosotros are doing hither :

<project name="test" default="all" basedir=".">


This describe defines our project; every construct file must bring this line. The projection refer is “test” defined yesteryear attribute “name”; default target is “all” piece running “ant” ascendency from ascendency prompt if nosotros don’t specify whatever target than emmet executed this default target.
basedir tells which is the exceed marker directory for creating the construct inward this illustration its electrical current directory (from where you lot run emmet command) , denoted yesteryear point “.” .

<property name="src"   value="src"/>

Here nosotros are declaring in addition to specifying belongings ,you tin tell variable every belongings has at to the lowest degree 2 attributes “name” in addition to “value” , though you lot tin define your all properties inward a split upwards properties file in addition to charge from at that spot equally good .<property> denotes ant’s belongings task, which do bring another attribute e.g. location to specify location of whatever properties file. I recommend that you lot e'er purpose belongings inward your build.xml instead of using difficult coded values inward target for directory refer etc , this volition laissez passer on you lot flexibility to modify the value anytime without changing at many places (in illustration you lot bring difficult coded it).

<target name="all" depends="clean, compile" description="Builds the whole project">

Here nosotros are defining a target since nosotros bring already called target “all” equally default inward projection tag, thence if nosotros don’t specify this target our construct volition neglect to tell “target non found”.

”name” attribute specified refer of target. “depends ontarget” says that earlier executing this target executed starting fourth dimension “clean” in addition to and thence “compile”
<echo>Doing all</echo>

This volition impress message inward console equally “doing all”


<target name="Clean" description="Removes previous build">

This is target “Clean” which volition delete sometime construct earlier edifice novel 1 , you lot tin bring equally many target you lot desire based on your need.

<delete verbose="true">
      <fileset dir="${build}"/>
</delete>


delete occupation or tag is used to delete directory, file etc, verbose=true makes it to impress message piece deleting inward cosole, <fileset> is an of import tag in addition to I recommend you lot to read inward especial somewhere inward emmet manual or may locomote I volition explicate inward especial sometime because it include “patternset” which supports designing matching of directory/files via its includes in addition to excludes attribute which is extremely useful to filter unwanted files (generally meta information files shape CVS, SVN etc).

Here nosotros are deleting construct directory yesteryear using value of belongings “build”, ${build} denotes value of whatever property.

<target name="compile" depends="clean" description="compile whole project">
    <echo>compile ${ant.project.name} </echo>
    <copy file="${src}/splashscreen.jpeg" tofile="${build}/splashscreen.jpeg"/>
    <javac srcdir="${src}" destdir="${build}" includes="Test.java"/>
  </target>
</project>


This is our compile target ,which compiles our code in addition to too copies resources e.g. images, nosotros tin too create jolt file using ant, which nosotros are non doing hither only for simplicity.

Imporant matter hither is belongings ${ant.project.name} this is builtin propety provided yesteryear emmet in addition to its’s value is refer of projection defined yesteryear attribute “name” of proejct tag.

<copy> tag is used to re-create files in addition to <javac> tag is used to compile coffee code .

How do I debug build.xml?
if you lot run across work on your construct or you lot are getting exception related to findiing files/directory or anything in addition to thence you lot would similar to know what’s going behind at that spot are 2 alternative , run emmet on verbose alternative , it volition impress lots of especial (I don’t prefer this) because of thence much unwanted information but tin locomote usefule inward certainly situation.

Second in addition to my preffered way is practiced sometime “echo” way . purpose echo occupation to impress values of properties, variables or printing uncomplicated message to banking venture check the locomote flow.

hither are approximately illustration of using echo

<echo>Doing all</echo>
<echo message="Now creating directory root "/>
<echo level="warning" message ="Active configuration (config.active property) is non laid - using default." />



How do I enforce emmet to purpose file other than build.xml?

Normally when you lot run emmet from whatever directory from ascendency prompt it volition hold off for file called build.xml inward electrical current directory; if it doesn’t honour the file it volition laissez passer on error. If you lot bring file named “custom_build.xml” you lot tin teach emmet to purpose this file for edifice your application yesteryear using alternative “-f” e.g. emmet –f custom_build.xml

Hope this would locomote useful allow me know if you lot bring whatever questions, uncertainty etc volition locomote happy to answer.

Further Learning
Maven Fundamentals yesteryear Bryan Hansen
Java Web Fundamentals
Apache Ant Fundamentals By Rusty Lowrey

Some other Tutorial you lot may like



Demikianlah Artikel How To Write Build.Xml Together With Operate Gear Upwardly Inward Apache Ant

Sekianlah artikel How To Write Build.Xml Together With Operate Gear Upwardly Inward Apache Ant kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.

Anda sekarang membaca artikel How To Write Build.Xml Together With Operate Gear Upwardly Inward Apache Ant dengan alamat link https://bestlearningjava.blogspot.com/2019/04/how-to-write-buildxml-together-with.html

Belum ada Komentar untuk "How To Write Build.Xml Together With Operate Gear Upwardly Inward Apache Ant"

Posting Komentar

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel