Applying a plugin by alias to settings.gradle

I have a Gradle plugin that implements Plugin<PluginAware> to be able to be applied to build.gradle and settings.gradle. The following works absolutely find in build.gradle

buildscript { dependencies { classpath files(/path\to\my-plugin.jar/) } }
apply plugin: 'properties'

The same does not work in settings.gradle. There I have to write

buildscript { dependencies { classpath files(/path\to\my-plugin.jar/) } }
apply plugin: package.of.my.Plugin

Why won’t the alias work in settings.gradle? Is there something the plugin does wrong? Or something the settings.gradle file does wrong? Or is this a bug in Gradle?

Hello Björn, aliases should also work in gradle settings. Can you double check that the jar you’re pointing to contains a plugin descriptor?

Does it need something different from applying to a project? It was not a theoretical question, I really apply the plugin to both, the project and the settings. And I use the very same JAR. Which contains a META-INF/gradle-plugins/pluginid.properties file with a implementation-class property.

There’s nothing special except that you’re plugin should extend Plugin instead of Plugin. PluginAware should also be fine.

BTW, I created a sample project at gradle-demos/settingsPlugin at master · breskeby/gradle-demos · GitHub

cheers, René

Hm, assuming you meant Plugin<Settings> and Plugin<Project>, I don’t understand why it is not working then. :frowning:

can you create a selfcontained example demoing your issue? than I can have a look

May I just give you my work in progress? You can pull it from https://github.com/Vampire/gradle-properties-plugin/tree/settings-plugin-wip Then “./gradlew jar” And apply it to any build in project and / or settings with

buildscript { dependencies { classpath files('path/to/worktree/build/libs/gradle-properties-plugin-1.3.1.jar') } }
  apply plugin: 'properties'
//apply plugin: net.saliman.gradle.plugin.properties.PropertiesPlugin

The not-commented apply will work in project, in settings, only the commented line will work.

I also prepared a self-contained example at https://github.com/Vampire/gradle-properties-settings-plugin-example. Just clone it and call “./gradlew tasks” for example.

I created another more self-contained example. You don’t need my wip or anything else, just the showcase from https://github.com/Vampire/settings-plugin-problem-showcase (git clone git@github.com:Vampire/settings-plugin-problem-showcase.git) and run ‘’’./gradlew --continue’’’. Then you will see that it works by name in build.gradle always and that it also works by name in settings gradle if the plugin lives in buildSrc. But if the plugin is pulled in as dependency, in this case direclty as JAR, but I also tried through an Ivy repository, then it only works by classname, not by alias.

Rene, were you able to reproduce the problem with this showcase? Can you confirm that this is a gradle bug and not a problem of the plugin or the usage of it?

Anything more I can do to help you analyze this?