GRIP (Gradle Replace In-Place)

A gradle tool to update some values in your (documentation) files by running a task.

(inspired by Knit)

Directives

Insert a gradle properties: GRADLE_PROPERTIES

<!--$ GRADLE_PROPERTIES version --><!-- END $-->

Take 1 parameter that must be the name of the gradle properties on your project.

Insert a system environment variable: SYSTEM_ENV

<!--$ SYSTEM_ENV LOGNAME --><!-- END $-->

Take 1 parameter that must be the name of one of the environment variable on the computer running grip.

Insert a local file

<!--$ INSERT src/commonMain/kotlin/com/glureau/grip/sample/doc.md --><!-- END $-->

Take 1 parameter that uses the gradle file pattern.

For example, the previous INSERT could be extended to:

<!--$ INSERT src/**/sample/*.md --><!-- END $-->

Insert a date/time: DATETIME

<!--$ DATETIME yyyy.MM.dd G 'at' HH:mm:ss z --><!-- END $-->

Take 1 parameter that represents the formatting of the current time (Calendar.getInstance()).

Setup

plugins {
    id("com.glureau.grip") version "0.2.0"
}

Then you can add additional configuration, with:

grip {
    // When replaceInPlace is false, the files are processed and the resulting file is stored in build/grip
    replaceInPlace = false

    // Choose the files that grip should process
    files = fileTree(project.projectDir) {
        // By default, we pick only markdowns on the src directory, but there is really no limitation
        include("**/**.md")
        // Avoid re-loading the generated files
        exclude("**/grip/**")
    }
}

File types support

Currently the replacement token is made for Markdown and tools like mkdocs or dokka as it’s considering a web comment format.

If you want to use the same plugin on other type of files, please open an issue with your needs!

GitHub

View Github