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


Java Target.setName方法代码示例

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


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

示例1: 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();
   }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:22,代码来源:ForTask.java

示例2: 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;
	}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:20,代码来源:AntJavaCompilerTest.java

示例3: 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);
}
 
开发者ID:apache,项目名称:groovy,代码行数:26,代码来源:AntBuilder.java

示例4: getEchoTask

import org.apache.tools.ant.Target; //导入方法依赖的package包/类
public Echo getEchoTask() {
    Project project = new Project();
    project.setName("testProject");

    Target target = new Target();
    target.setName("testTarget");
    target.setProject(project);

    Echo.EchoLevel level = new Echo.EchoLevel();
    level.setValue("error");
    Echo echoTask = new Echo();
    echoTask.setOwningTarget(target);
    echoTask.setLevel(level);
    echoTask.setTaskName("echo");
    echoTask.setTaskType("echo");
    echoTask.setMessage("This is a sample message.");

    return echoTask;
}
 
开发者ID:ModelN,项目名称:build-management,代码行数:20,代码来源:ReportTest.java

示例5: MockProject

import org.apache.tools.ant.Target; //导入方法依赖的package包/类
public MockProject() {
    task = new Task() {
        public void execute() {
        }
    };
    task.setTaskName("testTask");
    target = new Target();
    target.setName("testTarget");
    target.setProject(this);
    target.addTask(task);
    task.setOwningTarget(target);
}
 
开发者ID:apache,项目名称:ant,代码行数:13,代码来源:ModifiedSelectorTest.java

示例6: runClass

import org.apache.tools.ant.Target; //导入方法依赖的package包/类
/**
 * Runs the given class via Apache Ant in the same JVM instance.
 * 
 * @param className
 *            class to be run
 */
private static void runClass(String className, String packageName, String outputDir) {

	Project project = new Project();
	project.setName("ClassRunner");
	project.init();

	Target target = new Target();
	target.setName(TARGET_NAME);

	Java task = new Java();
	Path path = task.createClasspath();
	path.createPathElement().setPath("./sootOutput/" + outputDir);
	path.createPathElement().setPath("./bin");

	// TODO: if we don't fork, why do I need to set the classpath?
	for (URL url : ((URLClassLoader) ClassLoader.getSystemClassLoader())
			.getURLs()) {
		path.createPathElement().setPath(url.getPath());
	}
	task.setClasspath(path);
	task.setClassname(packageName + "." + className);
	task.setFork(false);
	task.setFailonerror(true);
	task.setProject(project);

	target.addTask(task);

	project.addTarget(target);
	project.setDefault(TARGET_NAME);

	// TODO: check if this is right and explain why (the double execute)
	target.execute();
	project.executeTarget(project.getDefaultTarget());

}
 
开发者ID:proglang,项目名称:jgs,代码行数:42,代码来源:ClassRunner.java

示例7: fixedModulesBuild

import org.apache.tools.ant.Target; //导入方法依赖的package包/类
/** Execute targets which cannot fail and though throw BuildException */
private void fixedModulesBuild() throws BuildException {
    // Somewhat convoluted code because Project.executeTargets does not
    // eliminate duplicates when analyzing dependencies! Ecch.
    // build fixed modules first
    dummy = new Target ();
    dummyName = "nbmerge-" + getOwningTarget().getName();
    targets = getProject().getTargets();
    while (targets.contains (dummyName))
        dummyName += "-x";
    dummy.setName (dummyName);
    for (String fixedmodule : buildfixedmodules) {
        dummy.addDependency (targetprefix + fixedmodule);
    }
    getProject().addTarget(dummy);

    getProject().setProperty("fixedmodules-built",  "1" );
    @SuppressWarnings("unchecked")
    Vector<Target> fullList = getProject().topoSort(dummyName, targets);
    // Now remove earlier ones: already done.
    Vector<Target> doneList = getProject().topoSort(getOwningTarget().getName(), targets);
    List<Target> todo = new ArrayList<>(fullList.subList(0, fullList.indexOf(dummy)));
    todo.removeAll(doneList.subList(0, doneList.indexOf(getOwningTarget())));
    log("Going to execute targets " + todo);
    for (Target nexttargit: todo) {
        String targetname = nexttargit.getName();
        if ( builttargets.indexOf(targetname) < 0 ) {
            // XXX poor replacement for Project.fireTargetStarted etc.
            System.out.println(""); System.out.println(targetname + ":");
            try {
                nexttargit.execute();
            } catch (BuildException ex) {
                log("Failed to build target: " + targetname, Project.MSG_ERR);
                throw ex;
            }
            builttargets.addElement(targetname);
        }
    }

    builtmodules.addAll(buildfixedmodules); // add already built fixed modules to the list
    log("fixedmodules=" + buildfixedmodules, Project.MSG_DEBUG);
    log("builtmodules=" + builtmodules, Project.MSG_VERBOSE);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:44,代码来源:NbMerge.java

示例8: modulesBuild

import org.apache.tools.ant.Target; //导入方法依赖的package包/类
/** Execute targets which can fail _without_ throwing BuildException */
private void modulesBuild() throws BuildException {
    if ( ! failonerror ) {
        // build the rest of modules
        for (String module : buildmodules) {
            dummy = new Target ();
            dummyName = "nbmerge-" + getOwningTarget().getName() + "-" + module;
            while (targets.contains (dummyName))
                dummyName += "-x";
            dummy.setName (dummyName);
            dummy.addDependency (targetprefix + module);
            getProject().addTarget(dummy);
            @SuppressWarnings("unchecked")
            Vector<Target> fullList = getProject().topoSort(dummyName, targets);
            // Now remove earlier ones: already done.
            @SuppressWarnings("unchecked")
            Vector<Target> doneList = getProject().topoSort(getOwningTarget().getName(), targets);
            List<Target> todo = new ArrayList<>(fullList.subList(0, fullList.indexOf(dummy)));
            todo.removeAll(doneList.subList(0, doneList.indexOf(getOwningTarget())));
            
            Iterator<Target> targit = todo.iterator();
            try {
                while (targit.hasNext()) {
                    Target nexttargit = targit.next();
                    String targetname = nexttargit.getName();
                    if ( builttargets.indexOf(targetname) < 0 ) {
                        System.out.println(); System.out.println(targetname + ":");
                        nexttargit.execute();
                        builttargets.addElement(targetname);
                    }
                    
                }
                builtmodules.addElement(module);
            } catch (BuildException BE) {
                    log(BE.toString(), Project.MSG_WARN);
                    BE.printStackTrace();
                    failedmodules.addElement(module);
            }
        }
        log("builtmodules=" + builtmodules, Project.MSG_VERBOSE);
        log("failedmodules=" + failedmodules, Project.MSG_VERBOSE);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:44,代码来源:NbMerge.java

示例9: parse

import org.apache.tools.ant.Target; //导入方法依赖的package包/类
/**
 * Parse a source xml input.
 *
 * @param project the current project
 * @param source  the xml source
 * @exception BuildException if an error occurs
 */
@Override
public void parse(Project project, Object source) throws BuildException {
    getImportStack().addElement(source);
    AntXMLContext context = null;
    context = (AntXMLContext) project.getReference(REFID_CONTEXT);
    if (context == null) {
        context = new AntXMLContext(project);
        project.addReference(REFID_CONTEXT, context);
        project.addReference(REFID_TARGETS, context.getTargets());
    }
    if (getImportStack().size() > 1) {
        // we are in an imported file.
        context.setIgnoreProjectTag(true);
        Target currentTarget = context.getCurrentTarget();
        Target currentImplicit = context.getImplicitTarget();
        Map<String, Target>    currentTargets = context.getCurrentTargets();
        try {
            Target newCurrent = new Target();
            newCurrent.setProject(project);
            newCurrent.setName("");
            context.setCurrentTarget(newCurrent);
            context.setCurrentTargets(new HashMap<String, Target>());
            context.setImplicitTarget(newCurrent);
            parse(project, source, new RootHandler(context, mainHandler));
            newCurrent.execute();
        } finally {
            context.setCurrentTarget(currentTarget);
            context.setImplicitTarget(currentImplicit);
            context.setCurrentTargets(currentTargets);
        }
    } else {
        // top level file
        context.setCurrentTargets(new HashMap<String, Target>());
        parse(project, source, new RootHandler(context, mainHandler));
        // Execute the top-level target
        context.getImplicitTarget().execute();

        // resolve extensionOf attributes
        resolveExtensionOfAttributes(project);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:49,代码来源:ProjectHelper2.java

示例10: init

import org.apache.tools.ant.Target; //导入方法依赖的package包/类
/**
 * Initialisation routine called after handler creation
 * with the element name and attributes. The attributes which
 * this handler can deal with are: <code>"name"</code>,
 * <code>"depends"</code>, <code>"if"</code>,
 * <code>"unless"</code>, <code>"id"</code> and
 * <code>"description"</code>.
 *
 * @param tag Name of the element which caused this handler
 *            to be created. Should not be <code>null</code>.
 *            Ignored in this implementation.
 * @param attrs Attributes of the element which caused this
 *              handler to be created. Must not be <code>null</code>.
 *
 * @exception SAXParseException if an unexpected attribute is encountered
 *            or if the <code>"name"</code> attribute is missing.
 */
public void init(String tag, AttributeList attrs) throws SAXParseException {
    String name = null;
    String depends = "";
    String ifCond = null;
    String unlessCond = null;
    String id = null;
    String description = null;

    for (int i = 0; i < attrs.getLength(); i++) {
        String key = attrs.getName(i);
        String value = attrs.getValue(i);

        if ("name".equals(key)) {
            name = value;
            if (name.isEmpty()) {
                throw new BuildException("name attribute must not" + " be empty",
                        new Location(helperImpl.locator));
            }
        } else if ("depends".equals(key)) {
            depends = value;
        } else if ("if".equals(key)) {
            ifCond = value;
        } else if ("unless".equals(key)) {
            unlessCond = value;
        } else if ("id".equals(key)) {
            id = value;
        } else if ("description".equals(key)) {
            description = value;
        } else {
            throw new SAXParseException("Unexpected attribute \"" + key + "\"",
                    helperImpl.locator);
        }
    }

    if (name == null) {
        throw new SAXParseException("target element appears without a name attribute",
                helperImpl.locator);
    }

    target = new Target();

    // implicit target must be first on dependency list
    target.addDependency("");

    target.setName(name);
    target.setIf(ifCond);
    target.setUnless(unlessCond);
    target.setDescription(description);
    helperImpl.project.addTarget(name, target);

    if (id != null && !id.isEmpty()) {
        helperImpl.project.addReference(id, target);
    }

    // take care of dependencies

    if (depends.length() > 0) {
        target.setDepends(depends);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:78,代码来源:ProjectHelperImpl.java

示例11: compile

import org.apache.tools.ant.Target; //导入方法依赖的package包/类
/**
     * Compile generated code.
     *
     * @param outdir
     */
    private void compile(String outdir) throws Exception {
        String cp = null;
        try {
            BufferedReader br = new BufferedReader(
                    new FileReader(System.getProperty("basedir", ".") + "/target/cp.txt"));
            cp = br.readLine();
        } catch (Exception e) {
            // Don't care
        }
        if (cp == null) {
            cp = "";
        }

        //using the ant javac task for compilation
        Javac javaCompiler = new Javac();
        Project codeGenProject = new Project();
        Target compileTarget = new Target();

        compileTarget.setName(COMPILE_TARGET_NAME);
        compileTarget.addTask(javaCompiler);
        codeGenProject.addTarget(compileTarget);
        codeGenProject.setSystemProperties();
        javaCompiler.setProject(codeGenProject);
        javaCompiler.setIncludejavaruntime(true);
        javaCompiler.setIncludeantruntime(true);

        /*
          This harmless looking setFork is actually very important. unless the compiler is
          forked it wont work!
        */
        javaCompiler.setFork(true);

        //Create classpath - The generated output directories also become part of the classpath
        //reason for this is that some codegenerators(XMLBeans) produce compiled classes as part of
        //generated artifacts
        String classdir = outdir + "/classes";
        File outputLocationFile = new File(classdir);
        outputLocationFile.mkdir();
        Path classPath = new Path(codeGenProject, classdir);
        classPath.add(new Path(codeGenProject, TEST_CLASSES_DIR));
        classPath.addExisting(classPath.concatSystemClasspath(), false);
        for (int i = 0; i < moduleNames.length; i++) {
            classPath.add(new Path(codeGenProject,
                                   MODULE_PATH_PREFIX + moduleNames[i] + CLASSES_DIR));
        }
        classPath.add(new Path(codeGenProject, cp));

        javaCompiler.setClasspath(classPath);

        //set sourcePath - The generated output directories also become part of the sourcepath
        Path sourcePath = new Path(codeGenProject, outdir);
        sourcePath.setLocation(outputLocationFile);
        javaCompiler.setSrcdir(sourcePath);

        //output the classes into the output dir as well
        javaCompiler.setDestdir(outputLocationFile);
        javaCompiler.setDebug(true);
        javaCompiler.setVerbose(true);
        javaCompiler.execute();
//        codeGenProject.executeTarget(COMPILE_TARGET_NAME);
    }
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:67,代码来源:Test.java

示例12: compile

import org.apache.tools.ant.Target; //导入方法依赖的package包/类
/** @param outputLocation  */
private void compile(String outputLocation) {
    String cp = null;
    try {
        BufferedReader br = new BufferedReader(
                new FileReader(System.getProperty("basedir", ".") + "/target/cp.txt"));
        cp = br.readLine();
    } catch (Exception e) {
        // Don't care
    }
    if (cp == null) {
        cp = "";
    }

    //using the ant javac task for compilation
    Javac javaCompiler = new Javac();
    Project codeGenProject = new Project();
    Target compileTarget = new Target();

    compileTarget.setName(COMPILE_TARGET_NAME);
    compileTarget.addTask(javaCompiler);
    codeGenProject.addTarget(compileTarget);
    codeGenProject.setSystemProperties();
    javaCompiler.setProject(codeGenProject);
    javaCompiler.setIncludejavaruntime(true);
    javaCompiler.setIncludeantruntime(true);

    /*
      This harmless looking setFork is actually very important. unless the compiler is
      forked it wont work!
    */
    javaCompiler.setFork(true);

    //Create classpath - The generated output directories also become part of the classpath
    //reason for this is that some codegenerators(XMLBeans) produce compiled classes as part of
    //generated artifacts
    File outputLocationFile = new File(outputLocation);
    Path classPath = new Path(codeGenProject, outputLocation);
    classPath.addExisting(classPath.concatSystemClasspath(), false);
    for (int i = 0; i < moduleNames.length; i++) {
        classPath.add(new Path(codeGenProject,
                               MODULE_PATH_PREFIX + moduleNames[i] + CLASSES_DIR));
    }

    classPath.add(new Path(codeGenProject, cp));

    javaCompiler.setClasspath(classPath);

    //set sourcePath - The generated output directories also become part of the sourcepath
    Path sourcePath = new Path(codeGenProject, outputLocation);
    sourcePath.setLocation(outputLocationFile);
    javaCompiler.setSrcdir(sourcePath);

    //output the classes into the output dir as well
    javaCompiler.setDestdir(outputLocationFile);
    javaCompiler.setVerbose(true);
    javaCompiler.execute();

}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:60,代码来源:WSDL2JavaSuccessTestBase.java

示例13: parseLine

import org.apache.tools.ant.Target; //导入方法依赖的package包/类
/**
     * Parse a line from a log file.  If the line is invalid, a null will be 
     * returned.
     *
     * @param   line    Text to be parsed
     * @param   hasStack  True if the line contains execution stack information
     * @return  Information about the log entry line
     */
    public static LogEntry parseLine(String line, boolean hasStack) {
        LogEntry entry = new LogEntry();
        StringBuffer text = new StringBuffer(line);

        try {
            // Obtain the most recent date
            String timestamp = text.substring(0, DATE_FORMAT.length() + 1);
            SimpleDateFormat datefmt = new SimpleDateFormat(DATE_FORMAT);
            entry.setDate(datefmt.parse(timestamp.trim()));
            text = text.delete(0, DATE_FORMAT.length() + 1);

            // Obtain the message priority
            int spcIdx = text.toString().indexOf(" ");
            String priority = text.substring(0, spcIdx).trim();
            entry.setPriority(getPriorityAsInt(priority));
            text = text.delete(0, spcIdx);

            // Obtain the execution stack 
            if (hasStack) {
                int stackBegin = text.toString().indexOf("[");
                int stackEnd   = text.toString().indexOf("]");
                String stack = text.substring(stackBegin + 1, stackEnd).trim();
                String stackEntry = null;
                StringTokenizer stackTokenizer = new StringTokenizer(stack, STACK_DELIMITER);
                while (stackTokenizer.hasMoreTokens()) {
                    stackEntry = stackTokenizer.nextToken();
                    int eqIdx = stackEntry.indexOf("=");
                    String name = stackEntry.substring(eqIdx + 1);
                    if (stackEntry.startsWith(PROJECT)) {
                        Project prj = new Project();
                        prj.setName(name);
                        entry.add(prj);
                    } else if (stackEntry.startsWith(TARGET)) {
                        Target tgt = new Target();
                        tgt.setName(name);
                        entry.add(tgt);
                    } else if (stackEntry.startsWith(TASK)) {
                        Task tsk = new DummyTask();
                        tsk.setTaskName(name);
                        entry.add(tsk);
                    }
                }
                text = text.delete(0, stackEnd + 1);
            }

            // Assume that the remaining text is the message
            entry.setMessage(text.toString().trim());

        } catch (Exception ex) {
//System.out.println("Error parsing line: " + ex);
            entry = null;
        }

        return entry;
    }
 
开发者ID:ModelN,项目名称:build-management,代码行数:64,代码来源:LineLogger.java


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