Skip to content

Setup

To set up the plugin in your project, follow the below instructions:

Step 1

Make sure your project uses Git VCS and Gradle version 6.1+.

Gradle Analytics Plugin uses Git terminal to get the branch names and latest HEAD commit hash. so It is required for your project to use Git VCS.



Step 2

Apply the Gradle Plugin to the root of your project.

plugins {
    id("io.github.janbarari.gradle-analytics-plugin") version "1.0.0-beta6"
}
plugins {
    id 'io.github.janbarari.gradle-analytics-plugin' version '1.0.0-beta6'
}

For legacy plugin application, see the Gradle Plugin Portal.

Step 3

Add plugin configuration in the root of your project.

gradleAnalyticsPlugin {
    isEnabled = true // By default it's True.

    database {
        local = sqlite {
            path = "DATABASE_PATH"
            name = "DATABASE_NAME" // Don't add `.db` in the database name.
            user = "DATABASE_USER" // Remove `user` if you want the plugin to create the DB.
            password = "DATABASE_PASSWORD" // Remove `password` if you want the plugin to create the DB.
        }
        ci = mysql {
            host = "MYSQL_DATABASE_HOST"
            name = "MYSQL_DATABASE_NAME"
            user = "MYSQL_DATABASE_USER"
            password = "MYSQL_DATABASE_PASSWORD"
            port = MYSQL_DATABASE_PORT // Default is 3306
        }
    }

    trackingTasks = listOf(
        // Add your requested tasks to be analyzed, Example:
        ":app:assembleDebug"
    )

    trackingBranches = listOf(
        // requested tasks only analyzed in the branches you add here, Example:
        "master",
        "develop"
    )

    isTrackAllBranchesEnabled = false // Default is false

    outputPath = "OUTPUT_REPORT_PATH"
}
gradleAnalyticsPlugin {
    isEnabled = true // By default it's True.

    database {
        local = sqlite {
            path = 'DATABASE_PATH'
            name = 'DATABASE_NAME' // Don't add `.db` in the database name.
            user = 'DATABASE_USER' // Remove `user` if you want the plugin to create the DB.
            password = 'DATABASE_PASSWORD' // Remove `password` if you want the plugin to create the DB.
        }
        ci = mysql {
            host = 'MYSQL_DATABASE_HOST'
            name = 'MYSQL_DATABASE_NAME'
            user = 'MYSQL_DATABASE_USER'
            password = 'MYSQL_DATABASE_PASSWORD'
            port = MYSQL_DATABASE_PORT // Default is 3306
        }
    }

    trackingTasks = [
        // Add your requested tasks to be analyzed, Example:
        ':app:assembleDebug'
    ]

    trackingBranches = [
        // requested tasks only analyzed in the branches you add here, Example:
        'master',
        'develop'
    ]

    isTrackAllBranchesEnabled = false // Default is false

    outputPath = 'OUTPUT_REPORT_PATH'
}


Important Notes

  • The plugin will create one automatically if there isn't an SQLite database. You only need to fill in the name and path (Recommended).
  • Both sqlite / mysql can be used to config local or ci databases.
  • Both local and ci configs are optional.
  • If using the plugin in your CI/CD make sure the CI=true environment variable exists in your CI system environments and the ci database is configured.
  • The outputPath can be skipped, it will generate the report inside the project build directory.
  • By enabling isTrackAllBranchesEnabled analytics will be kicked on all branches.
  • isEnabled and isTrackAllBranchesEnabled are not mandatory since they have default values.