This message was deleted.
# community-support
s
This message was deleted.
j
Remote application being a an application that is running? When you start the application, you would need to attach the jacoco agent to the process to get coverage.
e
I’m starting the application with jacocoagent running in tcpserver mode, but I’m not sure how to pull the coverage data after test run is done
I found some 7 year old thread on the forums related to it, where someone solved it with an Ant-task but I’m not sure if that is still possible.. would go something like this:
Copy code
tasks.register("dumpCoverage") {

// groovy version:
//        ant {
//            taskdef(name: 'dump',
//            classname: 'org.jacoco.ant.DumpTask',
//            classpath: configurations.jacocoAnt.asPath)
//
//            dump(address: '<http://server.com|server.com>',
//            destfile: "$buildDir/jacoco.exec")
//        }

    ant {
        task(
            mapOf(
                "classname" to "org.jacoco.ant.DumpTask",
                "classpath" to configurations.jacocoAnt.get().asPath
            ),
            "dump"
        )
    }
}

tasks.test { finalizedBy(tasks.withName("dumpCoverage").single()) }
v
Why are you running in TCP server mode? Do you have something that is connecting to the agent?
e
CI pipeline starts application as a docker with jacocoagent in server mode and a parallel separate step runs tests using gradle against this docker container
Now I want the gradle task that runs the tests to also connect and dump the coverage data before being done
v
Independent from "triggering the dump", if you run in TCP server mode, some capable tool has to connect to that server to retrieve the data. Where should it dump to otherwise?
e
yes.. and jacoco ant plugin has pre-defined task for this, as does jacoco maven plugin.. was wondering if there’s any conventional way of doing it with gradle as well 🙂
v
Ah, sorry, forgot that the ant task actually retrieves the data and writes it to a file. I thought it only sends the dump command. Well, Ant is still a first-class citizen in Gradle, so you can just use the Ant task. If you don't like that, you can also copy a few lines of code from http://www.eclemma.org/jacoco/trunk/doc/examples/java/ExecutionDataClient.java to just do it in an own class.
I'm not aware of any Gradle built-in functionality besides the Ant task, but I might be wrong of course.