当前位置: 首页>>代码示例>>Java>>正文


Java Location类代码示例

本文整理汇总了Java中org.apache.tools.ant.Location的典型用法代码示例。如果您正苦于以下问题:Java Location类的具体用法?Java Location怎么用?Java Location使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Location类属于org.apache.tools.ant包,在下文中一共展示了Location类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFileNameOfLocation

import org.apache.tools.ant.Location; //导入依赖的package包/类
private static String getFileNameOfLocation(Location loc) {
    if (locationGetFileName != null) {
        try {
            return (String) locationGetFileName.invoke(loc);
        } catch (Exception e) {
            LOG.log(Level.WARNING, null, e);
        }
    }
    // OK, using Ant 1.5.x.
    String locs = loc.toString();
    // Format: "$file:$line: " or "$file: " or ""
    int x = locs.indexOf(':');
    if (x != -1) {
        return locs.substring(0, x);
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:NbBuildLogger.java

示例2: execute

import org.apache.tools.ant.Location; //导入依赖的package包/类
public void execute() throws BuildException {
    for(FileSet fs: filesets) {
        FileScanner scanner = fs.getDirectoryScanner(getProject());
        File dir = scanner.getBasedir();
        String[] files = scanner.getIncludedFiles();
        for (int i = 0; i < files.length; i++) {
            File helpset = new File(dir, files[i]);
            try {
                checkHelpSet(helpset);
            } catch (BuildException be) {
                throw be;
            } catch (Exception e) {
                throw new BuildException("Error checking helpset", e, new Location(helpset.getAbsolutePath()));
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:CheckHelpSets.java

示例3: onDefineTarget

import org.apache.tools.ant.Location; //导入依赖的package包/类
private Target onDefineTarget(final Attributes attrs, String tagName, String ns) {
    final Target target = new Target();
    target.setProject(project);
    target.setLocation(new Location(antXmlContext.getLocator()));
    try {
        antTargetHandler.onStartElement(ns, tagName, tagName, attrs, antXmlContext);
        final Target newTarget = getProject().getTargets().get(attrs.getValue("name"));
        antXmlContext.setCurrentTarget(newTarget);
        definingTarget = newTarget;
        return newTarget;
    }
    catch (final SAXParseException e) {
        log.log(Level.SEVERE, "Caught: " + e, e);
    }
    return null;
}
 
开发者ID:apache,项目名称:groovy,代码行数:17,代码来源:AntBuilder.java

示例4: onStartTarget

import org.apache.tools.ant.Location; //导入依赖的package包/类
private Target onStartTarget(final Attributes attrs, String tagName, String ns) {
    final Target target = new Target();
    target.setProject(project);
    target.setLocation(new Location(antXmlContext.getLocator()));
    try {
        antTargetHandler.onStartElement(ns, tagName, tagName, attrs, antXmlContext);
        final Target newTarget = getProject().getTargets().get(attrs.getValue("name"));

        // execute dependencies (if any)
        final Vector<Target> targets = new Vector<Target>();
        for (final Enumeration<String> deps = newTarget.getDependencies(); deps.hasMoreElements();) {
            final String targetName = deps.nextElement();
            targets.add(project.getTargets().get(targetName));
        }
        getProject().executeSortedTargets(targets);

        antXmlContext.setCurrentTarget(newTarget);
        return newTarget;
    }
    catch (final SAXParseException e) {
        log.log(Level.SEVERE, "Caught: " + e, e);
    }
    return null;
}
 
开发者ID:apache,项目名称:groovy,代码行数:25,代码来源:AntBuilder.java

示例5: getJavaCopyFileSet

import org.apache.tools.ant.Location; //导入依赖的package包/类
/**
 * FILL IN JAVADOC HERE
 * 
 */
public FileSet getJavaCopyFileSet(Project p, Location l) throws BuildException {

	if (failureReason != null)
		throw new BuildException(failureReason, l);
	else if (pack.indexOf("/") != -1 || pack.indexOf("\\") != -1)
		throw new BuildException("A package name cannot contain '\\' or '/' like package=" + pack
				+ "\nIt must look like biz.xsoftware.* for example", l);
	FileSet set = new FileSet();

	String match = getMatch(p, pack, ".java");
	// log("match="+match+" pack="+pack);
	// first exclude the compilation module, then exclude all it's
	// dependencies too.
	set.setIncludes(match);

	return set;
}
 
开发者ID:cniweb,项目名称:ant-contrib,代码行数:22,代码来源:Package.java

示例6: testImportError

import org.apache.tools.ant.Location; //导入依赖的package包/类
@Test
public void testImportError() {
    try {
        buildRule.configureProject(
            "src/etc/testcases/taskdefs/import/import_bad_import.xml");
        fail("Build exception should have been thrown");
    } catch (BuildException ex) {
        Location lo = ex.getLocation();
        assertNotNull(
            "expected location of build exception to be set", lo);
        assertContains(
            "expected location to contain calling file", "import_bad_import.xml", lo.getFileName());
        assertContains(
            "expected message of ex to contain called file", "bad.xml", ex.getMessage());
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:17,代码来源:ImportTest.java

示例7: setUp

import org.apache.tools.ant.Location; //导入依赖的package包/类
@Before
public void setUp() throws URISyntaxException, IOException {
    Project project = new Project();
    ProjectUtils.configureProjectHelper(project);
    configureBuildLogger(project, Project.MSG_VERBOSE);

    File cache = folder.newFolder("build-cache");
    project.setProperty("ivy.cache.dir", cache.getAbsolutePath());
    File projectCache = folder.newFolder("easyant-cache-test");
    project.setProperty("easyant.default.cache.dir", projectCache.getAbsolutePath());

    configureEasyantSettings(project);
    configureProjectSettings(project);

    project.setBaseDir(new File(this.getClass().getResource("simple").toURI()));

    configurePluginService(project);
    configureEasyantBuildScopeRepository(project);
    configureProjectBuildScopeRepository(project);

    goOffline = new GoOffline();
    goOffline.setProject(project);
    goOffline.setOwningTarget(ProjectUtils.createTopLevelTarget());
    goOffline.setLocation(new Location(ProjectUtils.emulateMainScript(project).getAbsolutePath()));

}
 
开发者ID:apache,项目名称:ant-easyant-core,代码行数:27,代码来源:GoOfflineTest.java

示例8: setUp

import org.apache.tools.ant.Location; //导入依赖的package包/类
@Before
public void setUp() throws URISyntaxException, IOException {
    Project project = new Project();
    ProjectUtils.configureProjectHelper(project);

    File cache = folder.newFolder("build-cache");
    project.setProperty("ivy.cache.dir", cache.getAbsolutePath());

    IvyConfigure configure = new IvyConfigure();
    configure.setSettingsId(EasyAntMagicNames.EASYANT_IVY_INSTANCE);
    configure.setProject(project);
    configure.setFile(new File(this.getClass().getResource("/repositories/easyant-ivysettings-test.xml").toURI()));
    configure.execute();

    project.setBaseDir(new File(this.getClass().getResource("simple").toURI()));
    project.setInputHandler(fakeInputHandler);

    searchModule.setProject(project);
    searchModule.setOwningTarget(ProjectUtils.createTopLevelTarget());
    searchModule.setLocation(new Location(ProjectUtils.emulateMainScript(project).getAbsolutePath()));
    searchModule.setSettingsRef(IvyInstanceHelper.buildEasyAntIvyReference(project));
}
 
开发者ID:apache,项目名称:ant-easyant-core,代码行数:23,代码来源:SearchModuleTest.java

示例9: setUp

import org.apache.tools.ant.Location; //导入依赖的package包/类
@Before
public void setUp() throws URISyntaxException, IOException {
    Project project = new Project();
    ProjectUtils.configureProjectHelper(project);

    File cache = folder.newFolder("build-cache");
    project.setProperty("ivy.cache.dir", cache.getAbsolutePath());

    IvyConfigure configure = new IvyConfigure();
    configure.setProject(project);

    File f = new File(this.getClass().getResource("/repositories/easyant-ivysettings-test.xml").toURI());
    configure.setFile(f);

    configure.setSettingsId(EasyAntMagicNames.EASYANT_IVY_INSTANCE);
    configure.execute();

    project.setBaseDir(new File(this.getClass().getResource("simple").toURI()));

    loadModule = new LoadModule();
    loadModule.setProject(project);
    loadModule.setOwningTarget(ProjectUtils.createTopLevelTarget());
    loadModule.setLocation(new Location(ProjectUtils.emulateMainScript(project).getAbsolutePath()));
}
 
开发者ID:apache,项目名称:ant-easyant-core,代码行数:25,代码来源:LoadModuleTest.java

示例10: setUp

import org.apache.tools.ant.Location; //导入依赖的package包/类
@Before
public void setUp() throws URISyntaxException, IOException {
    Project project = new Project();
    ProjectUtils.configureProjectHelper(project);

    File cache = folder.newFolder("build-cache");
    project.setProperty("ivy.cache.dir", cache.getAbsolutePath());

    IvyConfigure configure = new IvyConfigure();
    configure.setProject(project);

    File f = new File(this.getClass().getResource("/repositories/easyant-ivysettings-test.xml").toURI());
    configure.setFile(f);

    configure.setSettingsId(EasyAntMagicNames.EASYANT_IVY_INSTANCE);
    configure.execute();

    importTask = new Import();
    importTask.setProject(project);
    importTask.setOwningTarget(ProjectUtils.createTopLevelTarget());
    importTask.setLocation(new Location(ProjectUtils.emulateMainScript(project).getAbsolutePath()));
}
 
开发者ID:apache,项目名称:ant-easyant-core,代码行数:23,代码来源:ImportTest.java

示例11: matches

import org.apache.tools.ant.Location; //导入依赖的package包/类
/**
 * Determine if the parse target matches the specified ant Target.
 *
 * @param   target    Ant target
 * @return  TRUE if the target matches
 */
public boolean matches(Target target) {
    boolean match = true;

    if (!targetName.equals(target.getName())) {
        match = false;
    }

    Location location = target.getLocation();
    String targetFileName = targetFile.getAbsolutePath();
    if (!targetFileName.equals(location.getFileName())) {
        match = false;
    }

    return match;
}
 
开发者ID:ModelN,项目名称:build-management,代码行数:22,代码来源:ProgressTarget.java

示例12: buildExceptionForModule

import org.apache.tools.ant.Location; //导入依赖的package包/类
private BuildException buildExceptionForModule(final Throwable cause, final Module module)
{
    final BuildException ex = new BuildException(MessageFormat.format(
            "Module ''{0}'': {1}", module.getPath(), cause.getMessage()), cause);
    
    // Gathering all information available from the original build exception.
    if (cause instanceof BuildException) {
        /* The thread that generated this exception is either the current thread or
           a dead thread so synchronisation is not needed to read location. */
        final Location location = ((BuildException) cause).getLocation();
        ex.setLocation(location == null ? Location.UNKNOWN_LOCATION : location);
        ex.setStackTrace(cause.getStackTrace());
    }
    
    return ex;
}
 
开发者ID:dzidzitop,项目名称:ant_modular,代码行数:17,代码来源:CallTargetForModules.java

示例13: testRootModuleWithDependency_CyclicDependency_TaskLocationUndefined

import org.apache.tools.ant.Location; //导入依赖的package包/类
public void testRootModuleWithDependency_CyclicDependency_TaskLocationUndefined()
{
    final ModuleInfo moduleInfo1 = new ModuleInfo("foo/", moduleLoader);
    final ModuleInfo moduleInfo2 = new ModuleInfo("bar/", moduleLoader);
    moduleInfo1.addDependency("bar/");
    moduleInfo2.addDependency("foo/");
    moduleLoader.modules.put("foo/", moduleInfo1);
    moduleLoader.modules.put("bar/", moduleInfo2);
    
    task.init();
    task.setTarget("testTarget");
    task.setModuleRefId("moduleRef");
    task.createModule().setPath("foo");
    task.addConfigured(moduleLoader);
    
    try {
        task.perform();
        fail();
    }
    catch (BuildException ex) {
        assertTrue(ex.getCause() instanceof CyclicDependenciesDetectedException);
        assertEquals(ex.getMessage(), ex.getCause().getMessage());
        assertSame(Location.UNKNOWN_LOCATION, ex.getLocation());
    }
}
 
开发者ID:dzidzitop,项目名称:ant_modular,代码行数:26,代码来源:CallTargetForModules_InvalidUseCasesTest.java

示例14: createTask

import org.apache.tools.ant.Location; //导入依赖的package包/类
/**
 * A utility method to create Ant worker tasks.
 */
protected <T extends Task> T createTask(Class<T> type) {

    if (type == null) {
        throw new NullPointerException("Null task class");
    }

    T task;
    try {
        task = type.newInstance();
    } catch (Exception e) {
        throw new RuntimeException("Can't create Ant task: " + type.getName());
    }

    task.setProject(project);
    task.setTaskName(type.getSimpleName());
    task.setLocation(Location.UNKNOWN_LOCATION);
    return task;
}
 
开发者ID:andrus,项目名称:japp-maven-plugin,代码行数:22,代码来源:AbstractAntWorker.java

示例15: getLocationOfTarget

import org.apache.tools.ant.Location; //导入依赖的package包/类
/**
 * Try to find the location of an Ant target.
 * @param project if not null, the main project from which this target might have been imported
 */
private Location getLocationOfTarget(Target target, Project project) {
    if (targetGetLocation != null) {
        try {
            return (Location) targetGetLocation.invoke(target);
        } catch (Exception e) {
            LOG.log(Level.WARNING, null, e);
        }
    }
    // For Ant 1.6.2 and earlier, hope we got the right info from the hacks above.
    LOG.log(Level.FINEST, "knownImportedTargets: {0}", knownImportedTargets);
    if (project != null) {
        String file = project.getProperty("ant.file"); // NOI18N
        if (file != null) {
            Map<String,String> targetLocations = knownImportedTargets.get(file);
            if (targetLocations != null) {
                String importedFile = targetLocations.get(target.getName());
                if (importedFile != null) {
                    // Have no line number, note.
                    return new Location(importedFile);
                }
            }
        }
    }
    // Dunno.
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:NbBuildLogger.java


注:本文中的org.apache.tools.ant.Location类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。