cdsap / Talaiot

Simple and extensible plugin to track task times in your Gradle Project.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Version 1.4 questions

MyDogTom opened this issue · comments

I'm still catching up with all changes made in last months. I'll write here my findings / questions as soon as I notice them. Just in case they make sense to you.

Plugin dependencies

Readme has classpath ""com.cdsap.talaiot.plugin:base:1.4.0"" . According to Gradle portal it should be com.cdsap.talaiot.plugin:base-plugin:1.4.0.

The same for InfluxDb and others.

I can open a PR and fix readme when I manage to properly setup 1.4.0 in my project.

Overall setup

In my project I have an included build where I create some custom metrics. I also create a plugin that applies Talaiot plugin and performs all configuration.

previously I declared a dependency implementation("com.cdsap:talaiot:1.3.5") and had a custom metric like that:

import com.cdsap.talaiot.metrics.base.GradleMetric

class ProjectFolderMetric : GradleMetric<String>(
    provider = { it.rootDir.absolutePath },
    assigner = { report, value -> report.customProperties.buildProperties["projectFolder"] = value }

)

After changing to implementation("com.cdsap:talaiot:1.4.0"), GradleMetric cannot be found anymore. I couldn't find an explanation so far. GradleMetric seems to be under the same package.

Update 1

I had to change dependency to implementation("com.cdsap.talaiot:talaiot:1.4.0"). Is that expected? Should we include this in readme too?

Update 2

I ended up having these dependencies

    implementation("com.cdsap.talaiot:talaiot:1.4.0")
    implementation("com.cdsap.talaiot.plugin:base-plugin:1.4.0")
    implementation("com.cdsap.talaiot.plugin:influxdb-plugin:1.4.0")

My plugin code looks like that now

        project.extensions.configure(InfluxdbExtension::class.java) { talaiotExtension ->
            talaiotExtension.metrics {
                gitMetrics = false
                customMetrics(
                    ProjectFolderMetric(),
                    AndroidStudioMetric()
                )
            }

            talaiotExtension.publishers {
                if (this is InfluxdbConfiguration) {
                    influxDbPublisher {
                        dbName = targetDatabase
                        url = "...."
                        taskMetricName = "task"
                        buildMetricName = "build"
                        publishTaskMetrics = true
                    }
                }
            }
            talaiotExtension.filter {
                build {
                    success = true
                    requestedTasks {
                        excludes = arrayOf("....")
                    }
                }
            }
            talaiotExtension.ignoreWhen {
                envName = PROPERTY_IGNORE_STATS_PUBLISHING
                envValue = "true"
            }
        }

still it fails because InfluxDbPublisherConfiguration cannot be found. I suspect it's because influxdb-plugin has implementation dependency on influxdb-publisher. I think it should have api dependency because InfluxDbPublisherConfiguration is a part of InfluxdbConfiguration api.

Could it be the case?

Thanks for the testing, and don't worry I think sometimes during those times is hard to have the available time like before pandemic.

Plugin dependencies
You're totally right. When I was testing the plugins, they were pointing to the snapshot repository and the maven configuration was including the correct artifactId defined in the configuration of the plugin. Once the Plugins were deployed to the plugin portal the coordinates of the maven object were matching the project id. I saw it for Talaiot(talaiot/talaiot-standard). I was able to fix it but not put attention on the other plugins.

Overall setup
The project has been separated in different components in three main layers:
Screen Shot 2020-11-18 at 8 06 47 PM
(Base is the core part)

This allows to have more flexible approach on how you want to use the library and separating the core functionality, every single component is deployed to jcenter except the plugins that are deployed to Gradle Portal.
To have the compatibility with the old plugin we have kept the coordinates: com.cdsap:talaiot:xxx for the plugin that contains all the information...

The dependency implementation("com.cdsap.talaiot:talaiot:1.4.0" corresponds with the core functionality of the library without publishers and plugins.
Analyzing your case I tried to reproduce:
1- Add Talaiot plugin in main build.gradle.kts:

plugins {
    id("com.cdsap.talaiot") version "1.4.0"
}

2- Add in the module the specific conf:

import com.cdsap.talaiot.metrics.base.GradleMetric

plugins {
    java
    id("com.cdsap.talaiot")
}

class ProjectFolderMetric : GradleMetric<String>(
    provider = { it.rootDir.absolutePath },
    assigner = { report, value -> report.customProperties.buildProperties["projectFolder"] = value }
)

talaiot {
    publishers {
        jsonPublisher = true
        influxDbPublisher {
            dbName = "tracking"
            url = "http://localhost:8086"
            taskMetricName = "task"
            buildMetricName = "build"
        }
    }
    logger = com.cdsap.talaiot.logger.LogTracker.Mode.INFO
    metrics {
        gitMetrics = false
        customMetrics(
            ProjectFolderMetric()
        )
    }
}

I added your ProjectFolder and added to jsonPublisher to evaluate the result. Once is executed a simple tasks execution for the given module we have for the json publisher:

  "customProperties": {
    "buildProperties": {
      "projectFolder": "/Users/inakivillar/AndroidStudioProjects/MyApplication10"
    },
    "taskProperties": {}

and for influxdb:

[InfluxDbPublisher]: Sending points to InfluxDb server BatchPoints [..projectFolder=/Users/inakivillar/AndroidStudioProjects/]

I didn't include any extra configuration and looks working correctly but I'm using the plugin in the classpath of the build.
Can you give me more details how you're including the dependencies? I see you are using implementation but in your case Talaiot is a build classpath dependency or dependency for a runtime/compile configuration?

Summary

  • I'm going still to freeze the release and if is required remove the wrong id plugins. For that I created this issue #257. I will work on this issue now.
  • Please, how are you including the project and I will investigate it.

Again thanks

Just an additional note, we have updated this week to Gradle 6.7.1/Talaiot 1.4.0 in the company and at the moment we are reporting/working ok.
One of the changes in our custom implementation(we are injecting different Talaiot configurations depending on the environment) was:
Screen Shot 2020-11-18 at 8 54 01 PM

I have found the problem with the artifact id for the legacy plugin system of the different plugins.
Now I need to work in the second problem.

I'm closing this issue because I was able properly setup new version (see conversation in #258)