Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Buckminster » os conditional artifact targets (UI action filter ?)
os conditional artifact targets (UI action filter ?) [message #380399] Wed, 22 October 2008 14:11 Go to next message
Guillaume Chatelet is currently offline Guillaume ChateletFriend
Messages: 146
Registered: July 2009
Senior Member
Hello,

In the CSpec Editor, there's an "actions" tab. When an action is created one has access to a few menus including "General", "Properties", "Products", "Installer Hints" and "Documentation".
In the "General" menu, there's a "Filter" text area. Is it working ? Is there any documentation available ? (I can't find any here http://wiki.eclipse.org/Buckminster_component_meta-data_lang uage_(Reference)_-_LATEST#Actions_component )

Actually I would like my artifacts target (or action's product) to be one path or another depending on the OS. Is it even feasible ?

I can have os dependents actions with a ant trick ( conditional properties with ${osgi.os} ).
The result of this action produces an executable, let's say test.exe for windows and test for linux.

I need refer to this executable in another component. When I'm on windows my artifact would point to "test.exe" and when I'm on linux my artifact would point to "test".
I tried giving the same name to my two executables "test" but windows refuses to execute it saying it's the command is not recognized as an executable.

Have you ever faced this case ? Have you some solutions ?

Best regards,
Guillaume
Re: os conditional artifact targets (UI action filter ?) [message #380401 is a reply to message #380399] Sun, 26 October 2008 11:36 Go to previous messageGo to next message
Guillaume Chatelet is currently offline Guillaume ChateletFriend
Messages: 146
Registered: July 2009
Senior Member
Just to give a bit of feedback on this issue, after digging in the code a
little bit : the filter text area is matched against a
org.osgi.framework.Filter interface. This is done while checking if the
Artifact is enabled, ie : if the filter matches negatively it's as if the
artifact were disabled.

More informations about the Filter class here :
http://www.osgi.org/javadoc/r4v41/org/osgi/framework/Filter. html

The Filter is ldap style filter. I did a test to select an action
according to the platform.

I created 3 actions in a CSpec : test, test.linux and test.windows. test
has test.linux and test.windows as prerequisites to trigger them as needed
and hide the platform choice to the outside world. Here it is :

<?xml version="1.0" encoding="UTF-8"?>
<cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0"
name="cppunit-1.12.0" componentType="buckminster">
<cs:actions>
<cs:public name="test" actor="null">
<cs:prerequisites>
<cs:attribute name="test.linux"/>
<cs:attribute name="test.windows"/>
</cs:prerequisites>
</cs:public>
<cs:private name="test.linux" filter="(target.os=linux)"
actor="executor">
<cs:actorProperties>
<cs:property key="shell" value="echo linux"/>
</cs:actorProperties>
</cs:private>
<cs:private name="test.windows" filter="(target.os=win32)"
actor="executor">
<cs:actorProperties>
<cs:property key="shell" value="echo windows"/>
</cs:actorProperties>
</cs:private>
</cs:actions>
</cs:cspec>

Actually this doesn't work as expected so I dug into the code and found
this :
In the component org.eclipse.buckminster.core, package
org.eclipse.buckminster.core.cspec.model, class Attribute, Function
isEnabled.
The filter is matched against ctx.getProperties(). This property is empty
and so the filter's matching returns false.

I corrected this behavior like this :
public boolean isEnabled(IModelCache ctx) throws CoreException
{
if(m_filter == null)
return true;

final Map<String, String> properties = ctx.getProperties();
properties.putAll(RMContext.getGlobalPropertyAdditions());
return FilterUtils.isMatch(m_filter, properties);
}

Thomas, do you think this is a bug ? Is this the right fix ? Or should it
be handled in GlobalContext (the IModelCache implementation of ctx in this
case).

Tell me but I think Artifacts filtering according to platform could be of
great benefits.

Best regards,
Guillaume
Re: os conditional artifact targets (UI action filter ?) [message #380408 is a reply to message #380401] Mon, 27 October 2008 08:13 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
Hi Guillaume,
This looks like a bug, yes. The GlobalContext should override the
ModelCache.getProperties() method.

Regards,
Thomas Hallgren



Guillaume CHATELET wrote:
> Just to give a bit of feedback on this issue, after digging in the code
> a little bit : the filter text area is matched against a
> org.osgi.framework.Filter interface. This is done while checking if the
> Artifact is enabled, ie : if the filter matches negatively it's as if
> the artifact were disabled.
>
> More informations about the Filter class here :
> http://www.osgi.org/javadoc/r4v41/org/osgi/framework/Filter. html
>
> The Filter is ldap style filter. I did a test to select an action
> according to the platform.
>
> I created 3 actions in a CSpec : test, test.linux and test.windows. test
> has test.linux and test.windows as prerequisites to trigger them as
> needed and hide the platform choice to the outside world. Here it is :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0"
> name="cppunit-1.12.0" componentType="buckminster">
> <cs:actions>
> <cs:public name="test" actor="null">
> <cs:prerequisites>
> <cs:attribute name="test.linux"/>
> <cs:attribute name="test.windows"/>
> </cs:prerequisites>
> </cs:public>
> <cs:private name="test.linux" filter="(target.os=linux)"
> actor="executor">
> <cs:actorProperties>
> <cs:property key="shell" value="echo linux"/>
> </cs:actorProperties>
> </cs:private>
> <cs:private name="test.windows" filter="(target.os=win32)"
> actor="executor">
> <cs:actorProperties>
> <cs:property key="shell" value="echo windows"/>
> </cs:actorProperties>
> </cs:private>
> </cs:actions>
> </cs:cspec>
>
> Actually this doesn't work as expected so I dug into the code and found
> this :
> In the component org.eclipse.buckminster.core, package
> org.eclipse.buckminster.core.cspec.model, class Attribute, Function
> isEnabled.
> The filter is matched against ctx.getProperties(). This property is
> empty and so the filter's matching returns false.
>
> I corrected this behavior like this :
> public boolean isEnabled(IModelCache ctx) throws CoreException
> {
> if(m_filter == null)
> return true;
>
> final Map<String, String> properties = ctx.getProperties();
> properties.putAll(RMContext.getGlobalPropertyAdditions());
> return FilterUtils.isMatch(m_filter, properties);
> }
>
> Thomas, do you think this is a bug ? Is this the right fix ? Or should
> it be handled in GlobalContext (the IModelCache implementation of ctx in
> this case).
>
> Tell me but I think Artifacts filtering according to platform could be
> of great benefits.
>
> Best regards,
> Guillaume
>
Re: os conditional artifact targets (UI action filter ?) [message #380412 is a reply to message #380408] Mon, 27 October 2008 09:11 Go to previous messageGo to next message
Guillaume Chatelet is currently offline Guillaume ChateletFriend
Messages: 146
Registered: July 2009
Senior Member
I opened an entry in Bugzilla : https://bugs.eclipse.org/bugs/show_bug.cgi?id=252146
I'll fix this ASAP.

Regards,
Guillaume

Thomas Hallgren wrote:
> Hi Guillaume,
> This looks like a bug, yes. The GlobalContext should override the
> ModelCache.getProperties() method.
>
> Regards,
> Thomas Hallgren
>
>
>
> Guillaume CHATELET wrote:
>> Just to give a bit of feedback on this issue, after digging in the
>> code a little bit : the filter text area is matched against a
>> org.osgi.framework.Filter interface. This is done while checking if
>> the Artifact is enabled, ie : if the filter matches negatively it's as
>> if the artifact were disabled.
>>
>> More informations about the Filter class here :
>> http://www.osgi.org/javadoc/r4v41/org/osgi/framework/Filter. html
>>
>> The Filter is ldap style filter. I did a test to select an action
>> according to the platform.
>>
>> I created 3 actions in a CSpec : test, test.linux and test.windows.
>> test has test.linux and test.windows as prerequisites to trigger them
>> as needed and hide the platform choice to the outside world. Here it is :
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0"
>> name="cppunit-1.12.0" componentType="buckminster">
>> <cs:actions>
>> <cs:public name="test" actor="null">
>> <cs:prerequisites>
>> <cs:attribute name="test.linux"/>
>> <cs:attribute name="test.windows"/>
>> </cs:prerequisites>
>> </cs:public>
>> <cs:private name="test.linux" filter="(target.os=linux)"
>> actor="executor">
>> <cs:actorProperties>
>> <cs:property key="shell" value="echo linux"/>
>> </cs:actorProperties>
>> </cs:private>
>> <cs:private name="test.windows" filter="(target.os=win32)"
>> actor="executor">
>> <cs:actorProperties>
>> <cs:property key="shell" value="echo windows"/>
>> </cs:actorProperties>
>> </cs:private>
>> </cs:actions>
>> </cs:cspec>
>>
>> Actually this doesn't work as expected so I dug into the code and
>> found this :
>> In the component org.eclipse.buckminster.core, package
>> org.eclipse.buckminster.core.cspec.model, class Attribute, Function
>> isEnabled.
>> The filter is matched against ctx.getProperties(). This property is
>> empty and so the filter's matching returns false.
>>
>> I corrected this behavior like this :
>> public boolean isEnabled(IModelCache ctx) throws CoreException
>> {
>> if(m_filter == null)
>> return true;
>>
>> final Map<String, String> properties = ctx.getProperties();
>> properties.putAll(RMContext.getGlobalPropertyAdditions());
>> return FilterUtils.isMatch(m_filter, properties);
>> }
>>
>> Thomas, do you think this is a bug ? Is this the right fix ? Or should
>> it be handled in GlobalContext (the IModelCache implementation of ctx
>> in this case).
>>
>> Tell me but I think Artifacts filtering according to platform could be
>> of great benefits.
>>
>> Best regards,
>> Guillaume
>>
Re: os conditional artifact targets (UI action filter ?) [message #380414 is a reply to message #380412] Mon, 27 October 2008 16:35 Go to previous messageGo to next message
Guillaume Chatelet is currently offline Guillaume ChateletFriend
Messages: 146
Registered: July 2009
Senior Member
Hi Thomas,

The isEnabled function is called on attributes that are prerequisites for other attributes only.
So if the attribute is a root action for instance ( not a prerequisites for another group/action ) the filter will not be tested and the action will be executed anyway.

Is this the expected behavior ?
I suspect this is also a bug, do you agree ?

Regards,
Guillaume

Guillaume CHATELET wrote:
> I opened an entry in Bugzilla :
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=252146
> I'll fix this ASAP.
>
> Regards,
> Guillaume
>
> Thomas Hallgren wrote:
>> Hi Guillaume,
>> This looks like a bug, yes. The GlobalContext should override the
>> ModelCache.getProperties() method.
>>
>> Regards,
>> Thomas Hallgren
>>
>>
>>
>> Guillaume CHATELET wrote:
>>> Just to give a bit of feedback on this issue, after digging in the
>>> code a little bit : the filter text area is matched against a
>>> org.osgi.framework.Filter interface. This is done while checking if
>>> the Artifact is enabled, ie : if the filter matches negatively it's
>>> as if the artifact were disabled.
>>>
>>> More informations about the Filter class here :
>>> http://www.osgi.org/javadoc/r4v41/org/osgi/framework/Filter. html
>>>
>>> The Filter is ldap style filter. I did a test to select an action
>>> according to the platform.
>>>
>>> I created 3 actions in a CSpec : test, test.linux and test.windows.
>>> test has test.linux and test.windows as prerequisites to trigger them
>>> as needed and hide the platform choice to the outside world. Here it
>>> is :
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0"
>>> name="cppunit-1.12.0" componentType="buckminster">
>>> <cs:actions>
>>> <cs:public name="test" actor="null">
>>> <cs:prerequisites>
>>> <cs:attribute name="test.linux"/>
>>> <cs:attribute name="test.windows"/>
>>> </cs:prerequisites>
>>> </cs:public>
>>> <cs:private name="test.linux" filter="(target.os=linux)"
>>> actor="executor">
>>> <cs:actorProperties>
>>> <cs:property key="shell" value="echo linux"/>
>>> </cs:actorProperties>
>>> </cs:private>
>>> <cs:private name="test.windows" filter="(target.os=win32)"
>>> actor="executor">
>>> <cs:actorProperties>
>>> <cs:property key="shell" value="echo windows"/>
>>> </cs:actorProperties>
>>> </cs:private>
>>> </cs:actions>
>>> </cs:cspec>
>>>
>>> Actually this doesn't work as expected so I dug into the code and
>>> found this :
>>> In the component org.eclipse.buckminster.core, package
>>> org.eclipse.buckminster.core.cspec.model, class Attribute, Function
>>> isEnabled.
>>> The filter is matched against ctx.getProperties(). This property is
>>> empty and so the filter's matching returns false.
>>>
>>> I corrected this behavior like this :
>>> public boolean isEnabled(IModelCache ctx) throws CoreException
>>> {
>>> if(m_filter == null)
>>> return true;
>>>
>>> final Map<String, String> properties = ctx.getProperties();
>>> properties.putAll(RMContext.getGlobalPropertyAdditions());
>>> return FilterUtils.isMatch(m_filter, properties);
>>> }
>>>
>>> Thomas, do you think this is a bug ? Is this the right fix ? Or
>>> should it be handled in GlobalContext (the IModelCache implementation
>>> of ctx in this case).
>>>
>>> Tell me but I think Artifacts filtering according to platform could
>>> be of great benefits.
>>>
>>> Best regards,
>>> Guillaume
>>>
Re: os conditional artifact targets (UI action filter ?) [message #380419 is a reply to message #380414] Tue, 28 October 2008 07:33 Go to previous message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
Guillaume CHATELET wrote:
> Hi Thomas,
>
> The isEnabled function is called on attributes that are prerequisites
> for other attributes only.
> So if the attribute is a root action for instance ( not a prerequisites
> for another group/action ) the filter will not be tested and the action
> will be executed anyway.
>
> Is this the expected behavior ?
> I suspect this is also a bug, do you agree ?
>
Yes. That sounds like a bug. Calling a disabled action should be a no-op in all cases.

Regards,
Thomas Hallgren
Previous Topic:Buckminster, SVN and file urls
Next Topic:how to "combine" component queries
Goto Forum:
  


Current Time: Fri Apr 19 00:29:59 GMT 2024

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

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

Back to the top