I'm working on a Gradle plugin that simply adds a task to the project to run a simple jvm application. The plugin and the application are in the same project, and I'm hoping to just deploy a single binary to the plugin portal eventually. My understanding of maven dependency management is a little shaky, but the following code complains that Gradle can't resolve required artifacts for "dep". I don't need it to load the artifact from a maven repo though, since I've copied classfiles into the resulting plugin jar.
I've tried setting the maven dependencies to an empty list to override, but that doesn't help either.
I've also tried making the implementation
dependencies runtimeOnly
instead. That gets me further, but for some reason, it confuses the Gradle later down the line. Gradle tells me that it can't find a plugin with the specified id. The appropriate classfiles for the plugin implementation and application it depends on are in the jar. So perhaps a metadata file is misconfigured? The pom looks okay to me.
Is there an easier way to include classfiles of dependent projects into your plugin jar directly? What am I missing?
dependencies {
implementation(project(":dep"))
implementation(kotlin("stdlib-jdk8"))
testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.22")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.0")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.6.0")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.6.0")
}
gradlePlugin {
plugins {
register("plugin") {
id = "plugin"
implementationClass = "com.jzbrooks.plugin.PluginImpl"
}
}
}
tasks {
withType<Jar> {
dependsOn(configurations.runtimeClasspath)
val sourceClasses = sourceSets.main.get().output.classesDirs
inputs.files(sourceClasses)
doFirst {
from(configurations.runtimeClasspath.get().asFileTree.files.map(::zipTree))
from(files(sourceClasses))
}
}
question from:
https://stackoverflow.com/questions/65878124/including-dependency-classfiles-in-plugin-jar 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…