The Catalyst Maven Plugin

Introduction

The catalyst plugin will be available under Maven plugins after you initialize a Basic I/O or an Advanced I/O function from the archetype. You can find the individual commands shown below under this plugin that will enable you to perform various operations on your Catalyst functions and Maven artifacts.

maven-plugins

The serve and deploy command executions are performed after your request is authenticated. Catalyst currently provides proprietary authentication for the Maven plugin that is independent of the Catalyst CLI authentication. Your IDE will prompt you for the authentication token generation when you execute these commands, and the tokens that are created will be saved in your local system. The package and help commands do not require to be authenticated.


Package

The Catalyst package command is exclusive to the Maven plugin and is not available in the CLI. This allows you to pack your Java function directory as an executable bundle.

Note: You can pack a function manually before you serve or deploy it. However, if you directly serve or deploy a function without executing the package command first, Catalyst will automatically pack the function before serving or deploying it.

Pack a Function with the Catalyst Maven Plugin

You can pack a Java Basic I/O or Advanced I/O function as described below. We have executed this command through the VS Code IDE in this example.

Click the package command under Plugins > catalyst in the Maven tools.

maven-package-1

You can track the progress of the execution in your IDE’s terminal. The function will be compiled to the JAR file format as a Maven SNAPSHOT. You can find the entire deployable bundle catalyst-archive.zip added in the target folder of your Maven’s project directory.

maven-package-2

The target directory will contain all the compiled files, libraries, and other Maven dependencies, along with the build archive and the SNAPSHOT JAR of the main function.

maven-catalyst-archive

catalyst-archive contains the deployable library files including the Java SDK, the compiled source files, catalyst-config.json, and pom.xml.

maven-catalyst-archive-structure

The function can now be served locally, or deployed to the remote project.


Serve

The serve command under the Catalyst Maven plugin is similar to the CLI command, catalyst serve. It enables you to serve and test your function through a localhost in your system, before you deploy it to the remote project. You can serve both Basic I/O and Advanced I/O functions and obtain their local endpoints to test.

Additionally, you can leverage your IDE’s debugger and attach it to the live serve session for an enhanced testing experience. Catalyst also enables you to perform a hot reload of the function you serve. This enables you to make changes in your function’s code and see the updates reflected live, without having to re-compile or re-serve the code.

Note:
  • The project ID and org ID associated with the function needs to be configured in pom.xml before you serve the function.

  • Your function will need to be bundled before it is served. You can package it from the plugin, or serve it directly, which will automatically execute the package command.

  • The Maven project’s directory must be in the standard structure with all required Maven and Catalyst dependency files for a successful serve.


Serve a Function with the Catalyst Maven Plugin

You can serve a Java Basic I/O or Advanced I/O function as described below. We have executed this command through the VS Code IDE in this example.

  1. Click the serve command under Plugins > catalyst in the Maven tools.

maven-serve-1

The terminal of your IDE will display the progress of the serve session.

maven-serve-2

  1. Catalyst will prompt you to authenticate your serve request if no valid authentication token is detected. Open the URL displayed in the terminal in a browser window.

maven-serve-3

  1. Click Accept in your browser window. This will authenticate your Catalyst account and provide the requested permissions to Catalyst CLI.

maven-serve-4

You can now close the window and navigate to your IDE.

  1. Catalyst will start a local server in the default port 3010. Access the local URL of the served function from the terminal.

maven-serve-5

Note: Depending on your IDE, a debug console might automatically spawn for you to test your hosted resources. You can also attach a debugger by yourself with the serve session, if this does not happen automatically.

The terminal will display a live log of the actions performed. Depending on your IDE, you can quit the serve session by killing the command execution.


Deploy

The deploy command under the Catalyst Maven plugin is similar to the CLI command, catalyst deploy. It enables you to deploy your function to the remote project after you finish testing it. You can deploy both Basic I/O and Advanced I/O functions and obtain their deployed URL endpoint.

Note:
  • The project ID and org ID associated with the function needs to be configured in pom.xml before you deploy the function.

  • Your function will need to be bundled before it is deployed. You can package it from the plugin, or deploy it directly, which will automatically execute the package command.

  • The Maven project’s directory must be in the standard structure with all required Maven and Catalyst dependency files for a successful deployment.


Deploy a Function with the Catalyst Maven Plugin

You can deploy a Java Basic I/O or Advanced I/O function as described below. We have executed this command through the VS Code IDE in this example.

  1. Click the deploy command under Plugins > catalyst in the Maven tools.

maven-deploy-1

The terminal of your IDE will display the progress command execution.

maven-deploy-2

  1. Catalyst will prompt you to authenticate your deploy request if no valid authentication token is detected. Open the URL displayed in the terminal in a browser window.

maven-deploy-3

  1. Click Accept in your browser window. This will authenticate your Catalyst account and provide the requested permissions to Catalyst CLI.

maven-serve-4

You can now close the window and navigate to your IDE.

  1. The terminal will display the deployed URL of your function that you can access.

maven-deploy-4

Note: The /server/ part in the URL of a Catalyst application indicates a function. A Basic I/O function's URL contains an /execute after the function's name, whereas an Advanced I/O function's URL does not contain that keyword.

You will now be able to access the function in your project in the remote console.


Help

The Maven plugin provides a help command that displays help information of all the commands in the plugin when you execute it.

maven-help-1

You can see the details in your IDE’s terminal.

maven-help-2

Last Updated 2024-04-15 17:30:30 +0530 +0530