• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ProjectHelper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: altCompile

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
/**
 * Description: compile method that does not maintains the i/o streams after the task is done.
 * This is an alternative for the current compile method for future uses.
 * @param file path of the build xml to be executed
 */
public static void altCompile( String file) {
    
    // File buildFile = new File("build.xml");
    File buildFile = new File(file);
    Project p = new Project();
    p.setUserProperty("ant.file", buildFile.getAbsolutePath());     
    DefaultLogger consoleLogger = new DefaultLogger();
    consoleLogger.setErrorPrintStream(System.err);
    consoleLogger.setOutputPrintStream(System.out);
    consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
    p.addBuildListener(consoleLogger);
    
    try {
        p.fireBuildStarted();
        p.init();
        ProjectHelper helper = ProjectHelper.getProjectHelper();
        p.addReference("ant.projectHelper", helper);
        helper.parse(p, buildFile);
        p.executeTarget(p.getDefaultTarget());
        p.fireBuildFinished(null);
      
    } catch (Exception e) {}
}
 
开发者ID:bufferhe4d,项目名称:call-IDE,代码行数:29,代码来源:BuildSys.java


示例2: createProject

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
/**
 * @return Factory method to create new Project instances
 */
protected static Project createProject() {
    final Project project = new Project();

    final ProjectHelper helper = ProjectHelper.getProjectHelper();
    project.addReference(ProjectHelper.PROJECTHELPER_REFERENCE, helper);
    helper.getImportStack().addElement("AntBuilder"); // import checks that stack is not empty 

    final BuildLogger logger = new NoBannerLogger();

    logger.setMessageOutputLevel(org.apache.tools.ant.Project.MSG_INFO);
    logger.setOutputPrintStream(System.out);
    logger.setErrorPrintStream(System.err);

    project.addBuildListener(logger);

    project.init();
    project.getBaseDir();
    return project;
}
 
开发者ID:apache,项目名称:groovy,代码行数:23,代码来源:AntBuilder.java


示例3: setUp

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
protected void setUp() throws Exception {
    super.setUp(); //  Potentially throws Exception.
    project = new Project();
    project.init();
    ProjectHelper.getProjectHelper().parse(project, antFile);
    project.executeTarget("clean");
    String altJavaHome = System.getProperty("java.home");
    if (altJavaHome.lastIndexOf("jre") >= 0) {
        altJavaHome = altJavaHome.substring(0, altJavaHome.lastIndexOf("jre"));
    } else {
        altJavaHome = altJavaHome + File.separator + "jre";
    }
    try {
        File altFile = new File(altJavaHome);
        if (altFile.exists()) {
            project.setProperty("alt.java.home", altJavaHome);
        }
    } catch (Exception e) {
        // could be security, io, etc.  Ignore it.
        // End result is as if .exists() returned null
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:23,代码来源:GroovycTest.java


示例4: init

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
public void init(String _buildFile, String _baseDir) throws Exception {
    project = new Project();
    project.init();
    DefaultLogger consoleLogger = new DefaultLogger();
    consoleLogger.setErrorPrintStream(System.err);
    consoleLogger.setOutputPrintStream(System.out);
    consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
    project.addBuildListener(consoleLogger);
    if (_baseDir == null)
        _baseDir = new String(".");
    project.setBasedir(_baseDir);
    if (_buildFile == null)
        _buildFile = new String(projectBasePath + File.separator
                + "build.xml");
    ProjectHelper.configureProject(project, new File(_buildFile));
}
 
开发者ID:HongQiQu,项目名称:AndroidAntMakePackage,代码行数:17,代码来源:AntMakeAPK.java


示例5: getErrorProject

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
/**
 * Constructs the Project and returns it.
 * 
 * @return The Project
 * @throws Exception
 *            If anything goes wrong.
 */
private Project getErrorProject() throws Exception {
   Path buildFilePath = Paths.get(BUILD_REPORT_FILE);
   LOG.finer("Build file path set to " + String.valueOf(buildFilePath));
   Project p = new Project();
   p.setSystemProperties();
   p.setUserProperty("ant.file", buildFilePath.toAbsolutePath().toString());
   LOG.finer("Project ant.file property set.");
   p.init();
   LOG.finer("Project.init() called.");
   ProjectHelper helper = ProjectHelper.getProjectHelper();
   LOG.finer("ProjectHelper created.");
   p.addReference("ant.projectHelper", helper);
   LOG.finer("Project ant.projectHelper reference set.");
   p.addReference("user.dir", System.getProperty("user.dir"));
   LOG.finer("Project user.dir reference set.");
   helper.parse(p, buildFilePath.toAbsolutePath().toFile());
   LOG.finer("PrjectHelper.parse() called.");
   errorProject = p;
   p.addBuildListener(getBuildListener());
   LOG.finer("BuildListener added.");
   return errorProject;
}
 
开发者ID:Loreinator,项目名称:Shuffle-Move,代码行数:30,代码来源:ShuffleModel.java


示例6: createProject

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
/**
 * Creates and configures Ant project for Java task.
 * 
 * @return Ant project for Java task
 */
protected Project createProject()
{
    final Project result = new Project();

    final ProjectHelper helper = ProjectHelper.getProjectHelper();
    result.addReference( ProjectHelper.PROJECTHELPER_REFERENCE, helper );
    helper.getImportStack().addElement( "AntBuilder" ); // import checks that stack is not empty

    final BuildLogger logger = new NoBannerLogger();

    logger.setMessageOutputLevel( Project.MSG_INFO );
    logger.setOutputPrintStream( System.out );
    logger.setErrorPrintStream( System.err );

    result.addBuildListener( logger );

    result.init();
    result.setDefaultInputStream( System.in ); // for interactive commands, like "shell", needs more work!
    return result;
}
 
开发者ID:sbtrun-maven-plugin,项目名称:sbtrun-maven-plugin,代码行数:26,代码来源:AbstractAntJavaBasedMojo.java


示例7: createProject

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
protected Project createProject()
{
    final Project project = new Project();

    final ProjectHelper helper = ProjectHelper.getProjectHelper();
    project.addReference( ProjectHelper.PROJECTHELPER_REFERENCE, helper );
    helper.getImportStack().addElement( "AntBuilder" ); // import checks that stack is not empty

    final BuildLogger logger = new NoBannerLogger();

    logger.setMessageOutputLevel( Project.MSG_INFO );
    logger.setOutputPrintStream( System.out );
    logger.setErrorPrintStream( System.err );

    project.addBuildListener( logger );

    project.init();
    project.getBaseDir();
    return project;
}
 
开发者ID:play1-maven-plugin,项目名称:play1-maven-plugin,代码行数:21,代码来源:AbstractAntJavaBasedPlayMojo.java


示例8: addText

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
/**
 * Adds descriptive text to the project.
 *
 * @param text the descriptive text
 */
public void addText(String text) {

    ProjectHelper ph = getProject().getReference(ProjectHelper.PROJECTHELPER_REFERENCE);
    if (!(ph instanceof ProjectHelperImpl)) {
        // New behavior for delayed task creation. Description
        // will be evaluated in Project.getDescription()
        return;
    }
    String currentDescription = getProject().getDescription();
    if (currentDescription == null) {
        getProject().setDescription(text);
    } else {
        getProject().setDescription(currentDescription + text);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:21,代码来源:Description.java


示例9: isSelected

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
/**
 * Return true if this Resource is selected.
 * @param r the Resource to check.
 * @return whether the Resource was selected.
 * @throws BuildException if an error occurs.
 */
public boolean isSelected(Resource r) {
    if ((clazz == null) == (type == null)) {
        throw new BuildException(ONE_ONLY);
    }
    Class<?> c = clazz;
    if (type != null) {
        if (project == null) {
            throw new BuildException(
                "No project set for InstanceOf ResourceSelector; the type attribute is invalid.");
        }
        AntTypeDefinition d = ComponentHelper.getComponentHelper(
            project).getDefinition(ProjectHelper.genComponentName(uri, type));
        if (d == null) {
            throw new BuildException("type %s not found.",type);
        }
        try {
            c = d.innerGetTypeClass();
        } catch (ClassNotFoundException e) {
            throw new BuildException(e);
        }
    }
    return c.isAssignableFrom(r.getClass());
}
 
开发者ID:apache,项目名称:ant,代码行数:30,代码来源:InstanceOf.java


示例10: execute

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
/**
 * Create a new ant type based on the embedded tasks and types.
 */
@Override
public void execute() {
    if (nestedSequential == null) {
        throw new BuildException("Missing sequential element");
    }
    if (name == null) {
        throw new BuildException("Name not specified");
    }

    name = ProjectHelper.genComponentName(getURI(), name);

    MyAntTypeDefinition def = new MyAntTypeDefinition(this);
    def.setName(name);
    def.setClass(MacroInstance.class);

    ComponentHelper helper = ComponentHelper.getComponentHelper(
        getProject());

    helper.addDataTypeDefinition(def);
    log("creating macro  " + name, Project.MSG_VERBOSE);
}
 
开发者ID:apache,项目名称:ant,代码行数:25,代码来源:MacroDef.java


示例11: processTasks

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
private void processTasks() {
    if (implicitTag != null) {
        return;
    }
    for (Task task : unknownElements) {
        UnknownElement ue = (UnknownElement) task;
        String name = ProjectHelper.extractNameFromComponentName(
            ue.getTag()).toLowerCase(Locale.ENGLISH);
        if (getNsElements().get(name) == null) {
            throw new BuildException("unsupported element %s", name);
        }
        if (presentElements.get(name) != null) {
            throw new BuildException("Element %s already present", name);
        }
        presentElements.put(name, ue);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:18,代码来源:MacroInstance.java


示例12: execute

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
@Override
public void execute() throws BuildException {
    if (extensionPoint == null) {
        throw new BuildException("extensionPoint required", getLocation());
    }

    if (getOwningTarget() == null
            || !"".equals(getOwningTarget().getName())) {
        throw new BuildException(
                "bindtargets only allowed as a top-level task");
    }

    if (onMissingExtensionPoint == null) {
        onMissingExtensionPoint = OnMissingExtensionPoint.FAIL;
    }
    final ProjectHelper helper = (ProjectHelper) getProject().getReference(
            ProjectHelper.PROJECTHELPER_REFERENCE);

    for (String target : targets) {
        helper.getExtensionStack().add(new String[] {extensionPoint,
            target, onMissingExtensionPoint.name()});
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:24,代码来源:BindTargets.java


示例13: doesTypeExist

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
/**
 * test for a task or other ant type existing in the current project
 * @param typename the name of the type
 * @return true if the typename exists
 */
protected boolean doesTypeExist(String typename) {
    ComponentHelper helper =
        ComponentHelper.getComponentHelper(getProject());
    String componentName = ProjectHelper.genComponentName(uri, typename);
    AntTypeDefinition def = helper.getDefinition(componentName);
    if (def == null) {
        return false;
    }
    //now verify that the class has an implementation
    boolean found = def.getExposedClass(getProject()) != null;
    if (!found) {
        String text = helper.diagnoseCreationFailure(componentName, "type");
        log(text, Project.MSG_VERBOSE);
    }
    return found;
}
 
开发者ID:apache,项目名称:ant,代码行数:22,代码来源:TypeFound.java


示例14: newProject

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
private static Project newProject() throws IOException {
    setupBuildFile();
    Project project = new Project();
    project.setUserProperty("ant.file", buildFile.getAbsolutePath());
    project.init();
    DefaultLogger listener = new DefaultLogger();
    listener.setErrorPrintStream(System.err);
    listener.setOutputPrintStream(System.out);
    listener.setMessageOutputLevel(Project.MSG_INFO);
    ProjectHelper helper = ProjectHelper.getProjectHelper();
    project.addReference("ant.projectHelper", helper);
    project.setProperty("ftp.port", String.valueOf(ftpPort));
    project.setProperty("ssh.port", String.valueOf(sshPort));
    helper.parse(project, buildFile);
    project.addBuildListener(listener);
    return project;
}
 
开发者ID:Alexey1Gavrilov,项目名称:ExpectIt,代码行数:18,代码来源:AntHarnessTest.java


示例15: main

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
public static void main(String[] args) {

    DefaultLogger consoleLogger = new DefaultLogger();
    consoleLogger.setErrorPrintStream(System.err);
    consoleLogger.setOutputPrintStream(System.out);
    consoleLogger.setMessageOutputLevel(Project.MSG_INFO);

    File buildFile = new File("build.xml");
    Project p = new Project();
    p.addBuildListener(consoleLogger);
    p.setUserProperty("ant.file", buildFile.getAbsolutePath());
    p.init();
    ProjectHelper helper = ProjectHelper.getProjectHelper();
    p.addReference("ant.projectHelper", helper);
    helper.parse(p, buildFile);
    p.executeTarget("test");

  }
 
开发者ID:perdian,项目名称:ant-webstart,代码行数:19,代码来源:TestAnt.java


示例16: install

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
static void install(Map<String, String> options)
{
    // Initialize an Ant project from the build file
    Project project = new Project();
    project.setBaseDir(new File(System.getProperty("user.dir"))); // XXX current dir?

    ProjectHelper projectHelper = ProjectHelper.getProjectHelper();
    project.addReference(ProjectHelper.PROJECTHELPER_REFERENCE, projectHelper);
    URL buildResource = Installer.class.getResource("/build.xml");
    projectHelper.parse(project, buildResource);

    // Configure the project
    project.setProperty("ivySettings",
                Installer.class.getResource("/ivysettings.xml").toString());

    // Select the target operation

    String target;
    if (options.containsKey(OPT_TARGET))
        target = options.get(OPT_TARGET);
    else
        target = project.getDefaultTarget();

    // Install
    project.executeTarget(target);
}
 
开发者ID:mwoodiupui,项目名称:DSpace-installer,代码行数:27,代码来源:Installer.java


示例17: invokeAntBuild

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
private File invokeAntBuild(String pathToBuildFile) throws URISyntaxException {
    File buildFile = new File(this.getClass().getResource(pathToBuildFile).toURI());

    File targetDirectory = createTemporaryOutputFolder();

    Project project = new Project();
    project.setUserProperty("ant.file", buildFile.getAbsolutePath());
    project.setUserProperty("targetDirectory", targetDirectory.getAbsolutePath());
    project.init();

    ProjectHelper helper = ProjectHelper.getProjectHelper();
    project.addReference("ant.projecthelper", helper);
    helper.parse(project, buildFile);

    project.executeTarget(project.getDefaultTarget());

    return targetDirectory;
}
 
开发者ID:fge,项目名称:jsonschema2pojo,代码行数:19,代码来源:Jsonschema2PojoTaskIT.java


示例18: importBuild

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
public void importBuild(Object antBuildFile, Transformer<? extends String, ? super String> taskNamer) {
    File file = gradleProject.file(antBuildFile);
    final File baseDir = file.getParentFile();

    Set<String> existingAntTargets = new HashSet<String>(getAntProject().getTargets().keySet());
    File oldBaseDir = getAntProject().getBaseDir();
    getAntProject().setBaseDir(baseDir);
    try {
        getAntProject().setUserProperty(MagicNames.ANT_FILE, file.getAbsolutePath());
        ProjectHelper.configureProject(getAntProject(), file);
    } catch (Exception e) {
        throw new GradleException("Could not import Ant build file '" + String.valueOf(file) + "'.", e);
    } finally {
        getAntProject().setBaseDir(oldBaseDir);
    }

    // Chuck away the implicit target. It has already been executed
    getAntProject().getTargets().remove("");

    // Add an adapter for each newly added target
    Set<String> newAntTargets = new HashSet<String>(getAntProject().getTargets().keySet());
    newAntTargets.removeAll(existingAntTargets);
    for (String name : newAntTargets) {
        final Target target = getAntProject().getTargets().get(name);
        String taskName = taskNamer.transform(target.getName());
        final AntTarget task = gradleProject.getTasks().create(taskName, AntTarget.class);
        configureTask(target, task, baseDir, taskNamer);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:30,代码来源:DefaultAntBuilder.java


示例19: createProject

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
/**
 * @return Factory method to create new Project instances
 */
public static Project createProject() {
    final Project project = new Project();

    final ProjectHelper helper = ProjectHelper.getProjectHelper();
    project.addReference(ProjectHelper.PROJECTHELPER_REFERENCE, helper);
    helper.getImportStack().addElement("AntBuilder"); // import checks that stack is not empty

    project.addBuildListener(new AntLoggingAdapter());

    project.init();
    project.getBaseDir();
    return project;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:AntUtil.java


示例20: invokeAntBuild

import org.apache.tools.ant.ProjectHelper; //导入依赖的package包/类
private void invokeAntBuild(String pathToBuildFile) throws URISyntaxException {
    File buildFile = new File(this.getClass().getResource(pathToBuildFile).toURI());

    Project project = new Project();
    project.setUserProperty("ant.file", buildFile.getAbsolutePath());
    project.setUserProperty("targetDirectory", schemaRule.getGenerateDir().getAbsolutePath());
    project.init();

    ProjectHelper helper = ProjectHelper.getProjectHelper();
    project.addReference("ant.projecthelper", helper);
    helper.parse(project, buildFile);

    project.executeTarget(project.getDefaultTarget());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:Jsonschema2PojoTaskIT.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PlatformConfig类代码示例发布时间:2022-05-21
下一篇:
Java XSElementDecl类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap