Java Code Examples for org.apache.tools.ant.types.FileSet#setExcludes()
The following examples show how to use
org.apache.tools.ant.types.FileSet#setExcludes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testWithRootExclude() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); fs.setIncludes("**/build.xml"); fs.setExcludes("E2/**"); buildlist.addFileset(fs); buildlist.setRoot("C"); buildlist.setExcludeRoot(true); buildlist.setOnMissingDescriptor("skip"); String[] files = getFiles(buildlist); assertEquals(1, files.length); // A, D and C should be filtered out assertListOfFiles("test/buildlist/", new String[] {"B"}, files); }
Example 2
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testWithModuleWithSameNameAndDifferentOrg() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); fs.setIncludes("**/build.xml"); fs.setExcludes("F/build.xml,G/build.xml"); buildlist.addFileset(fs); buildlist.setOnMissingDescriptor("skip"); String[] files = getFiles(buildlist); assertEquals(6, files.length); assertListOfFiles("test/buildlist/", new String[] {"B", "C", "A", "D"}, files); // the order of E and E2 is undefined List<URI> other = new ArrayList<>(); other.add(new File(files[4]).getAbsoluteFile().toURI()); other.add(new File(files[5]).getAbsoluteFile().toURI()); Collections.sort(other); assertEquals(new File("test/buildlist/E/build.xml").getAbsoluteFile().toURI(), other.get(0)); assertEquals(new File("test/buildlist/E2/build.xml").getAbsoluteFile().toURI(), other.get(1)); }
Example 3
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testOnMissingDescriptor2() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); fs.setIncludes("**/build.xml"); fs.setExcludes("E2/build.xml,F/build.xml,G/build.xml"); buildlist.addFileset(fs); buildlist.setOnMissingDescriptor("skip"); // IVY-805: new String instance String[] files = getFiles(buildlist); assertEquals(5, files.length); assertListOfFiles("test/buildlist/", new String[] {"B", "C", "A", "D", "E"}, files); }
Example 4
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testOnMissingDescriptor() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); fs.setIncludes("**/build.xml"); fs.setExcludes("E2/build.xml,F/build.xml,G/build.xml"); buildlist.addFileset(fs); buildlist.setOnMissingDescriptor("tail"); // IVY-805: new String instance String[] files = getFiles(buildlist); assertEquals(6, files.length); assertListOfFiles("test/buildlist/", new String[] {"B", "C", "A", "D", "E", "H"}, files); }
Example 5
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testRestartFrom() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); fs.setIncludes("**/build.xml"); fs.setExcludes("E2/build.xml,F/build.xml,G/build.xml"); buildlist.addFileset(fs); buildlist.setOnMissingDescriptor("skip"); buildlist.setRestartFrom("C"); String[] files = getFiles(buildlist); assertEquals(4, files.length); assertListOfFiles("test/buildlist/", new String[] {"C", "A", "D", "E"}, files); }
Example 6
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testWithLeafAndOnlyDirectDep() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); fs.setIncludes("**/build.xml"); fs.setExcludes("E2/**"); buildlist.addFileset(fs); buildlist.setOnMissingDescriptor("skip"); buildlist.setLeaf("C"); buildlist.setOnlydirectdep(true); String[] files = getFiles(buildlist); assertEquals(2, files.length); // We must have only A and C assertListOfFiles("test/buildlist/", new String[] {"C", "A"}, files); }
Example 7
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testWithLeafExclude() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); fs.setIncludes("**/build.xml"); fs.setExcludes("E2/**"); buildlist.addFileset(fs); buildlist.setLeaf("C"); buildlist.setExcludeLeaf(true); buildlist.setOnMissingDescriptor("skip"); String[] files = getFiles(buildlist); assertEquals(2, files.length); // B and C should be filtered out assertListOfFiles("test/buildlist/", new String[] {"A", "D"}, files); }
Example 8
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testWithTwoLeafs() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); fs.setIncludes("**/build.xml"); fs.setExcludes("E2/**"); buildlist.addFileset(fs); buildlist.setLeaf("C,E"); buildlist.setOnMissingDescriptor("skip"); String[] files = getFiles(buildlist); assertEquals(4, files.length); // B should be filtered out assertListOfFiles("test/buildlist/", new String[] {"C", "A", "D", "E"}, files); }
Example 9
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testWithLeaf() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); fs.setIncludes("**/build.xml"); fs.setExcludes("E2/**"); buildlist.addFileset(fs); buildlist.setLeaf("C"); buildlist.setOnMissingDescriptor("skip"); String[] files = getFiles(buildlist); assertEquals(3, files.length); // B should be filtered out assertListOfFiles("test/buildlist/", new String[] {"C", "A", "D"}, files); }
Example 10
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testWithRootAndOnlyDirectDep() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); fs.setIncludes("**/build.xml"); fs.setExcludes("E2/**"); buildlist.addFileset(fs); buildlist.setRoot("A"); buildlist.setOnlydirectdep(true); buildlist.setOnMissingDescriptor("skip"); String[] files = getFiles(buildlist); assertEquals(2, files.length); // We should have only A and C assertListOfFiles("test/buildlist/", new String[] {"C", "A"}, files); }
Example 11
Source File: FileFinder.java From warnings-ng-plugin with MIT License | 6 votes |
/** * Returns an array with the file names of the specified file pattern that have been found in the workspace. * * @param workspace * root directory of the workspace * * @return the file names of all found files */ public String[] find(final File workspace) { try { FileSet fileSet = new FileSet(); Project antProject = new Project(); fileSet.setProject(antProject); fileSet.setDir(workspace); fileSet.setIncludes(includesPattern); TypeSelector selector = new TypeSelector(); FileType fileType = new FileType(); fileType.setValue(FileType.FILE); selector.setType(fileType); fileSet.addType(selector); if (StringUtils.isNotBlank(excludesPattern)) { fileSet.setExcludes(excludesPattern); } fileSet.setFollowSymlinks(followSymlinks); return fileSet.getDirectoryScanner(antProject).getIncludedFiles(); } catch (BuildException ignored) { return new String[0]; // as fallback do not return any file } }
Example 12
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testWithTwoRoots() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); fs.setIncludes("**/build.xml"); fs.setExcludes("E2/**"); buildlist.addFileset(fs); buildlist.setRoot("C,E"); buildlist.setOnMissingDescriptor("skip"); String[] files = getFiles(buildlist); assertEquals(3, files.length); // A and D should be filtered out assertListOfFiles("test/buildlist/", new String[] {"B", "C", "E"}, files); }
Example 13
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testWithRoot() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); fs.setIncludes("**/build.xml"); fs.setExcludes("E2/**"); buildlist.addFileset(fs); buildlist.setRoot("C"); buildlist.setOnMissingDescriptor("skip"); String[] files = getFiles(buildlist); assertEquals(2, files.length); // A and D should be filtered out assertListOfFiles("test/buildlist/", new String[] {"B", "C"}, files); }
Example 14
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testReverse() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); fs.setIncludes("**/build.xml"); fs.setExcludes("E2/build.xml,F/build.xml,G/build.xml"); buildlist.addFileset(fs); buildlist.setReverse(true); buildlist.setOnMissingDescriptor("skip"); String[] files = getFiles(buildlist); assertEquals(5, files.length); assertListOfFiles("test/buildlist/", new String[] {"E", "D", "A", "C", "B"}, files); }
Example 15
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testSimple() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); fs.setIncludes("**/build.xml"); fs.setExcludes("E2/build.xml,F/build.xml,G/build.xml"); buildlist.addFileset(fs); buildlist.setOnMissingDescriptor("skip"); String[] files = getFiles(buildlist); assertEquals(5, files.length); assertListOfFiles("test/buildlist/", new String[] {"B", "C", "A", "D", "E"}, files); }
Example 16
Source File: Zip.java From Export with Apache License 2.0 | 6 votes |
/** * ʹ��zipѹ���ļ� * * @param source * ��Ҫѹ�����ļ� * @param target * ѹ�����ļ��Ĵ��·�� * @param delflag * ѹ�����Ƿ�ɾ��Դ�ļ� */ public static void compress(File source, File target, boolean delflag) { if (!target.exists()) { target.mkdirs(); } File zipFile = new File(target.getAbsolutePath() + File.separator + source.getName() + ".zip"); Project prj = new Project(); org.apache.tools.ant.taskdefs.Zip zip = new org.apache.tools.ant.taskdefs.Zip(); zip.setProject(prj); zip.setDestFile(zipFile); FileSet fileSet = new FileSet(); fileSet.setProject(prj); fileSet.setDir(target); // ������Щ�ļ����ļ��� fileSet.setIncludes(source.getName()); // �ų���Щ�ļ����ļ��� fileSet.setExcludes("*.zip"); zip.addFileset(fileSet); zip.execute(); if (delflag) { source.delete(); } }
Example 17
Source File: BundleLocator.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void processBundlePath() { if (null!=bundlePath && 0<bundlePath.length()) { final URL baseUrl = getBaseURL(); // Create a file set for each entry in the bundle path. final String[] urls = Util.splitwords(this.bundlePath, ";", '"'); for (final String url2 : urls) { log("Processing URL '" + url2 + "' from bundlePath '" + this.bundlePath + "'.", Project.MSG_DEBUG); try { final URL url = new URL(baseUrl, url2.trim()); if ("file".equals(url.getProtocol())) { final String path = url.getPath(); final File dir = new File(path.replace('/', File.separatorChar)); log("Adding file set with dir '" + dir + "' for bundlePath file URL with path '" + path + "'.", Project.MSG_VERBOSE); final FileSet fs = new FileSet(); fs.setDir(dir); fs.setExcludes("**/*-source.jar,**/*-javadoc.jar"); fs.setIncludes("**/*.jar"); fs.setProject(getProject()); filesets.add(fs); } } catch (final MalformedURLException e) { throw new BuildException("Invalid URL, '" + url2 + "' found in bundlePath: '" + bundlePath + "'.", e); } } } }
Example 18
Source File: BundleClasspathTask.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void execute() throws BuildException { if ( (null==propertyName || 0==propertyName.length()) && (null==filesetId || 0==filesetId.length()) ) { throw new BuildException ("Either propertyName or filesetId must be given."); } if (null!=filesetId && dir==null) { throw new BuildException ("dir is required when filesetId is given."); } if (null==bundleClasspath || 0==bundleClasspath.length() ) { bundleClasspath = "."; } final StringBuffer sb = new StringBuffer(100); // Convert path entries to patterns. final StringTokenizer st = new StringTokenizer(bundleClasspath, ","); while (st.hasMoreTokens()) { String entry = st.nextToken().trim(); if (entry.startsWith("/")) { // Entry is a relative path, must not start with a '/', fix it. entry = entry.substring(1); } if (".".equals(entry)) { sb.append("**/*.class"); } else if (entry.endsWith(".jar")) { sb.append(entry); } else { sb.append(entry + "/**/*.class"); } if (st.hasMoreTokens()) { sb.append(","); } } final Project proj = getProject(); // Conversion done - write back properties if (null!=propertyName) { proj.setProperty(propertyName, sb.toString()); log("Converted \"" +bundleClasspath +"\" to pattern \"" +sb.toString() +"\"", Project.MSG_VERBOSE); } if (null!=filesetId) { final FileSet fileSet = new FileSet(); fileSet.setProject(proj); if (dir.exists()) { fileSet.setDir(dir); fileSet.setIncludes(sb.toString()); } else { log("Bundle class path root dir '" +dir +"' does not exist, returning empty file set.", Project.MSG_DEBUG); fileSet.setDir(new File(".")); fileSet.setExcludes("**/*"); } proj.addReference(filesetId, fileSet); log("Converted bundle class path \"" +bundleClasspath +"\" to file set with id '" +filesetId +"' and files \"" +fileSet +"\"", Project.MSG_VERBOSE); } }
Example 19
Source File: CustomJavac.java From netbeans with Apache License 2.0 | 4 votes |
/** * See issue #166888. If there are any existing class files with no matching * source file, assume this is an incremental build and the source file has * since been deleted. In that case, delete the whole classes dir. (Could * merely delete the stale class file, but if an annotation processor also * created associated resources, these may be stale too. Kill them all and * let JSR 269 sort it out.) */ private void cleanUpStaleClasses() { File d = getDestdir(); if (!d.isDirectory()) { return; } List<File> sources = new ArrayList<>(); for (String s : getSrcdir().list()) { sources.add(new File(s)); } if (generatedClassesDir.isDirectory()) { sources.add(generatedClassesDir); } FileSet classes = new FileSet(); classes.setDir(d); classes.setIncludes("**/*.class"); classes.setExcludes("**/*$*.class"); String startTimeProp = getProject().getProperty("module.build.started.time"); Date startTime; try { startTime = startTimeProp != null ? new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").parse(startTimeProp) : null; } catch (ParseException x) { throw new BuildException(x); } for (String clazz : classes.getDirectoryScanner(getProject()).getIncludedFiles()) { if (startTime != null && new File(d, clazz).lastModified() > startTime.getTime()) { // Ignore recently created classes. Hack to get contrib/j2ee.blueprints and the like // to build; these generate classes and resources before main compilation step. continue; } String java = clazz.substring(0, clazz.length() - ".class".length()) + ".java"; boolean found = false; for (File source : sources) { if (new File(source, java).isFile()) { found = true; break; } } if (!found) { // XXX might be a false negative in case this was a nonpublic outer class // (could check for "ClassName.java" in bytecode to see) log(new File(d, clazz) + " appears to be stale, rebuilding all module sources", Project.MSG_WARN); Delete delete = new Delete(); delete.setProject(getProject()); delete.setOwningTarget(getOwningTarget()); delete.setLocation(getLocation()); FileSet deletables = new FileSet(); deletables.setDir(d); delete.addFileset(deletables); delete.init(); delete.execute(); break; } } }