No code is included in created bundle

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

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.

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.

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.

So you removed

configurations {
    bundleCompile
}

sourceSets {
    bundle
}

and changed the bundle task to:

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",
        )
    }
}

?

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.

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

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

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

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