Skip to content

Latest commit

 

History

History
47 lines (39 loc) · 1.71 KB

README.md

File metadata and controls

47 lines (39 loc) · 1.71 KB

Gloc

A Gradle Plugin which counts the lines of code in given directories.

Droidcon Italy 18:
I gave a talk at the Droidcon Italy 18 in Turin where I used that Plugin as an example to demonstrate how to write a Gradle Plugin. Slides of my Talk are available at Speaker Deck.

How to use

As the Plugin isn't published anywhere you have to do so first. For "manual testing" you can simply push it to your local maven repo. Just call:

./gradlew clean build publishToMavenLocal

After that you are able to use/apply that plugin (even in this project) like this:

// settings.gradle.kts
pluginManagement {
  repositories {
    gradlePluginPortal()
    mavenLocal()
  }
}

// build.gradke.kts
plugins {
  id("guru.stefma.gloc") version "0.0.1"
}

gloc {
  enabled = true
  dirs = arrayOf("src/main", "src/test")
}

Extension configuration

The extension provide two properties:

  • enabled - which will enable or disable the plugin
  • dirs - a array of file pathes which defines where to count the lines of code

Task

The plugin provides the task called gloc.
If you can run it for the first time it will - well - run and SUCCESS. Meaning the task was executed.

If you run it for the second time - without cleaning the buid/ dir and changing the input (the dirs property) - it will be UP-TO-DATE.

Running it with the Gradle build cache enabled it wil be - if you run it the second time - use the output from the cache. The output should be FROM-CACHE