# Build with tests
./gradlew build
# Build without tests
./gradlew assemble
# Run all tests for a module
./gradlew :agent:test
# Run a single test
./gradlew :agent:test --tests "com.teamscale.jacoco.agent.MyTest.testMethod"
# Publish to local Maven repo (for local plugin testing)
./gradlew publishToMavenLocal
# Build Docker image
docker build -f agent/src/docker/Dockerfile .
# Compile for different JaCoCo version (don't commit unless upgrading)
./gradlew distThis is a multi-module Gradle project (Java 21 toolchain, targets Java 8) that provides a JVM profiler for collecting code coverage and uploading it to Teamscale.
- agent - Main Java agent that instruments bytecode via JaCoCo and collects coverage
- report-generator - Converts JaCoCo binary execution data to XML/testwise coverage formats
- teamscale-client - HTTP client library for Teamscale server communication
- tia-client - Test Impact Analysis client for identifying impacted tests
- teamscale-gradle-plugin - Gradle plugin for coverage collection and test-wise execution
- teamscale-maven-plugin - Maven plugin with equivalent functionality
- impacted-test-engine - JUnit 5 engine that queries Teamscale for impacted tests
Entry point: PreMain.premain() in agent/src/main/java/com/teamscale/jacoco/agent/PreMain.java
Initialization flow:
- JVM loads agent via
-javaagentparameter PreMain.premain()parses options and initializes loggingJaCoCoPreMainregistersLenientCoverageTransformerwith the JVM- Classes are instrumented at load time with coverage probes
Coverage modes:
- Interval-based (
Agentclass) - Periodically dumps coverage (default every 10 min) - Test-wise (
TestwiseCoverageAgentclass) - Per-test coverage via HTTP endpoints (/test/start,/test/end)
Key classes:
AgentOptions- Central configuration holderJacocoRuntimeController- Interface to JaCoCo's execution dataLenientCoverageTransformer- Bytecode instrumentation with error recoveryIUploader- Interface for upload backends (Teamscale, Azure, Artifactory, disk)
The system-tests/ directory contains integration tests that exercise the packaged agent JAR in various scenarios. Each subdirectory is a separate Gradle subproject.
Before completing any code change, verify:
- CHANGELOG.md updated for user-visible changes (bug fixes, new features, breaking changes)
- Tests added/updated for the change
- No unintended files modified