Table of contents

Official Content

The Application Deployment tool has an option to package Java sources to later assemble the binaries instead of packaging the binaries directly. Afterwards, these files can be put under version control—with Git, for example.

Using the Application Deployment tool, you must select Target = Local and set the Package Type property with the "Sources" value. 

image_2023511191210_1_png

When you click on the Deploy button, the source code, configuration files, and resources corresponding to the selected Deployment Unit object are copied to a specific folder structure, detailed below.

Build management tool

As from GeneXus 18, Gradle is the tool for managing the Java Generator’s dependencies and build process (see Gradle and the Java Generator).
For that reason, the Application Deployment tool generates a gradle.properties file for when the user wants to use Gradle as the building and packaging tool (although any other tool can be used for that purpose).

The structure generated by the Application Deployment tool is as follows:

  • src\
    • main\java\<package> 
      Where package is the Java package name property. All the source files and configuration files (client.cfg, images.txt, messages<lang>.txt) are located under this directory.
    • main\webapp\WEB-INF.
      This structure is created for web applications. It contains the configuration files needed to be under this directory.
  • build.gradle file
    This file is copied from the web directory to the root of the deployment package. 
    The gradlew, gradle.bat, and gradle folder are also copied automatically to the package.
  • gradle.properties file
    This file is generated from the information that can be extracted from the deployment unit (such as Java Platform, Datastores, servlet version, etc). All that information is used by the Gradle engine to download all the dependencies required to compile and run the application.

Warning: The build.gradle file should be changed according to your needs.

Note that the build.gradle file copied from the web directory is useful for a rapid startup, but it contains tasks that are specifically designed for GeneXus development (downloading dependencies from the Maven repository and copying the binaries to a local folder structure).

You should change it to fit your needs.

MSBuild Scripts for packaging Java sources 

In order to create a CI/CD pipeline, you can execute the Application deployment tool using MSBuild tasks, as explained in Application Deployment MSBuild tasks.
The first step to run is the CreateDeployProject target. This step creates a .gxdproj file with the entire call tree of your deployment unit, and some properties that will be used later.

It receives the DEPLOY_TYPE property that indicates whether the final package will be sources or binaries.

Important
It's mandatory to pass DEPLOY_TYPE property to the createdeploy task. It can be either "Sources" or "Binaries".

The second step takes as input the .gxdproj script file generated in the previous step.

Example command to execute the CreatePackage target

MSBuild.exe  /verbosity:minimal /ToolsVersion:4.0 "c:\<Web model directory>\<project>.gxdproj"
/p:GX_PROGRAM_DIR=<GX program directory>
/p:USE_APPSERVER_DATASOURCE="False"
/p:DEPLOY_TYPE="SOURCES"
/p:APPLICATION_KEY="000000000000000000000000000"
/p:INCLUDE_GAM="False"
/p:INCLUDE_GXFLOW_BACKOFFICE="True"
/p:TARGET_JRE="9"
/p:TimeStamp="20230511182904"
/p:AppName="GenexusWebApp"
/t:CreatePackage

The generated package will contain all the sources, resources, and dependencies needed for building the application using Gradle.

Building the sources of a Spring Boot application

In the case of a Spring Boot Java Application, there is nothing particular to consider when packaging the sources of the application.

The Deploy Engine detects that the app uses the Spring Boot framework because the generated .gxdproj file has a property stating the Java Framework to be Spring Boot.

For more information see Deploying Java applications with Spring Boot.

Building the package

To build the package, execute the following command. 
gradlew build 

As stated before, the gradle.properties file is generated by the Deploy Engine, and its information is used by the Gradle engine to download all the dependencies required to compile and then run the application.

Temporary limitation

In the case of non-SpringBoot applications, the package includes more dependencies than the really needed.

Last update: December 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant