Using deploy-free coding

October 8, 2024

Introduction

Deploy-free coding is a technology unique to Jahia's solution, which is quite useful. It bypasses expensive compile-build-deploy cycles during development by directly using changes from the source code. It is similar in experience to directly editing files on the server while still working from your source project. It then allows you to make changes to JSPs, and CSS files, save them and directly see the changes reflected on the server.

How deploy-free coding works

When building the project, the Jahia Maven Plugin will add a special MANIFEST.MF header that points to the source code location with an absolute path. This is configured in the Felix Maven Bundle plugin by the following line:

<Jahia-Source-Folders>${project.basedir}</Jahia-Source-Folders>

Upon generation of the MANIFEST.MF inside the JAR, it will look something like this:

Jahia-Source-Folders: /home/jahia/modules/assets

When a request comes in to a /modules/assets URL, Jahia will use the Jahia-Source-Folders manifest header (if present) to look for the source code of the project. If it is present, it will try to access the requested resource directly from the source folder instead of using the contents of the bundle. There are some limitations. Not all files can be directly used as some require compilation or internal caches that may interfere with the proper detection of file modifications. Here is a list of resource types that are supported with deploy-free coding:

  • JSP
  • HTML
  • Images
  • CSS
  • Javascript
  • Other static files types such as documents and text files

The following resource types are not supported:

  • Groovy files (due to the internal Groovy engine class cache)
  • Java classes
  • Java libraries

Of course, for the file types that don’t work with deploy-free coding, you can still hot deploy them using OSGi bundle redeployment. So, for those file types the deployment life cycle is a little longer but still much faster than in previous versions of Jahia.

Using deploy-free coding with a local Jahia instance

  1. Create your module’s source code project.
  2. Compile and deploy it to your Jahia server which must be on the same file system as your project. The initial deployment “links” source code with Jahia server. Note that the file system could also be a network shared file system.
  3. Modify static resources directly in your source code. Jahia will pick up the changes directly from the source. No deployment is needed.

Using deploy-free coding with a local Docker Jahia instance

It is also possible to use deploy-free coding with a local (meaning on the same host) machine, which your project outside of Docker and your Jahia instance running inside a Docker container on the same machine. The way this works is by using a mount of the local source code to a local Docker container which makes it possible to directly access changes in the source code.

The steps to use deploy-free coding are actually detailed in the first and second getting started tutorials. 

For the moment it is not recommended to use this procedure with a remote (distant) Jahia instance as performance is not very good, but you could get it working by using a shared file system between the Docker host and the machine that is hosting the project. In our testing this setup has resulted in poor performance because of the amount of small files in such a project but we do want to mention its existence for exhaustivity.