# In ant i can pass an custom ant task as a parameter to an another custom ant task and i can perform/execute the passed ant task. The sample ant custom task code looks something like this.

**URL:** <https://discuss.gradle.org/t/in-ant-i-can-pass-an-custom-ant-task-as-a-parameter-to-an-another-custom-ant-task-and-i-can-perform-execute-the-passed-ant-task-the-sample-ant-custom-task-code-looks-something-like-this/31188>\
**Category:** Help/Discuss\
**Created:** [March 29, 2019, 3:08pm UTC](https://discuss.gradle.org/t/in-ant-i-can-pass-an-custom-ant-task-as-a-parameter-to-an-another-custom-ant-task-and-i-can-perform-execute-the-passed-ant-task-the-sample-ant-custom-task-code-looks-something-like-this/31188 "2019-03-29T15:08:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ponaravind](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@ponaravind](https://discuss.gradle.org/u/ponaravind)\
**Post date:** [March 29, 2019, 3:08pm UTC](https://discuss.gradle.org/t/in-ant-i-can-pass-an-custom-ant-task-as-a-parameter-to-an-another-custom-ant-task-and-i-can-perform-execute-the-passed-ant-task-the-sample-ant-custom-task-code-looks-something-like-this/31188/1 "2019-03-29T15:08:12Z")

</div>

```gradle
public class MyGenericCustomTask extents Task implements TaskContainer {
private Task task;
boolean isSerious = false;

@Override
public void addTask(Task arg0) {
 this.task = arg0;
}

public void setIsSerious(boolean b) {
        this.isSerious = b;
}

@Override
public void execute() throws BuildException {
 try {
      this.task.perform(); // If there is a exception
 }catch(BuildException e) {
   if(isSerious) {
     println("Failure is series");
   }
   else {
     println("Log the failure and Continue for this run.");
  }
 } 
} 

```

How do i achieve the same in gradle custom task ?
