bndtools / workspace

A starter Bnd workspace with plain OSGi dependencies and a Bnd Gradle build.
http://bndtools.org
Apache License 2.0
7 stars 13 forks source link

The resolve plugin only works for the mainSourceSet.getRuntimeClasspath() and artifacts #15

Closed catshow closed 2 years ago

catshow commented 2 years ago

Please add a Configuration property for the resolve plugin for which you can set a configuration like this sample task:

val resolveTask = tasks.register<aQute.bnd.gradle.Resolve>("resolve") {
    description = "Resolve test.bndrun"
    group = "test"
    configuration.set(configurations.testRuntimeClasspath)
    bndrun.set(file("test.bndrun"))
    outputBndrun.set(layout.buildDirectory.file("test.bndrun"))
}

I am not allowed to make large source contributions but this is how I patched the plugin in AbstractBndrun.java

+       private final Property<Configuration>           configuration;

        /**
         * The bndrun file for the execution.
@@ -113,6 +116,12 @@ public abstract class AbstractBndrun extends DefaultTask {
                return bundles;
        }

+       @Input
+       @org.gradle.api.tasks.Optional
+       public Property<Configuration> getConfiguration(){
+               return configuration;
+       }
`
 @ line 352
`                                if (!workspace.isPresent()) {
-                                       FileSetRepository fileSetRepository = new FileSetRepository(getName(), getBundles().getFiles());
+                                       final Set<File> repositoryFiles = new HashSet<>();
+                                       repositoryFiles.addAll(getBundles().getFiles());
+                                       if (getConfiguration().isPresent()){
+                                               repositoryFiles.addAll(getConfiguration().get().resolve());
+                                       }
+                                       FileSetRepository fileSetRepository = new FileSetRepository(getName(), repositoryFiles);
bjhargrave commented 2 years ago
  1. This is the wrong GitHub repo. The code is in bndtools/bnd.
  2. Why don't you use the bundles property which is a ConfigurableFileCollection?
val resolveTask = tasks.register<aQute.bnd.gradle.Resolve>("resolve") {
    description = "Resolve test.bndrun"
    group = "test"
    bundles.from(configurations.testRuntimeClasspath)
    bndrun.set(file("test.bndrun"))
    outputBndrun.set(layout.buildDirectory.file("test.bndrun"))
}
catshow commented 2 years ago

Sorry about the wrong repo. I was looking at how to configure a workspace. Yep the bundles thing works. I'm still a gradle newb. I was just following an example from osgi.test which requires an integration project. Could you update the resolve and TestOSGi task documentation to show how to use the bundles? Thanks!