/** * Adds a new task definition to the project. * Attempting to override an existing definition with an * equivalent one (i.e. with the same classname) results in * a verbose log message. Attempting to override an existing definition * with a different one results in a warning log message. * * @param taskName The name of the task to add. * Must not be <code>null</code>. * @param taskClass The full name of the class implementing the task. * Must not be <code>null</code>. * * @exception BuildException if the class is unsuitable for being an Ant * task. An error level message is logged before * this exception is thrown. * * @see #checkTaskClass(Class) */ public void addTaskDefinition(String taskName, Class<?> taskClass) { checkTaskClass(taskClass); AntTypeDefinition def = new AntTypeDefinition(); def.setName(taskName); def.setClassLoader(taskClass.getClassLoader()); def.setClass(taskClass); def.setAdapterClass(TaskAdapter.class); def.setClassName(taskClass.getName()); def.setAdaptToClass(Task.class); updateDataTypeDefinition(def); }
/** * Adds a new datatype definition. * Attempting to override an existing definition with an * equivalent one (i.e. with the same classname) results in * a verbose log message. Attempting to override an existing definition * with a different one results in a warning log message, but the * definition is changed. * * @param typeName The name of the datatype. * Must not be <code>null</code>. * @param typeClass The full name of the class implementing the datatype. * Must not be <code>null</code>. */ public void addDataTypeDefinition(String typeName, Class<?> typeClass) { final AntTypeDefinition def = new AntTypeDefinition(); def.setName(typeName); def.setClass(typeClass); updateDataTypeDefinition(def); project.log(" +User datatype: " + typeName + " " + typeClass.getName(), Project.MSG_DEBUG); }
private AntTypeDefinition getNestedType() { AntElementNode currentNode = antModel.getNode(cursorPosition, false); if (currentNode == null) { return null; } IAntElement parent = currentNode.getParentNode(); if (parent instanceof AntTaskNode) { String parentName = parent.getName(); if (hasNestedElements(parentName)) { AntTypeDefinition taskClass = getTaskClass(parentName); if (taskClass != null) { IntrospectionHelper helper = getIntrospectionHelper(taskClass); if (helper != null) { try { Class<?> nestedType = helper.getElementType(currentNode.getName()); // TODO probably a much better way to find the definition of a nested type than this AntTypeDefinition def = new AntTypeDefinition(); def.setClass(nestedType); def.setClassName(nestedType.getName()); return def; } catch (BuildException be) { // do nothing } } } } } return null; }
/** * Run the definition. * This registers the XML namespace (URI) as a namespace for * attributes. */ public void execute() { String componentName = ProjectHelper.nsToComponentName( getURI()); AntTypeDefinition def = new AntTypeDefinition(); def.setName(componentName); def.setClassName(AttributeNamespace.class.getName()); def.setClass(AttributeNamespace.class); def.setRestrict(true); def.setClassLoader(AttributeNamespace.class.getClassLoader()); ComponentHelper.getComponentHelper(getProject()) .addDataTypeDefinition(def); } }
AntTypeDefinition def = new AntTypeDefinition(); def.setName(name); def.setClass(ScriptDefBase.class); ComponentHelper.getComponentHelper( getProject()).addDataTypeDefinition(def);
def.setName(name); def.setClassName(classname); def.setClass(cl); def.setAdapterClass(adapterClass); def.setAdaptToClass(adaptToClass);
/** * Perform common operations after the object building. */ private void postInit() { taskLinkFinder = new LinkFinderVisitor(this); // Change the component helper to instantiate SubAntHelper for subant // task. final ComponentHelper helper = antProject.getReference("ant.ComponentHelper"); if (helper != null) { final AntTypeDefinition subAntDef = helper.getDefinition("subant"); if (subAntDef == null) { LOG.warn("No definition found for the subant task in ComponentHelper, disabling subant"); } else { subAntDef.setClass(SubAntHelper.class); } final AntTypeDefinition taskDefDef = helper.getDefinition("taskdef"); if (taskDefDef == null) { LOG.warn("No definition found for the taskdef task in ComponentHelper, some file may not load properly"); } else { taskDefDef.setClass(TaskDefHelper.class); } } else { LOG.warn("No component helper in current project"); } }