设为首页 收藏本站
查看: 883|回复: 0

[经验分享] Note of Apache Ant

[复制链接]
YunVN网友  发表于 2018-11-27 10:16:51 |阅读模式
Using Ant

Projects
A project has three attributes:
name
default
basedir
The base directory from which all path calculations are done. This attribute might be overridden by setting the "basedir" property beforehand. When this is done, it must be omitted in the project tag. If neither the attribute nor the property have been set, the parent directory of the buildfile will be used.

Each project defines one or more targets. A target is a set of tasks you want to be executed. When starting Ant, you can select which target(s) you want to have executed. When no target is given, the project's default is used.

Targets
A target has the following attributes:
name
depends
a comma-separated list of names of targets on which this target depends.
if
the name of the property that must be set in order for this target to execute.
unless
the name of the property that must not be set in order for this target to execute.
description
a short description of this target's function.


A target can depend on other targets.
eg,





Explain:
Suppose we want to execute target D. From its depends attribute, you might think that first target C, then B and then A is executed. Wrong! C depends on B, and B depends on A, so first A is executed, then B, then C, and finally D.

Note: Ant will only check whether the property has been set, the value doesn't matter. A property set to the empty string is still an existing property.
eg





In the first example, if the module-A-present property is set (to any value, e.g. false), the target will be run. In the second example, if the module-A-present property is set (again, to any value), the target will not be run.

If you want to check multiple conditions, you can use a dependend target for computing the result for the check:

        Files foo.txt and bar.txt are present.



        
               
                        
                        
               
        






Tasks
A task is a piece of code that can be executed.

Tasks have a common structure:





Properties
A project can have a set of properties.
Properties may be used in the value of task attributes. This is done by placing the property name between "${" and "}" in the attribute value. For example, if there is a "builddir" property with the value "build", then this could be used in an attribute like this: ${builddir}/classes. This is resolved at run-time as build/classes.


In the event you should need to include this construct literally (i.e. without property substitutions), simply "escape" the '$' character by doubling it. To continue the previous example: $${builddir}=${builddir}

  will echo this message:
${builddir}=build/classes



Example Buildfile

        
                simple example build file
        
     
   
   
   

   
         
        
         
        
   

   
         
        
   

   
         
        

         
        
   

   
         
        
        
   







Path-like Structures
one or more Resource Collections can be specified as nested elements (these must consist of file-type resources only). Additionally, it should be noted that although resource collections are processed in the order encountered, certain resource collection types such as fileset, dirset and files are undefined in terms of order.

            
            
               
            
            
            
               
               
            
            
        



This builds a path that holds the value of ${classpath}, followed by all jar files in the lib directory, the classes directory, all directories named classes under the apps subdirectory of ${build.dir}, except those that have the text Test in their name, and the files specified in the referenced FileList.

Note:
Fileset
A FileSet is a group of files. These files can be found in a directory tree starting in a base directory and are matched by patterns taken from a number of PatternSets and Selectors.




A path-like structure can include a reference to another path-like structure (a path being itself a resource collection) via nested elements:

            
            
               
            
            
        

        
            
            
        



The shortcuts previously mentioned for are also valid for .For example:

            
        


can be written as:






Typic Builder.xml of JSF


         
        

         
        
        
        
        

         
        
               
               
               
               
               
               
               
               
               
               
               
        

         
        


         
        
               
        

         
        
               
                        
                        
                                
                                
                                
                        
                        
               
        

         
        
               
                        
               
        

         
        
            
            
        

         
        
        

         
        
            
            
               
               
               
            

        

        
            
            
            
        









运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-640180-1-1.html 上篇帖子: rhel6 apache的安装 下篇帖子: 以ab来测试apache的性能
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表