Gradle is an advanced compilation tool that allows you to automate and manage the compilation process, as well as to define customized and flexible compilation configurations.
As from GeneXus 18, Gradle is the tool for managing the Java Generator’s dependencies and build process. Therefore, the compilation mechanism GXJMake and createwebapplication.bat are no longer used, and Gradle is used instead. In addition, the compile folder that contained a file for every GeneXus object to be compiled is no longer used either.
The use of Gradle brings about the following changes: at the folder structure level, the available command lines, and the properties to generate your KB.
Below is a list of the folders structure:
- The *.java sources are generated in the folder src\main\java.
- The JavaScript sources are generated in the js folder of the model.
- The compiled code is generated in the folder build\classes\java\main.
Gradle can be called from command line, indicating the task to be executed. The available tasks are listed below:
This task calls the tasks buildGenexus, copyTomcat, and compileJava.
This task calls the tasks copyRuntimeLibs and copyAdditionalFiles.
This task compiles all the existing sources in “src\main\java” and leaves the classes in “build\classes\java\main.”
This task downloads and copies all the necessary packages to the “build\libs” folder to execute any proc command line.
This task copies all the necessary files to the “build\classes\java\main” folder from the model folder to execute any proc command line.
This task downloads and copies all the necessary packages to the webapp lib folder in Tomcat to run the webapp.
This task copies all the necessary classes to the webapp classes folder in Tomcat in order to run the webapp.
This task copies all the static content to the 'static' folder of the webapp in Tomcat.
This task copies all necessary resources other than jars, static content, or classes to the Tomcat webapp.
This task calls the tasks that are necessary to run the webapp on Tomcat.
This task deletes the “dependencies” folder.
This task calls the cleanTomcat, cleanSources tasks and deletes the “build” folder.
This task deletes the webapp from Tomcat.
This task deletes all the sources from the “src\main\java” folder.
This task downloads all the packages needed to run to the “dependencies” folder.
The Gradle project is located in the build.gradle file that is distributed by GeneXus with the generator. This file is overwritten when the generator is updated.
In addition, Gradle uses a set of properties to run the project. These properties are located in the gradle.properties file, which is generated every time you compile.
To run Gradle from the command line, you may want to overwrite some of the properties of the gradle.properties file, which are shown in the table below. To overwrite the values of these properties, you must indicate the value of the property in the command line.
GENEXUS_VERSION |
Version of the standard classes to be used. |
JAVA_PACKAGE_NAME_FOLDER |
Package name of the model. |
TOMCAT_WEBAPP_PATH |
Path to Tomcat. |
TOMCAT_STATIC_PATH |
Path to the static folder in Tomcat. |
JAVA_PLATFORM |
It can have the values jakartaEE, javaEE or both. |
SQLSERVER |
If a SQL Server datastore exists. |
ORACLE |
If an Oracle datastore exists. |
POSTGRESQL |
If a PostgreSQL datastore exists. |
MYSQL |
If a MySQL datastore exists. |
DBMS_MYSQL_VERSION |
MySQL Datastore Version. |
DB2ISERIES |
If an iSeries datastore exists. |
WEBAPP_NAME |
Name of the webapp in Tomcat. |
LAYOUT_METADATA_FOLDER |
If there are dynamic reports, their templates are saved in this folder. |
DAMENG |
If a Dameng datastore exists. |
The following examples are command line calls to Gradle.
You can make a Build using the Build task with the properties defined by default in the gradle.properties file that GeneXus generated. To do so, type the following in command line:
gradlew.bat build
It is the same command that is called from GeneXus when selecting any Build option.
It is also possible to make a Build by typing the value of the GENEXUS_VERSION property, as shown in the following line:
gradlew.bat build -PGENEXUS_VERSION="2.8-SNAPSHOT"
- To start Gradle it uses the value defined in the JAVA_HOME environment variable.
-
To include additional dependencies in your GeneXus application, create a .gradle file in the web directory of your project. This file allows you to specify external libraries that your application needs. Add the required dependencies within the.gradle file, following the standard Gradle syntax. For example, to integrate Spring Boot Actuator, refer to the official Spring Boot documentation for the specific dependency you need to add: https://docs.spring.io/spring-boot/reference/actuator/tracing.html.
When you build your GeneXus application, Gradle will automatically incorporate these dependencies, ensuring that your application has access to the necessary libraries. Once you've added the dependencies, follow the instructions in the relevant documentation to configure and use the libraries in your application.
This feature is available since GeneXus 18.