Call tasks of composite builds directly

According to documentation is not possible to call tasks of composite build directly:
https://docs.gradle.org/current/userguide/composite_builds.html#composite_build_executing_tasks

There is not (yet) any means to directly execute a task from an included build via the command line.

But why?
If I have includeBuild("plugin")

Why I cannot simply call for example gradlew :plugin:publishToMavenLocal as for any other model?

I need one simple thing. To have a project where will be Gradle plugin as module plugin and several samples project which will directly use plugin module as GradlePlugin. But I still need to publish plugin to artifactory as a normal plugin.

While not without some limitations, here’s what I’ve used as a workaround for now

tasks.addRule( 'Pattern: <included build>%<task>' ) { String taskName ->
    if( taskName.contains( '%' ) ) {
        def parts = taskName.split( '%' )
        if( parts.size() != 2 ) {
            throw new RuntimeException( "Invalid included build task reference '${taskName}'" )
        }
        task( taskName ) {
            dependsOn gradle.includedBuild( parts[0] ).task( ":${parts[1]}" )
        }
    }
}

Wow, thanks, interesting thing. And where exactly you have it?

I’m currently using a different hack via buildSrc described here
Plugin project with samples in one repository?
It works completely fine from command line but IDEA has some issues to open it :frowning:

I have it in the build.gradle of a composite build.