Search code examples
angulargrailsgradlegradlewgrails-3.3

How do I use GrailsApplicationCommand with the gradle wrapper in an angular project?


In my grails angular project, I have a GrailsApplicationCommand which I want to run within the server project.

I am able to execute the command from the server working directory using the grails CLI:

grails run-command my-command

I want to use the gradle wrapper so I can execute the command on the automated build server without worrying about which Grails version the server has installed.

I tried several variants of the gradlew command, but I can't figure out one that works. I think that Grails can't find the GrailsApplicationCommand because it's not in the same Gradle project as the gradle wrapper itself.

What is the correct syntax to execute a command in a subproject using gradlew?

Update:

The following did not work (Command not found error):

example> gradlew server:runCommand -Pargs="myExample"

I verified that the following works:

example/server> grails run-command my-example

I am using Grails 3.3.0.M2


Solution

  • The documentation shows how to run a command with Gradle

    http://docs.grails.org/latest/ref/Command%20Line/run-command.html

    So to execute that task on the server subproject:

    ./gradlew server:runCommand -Pargs="myCommand"

    EDIT: The following works with your example

    ./gradlew server:runCommand -Pargs="my-example"