Java-gradle-plugin validatePlugins task

I am testing validatePlugins task from core plugin java-gradle-plugin which seems to be doing nothing during build or if I run it directly.

I have a build script that defined plugins with a nonexisting plugin class. Note foo.bar.NonexistingPluginClass this class is not in my source code.

plugins {
    id 'java-gradle-plugin'
}

gradlePlugin {
    plugins {
        create("simplePlugin") {
            id = "foo.bar.validation-plugin-test"
            implementationClass = "foo.bar.NonexistingPluginClass"
        }
    }
}

Now official Gradle page says following validation is being done:

The implementation-class property references a valid class file in the jar.

Still when I run the build task which also triggers validatePlugins one and there are no warnings reported, nothing. Also if I check build/reports/plugin-development/validation-report.txt the file is just blank.

Instead what I see is that :jar task that gets executed even before validatePlugins is being executed throws a message in the logs as shown below:

> Task :compileJava
> Task :pluginDescriptors
> Task :processResources
> Task :classes

> Task :jar
:jar: A valid plugin descriptor was found for foo.bar.validation-plugin-test.properties but the implementation class foo.bar.NonexistingPluginClass was not found in the jar.

> Task :assemble
>...
> Task :validatePlugins
> Task :check
> Task :build

BUILD SUCCESSFUL in 1s

Am I missing some additional configuration so that I get the warning that the implementationClass is not actually referring to existing class from the validatePlugins task? Or I misinterpreted documentation? Is this a bug?

Using Gradle version 7.2, Java 15

The ValidatePlugins task only validates that the input and output properties of a task or worker api item and similar are properly annotated. The documentation you refer to says that those checks are added by the plugin and that they produce a warning message. And that is exactly what happens. This specific check is added to the jar task and produces a warning message as you have shown. A warning message does not fail the build though.

1 Like