I’m trying to publish a custom plugin locally using the com.gradle.plugin-publish 0.12.0 and maven-publish. The custom plugin uses default dependencies, which I’m trying to test out if they are working correctly. When I user the following in build.gradle(see below) the plugin loads and works, but the default dependency doesn’t get overridden.
build.gradle
buildscript {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath “com.example:custom-gradle-plugin:1.0-SNAPSHOT”
}
}plugins {
id ‘java’
}apply plugin: ‘com.example.custom-plugin’
group ‘org.example’
version ‘1.0-SNAPSHOT’repositories {
mavenCentral()
}dependencies {
“h2” (“com.h2database:h2:1.4.197”)
testImplementation(“org.junit.jupiter:junit-jupiter-api:5.3.1”)
testRuntimeOnly(“org.junit.jupiter:junit-jupiter-engine:5.3.1”)
}
If I edit the settings.gradle file (see below) and the build.gradle (see below) the plugin is not found.
settings.gradle
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
}
}rootProject.name = ‘test’
build.gradle
plugins {
id ‘java’
id ‘com.example.custom-plugin’
}group ‘org.example’
version ‘1.0-SNAPSHOT’repositories {
mavenCentral()
}dependencies {
“h2” (“com.h2database:h2:1.4.197”)
testImplementation(“org.junit.jupiter:junit-jupiter-api:5.3.1”)
testRuntimeOnly(“org.junit.jupiter:junit-jupiter-engine:5.3.1”)
}
For the default dependencies, I followed the guide here Gradle Implementing Gradle Plugins. I’m just unsure if listing the implementation dependency under dependencies is causing the issue. If so how am I suppose to include the dependency to build the plugin while letting a user change the version of the dependency.
Thanks for all your help.