The allprojects section defines the group and version of the project
artifacts being built. Artifact names are based on module names specified in
settings.gradle. If the ext.isSnapshot property is true,
artifact names will have the SNAPSHOT suffix. The ext.tomcatDir property sets the
location of the Tomcat installation directory. Furthermore,
the allprojects section may have the following optional properties:
-
ext.copyright– the copyright notice text that is inserted by IntelliJ IDEA into the source text files. -
ext.vcs– type of VCS used in the project. If this property is specified, IntelliJ IDEA’s generated project files will have a VCS integration parameter for this VCS. Possible values:svn,git. -
ext.uploadUrl– URL of the repository where assembled project artifacts will be uploaded to upon completion of theuploadArchivestask. Haulmont repository is used by default. -
ext.uploadUser– name of the repository user that will be used to upload assembled project artifacts.HAULMONT_REPOSITORY_USERenvironment variable value is used by default. -
ext.uploadPasswordrepository user password that will be used to upload assembled project artifacts.HAULMONT_REPOSITORY_PASSWORDenvironment variable value is used by default. -
ext.tomcatPort,ext.tomcatShutdownPortandext.tomcatDebugPortproperties affect thesetupTomcattask (see below) and can be used to install Tomcat with non-standard ports.
Instead of setting project properties in build.gradle itself, you can do it by passing a command-line argument with the -P prefix, for example:
gradlew uploadArchives -PuploadUser=myuser -PuploadPassword=mypassword
In the buildscript section, the following actions are executed:
-
The base projects version is specified.
-
The set of repositories for loading project dependencies is specified. Values of
repoUserandrepoPassproject properties or standard values explicitly set in the build script are used as credentials to access the repository. Similar to other project properties, you can passrepoUserandrepoPassin the command line arguments with-Pprefix. -
Dependency from the cuba-plugin is declared; the plugin contains the project's build specifics and is connected to the module build configuration using the following method:
apply(plugin: 'cuba')
Then, application modules building parameters are defined in the configure section.
Tasks are executable units in Gradle. They are defined both in the plugins and in the build script itself. Below are CUBA-specific
tasks; their parameters can be configured in build.gradle.
-
enhance– theCubaEnhancing-type task that executes bytecode enhancement of persistent entity classes. It is declared in the global module. The path to the persistence.xml project file is specified in thepersistenceXmltask parameter.For example:
task enhance(type: CubaEnhancing) { persistenceXml = "${globalModule.projectDir}/src/persistence.xml" } -
enhanceTransient– theCubaEnhanceTransient-type task that executes bytecode enhancement of non-persistent entity classes. The path to the metadata.xml project file is specified in themetadataXmltask parameter.For example:
task enhanceTransient(type: CubaEnhanceTransient) { metadataXml = "${globalModule.projectDir}/src/metadata.xml" } -
setupTomcat– theCubaSetupTomcat-type task that performs installation and initialization of the local Tomcat server for subsequent fast deployment of the application. This task is automatically added to the project when you connect the cuba build plugin, so you don’t need to declare it inbuild.gradle. Tomcat installation directory is specified by theext.tomcatDirproperty in theallprojectssection. By default, it is the project’sbuild/tomcatsubfolder. -
deploy– theCubaDeployment-type task that performs fast deployment of a module to Tomcat. It is declared in the core, web and portal modules. Parameters:-
appName– name of the web application that will be created from the module. In fact, it is the name of a subdirectory insidetomcat/webapps. -
jarNames– the list of JAR file names (without versions) produced as a result of building a module and intended to be placed into theWEB-INF/libcatalog of the web application. All other module artifacts and dependencies will be copied totomcat/shared/lib.
For example:
task deploy(dependsOn: assemble, type: CubaDeployment) { appName = 'app-core' jarNames = ['cuba-global', 'cuba-core', 'app-global', 'app-core'] } -
-
buildWar– theCubaWarBuilding-type task that builds a module into a WAR file. It can be declared in the core, web and portal modules, if application deployment to WAR is required. The built WAR files are located in thebuild/distributionsmodule subdirectories.Task parameters:
-
appName– the name of the resulting WAR file. -
appHome– the path to the application home directory. The home directory contains the logging configuration file, the database scripts directory, and the configuration, temporary and work directories of the application.In the
appHomeparameter, you can specify either an absolute path to the home directory or a system variable, which should be set at server start. For example:appHome = '/work/sales_home'orappHome = '${app.home}'. -
appProperties– the map of the properties that will be written to theWEB-INF/local.app.propertiesfile in addition to those defined in the task itself. By default, thebuildWartask creates this file and defines propertiescuba.logDir,cuba.confDir,cuba.tempDir,cuba.dataDirin it, in order to work with the application home directory mentioned above. Additionally, the following parameter is set for the middleware:cuba.dataSourceJndiName = jdbc/CubaDS
and for the web client:
cuba.connectionUrl = http://localhost:8080/${appName}-core cuba.useLocalServiceInvocation = false
An example of a task in the web module:
task buildWar(dependsOn: assemble, type: CubaWarBuilding) { appName = 'app' appHome = '${app.home}' appProperties = ['cuba.connectionUrlList': 'http://server/app-core'] } -
-
createWarDistr– theCubaWarDistribution-type task that prepares the distribution that includes application WAR files and their home directory. The task must depend on the tasks of thebuildWarmodule and have the following parameters:-
appHome– the path to the home directory of the application (seebuildWartask description for details). -
distrDir– target folder for the distribution content. It is an optional parameter; by default, thebuild/warproject subdirectory is used.
Below is a sample task description:
task createWarDistr(dependsOn: [coreModule.buildWar, webModule.buildWar], type: CubaWarDistribution) { appHome = '${app.home}' } -
-
createDb– theCubaDbCreation-type task that creates application database by executing the corresponding scripts. It is declared in the core module. Parameters:-
dbms– the DBMS type; specified as string (hsql,postgres,mssql, ororacle). -
dbName– the database name. -
dbUser– the DBMS username. -
dbPassword– the DBMS user password. -
host– the DBMS host and port (optional) in thehost[:port]format. If not specified,localhostis used. -
masterUrl– the URL used to connect when creating the database. If not specified, the default value that depends on the DBMS type and thehostparameter is used. -
dropDbSql– the SQL command to delete the database. If not specified, the default value that depends on the DBMS type is used. -
createDbSql– the SQL command to create a database. If not specified, the default value that depends on the DBMS type is used. -
driverClasspath– the list of JAR files containing the JDBC driver. The items in the list are separated by ":" on Linux and by ";" on Windows. If not specified, the system uses the dependencies that are part of the current module’sjdbcconfiguration. Explicit definition ofdriverClasspathis necessary when using Oracle, because its JDBC driver is not available in the dependencies. -
oracleSystemPassword– the SYSTEM user password for Oracle.
Example for PostgreSQL:
task createDb(dependsOn: assemble, description: 'Creates local database', type: CubaDbCreation) { dbms = 'postgres' dbName = 'sales' dbUser = 'cuba' dbPassword = 'cuba' }Example for MS SQL Server:
task createDb(dependsOn: assemble, description: 'Creates local database', type: CubaDbCreation) { dbms = 'mssql' dbName = 'sales' dbUser = 'sa' dbPassword = 'saPass1' }Example for Oracle:
task createDb(dependsOn: assemble, description: 'Creates database', type: CubaDbCreation) { dbms = 'oracle' host = '192.168.1.10' dbName = 'orcl' dbUser = 'sales' dbPassword = 'sales' oracleSystemPassword = 'manager' driverClasspath = "$tomcatDir/lib/ojdbc6.jar" } -
-
updateDb– theCubaDbUpdate-type task that updates the database by executing the corresponding scripts. It is similar to thecreateDbtask, except that thedropDbSqlandcreateDbSqlparameters are omitted. -
startDb– theCubaHsqlStart-type task that starts the local HSQLDB server. Parameters:-
dbName– database name, default iscubadb. -
dbDataDir– database directory, default is thedatasubfolder of the project. -
dbPort– server port, default is 9001.
For example:
task startDb(type: CubaHsqlStart) { dbName = 'sales' } -
-
stopDb– theCubaHsqlStop-type task that stops the local HSQLDB server. The parameters are similar tostartDb. -
start– theCubaStartTomcat-type task that starts the local Tomcat server installed by the setupTomcat task. This task is automatically added to the project when you add the cuba plugin, so you don’t need to declare it inbuild.gradle. -
stop– theCubaStopTomcattype task that stops the local Tomcat server installed by the setupTomcat task. This task is automatically added to the project when you include the cuba plugin, so you don’t need to declare it inbuild.gradle. -
restart– the task that stops the local Tomcat server, runs fast deployment, and starts the server once again. -
debugWidgetSet- theCubaWidgetSetDebugtype task that launches GWT Code Server for debugging widgets in the browser.Example usage:
task debugWidgetSet(type: CubaWidgetSetDebug) { widgetSetClass = 'com.haulmont.cuba.web.toolkit.ui.WidgetSet' }Ensure that the
web-toolkitmodule has a dependency on Servlet API library in theruntimeconfiguration:configure(webToolkitModule) { dependencies { runtime(servletApi) } ...See Section 5.7.2, “Debugging Web Widgets” for information on how to debug code in the browser.

