本文整理汇总了Java中org.apache.tools.ant.Target类的典型用法代码示例。如果您正苦于以下问题:Java Target类的具体用法?Java Target怎么用?Java Target使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Target类属于org.apache.tools.ant包,在下文中一共展示了Target类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyFile
import org.apache.tools.ant.Target; //导入依赖的package包/类
static public void copyFile(File src, File obj) {
final class AntCopy extends Copy {
@SuppressWarnings("deprecation")
public AntCopy() {
project = new Project();
project.init();
taskType = "copy";
taskName = "copy";
target = new Target();
}
}
AntCopy ant = new AntCopy();
ant.setFile(src);
ant.setTofile(obj);
ant.execute();
}
示例2: configureTask
import org.apache.tools.ant.Target; //导入依赖的package包/类
private static void configureTask(Target target, AntTarget task, File baseDir, Transformer<? extends String, ? super String> taskNamer) {
task.setTarget(target);
task.setBaseDir(baseDir);
final List<String> taskDependencyNames = getTaskDependencyNames(target, taskNamer);
task.dependsOn(new AntTargetsTaskDependency(taskDependencyNames));
addDependencyOrdering(taskDependencyNames, task.getProject().getTasks());
}
示例3: BasicAntBuilder
import org.apache.tools.ant.Target; //导入依赖的package包/类
public BasicAntBuilder() {
// These are used to discard references to tasks so they can be garbage collected
Field collectorField;
try {
nodeField = AntBuilder.class.getDeclaredField("lastCompletedNode");
nodeField.setAccessible(true);
collectorField = AntBuilder.class.getDeclaredField("collectorTarget");
collectorField.setAccessible(true);
Target target = (Target) collectorField.get(this);
Field childrenField = Target.class.getDeclaredField("children");
childrenField.setAccessible(true);
children = (List) childrenField.get(target);
} catch (Exception e) {
throw new RuntimeException(e);
}
getAntProject().addDataTypeDefinition("gradleFileResource", AntFileResource.class);
getAntProject().addDataTypeDefinition("gradleBaseDirSelector", BaseDirSelector.class);
}
示例4: testInstallAllTargetWithClusters
import org.apache.tools.ant.Target; //导入依赖的package包/类
public void testInstallAllTargetWithClusters() {
InsertModuleAllTargets insert = new InsertModuleAllTargets();
insert.setProject(p);
insert.execute();
Object obj = p.getTargets().get("all-java.source.queries");
assertNotNull("Target found", obj);
Target t = (Target)obj;
Set<String> s = depsToNames(t.getDependencies());
assertEquals("One dep: " + s, 1, s.size());
assertEquals("Just dep on init", "init", s.iterator().next());
int callTargets = 0;
for (Task task : t.getTasks()) {
if (task instanceof CallTarget) {
callTargets++;
}
}
assertEquals("One call target to build super cluster", 1, callTargets);
}
示例5: testInstallAllTargetWithoutClusters
import org.apache.tools.ant.Target; //导入依赖的package包/类
public void testInstallAllTargetWithoutClusters() {
InsertModuleAllTargets insert = new InsertModuleAllTargets();
insert.setProject(p);
insert.setUseClusters(false);
insert.execute();
Object obj = p.getTargets().get("all-java.source.queries");
assertNotNull("Target found", obj);
Target t = (Target)obj;
Set<String> s = depsToNames(t.getDependencies());
assertEquals("Three dependencies: " + s, 5, s.size());
assertTrue("on init", s.contains("init"));
assertTrue("on all-openide.util", s.contains("all-openide.util"));
assertTrue("on all-openide.util.lookup", s.contains("all-openide.util.lookup"));
assertTrue("on all-api.annotations.common", s.contains("all-api.annotations.common"));
assertTrue("on all-openide.dialogs", s.contains("all-openide.dialogs"));
int callTargets = 0;
for (Task task : t.getTasks()) {
if (task instanceof CallTarget) {
callTargets++;
}
}
assertEquals("No call targes", 0, callTargets);
}
示例6: execute
import org.apache.tools.ant.Target; //导入依赖的package包/类
/**
* Execute all tasks.
*
* @exception BuildException Description of Exception
*/
public void execute() throws BuildException {
for ( int i = initValue; i < maxValue; i += inc ) {
if ( initName != null ) {
getProject().setUserProperty( initName, String.valueOf( i ) );
}
Target target = new Target();
target.setName( "for.subtarget" );
getProject().addOrReplaceTarget( target );
for ( Enumeration e = tasks.elements(); e.hasMoreElements(); ) {
Task task = (Task)e.nextElement();
addTaskToTarget( target, task );
}
target.execute();
}
}
示例7: addTaskToTarget
import org.apache.tools.ant.Target; //导入依赖的package包/类
private void addTaskToTarget( Target target, Task task ) {
UnknownElement replacement = new UnknownElement( taskType ); // shouldn't do taskType, for Ant 1.6 and later there is a getTaskType method
replacement.setProject( getProject() );
invokeMethod( replacement, "setTaskType", taskType );
replacement.setTaskName( task.getTaskName() );
replacement.setLocation( task.getLocation() );
replacement.setOwningTarget( target );
replacement.setRuntimeConfigurableWrapper( task.getRuntimeConfigurableWrapper() );
invokeMethod( task.getRuntimeConfigurableWrapper(), "setProxy", replacement );
replacement.maybeConfigure();
log("replacement is a " + replacement.getTaskName() + ", " + replacement.getClass().getName());
if (replacement instanceof TaskContainer) {
log("replacement is a TaskContainer");
invokeMethod(replacement, "handleChildren", new Object[]{this, this.getRuntimeConfigurableWrapper()});
}
target.addTask(replacement);
}
示例8: extracted
import org.apache.tools.ant.Target; //导入依赖的package包/类
private Target extracted(Project p) {
Target target = new Target() {
// @Override
// public Project getProject() {
// return p;
// }
};
target.setProject(p);
target.setName("Hello build");
target.setDescription("Runtime Adding Target");
Echo echo = new Echo();
echo.setMessage("Hello ant build");
echo.setProject(p);
target.addTask(echo);
return target;
}
示例9: removeFiles
import org.apache.tools.ant.Target; //导入依赖的package包/类
/**
* Removes files from a given zip file.
*
* @param zipFile name of the zip file to be modified
* @param removePattern pattern of the files to be removed
*
* @throws IOException
*/
public static void removeFiles(File zipFile, String removePattern) throws IOException {
String zipFileName = zipFile.getName();
File tmpFile = new File(zipFile.getCanonicalPath() + ".tmp");
Project antProject = new Project();
Target antTarget = new Target();
antProject.addTarget("zip", antTarget);
Zip zipTask = new Zip();
zipTask.setProject(antProject);
zipTask.setDestFile(tmpFile);
ZipFileSet set = new ZipFileSet();
set.setSrc(zipFile);
set.setExcludes(removePattern);
zipTask.addZipfileset(set);
antTarget.addTask(zipTask);
antTarget.execute();
zipFile.delete();
tmpFile.renameTo(new File(tmpFile.getParentFile(), zipFileName));
}
示例10: AntBuilder
import org.apache.tools.ant.Target; //导入依赖的package包/类
public AntBuilder(final Project project, final Target owningTarget) {
this.project = project;
/*
* GROOVY-4524: The following is not needed anymore as an ant Project already by default has inputhandler
* set to DefaultInputHandler. And if it is again set here, it mistakenly overrides the custom input handler
* if set using -inputhandler switch.
*/
//this.project.setInputHandler(new DefaultInputHandler());
collectorTarget = owningTarget;
antXmlContext = new AntXMLContext(project);
collectorTarget.setProject(project);
antXmlContext.setCurrentTarget(collectorTarget);
antXmlContext.setLocator(new AntBuilderLocator());
antXmlContext.setCurrentTargets(new HashMap<String, Target>());
implicitTarget = new Target();
implicitTarget.setProject(project);
implicitTarget.setName("");
antXmlContext.setImplicitTarget(implicitTarget);
// FileScanner is a Groovy utility
project.addDataTypeDefinition("fileScanner", FileScanner.class);
}
示例11: onDefineTarget
import org.apache.tools.ant.Target; //导入依赖的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;
}
示例12: onStartTarget
import org.apache.tools.ant.Target; //导入依赖的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;
}
示例13: zipDir
import org.apache.tools.ant.Target; //导入依赖的package包/类
static public void zipDir(File destFile, File zipFile) {
final class AntZIP extends Zip {
@SuppressWarnings("deprecation")
public AntZIP() {
project = new Project();
project.init();
taskType = "zip";
taskName = "zip";
target = new Target();
}
}
AntZIP zip = new AntZIP();
zip.setBasedir(zipFile);
zip.setDestFile(destFile);
zip.execute();
}
示例14: unzipFile
import org.apache.tools.ant.Target; //导入依赖的package包/类
static public void unzipFile(File destFile, File zipFile) {
final class Expander extends Expand {
@SuppressWarnings("deprecation")
public Expander() {
project = new Project();
project.init();
taskType = "unzip";
taskName = "unzip";
target = new Target();
}
}
Expander expander = new Expander();
expander.setSrc(zipFile);
expander.setDest(destFile);
expander.execute();
}
示例15: delDir
import org.apache.tools.ant.Target; //导入依赖的package包/类
static public void delDir(File dir) {
final class AntDelete extends Delete {
@SuppressWarnings("deprecation")
public AntDelete() {
project = new Project();
project.init();
taskType = "delete";
taskName = "delete";
target = new Target();
}
}
AntDelete ant = new AntDelete();
ant.setDir(dir);
ant.execute();
}