dx-sync-module synchronizes changes in files with Magnolia repositories.
Also it provides a set of tasks and strategies for updating Magnolia resources. 

It allows to edit templates scripts, CSS, JavaScript and other files directly from IDE or editor of your choice. Changes are instantly propagated to Magnolia repositories of a running Magnolia instance.
So you can preview your changes on the website as soon as you save your files.

Content

Supported resource types

The following resource types are supported at the moment:

Initial setup

Download the latest module version.
Note: it is going to be available as a Maven artefact soon.

Download

dx-sync-module-1.1.1.jar
dx-sync-module-1.1.1-sources.jar 

Install

First, you need to install jnotify http://jnotify.sourceforge.net/ library to your servlet container, including both java and native library parts.
This library is used to get notifications from the file system about file updates.
You can download it from here:

If you use Tomcat you can:

Steps are very similar for other servlet containers.

Then you need to add dx-sync-module to your project.
If you're going to use File-based configuration, you can just put dx-sync-module.jar to Magnolia'a WEB-INF/lib directory.
If you need advanced features, including DxModuleVersionHandler, you need to add dx-sync-module to your project. 
Put dx-sync-module to your local Maven repository:

mvn install:install-file -DgroupId=com.devexperts.web -DartifactId=dx-sync-module -Dversion=1.1.1 -Dpackaging=jar -Dfile=dx-sync-module-1.1.1.jar -DgeneratePom=true
mvn install:install-file -DgroupId=com.devexperts.web -DartifactId=dx-sync-module -Dversion=1.1.1 -Dpackaging=jar -Dclassifier=sources -Dfile=dx-sync-module-1.1.1-sources.jar -DgeneratePom=false

Add the following dependency to your Maven project:

<dependency>
<groupId>com.devexperts.web</groupId>
<artifactId>dx-sync-module</artifactId>
<version>1.1.1</version>
</dependency>
Configuration
Version Handler based configuration

You can specify resources which are to be synchronized in version handler for your module. 
In this case

  1. Specify DxModuleVersionHandler as a base class of your module version handler 
  2. Pass folder where your module is placed as a parameter to the DxModuleVersionHanlder constructor.
  3. Specify resources which need synchronization in your module version handler constuctor.

For example:

super("web-devspace");
keepUpToDateResources("/mgnl-files", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.MGNL_FILE);
keepUpToDateResources("/abc/img", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.DMS_FILE);
keepUpToDateResources("/abc/themes/img", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.DMS_FILE);
keepUpToDateResources("/dev/docs", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.DMS_FILE);
keepUpToDateResources("/abc/js", Scope.FOLDER_ONLY, ResourceType.RESOURCE_PROCESSED_JS);
keepUpToDateResources("/abc/js", Scope.SUBFOLDERS_ONLY, ResourceType.RESOURCE_JS);
keepUpToDateResources("/abc/themes/abc/css", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.RESOURCE_PROCESSED_CSS);
keepUpToDateResources("/abc/emails", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.TEMPLATE);
keepUpToDateResources("/abc/paragraphs", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.TEMPLATE);
keepUpToDateResources("/abc/templates", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.TEMPLATE);
keepUpToDateResources("/search-module/templates", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.TEMPLATE);
keepUpToDateResources("/abc/groovy", Scope.FOLDER_AND_SUBFOLDERS, ResourceType.GROOVY_SCRIPT);

 

File-based configuration

You can specify which files are to be synchronized in a configuration file.
Synchronization is performed on a directory basis. Each directory that is needed synchronization should be listed in the configuration file.

Example configuration file: 

# Line format is:
#    source path, scope, recource type, destination path                                                               \
# Possible scopes are:
# - FOLDER_AND_SUBFOLDERS
# - FOLDER_ONLY
# - SUBFOLDERS_ONLY
# Possible resource types are:
# - MGNL_FILE
# - GROOVY_CLASS
# - GROOVY_SCRIPT
# - DMS_FILE
# - DMS_ZIP
# - RESOURCE_JS
# - RESOURCE_PROCESSED_JS
# - RESOURCE_CSS
# - RESOURCE_PROCESSED_CSS
# - TEMPLATE
 
# test javadoc link 
web-devspace\docs, FOLDER_ONLY, DMS_ZIP, /dev/apidocs
# test downloads
web-devspace\resources\downloads, FOLDER_AND_SUBFOLDERS, DMS_FILE, /dev/downloads

2 parameters should be specified for this module.

Specify them by adding -Ddx.sync.sources=<path to source files root> -Ddx.sync.config=<path to configuration file> to the JVM startup command line.
License 

The module is released under GPL license. Contact us if you need this module under different license.

Questions

We really appreciate your feedback, feature requests, bug reports or any kind of comments. 
Contact us at avasiliev@devexperts.com