5.3.4. Starting Build Tasks

Gradle tasks described in build scripts can be launched in the following ways:

  • If you are working with the project in CUBA Studio, all commands under the Build and Run main menu items actually connect to the Gradle daemon (launched at the start of Studio server) and run corresponding tasks.

  • Alternatively, you can use the executable gradlew script (Gradle wrapper) included in the project. The script should be located in the project root directory and can be created in Studio using the Build > Create Gradle wrapper command.

  • One more way is to use the manually installed Gradle version 3.1. In this case, run the gradle executable located in the bin subdirectory of the Gradle installation.

Tip

It is recommended to run the gradlew and gradle commands with the --daemon argument; in this case the Gradle daemon is retained in memory, which significantly accelerates the subsequent execution.

To remove the daemon from memory, you can use the --stop argument.

For example, in order to compile the Java files and build the JAR files for project artifacts, you need to run the following command:

gradlew --daemon assemble
Warning

If your project uses Premium Add-ons, and you are starting build tasks outside Studio, pass the Premium Add-ons repository credentials in the command line arguments with -P prefix, for example:

gradle assemble -PpremiumRepoUser=111111222222 -PpremiumRepoPass=abcdefabcdef

See above for details.

Typical build tasks in their normal usage sequence are provided below.

  • idea, eclipse – create IntelliJ IDEA or Eclipse project files. When this task is executed, dependencies with their source code are loaded from the artifact repository to the local Gradle cache.

  • cleanIdea, cleanEclipse – remove IntelliJ IDEA or Eclipse project files.

  • assemble – compile Java files and build JARs for project artifacts in the build subdirectories of the modules.

  • clean – remove build subdirectories of all project modules.

  • setupTomcat – setup the Tomcat server to the path that is specified by the cuba..tomcat.dir property of the build.gradle script.

  • deploy – deploy the application to the Tomcat server that has been pre-installed by the setupTomcat task.

  • createDb – create an application database and run the corresponding scripts.

  • updateDb – update the existing application database by running the corresponding scripts.

  • start – start the Tomcat server.

  • stop – stop the running Tomcat server.

  • restart – sequentially run the stop, deploy, start tasks.