How to copy the runtime classpath of another project into a zip, but not its jar-artifact itself

Hi! How do I best solve an issue like this:

Let’s say I have two subprojects, called AppProject and PluginProject. AppProject and PluginProject both are java projects. AppProject has a zip task (or really any kind of copy task) and I want to copy all dependencies (actually configurations.runtimeClasspath) of PluginProject into the zip file - but not the jar file produced by :PluginProject:jar .

Gradle doesn’t seem to like it when I try to reference project(':PluginProject').configurations.runtimeClasspath in my build script of AppProject and prints a deprecation warning. I tried to create a new configuration “myconf” in AppProject and do something like configurations { myconf.extendsFrom project(':PluginProject').configurations.runtimeClasspath }, but this doesn’t work (because expected dependencies are not copied into the zip when using from configurations.myconf with the copyspec), even after fiddling with project.evaluationDependsOn(..).

I actually found a solution, but I have the feeling that it could be done in a cleaner way. This is part of my build script of AppProject:

configurations {
  appPlugin
}

dependencies {
  appPlugin project(':PluginProject')
}

def pluginJars = []

configurations.appPlugin.dependencies.each { dep -> 
  if(dep instanceof ProjectDependency) {
    def pluginProject = dep.dependencyProject
    pluginJars.addAll(pluginProject.tasks.jar.outputs.files)
  }
}

task myZipTask(type: Zip) {
  into '/usr/share/myapp/'
  from configurations.appPlugin 
  exclude { it.file in pluginJars } // Include all dependencies of the plugins, but not the plugin-jars themselves.
}

This feels dirty. Is there a better way to do that?