FWIW: "id" is some kind of _magic_ attribute dealt with at parsing time in
the project helper impl. I naively thought it was a regular 'attribute' with
a setter... --DD
package org.apache.tools.ant.helper;
public class ProjectHelperImpl extends ProjectHelper {
<snip/>
/**
* Scans an attribute list for the <code>id</code> attribute and
* stores a reference to the target object in the project if an
* id is found.
* <p>
* This method was moved out of the configure method to allow
* it to be executed at parse time.
*
* @see #configure(Object,AttributeList,Project)
*/
private void configureId(Object target, AttributeList attr) {
String id = attr.getValue("id");
if (id != null) {
project.addReference(id, target);
}
}
}
-----Original Message-----
From: Dominique Devienne [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 22, 2002 2:44 PM
To: 'Ant Users List'
Subject: RE: Building a Classpath
OK, I think I've got it this time:
String idname = "myid";
Path path = new Path(getProject(), classpath);
getProject().addReference(idname, path);
Let me know. --DD
-----Original Message-----
From: William E. Kempf [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 22, 2002 2:34 PM
To: Ant Users List
Subject: Re: Building a Classpath
There is no "setId()" method for org.apache.tools.ant.types.Path.
----- Original Message -----
From: "Dominique Devienne" <[EMAIL PROTECTED]>
To: "'Ant Users List'" <[EMAIL PROTECTED]>
Sent: Monday, July 22, 2002 2:20 PM
Subject: RE: Building a Classpath
> I think it should be simply path.setId("myid"); --DD
>
> -----Original Message-----
> From: William E. Kempf [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 22, 2002 2:16 PM
> To: Ant Users List
> Subject: Re: Building a Classpath
>
> ----- Original Message -----
> From: "Dominique Devienne" <[EMAIL PROTECTED]>
> To: "'Ant Users List'" <[EMAIL PROTECTED]>
> Sent: Monday, July 22, 2002 11:38 AM
> Subject: RE: Building a Classpath
>
>
> > Sound to me that your task should define a Ant 'Path' data type. Have
your
> > task ask for an 'id' name, and assign that id to the Path it creates
> (using
> > setId()). After your class as executed, you should be able to refer to
> that
> > id, as is <classpath refid="myid"/> inside <javac> for example. But
maybe
> > not, as real Ant committers will likely say soon. --DD
>
> I'm having trouble codifying this. Here's the basic code I've used to do
> what you mention above:
>
> Path path = new Path(getProject(), classpath);
> Reference ref = new Reference(id);
> path.setRefid(ref);
>
> When I try and use this in an ant script, however, I get the following
error
> on the line that calls the custom ant task:
>
> file:C:/build/build.xml:284: You must not specify more than one attribute
> when using refid
> at
> org.apache.tools.ant.types.DataType.tooManyAttributes(DataType.java:1
> 90)
> at org.apache.tools.ant.types.Path.setRefid(Path.java:174)
> at com.foo.ant.eclipse.ParseClassPath.endDocument(Unknown Source)
> at
> org.apache.xerces.parsers.AbstractSAXParser.endDocument(AbstractSAXPa
> rser.java:735)
> at
> org.apache.xerces.impl.XMLNamespaceBinder.endDocument(XMLNamespaceBin
> der.java:704)
> at
> org.apache.xerces.impl.dtd.XMLDTDValidator.endDocument(XMLDTDValidato
> r.java:945)
> at
> org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(XMLDocumentSc
> annerImpl.java:451)
> at
> org.apache.xerces.impl.XMLEntityManager.endEntity(XMLEntityManager.ja
> va:1228)
> at
> org.apache.xerces.impl.XMLEntityManager$EntityScanner.load(XMLEntityM
> anager.java:3275)
> at
> org.apache.xerces.impl.XMLEntityManager$EntityScanner.skipSpaces(XMLE
> ntityManager.java:2945)
> at
> org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.
> dispatch(XMLDocumentScannerImpl.java:1002)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XM
> LDocumentFragmentScannerImpl.java:333)
> at
> org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.jav
> a:524)
> at
> org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.jav
> a:580)
> at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
> at
> org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.j
> ava:1108)
> at com.fdr.ant.eclipse.EclipseClassPath.execute(Unknown Source)
> at org.apache.tools.ant.Task.perform(Task.java:317)
> at org.apache.tools.ant.Target.execute(Target.java:309)
> at org.apache.tools.ant.Target.performTasks(Target.java:334)
> at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
> at org.apache.tools.ant.Project.executeTargets(Project.java:1250)
> at org.apache.tools.ant.Main.runBuild(Main.java:610)
> at org.apache.tools.ant.Main.start(Main.java:196)
> at org.apache.tools.ant.Main.main(Main.java:235)
>
> Total time: 1 second
>
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>