Hi Mittie

Thanks. I like that idea. And it works (checkDirSize is a custom task):

    def reducedDependencies = build.taskDependencies.values - check
    build.dependsOn = reducedDependencies
    println build.taskDependencies.values

Etienne



On 24.11.2010, at 23:39, Dierk König wrote:

> Well, instead of "knowing", you can ask the API and removing from a list is 
> simple in Groovy.
> 
>>> someTask.dependsOn = oldDependencies - depsToRemove
> 
> I guess you can get the oldDependencies from the TaskGraph.
> 
> That said, it certainly feels more symmetric to also have a 'remove' where 
> there is an 'add'.
> 
> cheers
> Dierk
> 
> Am 24.11.2010 um 23:30 schrieb Etienne Studer:
> 
>> On one hand, it's a general question. If I can add dependencies, it would be 
>> nice to also remove dependencies. Especially when I use a plugin and want to 
>> wire the task dependencies differently (as far as it makes sense).
>> 
>> Example 1: Let's say I want to run 'gradle build' and always skip the tests 
>> (gradle build -x test is not an option if done repeatedly). In this case, I 
>> need to remove the dependency of check on test.
>> 
>> Example 2: When running the tests, I want to first run another task to 
>> prepare clover and after my tests are done, I want to run the clover report 
>> generation. I need: build -> check -> cloverReport -> test -> cloverSetup -> 
>> ...). Hence, check must not depend on test directly anymore.
>> 
>> These are just examples. I've come across several cases over the past few 
>> months where I wanted to squeeze in a new task between a task and its 
>> dependent task. Right now, this is not easy to achieve (except to replace 
>> all the dependencies, in case I know which ones were set before).
>> 
>> Etienne
>> 
>> 
>> On 24.11.2010, at 09:46, Adam Murdoch wrote:
>> 
>>> 
>>> On 24/11/2010, at 6:03 PM, Etienne Studer wrote:
>>> 
>>>> Hi
>>>> 
>>>> It's easy to add an additional task dependency to a given task. How can I 
>>>> do the opposite? Remove a dependency from a given task?
>>> 
>>> You can do something like this:
>>> 
>>> someTask.dependsOn = [... the set of dependencies that you'd actually 
>>> like... ]
>>> 
>>> 
>>>> 
>>>> Let's say, just for an example, I want to remove the dependency of the 
>>>> check task on the test task.
>>> 
>>> Do you want to change the dependencies that the standard Gradle plugins 
>>> define? If so, I don't suppose you could give a quick description of why 
>>> you want to do this?
>>> 
>>> 
>>> --
>>> Adam Murdoch
>>> Gradle Developer
>>> http://www.gradle.org
>>> CTO, Gradle Inc. - Gradle Training, Support, Consulting
>>> http://www.gradle.biz
>>> 
>> 
>> Etienne Studer
>> Senior Software Developer
>> 
>> Canoo Engineering AG
>> Kirschgartenstrasse 5
>> CH-4051 Basel
>> 
>> T +41 61 228 94 44
>> F +41 61 228 94 49
>> 
>> [email protected]
>> www.canoo.com
>> 
>> 
> 

Etienne Studer
Senior Software Developer

Canoo Engineering AG
Kirschgartenstrasse 5
CH-4051 Basel

T +41 61 228 94 44
F +41 61 228 94 49

[email protected]
www.canoo.com


Reply via email to