com.netflix.gradle.plugins.docker.OsPackageDockerBasePlugin.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-ospackage-plugin Show documentation
Show all versions of gradle-ospackage-plugin Show documentation
Provides a task similar to Tar and Zip for constructing RPM and DEB package files.
package com.netflix.gradle.plugins.docker
import com.bmuschko.gradle.docker.DockerRemoteApiPlugin
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.netflix.gradle.plugins.packaging.CommonPackagingPlugin
import com.netflix.gradle.plugins.rpm.Rpm
import com.netflix.gradle.plugins.rpm.RpmPlugin
import groovy.transform.CompileDynamic
import org.gradle.api.Action
import org.gradle.api.Plugin
import org.gradle.api.Project
@CompileDynamic
class OsPackageDockerBasePlugin implements Plugin {
static final String CREATE_DOCKERFILE_TASK_NAME = 'createDockerfile'
static final String BUILD_IMAGE_TASK_NAME = 'buildImage'
static final String AGGREGATION_TASK_NAME = 'buildDocker'
@Override
void apply(Project project) {
project.plugins.apply(CommonPackagingPlugin)
// Some defaults, if not set by the user
project.tasks.withType(SystemPackageDockerfile).configureEach(new Action() {
@Override
void execute(SystemPackageDockerfile systemPackageDockerfile) {
systemPackageDockerfile.applyConventions()
}
})
project.plugins.withType(DockerRemoteApiPlugin).configureEach(new Action() {
@Override
void execute(DockerRemoteApiPlugin dockerRemoteApiPlugin) {
createTasks(project)
}
})
}
private void createTasks(Project project) {
SystemPackageDockerfile createDockerfileTask = project.task(CREATE_DOCKERFILE_TASK_NAME, type: SystemPackageDockerfile)
DockerBuildImage buildImageTask = project.task(BUILD_IMAGE_TASK_NAME, type: DockerBuildImage) {
dependsOn createDockerfileTask
conventionMapping.inputDir = { createDockerfileTask.destinationDir }
}
project.task(AGGREGATION_TASK_NAME) {
dependsOn buildImageTask
}
}
}