This page provides instructions on how to use the Caplin CLI to create scaffolding for a new application.
To create a Caplin Trader 5 application, you require the following:
A Caplin Trader development workspace. For instructions on creating a development workspace, see Creating a new workspace.
To add support for Java Servlets in Caplin Trader’s development server, you will also require:
Creating a new application
You create a package using Caplin CLI’s
$ caplin-cli create-app <application-name>
For example, to create a new application called MyApp, follow the steps below:
From the root directory of your development workspace, run the command below:
$ caplin-cli create-app MyApp
The command asks if you wish to add support for Java Servlets to the CT development server. For this example, answer no. For more information on this feature, see Adding Java Servlet support below.
The command creates the following scaffolding for your new application:
Change directory to
apps/MyApp, and run the command below to download the project’s dependencies:
$ yarn install
Click on the terminal recording below to watch the creation of the scaffolding for an example CT5 application:
Adding Java Servlet support
Caplin Trader’s development server has optional support for Java Servlets. Support for Java Servlets can be activated when the application is created, or activated later through manual modification.
If your application uses Caplin’s Webcentric layout manager, you need to add support for Java Servlets to the development server if you want to run the Webcentric server-side persistence Servlet in development.
Adding Java Servlet support on application creation
When you create an application using the caplin-cli create-app command, the command asks if you want to run Java Servlets during development.
If you opt to include support for Java Servlets, the caplin-cli create-app command makes the following modifications to the new application’s scaffolding:
The following code is added to the file
server/node/server.jsto spawn Maven to download and run Jetty:
spawn( "mvn", ["-f", "server/java/proxy-target/pom.xml", "jetty:run"], proxySpawnOptions )
A new directory
server/javais added to the application’s scaffolding:
When you start the development server using the command
npm start (see Starting the development server), the server spawns Maven to download and run Jetty. When you close the development server by pressing Ctrl-C, the Jetty server detects this and shuts down gracefully.
Adding Java Servlet support after application creation
To avoid overwriting any modifications you may make to
caplin-cli command does not include a command to add Java Servlet support to an existing application. You must activate Java Servlet support manually.
Follow the steps below:
Run the command below to create the scaffolding for a new application:
$ caplin-cli create-app TemporaryApp
server/javadirectory from the new application to your existing application.
server/node/server.jsfile in the new application with the
server/node/server.jsfile in your application. Copy the code in the new
server.jsthat spawns Maven and paste it into the equivalent location in your application’s