I’m trying to run both the compiler plugin and the...
# detekt
t
I’m trying to run both the compiler plugin and the main gradle plugin at the same time. When I do this, the main gradle plugin cannot find it’s
versions.properties
in resources anymore, and I’m struggling to figure out why. Any ideas that could get me unstuck?
c
What is “the main gradle plugin”? If both files contain versions.properties on the classpath at the same location, only one will be resolved.
t
Copy code
id("io.github.detekt.gradle.compiler-plugin")
    id("io.gitlab.arturbosch.detekt")
Would that mean if a totally unrelated plugin also had a
versions.properties
, it would break in a similar way?
c
Depends on how
versions.properties
is loaded. There are options to find all occurrences, though most of the common ways load just the first instance.
t
So you’re saying maybe the check in
io.gitlab.arturbosch.detekt
Copy code
internal fun loadDetektVersion(classLoader: ClassLoader): String = Properties().run {
    load(classLoader.getResource("versions.properties")!!.openSafeStream())
    getProperty("detektVersion")
}
could use
getResources
instead? So instead of finding the first
versions.properties
it uses the first one that has
detektVersion
?
c
ideally the resource would be located in a plugin-specific location to avoid collisions, but, yes, the loading logic could be tweaked to find all versions.properties, though that raises the question as to which one to use…
t
I did the quick and dirty solution for now, because the other plugin is a local fork. I just added the right property to that plugin’s
versions.properties
and it worked. But I could probably put up a PR to
io.gitlab.arturbosch.detekt
. It should probably handle this, in case another random plugin has this resource too.
👍 1