WAR build
An executable WAR can be built in a TopLogic app module (cf. Creating an application) via mvn package
. It should be noted that the application configuration may have to be adapted for the target environment during deployment.
mvn package
In the default configuration, the WAR is built with the identical configuration in which the application also runs in the development environment. That is, the configuration files located in the folder deploy/local/webapp
are included. Usually an embedded H2 database is used:
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.top-logic:tl-bpe-app >----------------------
[INFO] Building tl-bpe-app 7.6.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
...
[INFO] Packaging application
[INFO] Building war: .../target/tl-bpe-app-7.6.0-app.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
If these settings are to be customized for deployment, either additional deploy folders can be created and these can be activated via Maven profiles in deployment, or special deploy modules can be created per target environment (see below).
Deploy folders for customizations in deployment
Configurations that are specific to a target environment can be collected in a deploy folder. As an example, the deployment application will have a database configuration file for an Oracle database.
The deploy folder "productive
" is created with the file deploy/productive/webapp/WEB-INF/conf/metaConf.txt
:
db-default.xml
db-oracle.xml
During deployment, this deploy folder is now to be used instead of deploy/local
. For this purpose, the property deployAspects
is set to the deploy folder name in the pom.xml
of the application:
<properties>
<deployAspects>productive</deployAspects>
</properties>
If different configurations are to be stored for several target environments, then the property can also be set in a profile instead of in the global properties section of the application:
<profiles>
<profile>
<id>productive</id>
<properties>
<deployAspects>productive</deployAspects>
</properties>
</profile>
</profiles>
In this case, the corresponding deployment configuration is activated via the profile productive
:
mvn -P productive package
Deploy module
The deploy aspects can also be completely separated from the actual application and outsourced to a deploy module. Such a deploy module consists only of a pom.xml
and optionally additional configuration files. For an application my.company:my-app:1.0
, a deploy module my.company:my-app-deploy:1.0
is created using the Maven archetype tl-archetype-deploy
as follows:
mvn -P tl-dev archetype:generate \
-DarchetypeGroupId=com.top-logic \
-DarchetypeArtifactId=tl-archetype-deploy \
-DarchetypeVersion=7.6.0 \
\
-DgroupId=my.company \
-DartifactId=my-app-deploy \
-Dversion=1.0 \
\
-DappGroupId=my.company \
-DappArtifactId=my-app \
-DappVersion=1.0
Here, the parameters groupId
, artifactId
and version
specify the coordinates of the deploy module to be created. The application built by this deploy module is specified via appGroupId
, appArtifactId
and appVersion
. The parameters appGroupId
and appVersion
can be omitted as they match the built application by default.
The application can then be built in the deploy module:
cd my-app-deploy
mvn -P with-h2 clean package
Deploy modules have distinct advantages over deploy folders within the application module.
- The deploy module can be treated like a normal application module. All settings and configuration files are in the same place as in a regular application.
- The build of the application can be separated from its deployment. A deploy module can generate a WAR for a completed built application whose artifacts can be loaded from a repository. This makes it possible to build multiple WARs in different configurations for the same application without having to build the application itself multiple times. With a deploy folder, the complete application must always be built to generate a WAR.