Can I make the Ant copy task OS-specific?

后端 未结 6 1704
醉梦人生
醉梦人生 2021-02-07 05:03

I have an Ant script that performs a copy operation using the \'copy\' task. It was written for Windows, and has a hardcoded C:\\ path as the \'todir\' argument. I see the \'exe

6条回答
  •  广开言路
    2021-02-07 05:19

    The previously posted suggestions of an OS specific variable will work, but many times you can simply omit the "C:" prefix and use forward slashes (Unix style) file paths and it will work on both Windows and Unix systems.

    So, if you want to copy files to "C:/tmp" on Windows and "/tmp" on Unix, you could use something like:

    
             
                 
             
    
    

    If you do want/need to set a conditional path based on OS, it can be simplified as:

        
            
        
        
                 
                     
                 
        
    

提交回复
热议问题