Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute gradle build task from any location

I´m trying to build my gradle projects from other locations than the project folder itself, but it always says it couldn´t find build task.

What I´ve tried so far:

sudo ./myprojects/myapp/gradlew build

sudo ./myprojects/myapp/gradlew ./myprojects/myapp/build

How can I execute a gradle build task from any location?

like image 516
Marian Klühspies Avatar asked Sep 03 '14 07:09

Marian Klühspies


People also ask

Where can I run Gradle build?

The gradle command will run Gradle on the gradle build script located in the same directory as the command prompt is located in. That means, that to run gradle on a specific gradle build script you must change directory in the command prompt into the directory where the build script is located.

Where should I execute Gradle command?

Press ⌃⌃ (macOS), or Ctrl+Ctrl (Windows/Linux), type "gradle" followed by the gradle task name or names. We can, of course, run Gradle commands from the terminal window inside IntelliJ IDEA. Open this with ⌥F12 (macOS), or Alt+F12 (Windows/Linux).


1 Answers

Various people have written (and published) scripts to execute gradlew from any subproject directory (in a multi-project build). To reliably execute Gradle from any subdirectory, it is necessary to set the "current project directory" via -p. It would be nice to have this restriction lifted (this would make a good feature request).

like image 183
Peter Niederwieser Avatar answered Oct 04 '22 16:10

Peter Niederwieser