本文整理匯總了Java中org.apache.tools.ant.Project.addReference方法的典型用法代碼示例。如果您正苦於以下問題:Java Project.addReference方法的具體用法?Java Project.addReference怎麽用?Java Project.addReference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.tools.ant.Project
的用法示例。
在下文中一共展示了Project.addReference方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import org.apache.tools.ant.Project; //導入方法依賴的package包/類
@Override
public void execute() throws BuildException {
if (this.id == null || this.id.isEmpty()) {
throw new BuildException("The id has to be set."); //NOI18N
}
if (this.srcdir == null || !this.srcdir.isDirectory()) {
throw new BuildException("The srcdir has to point to a directory."); //NOI18N
}
if (this.includes == null || this.includes.isEmpty()) {
throw new BuildException("The includes has to be set."); //NOI18N
}
final Project prj = getProject();
final CosFileSet cfs = new CosFileSet();
cfs.setProject(prj);
cfs.setDir(this.srcdir);
for (String include : includes.split(",")) { //NOI18N
include = include.trim();
if (!include.isEmpty()) {
cfs.createInclude().setName(include);
}
}
prj.addReference(this.id, cfs);
}
示例2: altCompile
import org.apache.tools.ant.Project; //導入方法依賴的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) {}
}
示例3: createProject
import org.apache.tools.ant.Project; //導入方法依賴的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;
}
示例4: invokeAntBuild
import org.apache.tools.ant.Project; //導入方法依賴的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());
}
示例5: testDependencies
import org.apache.tools.ant.Project; //導入方法依賴的package包/類
public void testDependencies() throws Exception {
CreateDependencies d = new CreateDependencies();
Project prj = new Project();
DirSet ds = new DirSet();
File dependencies = new File(nb_all, "dependencies");
ds.setProject(prj);
ds.setDir(nb_all);
prj.addReference("x", ds);
prj.setProperty("nb_all", nb_all.getAbsolutePath());
d.setProject(prj);
d.getProject();
d.setRefid("x");
d.setDependencies(dependencies);
d.execute();
assertFileContent(dependencies,
"This project's dependencies\n" +
"\n" +
"\n" +
"Runtime dependencies:\n" +
"=====================\n" +
"\n" +
"From: XC\n" +
" - XA: XB (XD)\n" +
" License: Test license\n" +
"\n");
}
示例6: testCompileTimeDependencies
import org.apache.tools.ant.Project; //導入方法依賴的package包/類
public void testCompileTimeDependencies() throws Exception {
CreateDependencies d = new CreateDependencies();
Project prj = new Project();
DirSet ds = new DirSet();
File dependencies = new File(nb_all, "dependencies");
ds.setProject(prj);
ds.setDir(nb_all);
prj.addReference("x", ds);
prj.setProperty("nb_all", nb_all.getAbsolutePath());
d.setProject(prj);
d.getProject();
d.setRefid("x");
d.setDependencies(dependencies);
d.setSourceDependencies(true);
d.execute();
assertFileContent(dependencies,
"This project's dependencies\n" +
"\n" +
"\n" +
"Runtime dependencies:\n" +
"=====================\n" +
"\n" +
"From: XC\n" +
" - XA: XB (XD)\n" +
" License: Test license\n" +
"\n" +
"\n" +
"Compile time dependencies:\n" +
"==========================\n" +
"\n" +
"From: XC2\n" +
" - XA2: XB2 (XD2)\n" +
" License: Test license2\n" +
"\n");
}
示例7: compile
import org.apache.tools.ant.Project; //導入方法依賴的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) {}
}