# Rule based model & Task rules

**URL:** <https://discuss.gradle.org/t/rule-based-model-task-rules/24381>\
**Category:** Help/Discuss\
**Created:** [October 10, 2017, 12:27pm UTC](https://discuss.gradle.org/t/rule-based-model-task-rules/24381 "2017-10-10T12:27:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobiash](https://avatars.discourse-cdn.com/v4/letter/t/4af34b/32.png) [@tobiash](https://discuss.gradle.org/u/tobiash)\
**Post date:** [October 10, 2017, 12:27pm UTC](https://discuss.gradle.org/t/rule-based-model-task-rules/24381/1 "2017-10-10T12:27:27Z")

</div>

While trying to port an existing plugin to the rule based model, I found that it does not seem to be possible to create a task rule using the model, nor is it possible to configure the model using a task rule.

The latter results in an exception:

> Cannot add rule model.releases for model element ‘releases’ at state Initialized as this element is already at state GraphClosed.

Is there an alternative to task rules? Ideally I would use some model input type that provides me with the currently called task name and I could setup my model/tasks based on that, but I did not find a suitable model element that carries that.

---

<div class="post-metadata">

**Author:** ![Schalk\_Cronje](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/schalk_cronje/32/6511_2.png) [@Schalk\_Cronje](https://discuss.gradle.org/u/Schalk_Cronje)\
**Post date:** [October 10, 2017, 3:21pm UTC](https://discuss.gradle.org/t/rule-based-model-task-rules/24381/2 "2017-10-10T15:21:31Z")

</div>

I would hold back porting anything to the rule-based model as it is all changing and are being simplified.

---

<div class="post-metadata">

**Author:** ![piotrj](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/piotrj/32/3514_2.png) [@piotrj](https://discuss.gradle.org/u/piotrj)\
**Post date:** [October 10, 2017, 4:13pm UTC](https://discuss.gradle.org/t/rule-based-model-task-rules/24381/3 "2017-10-10T16:13:19Z")

</div>

For status of the software model and rule-based configuration engine see [https://blog.gradle.org/state-and-future-of-the-gradle-software-model](https://blog.gradle.org/state-and-future-of-the-gradle-software-model).

---

<div class="post-metadata">

**Author:** ![tobiash](https://avatars.discourse-cdn.com/v4/letter/t/4af34b/32.png) [@tobiash](https://discuss.gradle.org/u/tobiash)\
**Post date:** [October 11, 2017, 7:56am UTC](https://discuss.gradle.org/t/rule-based-model-task-rules/24381/4 "2017-10-11T07:56:04Z")

</div>

Thank you, I was not aware of that. I had it on my list of things to look into for a while and started playing around with it yesterday after being fed up with `afterEvaluate` constructs.
