How to include ant-contrib.jar dynamically in Ant

后端 未结 2 1762
一向
一向 2020-11-29 12:53

I\'m looking for a way to include a .jar from within an Ant file so I can use it straight away and call its methods in my targets. In my case it\'s ant-contrib-1.0b3.j

2条回答
  •  Happy的楠姐
    2020-11-29 13:00

    The best solution is to integrate the apache ivy dependency manager. Ivy can be used to manage all your build classpaths Maven-style!

    Example

    ivy.xml

    This file describes your project's 3rd party dependencies. Ivy uses configurations to logically group files together. In your case note the special "build" configuration uses to configure ANT tasks needed by the build:

    
        
    
        
            
            
            
            
        
    
        
            
            
    
            
            
    
            
            
    
            
            
        
    
    
    

    Note:

    • Dependencies are retrieved by default from Maven Central that now hosts approx 90% of open source jars

    build.xml

    
    
        
            
            
        
    
        
            
    
            
    
            
            
            
            
        
    
        
            
        
    
        
            
    
            
                
                    Letter @{letter}
                
            
        
    
        
            
        
    
        
            
        
    
    
    

    Notes:

    • There is a special "bootstrap" target used to kick-start a new installation. Unfortunately ivy is not distributed with core ANT
    • The cachepath ivy task is used to create ANT paths containing the jars downloaded and cached by ivy.
    • The ivy report task is very useful to understand the transitive dependencies of your 3rd party libraries.
    • antcontrib is now distributed as an ANT lib explaining the weird namespacing stuff.

提交回复
热议问题