org.apache.tools.ant.types.Path Java Examples
The following examples show how to use
org.apache.tools.ant.types.Path.
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: MakeNBM.java From netbeans with Apache License 2.0 | 6 votes |
static void validateAgainstAUDTDs(InputSource input, final Path updaterJar, final Task task) throws IOException, SAXException { XMLUtil.parse(input, true, false, XMLUtil.rethrowHandler(), new EntityResolver() { ClassLoader loader = new AntClassLoader(task.getProject(), updaterJar); public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { String remote = "http://www.netbeans.org/dtds/"; if (systemId.startsWith(remote)) { String rsrc = "org/netbeans/updater/resources/" + systemId.substring(remote.length()); URL u = loader.getResource(rsrc); if (u != null) { return new InputSource(u.toString()); } else { task.log(rsrc + " not found in " + updaterJar, Project.MSG_WARN); } } return null; } }); }
Example #2
Source File: IvyCachePathTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testOSGi() { project.setProperty("ivy.dep.file", "test/repositories/1/packaging/module5/ivys/ivy-1.0.xml"); path.setPathid("testOSGi"); path.setOsgi(true); path.execute(); Object ref = project.getReference("testOSGi"); assertNotNull(ref); assertTrue(ref instanceof Path); Path p = (Path) ref; assertEquals(4, p.size()); File cacheDir = path.getSettings().getDefaultRepositoryCacheBasedir(); File unpacked = new File(cacheDir, "packaging/module3/jar_unpackeds/module3-1.0"); assertEquals(new File(unpacked, "lib/ant-antlr.jar"), new File(p.list()[0])); assertEquals(new File(unpacked, "lib/ant-apache-bcel.jar"), new File(p.list()[1])); assertEquals(new File(unpacked, "lib/ant-apache-bsf.jar"), new File(p.list()[2])); assertEquals(new File(unpacked, "lib/ant-apache-log4j.jar"), new File(p.list()[3])); }
Example #3
Source File: IvyCachePathTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testInline1() { // we first resolve another ivy file IvyResolve resolve = new IvyResolve(); resolve.setProject(project); resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-latest.xml")); resolve.execute(); assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.2", "mod1.2", "jar", "jar").exists()); // then we resolve a dependency directly path.setOrganisation("org1"); path.setModule("mod1.2"); path.setRevision("2.0"); path.setInline(true); path.setPathid("simple-pathid"); path.execute(); Object ref = project.getReference("simple-pathid"); assertNotNull(ref); assertTrue(ref instanceof Path); Path p = (Path) ref; assertEquals(1, p.size()); assertEquals(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar") .getAbsolutePath(), new File(p.list()[0]).getAbsolutePath()); }
Example #4
Source File: IvyCachePathTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testInline2() { // we first resolve a dependency directly path.setOrganisation("org1"); path.setModule("mod1.2"); path.setRevision("2.0"); path.setInline(true); path.setPathid("simple-pathid"); path.execute(); Object ref = project.getReference("simple-pathid"); assertNotNull(ref); assertTrue(ref instanceof Path); Path p = (Path) ref; assertEquals(1, p.size()); assertEquals(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar") .getAbsolutePath(), new File(p.list()[0]).getAbsolutePath()); // we then resolve another ivy file IvyResolve resolve = new IvyResolve(); resolve.setProject(project); resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-latest.xml")); resolve.execute(); assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.2", "mod1.2", "jar", "jar").exists()); }
Example #5
Source File: ZserioTask.java From zserio with BSD 3-Clause "New" or "Revised" License | 6 votes |
private long calcLatestDependency() { long lastModified = 0; for (Path p : dependencies) { String [] files = p.list(); for (String file: files) { final long m = new File(file).lastModified(); verbose("ea: " + file + " " + m); if (m > lastModified) { lastModified = m; } } } return lastModified; }
Example #6
Source File: ZserioTask.java From zserio with BSD 3-Clause "New" or "Revised" License | 6 votes |
private long calcEarliestOutput() { long lastModified = Long.MAX_VALUE; for (Path p : output) { String [] files = p.list(); for (String file: files) { final long m = new File(file).lastModified(); if (m < lastModified) { lastModified = m; } } } return lastModified; }
Example #7
Source File: ZserioTask.java From zserio with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void cleanPreviousOutput() { int count = 0; for (Path p : output) { String [] files = p.list(); for (String file: files) { verbose("delete: " + file); final File fileObject = new File(file); if (!fileObject.delete()) System.out.println("File " + file + " cannot be deleted!"); else count++; } } System.out.println("Deleted " + count + " files."); }
Example #8
Source File: ModuleListParser.java From netbeans with Apache License 2.0 | 6 votes |
private static void doScanSuite(Map<String,Entry> entries, File suite, Map<String,Object> properties, Project project) throws IOException { Project fakeproj = new Project(); fakeproj.setBaseDir(suite); // in case ${basedir} is used somewhere Property faketask = new Property(); faketask.setProject(fakeproj); faketask.setFile(new File(suite, "nbproject/private/private.properties".replace('/', File.separatorChar))); faketask.execute(); faketask.setFile(new File(suite, "nbproject/project.properties".replace('/', File.separatorChar))); faketask.execute(); String modulesS = fakeproj.getProperty("modules"); if (modulesS == null) { throw new IOException("No definition of modules in " + suite); } String[] modules = Path.translatePath(fakeproj, modulesS); for (int i = 0; i < modules.length; i++) { File module = new File(modules[i]); if (!module.isDirectory()) { throw new IOException("No such module " + module + " referred to from " + suite); } if (!scanPossibleProject(module, entries, properties, null, ModuleType.SUITE, project, null)) { throw new IOException("No valid module found in " + module + " referred to from " + suite); } } }
Example #9
Source File: JPDAStart.java From netbeans with Apache License 2.0 | 6 votes |
static ClassPath createJDKSourcePath ( Project project, Path bootclasspath ) { if (bootclasspath == null) { // if current platform is default one, bootclasspath is set to null JavaPlatform jp = JavaPlatform.getDefault(); if (jp != null) { return jp.getSourceFolders (); } else { return ClassPathSupport.createClassPath(java.util.Collections.EMPTY_LIST); } } else { return convertToSourcePath (project, bootclasspath, false); } }
Example #10
Source File: SortSuiteModulesTest.java From netbeans with Apache License 2.0 | 6 votes |
private void generateTestModules1(boolean sortTests) throws IOException, BuildException { // a -> b means: a depends on b // a-> b,c // b -> d,e, unittest g // f -> g createModule(g,NULL); createModule(d,NULL); createModule(c,NULL); createModule(e,NULL); createModule(a,new String[]{b,c}); createModule(b,new String[]{e,d},new String[]{g},NULL); createModule(f,new String[]{g}); Path path = createPath(new String[]{a,b,c,d,e,f,g}); SortSuiteModules ssm = new SortSuiteModules(); ssm.setProject(project); ssm.setUnsortedModules(path); ssm.setSortedModulesProperty(SORTED_MODULES); if (sortTests) { ssm.setSortTests(true); } ssm.execute(); }
Example #11
Source File: IvyCachePathTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testPackedOSGi() { project.setProperty("ivy.dep.file", "test/repositories/1/packaging/module8/ivys/ivy-1.0.xml"); path.setPathid("testOSGi"); path.setOsgi(true); path.execute(); Object ref = project.getReference("testOSGi"); assertNotNull(ref); assertTrue(ref instanceof Path); Path p = (Path) ref; assertEquals(4, p.size()); File cacheDir = path.getSettings().getDefaultRepositoryCacheBasedir(); File unpacked = new File(cacheDir, "packaging/module7/jar_unpackeds/module7-1.0"); assertEquals(new File(unpacked, "lib/ant-antlr.jar"), new File(p.list()[0])); assertEquals(new File(unpacked, "lib/ant-apache-bcel.jar"), new File(p.list()[1])); assertEquals(new File(unpacked, "lib/ant-apache-bsf.jar"), new File(p.list()[2])); assertEquals(new File(unpacked, "lib/ant-apache-log4j.jar"), new File(p.list()[3])); }
Example #12
Source File: CacheWriterTask.java From netbeans with Apache License 2.0 | 6 votes |
public void execute() throws BuildException { if (paths.isEmpty()) { throw new BuildException ("Source dir or fileset required to scan for images"); } if (outDir == null) { throw new BuildException ("Output directory for cache file must be specified"); } try { CacheWriter writer = new CacheWriter(); writer.setDir(outDir.toString(), clean); Iterator it = paths.iterator(); while (it.hasNext()) { Path curr = (Path) it.next(); String[] dirs = curr.list(); for (int i=0; i < dirs.length; i++) { System.err.println("WriteDir " + dirs[i]); writer.writeDir(dirs[i], true); } } } catch (IOException ioe) { ioe.printStackTrace(); throw new BuildException (ioe.getMessage()); } }
Example #13
Source File: AntBuildResolverTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testCachePathFolder() { wa.setPath("target/classes"); IvyResolve resolve = new IvyResolve(); resolve.setProject(project); resolve.setFile(new File("test/workspace/project2/ivy.xml")); resolve.setKeep(true); resolve.execute(); IvyCachePath cachePath = new IvyCachePath(); cachePath.setProject(project); cachePath.setPathid("test.cachepath.id"); cachePath.execute(); Path path = project.getReference("test.cachepath.id"); assertEquals(2, path.size()); assertEquals(new File("test/workspace/project1/target/classes").getAbsolutePath(), path.list()[0]); assertEquals(new File(TestHelper.cache, "org.acme/module1/jars/module1-1.1.jar").getAbsolutePath(), path.list()[1]); }
Example #14
Source File: XtendCompilerAntTask.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
private void validateArgs() { if (getDestdir() == null) { throw new BuildException("Destination directory 'destdir' is required."); } Path srcDirs = getSrcdir(); if (srcDirs == null) { throw new BuildException("Sources directory 'srcdir' is required."); } Iterator<?> pathIter = srcDirs.iterator(); while (pathIter.hasNext()) { Object next = pathIter.next(); if (!(next instanceof Resource && ((Resource) next).isDirectory())) { throw new BuildException("Source directory must be a directory. Check 'srcdir' entry: " + next); } } }
Example #15
Source File: TaskModel.java From testability-explorer with Apache License 2.0 | 5 votes |
public String getClassPath() { Path totalPath = null; for (Path p : classPaths) { if (totalPath == null) { totalPath = p; continue; } totalPath.add(p); } return totalPath != null ? totalPath.toString() : DEFAULT_FILTER; }
Example #16
Source File: AntRewriteTask.java From tascalate-javaflow with Apache License 2.0 | 5 votes |
/** * Set the classpath to be used for this compilation. * * @param classpath an Ant Path object containing the compilation classpath. */ public void setClasspath(Path classpath) { if (compileClasspath == null) { compileClasspath = classpath; } else { compileClasspath.append(classpath); } }
Example #17
Source File: ValidatePathTest.java From netbeans with Apache License 2.0 | 5 votes |
protected void setUp() throws Exception { super.setUp(); clearWorkDir(); Project prj = new Project(); prj.setBaseDir(getWorkDir()); path = new Path(prj); vp = new ValidatePath(); vp.setPath(path); }
Example #18
Source File: CompileTaskSupport.java From groovy with Apache License 2.0 | 5 votes |
public void setSrcdir(final Path dir) { assert dir != null; if (src == null) { src = dir; } else { src.append(dir); } }
Example #19
Source File: SortSuiteModulesTest.java From netbeans with Apache License 2.0 | 5 votes |
private String[] getSorted(String property) { Path path = new Path(project); path.setPath(property); String paths[] = path.list(); String rets [] = new String[paths.length]; for (int i = 0; i < paths.length; i++) { rets[i] = new File(paths[i]).getName(); } return rets; }
Example #20
Source File: JRAntXmlExportTask.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * Sets the source directories to find the XML report design files. * * @param srcdir source path */ public void setSrcdir(Path srcdir) { if (src == null) { src = srcdir; } else { src.append(srcdir); } }
Example #21
Source File: DelombokTask.java From EasyMPermission with MIT License | 5 votes |
public void setSourcepath(Path sourcepath) { if (this.sourcepath == null) { this.sourcepath = sourcepath; } else { this.sourcepath.append(sourcepath); } }
Example #22
Source File: DUnitConfigAntTask.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Creates a nested <code>extraClientClasspath</code> path */ public Path createExtraClientClasspath() { if (this.extraClientClasspath == null) { this.extraClientClasspath = new Path(this.getProject()); } return this.extraClientClasspath.createPath(); }
Example #23
Source File: FindBugsTask.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
/** * the excludepath to use. * * @param src * excludepath */ public void setExcludePath(Path src) { if (excludePath == null) { excludePath = src; } else { excludePath.append(src); } }
Example #24
Source File: JPDAStart.java From netbeans with Apache License 2.0 | 5 votes |
static void verifyPaths(Project project, Path path) { if (path == null) return ; String[] paths = path.list(); for (int i = 0; i < paths.length; i++) { String pathName = project.replaceProperties(paths[i]); File file = FileUtil.normalizeFile (project.resolveFile (pathName)); if (!file.exists()) { project.log("Non-existing path \""+pathName+"\" provided.", Project.MSG_WARN); //throw new BuildException("Non-existing path \""+paths[i]+"\" provided."); } } }
Example #25
Source File: AbstractFindBugsTask.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
/** * the plugin list to use. * * @param src * plugin list to use */ public void setPluginList(Path src) { if (pluginList == null) { pluginList = src; } else { pluginList.append(src); } }
Example #26
Source File: Sigtest.java From netbeans with Apache License 2.0 | 5 votes |
public void setClasspath(Path p) { if (classpath == null) { classpath = p; } else { classpath.append(p); } }
Example #27
Source File: PathBuilder.java From development with Apache License 2.0 | 5 votes |
private void addRuntimePath(Path path, IEclipseProject p) { addClasses(path, p); addLibraries(path, p.getLibraries()); for (IEclipseProject d : p.getJavaPathDependencies()) { addRuntimePath(path, d); } }
Example #28
Source File: PathBuilder.java From development with Apache License 2.0 | 5 votes |
private void addClasses(Path path, IEclipseProject project) { File javasrc = new File(project.getLocation(), "javasrc"); if (javasrc.exists()) { // Add class files only if this project has Java sources File projectWorkDir = new File(workdir, project.getName()); path.setLocation(new File(projectWorkDir, "classes")); } }
Example #29
Source File: UberCompileTask.java From groovy with Apache License 2.0 | 5 votes |
public void setSrcdir(final Path dir) { assert dir != null; if (src == null) { src = dir; } else { src.append(dir); } }
Example #30
Source File: DependencyPropertiesTaskTest.java From development with Apache License 2.0 | 5 votes |
@Test public void testCompilePathProjectA() { task.setWorkspacedir(TESTWORKSPACE); task.setProjectdir(PROJECT_A_DIR); task.setResultdir(RESULTDIR); task.execute(); Path path = (Path) project.getReference("dependencies.compile.path"); List<String> expected = Arrays.asList(absospath( "resources/testworkspace/project-lib/javalib/samplelib.jar")); assertEquals(expected, Arrays.asList(path.list())); }