Configuring com.palantir.docker tag at Execution Phase

From NovaOrdis Knowledge Base
Revision as of 03:05, 11 November 2020 by Ovidiu (talk | contribs) (→‎Overview)
Jump to navigation Jump to search

Internal

Overview

This is an example of a custom task that configures the Docker image tag at execution phase. Normally, DockerExtension configuration elements can be configured in build.gradle only at configuration phase. If any of the configuration elements, such as the tag, must be computed dynamically at execution phase, as result of another task execution, it could be done by pulling the DockerExtension instance and invoking the corresponding setter, as shown below.

Identify the Plugin Library

The plugin is declared as follows in a regular sub-project build.gradle:

plugins {
    // some 'com.palantir.docker' plugin classes are used by this project's Gradle extensions,
    // defined in buildSrc, so plugin libraries are declared as buildSrc dependencies, and the 
    // plugin version is defined there. See buildSrc/build.gradle.
    id "com.palantir.docker"
}

Configure buildSrc build.gradle