Hi all,

For the archives, also added to 
http://wiki.magnolia-cms.com/display/WIKI/Handling+module+versions so 
comments/changes welcome:

As #getExtraInstallTasks is only invoked when Magnolia knows the version has 
changed, I've now added extracting the files from "mgnl-files" to 
#getStartupTasks. Something like: 

public class MyVersionHandler extends DefaultModuleVersionHandler {

        [..]

        /**
        * Forces extraction of the module's files, like template JSPs, from
        * <code>classes/mgnl-files</code> into the web application's root. This
        * does not yield a "Magnolia needs to be updated" screen. To avoid
        * destroying changes, Magnolia will not override files which have been
        * modified in the web application.
        * 
        * (In Magnolia, see also Tools, Development tools, to reload at 
request.)
        */
        @Override
        protected List<Task> getStartupTasks(InstallContext installContext) {
                final List<Task> tasks = new ArrayList<Task>();
                if ("SNAPSHOT".equalsIgnoreCase(installContext
                                
.getCurrentModuleDefinition().getVersion().getClassifier())) {

                        log.warn("Found SNAPSHOT release; forcing reload of 
module files."); 
                        tasks.add(new ModuleFilesExtraction());

                }
                return tasks;
        }
}

(I guess this would copy the files twice if a SNAPSHOT module is installed for 
the very first time, but I have not tested that yet.)

If one needs more than this, then maybe one could even execute all tasks 
returned by DefaultModuleVersionHandler #getBasicInstallTasks.

Cheers,
Arjan.



On Apr 29, 2010, at 2:58 PM, Matteo Pelucco wrote:

> 
> On 29.04.2010 10:29, Bert Leunis wrote:
>> Hi Arjan,
>> What I sometimes to force re-extraction of the module files is to
>> manualy lower the version number in the config (in
>> config/modules/mymodule/version), and then restart the app. The
>> versionhandler will see it has a higher version than available in the
>> repository, and bootstap the module. Be careful though: if you had
>> changed for example paragraph or dialog definitions belonging to your
>> module, and not saved those changes, they may be overwritten by the
>> bootstrap and you lose your changes.
>> Regards, Bert
> 
> We do it so, but I think you can even force file extraction (it is a 
> standard MgnlTask) if your version contains "-SNAPSHOT" placeholder.
> 
> It is a small customization of your Module class.
> 
> HTH,
> Matteo
> 
> 
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <[email protected]>
> ----------------------------------------------------------------
> 


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to