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. 
  • 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.

The gradlew, gradle.bat, and gradle folder should be added to the package folder by yourself.

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.

The second step takes as input the .gxdproj script file generated in the previous step. It will create an initial package (which will contain all the sources, but they will not be structured yet for building the application using Gradle).

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

Then you need to execute another script that will finally set up the package structure and copy the build.gradle file. This script is open under Deployment Targets GitHub repository.

Example

MSBuild.exe /nologo /verbosity:minimal /ToolsVersion:4.0 "C:\<GX program directory>\DeploymentTargets\Local\deploy.msbuild" 
/p:DEPLOY_TYPE="SOURCES" /p:LANGUAGE="12" 
/p:GENERATOR="Java" 
/p:DEPLOY_PATH=<Deploy path> 
/p:GX_PROGRAM_DIR=<GX program directory>
/p:CreateCloudPackage="false" 
/p:TargetId="LOCAL"
/p:DeployFullPath=<Deploy PaTh> 
/t:Deploy

Availability

This functionality is available since GeneXus 18 Upgrade 4.

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