# An AspectJ plugin for bnd(tools)

**URL:** <https://bnd.discourse.group/t/an-aspectj-plugin-for-bnd-tools/109>\
**Category:** GENERAL\
**Created:** [February 26, 2021, 5:45pm UTC](https://bnd.discourse.group/t/an-aspectj-plugin-for-bnd-tools/109 "2021-02-26T17:45:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkriens](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/pkriens/32/3_2.png) [@pkriens](https://bnd.discourse.group/u/pkriens)\
**Post date:** [February 26, 2021, 5:45pm UTC](https://bnd.discourse.group/t/an-aspectj-plugin-for-bnd-tools/109/1 "2021-02-26T17:45:19Z")

</div>

I am experimenting with AspectJ. Aspects allow you to write a _cross cutting concern_ that gets applied at selective points _anywhere_ in your bundles (or 3rd party bundles).

I created a bnd exporter plugin that will create an _executable JAR_, and then use the AspectJ compiler [ajc](https://www.eclipse.org/aspectj/doc/released/devguide/ajc-ref.html) to weave each bundle based on _aspect_ bundles. The aspect bundles and a properly wrapped aspectj runtime bundle are also added.

Aspects do not map very well to modules since they are crosscutting. I tried to keep the modularity of OSGi while still allowing the full support. However, some actual usage is needed. If people want to give this a test ride, you can find the manual [here](https://bnd.bndtools.org/plugins/aspectj.html).

---

<div class="post-metadata">

**Author:** ![gsrunion](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/gsrunion/32/95_2.png) [@gsrunion](https://bnd.discourse.group/u/gsrunion)\
**Post date:** [June 16, 2021, 8:18pm UTC](https://bnd.discourse.group/t/an-aspectj-plugin-for-bnd-tools/109/2 "2021-06-16T20:18:51Z")

</div>

Awesome. I will take a look.

---

<div class="post-metadata">

**Author:** ![gsrunion](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/gsrunion/32/95_2.png) [@gsrunion](https://bnd.discourse.group/u/gsrunion)\
**Post date:** [June 17, 2021, 12:33pm UTC](https://bnd.discourse.group/t/an-aspectj-plugin-for-bnd-tools/109/3 "2021-06-17T12:33:42Z")

</div>

Is there a place I can directly download the required bundle?..  
aQute.bnd.aspectj.plugin.AspectJ

---

<div class="post-metadata">

**Author:** ![pkriens](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/pkriens/32/3_2.png) [@pkriens](https://bnd.discourse.group/u/pkriens)\
**Post date:** [June 17, 2021, 12:45pm UTC](https://bnd.discourse.group/t/an-aspectj-plugin-for-bnd-tools/109/4 "2021-06-17T12:45:32Z")

</div>

It is built-in. Supporting it turned out to be very small:

```
     https://bnd.bndtools.org/plugins/aspectj.html
```

---

<div class="post-metadata">

**Author:** ![gsrunion](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/gsrunion/32/95_2.png) [@gsrunion](https://bnd.discourse.group/u/gsrunion)\
**Post date:** [June 17, 2021, 12:48pm UTC](https://bnd.discourse.group/t/an-aspectj-plugin-for-bnd-tools/109/5 "2021-06-17T12:48:12Z")

</div>

This requires I am on a certain version of bndtools? I am going to have to do some searching to figure out what versions of the aqute libs we are using with gradle.

---

<div class="post-metadata">

**Author:** ![pkriens](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/pkriens/32/3_2.png) [@pkriens](https://bnd.discourse.group/u/pkriens)\
**Post date:** [June 17, 2021, 12:49pm UTC](https://bnd.discourse.group/t/an-aspectj-plugin-for-bnd-tools/109/6 "2021-06-17T12:49:50Z")

</div>

Yes, it should be in 5.3, the latest release. I think but too laze to check 🙂

---

<div class="post-metadata">

**Author:** ![gsrunion](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/gsrunion/32/95_2.png) [@gsrunion](https://bnd.discourse.group/u/gsrunion)\
**Post date:** [June 17, 2021, 12:51pm UTC](https://bnd.discourse.group/t/an-aspectj-plugin-for-bnd-tools/109/7 "2021-06-17T12:51:39Z")

</div>

For older releases, would a bundle.jar with -pluginpath work to bring it into the fold?

---

<div class="post-metadata">

**Author:** ![pkriens](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/pkriens/32/3_2.png) [@pkriens](https://bnd.discourse.group/u/pkriens)\
**Post date:** [June 17, 2021, 12:59pm UTC](https://bnd.discourse.group/t/an-aspectj-plugin-for-bnd-tools/109/8 "2021-06-17T12:59:58Z")

</div>

I guess you have to extract the jar then since it is part of the core bndlib jar. But yeah, that should work.
