adding comment in .properties files

前端 未结 3 1115
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-02 07:01

By using following block of code in build.xml file


   

        
3条回答
  •  温柔的废话
    2021-02-02 07:46

    Writing the properties file with multiple comments is not supported. Why ?

    PropertyFile.java

    public class PropertyFile extends Task {
    
        /* ========================================================================
         *
         * Instance variables.
         */
    
        // Use this to prepend a message to the properties file
        private String              comment;
    
        private Properties          properties;
    

    The ant property file task is backed by a java.util.Properties class which stores comments using the store() method. Only one comment is taken from the task and that is passed on to the Properties class to save into the file.

    The way to get around this is to write your own task that is backed by commons properties instead of java.util.Properties. The commons properties file is backed by a property layout which allows settings comments for individual keys in the properties file. Save the properties file with the save() method and modify the new task to accept multiple comments through elements.

提交回复
热议问题