From e46978427ab1c72a10773b56e1942f98fa0a89d9 Mon Sep 17 00:00:00 2001 From: Svyatoslav Chatchenko Date: Sat, 21 Mar 2020 14:49:24 +0100 Subject: [PATCH] Add two custom metrics: ProjectFolderMetric and AndroidStudioMetric --- build.gradle | 4 ++++ buildSrc/.gitignore | 1 + buildSrc/build.gradle | 13 +++++++++++++ .../com/github/mydogtom/talaiot/CustomMetric.kt | 17 +++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 buildSrc/.gitignore create mode 100644 buildSrc/build.gradle create mode 100644 buildSrc/src/main/kotlin/com/github/mydogtom/talaiot/CustomMetric.kt diff --git a/build.gradle b/build.gradle index 1426c64..13ac2b9 100644 --- a/build.gradle +++ b/build.gradle @@ -19,10 +19,14 @@ buildscript { apply plugin: 'com.cdsap.talaiot' import com.cdsap.talaiot.metrics.GitBranchMetric +import com.github.mydogtom.talaiot.ProjectFolderMetric +import com.github.mydogtom.talaiot.AndroidStudioMetric talaiot { metrics.default() metrics.performance() metrics.metrics.add(new GitBranchMetric()) + metrics.metrics.add(new ProjectFolderMetric()) + metrics.metrics.add(new AndroidStudioMetric()) publishers { jsonPublisher = true diff --git a/buildSrc/.gitignore b/buildSrc/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/buildSrc/.gitignore @@ -0,0 +1 @@ +/build diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 0000000..1f56e63 --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,13 @@ +plugins { + id 'org.jetbrains.kotlin.jvm' version '1.3.70' +} + +repositories { + maven { url "https://plugins.gradle.org/m2/" } + jcenter() + mavenLocal() +} + +dependencies { + implementation "com.cdsap:talaiot:1.2.0" +} diff --git a/buildSrc/src/main/kotlin/com/github/mydogtom/talaiot/CustomMetric.kt b/buildSrc/src/main/kotlin/com/github/mydogtom/talaiot/CustomMetric.kt new file mode 100644 index 0000000..655acbd --- /dev/null +++ b/buildSrc/src/main/kotlin/com/github/mydogtom/talaiot/CustomMetric.kt @@ -0,0 +1,17 @@ +package com.github.mydogtom.talaiot + +import com.cdsap.talaiot.metrics.base.GradleMetric + +class ProjectFolderMetric : GradleMetric( + provider = { it.rootDir.absolutePath }, + assigner = { report, value -> report.customProperties.buildProperties["projectFolder"] = value } +) + +private const val KEY_ANDROID_STUDIO = "android.injected.invoked.from.ide" + +class AndroidStudioMetric : GradleMetric( + provider = { it.gradle.rootProject.hasProperty(KEY_ANDROID_STUDIO).toString() }, + assigner = { report, value -> + report.customProperties.buildProperties["fromAndroidStudio"] = value + } +)