Skip to content

santaevpavel/gradle-metrics-plugin

Repository files navigation

gradle-metrics-plugin

tests

This plugin allows to collect build metrics (like build time, tasks, etc) and dispatch to different sources.

Also the plugin provides API to implement your own collectors and dispatchers.

Terminal

Usage

Add Github repository and classpath

buildscript {
    repositories {
        // ...
        maven {
            url = uri("https://maven.pkg.github.com/santaevpavel/gradle-metrics-plugin")
            credentials {
                username = "YOUR USERNAME"
                password = "GITHUB TOKEN"
            }
        }
    }
    // ...
    dependencies {
        classpath "io.github.santaevpavel.gradle-metrics-plugin:gradle-metrics-plugin:1.0.0"
    }
}

Apply plugin

apply plugin: 'io.github.santaevpavel.gradle-metrics-plugin'

Configure plugin

metrics {
    collectors {
        Build
        TaskNames
        TasksCount
        ProjectProperties
    }
    dispatchers {
        ConsoleDispatcher
    }
}

Collectors and dispatchers

Built-in collectors

  1. Build time
  2. Build result
  3. Task name
  4. Tasks count
  5. Project name
  6. Root project name
  7. File size
  8. Unit test results

Built-in dispatchers

  1. Console
  2. File

Extension

Amplitude dispatcher

This extension allows to send build metrics to Amplitude.

AmplitudeChart

How to setup

  1. Add Github maven repository.
buildscript {
    repositories {
        // ...
        maven {
            url = uri("https://maven.pkg.github.com/santaevpavel/gradle-metrics-plugin")
            credentials {
                username = "YOUR USERNAME"
                password = "GITHUB TOKEN"
            }
        }
    }
    // ...
}

Add Github properties to local.properties

  1. Add dependency
dependencies {
    // ...
    gradleMetricsPluginExtension "io.github.santaevpavel.gradle-metrics-plugin:amplitude-extension:1.0.0"
}
  1. Configure amplitude extension
metrics {
    collectors {
        // ...
    }
    dispatchers {
        // ...
        AmplitudeDispatcher {
            apiKey = "AMPLITUDE API KEY"
        }
    }
}

How to test?

There is sample project that includes this plugin and core extensions. Test project requires plugin and extensions dependency in build/repo directory. To publish dependencies to local repo (build/repo) you need to run ./publishLocal.sh.

Then run command sample:jar to check plugin out.

About

Experimental gradle plugin to fetch and save metrics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages