You are on page 1of 12






Tutorial
       #   %

     
      &       "
           0 $. $* .  %)   
       0 1  /'2 34  53   

          

  
          #   '  "
          0 %  6   
 7    "
 

      


  

8

   0 %  6   
      
  
         
    0 .  6    

                 0 /  65$- 9
          
!  0 6)%   .     
               0 :'2   6     

  ! " 
  
   
             ()*  +  
 
          
 0 :'2   6     
    ""
   
    0 65-- ; :'2       
0 65-- ; :'2     
  
#  $
  0 1  :'2  :$2    7  6 
#               8

 " "  
      0 %  <  $     
  6 
                   

           
     
         ''  "
       
    #    0 1  6  --      7 
  $
  %
   & $     .   ' 8
' 
 ()' * +,   )-. 0 1  <    
   
$  
 / #   $  $    76$*+6$=+$+$    8
0 1  -6)5  >?    7     
   .  $  8
0   .      6  --
$
 7.  8

 
0 1  $   
0 1  @    
0 #
 .   

   ,,,

*      


    
           
       
 
1. Content
TRIVERA TECHNOLOGIES reserves the right not to be responsible for the topicality, completeness or quality of the
information provided. Liability claims regarding damage caused by the use of any information provided, including any
kind of information which is incomplete or incorrect, will therefore be rejected. Parts of the pages or the complete
publication including all information might be extended, changed or partly or completely deleted by the authors of
TRIVERA TECHNOLOGIES without separate announcements.

2. Referrals
TRIVERA TECHNOLOGIES is not responsible for any contents referred to from their presentation -unless TRIVERA
TECHNOLOGIES has full knowledge of illegal contents and would be able to prevent the readers from viewing those
pages. If any damage occurs by the use of information presented there, only the author of the respective pages might
be liable, not TRIVERA TECHNOLOGIES who has linked to these pages.

3. Copyright
TRIVERA TECHNOLOGIES intended not to use any copyrighted material for the publication or, if not possible, to
indicate the copyright of the respective object. The copyright for any material created by the authors of TRIVERA
TECHNOLOGIES is reserved. Any duplication or use of objects such as diagrams, texts in electronic form or printed
publications is not permitted without TRIVERA TECHNOLOGIES agreement in writing.

4. Legal validity of this disclaimer


This disclaimer is to be regarded as part of this presentation. If sections or individual terms of this statement are not
legal or correct, the content or validity of the other parts remain uninfluenced by this fact. This material is copyrighted
by TRIVERA TECHNOLOGIES. and shall not be reproduced, edited, or distributed, in hard copy or soft copy format,
without the express written consent of TRIVERA TECHNOLOGIES.

This material is copyrighted by TRIVERA TECHNOLOGIES. and shall not be reproduced, edited, or distributed, in hard
copy or soft copy format, without the express written consent of TRIVERA TECHNOLOGIES

For more information about Java or Enterprise Java courseware, please contact Trivera Technologies EMEAA. Our
courseware is available globally for license, instruction, customization and/or purchase.

Trivera Technologies LLC. Trivera Technologies EMEAA


135 Meeshaway Trail Delftechpark 26
Medford Lakes NJ08055 2628 XH Delft
USA The Netherlands

Copyright © 2007 Trivera Technologies. Java, Enterprise JavaBeans and all Java-based trademarks and logo
trademarks are registered trademarks of Sun Microsystems, Inc., in the United States and other countries. List of
Trademarks: IBM, the IBM logo, WebSphere, or registered trademarks of International Business Machines Corporation
in the United States, other countries, or both. Microsoft, Windows XP and Windows NT are registered trademarks of
Microsoft Corporation in the United States, other countries, or both. Other company, product, or service names may be
trademarks or service marks of others.
/ . .,# #  #      -'-.. ""     


 

. .   6 "    (        '    
' A  
B &++  +C

#      
          .,#         
       
.,#     
         .,#         
 =  
                .,#    7 &++  +8

-   
,
          
             

 A 
  
             
    
+      7
    
      8 $


      
  
 
   6          
   
 

   
        (
  
    
     
6          

-       "          


        
   
    
 
 "       
   
          
  
 A                
      

(
           
        
 

.,#   6 "    


                D   
      A  A       :'2   .,#      :'2 
    

     E  
   .,#  A
A    =  
     
     
    $   
   .,#   
  6          
   

      "
           



  . /
# A  
A              "  )      
build.xml

#    
     
   :'2     
          #
default                         
     7    8 # basedir      "    
    
   (   
                       .  
                 

%   F 5??G #  #      6  -  6 )    6 " 


    
 
   
  $ ' 
 (   / $        2  #
& ()'  ()'   
< $       
  (   )  '   %      / $       
   '   <  :*  <  ,#     
  '   %      / $   
         
       

  
    
   
4
/ . .,# #  #      -'-.. ""     

% 2 3 # ) 

<?xml version="1.0" encoding="ISO-8859-1"?>


<project name="Example" default="init" basedir=".">
...
</project>

  
<       
      .                 
<    .               
        
 A 
 <           A    

% 2 5 .  

<target name="compile">
...
</target>

.            #       depends   (  


  
        compile   .,#      init        
     
   #                         .,#
      


% 2 > .  

<target name="init">
<tstamp/>
</target>
<target name="compile" depends="init">
...
</target>

#  
       7  H"H                
  
 

  

  "
. .,#                 # .,#   
   
   
       

  =               .,#



 7 &++  +
+8 # 
       .,#  
7<ANT_HOME>/docs

-       #  


    
      
   
    

%   F 5??G #  #      6  -  6 )    6 " 


    
 
   
  $ ' 
 (   / $        2  #
& ()'  ()'   
< $       
  (   )  '   %      / $       
   '   <  :*  <  ,#     
  '   %      / $   
         
       

  
    
   
9
/ . .,# #  #      -'-.. ""     

% 2 4 -
   javac 7
 8 

<javac srcdir="../src"
destdir="../classes" >
<include name="**/*.java"/>
<exclude name="**/Test-.java"/>
</javac>

.,#           "      .,#              
      

<    6  --    


                
        
  A     .,#        
   

            

)     
.,#               
    .,# 
  taskdef 


% 2 9 -
  <  A 
.,# 

<taskdef name="wldeploy"
classname="weblogic.ant.taskdefs.management.WLDeploy">
<classpath path="${home.wls}/server/lib/weblogic.jar"/>
</taskdef>
<wldeploy action="deploy" source="${earFile}" name="${baseName}"
user="${wls.username}" password="${wls.password}"
verbose="true" adminurl="${wls.url}"
debug="true" upload="true"/>

# .*(        .,#       


   
    

.,#   
 

.


- 
    
                   7     
    " 8

(   A  " A    


                   
 A  A              

% 2 I      

<property name="ApplicationName" value="Sample"/>

                        


  
HJKH  HLH

%   F 5??G #  #      6  -  6 )    6 " 


    
 
   
  $ ' 
 (   / $        2  #
& ()'  ()'   
< $       
  (   )  '   %      / $       
   '   <  :*  <  ,#     
  '   %      / $   
         
       

  
    
   
I
/ . .,# #  #      -'-.. ""     

% 2 G /    

<echo>${ApplicationName}</echo>

*    
           

% 2 M /        

<javac srcdir="${dir.src}" destdir="${dir.classes}">

(                "               

% 2 N -       7global-build.properties8

dir.src=../src
dir.resources=../resources
dir.classes=../classes
dir.lib=../lib
spring.home=c:/spring2.0
spring.lib=${spring.home}/lib

, 

.       
                     
   

)        
              
 
    
  &

% 2 3? O           

<property file="../global-build.properties"/>

.,# 
   
     "    &

0  &            7.     basedir    project 


8
0  & #       
0   & # .,#           
0   
& # 
      7.     name    project 
8
0    &# 6             

*              #                     


7       8

%   F 5??G #  #      6  -  6 )    6 " 


    
 
   
  $ ' 
 (   / $        2  #
& ()'  ()'   
< $       
  (   )  '   %      / $       
   '   <  :*  <  ,#     
  '   %      / $   
         
       

  
    
   
G
/ . .,# #  #      -'-.. ""     

% 2 33 $     

<property name="javaVersionIs${ant.java.version}" value="1"/>

(  
                        <   6 
   6  $- I     
  

 #               
     
           6  $- I   

% 2 35   if        

<target name="compile" if="javaVersionIs1.6"/>

0   
#           .,#      
 

 "    
  
  
  7  
      A
 A8

% 2 3> O  .,#  

ant compile

<             7     default 
    project

8     

<   .,#                   build.xml .  
     
      -f 

% 2 34 O     .,# 

ant -f c:/mybuild/testbuild.xml

)   -projecthelp  .,#                   

<               



         #
           -projecthelp   

% 2 39      

ant -projecthelp

%   F 5??G #  #      6  -  6 )    6 " 


    
 
   
  $ ' 
 (   / $        2  #
& ()'  ()'   
< $       
  (   )  '   %      / $       
   '   <  :*  <  ,#     
  '   %      / $   
         
       

  
    
   
M
/ . .,# #  #      -'-.. ""     

% 2 3I     

Buildfile: build.xml
Main targets:
compile compile the Java classes
Default target: init

, 

'  (-A                  


  
 

# 1  / 
<  
   6     
    <         
   classpath 
   7  
 8  javac 


% 2 3G

<javac srcdir="${dir.src}" destdir="${dir.classes}">


<classpath>
<pathelement location="${dir.lib}"/>
<pathelement path="${dir.classes}/"/>
<pathelement path="${spring.lib}"/>
</classpath>
</javac>

@  
                     path 


% 2 3M

<path id="class.path">
<pathelement location="${dir.lib}"/>
<pathelement path="${dir.classes}/"/>
<pathelement path="${spring.lib}"/>
</path>

#            refid    element

% 2 3N

<javac srcdir="${dir.src}" destdir="${dir.classes}">


<classpath refid="class.path"/>
</javac>

    classpathref    javac 7   8 




%   F 5??G #  #      6  -  6 )    6 " 


    
 
   
  $ ' 
 (   / $        2  #
& ()'  ()'   
< $       
  (   )  '   %      / $       
   '   <  :*  <  ,#     
  '   %      / $   
         
       

  
    
   
N
/ . .,# #  #      -'-.. ""     

% 2 5?

<javac srcdir="${dir.src}" destdir="${dir.classes}"


classpathref="classpath">

#
%          7   8 .,#   '              
       

   
         if  unless      
 )   
        
         

, 

     
       if  unless  

0 if&  
      
               
0 unless&  
      
                 

% 2 53 if  unless    

<target name="compile" if="javaVersionIs1.6"/>


<target name="copy-war" unless="war.file.allready.copied"/>

<         
                   
 
        condition 


% 2 55 %
      condition 


<target name="compile" depends="version.check" if="correct.versions">


<echo>Java version is valid version 5 or 6 and properties file available</echo>
</target>
<target name="version.check">
<property name="javaVersionIs${ant.java.version}" value="1"/>
<condition property="correct.versions">
<and>
<or>
<isset property="javaVersionIs1.5"/>
<isset property="javaVersionIs1.6"/>
</or>
<available file="version.properties"/>
</and>
</condition>
</target>

.    
      
  
       
        &

%   F 5??G #  #      6  -  6 )    6 " 


    
 
   
  $ ' 
 (   / $        2  #
& ()'  ()'   
< $       
  (   )  '   %      / $       
   '   <  :*  <  ,#     
  '   %      / $   
         
       

  
    
   
3?
/ . .,# #  #      -'-.. ""     

and& #   .,   

or& #   O   

available:             

% 2 5> available: 




<available file="myfile.txt"

os& #          


     

% 2 54 os 


<os family="windows"

$       
   &   7      '  
< 8  7   '   $    
   '  
<   $+58
 7   . '  
8  7   / 
/"   
8   7  ,  , < 8 +5 7  $+58 
7 
@*A , $  E   "  
 #
8 N   '   <  N9  NM '-
 %-    '   <  ,#" 
   <  5??? :*
    P+    P+$  $+>N? +4??   $+4??  
    1'$
B &++  +
+%  #+    
C

equals&           !

% 2 59 equals 


<equals arg1="${ant.java.version}" arg2="1.6"


casesensitive="no" trim="yes"/>

isset& %       


      

% 2 5I isset 


<isset property="javaVersionIs1.6"/>

Recommended Resources:

www.triveratech.eu - Trivera Technologies EMEAA Website

http://ant.apache.org/ - Apache ANT website

%   F 5??G #  #      6  -  6 )    6 " 


    
 
   
  $ ' 
 (   / $        2  #
& ()'  ()'   
< $       
  (   )  '   %      / $       
   '   <  :*  <  ,#     
  '   %      / $   
         
       

  
    
   
33
For more information on TRIVERA Technologies EMEAA and our services,

Trivera Technologies EMEAA Trivera Technologies LLC.


Delftechpark 26 135 Meeshaway Trail
2628 XH Delft Medford Lakes NJ08055
The Netherlands USA
P+31 15 2600448 P+609-953-1515
F+31 15 2600428 F+270-514-8670
support_delft@triveratech.com info@triveratech.com
www.triveratech.eu www.triveratech.com

TRIVERA Technologies EMEAA Learning & Expertise Centers:


:: Europe >> The Netherlands, Delft
>> France, Sophia Antipolis
:: Middle East >> Egypt, Cairo
>> Turkey, Istanbul
:: Asia >> Malaysia, Kuala Lumpur
:: Africa >> South Africa, Cape Town

Executive Management EMEAA territory


Carine Y.R. Van de Walle Peter Schmitz
Managing Director Training Manager
Raphael Parree Canol Zeren
Curriculum Manager Large Account Manager
Jorden de Bouve
Sales Manager

You might also like