# multiplatform


02/04/2021, 12:26 AM
Hey all 👋 I’m trying to adapt a Gradle plugin to KMP. I’m having a hard time accessing the classpaths of the various source sets/targets. I’m unsure if trying to access a classpath makes sense for native/js targets, but there should definitely be a way to access jvm/android classpaths. Am I the only one facing this? Do you have some examples or other plugins that might be doing this to share?


02/04/2021, 1:11 AM
It might help to be more specific about what you’re trying to achieve. A gradle plugin will itself always be running on the JVM, so making the plugin logic itself multiplatform doesn’t make much sense. But it sounds like you might be taking a plugin that currently acts on jvm code and modifying it to act on multiplatform code?


02/04/2021, 1:25 AM
So I’m working on extending the support for the #detekt gradle plugin to support also projects that are using the
plugin. So far our Gradle plugin supports Android and JVM projects out of the box, and creates Detekt tasks with the correct classpaths. If a user is applying instead the KMP plugin, we don’t generate specific tasks for every target/source set. Ideally I would like to offer this support.


02/04/2021, 1:29 AM
I am using Detekt Gradle plugin in multiplatform projects 🤔, it should only work on JVM and Android sourcesets? I will check tomorrow 🕵️‍♂️


02/04/2021, 1:35 AM
If you:
Copy code
plugins {
    id("io.gitlab.arturbosch.detekt") version "1.18.0"
Then it will pickup the android source set correctly and will add specific tasks for that, as the Detekt plugin recognises that you’re applying AGP. But the KMP Gradle plugin is ignored as of today.

Nicholas Doglio

02/04/2021, 1:39 AM
On mobile so haven't looked at the code to see specifically how it's being achieved but the ktlint-grafle plugin already does this if you want to check that out.


02/04/2021, 1:40 PM
Thanks for the hint @Nicholas Doglio. Yeah ktlint-gradle does something similar, but they don’t access the classpath but just the
(here). The reason is that they don’t need to have access to depenencies and to resolve types. In detekt we do so we can provide more in-depth analysis.
After spending some time on it, I actually managed to do it. I’m now able to properly populate the classpath for Jvm and Android targets. Still unlucky with JS and Native targets, but hopefully will manage to find a way for those as well. I’m leaving the solution here for future reference