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.3"
}
plugins {
id 'io.github.janbarari.gradle-analytics-plugin' version '1.0.3'
}
For legacy plugin application, see the Gradle Plugin Portal.
Step 3
Add plugin configuration in the root of your project.
gradleAnalyticsPlugin {
enabled = true // Optional: 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 // Optional: Default is 3306.
}
}
trackingTasks = setOf(
// Add your requested tasks to be analyzed, Example:
":app:assembleDebug",
":jar",
":assemble"
)
trackingBranches = setOf(
// requested tasks only analyzed in the branches you add here, Example:
"master",
"develop"
)
// Optional: Exclude modules that are not necessary like test or demo modules
excludeModules = setOf()
trackAllBranchesEnabled = false // Optional: Default is False.
outputPath = "OUTPUT_REPORT_PATH" // Optional: Default is project /build/ dir.
}
gradleAnalyticsPlugin {
enabled = true // Optional: 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 // Optional: Default is 3306.
}
}
trackingTasks = [
// Add your requested tasks to be analyzed, Example:
':app:assembleDebug',
':jar',
':assemble'
]
trackingBranches = [
// requested tasks only analyzed in the branches you add here, Example:
'master',
'develop'
]
// Optional: Exclude modules that are not necessary like test or demo modules
excludeModules = []
trackAllBranchesEnabled = false // Optional: Default is False.
outputPath = 'OUTPUT_REPORT_PATH' // Optional: Default is project /build/ dir.
}
Important Notes
- The plugin will create one automatically if there isn't an SQLite database. You only need to fill in the
name
andpath
(Recommended). - All
sqlite / mysql / postgres
can be used to configlocal
orci
databases. - Both
local
andci
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 theci
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
andisTrackAllBranchesEnabled
are not mandatory since they have default values.