I have a source dependency that isn’t built by Gradle into which I would like to inject a Settings
plugin. I’m still developing this plugin, so I’m currently publishing it to mavenLocal()
.
Conceptually, I would like to do the following in my main project:
// settings.gradle
sourceControl {
gitRepository("https://github.com/tudortimi/svunit.git") {
producesModule("org.svunit:svunit")
plugins {
id 'com.verificationgentleman.gradle.hdvl.svunit-build' version '0.1.0-SNAPSHOT'
}
}
}
The doc for VersionControlRepository.plugins(...)
says that injected plugins must be located in the calling build’s buildSrc
project. This native sample shows that it’s also possible to inject plugins defined in included builds.
I thought I was going to game the system by defining a local plugin that just applies the aforementioned plugin from mavenLocal()
.
I created a new plugins
directory, which I included in the main build. I added an empty settings.gradle
file to have Gradle treat it as an own project. I made it a Gradle plugin build:
// plugins/build.gradle
plugins {
id 'groovy'
id 'java-gradle-plugin'
}
gradlePlugin {
plugins {
"local-svunit-build" {
id = "local-svunit-build"
implementationClass = "com.verificationgentleman.tgen.gradle.LocalSVUnitBuildPlugin"
}
}
}
The goal was to inject this plugin in the main settings.gradle
:
sourceControl {
gitRepository("https://github.com/tudortimi/svunit.git") {
producesModule("org.svunit:svunit")
plugins {
'local-svunit-build'
}
}
}
I added the following code to the implementation class:
class LocalSVUnitBuildPlugin implements Plugin<Settings> {
void apply(Settings settings) {
settings.apply plugin: "com.verificationgentleman.gradle.hdvl.svunit-build"
}
}
I get the following exception:
An exception occurred applying plugin request [id: 'local-svunit-build']
> Failed to apply plugin 'local-svunit-build'.
> Plugin with id 'com.verificationgentleman.gradle.hdvl.svunit-build' not found.
I figured this was because mavenLocal()
was missing as a repository from the ‘plugins’ project. I tried adding the following lines to the build file:
repositories {
mavenLocal()
}
No luck. I figured that maybe the issue was that Gradle didn’t know exactly how to handle the svunit-build
plugin version. I added a dependency on it to the classpath:
dependencies {
runtimeClasspath "com.verificationgentleman.gradle:gradle-hdvl:0.1.0-SNAPSHOT"
}
(I’m using IntelliJ IDEA and the project is integrated with Gradle. It shows me that the dependency is properly resolved. The jar also has a properties
file which specifies the implementation class for com.verificationgentleman.gradle.hdvl.svunit-build
.)
I still get the error.
Does anyone have any idea what I’m doing wrong?