Working set Location predicate on different platforms [message #1777364] |
Tue, 28 November 2017 21:00 |
Ernesto Posse Messages: 438 Registered: March 2011 |
Senior Member |
|
|
Is the location predicate sensitive to the path separator of different platforms?
In a setup model I have the following:
<workingSet
name="${scope.project.name} - tooling">
<predicate
xsi:type="predicates:LocationPredicate"
pattern="${git.clone.posysml.location}/plugins/tooling/.*"/>
</workingSet>
... which works on macOS (and presumably on Linux, although I haven't tested it there), but it is ignored on Windows. Must I write the following (quite horrible) predicate?
<workingSet
name="${scope.project.name} - tooling">
<predicate
xsi:type="predicates:LocationPredicate"
pattern="${git.clone.posysml.location}(\\|/)plugins(\\|/)tooling(\\|/).*"/>
</workingSet>
Not only that is quite unappealing and error prone, but some messages in the forum (cf https://www.eclipse.org/forums/index.php?t=msg&th=1085942&goto=1760836&#msg_1760836) suggest that using this with \\ doesn't work.
I've been looking for the implementation of the Working Sets task in Oomph's git repo at http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/ but I can't find where this is implemented. Where should I look?
By the way, is "Pattern" supposed to be a Java regex according to java.util.regex.Pattern, or some inhouse pattern?
[Updated on: Tue, 28 November 2017 21:01] Report message to a moderator
|
|
|
Re: Working set Location predicate on different platforms [message #1777399 is a reply to message #1777364] |
Wed, 29 November 2017 08:12 |
Ed Merks Messages: 33264 Registered: July 2009 |
Senior Member |
|
|
It's implemented by org.eclipse.oomph.predicates.impl.LocationPredicateImpl.matches(IResource) like this: public boolean matches(IResource resource)
{
if (resource != null)
{
IPath location = resource.getLocation();
if (location != null)
{
return getCompiledPattern().matcher(location.toPortableString()).matches();
}
}
return false;
} That uses java.util.regex.Pattern and apparently toPortableString does use "/" as a separator. But it seems to me you have to be pretty careful with ${git.clone.posysml.location} because that might well look like it has patterns in it, and will definitely use a \ on Windows. It's better to use ${git.clone.posysml.location|path} to be sure that / is used and not \, also also likely safer to use \Q${git.clone.posysml.location|path}\E to ensure that it's used literally and not in any way as a pattern.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03217 seconds