I have the following exception > Caused by: jav...
# community-support
g
I have the following exception
Caused by: java.lang.NoSuchMethodError: 'com.fasterxml.jackson.core.StreamReadConstraints com.fasterxml.jackson.dataformat.yaml.YAMLParser.streamReadConstraints()'
which is, probably, because I have multiple versions of that dependency in my classpath (2.14.2 and 2.16.1) what's the best way to debug and fix that?
m
Put all your plugin dependencies in
buildSrc/build.gradle.kts
(or
build-logic
if you're using included builds)
This way conflict resolution is happening in a central place
And you should only end up with 2.16.1
g
Here you can find my classpath,
dependencies
and
dependencyInsight --dependency com.fasterxml.jackson.core
Put all your plugin dependencies
It should't be a plugin dependency
👍 1
what's is weird is that
dependencyInsight --dependency com.fasterxml.jackson.core
shows conflict resolution between an additional version (2.9.10.1) which loses against 2.14.2
Selection reasons: - By constraint - By conflict resolution: between versions 2.14.2 and 2.9.10.1
v
When / where do you get that exception, how do you execute?
1
g
I'm running
Copy code
object ImageJMainTest {
    @JvmStatic
    fun main(args: Array<String>) {
        ImageJMain.main(args)
    }
}
from the tests, via Idea gui
m
Can you have two versions of a given dependency in a runtime classpath? I always thought Gradle would resolve to always one
You can dump your runtime classpath with
Copy code
afterEvaluate {
  println(configurations.getByName("runtimeClasspath").files)
}
v
Can you have two versions of a given dependency in a runtime classpath?
If you force it to, sure.
👍 1
Can you share your build script?
m
Idea gui
This is probably the issue ?
m
Maybe it's not going through Gradle at all?
☝️ 1
g
good point, it's not > /home/elect/.jdks/openjdk-21.0.2/bin/java -javaagent/home/elect/.local/share/JetBrains/Toolbox/apps/intellij idea ultimate 2/lib/idea rt.jar=33175/home/elect/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate-2/bin -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath.... sc.iview.ImageJMainTest
ok, so it's not Gradle related
👌 1
sorry for the noise, I'll open an issue on youtrack then
👍 1
m
Share the issue when you have it. I'm curious if there is a good solution to that problem.
👍 1
Like is there a convention that Gradle follows that IntelliJ can reuse to get the classpath? In theory, you could register your own
JavaExec
thing in your build script and do all kinds of things there. Sounds hard for IJ to pick this up
v
That's why you most problably should use the default which is delegating to Gradle. There you can then also do dirty trickery if needed like
Copy code
tasks
    .withType<JavaExec>()
    .matching { it.name.endsWith(".main()") }
    .configureEach { ... }
💯 1
m
Would be cool to be able to give IJ a task to execute for a given funcion:
Copy code
object ImageJMainTest {
    // ij-gradle-task: runMain
    @JvmStatic
    fun main(args: Array<String>) {
        ImageJMain.main(args)
    }
}
👍 1