Custom plugin that extends external plugin

Is it possible to extend a task defined in an external plugin, within a custom plugin?

I am moving my common build logic into a gradle plugin for my organization.

In a few projects, I have implemented the same task:

task jsExternalLibs(type:MinifyJsTask) {
    doLast {
         //same code in each project
    }
}

I would like to move this to the custom plugin I am building. How can I extend the MinifyJsTask from “com.eriwen.gradle.js” in my custom plugin?

Tasks are plain old Java classes. You can literally just extend that class with your own and add the logic you want to it.

I thought so…

My problem was that I needed to add “https://plugins.gradle.org/m2/” to the
repositories block, then add the plugin to the compile dependencies

Thanks!