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


Java Echo.execute方法代码示例

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


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

示例1: writeTextToFile

import org.apache.tools.ant.taskdefs.Echo; //导入方法依赖的package包/类
public static void writeTextToFile(String text, File file) {
        ensureParentFolderExists(file);

        Echo echo = new Echo();
        echo.setProject(new Project());
        echo.addText(text);
        echo.setFile(file);
        echo.execute();
}
 
开发者ID:rimerosolutions,项目名称:ant-wrapper,代码行数:10,代码来源:IOUtils.java

示例2: main

import org.apache.tools.ant.taskdefs.Echo; //导入方法依赖的package包/类
public static void main(String[] args) {
	// global ant project settings
	Project project = new Project();
	project.setBaseDir(new File(System.getProperty("user.dir")));
	project.init();
	DefaultLogger logger = new DefaultLogger();
	project.addBuildListener(logger);
	logger.setOutputPrintStream(System.out);
	logger.setErrorPrintStream(System.err);
	logger.setMessageOutputLevel(Project.MSG_INFO);
	System.setOut(new PrintStream(new DemuxOutputStream(project, false)));
	System.setErr(new PrintStream(new DemuxOutputStream(project, true)));
	project.fireBuildStarted();

	Throwable caught = null;
	try {
		// an echo example
		Echo echo = new Echo();
		echo.setTaskName("Echo");
		echo.setProject(project);
		echo.init();
		echo.setMessage("Launching ...");
		echo.execute();

		
		/** initialize an java task **/
		Java javaTask = new Java();
		javaTask.setNewenvironment(true);
		javaTask.setTaskName("runjava");
		javaTask.setProject(project);
		javaTask.setFork(true);
		javaTask.setFailonerror(true);
		javaTask.setClassname(MyClassToLaunch.class.getName());
		
		// add some vm args
		Argument jvmArgs = javaTask.createJvmarg();
		jvmArgs.setLine("-Xms512m -Xmx512m");
		
		// added some args for to class to launch
		Argument taskArgs = javaTask.createArg();
		taskArgs.setLine("bla path=/tmp/");
		
		Path classPath = new Path(project, new File(System.getProperty("user.dir") + "/bin/test").getAbsolutePath());
		javaTask.setClasspath(classPath);
		
		javaTask.init();
		int ret = javaTask.executeJava();
		System.out.println("return code: " + ret);

	} catch (BuildException e) {
		caught = e;
	}
	project.log("finished");
	project.fireBuildFinished(caught);
}
 
开发者ID:th-schwarz,项目名称:pmcms,代码行数:56,代码来源:MyLauncher.java

示例3: execute

import org.apache.tools.ant.taskdefs.Echo; //导入方法依赖的package包/类
public void execute() {
	// Make sure we have all the required fields set.
	if (outFile == null) {
		throw new BuildException("The outFile attribute is required");
	}


	// First, populate all of the properties we care about for this task.
	if (getProject().getProperty("ant.build.native.toolchain") != null) {
		this.setToolchain(getProject().getProperty("ant.build.native.toolchain"));
	}

	if (getProject().getProperty("ant.build.native.host") != null) {
		this.setHost(getProject().getProperty("ant.build.native.host"));
	}


	// Setup the compiler.
	LinkerAdapter linker = ToolchainFactory.getLinker(toolchain);
	linker.setProject(getProject());
	linker.setOutFile(outFile);

	if (host != null && host.length() > 0) {
		// Prepend the host string to the executable.
		linker.setExecutable(host + '-' + linker.getExecutable());
	}

	for (AbstractFeature feat : features) {
		if (feat.isIfConditionValid() && feat.isUnlessConditionValid()) {
			linker.addArg(feat);
		}
	}

	long newest = 0;
	Iterator<File> inFile = linker.getInFiles();
	while (inFile.hasNext()) {
		long modified = inFile.next().lastModified();

		if (newest < modified) {
			newest = modified;
		}
	}

	if (newest >= outFile.lastModified()) {
		// Print the executed command.
		Echo echo = (Echo) getProject().createTask("echo");
		echo.setTaskName(this.getTaskName());
		echo.setAppend(true);

		// Create an exec task to run a shell.  Using the current shell to
		// execute commands is required for Windows support.
		ExecTask shell = (ExecTask) getProject().createTask("exec");
		shell.setTaskName(this.getTaskName());
		shell.setFailonerror(true);
		//shell.setDir(dir);

		echo.addText(linker.getExecutable());
		shell.setExecutable(linker.getExecutable());

		Iterator<String> args = linker.getArgs();
		while (args.hasNext()) {
			String arg = args.next();

			echo.addText(" " + arg);
			shell.createArg().setLine(arg);
		}

		echo.execute();
		shell.execute();
	}
}
 
开发者ID:kwhat,项目名称:jnitasks,代码行数:72,代码来源:LdTask.java

示例4: execute

import org.apache.tools.ant.taskdefs.Echo; //导入方法依赖的package包/类
@Override
public void execute() throws BuildException {
	// Set the command to execute along with any required arguments.
	StringBuilder command = new StringBuilder(AutoreconfTask.cmd);

	// Take care of the optional arguments.
	if (!this.quiet) {
		command.append(" --verbose");
	}

	if (this.force) {
		command.append(" --force");
	}

	if (this.install) {
		command.append(" --install");
	}

	// Include arguments for nested Include.
	Iterator<AutoreconfTask.Include> iterator = includes.iterator();
	while (iterator.hasNext()) {
		AutoreconfTask.Include include = iterator.next();

		if (include.isIfConditionValid() && include.isUnlessConditionValid()) {
			if (include.isPrepend()) {
				command.append(" -B").append(include.getPath());
			}
			else {
				command.append(" -I").append(include.getPath());
			}
		}
	}

	// Print the executed command.
	Echo echo = (Echo) getProject().createTask("echo");
	echo.addText(command.toString());
	echo.setTaskName(this.getTaskName());
	echo.execute();

	// Create an exec task to run a shell.  Using the current shell to
	// execute commands is required for Windows support.
	ExecTask shell = (ExecTask) getProject().createTask("exec");
	shell.setTaskName(this.getTaskName());

	shell.setDir(dir);
	shell.setExecutable("sh");
	shell.setFailonerror(true);

	shell.createArg().setValue("-c");
	shell.createArg().setValue(command.toString());

	shell.execute();
}
 
开发者ID:kwhat,项目名称:jnitasks,代码行数:54,代码来源:AutoreconfTask.java


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