Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Buckminster » dynamic property refs
dynamic property refs [message #387949] Tue, 21 July 2009 09:15 Go to next message
Johannes Utzig is currently offline Johannes UtzigFriend
Messages: 329
Registered: July 2009
Senior Member
Hi,

I'm currently having some issues with property expansion in my rmap.
What I'm trying to do is to connect a legacy system that contains
artifacts and resolve them with an URL reader. The artifacts are
published on a samba share and there is an automatically generated
properties file that contains paths that are relative to the project
that produces the artifact (the artifact name is the property key).
In my CSPEC(X)s I refer to these artifacts by "ProjectName/ArtifactName".

Currently my rmap looks like this:
<searchPath name="MyArtifacts">
<provider readerType="url" componentTypes="jar">
<uri format="file://share/artifacts/{0}/{1}">
<bc:split pattern="/">
<bc:propertyRef key="buckminster.component" />
</bc:split>
</uri>
</provider>
</searchPath>

Now this will result in file://share/artifacts/ProjectName/ArtifactName
but what I really want is file://share/artifacts/ProjectName/relative/path.
In other words: I need to use 'ArtifactName' (which is {1} in the uri
format) itself as a property key that gets expanded. Is there a way to
do that?

Best regards,
Johannes
Re: dynamic property refs [message #387952 is a reply to message #387949] Tue, 21 July 2009 14:16 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Hm,
I don't think there is a way to use the result of a property operation
as a property key. That would require something like:
<bc:propertyRef> <bc:split ... > .... <bc:propertyRef />
Or some sort of indirection function when setting the key="..."
attribute. Neither is available.

Some ideas:
- transform the property file to a webpage with hrefs to the files and
use matcher to pick things
- transform the property file to a rmap :)
- write a property reader type
- modify propertyRef to allow indirection (don't know if this creates
new problems though).

- henrik

Johannes Utzig wrote:
> Hi,
>
> I'm currently having some issues with property expansion in my rmap.
> What I'm trying to do is to connect a legacy system that contains
> artifacts and resolve them with an URL reader. The artifacts are
> published on a samba share and there is an automatically generated
> properties file that contains paths that are relative to the project
> that produces the artifact (the artifact name is the property key).
> In my CSPEC(X)s I refer to these artifacts by "ProjectName/ArtifactName".
>
> Currently my rmap looks like this:
> <searchPath name="MyArtifacts">
> <provider readerType="url" componentTypes="jar">
> <uri format="file://share/artifacts/{0}/{1}">
> <bc:split pattern="/">
> <bc:propertyRef key="buckminster.component" />
> </bc:split>
> </uri>
> </provider>
> </searchPath>
>
> Now this will result in file://share/artifacts/ProjectName/ArtifactName
> but what I really want is file://share/artifacts/ProjectName/relative/path.
> In other words: I need to use 'ArtifactName' (which is {1} in the uri
> format) itself as a property key that gets expanded. Is there a way to
> do that?
>
> Best regards,
> Johannes
Re: dynamic property refs [message #387955 is a reply to message #387952] Tue, 21 July 2009 14:39 Go to previous messageGo to next message
Johannes Utzig is currently offline Johannes UtzigFriend
Messages: 329
Registered: July 2009
Senior Member
Hi Henrik,

comments below:

Henrik Lindberg schrieb:
> Hm,
> I don't think there is a way to use the result of a property operation
> as a property key. That would require something like:
> <bc:propertyRef> <bc:split ... > .... <bc:propertyRef />
> Or some sort of indirection function when setting the key="..."
> attribute. Neither is available.
>

Ok, that's what I thought, but I wasn't sure if I'm just missing something.

> Some ideas:
> - transform the property file to a webpage with hrefs to the files and
> use matcher to pick things
> - transform the property file to a rmap :)

Guess what, that's exactly what I did while waiting for a reply. JET
makes things like that easy :)
Only thing that doesn't work is if the path points to a directory
instead of a single file (yes, I know how ugly that is :) ). I guess I
need to write my own reader for that.

> - write a property reader type
> - modify propertyRef to allow indirection (don't know if this creates
> new problems though).
>
> - henrik
>

Best regards and thanks for the quick response,
Johannes

> Johannes Utzig wrote:
>> Hi,
>>
>> I'm currently having some issues with property expansion in my rmap.
>> What I'm trying to do is to connect a legacy system that contains
>> artifacts and resolve them with an URL reader. The artifacts are
>> published on a samba share and there is an automatically generated
>> properties file that contains paths that are relative to the project
>> that produces the artifact (the artifact name is the property key).
>> In my CSPEC(X)s I refer to these artifacts by "ProjectName/ArtifactName".
>>
>> Currently my rmap looks like this:
>> <searchPath name="MyArtifacts">
>> <provider readerType="url" componentTypes="jar">
>> <uri format="file://share/artifacts/{0}/{1}">
>> <bc:split pattern="/">
>> <bc:propertyRef key="buckminster.component" />
>> </bc:split>
>> </uri>
>> </provider>
>> </searchPath>
>>
>> Now this will result in
>> file://share/artifacts/ProjectName/ArtifactName but what I really want
>> is file://share/artifacts/ProjectName/relative/path.
>> In other words: I need to use 'ArtifactName' (which is {1} in the uri
>> format) itself as a property key that gets expanded. Is there a way to
>> do that?
>>
>> Best regards,
>> Johannes
Re: dynamic property refs [message #387957 is a reply to message #387952] Tue, 21 July 2009 14:45 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
Property expansion should be recursive actually, so if something expands to something that needs expansion, that
expansion too will happen. There's a depth limit that prevents endless recursion.

- thomas

Henrik Lindberg wrote:
> Hm,
> I don't think there is a way to use the result of a property operation
> as a property key. That would require something like:
> <bc:propertyRef> <bc:split ... > .... <bc:propertyRef />
> Or some sort of indirection function when setting the key="..."
> attribute. Neither is available.
>
> Some ideas:
> - transform the property file to a webpage with hrefs to the files and
> use matcher to pick things
> - transform the property file to a rmap :)
> - write a property reader type
> - modify propertyRef to allow indirection (don't know if this creates
> new problems though).
>
> - henrik
>
> Johannes Utzig wrote:
>> Hi,
>>
>> I'm currently having some issues with property expansion in my rmap.
>> What I'm trying to do is to connect a legacy system that contains
>> artifacts and resolve them with an URL reader. The artifacts are
>> published on a samba share and there is an automatically generated
>> properties file that contains paths that are relative to the project
>> that produces the artifact (the artifact name is the property key).
>> In my CSPEC(X)s I refer to these artifacts by "ProjectName/ArtifactName".
>>
>> Currently my rmap looks like this:
>> <searchPath name="MyArtifacts">
>> <provider readerType="url" componentTypes="jar">
>> <uri format="file://share/artifacts/{0}/{1}">
>> <bc:split pattern="/">
>> <bc:propertyRef key="buckminster.component" />
>> </bc:split>
>> </uri>
>> </provider>
>> </searchPath>
>>
>> Now this will result in
>> file://share/artifacts/ProjectName/ArtifactName but what I really want
>> is file://share/artifacts/ProjectName/relative/path.
>> In other words: I need to use 'ArtifactName' (which is {1} in the uri
>> format) itself as a property key that gets expanded. Is there a way to
>> do that?
>>
>> Best regards,
>> Johannes
Re: dynamic property refs [message #387959 is a reply to message #387957] Tue, 21 July 2009 15:18 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Thomas explained this to me as well - if a value contains "${property}"
it will be expanded. So all that is needed should be:
<uri format="file://share/artifacts/{0}/${{1}}">

i.e. use {1} as the name of a property.

- henrik

Thomas Hallgren wrote:
> Property expansion should be recursive actually, so if something expands
> to something that needs expansion, that expansion too will happen.
> There's a depth limit that prevents endless recursion.
>
> - thomas
>
> Henrik Lindberg wrote:
>> Hm,
>> I don't think there is a way to use the result of a property operation
>> as a property key. That would require something like:
>> <bc:propertyRef> <bc:split ... > .... <bc:propertyRef />
>> Or some sort of indirection function when setting the key="..."
>> attribute. Neither is available.
>>
>> Some ideas:
>> - transform the property file to a webpage with hrefs to the files and
>> use matcher to pick things
>> - transform the property file to a rmap :)
>> - write a property reader type
>> - modify propertyRef to allow indirection (don't know if this creates
>> new problems though).
>>
>> - henrik
>>
>> Johannes Utzig wrote:
>>> Hi,
>>>
>>> I'm currently having some issues with property expansion in my rmap.
>>> What I'm trying to do is to connect a legacy system that contains
>>> artifacts and resolve them with an URL reader. The artifacts are
>>> published on a samba share and there is an automatically generated
>>> properties file that contains paths that are relative to the project
>>> that produces the artifact (the artifact name is the property key).
>>> In my CSPEC(X)s I refer to these artifacts by
>>> "ProjectName/ArtifactName".
>>>
>>> Currently my rmap looks like this:
>>> <searchPath name="MyArtifacts">
>>> <provider readerType="url" componentTypes="jar">
>>> <uri format="file://share/artifacts/{0}/{1}">
>>> <bc:split pattern="/">
>>> <bc:propertyRef key="buckminster.component" />
>>> </bc:split>
>>> </uri>
>>> </provider>
>>> </searchPath>
>>>
>>> Now this will result in
>>> file://share/artifacts/ProjectName/ArtifactName but what I really
>>> want is file://share/artifacts/ProjectName/relative/path.
>>> In other words: I need to use 'ArtifactName' (which is {1} in the uri
>>> format) itself as a property key that gets expanded. Is there a way
>>> to do that?
>>>
>>> Best regards,
>>> Johannes
Re: dynamic property refs [message #387964 is a reply to message #387959] Tue, 21 July 2009 19:47 Go to previous messageGo to next message
Johannes Utzig is currently offline Johannes UtzigFriend
Messages: 329
Registered: July 2009
Senior Member
Oh wow, I didn't know that would work. I thought only the
Message-Format patterns {n} would be allowed in uri element.

Thanks a lot I will try that tomorrow

Best regards,
Johannes

Henrik Lindberg schrieb:
> Thomas explained this to me as well - if a value contains "${property}"
> it will be expanded. So all that is needed should be:
> <uri format="file://share/artifacts/{0}/${{1}}">
>
> i.e. use {1} as the name of a property.
>
> - henrik
>
> Thomas Hallgren wrote:
>> Property expansion should be recursive actually, so if something
>> expands to something that needs expansion, that expansion too will
>> happen. There's a depth limit that prevents endless recursion.
>>
>> - thomas
>>
>> Henrik Lindberg wrote:
>>> Hm,
>>> I don't think there is a way to use the result of a property
>>> operation as a property key. That would require something like:
>>> <bc:propertyRef> <bc:split ... > .... <bc:propertyRef />
>>> Or some sort of indirection function when setting the key="..."
>>> attribute. Neither is available.
>>>
>>> Some ideas:
>>> - transform the property file to a webpage with hrefs to the files
>>> and use matcher to pick things
>>> - transform the property file to a rmap :)
>>> - write a property reader type
>>> - modify propertyRef to allow indirection (don't know if this creates
>>> new problems though).
>>>
>>> - henrik
>>>
>>> Johannes Utzig wrote:
>>>> Hi,
>>>>
>>>> I'm currently having some issues with property expansion in my rmap.
>>>> What I'm trying to do is to connect a legacy system that contains
>>>> artifacts and resolve them with an URL reader. The artifacts are
>>>> published on a samba share and there is an automatically generated
>>>> properties file that contains paths that are relative to the project
>>>> that produces the artifact (the artifact name is the property key).
>>>> In my CSPEC(X)s I refer to these artifacts by
>>>> "ProjectName/ArtifactName".
>>>>
>>>> Currently my rmap looks like this:
>>>> <searchPath name="MyArtifacts">
>>>> <provider readerType="url" componentTypes="jar">
>>>> <uri format="file://share/artifacts/{0}/{1}">
>>>> <bc:split pattern="/">
>>>> <bc:propertyRef key="buckminster.component" />
>>>> </bc:split>
>>>> </uri>
>>>> </provider>
>>>> </searchPath>
>>>>
>>>> Now this will result in
>>>> file://share/artifacts/ProjectName/ArtifactName but what I really
>>>> want is file://share/artifacts/ProjectName/relative/path.
>>>> In other words: I need to use 'ArtifactName' (which is {1} in the
>>>> uri format) itself as a property key that gets expanded. Is there a
>>>> way to do that?
>>>>
>>>> Best regards,
>>>> Johannes
Re: dynamic property refs [message #388386 is a reply to message #387964] Tue, 28 July 2009 15:09 Go to previous messageGo to next message
Johannes Utzig is currently offline Johannes UtzigFriend
Messages: 329
Registered: July 2009
Senior Member
Hi,

I'm sorry to bother you again, but I simply can't get this to work.
This gives me an illegal argument exception:
<searchPath name="Artifacts">
<provider readerType="url" componentTypes="jar">
<uri format="file://share/artifacts/${{0}}/">
<bc:constant value="user.language" />
</uri>
</provider>
</searchPath>
E [0039] : java.lang.IllegalArgumentException: can't parse argument
number {0}: can't parse argument number {0}

Quoting it (file://share/artifacts/$'{'{0}'}')
doesn't expand the property and leads to an URISyntaxException:
java.net.URISyntaxException: Illegal character in path at index 24:
file://share/artifacts/${user.language}/

This works however:
<uri format="file://share/artifacts/{0}/">
<bc:constant value="${user.language}" />
</uri>

This doesn't:
<uri format="file://share/artifacts/{0}/">
<bc:format format="{0}{1}{2}">
<bc:constant value="${" />
<bc:constant value="user.language" />
<bc:constant value="}" />
</bc:format>
</uri>
ERROR java.net.URISyntaxException: Illegal character in path at
index 24: file://share/artifacts/${user.language}/

(using user.language doesn't make much sense of course, in my real case
I use buckminster.component. user.language just makes the example self
contained without a bunch of properties for every buckminster.component
in the query).

So, I'm really out of ideas on how this is supposed to work. It's great
that properties get expanded like that, but I just don't understand how
I can use the value of buckminster.component in the key for a property
that will actually get expanded.

Best regards,
Johannes


Johannes Utzig schrieb:
> Oh wow, I didn't know that would work. I thought only the
> Message-Format patterns {n} would be allowed in uri element.
>
> Thanks a lot I will try that tomorrow
>
> Best regards,
> Johannes
>
> Henrik Lindberg schrieb:
>> Thomas explained this to me as well - if a value contains
>> "${property}" it will be expanded. So all that is needed should be:
>> <uri format="file://share/artifacts/{0}/${{1}}">
>>
>> i.e. use {1} as the name of a property.
>>
>> - henrik
>>
>> Thomas Hallgren wrote:
>>> Property expansion should be recursive actually, so if something
>>> expands to something that needs expansion, that expansion too will
>>> happen. There's a depth limit that prevents endless recursion.
>>>
>>> - thomas
>>>
>>> Henrik Lindberg wrote:
>>>> Hm,
>>>> I don't think there is a way to use the result of a property
>>>> operation as a property key. That would require something like:
>>>> <bc:propertyRef> <bc:split ... > .... <bc:propertyRef />
>>>> Or some sort of indirection function when setting the key="..."
>>>> attribute. Neither is available.
>>>>
>>>> Some ideas:
>>>> - transform the property file to a webpage with hrefs to the files
>>>> and use matcher to pick things
>>>> - transform the property file to a rmap :)
>>>> - write a property reader type
>>>> - modify propertyRef to allow indirection (don't know if this
>>>> creates new problems though).
>>>>
>>>> - henrik
>>>>
>>>> Johannes Utzig wrote:
>>>>> Hi,
>>>>>
>>>>> I'm currently having some issues with property expansion in my
>>>>> rmap. What I'm trying to do is to connect a legacy system that
>>>>> contains artifacts and resolve them with an URL reader. The
>>>>> artifacts are published on a samba share and there is an
>>>>> automatically generated properties file that contains paths that
>>>>> are relative to the project that produces the artifact (the
>>>>> artifact name is the property key).
>>>>> In my CSPEC(X)s I refer to these artifacts by
>>>>> "ProjectName/ArtifactName".
>>>>>
>>>>> Currently my rmap looks like this:
>>>>> <searchPath name="MyArtifacts">
>>>>> <provider readerType="url" componentTypes="jar">
>>>>> <uri format="file://share/artifacts/{0}/{1}">
>>>>> <bc:split pattern="/">
>>>>> <bc:propertyRef key="buckminster.component" />
>>>>> </bc:split>
>>>>> </uri>
>>>>> </provider>
>>>>> </searchPath>
>>>>>
>>>>> Now this will result in
>>>>> file://share/artifacts/ProjectName/ArtifactName but what I really
>>>>> want is file://share/artifacts/ProjectName/relative/path.
>>>>> In other words: I need to use 'ArtifactName' (which is {1} in the
>>>>> uri format) itself as a property key that gets expanded. Is there a
>>>>> way to do that?
>>>>>
>>>>> Best regards,
>>>>> Johannes
Re: dynamic property refs [message #388389 is a reply to message #388386] Tue, 28 July 2009 15:42 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Hm,
I can see why the ${{0}} does not work... the {0} is expanded last (duh
- I should not have suggested that in the first place...)

Here is another attempt:
<uri format="file://share/artifacts/{0}" >
<bc:propertyRef key="${user.language}" />
</uri>

- henrik

Johannes Utzig wrote:
> Hi,
>
> I'm sorry to bother you again, but I simply can't get this to work.
> This gives me an illegal argument exception:
> <searchPath name="Artifacts">
> <provider readerType="url" componentTypes="jar">
> <uri format="file://share/artifacts/${{0}}/">
> <bc:constant value="user.language" />
> </uri>
> </provider>
> </searchPath>
> E [0039] : java.lang.IllegalArgumentException: can't parse argument
> number {0}: can't parse argument number {0}
>
> Quoting it (file://share/artifacts/$'{'{0}'}')
> doesn't expand the property and leads to an URISyntaxException:
> java.net.URISyntaxException: Illegal character in path at index 24:
> file://share/artifacts/${user.language}/
>
> This works however:
> <uri format="file://share/artifacts/{0}/">
> <bc:constant value="${user.language}" />
> </uri>
>
> This doesn't:
> <uri format="file://share/artifacts/{0}/">
> <bc:format format="{0}{1}{2}">
> <bc:constant value="${" />
> <bc:constant value="user.language" />
> <bc:constant value="}" />
> </bc:format>
> </uri>
> ERROR java.net.URISyntaxException: Illegal character in path at
> index 24: file://share/artifacts/${user.language}/
>
> (using user.language doesn't make much sense of course, in my real case
> I use buckminster.component. user.language just makes the example self
> contained without a bunch of properties for every buckminster.component
> in the query).
>
> So, I'm really out of ideas on how this is supposed to work. It's great
> that properties get expanded like that, but I just don't understand how
> I can use the value of buckminster.component in the key for a property
> that will actually get expanded.
>
> Best regards,
> Johannes
>
>
>
Re: dynamic property refs [message #388394 is a reply to message #388389] Tue, 28 July 2009 19:56 Go to previous messageGo to next message
Johannes Utzig is currently offline Johannes UtzigFriend
Messages: 329
Registered: July 2009
Senior Member
Hi Henrik,

this works of course, but it's not solving my problem. In this setup,
${user.language} will be expanded to its value and that will be used as
a key, but I need buckminster.component to be expanded and use that to
build a new property key and that's what doesn't seem to work (that's
why I introduced the constants in the example, because if it would work
with a constant, it would probably also work with buckminster.component
+ propertyRef).


Maybe you have another idea, I'm out of them :)

Best regards and thank you,
Johannes

Henrik Lindberg schrieb:
> Hm,
> I can see why the ${{0}} does not work... the {0} is expanded last (duh
> - I should not have suggested that in the first place...)
>
> Here is another attempt:
> <uri format="file://share/artifacts/{0}" >
> <bc:propertyRef key="${user.language}" />
> </uri>
>
> - henrik
>
> Johannes Utzig wrote:
>> Hi,
>>
>> I'm sorry to bother you again, but I simply can't get this to work.
>> This gives me an illegal argument exception:
>> <searchPath name="Artifacts">
>> <provider readerType="url" componentTypes="jar">
>> <uri format="file://share/artifacts/${{0}}/">
>> <bc:constant value="user.language" />
>> </uri>
>> </provider>
>> </searchPath>
>> E [0039] : java.lang.IllegalArgumentException: can't parse argument
>> number {0}: can't parse argument number {0}
>>
>> Quoting it (file://share/artifacts/$'{'{0}'}')
>> doesn't expand the property and leads to an URISyntaxException:
>> java.net.URISyntaxException: Illegal character in path at index 24:
>> file://share/artifacts/${user.language}/
>>
>> This works however:
>> <uri format="file://share/artifacts/{0}/">
>> <bc:constant value="${user.language}" />
>> </uri>
>>
>> This doesn't:
>> <uri format="file://share/artifacts/{0}/">
>> <bc:format format="{0}{1}{2}">
>> <bc:constant value="${" />
>> <bc:constant value="user.language" />
>> <bc:constant value="}" />
>> </bc:format> </uri>
>> ERROR java.net.URISyntaxException: Illegal character in path
>> at index 24: file://share/artifacts/${user.language}/
>>
>> (using user.language doesn't make much sense of course, in my real
>> case I use buckminster.component. user.language just makes the example
>> self contained without a bunch of properties for every
>> buckminster.component in the query).
>>
>> So, I'm really out of ideas on how this is supposed to work. It's
>> great that properties get expanded like that, but I just don't
>> understand how I can use the value of buckminster.component in the key
>> for a property that will actually get expanded.
>>
>> Best regards,
>> Johannes
>>
>>
>>
Re: dynamic property refs [message #388395 is a reply to message #388394] Tue, 28 July 2009 21:19 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
Hi Johannes,
I'm not sure what it is you are trying to do here:

<constant value="${buckminster.component}"/>

is exactly the same as

<propertyRef key="buckminster.component"/>

but

<propertyRef key="${buckminster.component}"/>

will give you the value of a property with a key that corresponds to the component name. If you want to add things to
that, you can of course do:

<propertyRef key="${buckminster.component}.foo.bar"/>

So what use-case is it that isn't covered?

Regards,
Thomas Hallgren


Johannes Utzig wrote:
> Hi Henrik,
>
> this works of course, but it's not solving my problem. In this setup,
> ${user.language} will be expanded to its value and that will be used as
> a key, but I need buckminster.component to be expanded and use that to
> build a new property key and that's what doesn't seem to work (that's
> why I introduced the constants in the example, because if it would work
> with a constant, it would probably also work with buckminster.component
> + propertyRef).
>
>
> Maybe you have another idea, I'm out of them :)
>


> Best regards and thank you,
> Johannes
>
> Henrik Lindberg schrieb:
>> Hm,
>> I can see why the ${{0}} does not work... the {0} is expanded last
>> (duh - I should not have suggested that in the first place...)
>>
>> Here is another attempt:
>> <uri format="file://share/artifacts/{0}" >
>> <bc:propertyRef key="${user.language}" />
>> </uri>
>>
>> - henrik
>>
>> Johannes Utzig wrote:
>>> Hi,
>>>
>>> I'm sorry to bother you again, but I simply can't get this to work.
>>> This gives me an illegal argument exception:
>>> <searchPath name="Artifacts">
>>> <provider readerType="url" componentTypes="jar">
>>> <uri format="file://share/artifacts/${{0}}/">
>>> <bc:constant value="user.language" />
>>> </uri>
>>> </provider>
>>> </searchPath>
>>> E [0039] : java.lang.IllegalArgumentException: can't parse argument
>>> number {0}: can't parse argument number {0}
>>>
>>> Quoting it (file://share/artifacts/$'{'{0}'}')
>>> doesn't expand the property and leads to an URISyntaxException:
>>> java.net.URISyntaxException: Illegal character in path at index 24:
>>> file://share/artifacts/${user.language}/
>>>
>>> This works however:
>>> <uri format="file://share/artifacts/{0}/">
>>> <bc:constant value="${user.language}" />
>>> </uri>
>>>
>>> This doesn't:
>>> <uri format="file://share/artifacts/{0}/">
>>> <bc:format format="{0}{1}{2}">
>>> <bc:constant value="${" />
>>> <bc:constant value="user.language" />
>>> <bc:constant value="}" />
>>> </bc:format> </uri>
>>> ERROR java.net.URISyntaxException: Illegal character in path
>>> at index 24: file://share/artifacts/${user.language}/
>>>
>>> (using user.language doesn't make much sense of course, in my real
>>> case I use buckminster.component. user.language just makes the
>>> example self contained without a bunch of properties for every
>>> buckminster.component in the query).
>>>
>>> So, I'm really out of ideas on how this is supposed to work. It's
>>> great that properties get expanded like that, but I just don't
>>> understand how I can use the value of buckminster.component in the
>>> key for a property that will actually get expanded.
>>>
>>> Best regards,
>>> Johannes
>>>
>>>
>>>
Re: dynamic property refs [message #388397 is a reply to message #388395] Wed, 29 July 2009 07:29 Go to previous messageGo to next message
Johannes Utzig is currently offline Johannes UtzigFriend
Messages: 329
Registered: July 2009
Senior Member
Hi Thomas,

the thing that I can't seem to get to work is this:
A property of the name artifact.ARTIFACTNAME.path has a value that is
the relative path to the artifact from the project that produced it. Now
to use buckminster for the resolution I need three pieces of information:
-the name of the artifact
-the name of the project that produced the artifact
-the property value of artifact.ARTIFACTNAME.path

The parent/child hierarchie seemed close enough to me to Maven + Parent
poms, so I decided to encode the information about the parent project
the same way:
projectName/artifactName is my component name.

Now to look up the relative path I need to split buckminster.component
and use the artifact name as a property key but I can't get it to work.
This is how it currently looks like. It's obvious why it doesn't work,
the 'format' creates a string artifact.artifactName.path, not a
property, but how would I treat it as a property?


<searchPath name="Artifacts">
<provider readerType="url" componentTypes="jar">
<!-- the artifact will be in
//share/artifacts/projectName/${artifact.artifactName.path} -->
<uri format="file://share/artifacts/{1}/{0}">
<bc:format format="artifact.{1}.path" >
<bc:split pattern="/">
<bc:propertyRef key="buckminster.component" />
</bc:split>
</bc:format>
<bc:split pattern="/">
<bc:propertyRef key="buckminster.component" />
</bc:split>
</uri>
</provider>
</searchPath>

I think what I'd need now is a propertyRef that alows the value of a
nested child element to be the key, then I could resolve my property.
But maybe I'm just missing the obvious here...

Best regards,
Johannes

Thomas Hallgren schrieb:
> Hi Johannes,
> I'm not sure what it is you are trying to do here:
>
> <constant value="${buckminster.component}"/>
>
> is exactly the same as
>
> <propertyRef key="buckminster.component"/>
>
> but
>
> <propertyRef key="${buckminster.component}"/>
>
> will give you the value of a property with a key that corresponds to the
> component name. If you want to add things to that, you can of course do:
>
> <propertyRef key="${buckminster.component}.foo.bar"/>
>
> So what use-case is it that isn't covered?
>
> Regards,
> Thomas Hallgren
>
>
> Johannes Utzig wrote:
>> Hi Henrik,
>>
>> this works of course, but it's not solving my problem. In this setup,
>> ${user.language} will be expanded to its value and that will be used
>> as a key, but I need buckminster.component to be expanded and use that
>> to build a new property key and that's what doesn't seem to work
>> (that's why I introduced the constants in the example, because if it
>> would work with a constant, it would probably also work with
>> buckminster.component + propertyRef).
>>
>>
>> Maybe you have another idea, I'm out of them :)
>>
>
>
>> Best regards and thank you,
>> Johannes
>>
>> Henrik Lindberg schrieb:
>>> Hm,
>>> I can see why the ${{0}} does not work... the {0} is expanded last
>>> (duh - I should not have suggested that in the first place...)
>>>
>>> Here is another attempt:
>>> <uri format="file://share/artifacts/{0}" >
>>> <bc:propertyRef key="${user.language}" />
>>> </uri>
>>>
>>> - henrik
>>>
>>> Johannes Utzig wrote:
>>>> Hi,
>>>>
>>>> I'm sorry to bother you again, but I simply can't get this to work.
>>>> This gives me an illegal argument exception:
>>>> <searchPath name="Artifacts">
>>>> <provider readerType="url" componentTypes="jar">
>>>> <uri format="file://share/artifacts/${{0}}/">
>>>> <bc:constant value="user.language" />
>>>> </uri>
>>>> </provider>
>>>> </searchPath>
>>>> E [0039] : java.lang.IllegalArgumentException: can't parse argument
>>>> number {0}: can't parse argument number {0}
>>>>
>>>> Quoting it (file://share/artifacts/$'{'{0}'}')
>>>> doesn't expand the property and leads to an URISyntaxException:
>>>> java.net.URISyntaxException: Illegal character in path at index 24:
>>>> file://share/artifacts/${user.language}/
>>>>
>>>> This works however:
>>>> <uri format="file://share/artifacts/{0}/">
>>>> <bc:constant value="${user.language}" />
>>>> </uri>
>>>>
>>>> This doesn't:
>>>> <uri format="file://share/artifacts/{0}/">
>>>> <bc:format format="{0}{1}{2}">
>>>> <bc:constant value="${" />
>>>> <bc:constant value="user.language" />
>>>> <bc:constant value="}" />
>>>> </bc:format> </uri>
>>>> ERROR java.net.URISyntaxException: Illegal character in path
>>>> at index 24: file://share/artifacts/${user.language}/
>>>>
>>>> (using user.language doesn't make much sense of course, in my real
>>>> case I use buckminster.component. user.language just makes the
>>>> example self contained without a bunch of properties for every
>>>> buckminster.component in the query).
>>>>
>>>> So, I'm really out of ideas on how this is supposed to work. It's
>>>> great that properties get expanded like that, but I just don't
>>>> understand how I can use the value of buckminster.component in the
>>>> key for a property that will actually get expanded.
>>>>
>>>> Best regards,
>>>> Johannes
>>>>
>>>>
>>>>
Re: dynamic property refs [message #388400 is a reply to message #388397] Wed, 29 July 2009 08:05 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
Johannes Utzig wrote:
> Hi Thomas,
>
> the thing that I can't seem to get to work is this:
> A property of the name artifact.ARTIFACTNAME.path has a value that is
> the relative path to the artifact from the project that produced it. Now
> to use buckminster for the resolution I need three pieces of information:
> -the name of the artifact
> -the name of the project that produced the artifact
> -the property value of artifact.ARTIFACTNAME.path
>
> The parent/child hierarchie seemed close enough to me to Maven + Parent
> poms, so I decided to encode the information about the parent project
> the same way:
> projectName/artifactName is my component name.
>
> Now to look up the relative path I need to split buckminster.component
> and use the artifact name as a property key but I can't get it to work.
> This is how it currently looks like. It's obvious why it doesn't work,
> the 'format' creates a string artifact.artifactName.path, not a
> property, but how would I treat it as a property?
>
Aha, you need to make part of a property a key for another property. Well, you can do that too :-). You need to use a
propertyElement to declare a new property. You can define new properties on the RMAP top level.

<propertyElement key="artifact.name">
<bc:format format="{1}" >
<bc:split pattern="/">
<bc:propertyRef key="buckminster.component" />
</bc:split>
</bc:format>
</propertyElement>

That defines the new artifact.name property. In the provider uri element you should then be able to do:

<bc:propertyRef key="artifact.${artifact.name}.path"/>

HTH,
Thomas Hallgren


>
> <searchPath name="Artifacts">
> <provider readerType="url" componentTypes="jar">
> <!-- the artifact will be in
> //share/artifacts/projectName/${artifact.artifactName.path} -->
> <uri format="file://share/artifacts/{1}/{0}">
> <bc:format format="artifact.{1}.path" >
> <bc:split pattern="/">
> <bc:propertyRef key="buckminster.component" />
> </bc:split>
> </bc:format>
> <bc:split pattern="/">
> <bc:propertyRef key="buckminster.component" />
> </bc:split>
> </uri>
> </provider>
> </searchPath>
>
> I think what I'd need now is a propertyRef that alows the value of a
> nested child element to be the key, then I could resolve my property.
> But maybe I'm just missing the obvious here...
>
> Best regards,
> Johannes
>
> Thomas Hallgren schrieb:
>> Hi Johannes,
>> I'm not sure what it is you are trying to do here:
>>
>> <constant value="${buckminster.component}"/>
>>
>> is exactly the same as
>>
>> <propertyRef key="buckminster.component"/>
>>
>> but
>>
>> <propertyRef key="${buckminster.component}"/>
>>
>> will give you the value of a property with a key that corresponds to
>> the component name. If you want to add things to that, you can of
>> course do:
>>
>> <propertyRef key="${buckminster.component}.foo.bar"/>
>>
>> So what use-case is it that isn't covered?
>>
>> Regards,
>> Thomas Hallgren
>>
>>
>> Johannes Utzig wrote:
>>> Hi Henrik,
>>>
>>> this works of course, but it's not solving my problem. In this setup,
>>> ${user.language} will be expanded to its value and that will be used
>>> as a key, but I need buckminster.component to be expanded and use
>>> that to build a new property key and that's what doesn't seem to work
>>> (that's why I introduced the constants in the example, because if it
>>> would work with a constant, it would probably also work with
>>> buckminster.component + propertyRef).
>>>
>>>
>>> Maybe you have another idea, I'm out of them :)
>>>
>>
>>
>>> Best regards and thank you,
>>> Johannes
>>>
>>> Henrik Lindberg schrieb:
>>>> Hm,
>>>> I can see why the ${{0}} does not work... the {0} is expanded last
>>>> (duh - I should not have suggested that in the first place...)
>>>>
>>>> Here is another attempt:
>>>> <uri format="file://share/artifacts/{0}" >
>>>> <bc:propertyRef key="${user.language}" />
>>>> </uri>
>>>>
>>>> - henrik
>>>>
>>>> Johannes Utzig wrote:
>>>>> Hi,
>>>>>
>>>>> I'm sorry to bother you again, but I simply can't get this to work.
>>>>> This gives me an illegal argument exception:
>>>>> <searchPath name="Artifacts">
>>>>> <provider readerType="url" componentTypes="jar">
>>>>> <uri format="file://share/artifacts/${{0}}/">
>>>>> <bc:constant value="user.language" />
>>>>> </uri>
>>>>> </provider>
>>>>> </searchPath>
>>>>> E [0039] : java.lang.IllegalArgumentException: can't parse argument
>>>>> number {0}: can't parse argument number {0}
>>>>>
>>>>> Quoting it (file://share/artifacts/$'{'{0}'}')
>>>>> doesn't expand the property and leads to an URISyntaxException:
>>>>> java.net.URISyntaxException: Illegal character in path at index 24:
>>>>> file://share/artifacts/${user.language}/
>>>>>
>>>>> This works however:
>>>>> <uri format="file://share/artifacts/{0}/">
>>>>> <bc:constant value="${user.language}" />
>>>>> </uri>
>>>>>
>>>>> This doesn't:
>>>>> <uri format="file://share/artifacts/{0}/">
>>>>> <bc:format format="{0}{1}{2}">
>>>>> <bc:constant value="${" />
>>>>> <bc:constant value="user.language" />
>>>>> <bc:constant value="}" />
>>>>> </bc:format> </uri>
>>>>> ERROR java.net.URISyntaxException: Illegal character in
>>>>> path at index 24: file://share/artifacts/${user.language}/
>>>>>
>>>>> (using user.language doesn't make much sense of course, in my real
>>>>> case I use buckminster.component. user.language just makes the
>>>>> example self contained without a bunch of properties for every
>>>>> buckminster.component in the query).
>>>>>
>>>>> So, I'm really out of ideas on how this is supposed to work. It's
>>>>> great that properties get expanded like that, but I just don't
>>>>> understand how I can use the value of buckminster.component in the
>>>>> key for a property that will actually get expanded.
>>>>>
>>>>> Best regards,
>>>>> Johannes
>>>>>
>>>>>
>>>>>
Re: dynamic property refs [message #388401 is a reply to message #388400] Wed, 29 July 2009 08:30 Go to previous messageGo to next message
Johannes Utzig is currently offline Johannes UtzigFriend
Messages: 329
Registered: July 2009
Senior Member
Thank you so much Thomas, this looks exactly like what I need.
Unfortunately it gives me a NullPointerException without any stacktrace
or message:
ProjectName/ArtifactName:jar: Using resource map
http://somehost.de/some.rmap
ERROR [0001] : java.lang.NullPointerException
Errors and Warnings
E [0001] : java.lang.NullPointerException: java.lang.NullPointerException

The NPE no longer occurs if I remove the split and format in the
property element:
<propertyElement key="artifact.name">
<bc:propertyRef key="buckminster.component" />
</propertyElement>

Now the error is this:
The property ${ artifact.${artifact.name}.path } has not been set and
will default to null

So it looks like the propertyElement does not properly expand
buckminster.component?

Best regards,
Johannes

Thomas Hallgren schrieb:
> Johannes Utzig wrote:
>> Hi Thomas,
>>
>> the thing that I can't seem to get to work is this:
>> A property of the name artifact.ARTIFACTNAME.path has a value that is
>> the relative path to the artifact from the project that produced it.
>> Now to use buckminster for the resolution I need three pieces of
>> information:
>> -the name of the artifact
>> -the name of the project that produced the artifact
>> -the property value of artifact.ARTIFACTNAME.path
>>
>> The parent/child hierarchie seemed close enough to me to Maven +
>> Parent poms, so I decided to encode the information about the parent
>> project the same way:
>> projectName/artifactName is my component name.
>>
>> Now to look up the relative path I need to split buckminster.component
>> and use the artifact name as a property key but I can't get it to work.
>> This is how it currently looks like. It's obvious why it doesn't work,
>> the 'format' creates a string artifact.artifactName.path, not a
>> property, but how would I treat it as a property?
>>
> Aha, you need to make part of a property a key for another property.
> Well, you can do that too :-). You need to use a propertyElement to
> declare a new property. You can define new properties on the RMAP top
> level.
>
> <propertyElement key="artifact.name">
> <bc:format format="{1}" >
> <bc:split pattern="/">
> <bc:propertyRef key="buckminster.component" />
> </bc:split>
> </bc:format>
> </propertyElement>
>
> That defines the new artifact.name property. In the provider uri element
> you should then be able to do:
>
> <bc:propertyRef key="artifact.${artifact.name}.path"/>
>
> HTH,
> Thomas Hallgren
>
>
>>
>> <searchPath name="Artifacts">
>> <provider readerType="url" componentTypes="jar">
>> <!-- the artifact will be in
>> //share/artifacts/projectName/${artifact.artifactName.path} -->
>> <uri format="file://share/artifacts/{1}/{0}">
>> <bc:format format="artifact.{1}.path" >
>> <bc:split pattern="/">
>> <bc:propertyRef key="buckminster.component" />
>> </bc:split>
>> </bc:format>
>> <bc:split pattern="/">
>> <bc:propertyRef key="buckminster.component" />
>> </bc:split> </uri>
>> </provider>
>> </searchPath>
>>
>> I think what I'd need now is a propertyRef that alows the value of a
>> nested child element to be the key, then I could resolve my property.
>> But maybe I'm just missing the obvious here...
>>
>> Best regards,
>> Johannes
>>
>> Thomas Hallgren schrieb:
>>> Hi Johannes,
>>> I'm not sure what it is you are trying to do here:
>>>
>>> <constant value="${buckminster.component}"/>
>>>
>>> is exactly the same as
>>>
>>> <propertyRef key="buckminster.component"/>
>>>
>>> but
>>>
>>> <propertyRef key="${buckminster.component}"/>
>>>
>>> will give you the value of a property with a key that corresponds to
>>> the component name. If you want to add things to that, you can of
>>> course do:
>>>
>>> <propertyRef key="${buckminster.component}.foo.bar"/>
>>>
>>> So what use-case is it that isn't covered?
>>>
>>> Regards,
>>> Thomas Hallgren
>>>
>>>
>>> Johannes Utzig wrote:
>>>> Hi Henrik,
>>>>
>>>> this works of course, but it's not solving my problem. In this
>>>> setup, ${user.language} will be expanded to its value and that will
>>>> be used as a key, but I need buckminster.component to be expanded
>>>> and use that to build a new property key and that's what doesn't
>>>> seem to work (that's why I introduced the constants in the example,
>>>> because if it would work with a constant, it would probably also
>>>> work with buckminster.component + propertyRef).
>>>>
>>>>
>>>> Maybe you have another idea, I'm out of them :)
>>>>
>>>
>>>
>>>> Best regards and thank you,
>>>> Johannes
>>>>
>>>> Henrik Lindberg schrieb:
>>>>> Hm,
>>>>> I can see why the ${{0}} does not work... the {0} is expanded last
>>>>> (duh - I should not have suggested that in the first place...)
>>>>>
>>>>> Here is another attempt:
>>>>> <uri format="file://share/artifacts/{0}" >
>>>>> <bc:propertyRef key="${user.language}" />
>>>>> </uri>
>>>>>
>>>>> - henrik
>>>>>
>>>>> Johannes Utzig wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I'm sorry to bother you again, but I simply can't get this to work.
>>>>>> This gives me an illegal argument exception:
>>>>>> <searchPath name="Artifacts">
>>>>>> <provider readerType="url" componentTypes="jar">
>>>>>> <uri format="file://share/artifacts/${{0}}/">
>>>>>> <bc:constant value="user.language" />
>>>>>> </uri>
>>>>>> </provider>
>>>>>> </searchPath>
>>>>>> E [0039] : java.lang.IllegalArgumentException: can't parse
>>>>>> argument number {0}: can't parse argument number {0}
>>>>>>
>>>>>> Quoting it (file://share/artifacts/$'{'{0}'}')
>>>>>> doesn't expand the property and leads to an URISyntaxException:
>>>>>> java.net.URISyntaxException: Illegal character in path at index
>>>>>> 24: file://share/artifacts/${user.language}/
>>>>>>
>>>>>> This works however:
>>>>>> <uri format="file://share/artifacts/{0}/">
>>>>>> <bc:constant value="${user.language}" />
>>>>>> </uri>
>>>>>>
>>>>>> This doesn't:
>>>>>> <uri format="file://share/artifacts/{0}/">
>>>>>> <bc:format format="{0}{1}{2}">
>>>>>> <bc:constant value="${" />
>>>>>> <bc:constant value="user.language" />
>>>>>> <bc:constant value="}" />
>>>>>> </bc:format> </uri>
>>>>>> ERROR java.net.URISyntaxException: Illegal character in
>>>>>> path at index 24: file://share/artifacts/${user.language}/
>>>>>>
>>>>>> (using user.language doesn't make much sense of course, in my real
>>>>>> case I use buckminster.component. user.language just makes the
>>>>>> example self contained without a bunch of properties for every
>>>>>> buckminster.component in the query).
>>>>>>
>>>>>> So, I'm really out of ideas on how this is supposed to work. It's
>>>>>> great that properties get expanded like that, but I just don't
>>>>>> understand how I can use the value of buckminster.component in the
>>>>>> key for a property that will actually get expanded.
>>>>>>
>>>>>> Best regards,
>>>>>> Johannes
>>>>>>
>>>>>>
>>>>>>
Re: dynamic property refs [message #388463 is a reply to message #388401] Wed, 29 July 2009 08:40 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
Does your <workspace>/.metadata/.log reveal anything?

- thomas

Johannes Utzig wrote:
> Thank you so much Thomas, this looks exactly like what I need.
> Unfortunately it gives me a NullPointerException without any stacktrace
> or message:
> ProjectName/ArtifactName:jar: Using resource map
> http://somehost.de/some.rmap
> ERROR [0001] : java.lang.NullPointerException
> Errors and Warnings
> E [0001] : java.lang.NullPointerException: java.lang.NullPointerException
>
> The NPE no longer occurs if I remove the split and format in the
> property element:
> <propertyElement key="artifact.name">
> <bc:propertyRef key="buckminster.component" />
> </propertyElement>
>
> Now the error is this:
> The property ${ artifact.${artifact.name}.path } has not been set and
> will default to null
>
> So it looks like the propertyElement does not properly expand
> buckminster.component?
>
> Best regards,
> Johannes
>
> Thomas Hallgren schrieb:
>> Johannes Utzig wrote:
>>> Hi Thomas,
>>>
>>> the thing that I can't seem to get to work is this:
>>> A property of the name artifact.ARTIFACTNAME.path has a value that
>>> is the relative path to the artifact from the project that produced
>>> it. Now to use buckminster for the resolution I need three pieces of
>>> information:
>>> -the name of the artifact
>>> -the name of the project that produced the artifact
>>> -the property value of artifact.ARTIFACTNAME.path
>>>
>>> The parent/child hierarchie seemed close enough to me to Maven +
>>> Parent poms, so I decided to encode the information about the parent
>>> project the same way:
>>> projectName/artifactName is my component name.
>>>
>>> Now to look up the relative path I need to split
>>> buckminster.component and use the artifact name as a property key but
>>> I can't get it to work.
>>> This is how it currently looks like. It's obvious why it doesn't
>>> work, the 'format' creates a string artifact.artifactName.path, not a
>>> property, but how would I treat it as a property?
>>>
>> Aha, you need to make part of a property a key for another property.
>> Well, you can do that too :-). You need to use a propertyElement to
>> declare a new property. You can define new properties on the RMAP top
>> level.
>>
>> <propertyElement key="artifact.name">
>> <bc:format format="{1}" >
>> <bc:split pattern="/">
>> <bc:propertyRef key="buckminster.component" />
>> </bc:split>
>> </bc:format>
>> </propertyElement>
>>
>> That defines the new artifact.name property. In the provider uri
>> element you should then be able to do:
>>
>> <bc:propertyRef key="artifact.${artifact.name}.path"/>
>>
>> HTH,
>> Thomas Hallgren
>>
>>
>>>
>>> <searchPath name="Artifacts">
>>> <provider readerType="url" componentTypes="jar">
>>> <!-- the artifact will be in
>>> //share/artifacts/projectName/${artifact.artifactName.path} -->
>>> <uri format="file://share/artifacts/{1}/{0}">
>>> <bc:format format="artifact.{1}.path" >
>>> <bc:split pattern="/">
>>> <bc:propertyRef key="buckminster.component" />
>>> </bc:split>
>>> </bc:format>
>>> <bc:split pattern="/">
>>> <bc:propertyRef key="buckminster.component" />
>>> </bc:split> </uri>
>>> </provider>
>>> </searchPath>
>>>
>>> I think what I'd need now is a propertyRef that alows the value of a
>>> nested child element to be the key, then I could resolve my property.
>>> But maybe I'm just missing the obvious here...
>>>
>>> Best regards,
>>> Johannes
>>>
>>> Thomas Hallgren schrieb:
>>>> Hi Johannes,
>>>> I'm not sure what it is you are trying to do here:
>>>>
>>>> <constant value="${buckminster.component}"/>
>>>>
>>>> is exactly the same as
>>>>
>>>> <propertyRef key="buckminster.component"/>
>>>>
>>>> but
>>>>
>>>> <propertyRef key="${buckminster.component}"/>
>>>>
>>>> will give you the value of a property with a key that corresponds to
>>>> the component name. If you want to add things to that, you can of
>>>> course do:
>>>>
>>>> <propertyRef key="${buckminster.component}.foo.bar"/>
>>>>
>>>> So what use-case is it that isn't covered?
>>>>
>>>> Regards,
>>>> Thomas Hallgren
>>>>
>>>>
>>>> Johannes Utzig wrote:
>>>>> Hi Henrik,
>>>>>
>>>>> this works of course, but it's not solving my problem. In this
>>>>> setup, ${user.language} will be expanded to its value and that will
>>>>> be used as a key, but I need buckminster.component to be expanded
>>>>> and use that to build a new property key and that's what doesn't
>>>>> seem to work (that's why I introduced the constants in the example,
>>>>> because if it would work with a constant, it would probably also
>>>>> work with buckminster.component + propertyRef).
>>>>>
>>>>>
>>>>> Maybe you have another idea, I'm out of them :)
>>>>>
>>>>
>>>>
>>>>> Best regards and thank you,
>>>>> Johannes
>>>>>
>>>>> Henrik Lindberg schrieb:
>>>>>> Hm,
>>>>>> I can see why the ${{0}} does not work... the {0} is expanded last
>>>>>> (duh - I should not have suggested that in the first place...)
>>>>>>
>>>>>> Here is another attempt:
>>>>>> <uri format="file://share/artifacts/{0}" >
>>>>>> <bc:propertyRef key="${user.language}" />
>>>>>> </uri>
>>>>>>
>>>>>> - henrik
>>>>>>
>>>>>> Johannes Utzig wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I'm sorry to bother you again, but I simply can't get this to work.
>>>>>>> This gives me an illegal argument exception:
>>>>>>> <searchPath name="Artifacts">
>>>>>>> <provider readerType="url" componentTypes="jar">
>>>>>>> <uri format="file://share/artifacts/${{0}}/">
>>>>>>> <bc:constant value="user.language" />
>>>>>>> </uri>
>>>>>>> </provider>
>>>>>>> </searchPath>
>>>>>>> E [0039] : java.lang.IllegalArgumentException: can't parse
>>>>>>> argument number {0}: can't parse argument number {0}
>>>>>>>
>>>>>>> Quoting it (file://share/artifacts/$'{'{0}'}')
>>>>>>> doesn't expand the property and leads to an URISyntaxException:
>>>>>>> java.net.URISyntaxException: Illegal character in path at index
>>>>>>> 24: file://share/artifacts/${user.language}/
>>>>>>>
>>>>>>> This works however:
>>>>>>> <uri format="file://share/artifacts/{0}/">
>>>>>>> <bc:constant value="${user.language}" />
>>>>>>> </uri>
>>>>>>>
>>>>>>> This doesn't:
>>>>>>> <uri format="file://share/artifacts/{0}/">
>>>>>>> <bc:format format="{0}{1}{2}">
>>>>>>> <bc:constant value="${" />
>>>>>>> <bc:constant value="user.language" />
>>>>>>> <bc:constant value="}" />
>>>>>>> </bc:format> </uri>
>>>>>>> ERROR java.net.URISyntaxException: Illegal character in
>>>>>>> path at index 24: file://share/artifacts/${user.language}/
>>>>>>>
>>>>>>> (using user.language doesn't make much sense of course, in my
>>>>>>> real case I use buckminster.component. user.language just makes
>>>>>>> the example self contained without a bunch of properties for
>>>>>>> every buckminster.component in the query).
>>>>>>>
>>>>>>> So, I'm really out of ideas on how this is supposed to work. It's
>>>>>>> great that properties get expanded like that, but I just don't
>>>>>>> understand how I can use the value of buckminster.component in
>>>>>>> the key for a property that will actually get expanded.
>>>>>>>
>>>>>>> Best regards,
>>>>>>> Johannes
>>>>>>>
>>>>>>>
>>>>>>>
Re: dynamic property refs [message #388465 is a reply to message #388401] Wed, 29 July 2009 08:42 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
Another question.

Johannes Utzig wrote:
> Now the error is this:
> The property ${ artifact.${artifact.name}.path } has not been set and
> will default to null
>
It looks like you have spaces in that property key. Did you add them for clarity here or are they present in your
declaration?

- thomas
Re: dynamic property refs [message #388468 is a reply to message #388463] Wed, 29 July 2009 08:44 Go to previous messageGo to next message
Johannes Utzig is currently offline Johannes UtzigFriend
Messages: 329
Registered: July 2009
Senior Member
No, I checked that too, no more information:

!ENTRY org.eclipse.buckminster.core 4 293 2009-07-29 10:24:26.312
!MESSAGE Errors and Warnings

!ENTRY org.eclipse.buckminster.core 4 293 2009-07-29 10:24:26.312
!MESSAGE E [0001] : java.lang.NullPointerException:
java.lang.NullPointerException

!ENTRY org.eclipse.buckminster.core 2 293 2009-07-29 10:26:12.921
!MESSAGE The property ${ artifact.${artifact.name}.path } has not been
set and will default to null

I also set the buckminster log level to debug but I'm not getting any
additional information.

Thomas Hallgren schrieb:
> Does your <workspace>/.metadata/.log reveal anything?
>
> - thomas
>
> Johannes Utzig wrote:
>> Thank you so much Thomas, this looks exactly like what I need.
>> Unfortunately it gives me a NullPointerException without any
>> stacktrace or message:
>> ProjectName/ArtifactName:jar: Using resource map
>> http://somehost.de/some.rmap
>> ERROR [0001] : java.lang.NullPointerException
>> Errors and Warnings
>> E [0001] : java.lang.NullPointerException: java.lang.NullPointerException
>>
>> The NPE no longer occurs if I remove the split and format in the
>> property element:
>> <propertyElement key="artifact.name">
>> <bc:propertyRef key="buckminster.component" />
>> </propertyElement>
>>
>> Now the error is this:
>> The property ${ artifact.${artifact.name}.path } has not been set and
>> will default to null
>>
>> So it looks like the propertyElement does not properly expand
>> buckminster.component?
>>
>> Best regards,
>> Johannes
>>
>> Thomas Hallgren schrieb:
>>> Johannes Utzig wrote:
>>>> Hi Thomas,
>>>>
>>>> the thing that I can't seem to get to work is this:
>>>> A property of the name artifact.ARTIFACTNAME.path has a value that
>>>> is the relative path to the artifact from the project that produced
>>>> it. Now to use buckminster for the resolution I need three pieces of
>>>> information:
>>>> -the name of the artifact
>>>> -the name of the project that produced the artifact
>>>> -the property value of artifact.ARTIFACTNAME.path
>>>>
>>>> The parent/child hierarchie seemed close enough to me to Maven +
>>>> Parent poms, so I decided to encode the information about the parent
>>>> project the same way:
>>>> projectName/artifactName is my component name.
>>>>
>>>> Now to look up the relative path I need to split
>>>> buckminster.component and use the artifact name as a property key
>>>> but I can't get it to work.
>>>> This is how it currently looks like. It's obvious why it doesn't
>>>> work, the 'format' creates a string artifact.artifactName.path, not
>>>> a property, but how would I treat it as a property?
>>>>
>>> Aha, you need to make part of a property a key for another property.
>>> Well, you can do that too :-). You need to use a propertyElement to
>>> declare a new property. You can define new properties on the RMAP top
>>> level.
>>>
>>> <propertyElement key="artifact.name">
>>> <bc:format format="{1}" >
>>> <bc:split pattern="/">
>>> <bc:propertyRef key="buckminster.component" />
>>> </bc:split>
>>> </bc:format>
>>> </propertyElement>
>>>
>>> That defines the new artifact.name property. In the provider uri
>>> element you should then be able to do:
>>>
>>> <bc:propertyRef key="artifact.${artifact.name}.path"/>
>>>
>>> HTH,
>>> Thomas Hallgren
>>>
>>>
>>>>
>>>> <searchPath name="Artifacts">
>>>> <provider readerType="url" componentTypes="jar">
>>>> <!-- the artifact will be in
>>>> //share/artifacts/projectName/${artifact.artifactName.path} -->
>>>> <uri format="file://share/artifacts/{1}/{0}">
>>>> <bc:format format="artifact.{1}.path" >
>>>> <bc:split pattern="/">
>>>> <bc:propertyRef key="buckminster.component" />
>>>> </bc:split>
>>>> </bc:format>
>>>> <bc:split pattern="/">
>>>> <bc:propertyRef key="buckminster.component" />
>>>> </bc:split> </uri>
>>>> </provider>
>>>> </searchPath>
>>>>
>>>> I think what I'd need now is a propertyRef that alows the value of a
>>>> nested child element to be the key, then I could resolve my property.
>>>> But maybe I'm just missing the obvious here...
>>>>
>>>> Best regards,
>>>> Johannes
>>>>
>>>> Thomas Hallgren schrieb:
>>>>> Hi Johannes,
>>>>> I'm not sure what it is you are trying to do here:
>>>>>
>>>>> <constant value="${buckminster.component}"/>
>>>>>
>>>>> is exactly the same as
>>>>>
>>>>> <propertyRef key="buckminster.component"/>
>>>>>
>>>>> but
>>>>>
>>>>> <propertyRef key="${buckminster.component}"/>
>>>>>
>>>>> will give you the value of a property with a key that corresponds
>>>>> to the component name. If you want to add things to that, you can
>>>>> of course do:
>>>>>
>>>>> <propertyRef key="${buckminster.component}.foo.bar"/>
>>>>>
>>>>> So what use-case is it that isn't covered?
>>>>>
>>>>> Regards,
>>>>> Thomas Hallgren
>>>>>
>>>>>
>>>>> Johannes Utzig wrote:
>>>>>> Hi Henrik,
>>>>>>
>>>>>> this works of course, but it's not solving my problem. In this
>>>>>> setup, ${user.language} will be expanded to its value and that
>>>>>> will be used as a key, but I need buckminster.component to be
>>>>>> expanded and use that to build a new property key and that's what
>>>>>> doesn't seem to work (that's why I introduced the constants in the
>>>>>> example, because if it would work with a constant, it would
>>>>>> probably also work with buckminster.component + propertyRef).
>>>>>>
>>>>>>
>>>>>> Maybe you have another idea, I'm out of them :)
>>>>>>
>>>>>
>>>>>
>>>>>> Best regards and thank you,
>>>>>> Johannes
>>>>>>
>>>>>> Henrik Lindberg schrieb:
>>>>>>> Hm,
>>>>>>> I can see why the ${{0}} does not work... the {0} is expanded
>>>>>>> last (duh - I should not have suggested that in the first place...)
>>>>>>>
>>>>>>> Here is another attempt:
>>>>>>> <uri format="file://share/artifacts/{0}" >
>>>>>>> <bc:propertyRef key="${user.language}" />
>>>>>>> </uri>
>>>>>>>
>>>>>>> - henrik
>>>>>>>
>>>>>>> Johannes Utzig wrote:
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I'm sorry to bother you again, but I simply can't get this to work.
>>>>>>>> This gives me an illegal argument exception:
>>>>>>>> <searchPath name="Artifacts">
>>>>>>>> <provider readerType="url" componentTypes="jar">
>>>>>>>> <uri format="file://share/artifacts/${{0}}/">
>>>>>>>> <bc:constant value="user.language" />
>>>>>>>> </uri>
>>>>>>>> </provider>
>>>>>>>> </searchPath>
>>>>>>>> E [0039] : java.lang.IllegalArgumentException: can't parse
>>>>>>>> argument number {0}: can't parse argument number {0}
>>>>>>>>
>>>>>>>> Quoting it (file://share/artifacts/$'{'{0}'}')
>>>>>>>> doesn't expand the property and leads to an URISyntaxException:
>>>>>>>> java.net.URISyntaxException: Illegal character in path at index
>>>>>>>> 24: file://share/artifacts/${user.language}/
>>>>>>>>
>>>>>>>> This works however:
>>>>>>>> <uri format="file://share/artifacts/{0}/">
>>>>>>>> <bc:constant value="${user.language}"
>>>>>>>> /> </uri>
>>>>>>>>
>>>>>>>> This doesn't:
>>>>>>>> <uri format="file://share/artifacts/{0}/">
>>>>>>>> <bc:format format="{0}{1}{2}">
>>>>>>>> <bc:constant value="${" />
>>>>>>>> <bc:constant value="user.language" />
>>>>>>>> <bc:constant value="}" />
>>>>>>>> </bc:format> </uri>
>>>>>>>> ERROR java.net.URISyntaxException: Illegal character in
>>>>>>>> path at index 24: file://share/artifacts/${user.language}/
>>>>>>>>
>>>>>>>> (using user.language doesn't make much sense of course, in my
>>>>>>>> real case I use buckminster.component. user.language just makes
>>>>>>>> the example self contained without a bunch of properties for
>>>>>>>> every buckminster.component in the query).
>>>>>>>>
>>>>>>>> So, I'm really out of ideas on how this is supposed to work.
>>>>>>>> It's great that properties get expanded like that, but I just
>>>>>>>> don't understand how I can use the value of
>>>>>>>> buckminster.component in the key for a property that will
>>>>>>>> actually get expanded.
>>>>>>>>
>>>>>>>> Best regards,
>>>>>>>> Johannes
>>>>>>>>
>>>>>>>>
>>>>>>>>
Re: dynamic property refs [message #388469 is a reply to message #388465] Wed, 29 July 2009 08:49 Go to previous messageGo to next message
Johannes Utzig is currently offline Johannes UtzigFriend
Messages: 329
Registered: July 2009
Senior Member
Thomas Hallgren schrieb:
> Another question.
>
> Johannes Utzig wrote:
>> Now the error is this:
>> The property ${ artifact.${artifact.name}.path } has not been set and
>> will default to null
>>
> It looks like you have spaces in that property key. Did you add them for
> clarity here or are they present in your declaration?
>
> - thomas
No, I didn't add them, and they are not part of the rmap. Looks like
that's just done by buckminster for the log output.

These are the parts in the rmap:

<propertyElement key="artifact.name">
<bc:format format="{1}" >
<bc:split pattern="/">
<bc:propertyRef key="buckminster.component" />
</bc:split>
</bc:format>
</propertyElement>

<searchPath name="Artifacts">
<provider readerType="url" componentTypes="jar">
<uri format="file://share/artifacts/{1}/{0}">
<bc:propertyRef key="artifact.${artifact.name}.path" />
<bc:split pattern="/">
<bc:propertyRef key="buckminster.component" />
</bc:split>
</uri>
</provider>
</searchPath>
Re: dynamic property refs [message #388474 is a reply to message #388401] Wed, 29 July 2009 10:16 Go to previous messageGo to next message
Carsten Reckord is currently offline Carsten ReckordFriend
Messages: 139
Registered: July 2009
Senior Member
When I experimented with top-level properties in my RMAPs, I noticed that they seem to be evaluated statically, i.e. once when the RMAP is
instantiated instead of per resolution. Therefore the

> <bc:propertyRef key="buckminster.component" />

will evaluate to null in a top-level propertyElement. I guess the NPE is caused by the subsequent formatting because either no {1} exists in
the String "null" or because it literally gets a null value from the propertyRef.

My problem with that was that things like this don't work:

<property key="default.value" value="null"/>
<property key="a.value" value="${default.value}"/>
<property key="b.value" value="${default.value}"/>

You'll always get a.value="null" even when default.value is set per -D or -P argument on invocation.

I wanted to use these kind of chained properties to make SCM urls and credentials per searchPath more configurable, like this:
<rmap>
<property key="svn.user" value="null"/>
<property key="svn.pass" value="null"/>
<property key="svn.user.a" value="${svn.user}"/>
<property key="svn.user.b" value="${svn.user}"/>
<property key="svn.pass.a" value="${svn.pass}"/>
<property key="svn.pass.b" value="${svn.pass}"/>
<property key="svn.url.a" value="svn+ssh://{0}:{1}@url/trunk"/>
<property key="svn.url.b" value="svn+ssh://{0}:{1}@other/url/trunk"/>

<searchPath name="a">
<provider readerType="svn" componentTypes="osgi.bundle,eclipse-feature" mutable="true" source="true">
<uri format="${svn.url.a}/{2}">
<bc:propertyRef key="svn.user.a" />
<bc:propertyRef key="svn.pass.a" />
<bc:propertyRef key="buckminster.component" />
</uri>
</provider>
</searchPath>

<searchPath name="b">
<provider readerType="svn" componentTypes="osgi.bundle,eclipse-feature" mutable="true" source="true">
<uri format="${svn.url.b}/{2}">
<bc:propertyRef key="svn.user.b" />
<bc:propertyRef key="svn.pass.b" />
<bc:propertyRef key="buckminster.component" />
</uri>
</provider>
</searchPath>

...
</rmap>


This way it would have been easy to override values on invocation without using a ton of properties (just set e.g. the svn.user and it's
used for all svn credentials, or override a specific one if that's needed)

On 29.07.2009 10:30, Johannes Utzig wrote:
> Thank you so much Thomas, this looks exactly like what I need.
> Unfortunately it gives me a NullPointerException without any stacktrace
> or message:
> ProjectName/ArtifactName:jar: Using resource map
> http://somehost.de/some.rmap
> ERROR [0001] : java.lang.NullPointerException
> Errors and Warnings
> E [0001] : java.lang.NullPointerException: java.lang.NullPointerException
>
> The NPE no longer occurs if I remove the split and format in the
> property element:
> <propertyElement key="artifact.name">
> <bc:propertyRef key="buckminster.component" />
> </propertyElement>
>
> Now the error is this:
> The property ${ artifact.${artifact.name}.path } has not been set and
> will default to null
>
> So it looks like the propertyElement does not properly expand
> buckminster.component?
>
> Best regards,
> Johannes
Re: dynamic property refs [message #388485 is a reply to message #388474] Wed, 29 July 2009 11:02 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
Carsten Reckord wrote:
> When I experimented with top-level properties in my RMAPs, I noticed
> that they seem to be evaluated statically, i.e. once when the RMAP is
> instantiated instead of per resolution. Therefore the
>
> > <bc:propertyRef key="buckminster.component" />
>
> will evaluate to null in a top-level propertyElement. I guess the NPE is
> caused by the subsequent formatting because either no {1} exists in the
> String "null" or because it literally gets a null value from the
> propertyRef.
>
Ouch! Can you please enter a bugzilla on this?
Re: dynamic property refs [message #388488 is a reply to message #388468] Wed, 29 July 2009 11:02 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
Hi Johannes,
Can you please enter a bugzilla on this NPE?

Thanks,
Thomas Hallgren

Johannes Utzig wrote:
> No, I checked that too, no more information:
>
> !ENTRY org.eclipse.buckminster.core 4 293 2009-07-29 10:24:26.312
> !MESSAGE Errors and Warnings
>
> !ENTRY org.eclipse.buckminster.core 4 293 2009-07-29 10:24:26.312
> !MESSAGE E [0001] : java.lang.NullPointerException:
> java.lang.NullPointerException
>
> !ENTRY org.eclipse.buckminster.core 2 293 2009-07-29 10:26:12.921
> !MESSAGE The property ${ artifact.${artifact.name}.path } has not been
> set and will default to null
>
> I also set the buckminster log level to debug but I'm not getting any
> additional information.
>
> Thomas Hallgren schrieb:
>> Does your <workspace>/.metadata/.log reveal anything?
>>
>> - thomas
>>
>> Johannes Utzig wrote:
>>> Thank you so much Thomas, this looks exactly like what I need.
>>> Unfortunately it gives me a NullPointerException without any
>>> stacktrace or message:
>>> ProjectName/ArtifactName:jar: Using resource map
>>> http://somehost.de/some.rmap
>>> ERROR [0001] : java.lang.NullPointerException
>>> Errors and Warnings
>>> E [0001] : java.lang.NullPointerException:
>>> java.lang.NullPointerException
>>>
>>> The NPE no longer occurs if I remove the split and format in the
>>> property element:
>>> <propertyElement key="artifact.name">
>>> <bc:propertyRef key="buckminster.component" />
>>> </propertyElement>
>>>
>>> Now the error is this:
>>> The property ${ artifact.${artifact.name}.path } has not been set and
>>> will default to null
>>>
>>> So it looks like the propertyElement does not properly expand
>>> buckminster.component?
>>>
>>> Best regards,
>>> Johannes
>>>
>>> Thomas Hallgren schrieb:
>>>> Johannes Utzig wrote:
>>>>> Hi Thomas,
>>>>>
>>>>> the thing that I can't seem to get to work is this:
>>>>> A property of the name artifact.ARTIFACTNAME.path has a value that
>>>>> is the relative path to the artifact from the project that produced
>>>>> it. Now to use buckminster for the resolution I need three pieces
>>>>> of information:
>>>>> -the name of the artifact
>>>>> -the name of the project that produced the artifact
>>>>> -the property value of artifact.ARTIFACTNAME.path
>>>>>
>>>>> The parent/child hierarchie seemed close enough to me to Maven +
>>>>> Parent poms, so I decided to encode the information about the
>>>>> parent project the same way:
>>>>> projectName/artifactName is my component name.
>>>>>
>>>>> Now to look up the relative path I need to split
>>>>> buckminster.component and use the artifact name as a property key
>>>>> but I can't get it to work.
>>>>> This is how it currently looks like. It's obvious why it doesn't
>>>>> work, the 'format' creates a string artifact.artifactName.path, not
>>>>> a property, but how would I treat it as a property?
>>>>>
>>>> Aha, you need to make part of a property a key for another property.
>>>> Well, you can do that too :-). You need to use a propertyElement to
>>>> declare a new property. You can define new properties on the RMAP
>>>> top level.
>>>>
>>>> <propertyElement key="artifact.name">
>>>> <bc:format format="{1}" >
>>>> <bc:split pattern="/">
>>>> <bc:propertyRef key="buckminster.component" />
>>>> </bc:split>
>>>> </bc:format>
>>>> </propertyElement>
>>>>
>>>> That defines the new artifact.name property. In the provider uri
>>>> element you should then be able to do:
>>>>
>>>> <bc:propertyRef key="artifact.${artifact.name}.path"/>
>>>>
>>>> HTH,
>>>> Thomas Hallgren
>>>>
>>>>
>>>>>
>>>>> <searchPath name="Artifacts">
>>>>> <provider readerType="url" componentTypes="jar">
>>>>> <!-- the artifact will be in
>>>>> //share/artifacts/projectName/${artifact.artifactName.path} -->
>>>>> <uri format="file://share/artifacts/{1}/{0}">
>>>>> <bc:format format="artifact.{1}.path" >
>>>>> <bc:split pattern="/">
>>>>> <bc:propertyRef key="buckminster.component" />
>>>>> </bc:split>
>>>>> </bc:format>
>>>>> <bc:split pattern="/">
>>>>> <bc:propertyRef key="buckminster.component" />
>>>>> </bc:split> </uri>
>>>>> </provider>
>>>>> </searchPath>
>>>>>
>>>>> I think what I'd need now is a propertyRef that alows the value of
>>>>> a nested child element to be the key, then I could resolve my
>>>>> property.
>>>>> But maybe I'm just missing the obvious here...
>>>>>
>>>>> Best regards,
>>>>> Johannes
>>>>>
>>>>> Thomas Hallgren schrieb:
>>>>>> Hi Johannes,
>>>>>> I'm not sure what it is you are trying to do here:
>>>>>>
>>>>>> <constant value="${buckminster.component}"/>
>>>>>>
>>>>>> is exactly the same as
>>>>>>
>>>>>> <propertyRef key="buckminster.component"/>
>>>>>>
>>>>>> but
>>>>>>
>>>>>> <propertyRef key="${buckminster.component}"/>
>>>>>>
>>>>>> will give you the value of a property with a key that corresponds
>>>>>> to the component name. If you want to add things to that, you can
>>>>>> of course do:
>>>>>>
>>>>>> <propertyRef key="${buckminster.component}.foo.bar"/>
>>>>>>
>>>>>> So what use-case is it that isn't covered?
>>>>>>
>>>>>> Regards,
>>>>>> Thomas Hallgren
>>>>>>
>>>>>>
>>>>>> Johannes Utzig wrote:
>>>>>>> Hi Henrik,
>>>>>>>
>>>>>>> this works of course, but it's not solving my problem. In this
>>>>>>> setup, ${user.language} will be expanded to its value and that
>>>>>>> will be used as a key, but I need buckminster.component to be
>>>>>>> expanded and use that to build a new property key and that's what
>>>>>>> doesn't seem to work (that's why I introduced the constants in
>>>>>>> the example, because if it would work with a constant, it would
>>>>>>> probably also work with buckminster.component + propertyRef).
>>>>>>>
>>>>>>>
>>>>>>> Maybe you have another idea, I'm out of them :)
>>>>>>>
>>>>>>
>>>>>>
>>>>>>> Best regards and thank you,
>>>>>>> Johannes
>>>>>>>
>>>>>>> Henrik Lindberg schrieb:
>>>>>>>> Hm,
>>>>>>>> I can see why the ${{0}} does not work... the {0} is expanded
>>>>>>>> last (duh - I should not have suggested that in the first place...)
>>>>>>>>
>>>>>>>> Here is another attempt:
>>>>>>>> <uri format="file://share/artifacts/{0}" >
>>>>>>>> <bc:propertyRef key="${user.language}" />
>>>>>>>> </uri>
>>>>>>>>
>>>>>>>> - henrik
>>>>>>>>
>>>>>>>> Johannes Utzig wrote:
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> I'm sorry to bother you again, but I simply can't get this to
>>>>>>>>> work.
>>>>>>>>> This gives me an illegal argument exception:
>>>>>>>>> <searchPath name="Artifacts">
>>>>>>>>> <provider readerType="url" componentTypes="jar">
>>>>>>>>> <uri format="file://share/artifacts/${{0}}/">
>>>>>>>>> <bc:constant value="user.language" />
>>>>>>>>> </uri>
>>>>>>>>> </provider>
>>>>>>>>> </searchPath>
>>>>>>>>> E [0039] : java.lang.IllegalArgumentException: can't parse
>>>>>>>>> argument number {0}: can't parse argument number {0}
>>>>>>>>>
>>>>>>>>> Quoting it (file://share/artifacts/$'{'{0}'}')
>>>>>>>>> doesn't expand the property and leads to an URISyntaxException:
>>>>>>>>> java.net.URISyntaxException: Illegal character in path at index
>>>>>>>>> 24: file://share/artifacts/${user.language}/
>>>>>>>>>
>>>>>>>>> This works however:
>>>>>>>>> <uri format="file://share/artifacts/{0}/">
>>>>>>>>> <bc:constant value="${user.language}"
>>>>>>>>> /> </uri>
>>>>>>>>>
>>>>>>>>> This doesn't:
>>>>>>>>> <uri format="file://share/artifacts/{0}/">
>>>>>>>>> <bc:format format="{0}{1}{2}">
>>>>>>>>> <bc:constant value="${" />
>>>>>>>>> <bc:constant value="user.language" />
>>>>>>>>> <bc:constant value="}" />
>>>>>>>>> </bc:format> </uri>
>>>>>>>>> ERROR java.net.URISyntaxException: Illegal character in
>>>>>>>>> path at index 24: file://share/artifacts/${user.language}/
>>>>>>>>>
>>>>>>>>> (using user.language doesn't make much sense of course, in my
>>>>>>>>> real case I use buckminster.component. user.language just makes
>>>>>>>>> the example self contained without a bunch of properties for
>>>>>>>>> every buckminster.component in the query).
>>>>>>>>>
>>>>>>>>> So, I'm really out of ideas on how this is supposed to work.
>>>>>>>>> It's great that properties get expanded like that, but I just
>>>>>>>>> don't understand how I can use the value of
>>>>>>>>> buckminster.component in the key for a property that will
>>>>>>>>> actually get expanded.
>>>>>>>>>
>>>>>>>>> Best regards,
>>>>>>>>> Johannes
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
Re: dynamic property refs [message #388493 is a reply to message #388488] Wed, 29 July 2009 11:28 Go to previous message
Johannes Utzig is currently offline Johannes UtzigFriend
Messages: 329
Registered: July 2009
Senior Member
Hi Thomas,

done: https://bugs.eclipse.org/bugs/show_bug.cgi?id=284995

Best regards,
Johannes

Thomas Hallgren schrieb:
> Hi Johannes,
> Can you please enter a bugzilla on this NPE?
>
> Thanks,
> Thomas Hallgren
>
> Johannes Utzig wrote:
>> No, I checked that too, no more information:
>>
>> !ENTRY org.eclipse.buckminster.core 4 293 2009-07-29 10:24:26.312
>> !MESSAGE Errors and Warnings
>>
>> !ENTRY org.eclipse.buckminster.core 4 293 2009-07-29 10:24:26.312
>> !MESSAGE E [0001] : java.lang.NullPointerException:
>> java.lang.NullPointerException
>>
>> !ENTRY org.eclipse.buckminster.core 2 293 2009-07-29 10:26:12.921
>> !MESSAGE The property ${ artifact.${artifact.name}.path } has not been
>> set and will default to null
>>
>> I also set the buckminster log level to debug but I'm not getting any
>> additional information.
>>
>> Thomas Hallgren schrieb:
>>> Does your <workspace>/.metadata/.log reveal anything?
>>>
>>> - thomas
>>>
>>> Johannes Utzig wrote:
>>>> Thank you so much Thomas, this looks exactly like what I need.
>>>> Unfortunately it gives me a NullPointerException without any
>>>> stacktrace or message:
>>>> ProjectName/ArtifactName:jar: Using resource map
>>>> http://somehost.de/some.rmap
>>>> ERROR [0001] : java.lang.NullPointerException
>>>> Errors and Warnings
>>>> E [0001] : java.lang.NullPointerException:
>>>> java.lang.NullPointerException
>>>>
>>>> The NPE no longer occurs if I remove the split and format in the
>>>> property element:
>>>> <propertyElement key="artifact.name">
>>>> <bc:propertyRef key="buckminster.component" />
>>>> </propertyElement>
>>>>
>>>> Now the error is this:
>>>> The property ${ artifact.${artifact.name}.path } has not been set
>>>> and will default to null
>>>>
>>>> So it looks like the propertyElement does not properly expand
>>>> buckminster.component?
>>>>
>>>> Best regards,
>>>> Johannes
>>>>
>>>> Thomas Hallgren schrieb:
>>>>> Johannes Utzig wrote:
>>>>>> Hi Thomas,
>>>>>>
>>>>>> the thing that I can't seem to get to work is this:
>>>>>> A property of the name artifact.ARTIFACTNAME.path has a value
>>>>>> that is the relative path to the artifact from the project that
>>>>>> produced it. Now to use buckminster for the resolution I need
>>>>>> three pieces of information:
>>>>>> -the name of the artifact
>>>>>> -the name of the project that produced the artifact
>>>>>> -the property value of artifact.ARTIFACTNAME.path
>>>>>>
>>>>>> The parent/child hierarchie seemed close enough to me to Maven +
>>>>>> Parent poms, so I decided to encode the information about the
>>>>>> parent project the same way:
>>>>>> projectName/artifactName is my component name.
>>>>>>
>>>>>> Now to look up the relative path I need to split
>>>>>> buckminster.component and use the artifact name as a property key
>>>>>> but I can't get it to work.
>>>>>> This is how it currently looks like. It's obvious why it doesn't
>>>>>> work, the 'format' creates a string artifact.artifactName.path,
>>>>>> not a property, but how would I treat it as a property?
>>>>>>
>>>>> Aha, you need to make part of a property a key for another
>>>>> property. Well, you can do that too :-). You need to use a
>>>>> propertyElement to declare a new property. You can define new
>>>>> properties on the RMAP top level.
>>>>>
>>>>> <propertyElement key="artifact.name">
>>>>> <bc:format format="{1}" >
>>>>> <bc:split pattern="/">
>>>>> <bc:propertyRef key="buckminster.component" />
>>>>> </bc:split>
>>>>> </bc:format>
>>>>> </propertyElement>
>>>>>
>>>>> That defines the new artifact.name property. In the provider uri
>>>>> element you should then be able to do:
>>>>>
>>>>> <bc:propertyRef key="artifact.${artifact.name}.path"/>
>>>>>
>>>>> HTH,
>>>>> Thomas Hallgren
>>>>>
>>>>>
>>>>>>
>>>>>> <searchPath name="Artifacts">
>>>>>> <provider readerType="url" componentTypes="jar">
>>>>>> <!-- the artifact will be in
>>>>>> //share/artifacts/projectName/${artifact.artifactName.path} -->
>>>>>> <uri format="file://share/artifacts/{1}/{0}">
>>>>>> <bc:format format="artifact.{1}.path" >
>>>>>> <bc:split pattern="/">
>>>>>> <bc:propertyRef key="buckminster.component" />
>>>>>> </bc:split>
>>>>>> </bc:format>
>>>>>> <bc:split pattern="/">
>>>>>> <bc:propertyRef key="buckminster.component" />
>>>>>> </bc:split> </uri>
>>>>>> </provider>
>>>>>> </searchPath>
>>>>>>
>>>>>> I think what I'd need now is a propertyRef that alows the value of
>>>>>> a nested child element to be the key, then I could resolve my
>>>>>> property.
>>>>>> But maybe I'm just missing the obvious here...
>>>>>>
>>>>>> Best regards,
>>>>>> Johannes
>>>>>>
>>>>>> Thomas Hallgren schrieb:
>>>>>>> Hi Johannes,
>>>>>>> I'm not sure what it is you are trying to do here:
>>>>>>>
>>>>>>> <constant value="${buckminster.component}"/>
>>>>>>>
>>>>>>> is exactly the same as
>>>>>>>
>>>>>>> <propertyRef key="buckminster.component"/>
>>>>>>>
>>>>>>> but
>>>>>>>
>>>>>>> <propertyRef key="${buckminster.component}"/>
>>>>>>>
>>>>>>> will give you the value of a property with a key that corresponds
>>>>>>> to the component name. If you want to add things to that, you can
>>>>>>> of course do:
>>>>>>>
>>>>>>> <propertyRef key="${buckminster.component}.foo.bar"/>
>>>>>>>
>>>>>>> So what use-case is it that isn't covered?
>>>>>>>
>>>>>>> Regards,
>>>>>>> Thomas Hallgren
>>>>>>>
>>>>>>>
>>>>>>> Johannes Utzig wrote:
>>>>>>>> Hi Henrik,
>>>>>>>>
>>>>>>>> this works of course, but it's not solving my problem. In this
>>>>>>>> setup, ${user.language} will be expanded to its value and that
>>>>>>>> will be used as a key, but I need buckminster.component to be
>>>>>>>> expanded and use that to build a new property key and that's
>>>>>>>> what doesn't seem to work (that's why I introduced the constants
>>>>>>>> in the example, because if it would work with a constant, it
>>>>>>>> would probably also work with buckminster.component + propertyRef).
>>>>>>>>
>>>>>>>>
>>>>>>>> Maybe you have another idea, I'm out of them :)
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Best regards and thank you,
>>>>>>>> Johannes
>>>>>>>>
>>>>>>>> Henrik Lindberg schrieb:
>>>>>>>>> Hm,
>>>>>>>>> I can see why the ${{0}} does not work... the {0} is expanded
>>>>>>>>> last (duh - I should not have suggested that in the first
>>>>>>>>> place...)
>>>>>>>>>
>>>>>>>>> Here is another attempt:
>>>>>>>>> <uri format="file://share/artifacts/{0}" >
>>>>>>>>> <bc:propertyRef key="${user.language}" />
>>>>>>>>> </uri>
>>>>>>>>>
>>>>>>>>> - henrik
>>>>>>>>>
>>>>>>>>> Johannes Utzig wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> I'm sorry to bother you again, but I simply can't get this to
>>>>>>>>>> work.
>>>>>>>>>> This gives me an illegal argument exception:
>>>>>>>>>> <searchPath name="Artifacts">
>>>>>>>>>> <provider readerType="url" componentTypes="jar">
>>>>>>>>>> <uri format="file://share/artifacts/${{0}}/">
>>>>>>>>>> <bc:constant value="user.language" />
>>>>>>>>>> </uri>
>>>>>>>>>> </provider>
>>>>>>>>>> </searchPath>
>>>>>>>>>> E [0039] : java.lang.IllegalArgumentException: can't parse
>>>>>>>>>> argument number {0}: can't parse argument number {0}
>>>>>>>>>>
>>>>>>>>>> Quoting it (file://share/artifacts/$'{'{0}'}')
>>>>>>>>>> doesn't expand the property and leads to an URISyntaxException:
>>>>>>>>>> java.net.URISyntaxException: Illegal character in path at
>>>>>>>>>> index 24: file://share/artifacts/${user.language}/
>>>>>>>>>>
>>>>>>>>>> This works however:
>>>>>>>>>> <uri format="file://share/artifacts/{0}/">
>>>>>>>>>> <bc:constant value="${user.language}"
>>>>>>>>>> /> </uri>
>>>>>>>>>>
>>>>>>>>>> This doesn't:
>>>>>>>>>> <uri format="file://share/artifacts/{0}/">
>>>>>>>>>> <bc:format format="{0}{1}{2}">
>>>>>>>>>> <bc:constant value="${" />
>>>>>>>>>> <bc:constant value="user.language" />
>>>>>>>>>> <bc:constant value="}" />
>>>>>>>>>> </bc:format> </uri>
>>>>>>>>>> ERROR java.net.URISyntaxException: Illegal character
>>>>>>>>>> in path at index 24: file://share/artifacts/${user.language}/
>>>>>>>>>>
>>>>>>>>>> (using user.language doesn't make much sense of course, in my
>>>>>>>>>> real case I use buckminster.component. user.language just
>>>>>>>>>> makes the example self contained without a bunch of properties
>>>>>>>>>> for every buckminster.component in the query).
>>>>>>>>>>
>>>>>>>>>> So, I'm really out of ideas on how this is supposed to work.
>>>>>>>>>> It's great that properties get expanded like that, but I just
>>>>>>>>>> don't understand how I can use the value of
>>>>>>>>>> buckminster.component in the key for a property that will
>>>>>>>>>> actually get expanded.
>>>>>>>>>>
>>>>>>>>>> Best regards,
>>>>>>>>>> Johannes
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
Previous Topic:Materialized Target Platform is missing Plugins
Next Topic:p2.director application is not available in headless buckminster
Goto Forum:
  


Current Time: Fri Sep 20 15:22:31 GMT 2024

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

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

Back to the top