You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by "Alexey N. Solofnenko" <A....@mdl.com> on 2005/05/06 02:26:41 UTC
RFC: metadata (annotations) in ANT
Hello,
As you may noticed, my primary love are executors. Projects become
bigger and bigger, and their build speed becomes more and more
important. As a private project, I implemented parallel executor to take
advantage of multi-CPU computers.It works with simple projects,
unfortunately in the real life projects, one information is missing -
what targets cannot be executed simultaneously. It is possible to add
"mutexes" attribute to the target and continue, but eventually we will
come to the point when we create too many attributes that are needed
only in some specific situations. So instead of adding N+1 attribute, it
is possible to use metadata facility similar to ones in Java or C# -
generic annotations for targets (and tasks). When I wrote "and tasks", I
was thinking about <macrodef>s - it is very convenient to specify custom
annotations within <macrodef>s that will affect targets (there was a
similar discussion before, that <macrodef>s should be able to add
dependencies on targets that use the macros).
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.
--
------------------------------------------------------------------------
/ Alexey N. Solofnenko
home: http://trelony.cjb.net/
/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: RFC: metadata (annotations) in ANT
Posted by "Alexey N. Solofnenko" <A....@mdl.com>.
Hello,
Please see my answers inline.
Stefan Bodewig wrote:
>On Thu, 05 May 2005, Alexey N. Solofnenko <A....@mdl.com>
>wrote:
>
>
>
>>So instead of adding N+1 attribute, it is possible to use metadata
>>facility similar to ones in Java or C# - generic annotations for
>>targets (and tasks).
>>
>>
>
>One alternative would be to use namespace aware attributes, making Ant
>ignore attributes in namespaces it didn't understand but still store
>them (in an identity map for example).
>
>I must confess that I don't follow your usecases, though. So far I
>don't even understand your approach to parallel execution based on
>such metadata, your example might be too terse or I should go to
>bugzilla or the mailing list archives to get the context. Dunno.
>
>
>
>> Annotations are defined using XML processing instructions in
>> format <?name attr="value"...?>
>>
>>
>
>Ouch.
>
>Any way that worked without PIs would be better IMHO.
>
>
>
PIs are good that the do not change original XML, so they can be
invisible to programs that do not understand them.
>>IdentityHashMap was introduced in Java 1.4. This would be a good
>>reason to drop 1.3 support in ANT (discussed separately),
>>
>>
>
>We haven't even dropped 1.2 support 8-)
>
>
We will need to work it out. System.identityHashCode() is there from 1.1.
>
>
>>Possible uses:
>>- for parallel executor: <?mutex names="test-mutex1,remote-test-mutex"?>
>> <target name="some-test">
>>
>>
>
>what would that mean? And what would it mean for your parallel
>executor if I don't mark up my build file at all? Maybe I can't
>because I'm checking it out from somewhere else.
>
>
>
That means no targets with the same mutex name specified can be executed
concurrently (for example, only one target with "test-mutex1" mutex
specified).
>>- for distributed executor:
>> <?prerequisite name="Linux" min-version="2.4"?>
>> <?prerequisite name="InstallShield" version="6.1"?>
>> <?option name="support-unc-path" value="no"?>
>>
>>
>
>This completely loses me. Is the first one the equivalent of
>
><fail>
> <condition>
> <not>
> <and>
> <os family="unix"/>
> <os name="Linux"/>
> <os version="2.4"/>
> </and>
> </not>
> </condition>
></fail>
>
>
>
This is to select where this target should be executed (for example, a
target can be a Linux portion of the build, or it can require some third
party software installed on computer, for example, InstallShield). Not
all computers are equal.
>>- for group executor (to execute only targets from some subset):
>> <?group names="solaris,install"?>
>>
>>
>
>
>
This is a cheap replacement for real distributed executor (not all
dependencies have to be executed on all computers, they may already be
executed before).
>No idea, sorry.
>
>Stefan
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>For additional commands, e-mail: dev-help@ant.apache.org
>
>
--
------------------------------------------------------------------------
/ Alexey N. Solofnenko
home: http://trelony.cjb.net/
/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: RFC: metadata (annotations) in ANT
Posted by Stefan Bodewig <bo...@apache.org>.
On Thu, 05 May 2005, Alexey N. Solofnenko <A....@mdl.com>
wrote:
> So instead of adding N+1 attribute, it is possible to use metadata
> facility similar to ones in Java or C# - generic annotations for
> targets (and tasks).
One alternative would be to use namespace aware attributes, making Ant
ignore attributes in namespaces it didn't understand but still store
them (in an identity map for example).
I must confess that I don't follow your usecases, though. So far I
don't even understand your approach to parallel execution based on
such metadata, your example might be too terse or I should go to
bugzilla or the mailing list archives to get the context. Dunno.
> Annotations are defined using XML processing instructions in
> format <?name attr="value"...?>
Ouch.
Any way that worked without PIs would be better IMHO.
> IdentityHashMap was introduced in Java 1.4. This would be a good
> reason to drop 1.3 support in ANT (discussed separately),
We haven't even dropped 1.2 support 8-)
> Possible uses:
> - for parallel executor: <?mutex names="test-mutex1,remote-test-mutex"?>
> <target name="some-test">
what would that mean? And what would it mean for your parallel
executor if I don't mark up my build file at all? Maybe I can't
because I'm checking it out from somewhere else.
> - for distributed executor:
> <?prerequisite name="Linux" min-version="2.4"?>
> <?prerequisite name="InstallShield" version="6.1"?>
> <?option name="support-unc-path" value="no"?>
This completely loses me. Is the first one the equivalent of
<fail>
<condition>
<not>
<and>
<os family="unix"/>
<os name="Linux"/>
<os version="2.4"/>
</and>
</not>
</condition>
</fail>
> - for group executor (to execute only targets from some subset):
> <?group names="solaris,install"?>
No idea, sorry.
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: RFC: metadata (annotations) in ANT
Posted by Curt Arnold <ca...@apache.org>.
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