Daren Burke
03/17/2025, 12:04 PMgradlePlugin {
plugins {
myConfigPlugin {
id = 'com.my.config-plugin'
implementationClass = 'my-plugin'
}
}
}
but there is no my-plugin class included in the jar that is generated, so when i publish locally and try to pull it into another project to share the settings, the implementationClass is not found
any ideas how to resolve this?Vampire
03/17/2025, 12:11 PMgradlePlugin { plugins { ... } }
, the plugin ID is derived from the package in the pre-compiled script plugin and the filename of the precompiled script plugin, unless you want to have the plugin available under multiple IDs.
Just two points, as you want to use Groovy DSL precompiled script plugins, you have to apply the plugin that enables support for them in that build which you probably did not.
And once you did, you should adjust the plugin ID, because currently it would be my-plugin
(unless there is a package declaration in the file and plugin IDs without dot (.
) should stay reserved for built-in plugins usually.Vampire
03/17/2025, 12:12 PMVampire
03/17/2025, 12:13 PMgroovy-gradle-plugin
is the plugin you need for Groovy DSL precompiled script pluginsDaren Burke
03/17/2025, 12:30 PMDaren Burke
03/17/2025, 5:24 PMTask :jar🫙 A valid plugin descriptor was found for com.my-config.properties but the implementation class my-config.gradle.kts.MyConfigPlugin was not found in the jar.
Vampire
03/17/2025, 5:26 PMDaren Burke
03/17/2025, 5:27 PMDaren Burke
03/17/2025, 5:27 PMVampire
03/17/2025, 5:28 PMbuildSrc/src/main/kotlin
?Daren Burke
03/17/2025, 5:28 PMVampire
03/17/2025, 5:29 PMDaren Burke
03/17/2025, 5:29 PMDaren Burke
03/17/2025, 5:48 PMplugins {
kotlin("jvm") version "2.1.10"
id("java-gradle-plugin")
id("maven-publish")
id("com.jfrog.artifactory") version "5.+"
}
group = "com.mycompany.myproduct"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation(platform("org.junit:junit-bom:5.+"))
testImplementation("org.junit.jupiter:junit-jupiter")
}
tasks.test {
useJUnitPlatform()
}
Daren Burke
03/17/2025, 5:49 PMplugins {
id("checkstyle")
id("java-gradle-plugin")
id("jacoco")
id("maven-publish")
id("pmd")
}
group = "com.mycompany.myproduct"
description = "Gradle Plugin containing Common myproduct Configuration settings"
version = "1.0.0"
repositories {
maven { url = uri("<https://mycompany.repository/java>") }
mavenLocal()
}
dependencies {
testImplementation platform("org.junit:junit-bom:5.+")
testImplementation "org.junit.jupiter:junit-jupiter"
}
Vampire
03/17/2025, 5:51 PMDaren Burke
03/17/2025, 6:03 PMVampire
03/17/2025, 6:17 PMVampire
03/17/2025, 6:22 PMmavenLocal()
is a very bad idea.
At least it is the last one, but it should practically never be used and if, then only with a repository content filter.
🙂Vampire
03/17/2025, 6:22 PMDaren Burke
03/17/2025, 6:30 PMDaren Burke
03/17/2025, 6:55 PMVampire
03/18/2025, 11:05 AM<http://services.gradle.org|services.gradle.org>
URL and currently not configurable: https://github.com/gradle/gradle/issues/27863
To work-around this, you would need to use an -all
distribution instead of a -bin
distribution as that already contains the sources so they don't need to be downloaded.Vampire
03/18/2025, 11:16 AMbuildSrc
build.
buildSrc
is a complete own build that "happens to run" before your main build and the result added to the buildscript classpath of your main build.
You must not mix up those two builds.
If you want to customize the buildSrc
build, you have to do it in the build scripts of that build, not in your main build.
So if you just remove the id("java-gradle-plugin")
and the whole gradlePlugin { ... }
block from your main build script, and instead add a build script to your buildSrc
build where you apply the kotlin-dsl
plugin and define a repository, it will work better.
Better in this case means that buildSrc
will fail to compile, as your plugin is not proper Kotlin syntax.Vampire
03/18/2025, 11:17 AMDaren Burke
03/18/2025, 3:19 PMDaren Burke
03/18/2025, 4:45 PMVampire
03/18/2025, 5:02 PMDaren Burke
03/18/2025, 5:07 PMVampire
03/18/2025, 5:09 PMDaren Burke
03/18/2025, 5:23 PMVampire
03/18/2025, 5:41 PMbuildSrc
build as I said beforeVampire
03/18/2025, 5:41 PMVampire
03/18/2025, 5:42 PMVampire
03/18/2025, 5:42 PMbuildSrc
in one build to configure all the projects in that one build uniformly?Vampire
03/18/2025, 5:43 PMbuildSrc
build is not what you want, because what you have in buildSrc
is for usage in the main build of exactly that build you are running, not to develop something you publish and other builds are using.Daren Burke
03/18/2025, 5:48 PMVampire
03/18/2025, 5:50 PMbuildSrc
is to develop build logic that you use in that very same work-tree.
If you for example have a multi-project build and there want to centralize build logic.
To publish a plugin other projects are using, you develop the code in the main build of course.Daren Burke
03/18/2025, 5:52 PMDaren Burke
03/18/2025, 5:54 PMVampire
03/18/2025, 5:54 PMDaren Burke
03/18/2025, 5:56 PMDaren Burke
03/18/2025, 5:58 PMVampire
03/18/2025, 5:58 PMdependsOn
(unless on the left-hand side is a lifecycle task) you do something wrongVampire
03/18/2025, 5:59 PMi thought adding the implementationClass = CommonConfigPluginThat does only tell the plugin dev plugin what implementation class to use for the given id
Vampire
03/18/2025, 5:59 PMapply
method to be executedDaren Burke
03/18/2025, 6:00 PMVampire
03/18/2025, 6:00 PMplugins {
id("com.my.config-plugin") version "1.2.3"
}
Vampire
03/18/2025, 6:00 PMok, so I need an apply method within my plugin?well, yes, that is where you do the work
Daren Burke
03/18/2025, 6:01 PMVampire
03/18/2025, 6:01 PMVampire
03/18/2025, 6:01 PMVampire
03/18/2025, 6:01 PMVampire
03/18/2025, 6:01 PMand that lives right in the plugin's build.gradle.kts?
Daren Burke
03/18/2025, 6:02 PMVampire
03/18/2025, 6:02 PMbuild.gradle.kts
is, what is used to build the pluginVampire
03/18/2025, 6:02 PMVampire
03/18/2025, 6:02 PMthere really isn't much in the plugin documentation regarding thisThen you probably didn't look at the correct pages