Unable to apply external pre-compiled plugin

I was following article publishing convention plugin. this is project structure for plugin.

       -- build.gradle
       -- settings.gradle
       -- src/main/groovy
          -- com.platform.platform-plugin.gradle

build.gradle looks like this

plugins {
        id 'groovy-gradle-plugin'
        id 'java-gradle-plugin'
        id 'maven-publish'
    group = 'com.platform.plugins'
    version = '0.1.0-SNAPSHOT'
    publishing {
        repositories {

Next i ran ./gradlew build && .gradlew publishToMavenLocal to publish plugin to local artifactory. (verified plugin-platform-0.1.0-SNAPSHOT.jar/.pom/.module packages are available)

Now In another project, where i want to apply com.platform.platform-plugin, i have updated settings.gradle to include plugin-management block as below

pluginManagement {
        repositories {

and applied plugin in plugins block of build script.

    plugins {
        id 'com.platform.platform-plugin' version '0.1.0-SNAPSHOT'

Now, when i run ./gradlew build, I get following error

FAILURE: Build failed with an exception.
    * What went wrong:
    > org.gradle.plugin.devel.internal.precompiled.FirstPassPrecompiledScript
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Any help / pointer to resolve this would be helpful. Thank you.

Hi @bytecoder

I bumped against the same issue recently. Couldn’t understand if this is an issue with using precompiled script plugins in other external projects as the same code worked if I have used in in the same project through buildSrc module.

At the end I manage to find the issue. It’s a breaking change in Gradle.

The message tells you that the FirstPassPrecompiledScript class is missing. It was added in Gradle version 7.0 and later.

This means you were using newer version of Gradle in the plugin project. You compiled, packaged and published it with new version of Gradle that contains this class, and then try to apply the plugin in a Gradle project with the version that is lower than 7.0. When older Gradle tried to load the provided plugin it throws above mentioned exception as it doesn’t have yet the FirstPassPrecompiledScript in its API.
You see gradle/FirstPassPrecompiledScriptRunner.java at master · gradle/gradle · GitHub it was introduced 8 months ago, with the logic that prevents usage of buildscript blocks in precompiled script plugins.

You have two options (hope you are using Gradle wrapper):

  • Set Gradle version in plugin to older one or
  • Set Gradle version in consuming project to at least 7.0