Coder Social home page Coder Social logo

surpsg / offlins-gradle-plugin Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 1.0 258 KB

JaCoCo Gradle plugin

License: MIT License

Kotlin 86.44% Java 13.56%
coverage gradle gradle-plugin jacoco jacoco-offline-instrumentation jacoco-plugin jacoco-reports powermock

offlins-gradle-plugin's Introduction

offlins-gradle-plugin

Gradle Plugin Portal Main branch codecov GitHub issues GitHub stars

Offlins is similar to standard Gradle JaCoCo plugin but uses JaCoCo tool in offline instrumentation mode. This plugin is useful if PowerMock is used in tests.

Compatibility

Compatibility table:

Offlins plugin Gradle
0.3.0 6.1 - 8.+
0.2.1.+ 5.1 - 7.6.+

Installation

The plugin is published to Gradle plugins.

Groovy
plugins {
    id "io.github.surpsg.offlins" version "0.3.0"
}
Kotlin
plugins {
    id("io.github.surpsg.offlins") version "0.3.0"
}

Configuration

All properties are optional but have the following defaults:

  • JaCoCo version 0.8.8
  • HTML report is enabled with dafault path build/reports/jacoco/html
  • XML report is disabled with dafault path build/reports/jacoco/coverageReport.xml
  • CSV report is disabled with dafault path build/reports/jacoco/coverageReport.csv
Groovy
offlinsCoverage {
    jacocoVersion = '0.8.7' // Optional. By default `0.8.8`

    reports {
        html.enabled.set true // Optional. By default `true`
        html.location.set project.file('build/custom/html') // Optional. By default `build/reports/jacoco/html`

        xml.enabled.set true // Optional. By default `false`
        xml.location.set project.file('build/custom/xmlCoverage.xml')
        // Optional. By default `build/reports/jacoco/coverageReport.xml`

        csv.enabled.set true // Optional. By default `false`
        csv.location.set project.file('build/custom/csvCoverage.csv')
        // Optional. By default `build/reports/jacoco/coverageReport.csv`    
    }
}
Kotlin
configure<io.github.surpsg.offlins.OfflinsExtension> {
    jacocoVersion = "0.8.7" // Optional. By default `0.8.8`

    reports {
        html.enabled.set(true) // Optional. By default `true`
        html.location.set(project.file("build/custom/html")) // Optional. By default `build/reports/jacoco/html`

        xml.enabled.set(true) // Optional. By default `false`
        xml.location.set(project.file("build/custom/xmlCoverage.xml")) // Optional. By default `build/reports/jacoco/coverageReport.xml`

        csv.enabled.set(true) // Optional. By default `false`
        csv.location.set(project.file("build/custom/csvCoverage.csv")) // Optional. By default `build/reports/jacoco/coverageReport.csv`    
    }
}

Excecute

Run tests by task test and generate reports by taks coverageReport:

 ./gradlew test coverageReport

Tasks description

  • instrumentClassesOffline - instruments .class files
    • Inputs: class files generated by classes task
    • Outputs: instrumented classes in build/classes-instrumented
    • Depends on classes task
  • assembleInstrumentedJar - generates jar file from instrumented classes
    • Inputs: insrumented class files generated by instrumentClassesOffline task
    • Outputs: jar file classes in libs/<project-name>-instrumented.jar
    • Depends on instrumentClassesOffline task
  • coverageReport - generates coverage reports
    • Inputs: .exec file generated by test task
    • Outputs: HTML, XML, CSV reports(depends on plugin configuration)

Offlins plugin modifies default test task from Java plugin:

  • Sets the test task to dependend on instrumentClassesOffline
  • Adds org.jacoco:org.jacoco.agent artifact to classpath
  • Replaces a project .class files with instrumented classes in classpath
  • Replaces jars(dependecies on subprojects) with instrumented jars in classpath

offlins-gradle-plugin's People

Contributors

surpsg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

daifalin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.