I am using gradle 7.x.x and now facing an issue while running gitlab pipeline and during build stage.
Error: gradle Task : "publish" uses the output of task ':jar" without declaring an explicit or implicit dependency.
Can anyone please help me with the solution ? Thanks :)
I tried enclosing puublishing block inside afterEvaluate block.
This is very easy to fix. You did not say whether you are using the Groovy or Kotlin DSL, so I will just give the Kotlin version. Add this to your build.gradle.kts
.
tasks.named("publish") {
dependsOn(tasks.named("jar"))
}
If you are using the Groovy DSL, refer to the DSL reference for examples of using the Groovy version:
https://docs.gradle.org/current/dsl/index.html
An important thing to understand is the first object in scope in a Gradle file is the Project
class. Meaning that if you are not in another nested scope, and you type tasks
at the beginning of the line, like above, this is referring to Project.getTasks()
.