How to put a task into a custom plugin


(Thomas Lee) #1

In the build.gradle, I have a task to publish the zip file like this. And now I want to put into the custom plugin. But I have no idea how to set the default action for this task.

apply plugin:“maven-publish”;

//to package the file

task packageFile(type: Zip) {

description “Package the source into zip file”

from “src”

}

publishing {

publications {

maven(MavenPublication) {

artifact packageFile

}

}

}

What should I write inside my groovyPlugin? I want to use as a default task, so no need to copy so many times.

Thanks.

@Override

public void apply(Project project) {

project.plugins.apply(“maven-publish”);

project.task[“publishing”].artifact = …?

}


(Thomas Lee) #2

I have figured out the way. Thanks


(Carlo Luib-Finetti) #3

Not a good way to close a problem. Do not forget: you ask, but other people listen and learn from questions and answers! Cheers