Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » B3 » Ideas on b3 "build files" using simple xtext based syntax...
Ideas on b3 "build files" using simple xtext based syntax... [message #489423] Fri, 02 October 2009 22:45 Go to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Hi,
I have been working with some ideas what an xtext based build file for
b3 could look like - how things like resolver configuration, and advice
can be expressed in a simple and compact way.

Below are some thoughts on what it could look like... (the ideas here
reflect what is available in the models I posted earlier).

Perhaps I got a bit carried away, but I am excited about the possibilities.

So - rip it apart please... ideas, questions, critique...

XText Syntax Ideas for b3 build files (version 0.1)

This document contains ideas for an xtext based syntax describing build
meta data. I have taken liberties with the syntax, you have to read it
with a "do what I mean" attitude, as this proposal otherwise may be very
difficult to handle for a parser. This first draft is just to vent some
ideas, not to nail down the exakt syntax.

As started to elaborate on some of things you may want to do in Xtext, I
found that I needed to describe some of the design ideas captured in the
models, so this text also includes some explanations of the b3 models.

The idea is that a b3 build file is used as input to b3 commands.
Commands in b3 are in practice just two basic commands - either
"import" (to populate the workspace), or "invoke" (to get the value (or
side effect) of a build unit part (e.g. MyProduct#createProductZip).
(Although, there may be other commands that can be issued that b3
handle, like querying, debugging, dumping, logging, etc. - but in
principle, there is just "import" and "invoke").

It is possible to do both import and return a result at the same time.
The only difference is that the "import" does not require specification
of a particular part, and that the typical use of "invoke" is to perform
it against what has already been imported to (or preexisted in) the
workspace, thus not requiring a resolver specification other than the
default (workspace and target platform).

CONTEXT
The b3 build file can be thought of as a configuration of the context in
which commands to b3 execute. The b3 context contains:
- units (the build units in the context)
- resolutions (the resolution of each required capability)
- advice (the set of advice to apply in the context)
- requests (the input request(s), and requests originating from required
capabilities)
- resolver (the network of resolvers to use to resolve
requests/requirements).

Each request sets up a new context (it may inherit from the default
context), and it is (optionally) configured with a build file.


RESOLVER
A context has a resolver network consisting of resolver nodes. Two
special nodes "first" and "best" are used to specify how the search is
conducted - resolvers in a "first" list results in the first found
resolution, and resolvers in a "best" list results in the resolution
with the highest score (compared to the request).

A b3 build file makes it possible to specify the resolution network with
a simple syntax.

The specified resolution node itself is a "first" type of node.

import org.eclipse.b3.resolvers.*; // import names of resolvers to
reduce typing

resolution {
TargetResolver;
WorkspaceResolver;
}

This specifies that an attempt is made to resolve against the target
platform, and if that fails against the Workspace. No options are
specified for the resolvers.

What if I want to resolver first from Target platform, but not for
certain tool bundles that, if I have them in the workspace, I would like
to get those instead of the installed. This could look something like this:

resolution {
WorkspaceResolver {
namePattern="org.myorg.mytool.*";
};
TargetResolver;
WorkspaceResolver;
}

Here is an example using best:

resolution {
TargetPlatformResolver;
WorkspaceResolver;
Best {
P2Resolver {
location = "http://www.someplace.good";
}
SVNResolver {
location = "svn+ssh://someplace.else";
...;
};
}
}

There are several settable properties in the different resolvers.
(Compare to Buckminster's Readers in the RMAP).

Additional features (TBD):
Here are some additional things I would like to be able to do:
- name top level resolution specifications
- reuse a named resolution in another resolution
- import resolutions from another build file, and reuse a named
resolution in the imported build file
- use of properties

Possibly also:
- specify an import with a translator to interpret the file in a
particular location

ADVICE

// advice sets values in the model
// similar to CSS
// An XPath is a query, it matches a set of nodes, where a value can be set
//
advice {
xpath = value;
...
xpath {
rel-path = value;
...
}

The xpath is relative to the context - which is analogous to the
"document" in XML/HTML.
At the root of the context there are:
- units (the build units in the context)
- resolutions (the resolution of each required capability)
- advice (the set of advice to apply in the context)
- requests (the input request(s), and requests originating from required
capabilities)
- resolver (the network of resolvers to use to resolve
requests/requirements).

It is unclear if it should be allowed to apply advice on all of these
(i.e. advice on advice). The idea is to primarily advice on requests,
and resolutions, and in some cases on units.

So here are some examples:
// All requests to org.myorg.projx.* should be requests for source
/requests[name=org.myorg.projx.*]/options/source = true;
// All requests to org.myorg.projx.* should be requests for mutable
/requests[name=org.myorg.projx.*]/options/mutable = true;

// shorthand for the two pieces of advice above
/requests[name=org.myorg.projx.*]/options {
source = true;
mutable = true;
}

// if I only need mutable source for the eclipse.features
/requests[name=org.myorg.projx.*, namespace="eclipse.feature"]/options/ {
source = true;
mutable = true;
}

Options include: source, mutable, branchTagPath, timestamp, revision,
resolverFilter, filterGroups, overlayPath, includeParts, excludeParts,
and prune.

Advice on resolutions
Here are some examples

// Place all of my organization's "core" components in the target platform
// (the rest goes to workspace by default).

/resolutions[name=org.myorg.core.*] /options {
materializer = org.eclipse.b3.targetPlatformMaterializer;
location = /where/it/should/be/stored;
conflictResolution = update;
}

It is possible to make very advanced advice:

/resolutions/[name=org.myorg.*]/subResolutions/resolution[na mespace= "org.myorg.annotations"]/options
{
materializer = org.eclipse.b3.workspaceMaterialzer;
location = /where/they/are/stored;
}

This would store all build units that provide a capability in the
namespace org.myorg.annotations in a particular location on disk and
link them to the workspace.

Advice on units
The advice on units is applied as units are resolved. This means that
the advice has an effect during the contexts lifetime, but as soon as
the operation is over, the live model will reflect the original meta
data translation.

The same advice can be applied again in some other context if needed.
Sometimes all that is required is to override some faulty meta data
(that the user wants to correct) to make resolution possible. As an
example, we want to override a components request for a particular
required capability. Once the components has been resolved it will
probably not build, the problem is corrected by the user and the unit
checked in. The next time, the overriding advice is not needed.

/units[name="org.myorg.projx.broken"]/requiredCapabilities[name= "org.myorg.x"]/versionRange
= [1.0.0, 3.0.0];

Creation of complex types.
Most of the time values are simply strings, or numbers, or there is a
simple translation from string form to the datatype required for a
settable attribute. Sometimes this is not possible, and a "new instance
operator" is required. This could look something like

path-expr = new RequiredCapability {
name = ...;
nameSpace = ...;
...
};

Synthetic nodes
It must be possible to address synthetic nodes in the document such as
the "before first" and "after last" positions in a list. This is done by
suffixing the xpath expression iwth ":synthetic node name"

e.g. /units[name=org.myorg.foo]/requiredCapabilities:first = new
RequiredCapability { ... }.

Lists
It must be possible to reference the list itself. Clear the list. Remove
an entry in the list, add an element first or last, and before or after
an element. (Have to look more at XPath to see how this is typically
done to give examples).

UNITS
As the advice mechanism is very powerful it is actually possible to
create build units directly in the b3 build file. This is useful in some
cases where a virtual/configuration unit is required to define the order
of dependencies. In many cases, creating an additional bundle or feature
that is only used for some special aspect of building/testing can be an
overkill - so it is quite convenient to declare it directly in the b3
build file.

Apart from this, the build units are mostly the result of an import, and
they may be advised (as described earlier).

REQUESTS
Requests, as you have already seen are the original "import statements"
and requests made by "required capabilities" in the resolution being
performed (as part of an import or an invocation). The requests can be
advised, but are otherwise not terribly interesting :). Note that it is
possible ro request something in any namespace, but that the resolution
will always resolve this into some build unit providing the capability
(analogous to how p2 does this).

RESOLUTIONS
Resolutions are the result of resolving - they tie the resulting build
units to the requirements that caused them to appear in the context.
Interesting, advanced things can be done with this as shown in the
advise section, but mainly this is a mechanism to tie everything
together and enable the invocation of actions that traverse the
resulting model.

(I probably forgot to describe something that is important... but this
post is already long enough as it is...)

- henrik
Re: Ideas on b3 "build files" using simple xtext based syntax... [message #489454 is a reply to message #489423] Sat, 03 October 2009 08:43 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
Hi Henrik,
Very cool indeed. And so much more readable then the dreaded XML. I think you got a lot of things covered. A few
comments inline:

On 10/03/2009 12:45 AM, Henrik Lindberg wrote:
> RESOLVER
> A context has a resolver network consisting of resolver nodes. Two
> special nodes "first" and "best" are used to specify how the search is
> conducted - resolvers in a "first" list results in the first found
> resolution, and resolvers in a "best" list results in the resolution
> with the highest score (compared to the request).
>
> A b3 build file makes it possible to specify the resolution network with
> a simple syntax.
>
> The specified resolution node itself is a "first" type of node.
>
> import org.eclipse.b3.resolvers.*; // import names of resolvers to
> reduce typing
>
> resolution {
> TargetResolver;
> WorkspaceResolver;
> }
>
I'm a bit confused by the terms 'resolution' and 'resolver'. A 'resolution' to me is something that a 'resolver'
produces, i.e. a BU annotaded with facts on how it got resolved. The bill of materials that you have between the
discovery phase (find where everything is) and the actual provisioning (now go get it) is constituted of resolutions.


> This specifies that an attempt is made to resolve against the target
> platform, and if that fails against the Workspace. No options are
> specified for the resolvers.
>
So in Buckminster terms this is more like the 'resourceMap', or 'resolverMap'. Isn't that a more descriptive term then
'resolution' ?

> Here is an example using best:
>
> resolution {
> TargetPlatformResolver;
> WorkspaceResolver;
> Best {
> P2Resolver {
> location = "http://www.someplace.good";
> }
> SVNResolver {
> location = "svn+ssh://someplace.else";
> ...;
> };
> }
> }
>
Just an idea, but given that many resolvers will consist of just a URI, would it be easy to create a short form? I.e.

resolution {
platform:/plugin/xxx;
platform:/resource://xxx;
Best {
p2:http://www.someplace.good";
svn:svn+ssh://someplace.else";
};
}

The 'platform' scheme is already recognized by Eclipse giving the host part a very special meaning (plugin basically
means TP, resource means workspace, etc.

If we add standard property expansion to this:

p2:http://www.someplace.good/updates-${eclipse.release}";

then we get a very compact form that will cover a lot of the cases we have today. The complex form must or course still
be available to make it possible to declare special namespaces, filters, etc. that will be important for source code
repositories in particular.


> ADVICE
>
> // advice sets values in the model
> // similar to CSS
> // An XPath is a query, it matches a set of nodes, where a value can be set
> //
> advice {
> xpath = value;
> ...
> xpath {
> rel-path = value;
> ...
> }
>
Why the term 'xpath' and not just 'path' ?

Regards,
Thomas Hallgren
Re: Ideas on b3 "build files" using simple xtext based syntax... [message #489458 is a reply to message #489454] Sat, 03 October 2009 12:08 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Thanks for the input, comments inline...

- henrik

On 10/3/09 10:43 AM, Thomas Hallgren wrote:
> On 10/03/2009 12:45 AM, Henrik Lindberg wrote:
>> RESOLVER
....omitted
>> resolution {
>> TargetResolver;
>> WorkspaceResolver;
>> }
>>
> I'm a bit confused by the terms 'resolution' and 'resolver'.
My bad. That was a typo. Should have been like this:
resolver {
TargetResolver;
WorkspaceResolver;
}

And the rest of the examples should also have used the keyword
"resolver" (not "resolution").


> Just an idea, but given that many resolvers will consist of just a URI,
> would it be easy to create a short form? I.e.
>
> resolution {
> platform:/plugin/xxx;
> platform:/resource://xxx;
> Best {
> p2:http://www.someplace.good";
> svn:svn+ssh://someplace.else";
> };
> }
>

I like the short form.

> If we add standard property expansion to this:
>
> p2:http://www.someplace.good/updates-${eclipse.release}";
>
Agree.

>> ADVICE
>> advice {
>> xpath = value;
>> ...
>> }
>>
> Why the term 'xpath' and not just 'path' ?
>
That is because I borrowed the syntax/style from XPath/XQuery :)
Re: Ideas on b3 "build files" using simple xtext based syntax... [message #489459 is a reply to message #489458] Sat, 03 October 2009 12:32 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
On 10/03/2009 02:08 PM, Henrik Lindberg wrote:

>> Why the term 'xpath' and not just 'path' ?
>>
> That is because I borrowed the syntax/style from XPath/XQuery :)
>
I kind of guessed that ;). But isn't one idea with this DSL to move away from XML?

- thomas
Re: Ideas on b3 "build files" using simple xtext based syntax... [message #489471 is a reply to message #489459] Sat, 03 October 2009 15:37 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Thomas Hallgren schrieb:
> On 10/03/2009 02:08 PM, Henrik Lindberg wrote:
>
>>> Why the term 'xpath' and not just 'path' ?
>>>
>> That is because I borrowed the syntax/style from XPath/XQuery :)
>>
> I kind of guessed that ;). But isn't one idea with this DSL to move
> away from XML?
I also stumbled across the x in xpath. I agree with Thomas that there
should be no x in a so much nicer format than XML ;-)

What about bpath?

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: Ideas on b3 "build files" using simple xtext based syntax... [message #489477 is a reply to message #489471] Sat, 03 October 2009 17:10 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 10/3/09 5:37 PM, Eike Stepper wrote:
> Thomas Hallgren schrieb:
>> On 10/03/2009 02:08 PM, Henrik Lindberg wrote:
>>
>>>> Why the term 'xpath' and not just 'path' ?
>>>>
>>> That is because I borrowed the syntax/style from XPath/XQuery :)
>>>
>> I kind of guessed that ;). But isn't one idea with this DSL to move
>> away from XML?
> I also stumbled across the x in xpath. I agree with Thomas that there
> should be no x in a so much nicer format than XML ;-)
>
> What about bpath?

I now understand the misunderstanding :) - the "xpath" is not somthing
anyone types - it was a placeholder for the "path" the user is writing
there - and I do propose that we use XPath/XQuery syntax to express these.

We do need to refer to these "query strings" as when talking about them,
documentation etc. For these purpose I am fine calling them just paths,
query-paths, path-queries, path-patterns, or why not bpaths as Eike
Stepper suggests, although I want to try to avoid introducing some new
concept (what is the difference between bpath and an xpath ?).

OTOH - if we stray far off xpath syntax, then bpath is what it should be
(and then not only a name, but a kind of syntax).

- henrik
Re: Ideas on b3 "build files" using simple xtext based syntax... [message #489478 is a reply to message #489477] Sat, 03 October 2009 17:30 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Henrik,

I see. I'm not an XPath expert but I wonder what happens to the paths if
the element structure is changed, e.g. elements are inserted?

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Henrik Lindberg schrieb:
> On 10/3/09 5:37 PM, Eike Stepper wrote:
>> Thomas Hallgren schrieb:
>>> On 10/03/2009 02:08 PM, Henrik Lindberg wrote:
>>>
>>>>> Why the term 'xpath' and not just 'path' ?
>>>>>
>>>> That is because I borrowed the syntax/style from XPath/XQuery :)
>>>>
>>> I kind of guessed that ;). But isn't one idea with this DSL to move
>>> away from XML?
>> I also stumbled across the x in xpath. I agree with Thomas that there
>> should be no x in a so much nicer format than XML ;-)
>>
>> What about bpath?
>
> I now understand the misunderstanding :) - the "xpath" is not somthing
> anyone types - it was a placeholder for the "path" the user is writing
> there - and I do propose that we use XPath/XQuery syntax to express
> these.
>
> We do need to refer to these "query strings" as when talking about
> them, documentation etc. For these purpose I am fine calling them just
> paths, query-paths, path-queries, path-patterns, or why not bpaths as
> Eike Stepper suggests, although I want to try to avoid introducing
> some new concept (what is the difference between bpath and an xpath ?).
>
> OTOH - if we stray far off xpath syntax, then bpath is what it should
> be (and then not only a name, but a kind of syntax).
>
> - henrik
>


Re: Ideas on b3 "build files" using simple xtext based syntax... [message #489486 is a reply to message #489478] Sat, 03 October 2009 21:15 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 10/3/09 7:30 PM, Eike Stepper wrote:
> I see. I'm not an XPath expert but I wonder what happens to the paths if
> the element structure is changed, e.g. elements are inserted?

Good question!

The document structure ("the context DOM") is API and should be treated
as such. Initially, the context DOM and the underlying model are
probably one and the same, but if the model needs to change it is
certainly possible to present the model via a backward compatible DOM.

There are several ways to implement this - we could for instance:
- have a "XPath compatible" implementation that works on Ecore rather
than a DOM. (There is ongoing work in this area I think - being able to
query an Ecore model). Don't know how hard it would be to create a
backward compatible model that adapts a newer model - but that can't be
impossible to acheive.
- expose the Ecore model as a XML DOM, and use an existing XPath
implementation. The "exposing as DOM" can be done differently depending
on the version of the "build file language".

I think the latter is probably fastest to implement (if there is a good
XPath implementation we can reuse). Exposing the model as a DOM should
be quite trivial - perhaps there is some neat model transformation
technology in EMF that we can use?

Note, I picked XPath as I think it provides a of query mechanism that I
think is both powerful and compact but since we have not written any
code yet - it is very easy to change if someone has other suggestions.

Any other ideas on how to handle the combination of queries, backward
compatible (or multiple version compatible) exposure of the b3 model?
Have someone done something similar and have experiences to share?

- henrik
Re: Ideas on b3 "build files" using simple xtext based syntax... [message #489497 is a reply to message #489486] Sun, 04 October 2009 07:02 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Henrik,

Maybe it's a misunderstanding. My question was more about instance
evolution (i.e. one particular build file) than b3 model evolution. The
issue is related to positional references vs. identifiers. If XPath only
supports positional references it's pretty useless, I'd say. What about
adding the notion of identifiers to your xtext syntax?

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Henrik Lindberg schrieb:
> On 10/3/09 7:30 PM, Eike Stepper wrote:
>> I see. I'm not an XPath expert but I wonder what happens to the paths if
>> the element structure is changed, e.g. elements are inserted?
>
> Good question!
>
> The document structure ("the context DOM") is API and should be
> treated as such. Initially, the context DOM and the underlying model
> are probably one and the same, but if the model needs to change it is
> certainly possible to present the model via a backward compatible DOM.
>
> There are several ways to implement this - we could for instance:
> - have a "XPath compatible" implementation that works on Ecore rather
> than a DOM. (There is ongoing work in this area I think - being able
> to query an Ecore model). Don't know how hard it would be to create a
> backward compatible model that adapts a newer model - but that can't
> be impossible to acheive.
> - expose the Ecore model as a XML DOM, and use an existing XPath
> implementation. The "exposing as DOM" can be done differently
> depending on the version of the "build file language".
>
> I think the latter is probably fastest to implement (if there is a
> good XPath implementation we can reuse). Exposing the model as a DOM
> should be quite trivial - perhaps there is some neat model
> transformation technology in EMF that we can use?
>
> Note, I picked XPath as I think it provides a of query mechanism that
> I think is both powerful and compact but since we have not written any
> code yet - it is very easy to change if someone has other suggestions.
>
> Any other ideas on how to handle the combination of queries, backward
> compatible (or multiple version compatible) exposure of the b3 model?
> Have someone done something similar and have experiences to share?
>
> - henrik


Re: Ideas on b3 "build files" using simple xtext based syntax... [message #489517 is a reply to message #489497] Sun, 04 October 2009 11:45 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Hi Eike,
I am not sure I fully understand what you mean by "positional references
vs. identifiers" - but I think you mean the difference between
navigating to an instance via its references, as opposed to just
referring to it with it's id (some primary key). Is that correct?

In b3, the build units have a (primary) key consisting of {name,
namespace, version}. So an XPath to a particular (resolved) osgi bundle
build unit called "org.myorg.myunit", of version 1.0.0.r12345, would be
expressed as
/units[name="org.myorg.myunit",
namespace="osgi.bundle",version="1.0.0.r12345"]

A unit has a collection of parts called "parts", and if I want a part
named "createZip" I could address it like this:
/units[name="org.myorg.myunit",
namespace="osgi.bundle",version="1.0.0.r12345]/parts[name= "createZip"]

If I wanted all parts (from any unit) called "createZip":
/units/parts[name="createZip"]

Do you see these queries as "positional"? (I can see how, since you have
to state that you want "the parts of a unit").

Would you have preferred to be able to directly address any element -
e.g. just state something like /parts[name="createZip"]?

As I see it positional queries are done with an index like /units[3] -
pick the fourth unit (which is obviously quite useless in (almost) all
cases). Virtual/Synthetic path elements can be used to address things
like "before first", "after last" etc. to make it possible to insert
elements.

So, if I want to insert a part before the existing parts I could use:
/units[<<predicates>>]/parts:first = new part { ... };

Don't know if that addresses the issue you brought up. Can you
elaborate, or give a use-case?

Regards
- henrik


On 10/4/09 9:02 AM, Eike Stepper wrote:
> Hi Henrik,
>
> Maybe it's a misunderstanding. My question was more about instance
> evolution (i.e. one particular build file) than b3 model evolution. The
> issue is related to positional references vs. identifiers. If XPath only
> supports positional references it's pretty useless, I'd say. What about
> adding the notion of identifiers to your xtext syntax?
>
> Cheers
> /Eike
>
> ----
> http://thegordian.blogspot.com
> http://twitter.com/eikestepper
>
>
>
> Henrik Lindberg schrieb:
>> On 10/3/09 7:30 PM, Eike Stepper wrote:
>>> I see. I'm not an XPath expert but I wonder what happens to the paths if
>>> the element structure is changed, e.g. elements are inserted?
>>
>> Good question!
>>
>> The document structure ("the context DOM") is API and should be
>> treated as such. Initially, the context DOM and the underlying model
>> are probably one and the same, but if the model needs to change it is
>> certainly possible to present the model via a backward compatible DOM.
>>
>> There are several ways to implement this - we could for instance:
>> - have a "XPath compatible" implementation that works on Ecore rather
>> than a DOM. (There is ongoing work in this area I think - being able
>> to query an Ecore model). Don't know how hard it would be to create a
>> backward compatible model that adapts a newer model - but that can't
>> be impossible to acheive.
>> - expose the Ecore model as a XML DOM, and use an existing XPath
>> implementation. The "exposing as DOM" can be done differently
>> depending on the version of the "build file language".
>>
>> I think the latter is probably fastest to implement (if there is a
>> good XPath implementation we can reuse). Exposing the model as a DOM
>> should be quite trivial - perhaps there is some neat model
>> transformation technology in EMF that we can use?
>>
>> Note, I picked XPath as I think it provides a of query mechanism that
>> I think is both powerful and compact but since we have not written any
>> code yet - it is very easy to change if someone has other suggestions.
>>
>> Any other ideas on how to handle the combination of queries, backward
>> compatible (or multiple version compatible) exposure of the b3 model?
>> Have someone done something similar and have experiences to share?
>>
>> - henrik
Re: Ideas on b3 "build files" using simple xtext based syntax... [message #489539 is a reply to message #489517] Sun, 04 October 2009 16:35 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Henrik Lindberg schrieb:
> Hi Eike,
> [...]
> As I see it positional queries are done with an index like /units[3] -
> pick the fourth unit (which is obviously quite useless in (almost) all
> cases).
Yes, that's what I meant ;-)
Your approach with (primary) keys is better.

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper


> Virtual/Synthetic path elements can be used to address things like
> "before first", "after last" etc. to make it possible to insert elements.
>
> So, if I want to insert a part before the existing parts I could use:
> /units[<<predicates>>]/parts:first = new part { ... };
>
> Don't know if that addresses the issue you brought up. Can you
> elaborate, or give a use-case?
>
> Regards
> - henrik
>
>
> On 10/4/09 9:02 AM, Eike Stepper wrote:
>> Hi Henrik,
>>
>> Maybe it's a misunderstanding. My question was more about instance
>> evolution (i.e. one particular build file) than b3 model evolution. The
>> issue is related to positional references vs. identifiers. If XPath only
>> supports positional references it's pretty useless, I'd say. What about
>> adding the notion of identifiers to your xtext syntax?
>>
>> Cheers
>> /Eike
>>
>> ----
>> http://thegordian.blogspot.com
>> http://twitter.com/eikestepper
>>
>>
>>
>> Henrik Lindberg schrieb:
>>> On 10/3/09 7:30 PM, Eike Stepper wrote:
>>>> I see. I'm not an XPath expert but I wonder what happens to the
>>>> paths if
>>>> the element structure is changed, e.g. elements are inserted?
>>>
>>> Good question!
>>>
>>> The document structure ("the context DOM") is API and should be
>>> treated as such. Initially, the context DOM and the underlying model
>>> are probably one and the same, but if the model needs to change it is
>>> certainly possible to present the model via a backward compatible DOM.
>>>
>>> There are several ways to implement this - we could for instance:
>>> - have a "XPath compatible" implementation that works on Ecore rather
>>> than a DOM. (There is ongoing work in this area I think - being able
>>> to query an Ecore model). Don't know how hard it would be to create a
>>> backward compatible model that adapts a newer model - but that can't
>>> be impossible to acheive.
>>> - expose the Ecore model as a XML DOM, and use an existing XPath
>>> implementation. The "exposing as DOM" can be done differently
>>> depending on the version of the "build file language".
>>>
>>> I think the latter is probably fastest to implement (if there is a
>>> good XPath implementation we can reuse). Exposing the model as a DOM
>>> should be quite trivial - perhaps there is some neat model
>>> transformation technology in EMF that we can use?
>>>
>>> Note, I picked XPath as I think it provides a of query mechanism that
>>> I think is both powerful and compact but since we have not written any
>>> code yet - it is very easy to change if someone has other suggestions.
>>>
>>> Any other ideas on how to handle the combination of queries, backward
>>> compatible (or multiple version compatible) exposure of the b3 model?
>>> Have someone done something similar and have experiences to share?
>>>
>>> - henrik
>


Re: Ideas on b3 "build files" using simple xtext based syntax... [message #580785 is a reply to message #489423] Sat, 03 October 2009 08:43 Go to previous message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
Hi Henrik,
Very cool indeed. And so much more readable then the dreaded XML. I think you got a lot of things covered. A few
comments inline:

On 10/03/2009 12:45 AM, Henrik Lindberg wrote:
> RESOLVER
> A context has a resolver network consisting of resolver nodes. Two
> special nodes "first" and "best" are used to specify how the search is
> conducted - resolvers in a "first" list results in the first found
> resolution, and resolvers in a "best" list results in the resolution
> with the highest score (compared to the request).
>
> A b3 build file makes it possible to specify the resolution network with
> a simple syntax.
>
> The specified resolution node itself is a "first" type of node.
>
> import org.eclipse.b3.resolvers.*; // import names of resolvers to
> reduce typing
>
> resolution {
> TargetResolver;
> WorkspaceResolver;
> }
>
I'm a bit confused by the terms 'resolution' and 'resolver'. A 'resolution' to me is something that a 'resolver'
produces, i.e. a BU annotaded with facts on how it got resolved. The bill of materials that you have between the
discovery phase (find where everything is) and the actual provisioning (now go get it) is constituted of resolutions.


> This specifies that an attempt is made to resolve against the target
> platform, and if that fails against the Workspace. No options are
> specified for the resolvers.
>
So in Buckminster terms this is more like the 'resourceMap', or 'resolverMap'. Isn't that a more descriptive term then
'resolution' ?

> Here is an example using best:
>
> resolution {
> TargetPlatformResolver;
> WorkspaceResolver;
> Best {
> P2Resolver {
> location = "http://www.someplace.good";
> }
> SVNResolver {
> location = "svn+ssh://someplace.else";
> ...;
> };
> }
> }
>
Just an idea, but given that many resolvers will consist of just a URI, would it be easy to create a short form? I.e.

resolution {
platform:/plugin/xxx;
platform:/resource://xxx;
Best {
p2:http://www.someplace.good";
svn:svn+ssh://someplace.else";
};
}

The 'platform' scheme is already recognized by Eclipse giving the host part a very special meaning (plugin basically
means TP, resource means workspace, etc.

If we add standard property expansion to this:

p2:http://www.someplace.good/updates-${eclipse.release}";

then we get a very compact form that will cover a lot of the cases we have today. The complex form must or course still
be available to make it possible to declare special namespaces, filters, etc. that will be important for source code
repositories in particular.


> ADVICE
>
> // advice sets values in the model
> // similar to CSS
> // An XPath is a query, it matches a set of nodes, where a value can be set
> //
> advice {
> xpath = value;
> ...
> xpath {
> rel-path = value;
> ...
> }
>
Why the term 'xpath' and not just 'path' ?

Regards,
Thomas Hallgren
Re: Ideas on b3 "build files" using simple xtext based syntax... [message #580808 is a reply to message #489454] Sat, 03 October 2009 12:08 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Thanks for the input, comments inline...

- henrik

On 10/3/09 10:43 AM, Thomas Hallgren wrote:
> On 10/03/2009 12:45 AM, Henrik Lindberg wrote:
>> RESOLVER
....omitted
>> resolution {
>> TargetResolver;
>> WorkspaceResolver;
>> }
>>
> I'm a bit confused by the terms 'resolution' and 'resolver'.
My bad. That was a typo. Should have been like this:
resolver {
TargetResolver;
WorkspaceResolver;
}

And the rest of the examples should also have used the keyword
"resolver" (not "resolution").


> Just an idea, but given that many resolvers will consist of just a URI,
> would it be easy to create a short form? I.e.
>
> resolution {
> platform:/plugin/xxx;
> platform:/resource://xxx;
> Best {
> p2:http://www.someplace.good";
> svn:svn+ssh://someplace.else";
> };
> }
>

I like the short form.

> If we add standard property expansion to this:
>
> p2:http://www.someplace.good/updates-${eclipse.release}";
>
Agree.

>> ADVICE
>> advice {
>> xpath = value;
>> ...
>> }
>>
> Why the term 'xpath' and not just 'path' ?
>
That is because I borrowed the syntax/style from XPath/XQuery :)
Re: Ideas on b3 "build files" using simple xtext based syntax... [message #580829 is a reply to message #489458] Sat, 03 October 2009 12:32 Go to previous message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
On 10/03/2009 02:08 PM, Henrik Lindberg wrote:

>> Why the term 'xpath' and not just 'path' ?
>>
> That is because I borrowed the syntax/style from XPath/XQuery :)
>
I kind of guessed that ;). But isn't one idea with this DSL to move away from XML?

- thomas
Re: Ideas on b3 "build files" using simple xtext based syntax... [message #580847 is a reply to message #489459] Sat, 03 October 2009 15:37 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Thomas Hallgren schrieb:
> On 10/03/2009 02:08 PM, Henrik Lindberg wrote:
>
>>> Why the term 'xpath' and not just 'path' ?
>>>
>> That is because I borrowed the syntax/style from XPath/XQuery :)
>>
> I kind of guessed that ;). But isn't one idea with this DSL to move
> away from XML?
I also stumbled across the x in xpath. I agree with Thomas that there
should be no x in a so much nicer format than XML ;-)

What about bpath?

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: Ideas on b3 "build files" using simple xtext based syntax... [message #580868 is a reply to message #489471] Sat, 03 October 2009 17:10 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 10/3/09 5:37 PM, Eike Stepper wrote:
> Thomas Hallgren schrieb:
>> On 10/03/2009 02:08 PM, Henrik Lindberg wrote:
>>
>>>> Why the term 'xpath' and not just 'path' ?
>>>>
>>> That is because I borrowed the syntax/style from XPath/XQuery :)
>>>
>> I kind of guessed that ;). But isn't one idea with this DSL to move
>> away from XML?
> I also stumbled across the x in xpath. I agree with Thomas that there
> should be no x in a so much nicer format than XML ;-)
>
> What about bpath?

I now understand the misunderstanding :) - the "xpath" is not somthing
anyone types - it was a placeholder for the "path" the user is writing
there - and I do propose that we use XPath/XQuery syntax to express these.

We do need to refer to these "query strings" as when talking about them,
documentation etc. For these purpose I am fine calling them just paths,
query-paths, path-queries, path-patterns, or why not bpaths as Eike
Stepper suggests, although I want to try to avoid introducing some new
concept (what is the difference between bpath and an xpath ?).

OTOH - if we stray far off xpath syntax, then bpath is what it should be
(and then not only a name, but a kind of syntax).

- henrik
Re: Ideas on b3 "build files" using simple xtext based syntax... [message #580883 is a reply to message #489477] Sat, 03 October 2009 17:30 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Henrik,

I see. I'm not an XPath expert but I wonder what happens to the paths if
the element structure is changed, e.g. elements are inserted?

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Henrik Lindberg schrieb:
> On 10/3/09 5:37 PM, Eike Stepper wrote:
>> Thomas Hallgren schrieb:
>>> On 10/03/2009 02:08 PM, Henrik Lindberg wrote:
>>>
>>>>> Why the term 'xpath' and not just 'path' ?
>>>>>
>>>> That is because I borrowed the syntax/style from XPath/XQuery :)
>>>>
>>> I kind of guessed that ;). But isn't one idea with this DSL to move
>>> away from XML?
>> I also stumbled across the x in xpath. I agree with Thomas that there
>> should be no x in a so much nicer format than XML ;-)
>>
>> What about bpath?
>
> I now understand the misunderstanding :) - the "xpath" is not somthing
> anyone types - it was a placeholder for the "path" the user is writing
> there - and I do propose that we use XPath/XQuery syntax to express
> these.
>
> We do need to refer to these "query strings" as when talking about
> them, documentation etc. For these purpose I am fine calling them just
> paths, query-paths, path-queries, path-patterns, or why not bpaths as
> Eike Stepper suggests, although I want to try to avoid introducing
> some new concept (what is the difference between bpath and an xpath ?).
>
> OTOH - if we stray far off xpath syntax, then bpath is what it should
> be (and then not only a name, but a kind of syntax).
>
> - henrik
>


Re: Ideas on b3 "build files" using simple xtext based syntax... [message #580900 is a reply to message #489478] Sat, 03 October 2009 21:15 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 10/3/09 7:30 PM, Eike Stepper wrote:
> I see. I'm not an XPath expert but I wonder what happens to the paths if
> the element structure is changed, e.g. elements are inserted?

Good question!

The document structure ("the context DOM") is API and should be treated
as such. Initially, the context DOM and the underlying model are
probably one and the same, but if the model needs to change it is
certainly possible to present the model via a backward compatible DOM.

There are several ways to implement this - we could for instance:
- have a "XPath compatible" implementation that works on Ecore rather
than a DOM. (There is ongoing work in this area I think - being able to
query an Ecore model). Don't know how hard it would be to create a
backward compatible model that adapts a newer model - but that can't be
impossible to acheive.
- expose the Ecore model as a XML DOM, and use an existing XPath
implementation. The "exposing as DOM" can be done differently depending
on the version of the "build file language".

I think the latter is probably fastest to implement (if there is a good
XPath implementation we can reuse). Exposing the model as a DOM should
be quite trivial - perhaps there is some neat model transformation
technology in EMF that we can use?

Note, I picked XPath as I think it provides a of query mechanism that I
think is both powerful and compact but since we have not written any
code yet - it is very easy to change if someone has other suggestions.

Any other ideas on how to handle the combination of queries, backward
compatible (or multiple version compatible) exposure of the b3 model?
Have someone done something similar and have experiences to share?

- henrik
Re: Ideas on b3 "build files" using simple xtext based syntax... [message #580922 is a reply to message #489486] Sun, 04 October 2009 07:02 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Henrik,

Maybe it's a misunderstanding. My question was more about instance
evolution (i.e. one particular build file) than b3 model evolution. The
issue is related to positional references vs. identifiers. If XPath only
supports positional references it's pretty useless, I'd say. What about
adding the notion of identifiers to your xtext syntax?

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Henrik Lindberg schrieb:
> On 10/3/09 7:30 PM, Eike Stepper wrote:
>> I see. I'm not an XPath expert but I wonder what happens to the paths if
>> the element structure is changed, e.g. elements are inserted?
>
> Good question!
>
> The document structure ("the context DOM") is API and should be
> treated as such. Initially, the context DOM and the underlying model
> are probably one and the same, but if the model needs to change it is
> certainly possible to present the model via a backward compatible DOM.
>
> There are several ways to implement this - we could for instance:
> - have a "XPath compatible" implementation that works on Ecore rather
> than a DOM. (There is ongoing work in this area I think - being able
> to query an Ecore model). Don't know how hard it would be to create a
> backward compatible model that adapts a newer model - but that can't
> be impossible to acheive.
> - expose the Ecore model as a XML DOM, and use an existing XPath
> implementation. The "exposing as DOM" can be done differently
> depending on the version of the "build file language".
>
> I think the latter is probably fastest to implement (if there is a
> good XPath implementation we can reuse). Exposing the model as a DOM
> should be quite trivial - perhaps there is some neat model
> transformation technology in EMF that we can use?
>
> Note, I picked XPath as I think it provides a of query mechanism that
> I think is both powerful and compact but since we have not written any
> code yet - it is very easy to change if someone has other suggestions.
>
> Any other ideas on how to handle the combination of queries, backward
> compatible (or multiple version compatible) exposure of the b3 model?
> Have someone done something similar and have experiences to share?
>
> - henrik


Re: Ideas on b3 "build files" using simple xtext based syntax... [message #580938 is a reply to message #489497] Sun, 04 October 2009 11:45 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Hi Eike,
I am not sure I fully understand what you mean by "positional references
vs. identifiers" - but I think you mean the difference between
navigating to an instance via its references, as opposed to just
referring to it with it's id (some primary key). Is that correct?

In b3, the build units have a (primary) key consisting of {name,
namespace, version}. So an XPath to a particular (resolved) osgi bundle
build unit called "org.myorg.myunit", of version 1.0.0.r12345, would be
expressed as
/units[name="org.myorg.myunit",
namespace="osgi.bundle",version="1.0.0.r12345"]

A unit has a collection of parts called "parts", and if I want a part
named "createZip" I could address it like this:
/units[name="org.myorg.myunit",
namespace="osgi.bundle",version="1.0.0.r12345]/parts[name= "createZip"]

If I wanted all parts (from any unit) called "createZip":
/units/parts[name="createZip"]

Do you see these queries as "positional"? (I can see how, since you have
to state that you want "the parts of a unit").

Would you have preferred to be able to directly address any element -
e.g. just state something like /parts[name="createZip"]?

As I see it positional queries are done with an index like /units[3] -
pick the fourth unit (which is obviously quite useless in (almost) all
cases). Virtual/Synthetic path elements can be used to address things
like "before first", "after last" etc. to make it possible to insert
elements.

So, if I want to insert a part before the existing parts I could use:
/units[<<predicates>>]/parts:first = new part { ... };

Don't know if that addresses the issue you brought up. Can you
elaborate, or give a use-case?

Regards
- henrik


On 10/4/09 9:02 AM, Eike Stepper wrote:
> Hi Henrik,
>
> Maybe it's a misunderstanding. My question was more about instance
> evolution (i.e. one particular build file) than b3 model evolution. The
> issue is related to positional references vs. identifiers. If XPath only
> supports positional references it's pretty useless, I'd say. What about
> adding the notion of identifiers to your xtext syntax?
>
> Cheers
> /Eike
>
> ----
> http://thegordian.blogspot.com
> http://twitter.com/eikestepper
>
>
>
> Henrik Lindberg schrieb:
>> On 10/3/09 7:30 PM, Eike Stepper wrote:
>>> I see. I'm not an XPath expert but I wonder what happens to the paths if
>>> the element structure is changed, e.g. elements are inserted?
>>
>> Good question!
>>
>> The document structure ("the context DOM") is API and should be
>> treated as such. Initially, the context DOM and the underlying model
>> are probably one and the same, but if the model needs to change it is
>> certainly possible to present the model via a backward compatible DOM.
>>
>> There are several ways to implement this - we could for instance:
>> - have a "XPath compatible" implementation that works on Ecore rather
>> than a DOM. (There is ongoing work in this area I think - being able
>> to query an Ecore model). Don't know how hard it would be to create a
>> backward compatible model that adapts a newer model - but that can't
>> be impossible to acheive.
>> - expose the Ecore model as a XML DOM, and use an existing XPath
>> implementation. The "exposing as DOM" can be done differently
>> depending on the version of the "build file language".
>>
>> I think the latter is probably fastest to implement (if there is a
>> good XPath implementation we can reuse). Exposing the model as a DOM
>> should be quite trivial - perhaps there is some neat model
>> transformation technology in EMF that we can use?
>>
>> Note, I picked XPath as I think it provides a of query mechanism that
>> I think is both powerful and compact but since we have not written any
>> code yet - it is very easy to change if someone has other suggestions.
>>
>> Any other ideas on how to handle the combination of queries, backward
>> compatible (or multiple version compatible) exposure of the b3 model?
>> Have someone done something similar and have experiences to share?
>>
>> - henrik
Re: Ideas on b3 "build files" using simple xtext based syntax... [message #580983 is a reply to message #489517] Sun, 04 October 2009 16:35 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Henrik Lindberg schrieb:
> Hi Eike,
> [...]
> As I see it positional queries are done with an index like /units[3] -
> pick the fourth unit (which is obviously quite useless in (almost) all
> cases).
Yes, that's what I meant ;-)
Your approach with (primary) keys is better.

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper


> Virtual/Synthetic path elements can be used to address things like
> "before first", "after last" etc. to make it possible to insert elements.
>
> So, if I want to insert a part before the existing parts I could use:
> /units[<<predicates>>]/parts:first = new part { ... };
>
> Don't know if that addresses the issue you brought up. Can you
> elaborate, or give a use-case?
>
> Regards
> - henrik
>
>
> On 10/4/09 9:02 AM, Eike Stepper wrote:
>> Hi Henrik,
>>
>> Maybe it's a misunderstanding. My question was more about instance
>> evolution (i.e. one particular build file) than b3 model evolution. The
>> issue is related to positional references vs. identifiers. If XPath only
>> supports positional references it's pretty useless, I'd say. What about
>> adding the notion of identifiers to your xtext syntax?
>>
>> Cheers
>> /Eike
>>
>> ----
>> http://thegordian.blogspot.com
>> http://twitter.com/eikestepper
>>
>>
>>
>> Henrik Lindberg schrieb:
>>> On 10/3/09 7:30 PM, Eike Stepper wrote:
>>>> I see. I'm not an XPath expert but I wonder what happens to the
>>>> paths if
>>>> the element structure is changed, e.g. elements are inserted?
>>>
>>> Good question!
>>>
>>> The document structure ("the context DOM") is API and should be
>>> treated as such. Initially, the context DOM and the underlying model
>>> are probably one and the same, but if the model needs to change it is
>>> certainly possible to present the model via a backward compatible DOM.
>>>
>>> There are several ways to implement this - we could for instance:
>>> - have a "XPath compatible" implementation that works on Ecore rather
>>> than a DOM. (There is ongoing work in this area I think - being able
>>> to query an Ecore model). Don't know how hard it would be to create a
>>> backward compatible model that adapts a newer model - but that can't
>>> be impossible to acheive.
>>> - expose the Ecore model as a XML DOM, and use an existing XPath
>>> implementation. The "exposing as DOM" can be done differently
>>> depending on the version of the "build file language".
>>>
>>> I think the latter is probably fastest to implement (if there is a
>>> good XPath implementation we can reuse). Exposing the model as a DOM
>>> should be quite trivial - perhaps there is some neat model
>>> transformation technology in EMF that we can use?
>>>
>>> Note, I picked XPath as I think it provides a of query mechanism that
>>> I think is both powerful and compact but since we have not written any
>>> code yet - it is very easy to change if someone has other suggestions.
>>>
>>> Any other ideas on how to handle the combination of queries, backward
>>> compatible (or multiple version compatible) exposure of the b3 model?
>>> Have someone done something similar and have experiences to share?
>>>
>>> - henrik
>


Previous Topic:Supporting Parallel Builds
Next Topic:Building non-Eclipse things with b3
Goto Forum:
  


Current Time: Fri Apr 19 20:43:01 GMT 2024

Powered by FUDForum. Page generated in 0.05181 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top