# No code is included in created bundle

**URL:** <https://bnd.discourse.group/t/no-code-is-included-in-created-bundle/258>\
**Category:** GENERAL\
**Created:** [August 18, 2022, 1:28pm UTC](https://bnd.discourse.group/t/no-code-is-included-in-created-bundle/258 "2022-08-18T13:28:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![BobChilcott](https://avatars.discourse-cdn.com/v4/letter/b/77aa72/32.png) [@BobChilcott](https://bnd.discourse.group/u/BobChilcott)\
**Post date:** [August 18, 2022, 1:28pm UTC](https://bnd.discourse.group/t/no-code-is-included-in-created-bundle/258/1 "2022-08-18T13:28:50Z")

</div>

Hi, I’m trying to generate a bundle using bnd’s `bnd.builder` Gradle plugin. The manifest file seems ok as far as I can tell (this is my first experience with both bnd and OSGi), however none of my code is included in the final bundle. Can anyone point out what I’m doing wrong? I can’t figure this out for the life of me.  
My build.gradle file is [here](https://hastebin.com/xuroboyise.gradle)

When I run `gradle bundle`, I receive this warning: `warning: Bundle-Activator com.example.MainActivator is being imported into the bundle rather than being contained inside it. This is usually a bundle packaging error`

Thanks,  
Bob.

---

<div class="post-metadata">

**Author:** ![bjhargrave](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/bjhargrave/32/10_2.png) [@bjhargrave](https://bnd.discourse.group/u/bjhargrave)\
**Post date:** [August 18, 2022, 2:24pm UTC](https://bnd.discourse.group/t/no-code-is-included-in-created-bundle/258/2 "2022-08-18T14:24:57Z")

</div>

Since your sourceSet is `bundle`, is your java source code in the `src/bundle/java` folder? If your source code is in `src/main/java`, then you don’t need to use a different sourceSet.

---

<div class="post-metadata">

**Author:** ![BobChilcott](https://avatars.discourse-cdn.com/v4/letter/b/77aa72/32.png) [@BobChilcott](https://bnd.discourse.group/u/BobChilcott)\
**Post date:** [August 18, 2022, 7:37pm UTC](https://bnd.discourse.group/t/no-code-is-included-in-created-bundle/258/3 "2022-08-18T19:37:10Z")

</div>

My source code is in `src/main/java`. I’ve removed the `sourceSet = sourceSets.bundle` line, but I’m met with exactly the same scenario.

---

<div class="post-metadata">

**Author:** ![bjhargrave](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/bjhargrave/32/10_2.png) [@bjhargrave](https://bnd.discourse.group/u/bjhargrave)\
**Post date:** [August 18, 2022, 7:55pm UTC](https://bnd.discourse.group/t/no-code-is-included-in-created-bundle/258/4 "2022-08-18T19:55:32Z")

</div>

So you removed

```auto
configurations {
    bundleCompile
}

sourceSets {
    bundle
}

```

and changed the bundle task to:

```auto
tasks.register("bundle", Bundle) {
    from sourceSets.main.output
    bundle {
        bnd(
                "Bundle-SymbolicName": "com.example.example-rewrite",
                "Bundle-Name": "example-rewrite",
                "Bundle-Version": "1.0",
                "Bundle-Activator": "com.example.MainActivator",
        )
    }
}

```

?

---

<div class="post-metadata">

**Author:** ![bjhargrave](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/bjhargrave/32/10_2.png) [@bjhargrave](https://bnd.discourse.group/u/bjhargrave)\
**Post date:** [August 18, 2022, 7:57pm UTC](https://bnd.discourse.group/t/no-code-is-included-in-created-bundle/258/5 "2022-08-18T19:57:48Z")

</div>

Unless you need the `jar` task to make some other jar, it is easier to just use the `jar` task which is enhanced by applying the bnd builder plugin.

```auto
tasks.named("jar") {
    bundle {
        bnd(
                "Bundle-SymbolicName": "com.example.example-rewrite",
                "Bundle-Name": "example-rewrite",
                "Bundle-Version": "1.0",
                "Bundle-Activator": "com.example.MainActivator",
        )
    }
}

```

---

<div class="post-metadata">

**Author:** ![BobChilcott](https://avatars.discourse-cdn.com/v4/letter/b/77aa72/32.png) [@BobChilcott](https://bnd.discourse.group/u/BobChilcott)\
**Post date:** [August 18, 2022, 8:07pm UTC](https://bnd.discourse.group/t/no-code-is-included-in-created-bundle/258/6 "2022-08-18T20:07:03Z")

</div>

I see my mistake, thank you. Using either of those two changes the bundle now contains my activator, and the warning is gone. However, karaf still won’t let me start the bundle, and I receive an error about `missing requirement: osgi.wiring.package; (osgi.wiring.package=com.example)`. You don’t happen to know how to resolve this as well? As I say, the package `com.example` is present within the bundle

---

<div class="post-metadata">

**Author:** ![BobChilcott](https://avatars.discourse-cdn.com/v4/letter/b/77aa72/32.png) [@BobChilcott](https://bnd.discourse.group/u/BobChilcott)\
**Post date:** [August 18, 2022, 8:11pm UTC](https://bnd.discourse.group/t/no-code-is-included-in-created-bundle/258/7 "2022-08-18T20:11:10Z")

</div>

Nevermind, it seems karaf was using an outdated cached bundle, it works perfectly. Thank you so much for all your help!

---

<div class="post-metadata">

**Author:** ![bjhargrave](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/bjhargrave/32/10_2.png) [@bjhargrave](https://bnd.discourse.group/u/bjhargrave)\
**Post date:** [August 18, 2022, 8:14pm UTC](https://bnd.discourse.group/t/no-code-is-included-in-created-bundle/258/8 "2022-08-18T20:14:29Z")

</div>

Without a fuller view into the project, I can’t provide much advice. The message indicates that the manifest is importing the com.example package which implies it is not in the bundle as far as the manifest calculation is concerned. Make sure you are not setting the `bundle.classpath` configuration (to anything other than `sourceSets.main.compileClasspath` which is the default).
