Allow subclass of AbstractCopyTask to execute task action without declared sources

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Allow subclass of AbstractCopyTask to execute task action without declared sources

bmuschko
Hi,

I am dealing with a custom task that extends org.gradle.api.tasks.bundling.AbstractArchiveTask. The concrete use case is to support other packaging types like Debian and RPM. For this specific implementation, it is required that the archive can be created even if no source files are declared (other inputs are declared in the subclass).

At the moment this is not possible as the method AbstractCopyTask.getSource() is annotated with @SkipWhenEmpty (https://github.com/gradle/gradle/blob/RB_1.12/subprojects/core/src/main/groovy/org/gradle/api/tasks/AbstractCopyTask.java#L92) which will mark the task UP-TO-DATE if it doesn't declare at least one from statement.

Is there a way for subclasses of AbstractCopyTask to avoid SkipEmptySourceFilesTaskExecuter from kicking in? I tried overriding the method. However, that didn't help as the annotation from AbstractCopyTask is still parsed.

Any thoughts on this?

Thanks,

Ben
Reply | Threaded
Open this post in threaded view
|

Re: Allow subclass of AbstractCopyTask to execute task action without declared sources

Daz DeBoer-2
Hey Ben
It looks like SkipEmptySourceFilesTaskExecuter will only skip the task if _all_ source file inputs are empty. So maybe it's a matter of configuring your task so that some of the other inputs are considered a "source" input. This could be done by adding @SkipWhenEmpty to one of your other inputs, or using Task.getInputs().source().
Worth a try, anyway.
Daz



On Tue, Jul 22, 2014 at 1:15 PM, bmuschko <[hidden email]> wrote:
Hi,

I am dealing with a custom task that extends
org.gradle.api.tasks.bundling.AbstractArchiveTask. The concrete use case is
to support other packaging types like Debian and RPM. For this specific
implementation, it is required that the archive can be created even if no
source files are declared (other inputs are declared in the subclass).

At the moment this is not possible as the method
AbstractCopyTask.getSource() is annotated with @SkipWhenEmpty
(https://github.com/gradle/gradle/blob/RB_1.12/subprojects/core/src/main/groovy/org/gradle/api/tasks/AbstractCopyTask.java#L92)
which will mark the task UP-TO-DATE if it doesn't declare at least one from
statement.

Is there a way for subclasses of AbstractCopyTask to avoid
SkipEmptySourceFilesTaskExecuter from kicking in? I tried overriding the
method. However, that didn't help as the annotation from AbstractCopyTask is
still parsed.

Any thoughts on this?

Thanks,

Ben



--
View this message in context: http://gradle.1045684.n5.nabble.com/Allow-subclass-of-AbstractCopyTask-to-execute-task-action-without-declared-sources-tp5712928.html
Sent from the gradle-dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Darrell (Daz) DeBoer
Reply | Threaded
Open this post in threaded view
|

Re: Allow subclass of AbstractCopyTask to execute task action without declared sources

bmuschko
Thanks, Daz. That did the job. Though it feels awkward as I don't really have any additional input files to declare. At least I could make the method private final.