Thursday, December 3, 2015

Build automation in Magnolia project


In my current Magnolia project, we want to automate the build process. To make sure QA certified build getting promoted to the next environment, we want build once deploy anywhere (environment agnostic WAR file). As part of presentation tier, main challenge what he had was environment specific property file inside the WAR file. (You can visualize something like base URLs, third party touch points URL etc in this file). We had two types of property files in the project.

  1. Magnolia specific configuration property files
  2. Application specific property files
Magnolia specific property:


Magnolia's main listener MgnlServletContextListener reads initialization parameters for each webapp from magnolia.properties files. By default, the listener looks for properties files in these locations:

WEB-INF/config/${servername}/${contextPath}/magnolia.properties,
WEB-INF/config/${servername}/${webapp}/magnolia.properties,
WEB-INF/config/${servername}/magnolia.properties,
WEB-INF/config/${contextPath}/magnolia.properties,
WEB-INF/config/${webapp}/magnolia.properties,
WEB-INF/config/default/magnolia.properties,
WEB-INF/config/magnolia.properties

These properties files are in the WEB-INF/config directory inside the WAR. You can configure alternative file names and locations by setting the magnolia.initialization.file context parameter in web.xml.
<context-param>
   <param-name>magnolia.initialization.file</param-name>
   <param-value>
      WEB-INF/config/dev.mysite.com/magnoliaAuthor/magnolia.properties,
      WEB-INF/config/default/magnolia.properties,
      WEB-INF/config/magnolia.properties
   </param-value>
</context-param>

In this way, you can extract it out all magnolia specific properties outside the webapp. Though it will be part of your version control, it won't be bundled.and it stays there for version purpose only.

Note: You have to manually copy/write a script to copy these properties in the configured folder whenever there is a change. In reality, this file won't be changed much unless you do something drastically different than your previous versions.

I will cover application specific property in my next post