Excluding files or folders from Include-Resource

629 views
Skip to first unread message

Stijn de Witt

unread,
Nov 26, 2013, 4:32:47 AM11/26/13
to bndtool...@googlegroups.com
I know that we can exclude classes from e.g. Import-Package using the negation symbol ! (exclamation mark)... However it seems to me from reading the instructions for BND that we cannot use the same trick for resources in the Include-Resource directive... Or am I wrong? I admit I find the instructions a bit difficult to read :)

Say I have this folder structure:

+ src
   + my/
      + folder1/
         + subA/
            - file1.txt
            - file2.txt
         + subB/
            - file3.txt
      + folder2/
         + subX
            - file4.txt
            - file5.txt

Now I want to include all *.txt resources below folder 'src/my/', *except* for the .txt files below 'src/my/folder1/subB/'...

If these were packages with classes to be used in Import-Package (and 'src\' would be on the classpath), I could do this:

Import-Package: !my.folder1.subB.*, my.*

Can I do the same with resources? If so, how?
Would something like this work?

Include-Resource:  !my/folder1/subB=src/my/folder1/subB;rescursive:=true;filter:=*.txt, my=src/my;recursive:=true;filter:=*.txt

Stijn de Witt

unread,
Nov 26, 2013, 4:41:07 AM11/26/13
to bndtool...@googlegroups.com
(I notice I introduced a spelling error in above example syntax for Include-Resource, 'rescursive', with extra 's', please ignore it)

So I tried the above syntax but it actually ends up including the resource twice. Once in a folder named '!my/folder1/subB' and then again below the regular folder 'my/folder1/subB'. So obviously this syntax is not working the way I was hoping...

Is there any other way to exclude a resource like this or do I just have to list all the folders below 'src/my/' that I do want to include?

Peter Kriens

unread,
Nov 26, 2013, 11:01:28 AM11/26/13
to bndtool...@googlegroups.com
Nope, this is beyond Include-Resources' capabilities. And adding this seems a bit overkill.

Kind regards,

Peter Kriens

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Raymond Auge

unread,
Nov 26, 2013, 11:05:11 AM11/26/13
to bndtool...@googlegroups.com
what about:

-donotcopy: <regex>

- Ray
--
Raymond Augé (@rotty3000)
Senior Software Architect
Liferay, Inc. (@Liferay)

Peter Kriens

unread,
Nov 26, 2013, 11:07:36 AM11/26/13
to bndtool...@googlegroups.com
The donotcopy en filter expressions are only done against the file name, not the path.

Kind regards,

Peter Kriens

Stijn de Witt

unread,
Nov 28, 2013, 9:46:05 AM11/28/13
to bndtool...@googlegroups.com
Why is it overkill here, but not for Import-Package? Seems to me the kind of use cases it is useful in are the same.
In the meantime I decided to move the file to a different spot.

The problem I see is that when there are certain files that should be excluded (and you cannot move these files) is that you have to make a very long list of directives that describe the whole folder tree surrounding the resource to be excluded. And worse still, every time you move, rename or add a folder in this tree you have to update the Include-Resource.

For my simple example, the solution (if you can't move the file) would be:

Include-Resource: \
  my/folder1/subA=src/my/folder1/subA;recursive:=true;filter:=*.txt,\
  my/folder2=src/my/folder2;recursive:=true;filter:=*.txt

Now this is still simple, but once we start adding folders this list will grow quickly. And if the file is deep in the tree, or in a folder whose parent contains many sub folders, we may end up with a very long list indeed.

Not trying to pressure you into implementing it, just wondering why you see differences between Import-Package and Include-Resource for this scenario.

-Stijn


Op dinsdag 26 november 2013 17:01:28 UTC+1 schreef Peter Kriens:

Peter Kriens

unread,
Nov 29, 2013, 3:03:37 AM11/29/13
to bndtool...@googlegroups.com
Well, worst case there are a couple of hundred packages on the import list, and I already have that list. So it is easy to filter. The file system potentially contains millions of files and I do not have that list handy. Creating this list of all files not trivial since you need to make sure the globbing works correctly. I.e. what does !*impl* mean in this context? This potentially is all the files on your system. I guess the easiest solution would be to add a new filter directive that would allow you to assert the full path. Or maybe detect that the filter contains slashes and then assert the full path.

Most of all, -includeresource has become quite a complex beast due to all the options and I have no desire to change it, but patches are welcome.

Kind regards,

Peter Kriens
Reply all
Reply to author
Forward
0 new messages