This message was deleted.
# community-support
s
This message was deleted.
t
Copy code
buildscript {
  repositories {
    mavenCentral()
  }
}
plugins {
  kotlin("jvm") version "1.8.10"
  id("com.company.myplugin")
}
repositories {
  mavenCentral()
}
I’m running the test with this:
Copy code
GradleRunner.create()
        .withProjectDir(context.projectDirectory.toFile())
        .withPluginClasspath()
        .withDebug(true)
        .withArguments("assemble", "--stacktrace")
        .build()
t
This is classloader issue: your plugin comes from a special classloader (from
withPluginClasspath
) that's a parent of the actual build, so it won't ever see the plugins loaded by the project itself.
You need to either: • add the Kotlin plugin to your plugin classpath metadata (that'll be used by
withPluginClasspath
) so both plugins are in the same classloader • or avoid
withPluginClasspath
and load your plugin from, e.g., a local repository where you previously published it.
t
Ahh I see. Thank you Thomas! I’ll give that a shot! It seems unfortunate though. Seems like the latter is the better solution, but might be a lot of work to get setup. Do people typically put their integration test for the plugin in a separate sub project in order to get it published first?
t
You can setup an additional publish repository (as a directory in your build dir) and wire your tasks to publish before running the tests.
t
Gotcha 👍 I’ll start with your first solution and maybe try that next. Thanks for the help!
Just to follow up, this worked great! The only thing I was stuck on for a bit was I was getting unresolved reference errors. I saw this issue and even though I’m on gradle 7.6.1 removing
withDebug
solved it.