Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@ Kover Toolset:
- [Kover features artifact](#kover-features-artifact)

## Kover Gradle Plugin
For full information about latest stable release of Kover Gradle Plugin, please refer to the [documentation](https://kotlin.github.io/kotlinx-kover/gradle-plugin).
For full information about the latest stable release of Kover Gradle Plugin, please refer to the [documentation](https://kotlin.github.io/kotlinx-kover/gradle-plugin).

### Features

* Collection of code coverage through `JVM` tests (JS and native targets are not supported yet).
* Collection of code coverage for JVM and Android host tests (JS and native targets are not supported yet).
* Generating `HTML` and `XML` reports.
* Support for `Kotlin JVM`, `Kotlin Multiplatform` projects.
* Support for `Kotlin Android` projects with build variants (instrumentation tests executing on the Android device are not supported yet).
* Support mixed `Kotlin` and `Java` sources
* Works with `kotlin("jvm")`, `kotlin("android")`, `kotlin("multiplatform")` and `com.android.kotlin.multiplatform.library` plugins.
* Support build variants in `kotlin("android")` projects.
* Support mixed `Kotlin` and `Java` sources.
* Verification rules with bounds in the Gradle plugin to keep track of coverage.
* Using JaCoCo library in Gradle plugin as an alternative for coverage measuring and report generation.

The recommended way of applying Kover is with the
[plugins DSL](https://docs.gradle.org/current/userguide/plugins.html#sec:plugins_block).

Minimum supported version of `Gradle` is `6.8`.
Minimum supported version of `Gradle` is `6.8.3`.
Minimum version of JVM for running tests is `1.7`.

Add the following to your top-level build file:

Expand Down Expand Up @@ -121,6 +122,8 @@ It is in its infancy, it is recommended to use it only for test or pet projects.
Refer to the [documentation](https://kotlin.github.io/kotlinx-kover/gradle-plugin/aggregated.html) for details.

## Kover Maven Plugin
Minimum Maven version for Maven plugin is `3.0`

The Kover Maven Plugin can be applied by specifying build plugin
```xml
<plugin>
Expand All @@ -132,10 +135,12 @@ The Kover Maven Plugin can be applied by specifying build plugin

The list of Kover goals is specified in [this document section](https://kotlin.github.io/kotlinx-kover/maven-plugin#goals).

For full information about latest stable release of Kover Maven Plugin, please refer to the [documentation](https://kotlin.github.io/kotlinx-kover/maven-plugin).
For full information about the latest stable release of Kover Maven Plugin, please refer to the [documentation](https://kotlin.github.io/kotlinx-kover/maven-plugin).


## Kover CLI
Minimum version of JVM is `1.8`.

Standalone JVM application used for offline instrumentation and generation of human-readable reports.

[Documentation of the Kover CLI](https://kotlin.github.io/kotlinx-kover/cli).
Expand All @@ -146,11 +151,16 @@ Offline instrumentation is the modification of class-files stored on disk to mea
The ways of offline instrumentation and running of the instrumented applications are described in the [documentation](https://kotlin.github.io/kotlinx-kover/offline-instrumentation).

## Kover JVM agent
Minimum version of JVM is `1.7`.

JVM agent is a jar file that modifies the bytecode of loaded into the JVM classes in order to measure coverage.
[Documentations](https://kotlin.github.io/kotlinx-kover/jvm-agent).

## Kover features artifact
A JVM dependency that allows to programmatically instrument class-files on a disk.
Minimum version of JVM is `1.8`.
Minimum version of Kotlin is `1.8.0`.

A JVM dependency that allows programmatically instrument class-files on a disk.

[Documentation of Kover features artifact](https://kotlin.github.io/kotlinx-kover/offline-instrumentation/#instrumentation-by-kover-features)

Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[versions]

intellij-coverage = "1.0.765"
junit = "5.9.0"
junit = "5.13.4"
kotlinx-bcv = "0.13.2"
kotlinx-dokka = "1.8.10"
kotlinx-dokka = "2.0.0"
args4j = "2.33"
gradle-plugin-publish = "1.2.1"
maven-plugin-development = "0.4.3"
maven-plugin-development = "1.0.3"
maven-embedder = "3.9.8"
maven-api = "3.0"
maven-resolver = "1.9.21"
Expand Down Expand Up @@ -47,5 +47,5 @@ jacoco-reporter = {module = "org.jacoco:org.jacoco.report", version.ref = "jacoc
gradle-pluginPublish = { id = "com.gradle.plugin-publish", version.ref = "gradle-plugin-publish" }
kotlinx-binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "kotlinx-bcv" }
kotlinx-dokka = { id = "org.jetbrains.dokka", version.ref = "kotlinx-dokka" }
mavenPluginDevelopment = { id = "de.benediktritter.maven-plugin-development", version.ref = "maven-plugin-development" }
mavenPluginDevelopment = { id = "org.gradlex.maven-plugin-development", version.ref = "maven-plugin-development" }

Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
9 changes: 3 additions & 6 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -114,7 +114,6 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
Expand Down Expand Up @@ -172,7 +171,6 @@ fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )

JAVACMD=$( cygpath --unix "$JAVACMD" )

Expand Down Expand Up @@ -205,15 +203,14 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"

# Stop when "xargs" is not available.
Expand Down
3 changes: 1 addition & 2 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ goto fail
:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
4 changes: 2 additions & 2 deletions kover-features-jvm/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ afterEvaluate {
compilerOptions {
allWarningsAsErrors = true
jvmTarget = JvmTarget.JVM_1_8
languageVersion = KotlinVersion.KOTLIN_1_5
apiVersion = KotlinVersion.KOTLIN_1_5
languageVersion = KotlinVersion.KOTLIN_1_8
apiVersion = KotlinVersion.KOTLIN_1_8
freeCompilerArgs.addAll("-Xsuppress-version-warnings")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't use also specify -Xjdk-release to avoid accidentally using API from higher JDKs?
(although you probably already has this covered by toolchain)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, output bytecode version is controlled by toolchain version

}
}
Expand Down
10 changes: 5 additions & 5 deletions kover-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dependencies {
functionalTestImplementation(kotlin("test"))
functionalTestImplementation(libs.junit.jupiter)
functionalTestImplementation(libs.junit.params)
"functionalTestRuntimeOnly"("org.junit.platform:junit-platform-launcher")

snapshotRelease(projects.koverFeaturesJvm)
snapshotRelease(projects.koverJvmAgent)
Expand All @@ -60,7 +61,6 @@ dependencies {
functionalTestImplementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$embeddedKotlinVersion")
functionalTestImplementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:$embeddedKotlinVersion")
functionalTestImplementation("org.jetbrains.kotlin:kotlin-compiler-runner:$embeddedKotlinVersion")

}

kotlin {
Expand Down Expand Up @@ -163,8 +163,8 @@ afterEvaluate {
compilerOptions {
allWarningsAsErrors = true
jvmTarget = JvmTarget.JVM_1_8
languageVersion = KotlinVersion.KOTLIN_1_5
apiVersion = KotlinVersion.KOTLIN_1_5
languageVersion = KotlinVersion.KOTLIN_1_8
apiVersion = KotlinVersion.KOTLIN_1_8
freeCompilerArgs.add("-Xsuppress-version-warnings")
}
}
Expand All @@ -183,8 +183,8 @@ tasks.dokkaHtml {
skipDeprecated = true
}
sourceLink {
localDirectory = rootDir
remoteUrl = URL("https://github.com/kotlin/kotlinx-kover/tree/main")
localDirectory.set(file(rootDir))
remoteUrl.set(URL("https://github.com/kotlin/kotlinx-kover/tree/main"))
remoteLineSuffix = "#L"
}
}
Expand Down
6 changes: 3 additions & 3 deletions kover-gradle-plugin/examples/android/dynamic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id("com.android.application") version "7.4.0" apply false
id("com.android.library") version "7.4.0" apply false
id("com.android.application") version "8.12.0" apply false
id("com.android.library") version "8.12.0" apply false
id ("com.android.dynamic-feature") version "7.4.0" apply false
id("org.jetbrains.kotlin.android") version "1.8.20" apply false
id("org.jetbrains.kotlin.android") version "2.2.20" apply false
id("org.jetbrains.kotlinx.kover") version "0.9.2" apply false
}
6 changes: 3 additions & 3 deletions kover-gradle-plugin/examples/android/flavors/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("com.android.application") version "7.4.0" apply false
id("com.android.library") version "7.4.0" apply false
id("org.jetbrains.kotlin.android") version "1.8.20" apply false
id("com.android.application") version "8.12.0" apply false
id("com.android.library") version "8.12.0" apply false
id("org.jetbrains.kotlin.android") version "2.2.20" apply false
id("org.jetbrains.kotlinx.kover") version "0.9.2" apply false
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
defaultConfig {
applicationId "kotlinx.kover.test.android"
minSdk 21
targetSdk 31
targetSdk 33
versionCode 1
versionName "1.0"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'com.android.application' version '7.4.0' apply false
id 'com.android.library' version '7.4.0' apply false
id 'org.jetbrains.kotlin.android' version '1.8.20' apply false
id 'com.android.application' version '8.12.0' apply false
id 'com.android.library' version '8.12.0' apply false
id 'org.jetbrains.kotlin.android' version '2.2.20' apply false
id 'org.jetbrains.kotlinx.kover' version '0.9.2' apply false
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
defaultConfig {
applicationId = "kotlinx.kover.test.android"
minSdk = 21
targetSdk = 31
targetSdk = 33
versionCode = 1
versionName = "1.0"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("com.android.application") version "7.4.0" apply false
id("com.android.library") version "7.4.0" apply false
id("org.jetbrains.kotlin.android") version "1.8.20" apply false
id("com.android.application") version "8.12.0" apply false
id("com.android.library") version "8.12.0" apply false
id("org.jetbrains.kotlin.android") version "2.2.20" apply false
id("org.jetbrains.kotlinx.kover") version "0.9.2" apply false
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ android {
isMinifyEnabled = true
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -37,11 +38,11 @@ dependencies {
implementation("androidx.appcompat:appcompat:1.5.0")
implementation("com.google.android.material:material:1.6.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
testImplementation("junit:junit:4.13.2")
commonTestImplementation("junit:junit:4.13.2")
}

kotlin {
android()
androidTarget()

jvm() {
testRuns["test"].executionTask.configure {
Expand Down Expand Up @@ -78,13 +79,12 @@ kover {

currentProject {
createVariant("custom") {

add("jvm")
/**
* Tests, sources, classes, and compilation tasks of the 'debug' build variant will be included in the report variant `custom`.
* Thus, information from the 'debug' variant will be included in the `custom` report for this project and any project that specifies this project as a dependency.
* Take coverage from this project and any project specified by `kover(project("..."))` dependency
*/
addWithDependencies("debug")
addWithDependencies("jvm")

add("debug")
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kotlinx.kover.test.android

import kotlinx.kover.test.android.Maths
import org.junit.Test

import org.junit.Assert.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id("com.android.application") version "7.4.0" apply false
id("com.android.library") version "7.4.0" apply false
kotlin("multiplatform") version ("1.8.20") apply false
id("com.android.application") version "8.12.0" apply false
id("com.android.kotlin.multiplatform.library") version "8.12.0" apply false
kotlin("multiplatform") version ("2.2.20") apply false
id("org.jetbrains.kotlinx.kover") version "0.9.2"
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,34 @@
plugins {
id ("com.android.library")
id("com.android.kotlin.multiplatform.library")
kotlin("multiplatform")
id ("org.jetbrains.kotlinx.kover")
}

android {
namespace = "kotlinx.kover.test.android"

compileSdk = 32

defaultConfig {
minSdk = 21

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
isMinifyEnabled = true
kotlin {
androidLibrary {
namespace = "kotlinx.kover.test.android"
compileSdk = 33
minSdk = 24

withJava()
withDeviceTestBuilder {
sourceSetTreeName = "test"
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

withHostTest { }
}
}

kotlin {
jvmToolchain(8)
android()
}

dependencies {
implementation("androidx.core:core-ktx:1.8.0")
implementation("androidx.appcompat:appcompat:1.5.0")
testImplementation("junit:junit:4.13.2")
commonTestImplementation("junit:junit:4.13.2")
}

kover {

kover {
currentProject {
createVariant("custom") { }
createVariant("custom") {
add("jvm")
}
}
}

This file was deleted.

Loading