This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 56127
Collapse All | Expand All

(-)src/org/apache/tools/ant/module/api/support/ActionUtils.java (-8 / +26 lines)
Lines 190-196 Link Here
190
        }
190
        }
191
        return (FileObject[])files.toArray(new FileObject[files.size()]);
191
        return (FileObject[])files.toArray(new FileObject[files.size()]);
192
    }
192
    }
193
193
    
194
    /**
194
    /**
195
     * Create an "includes" string such as is accepted by many Ant commands
195
     * Create an "includes" string such as is accepted by many Ant commands
196
     * as well as filesets.
196
     * as well as filesets.
Lines 203-208 Link Here
203
     * @throws IllegalArgumentException in case some file is not in the directory
203
     * @throws IllegalArgumentException in case some file is not in the directory
204
     */
204
     */
205
    public static String antIncludesList(FileObject[] files, FileObject dir) throws IllegalArgumentException {
205
    public static String antIncludesList(FileObject[] files, FileObject dir) throws IllegalArgumentException {
206
        return antIncludesList (files, dir, true);
207
    }
208
209
    /**
210
     * Create an "includes" string such as is accepted by many Ant commands
211
     * as well as filesets.
212
     * <samp>/</samp> is always used as the separator in the relative paths.
213
     * @param files a list of files or folders to include, in the case of folder
214
     * the generated include contains recursively all files under the folder.
215
     * @param dir a directory in which all the files reside
216
     * @param recursive if true the include list for directory is recursive
217
     * @return a comma-separated list of relative file paths suitable for use by Ant
218
     *         (the empty string in case there are no files)
219
     * @throws IllegalArgumentException in case some file is not in the directory
220
     */
221
    public static String antIncludesList(FileObject[] files, FileObject dir, boolean recursive) throws IllegalArgumentException {
206
        if (!dir.isFolder()) {
222
        if (!dir.isFolder()) {
207
            throw new IllegalArgumentException("Not a folder: " + dir); // NOI18N
223
            throw new IllegalArgumentException("Not a folder: " + dir); // NOI18N
208
        }
224
        }
Lines 215-228 Link Here
215
            if (i > 0) {
231
            if (i > 0) {
216
                b.append(',');
232
                b.append(',');
217
            }            
233
            }            
218
            if (path.length() > 0) {
234
            b.append(path);
219
                b.append(path);
235
            if (files[i].isFolder()) {
220
                if (files[i].isFolder()) {
221
                    b.append('/');
222
                }
223
            } else {
224
                // files[i] == dir, cannot use "/".
236
                // files[i] == dir, cannot use "/".
225
                b.append("**");
237
                if (path.length() > 0) {                    
238
                    b.append('/');  //NOI18N
239
                }
240
                b.append('*');  //NOI18N
241
                if (recursive) {
242
                    b.append('*'); //NOI18N
243
                }
226
            }
244
            }
227
        }
245
        }
228
        return b.toString();
246
        return b.toString();
(-)test/unit/src/org/apache/tools/ant/module/api/support/ActionUtilsTest.java (-5 / +11 lines)
Lines 103-113 Link Here
103
    public void testAntIncludesList() throws Exception {
103
    public void testAntIncludesList() throws Exception {
104
        assertEquals("2 includes", "f1.data,sub/f3.data", ActionUtils.antIncludesList(new FileObject[] {f1, f3}, dir));
104
        assertEquals("2 includes", "f1.data,sub/f3.data", ActionUtils.antIncludesList(new FileObject[] {f1, f3}, dir));
105
        assertEquals("1 include", "f1.data", ActionUtils.antIncludesList(new FileObject[] {f1}, dir));
105
        assertEquals("1 include", "f1.data", ActionUtils.antIncludesList(new FileObject[] {f1}, dir));
106
        assertEquals("no includes", "", ActionUtils.antIncludesList(new FileObject[0], dir));
106
        assertEquals("no includes", "", ActionUtils.antIncludesList(new FileObject[0], dir));                
107
        assertEquals("1 folder include","sub/",ActionUtils.antIncludesList(new FileObject[]{subdir}, dir));
107
        assertEquals("1 folder include","sub/**",ActionUtils.antIncludesList(new FileObject[]{subdir}, dir, true));
108
        assertEquals("root folder include","**",ActionUtils.antIncludesList(new FileObject[]{dir}, dir));        
108
        assertEquals("root folder include","**",ActionUtils.antIncludesList(new FileObject[]{dir}, dir, true));        
109
        assertEquals("2 folder includes","sub/,subdir2/sub/",ActionUtils.antIncludesList(new FileObject[]{subdir, subsubdir}, dir));
109
        assertEquals("2 folder includes","sub/**,subdir2/sub/**",ActionUtils.antIncludesList(new FileObject[]{subdir, subsubdir}, dir, true));
110
        assertEquals("mixed files and folder includes","sub/f3.data,subdir2/sub/",ActionUtils.antIncludesList(new FileObject[]{f3, subsubdir}, dir));
110
        assertEquals("mixed files and folder includes","sub/f3.data,subdir2/sub/**",ActionUtils.antIncludesList(new FileObject[]{f3, subsubdir}, dir, true));        
111
        assertEquals("1 folder include","sub/*",ActionUtils.antIncludesList(new FileObject[]{subdir}, dir, false));
112
        assertEquals("root folder include","*",ActionUtils.antIncludesList(new FileObject[]{dir}, dir, false));        
113
        assertEquals("2 folder includes","sub/*,subdir2/sub/*",ActionUtils.antIncludesList(new FileObject[]{subdir, subsubdir}, dir, false));
114
        assertEquals("mixed files and folder includes","sub/f3.data,subdir2/sub/*",ActionUtils.antIncludesList(new FileObject[]{f3, subsubdir}, dir, false));
115
        assertEquals("antIncludeList(FileObject[], FileObject) delegates to antIncludeList(FileObject[], FileObject, true)",ActionUtils.antIncludesList(new FileObject[]{subdir}, dir) ,ActionUtils.antIncludesList(new FileObject[]{subdir}, dir, true));
116
        assertEquals("antIncludeList(FileObject[], FileObject) delegates to antIncludeList(FileObject[], FileObject, true)",ActionUtils.antIncludesList(new FileObject[]{dir}, dir),ActionUtils.antIncludesList(new FileObject[]{dir}, dir, true));        
111
    }
117
    }
112
    
118
    
113
    public void testRegexpMapFiles() throws Exception {
119
    public void testRegexpMapFiles() throws Exception {

Return to bug 56127