Transmode / gradle-docker

A Gradle plugin to build Docker images from the build script.
Apache License 2.0
647 stars 142 forks source link

How to extend the gradle plugin functionality? How to make reference to a external plugin from Myplugin.groovy? #111

Closed jorgeluengo closed 7 years ago

jorgeluengo commented 7 years ago

If I try to use this plugin and I create a new standalone plugin from there, implementing the new functionality into src/main/groovy/gradle/plugins/MyNewplugin.groovy I'm not able to make reference to it in order to load its functionality and extend it.

I tried different ways to do it, but it did not allow me to reach my goal.

E.g. :

I added "project.task('BuildDocker',type: Docker)" into MyNewPlugin.groovy and I can build it "gradle build" but when this plugin is called from another place is not able to resolve the 'Docker' type. Any idea?

jorgeluengo commented 7 years ago

It was my mistake, the right way is: MyPlugin.groovy:

import se.transmode.gradle.plugins.docker.DockerTask

class MyPlugin implements Plugin<Project> {
    void apply(Project project) {
        project.plugins.apply('docker')
        project.task("MyTask", type: DockerTask){ ...