How to add a new task type via a custom plugin?

(Urs Reupke) #1

I’m trying to extend Andrew Oberstar’s git plugin for gradle with a “tag” command. I have written a new DefaultClass to this end, and installed the result[1] in my local maven repository. To my client project, I have added the necessary dependencies.

Now, I declare my task like this

task tag(type:
   message="Tag message"

and run the task using “gradlew tag”.

However, all I get for my effort is a build failure: It tells me that “Neither path nor basedir may be null or empty string” and the values of both. It shows that baseDir is set to my working directory, and path is indeed null.

Googling on the problem just led me to bugs long closed, so I am probably missing something. Can you help me out?

Thank you -Urs

[1] If you want to inspect my task, please do so in my pull request to Andrews repository:

(Andrew Oberstar) #2

I responded in more detail in the pull request, but this is just a usage issue on the task. With that version of my plugin, any Git task that extends GitBase (i.e. it acts on an existing Git repository) requires a repository path to be set. You can set that using the repoPath property on the task.

Really just poor documentation on my part.

(Urs Reupke) #3

Thank you, Andrew. This resolves the issue.