Skip to main content

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?

Popular posts from this blog

What are Java heap Young, Old and Permanent Generations?

The Java heap is dived into two parts i.e. Young generation and old generation. Young generationYoung generation  memory is 40% of Maximum Java Heap. It consists of two parts, Eden space and Survivor Space. Eden SpaceInitially objects are created in this  Part of Java Heap , here most objects die and quickly are cleaned up by the minor Garbage Collectors (It only runs in young generation and its frequency is high in compared to major garbage collector). Usually any new objects created inside a Java Method go into Eden space and the objects space is reclaimed once the method execution completes. Whereas the Instance Variables of a Class usually lives longer until the Object based on that class gets destroyed. When Eden fills up it causes a minor collection, in which some surviving objects are moved to Survivor Space or an older generation. Survivor Space  The pool containing objects that have survived the garbage collection of the Eden space The parameter Survivor Ratio can be used to tune…

Compression of HttpServletRequest and HttpServletResponse by gzip encoding

Description 
This filter is on HTTP headers in a HttpServletRequest, compress data written to the HttpServletResponse, or decompress data read from the request. When supported by the client browser, this can potentially greatly reduce the number of bytes written across the network from and to the client. As a Filter, this class can also be easily added to any J2EE 1.3+ web application.





Installation

1).Add the pjl-comp-filter-XX.jar file containing CompressingFilter to your web application's WEB-INF/lib directory.

2).Add the following entries to your web.xml deployment descriptor:

 <filter>
  <filter-name>CompressingFilter</filter-name>
  <filter-class>com.planetj.servlet.filter.compression.CompressingFilter</filter-class>
 </filter>

 <filter-mapping>
  <filter-name>CompressingFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>

The below data is of my application where i tested this compression technique…

Why Memory leak in Java ?

Memory leaks is a common error in programming, especially when using languages that have no built-in automatic garbage collection, such as C and C++.  In these type of programming languages when you need memory then you have to allocate the memory from OS and when your task completed then you have to release the memory manually. Means developer is only responsible for memory management and it depends on once programming . But languages like java  has there own automatic memory management. Java Virtual Machine periodically checks which objects in memory are still being used and which are not. Unused objects are removed from the memory  and the memory  is  reused again. This process is called garbage collection and the corresponding piece of JVM is called Garbage Collector, or GC.
So memory management in java is fully depended on garbage collector. But Garbage Collector will run according to it s algorithms used and developer can only request Garbage Collector . But is not necessary that …