Add ignore version to clean task?

(nspor) #1


I am currently running my builds using the following to enforce the user passing a version:

if (version == ‘unspecified’){

throw new GradleException(‘Must specify a version via -Pversion=’)


This works on enforcing the version string however it also enforces me to pass the build a string when I run a clean task.

I need 1 of 2 things.

A, have the clean task ignore the syntax above when cleaning up a java build. B. retrieve the task that is currently being run and if it is clean silently pass it a “version=clean”

Any ideas?

(Peter Niederwieser) #2

If all you want is not to check the version property when the ‘clean’ task is specified on the command line, then you can simply check ‘gradle.startParameter.taskNames’.

(nspor) #3

This answers my question, thank you!