How to use wildcard in Ant's Available command

后端 未结 3 1236
南方客
南方客 2020-12-17 14:16

I\'m using an Ant build script to collate my Eclipse-based application for distribution.

One step of the build is to check that the correct libraries are present in

3条回答
  •  醉梦人生
    2020-12-17 14:55

    The pathconvert task is probably the preferred way to go in most cases. But it creates a little problem when the directory tree is very large and one uses the echoproperties task. With a very large directory tree, the string generated by pathconvert can be huge. Then echoproperties sprays the huge string, making the output more difficult to work with. I use a macrodef on Linux that creates a property set to "1" if there are files in the directory:

    
        
        
        
        
            
                
                
            
        
    
    
    
        
        
        
    
        
    
    

    Executing the "test" target will generate the following echoproperties line if there are files in the ./target_dir/ directory:

    [echoproperties] files.exist=1
    

    What "test" does: It generates a temporary filename, ${temp.file}, that can later be used as a property file. It then executes the macrodef, which calls the shell to check the contents of the dirPath directory. If there are any files or directories in dirPath, it assigns the propertyName property a value of 1 in the temporary file. It then reads the file and sets the property given in the file. If the file is empty, no property is defined.

    Note that the temporary file could be reused for subsequent calls of the macrodef if desired. On the other hand, of course, once a property is set, it is immutable.

提交回复
热议问题