ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: RFC: metadata (annotations) in ANT
Date Fri, 06 May 2005 01:32:32 GMT

On May 5, 2005, at 7:26 PM, Alexey N. Solofnenko wrote:

> Proposal:
>
>  Annotations are defined using XML processing instructions in format 
> <?name attr="value"...?> (XML standard does not impose any structure 
> on a string after name in processing instructions, but we do) 
> specified before targets and tasks (I am not sure whether we should 
> support other XML nodes as well - <fileset>s could use some hints to 
> run faster in some situations). Annotations will be stored in identity 
> hash map (so no real object will have to be updated to support 
> annotations) within Project object and it will be updated 
> automatically when UnknownElements are converted into real objects. 
> IdentityHashMap was introduced in Java 1.4. This would be a good 
> reason to drop 1.3 support in ANT (discussed separately), but it is 
> also not difficult to our own IdentityHashMap using System 
> identityHashCode().
>
> API:
>
> class Annotation {
>  public final String name;
>  public final @readonly Map<String, String> attributes;
> }
>
> class Project {
>  private finally IdentityHashMap<Object, List<Annotations> > 
> annotations;
>
>  public List<Annotation> getAnnotations(Object o);
>  public List<Annotation> collectAnnotations(Target t); // collects all 
> annotations from target and its tasks
> }
>
> Possible uses:
> - for parallel executor:  <?mutex 
> names="test-mutex1,remote-test-mutex"?>
>  <target name="some-test">
>
> - for distributed executor:
>  <?prerequisite name="Linux" min-version="2.4"?>
>  <?prerequisite name="InstallShield" version="6.1"?>
>  <?option name="support-unc-path" value="no"?>
>
> - for group executor (to execute only targets from some subset):
>  <?group names="solaris,install"?>
>
> - Alexey.
>


A few comments:

Processing Instructions are the ugly step child of XML.  They were 
inherited from SGML and are generally shunned.

Metadata to an XML developer will typically bring to mind Resource 
Definition Format (http://www.w3.org/RDF/)

The proposed approach does not anticipate metadata outside of the ant 
file.  You may have different sets of metadata for the same build file 
depending on context or you may not have modification privileges to the 
build file.

RDF would handle this all nicely.  I'm not an RDF guru, so the 
following may be a little off:

Out-of-line equivalent of previous sample

<!--  statement about some-test target in build.xml,
           namespace prefixes for Dublin Core vocabulary and
           custom vocabulary are defined    -->
<rdf:RDF about="http://www.example.org/some-project/build.xml#some-test"
         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
          xmlns:dc="http://purl.org/dc/elements/1.1/"
         xmlns:stuff="http://www.example.org/my-ant-metadata">
        <dc:creator>Curt Arnold</dc:creator>
      <!--  there probably is a good set of URI's to identify OS's, this 
one gets the point across  -->
       <stuff:prerequisite href="http://www.linuxhq.com/kernel/v2.6/11/">
             <!--  statement about prerequisite statement   -->
             <rdf:RDF><stuff:min-version/></rdf:RDF>
        </stuff:prerequisite>
       <stuff:prerequisite 
href="http://www.installshield.com/versions/6.1"/>
       <stuff:support-unc-path>false</stuff:support-unc-path>
</rdf:RDF>


In line, it would just be added as a child (or children) of the element 
being described:

<target name="some-test">
      <rdf:RDF><dc:title xml:lang="en">some-test</dc:title><dc:title

xml:lang="fr">l'essai</dc:title></rdf:RDF>
</target>


The simplest API would be to be able to query with an URI and populate 
an Array of org.w3c.dom.Element

package org.apache.ant.metadata;

interface Model {
       Array<org.w3c.dom.Element> getProperties(final String uri);
}

  


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message