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 theuploadArchives
task. Haulmont repository is used by default. -
ext.uploadUser
– name of the repository user that will be used to upload assembled project artifacts.HAULMONT_REPOSITORY_USER
environment variable value is used by default. -
ext.uploadPassword
repository user password that will be used to upload assembled project artifacts.HAULMONT_REPOSITORY_PASSWORD
environment variable value is used by default. -
ext.tomcatPort
,ext.tomcatShutdownPort
andext.tomcatDebugPort
properties affect thesetupTomcat
task (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
repoUser
andrepoPass
project 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 passrepoUser
andrepoPass
in the command line arguments with-P
prefix. -
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 thepersistenceXml
task 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 themetadataXml
task 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.tomcatDir
property in theallprojects
section. By default, it is the project’sbuild/tomcat
subfolder. -
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/lib
catalog 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/distributions
module 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
appHome
parameter, 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.properties
file in addition to those defined in the task itself. By default, thebuildWar
task creates this file and defines propertiescuba.logDir
,cuba.confDir
,cuba.tempDir
,cuba.dataDir
in 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 thebuildWar
module and have the following parameters:-
appHome
– the path to the home directory of the application (seebuildWar
task description for details). -
distrDir
– target folder for the distribution content. It is an optional parameter; by default, thebuild/war
project 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,localhost
is used. -
masterUrl
– the URL used to connect when creating the database. If not specified, the default value that depends on the DBMS type and thehost
parameter 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’sjdbc
configuration. Explicit definition ofdriverClasspath
is 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 thecreateDb
task, except that thedropDbSql
andcreateDbSql
parameters are omitted. -
startDb
– theCubaHsqlStart
-type task that starts the local HSQLDB server. Parameters:-
dbName
– database name, default iscubadb
. -
dbDataDir
– database directory, default is thedata
subfolder 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
– theCubaStopTomcat
type 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
- theCubaWidgetSetDebug
type 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-toolkit
module has a dependency on Servlet API library in theruntime
configuration:configure(webToolkitModule) { dependencies { runtime(servletApi) } ...
See Section 5.7.2, “Debugging Web Widgets” for information on how to debug code in the browser.