Exclude some packages from dependency

1,392 views
Skip to first unread message

Nguyen Viet

unread,
Dec 20, 2020, 4:51:10 PM12/20/20
to bndtools-users
Hi,

I am trying to migrate a Maven project to gradle with BND. In our maven, there is a configuration to exclude some dependencies like this:
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-anim</artifactId>
<version>1.10</version>
<exclusions>
<exclusion>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-dom</artifactId>
</exclusion>
</exclusions>
</dependency>
In my bnd file, i am having: -buildpath: org.apache.xmlgraphics:batik-anim. So it is missing the exclusion.

So, may i know how can i achive this exclusion in bnd file?

Thank you so much in advance!
Viet

Mark Hoffmann

unread,
Dec 21, 2020, 2:03:40 AM12/21/20
to bndtool...@googlegroups.com
Hello Viet,

the buildpath instruction in the bnd is an allowlisting instruction. Only artifacts that are on the buildpath are considered for building this bundle. So, there is no need for an exclusion.

When it comes to create a bndrun to export or launch an application, you can use -runblacklist. Please note this is a requirement:


Regards,

Mark Hoffmann 
M.A. Dipl.-Betriebswirt (FH) 
CEO/CTO 

Phone: +49 3641 384 910


Data In Motion Consulting GmbH 
Kahlaische Strasse 4 
07745 Jena 
Germany 

Geschäftsführer/CEO 
Mark Hoffmann 
Jürgen Albert 

Jena HRB 513025 
Steuernummer 162/107/05779 
USt-Id DE310002614


-------- Ursprüngliche Nachricht --------
Von: Nguyen Viet <vietngu...@gmail.com>
Datum: 20.12.20 22:51 (GMT+01:00)
An: bndtools-users <bndtool...@googlegroups.com>
Betreff: Exclude some packages from dependency

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/bndtools-users/83da551b-d4fe-4fc8-9794-8f9a29b664e9n%40googlegroups.com.

Nguyen Viet

unread,
Dec 21, 2020, 4:24:34 AM12/21/20
to bndtools-users
Hi Mark,

Thank you so much for your reply. 

However, i have tried runblacklist but it does not work (maybe my configuration is wrong). Allow me explain more about my case. There are 2 dependencies: batik-dom and batik-anim. We found these buggy and decided to fix them. Then, we have 2 modified version: batik-anim-MODIFIED and batik-dom-MODIFIED. 

However, since batik-anim (and batik-anim-MODIFIED) depends on batik-dom naturally but we don't want that, we want to use our batik-dom-MODIFIED. That's why in our maven, we define like this:

<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-anim-MODIFIED</artifactId>
<version>1.10</version>
<exclusions>
<exclusion>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-dom</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-dom-MODIFIED</artifactId>
<version>1.10</version>
</dependency>

When i migrate to bnd, the bnd file looks like this: 
-buildpath: \
junit:junit,\
org.mockito.mockito-all,\
org.apache.xmlgraphics:batik-anim-MODIFIED,\
org.apache.xmlgraphics:batik-dom-MODIFIED,\
javax.xml.bind:jaxb-api,\
javax.xml:jaxb-impl
 -runblacklist: \
osgi.identity;filter:='(osgi.identity=org.apache.xmlgraphics.batik-dom)'

Then, i face an issue in Eclipse: The type org.apache.batik.dom.svg.SVGMotionAnimatableElement cannot be resolved. It is indirectly referenced from required .class files.

After some googlings, it seems that this issue is related to Jar collision meaning there are 2 jars providing the same class which is this: org.apache.batik.dom.svg.SVGMotionAnimatableElement.

So, may i have your advice for this?

Regards,
Viet 

Mark Hoffmann

unread,
Dec 21, 2020, 4:52:34 AM12/21/20
to bndtool...@googlegroups.com
Hi Viet,

the Maven Central bundles for Batik are not OSGified. So did you do that or did you take the Batik from a different location, like Eclipse Orbit? The Orbit bundles use Require-Bundle instead of import package, which would bind you to a specific bsn, what you dont want.

Otherwise is it an option to simply remove the unwanted bundes from your repository (e.g. remove them from the maven index file)?

Regards,

Mark Hoffmann 
M.A. Dipl.-Betriebswirt (FH) 
CEO/CTO 

Phone: +49 3641 384 910


Data In Motion Consulting GmbH 
Kahlaische Strasse 4 
07745 Jena 
Germany 

Geschäftsführer/CEO 
Mark Hoffmann 
Jürgen Albert 

Jena HRB 513025 
Steuernummer 162/107/05779 
USt-Id DE310002614


-------- Ursprüngliche Nachricht --------
Von: Nguyen Viet <vietngu...@gmail.com>
Datum: 21.12.20 10:24 (GMT+01:00)
An: bndtools-users <bndtool...@googlegroups.com>
Betreff: Re: Exclude some packages from dependency

Nguyen Viet

unread,
Dec 21, 2020, 5:22:12 AM12/21/20
to bndtool...@googlegroups.com
Hi Mark,

Thank you for your reply. They are not OSGIfied. They are just normal jar libraries. And in a lot of my bnd files, dependencies are not OSGIfied and they still can compile normally. The way i build them is I build, then push to Artifactory as the maven repo.

Can you please elaborate more on your last comment?

Regards,
Viet

You received this message because you are subscribed to a topic in the Google Groups "bndtools-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bndtools-users/e-3AeaSMuiE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bndtools-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bndtools-users/5fe0705f.1c69fb81.56d4d.3c76%40mx.google.com.

Mark Hoffmann

unread,
Dec 21, 2020, 6:14:41 AM12/21/20
to bndtool...@googlegroups.com
Hi Viet,

when you want to run your application, you will need OSGi artifacts for your application. Thats why we always use OSGified artifacts as dependencies.

In geadle you also have to define your dependencies like you do it in Maven. If you install bndtools in your Eclipse your get some workspace templates that do exactly that. You will get a cnf folder with repository defintions in it. Adittionally there are index files for Maven Repositories where you can exactly define the GAV's. This is the place where you can exactly define your dependencies.


Regards,

Mark Hoffmann 
M.A. Dipl.-Betriebswirt (FH) 
CEO/CTO 

Phone: +49 3641 384 910


Data In Motion Consulting GmbH 
Kahlaische Strasse 4 
07745 Jena 
Germany 

Geschäftsführer/CEO 
Mark Hoffmann 
Jürgen Albert 

Jena HRB 513025 
Steuernummer 162/107/05779 
USt-Id DE310002614


-------- Ursprüngliche Nachricht --------
Von: Nguyen Viet <vietngu...@gmail.com>
Datum: 21.12.20 11:22 (GMT+01:00)

Nguyen Viet

unread,
Dec 21, 2020, 9:48:09 AM12/21/20
to bndtool...@googlegroups.com
Hi Mark,

Thank you for your reply. Actually i knew and i did setup the workspace but your input opened me some new ideas.

From what i could see until this point, it seems to me the issue i am facing is not actually the jar collision but missing dependencies. It seems that maven can resolve the dependencies of the dependencies but gradle can not, or maybe i configured it to use our Artifactory so it could not. As the result, I have to add those dependencies of dependencies manually in the buildpath which leads to a chain of libraries...

But anyway, thank you so much for your support so far, i really appreciate it. Have a nice day and Merry Christmas!

Regards,
Viet

Mark Hoffmann

unread,
Dec 21, 2020, 10:29:28 AM12/21/20
to bndtool...@googlegroups.com
Hi Viet,

please also note that this group moved to:

https://bnd.discourse.group/

Maybe you repost this again there?

Merry X-Mas,

Mark

Am 21.12.20 um 15:47 schrieb Nguyen Viet:
> Hi Mark,
>
> Thank you for your reply. Actually i knew and i did setup the workspace but
> your input opened me some new ideas.
>
> From what i could see until this point, it seems to me the issue i am
> facing is not actually the jar collision but missing dependencies. It seems
> that maven can resolve the dependencies of the dependencies but gradle can
> not, or maybe i configured it to use our Artifactory so it could not. As
> the result, I have to add those dependencies of dependencies manually in
> the buildpath which leads to a chain of libraries...
... which makes your dependencies more obvious :-)
>
> But anyway, thank you so much for your support so far, i really appreciate
> it. Have a nice day and Merry Christmas!
>
> Regards,
> Viet
>
> On Mon, 21 Dec 2020 at 13:14, Mark Hoffmann <m.hof...@data-in-motion.biz>
> wrote:
>
>> Hi Viet,
>>
>> when you want to run your application, you will need OSGi artifacts for
>> your application. Thats why we always use OSGified artifacts as
>> dependencies.
>>
>> In geadle you also have to define your dependencies like you do it in
>> Maven. If you install bndtools in your Eclipse your get some workspace
>> templates that do exactly that. You will get a cnf folder with repository
>> defintions in it. Adittionally there are index files for Maven Repositories
>> where you can exactly define the GAV's. This is the place where you can
>> exactly define your dependencies.
>>
>> https://bndtools.org/workspace.html
>>
>> Regards,
>>
>> Mark Hoffmann
>> M.A. Dipl.-Betriebswirt (FH)
>> CEO/CTO
>>
>> Phone: +49 3641 384 910 <+49%203641%20384%20910> 0
>> Mobile: +49 175 701 2201 <+49%20175%20701%202201>
>>> Phone: +49 3641 384 910 <+49%203641%20384%20910> 0
>>> Mobile: +49 175 701 2201 <+49%20175%20701%202201>
>>>> Phone: +49 3641 384 910 <+49%203641%20384%20910> 0
>>>> Mobile: +49 175 701 2201 <+49%20175%20701%202201>
>>>> <https://groups.google.com/d/msgid/bndtools-users/83da551b-d4fe-4fc8-9794-8f9a29b664e9n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>>> 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.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/bndtools-users/d8153db6-b00e-4176-b7fc-b34e3d8eb0b8n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/bndtools-users/d8153db6-b00e-4176-b7fc-b34e3d8eb0b8n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "bndtools-users" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/bndtools-users/e-3AeaSMuiE/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> bndtools-user...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/bndtools-users/5fe0705f.1c69fb81.56d4d.3c76%40mx.google.com
>>> <https://groups.google.com/d/msgid/bndtools-users/5fe0705f.1c69fb81.56d4d.3c76%40mx.google.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/bndtools-users/CAFfxtUb%3DgRyBcFwcLtTsj45_B8vNTra%3DwooFkud-dA8W3cC0Zg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/bndtools-users/CAFfxtUb%3DgRyBcFwcLtTsj45_B8vNTra%3DwooFkud-dA8W3cC0Zg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "bndtools-users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/bndtools-users/e-3AeaSMuiE/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> bndtools-user...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/bndtools-users/5fe0839e.1c69fb81.d8116.6d07%40mx.google.com
>> <https://groups.google.com/d/msgid/bndtools-users/5fe0839e.1c69fb81.d8116.6d07%40mx.google.com?utm_medium=email&utm_source=footer>
>> .
>>
--
Mark Hoffmann
M.A. Dipl.-Betriebswirt (FH)
Geschäftsführer

Tel: +49 3641 384 910 0
Mobil: +49 175 701 2201
E-Mail: m.hof...@data-in-motion.biz
Web: www.datainmotion.de

Data In Motion Consulting GmbH
Kahlaische Straße 4
07745 Jena

Geschäftsführer

Raymond Auge

unread,
Dec 21, 2020, 11:09:50 AM12/21/20
to bndtool...@googlegroups.com
I'm fairly certain that the buildpath is not transitive.

Are you getting some sort of error, or are you just trying to assure the same level of configuration?

- Ray

--
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.


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

Raymond Auge

unread,
Dec 21, 2020, 11:15:09 AM12/21/20
to bndtool...@googlegroups.com
Sorry I see this conversation did not continue in threaded mode. I missed that.

- Ray
Reply all
Reply to author
Forward
0 new messages