本文整理汇总了Java中org.apache.tools.ant.types.Path类的典型用法代码示例。如果您正苦于以下问题:Java Path类的具体用法?Java Path怎么用?Java Path使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Path类属于org.apache.tools.ant.types包,在下文中一共展示了Path类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateTestModules1
import org.apache.tools.ant.types.Path; //导入依赖的package包/类
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();
}
示例2: testTestDependenciesCycleEnabledTestSort
import org.apache.tools.ant.types.Path; //导入依赖的package包/类
public void testTestDependenciesCycleEnabledTestSort() throws IOException {
createModule(a,new String[]{b},new String[]{b},NULL);
createModule(b,NULL,new String[]{a},NULL);
Path path = createPath(new String[]{a,b});
SortSuiteModules ssm = new SortSuiteModules();
ssm.setProject(project);
ssm.setUnsortedModules(path);
ssm.setSortedModulesProperty(SORTED_MODULES);
ssm.setSortTests(true);
try {
ssm.execute();
fail("Exception must be thrown");
} catch(BuildException be) {
// ok
}
}
示例3: validateAgainstAUDTDs
import org.apache.tools.ant.types.Path; //导入依赖的package包/类
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;
}
});
}
示例4: doScanSuite
import org.apache.tools.ant.types.Path; //导入依赖的package包/类
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);
}
}
}
示例5: execute
import org.apache.tools.ant.types.Path; //导入依赖的package包/类
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());
}
}
示例6: createSourcePath
import org.apache.tools.ant.types.Path; //导入依赖的package包/类
static ClassPath createSourcePath (
Project project,
Path modulepath,
Path classpath,
Path sourcepath,
boolean isSourcePathExclusive
) {
if (sourcepath != null && isSourcePathExclusive) {
return convertToClassPath (project, sourcepath);
}
ClassPath cp = convertToSourcePath (project, classpath, true);
ClassPath modulesSources = convertToSourcePath(project, modules(project, modulepath), true);
ClassPath sp = convertToClassPath (project, sourcepath);
ClassPath sourcePath = ClassPathSupport.createProxyClassPath (
new ClassPath[] {cp, modulesSources, sp}
);
return sourcePath;
}
示例7: createJDKSourcePath
import org.apache.tools.ant.types.Path; //导入依赖的package包/类
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);
}
}
示例8: testGetRuntimePathWithDependencies
import org.apache.tools.ant.types.Path; //导入依赖的package包/类
@Test
public void testGetRuntimePathWithDependencies() {
final ProjectStub projectA = new ProjectStub("project-a");
final ProjectStub projectC = new ProjectStub("project-c");
projectC.addLibraries(LIB);
projectA.addJavaPathDependencies(projectC);
Path path = createBuilder(projectA).getRuntimePath();
List<String> expected = Arrays.asList(
absospath("resources/result/work/project-a/classes"),
absospath(LIB));
assertEquals(expected, Arrays.asList(path.list()));
}
示例9: testProjectsNotSet
import org.apache.tools.ant.types.Path; //导入依赖的package包/类
@Test
public void testProjectsNotSet() {
task.setWorkspacedir(TESTWORKSPACE);
task.setProjects("");
task.execute();
Path path = (Path) project.getReference("resolved.projects.path");
String[] entries = path.list();
assertEquals(4, entries.length);
assertEquals(new File("resources/testworkspace/project-lib")
.getAbsolutePath(), entries[0]);
assertEquals(new File("resources/testworkspace/project-a")
.getAbsolutePath(), entries[1]);
assertEquals(new File("resources/testworkspace/project-b")
.getAbsolutePath(), entries[2]);
assertEquals(new File("resources/testworkspace/project-c")
.getAbsolutePath(), entries[3]);
}
示例10: compileJavaVersionChecker
import org.apache.tools.ant.types.Path; //导入依赖的package包/类
private void compileJavaVersionChecker() {
PhetBuildUtils.antEcho( antTaskRunner, "Compiling java version checker for " + project.getName() + ".", getClass() );
Javac javac = new Javac();
javac.setIncludeantruntime( false );//see #2431, should not include full classpath if running from IDE
javac.setSource( BuildToolsConstants.BOOTSTRAP_JAVA_VERSION );//Java version checker must be compiled in lowest language version
javac.setTarget( BuildToolsConstants.BOOTSTRAP_JAVA_VERSION );//so it can run in lowest language version jvms
javac.setClasspath( new Path( antTaskRunner.getProject(), new File( project.getTrunk(), BuildToolsPaths.JNLP_JAR ).getAbsolutePath() ) );
javac.setSrcdir( new Path( antTaskRunner.getProject(), new File( project.getTrunk(), BuildToolsPaths.JAVA_COMMON + "/java-version-checker/src" ).getAbsolutePath() ) );
javac.setDestdir( project.getClassesDirectory() );
javac.setDebugLevel( "lines,source" );
javac.setDebug( true );
//if this fails, you may need to add Oracles's tools.jar to your working copy (ignored from svn for legal reasons)
//see trunk/build-tools/contrib/sun-tools/readme.txt
antTaskRunner.runTask( javac );
PhetBuildUtils.antEcho( antTaskRunner, "Finished compiling java version checker for " + project.getName() + ".", getClass() );
}
示例11: testPathsOneFile
import org.apache.tools.ant.types.Path; //导入依赖的package包/类
@Test
public final void testPathsOneFile() throws IOException {
// given
TestRootModuleChecker.reset();
final CheckstyleAntTask antTask = getCheckstyleAntTask(CUSTOM_ROOT_CONFIG_FILE);
final FileSet examinationFileSet = new FileSet();
examinationFileSet.setFile(new File(getPath(FLAWLESS_INPUT)));
final Path sourcePath = new Path(antTask.getProject());
sourcePath.addFileset(examinationFileSet);
antTask.addPath(sourcePath);
// when
antTask.execute();
// then
assertTrue("Checker is not processed",
TestRootModuleChecker.isProcessed());
final List<File> filesToCheck = TestRootModuleChecker.getFilesToCheck();
assertThat("There more files to check then expected",
filesToCheck.size(), is(1));
assertThat("The path of file differs from expected",
filesToCheck.get(0).getAbsolutePath(), is(getPath(FLAWLESS_INPUT)));
}
示例12: testSetClasspathRef1
import org.apache.tools.ant.types.Path; //导入依赖的package包/类
/** This test is created to satisfy pitest, it is hard to emulate Reference by Id. */
@Test
public void testSetClasspathRef1() {
final CheckstyleAntTask antTask = new CheckstyleAntTask();
final Project project = new Project();
antTask.setClasspath(new Path(project, "firstPath"));
antTask.setClasspathRef(new Reference(project, "idXX"));
try {
assertNotNull("Classpath should not be null",
Whitebox.getInternalState(antTask, "classpath"));
final Path classpath = (Path) Whitebox.getInternalState(antTask, "classpath");
classpath.list();
fail("Exception is expected");
}
catch (BuildException ex) {
assertEquals("unexpected exception message",
"Reference idXX not found.", ex.getMessage());
}
}
示例13: verifyPathAdheresToDesign
import org.apache.tools.ant.types.Path; //导入依赖的package包/类
private void verifyPathAdheresToDesign(Design d, Path p) throws ClassFormatException, IOException {
String files[] = p.list();
for (int i = 0; i < files.length; i++) {
File file = new File(files[i]);
if (file.isDirectory()) {
FileSet set = new FileSet();
set.setDir(file);
set.setProject(task.getProject());
PatternSet.NameEntry entry1 = set.createInclude();
PatternSet.NameEntry entry2 = set.createInclude();
PatternSet.NameEntry entry3 = set.createInclude();
entry1.setName("**/*.class");
entry2.setName("**/*.jar");
entry3.setName("**/*.war");
DirectoryScanner scanner = set.getDirectoryScanner(task.getProject());
scanner.setBasedir(file);
String[] scannerFiles = scanner.getIncludedFiles();
for (int j = 0; j < scannerFiles.length; j++) {
verifyPartOfPath(scannerFiles[j], new File(file, scannerFiles[j]), d);
}
} else
verifyPartOfPath(files[i], file, d);
}
}
示例14: execute
import org.apache.tools.ant.types.Path; //导入依赖的package包/类
/**
* @see org.apache.tools.ant.Task#execute()
*/
@Override
public void execute() throws BuildException {
if (!ClassPathTask.TARGET_CLASSPATH.equalsIgnoreCase(this.produce)
&& !ClassPathTask.TARGET_FILESET.equals(this.produce)) {
throw new BuildException("Mandatory target must be either '" + ClassPathTask.TARGET_CLASSPATH + "' or '"
+ ClassPathTask.TARGET_FILESET + "'");
}
final ClassPathParser parser = new ClassPathParser();
AbstractCustomHandler handler;
if (ClassPathTask.TARGET_CLASSPATH.equalsIgnoreCase(this.produce)) {
final Path path = new Path(this.getProject());
this.getProject().addReference(this.idContainer, path);
handler = new PathCustomHandler(path);
} else {
final FileSet fileSet = new FileSet();
this.getProject().addReference(this.idContainer, fileSet);
fileSet.setDir(new File(this.getProject().getBaseDir().getAbsolutePath().toString()));
handler = new FileSetCustomHandler(fileSet);
}
parser.parse(new File(this.getProject().getBaseDir().getAbsolutePath(), ".classpath"), handler);
}
示例15: setup
import org.apache.tools.ant.types.Path; //导入依赖的package包/类
protected void setup(Java java) {
if (jarFile != null) {
java.setJar(jarFile);
} else {
if (classPath == null) {
java.setClasspath(Path.systemClasspath);
} else {
java.setClasspath(new Path(java.getProject(), classPath));
}
java.setClassname(mainClass);
}
if (jvmArgs != null) {
final Argument jvmArg = java.createJvmarg();
jvmArg.setLine(jvmArgs);
}
if (args != null) {
final Argument taskArgs = java.createArg();
taskArgs.setLine(args);
}
java.getProject().addBuildListener(new SimpleListener(java, outputOut, outputErr));
java.setCloneVm(cloneVM);
}