# commandLine not working after upgrading to Gradle 5

**URL:** <https://discuss.gradle.org/t/commandline-not-working-after-upgrading-to-gradle-5/46851>\
**Category:** Help/Discuss\
**Created:** [October 25, 2023, 12:14pm UTC](https://discuss.gradle.org/t/commandline-not-working-after-upgrading-to-gradle-5/46851 "2023-10-25T12:14:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![atewari](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@atewari](https://discuss.gradle.org/u/atewari)\
**Post date:** [October 25, 2023, 12:14pm UTC](https://discuss.gradle.org/t/commandline-not-working-after-upgrading-to-gradle-5/46851/1 "2023-10-25T12:14:01Z")

</div>

Hi,  
I upgraded my gradle version to 5.5.1 from 3.5.  
Since .execute() got deprecated in gradle 5, i removed execute() in calling of task.

Here is my code.

```groovy
def testExecTask = project.tasks.create(name: "test${testFile.name.capitalize()}" - '.uip', type: Exec) {
                    inputs.file testFile
                    inputs.files "${project.stage.testStageDir}"
                    commandLine ["${installShieldRoot}/sab/${installShieldExecutable}",
                                   "${testFile}".replaceAll('\\\\', '/'),
                                   "-pathVariable",
                                   "staging=${finalLocation}".replaceAll('\\\\', '/'),
                                   "-pathVariable",
                                   "staging64=${finalLocation}".replaceAll('\\\\', '/'),
                                   "-pathVariable",
                                   "ASSEMBLY_DIR=${project.buildDir}/build/kitting/assembly64".replaceAll('\\\\', /'),
                                   "-pathVariable",
                                   "images_dir=${project.stage.dir}/images".replaceAll('\\\\', '/'),
                                   "-build",
                                   "${configurationName}"]
                    environment KIT_OS_ARCH: "64"
                }
				
		testExecTask.execute()

```

Instead of testExecTask.execute(), now i am just calling task as testExecTask after upgrading to gradle 5.

Task is called but commandLine doesn’t get executed. Please can someone help as to how to make sure commandLine code is executed. Everything worked well in 3.5 gradle version.

Regards,  
Anand

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [October 25, 2023, 1:00pm UTC](https://discuss.gradle.org/t/commandline-not-working-after-upgrading-to-gradle-5/46851/2 "2023-10-25T13:00:19Z")

</div>

There is no way to “call” a task in Gradle.  
The `execute()` method was an accident in the API that had many problems and thus was removed from the API.

If you really want to always run this command whenever the Gradle build is configured - which is most probably a pretty bad idea - then do not use a task of type `Exec`, but an `exec { ... }` closure. Configuration is the same as for the task.

---

<div class="post-metadata">

**Author:** ![atewari](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@atewari](https://discuss.gradle.org/u/atewari)\
**Post date:** [October 25, 2023, 8:01pm UTC](https://discuss.gradle.org/t/commandline-not-working-after-upgrading-to-gradle-5/46851/3 "2023-10-25T20:01:29Z")

</div>

Thanks for the response.  
After using exec{ } instead of Type:Exec, I am getting below error.

_\> No signature of method: com.tim.gradle.plugins.kit.TestPlugin.exec() is applicable for argument types: (com.tim.gradle.plugins.kit.TestPlugin$\_kitUipMethod\_closure5) values: [com.tim.gradle.plugins.kit.TestPlugin$\_kitUipMethod\_closure5@270be080]_  
_00:02:49.418 Possible solutions: grep(), every(), grep(java.lang.Object), every(groovy.lang.Closure), each(groovy.lang.Closure), use([Ljava.lang.Object;)_

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [October 25, 2023, 10:14pm UTC](https://discuss.gradle.org/t/commandline-not-working-after-upgrading-to-gradle-5/46851/4 "2023-10-25T22:14:43Z")

</div>

I assumed you are in a build script. But as you are in a plugin class, inject `ExecOperations` and call `exec` on that.

---

<div class="post-metadata">

**Author:** ![atewari](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@atewari](https://discuss.gradle.org/u/atewari)\
**Post date:** [October 28, 2023, 8:55am UTC](https://discuss.gradle.org/t/commandline-not-working-after-upgrading-to-gradle-5/46851/5 "2023-10-28T08:55:10Z")

</div>

Thanks again for the response. ExecOperations was introduced in version 6, I am using version 5.5.1 of gradle.

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [October 28, 2023, 9:37am UTC](https://discuss.gradle.org/t/commandline-not-working-after-upgrading-to-gradle-5/46851/6 "2023-10-28T09:37:55Z")

</div>

Well, you should probably update instead of using an ancient version that was released more than 5 years ago. 😃  
In the meantime use `project.exec { ... }`. 🙂

---

<div class="post-metadata">

**Author:** ![atewari](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@atewari](https://discuss.gradle.org/u/atewari)\
**Post date:** [October 31, 2023, 8:03am UTC](https://discuss.gradle.org/t/commandline-not-working-after-upgrading-to-gradle-5/46851/7 "2023-10-31T08:03:58Z")

</div>

@Vampire Thanks. It worked.
