Apply Gradle plugin from source using `plugins` block

I’m trying to apply a Gradle plugin from source.

I figured out how to do it using the legacy apply method:

// build.gradle

buildscript {
    dependencies {
        classpath("com.verificationgentleman.gradle:gradle-hdvl") {
            version {
                branch = "master"
            }
        }
    }
}

apply plugin: 'com.verificationgentleman.gradle.hdvl.systemverilog'
// settings.gradle

sourceControl {
    gitRepository("https://github.com/tudortimi/gradle-hdvl.git") {
        producesModule("com.verificationgentleman.gradle:gradle-hdvl")
    }
}

Is it possible to do the same, but use the plugins block instead?

Hi @tudortimi,

No that is not possible at the moment. The reason is that source dependencies are resolved lazy at the moment. That is, only once the dependency is resolved the repository is cloned/updated.

For the plugins block, Gradle would need to do this upfront to know which plugins are provided by a source dependency. For that we would need a special mechanism that allows you to declare such a source dependency for this “early resolution”.

We are working on improving the mechanism for local included builds (see https://github.com/gradle/gradle/pull/15317). In the future it might be possible to build on top of that for source dependencies.

1 Like

Thanks for the info! As long as the apply(...) mechanism sticks around until source dependencies are available for “early resolution” it should be fine.