-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instructions on configuring mockito as agent lacks a Gradle Groovy DSL example (currently only Kotlin DSL) #3519
Comments
The documented instructions work fine with Gradle 8.11.1 when using kotlin dsl (which is the default in The
Also your snipped shows val mockitoAgent = configurations.create("mockitoAgent")
dependencies {
testImplementation(libs.mockito)
mockitoAgent(libs.mockito) { isTransitive = false }
}
tasks {
test {
jvmArgs("-javaagent:${mockitoAgent.asPath}")
}
} |
This depends how you define your catalog dependencyResolutionManagement {
versionCatalogs {
create("springDeps") {
from("...")
}
create("javaDeps") {
from("...")
}
}
} Becomes esp important if you use more then one catalog.
I know, but since kts syntax is by far not in feature parity with groovy ( most importantly the
Is there a way to go the other way around? What would be the counter part in groovy? Thanks for the help |
Here's how the same example can be done in groovy, note I'm still using the default catalog "libs" here. configurations {
mockitoAgent
}
dependencies {
mockitoAgent(libs.mockito) {
transitive = false
}
}
tasks {
test {
jvmArgs += "-javaagent:${configurations.mockitoAgent.asPath}"
}
} Out of scope for this issue. On the kotlin dsl side, you mentioned the limitations of |
This works, thank you! Maybe we should add the non kts example to the docs?
When we build our multi-project / composition project with gradle, we do split our configuration into different pieces, so we
e.g. // common
apply from: "$rootProject.projectDir/../gradle/common_compile.gradle"
apply from: "$rootProject.projectDir/../gradle/common_kotlin.gradle"
apply from: "$rootProject.projectDir/../gradle/common_repositories.gradle"
apply from: "$rootProject.projectDir/../gradle/common_dependencies.gradle"
apply from: "$rootProject.projectDir/../gradle/common_publish.gradle"
apply from: "$rootProject.projectDir/../gradle/common_tasks.gradle"
apply from: "$rootProject.projectDir/../gradle/common_dependency_check.gradle"
apply from: "$rootProject.projectDir/../gradle/common_dependencies_tests.gradle"
apply from: "$rootProject.projectDir/../gradle/common_tests_config.gradle"
// project specific
apply from: "$rootProject.projectDir/gradle/compile.gradle"
apply from: "$rootProject.projectDir/gradle/sonarqube.gradle"
apply from: "$rootProject.projectDir/gradle/publish.gradle"
apply from: "$rootProject.projectDir/gradle/dependencies.gradle" When you do this with kts gradle, most or all of them will not work, since e.g. sonarqube {
properties {
....
}
} Which a simple "include" at an arbitrary position the kts compiler cannot guarantee - thus such things cannot compile. For this to solve with kts based gradle, one will use company wide gradle-convention-plugins for the "common" stuff and the project wide convention plugins for the project. This is an effort, sure i is the better option in general - but it is nice to not being forced to go with the big guns. Again, you do no need to sell kotlin to me, we are basically only doing kotlin here, but for the gradle part, while i love the strong-typing, it comes with the named limitations which are a heavy price to pay (for us). |
Yes I will. Meanwhile I will rename this issue, so it will be easier to find. I see your point. I lived with it in the past. But now I think it's worth to invest in Kotlin DSL plugins. Maybe something like this https://github.com/melix/includegit-gradle-plugin from @melix could work for you ? |
Setup
Followed the instructions on https://javadoc.io/static/org.mockito/mockito-core/5.14.2/org/mockito/Mockito.html#0.3
my catalog (amongs other things)
Issue
Running gradle, i get the error for the line
mockitoAgent(javaDeps.mockito.core) { isTransitive = false }
What i tried
I also tried
Assumption
Is it a gradle version incompatibility (gradle 8.11.1) or something else? I'am using groovy
The text was updated successfully, but these errors were encountered: