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


Java ProjectHelper.parse方法代码示例

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


在下文中一共展示了ProjectHelper.parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: compile

import org.apache.tools.ant.ProjectHelper; //导入方法依赖的package包/类
/**
 * Description: compile method that maintains the i/o streams after the task is done.
 * @param file path of the build xml to be executed
 * @param out current output stream
 * @param err current input stream
 */
public static void compile( String file, PrintStream out, PrintStream err) {
    
    // 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);
        System.setErr(err);
        System.setOut(out);
        
        
    } catch (Exception e) {}
}
 
开发者ID:bufferhe4d,项目名称:call-IDE,代码行数:34,代码来源:BuildSys.java

示例9: executeAntTask

import org.apache.tools.ant.ProjectHelper; //导入方法依赖的package包/类
/**
 * @param filePath     with the file path
 * @param errorStream  with the error stream
 * @param outputStream with the output stream
 * @param temporaryDir with the temporary directory
 * @throws APIRestGeneratorException with an occurred exception
 */
public void executeAntTask(final String filePath,
                           final PrintStream errorStream,
                           final PrintStream outputStream,
                           final String temporaryDir) throws APIRestGeneratorException
{
    final File buildFile  = new File(this.generatorBuilderPath + File.separator + this.antFile);
    final Project project = this.generateProject(filePath, errorStream, outputStream, temporaryDir, buildFile);

    try
    {
        project.fireBuildStarted();
        project.init();

        final ProjectHelper projectHelper = ProjectHelper.getProjectHelper();
        project.addReference(ConstantsAnt.ANT_REF_PROJECT_HELPER, projectHelper);
        projectHelper.parse(project, buildFile);

        project.executeTarget(this.getGoalTask());
        project.fireBuildFinished(null);
    }
    catch (BuildException buildException)
    {
        project.fireBuildFinished(buildException);

        final String errorString = "BuildException while calling the ANT task with the following parameters: [antFile: " +
                                   this.antFile +
                                   ", filePath: " + filePath + "]";
        AbstractAntExecutor.LOGGER.error(errorString, buildException);
        throw new APIRestGeneratorException(errorString, buildException);
    }
}
 
开发者ID:BBVA-CIB,项目名称:APIRestGenerator,代码行数:39,代码来源:AbstractAntExecutor.java

示例10: runAnt

import org.apache.tools.ant.ProjectHelper; //导入方法依赖的package包/类
/**
 * Execute an ant script.
 * 
 * @param buildFile the ant script
 * @throws Exception if ant script execution fails
 */
protected void runAnt(final File buildFile) throws Exception {
    final Project project = new Project();
    project.addBuildListener(new TestLogger());
    project.setCoreLoader(this.getClass().getClassLoader());
    project.init();
    ProjectHelper helper = ProjectHelper.getProjectHelper();
    project.addReference("ant.projectHelper", helper);
    helper.parse(project, buildFile);
    Vector < String > targets = new Vector < String >();
    targets.addElement(project.getDefaultTarget());
    project.executeTargets(targets);
}
 
开发者ID:legsem,项目名称:legstar-cob2xsd,代码行数:19,代码来源:Cob2XsdTaskTest.java

示例11: runSetup

import org.apache.tools.ant.ProjectHelper; //导入方法依赖的package包/类
/**
 * Runs the given database configuration (~setup) on an AWS database instance. Make sure the setup
 * fits the database (e.g. a MSSQL setup for a MSSQL database).
 */
private void runSetup(DBInstance dbInstance, Database database) {
  String setup = database.getSetup();
  String buildFilePath = new LocaleRepository().getLocation() + SLASH + setup + "/build.xml";
  Endpoint endpoint = dbInstance.getEndpoint();
  File buildFile = new File(buildFilePath);

  this.console.write("Run database setup " + buildFilePath);
  this.console.write("Endpoint " + endpoint);

  Project project = new Project();
  project.setUserProperty(Variable.ANT_FILE, buildFile.getAbsolutePath());
  project.setUserProperty(Variable.DEST_ROOT_LOCAL, new LocaleRepository().getLocation() + SLASH
      + "tmp");
  project.setUserProperty(Variable.DB_SERVER, endpoint.getAddress());
  project.setUserProperty(Variable.DB_PORT, endpoint.getPort().toString());
  project.setUserProperty(Variable.DB_USER, database.getUsername());
  project.setUserProperty(Variable.DB_PASSWORD, database.getPassword());
  project.setUserProperty(Variable.ENV_NLS_LANG, "American_America.UTF8");
  project.setUserProperty(Variable.HEADLESS, "true");
  project.init();

  DefaultLogger consoleLogger = createConsoleLogger();
  project.addBuildListener(consoleLogger);

  ProjectHelper helper = ProjectHelper.getProjectHelper();
  project.addReference("ant.projectHelper", helper);
  helper.parse(project, buildFile);
  project.executeTarget(project.getDefaultTarget());

  this.console.newLine();
}
 
开发者ID:tuhrig,项目名称:DeployMan,代码行数:36,代码来源:Launcher.java

示例12: AntTargetExecution

import org.apache.tools.ant.ProjectHelper; //导入方法依赖的package包/类
public AntTargetExecution(final String projectUrl, final String target) {

		File buildfile = new File(projectUrl + "//build.xml");
		Project project = new Project();

		project.setUserProperty("ant.file", projectUrl + "//build.xml");
//		project.setProperty("java.home", "C://Program Files (x86)//Java/jdk1.7.0_25//bin");
		DefaultLogger antDefaultLogger = new DefaultLogger();
		antDefaultLogger.setEmacsMode(true);
		antDefaultLogger.setErrorPrintStream(System.err);
		antDefaultLogger.setOutputPrintStream(System.out);

		antDefaultLogger.setMessageOutputLevel(Project.MSG_INFO);
		project.addBuildListener(antDefaultLogger);

		try {
			project.fireBuildStarted();
			project.init();
			ProjectHelper helper = ProjectHelper.getProjectHelper();
			project.addReference("ant.projectHelper", helper);
			helper.parse(project, buildfile);

			project.executeTarget(target);
			project.fireBuildFinished(null);

		} catch (BuildException e) {
			OuZaLogger.LOGGER.error("build expection", e);
		}
	}
 
开发者ID:hadri-oussama,项目名称:ouza,代码行数:30,代码来源:AntTargetExecution.java

示例13: runAntScript

import org.apache.tools.ant.ProjectHelper; //导入方法依赖的package包/类
private void runAntScript() {
	Project ant = new Project();
	DefaultLogger consoleLogger = new DefaultLogger();
	consoleLogger.setErrorPrintStream(System.err);
	consoleLogger.setOutputPrintStream(System.out);
	consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
	ant.addBuildListener(consoleLogger);
	ant.init();
	ProjectHelper helper = new ProjectHelperImpl();
	helper.parse(ant, new File(filename));
	ant.executeTarget(ant.getDefaultTarget());
}
 
开发者ID:ibissource,项目名称:iaf,代码行数:13,代码来源:FileSender.java

示例14: AntRunner

import org.apache.tools.ant.ProjectHelper; //导入方法依赖的package包/类
public AntRunner(IResourceService resourceService, FileObject antFile, FileObject baseDir,
    Map<String, String> properties, @SuppressWarnings("unused") @Nullable URL[] classpaths,
    @Nullable BuildListener listener) {
    this.antProject = new Project();

    final File localAntFile = resourceService.localFile(antFile);
    final File localBaseDir = resourceService.localPath(baseDir);

    // TODO: use classpaths

    antProject.setProperty(MagicNames.ANT_FILE, localAntFile.getPath());
    antProject.setBaseDir(localBaseDir);
    antProject.init();
    if(listener != null) {
        antProject.addBuildListener(listener);
    }

    final PropertyHelper propHelper = PropertyHelper.getPropertyHelper(antProject);
    antProject.addReference(MagicNames.REFID_PROPERTY_HELPER, propHelper);
    for(Entry<String, String> property : properties.entrySet()) {
        propHelper.setUserProperty(property.getKey(), property.getValue());
    }

    final ProjectHelper projectHelper = ProjectHelper.getProjectHelper();
    antProject.addReference(MagicNames.REFID_PROJECT_HELPER, projectHelper);
    projectHelper.parse(antProject, localAntFile);
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:28,代码来源:AntRunner.java

示例15: runProxyGenerateTask

import org.apache.tools.ant.ProjectHelper; //导入方法依赖的package包/类
/**
 * Run the task.
 *
 * @param outputDir
 *            the output directory.
 * @param destinationPackage
 *            the destination package name.
 * @throws IOException
 */
private void runProxyGenerateTask(final File outputDir, final String destinationPackage)
        throws IOException {
    final BuildLogger logger = new DefaultLogger();
    logger.setMessageOutputLevel(Project.MSG_INFO);
    logger.setOutputPrintStream(System.out);
    logger.setErrorPrintStream(System.out);
    logger.setEmacsMode(true);

    final ProjectHelper ph = ProjectHelper.getProjectHelper();
    final Project p = new Project();
    p.addBuildListener(logger);
    p.init();
    p.addReference("ant.projectHelper", ph);

    final URL[] urls =
            ((URLClassLoader) (Thread.currentThread().getContextClassLoader())).getURLs();
    final StringBuffer classPath = new StringBuffer();
    for (final URL url : urls) {
        classPath.append(new File(url.getPath()));
        classPath.append(System.getProperty("path.separator"));
    }
    classPath.append("src/test/resources/test-webservices.jar");

    // set properties
    p.setUserProperty("client.src.dir", outputDir.getAbsolutePath());
    p.setUserProperty("task.classpath", classPath.toString());

    if (destinationPackage != null) {
        p.setUserProperty("destinationPackage", destinationPackage);
    }

    ph.parse(p, new File("src/test/resources/restProxyGenBuild.xml"));
    p.executeTarget("restProxyGen");

    // ensure all files are generated
    final Set<String> expectedFiles =
            new HashSet<>(FileUtils.readLines(new File(
                    "src/test/resources/test-weservices-files.txt")));
    final File packageDir =
            new File(outputDir, destinationPackage.replaceAll("\\.", File.separator));
    final Set<String> actualFiles = new HashSet<String>();
    for (final File file : packageDir.listFiles()) {
        if (file.isFile()) {
            actualFiles.add(file.getName());
        }
    }

    assertEquals(expectedFiles, actualFiles);
}
 
开发者ID:strandls,项目名称:alchemy-rest-client-generator,代码行数:59,代码来源:RestProxyGeneratorTest.java


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