Thank you for your response, appreciate it a lot!
never use project.getPlugins()
(
You are, of course, right. I have tried all the alternatives, and this one just left me in the editor when I formulated my forum question. Normally, I use project.getPluginManager
.
You need to add the plugin as dependency to the project that builds the plugin.
Should I define the following in my plugin project?
dependencies {
implements ("first:plugin:artifact")
implements ("second:plugin:artifact")
}
I have no idea how it could help in my target projects when using my plugin because I am referencing the other plugins via ID and not using the plugin class.
What worked for me was the following definition in build.gradle.kt
in my target project
buildscript {
dependencies {
classpath ("my:plugin:artifact")
classpath ("first:other_plugin:artifact")
classpath ("second:other_plugin:artifact")
}
}
However, this would not make my job easier - instead of defining the plugins in the plugins{}
block via ID, I do the definition in the buildscript{}
block. I have a lot of projects where the plugins{}
block in build.gradle
contains approx. ten 3rd party plugins (never published, distributed only as a ZIP file by the framework author, do not ask why?!), and it repeats in all my projects dealing with the framework. My idea was to apply all these plugins from my plugin without the need for additional definitions.
BTW - I discovered that in MyPlugin.apply()
, no repositories reference exists and this snipped reports nothing
project.getRepositories().forEach(repository -> {
System.out.println("REPOSITORY: " + repository.getName());
});
I tried to add repositories in MyPlugin.apply()
before calling project.getPluginManager().apply("...")
, did not help.
RepositoryHandler rh = project.getRepositories();
rh.mavenCentral();
rh.gradlePluginPortal();
rh.maven(repo -> {
repo.setUrl(new URI("file:///C://Path/To/3rd/Party/Maven/Repo"));
repo.setName("....");
});
//
I am giving up,