Skip to content
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

JaCoCo Agent Override #195

Closed
wakawaka54 opened this issue Jul 6, 2022 · 4 comments · Fixed by #295
Closed

JaCoCo Agent Override #195

wakawaka54 opened this issue Jul 6, 2022 · 4 comments · Fixed by #295
Labels
Feature Feature request issue type Kover DSL Kover Gradle Plugin S: postponed Status: work on the issue is not in the short term plans

Comments

@wakawaka54
Copy link

I'm working through JaCoCo support with this tool and I did have quite a bit of trouble with the JaCoCo Agent resolution logic. In the internal builds in my company we provide the JaCoCo dependencies in a custom manner.

This logic here expects the dependency name to be "org.jacoco.agent" https://github.com/Kotlin/kotlinx-kover/blob/main/src/main/kotlin/kotlinx/kover/engines/jacoco/JacocoAgent.kt#L20 . The problem I couldn't find a good way to manually provide an agent jar that would work resolve properly here.

I had to do this:

class JacocoAgentDependency(collection: FileCollectionInternal) : DefaultSelfResolvingDependency(collection) {
    override fun getName(): String = "org.jacoco.agent"
}

val koverJacocoConfig = project.configurations.getByName("JacocoKoverConfig")

val jacocoAgentJar: File = // my custom agent jar //

koverJacocoConfig.withDependencies {
    val fileCollectionFactory: FileCollectionFactory = serviceOf()
    add(JacocoAgentDependency(fileCollectionFactory.fixed(jacocoAgentJar)))
}
@shanshin
Copy link
Collaborator

shanshin commented Jul 6, 2022

Hi,
may you clarify, you are using a fork of the JaCoCo?

@wakawaka54
Copy link
Author

Uhhh technically no. But I think a good way to think about this request is that if I have the JaCoCo Agent JAR located locally within the same project, I'd want to configure Kover to just use that JaCoCo Agent rather than trying to implicitly resolve it.

This might also be better served by allowing some customization into the Kover engine adapters, potentially allowing me to register my own engine, etc.

@shanshin
Copy link
Collaborator

shanshin commented Jul 6, 2022

Unfortunately, you can't just replace the agent jar file - for the plugin to work correctly, it must be compatible with the classpath of reports.
Also, the plugin must be modified so that the build cache supports custom agents.
Making an adapter for custom coverage engines is a good idea, but it was not included in the short-term plans.

As a workaround, you may try to use a fork of the JaCoCo, publish it to a local Maven repository.

@shanshin shanshin added the S: postponed Status: work on the issue is not in the short term plans label Oct 27, 2022
@shanshin
Copy link
Collaborator

Resolved in 0.7.0-Alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Feature request issue type Kover DSL Kover Gradle Plugin S: postponed Status: work on the issue is not in the short term plans
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants