Navigation

Sunday, 2 March 2014

Some Advanced Ant Tasks (ANT Part-5)

In our last posts we have seen 

Sleep: If you want some gap between two tasks or want some pause then  this task is used to sleep the build process for a while. We can use milliseconds,seconds and hours also in aatribute. 

<sleep milliseconds="10"/> 

 Sql: To execute some query or after finishing a task you want to update some column in any table or want to fire any type of query then this task is used to execute SQL commands using Java JDBC connectivity. 
<sql 
 driver="jdbc driver name" 
 url="jdbc url" 
 userid="ui" 
 password="pass" 
 > 
insert 
insert into aots_users values (1, "aots1"); 
</sql> 

FTP: After creating any patch or folder you want to copy it on nay FTP to allow others to access it from another location then this task is used to ftp files to a ftp server 
 <ftp server="ftp.tcs.org" 
 remotedir="incoming" 
 userid="hemant12345" 
 password="hk@123" 
 depends="yes"> 
 <fileset dir="d:mypatch/currentpatch"/> 
 </ftp>

Sound: If you are running a build or any other task and do not want to sit and watch screen but you want to raise an alarm after finishing the task then you can use this task is to create sound during the build process for specific tasks. 
 <sound> 
 <success source="alert.wav"/> 
</sound>



Attrib: This task is used to set the properties of a file 
 <attrib file="username.properties" readonly="true" hidden="true"/> 

Sync:  To synchronize two folders we can use this task. This file will overwrite the data and also it will remove the files from the todir folder. 
<sync todir="Server"> 
 <fileset dir="local"/> 
</sync> 

LoadProperties: This task is used to load the contents of the properties file as ant properties.Means you do not need to rewrite the property file for ant in separately. 
The properties should be as key=value format 

 <loadproperties srcFile="file.properties"/>



You may also like:-

Using JConsole in java And creating memory dump by it


Heap analysis by Memory Analyzer (MAT) - Eclipse java


Main causes of Out-Of-Memory Errors in java


Five main types of Memory leaks in java


How to Reduce Garbage-Collection Pause Time?


4 Mains causes of Long Garbage Collection Pause?


How Application Performance get impacted by Garbage Collection?


Java Performance Tuning options Java heap


Why Memory leak in Java ?


What is a Memory Leak in java?


What is Garbage collector in java and how it works?


What is Garbage Collector Compaction in Java?


What are Java heap Young, Old and Permanent Generations?


What is difference between Web Server and Application Server ?


What is the maximum ram for 32 bits and 64 bits computer?


Some Amazing fact about memory (petabyte,exabyte,zettabyte) And How much data exists on the Web?

Saturday, 1 March 2014

Some Core Ant Tasks (ANT Part-4)

In our last post we have seen 
Now we will see some core task which can be performed by using ANT. Below are some of the most useful tasks .

GUnzip: This task is used to unzip and expand the tar files with gz
extensions. These files are unziped in the current folder.

<gunzip src="abc.tar.gz" dest="aaa.tar"/> 



Gzip: This task is used to zip the source files using GZip  algorithms. The source(src) and the destination (destfile or zipfiles) attributes are mandatory 
<gzip src="aaa.tar" destfile="abc.tar.gz"/> 


Copy: Copy a file to a new file or to a new folder. 
<copy file="copythis.txt" tofile="tothis.txt"/> 


Delete: This task is used to delete a folder , file and folder's entire sub directories. the properties used with delete are includes, includesfile, excludes, excludesfile or defaultexcludes to add or 
remove files from deleting. But all these tasks are depreciated and it’s recommended to use 
resource collections. 
 <delete> 
 <fileset dir="." includes="**/*.bak"/> 
</delete> 

Ear: This task is used to create ear file for Enterprise Deployment. 
 <ear destfile="build/myproject.ear" appxml="src/metadata/application.xml"> 
 <fileset dir="build" includes="*.jar,*.war"/> 
 </ear>



Echo: This task is used to echo message during the build process. We can write the message in the console or to a specified file. We have options to setup the level of logging 
as error, warning, info, verbose and debug. 
<echo file="mylogfile.lgo" level="error"> 
build filed!!!!!!!!!!!!!!!! 
</echo> 
<echo message="Hello copied folders "/>

Jar: This task is used to create jar file from a specific folder. The includes or excludes 
properties can be used to add or prevent few files adding in the jar file 
 <jar destfile="${dist}/lib/myfirstjar.jar" 
 basedir="${build}/classes" 
 includes="com/abc/**" 
 excludes="**/TestDemo.class" 
/>

Mail: This task is used to send mail using SMTP.
<mail mailhost="smtp.gmail.com" mailport="1076" subject="Testing Mail.."> 
 <from address="hemant2422@gmail.com"/> 
 <replyto address="hemant2422@gmail.com"/> 
 <to address="myreaders@gmail.com"/> 
 <message>type your message here </message
 <attachments
 <fileset dir="thisfolder"> 
 <include name="nameoffiletobeincluded"/> 
 </fileset> 
 </attachments
</mail

Move: This task is used to move or remane a file to a new file or to a folder 
<move file="abc.txt" tofile="xyz.txt"/> - this can be also used for renaming the file

Retry: If you want to repeate a task which is faild or want to run it sevral time when it fails then you have to use this 
<retry retrycount="5"> 
 <get src="myjar.jar" 
 dest="/com/build/myjar.jar" /> 
</retry> 



You may also like:-

Using JConsole in java And creating memory dump by it


Heap analysis by Memory Analyzer (MAT) - Eclipse java


Main causes of Out-Of-Memory Errors in java


Five main types of Memory leaks in java


How to Reduce Garbage-Collection Pause Time?


4 Mains causes of Long Garbage Collection Pause?


How Application Performance get impacted by Garbage Collection?


Java Performance Tuning options Java heap


Why Memory leak in Java ?


What is a Memory Leak in java?


What is Garbage collector in java and how it works?


What is Garbage Collector Compaction in Java?


What are Java heap Young, Old and Permanent Generations?


What is difference between Web Server and Application Server ?


What is the maximum ram for 32 bits and 64 bits computer?


Some Amazing fact about memory (petabyte,exabyte,zettabyte) And How much data exists on the Web?