:question: hello! I'm looking into creating custom...
# gradle
d
hello! I'm looking into creating custom gradle plugin and would like to apply it to an example project in the multi module project, e.g.
Copy code
project
| build.gradle.kts
| library
  | build.gradle.kts
| custom-plugin
  | build.gradle.kts
| example
  | build.gradle.kts <-- use both library classath dependency and apply custom-plugin to the build
It appears that it is not possible? Above setup is pretty easy to do in Maven project but getting some trouble with Gradle. My attempt for example build script
Copy code
buildscript {
    dependencies {
        // cannot use project(path = :custom-plugin) here -> Cannot use project dependencies in a script classpath definition
        classpath("com.sample:custom-plugin:1.0.0-SNAPSHOT") // this searches for the released jar
    }
}

apply(plugin = "com.sample.custom")

dependencies {
    implementation(project(path = ":library"))
}
Any suggestions?
Saw this -> https://stackoverflow.com/questions/35302414/adding-local-plugin-to-a-gradle-project but linking to a jar seems pretty frail, also would like to avoid having to publish jar as i would like to verify its behavior before publish
I believe this is not possible because of the
configuration
vs
execution
build phase?
d
👍 so i guess I don't need the
buildscript
part, thanks! i'll give it a try
ah... so the plugin and the lib are separate builds
o
yes
d
is it possible to build all at the same time?, e.g. in my example above I do want to build all projects and execute their tests but i also want to apply my custom plugin against the example project
o
if you build the example project with the plugin included, it will also be built to produce the artifact. I don't know if you can do a full build on both though
it might be easier to copy the example project to a Gradle Test Kit setup, and test it that way
d
yeah i was planning on doing that regardless, in my setup though example project serves as a sample for the library
so was looking into also exposing fully working example on how to use lib + plugin
again this is doable in maven (just define example as a project run after the other two and reference the lib artifact + plugin with current version) so was hoping i could do the same in gradle
i'm thinking probably the cleanest way is to keep the lib + plugin in a single build and then create separate build for the example, thanks for the help
i'll look into it tomorrow