In a normal update you align the project configuration with the latest version of Magnolia and its modules. In migration from Magnolia 4.4.x to 4.5.x, however, a huge amount of new features and changes have been implemented. Therefore a lot more code has to be adopted.
Please read Update configuration and code before you begin to gain a better understanding of the required steps.
Goal
Compile your own project code against Magnolia 4.5 code.
- Update your POM files. Keep in mind that some modules are deprecated and should be removed while some are new and must be added.
- Update your versions in the project module
- Add a version handler to your project
Update configuration
Version of Magnolia
Checkout the project dependencies and update the pom.xml files.
Adapt the parent pom project, update to Magnolia version 4.5.15 and STK to 2.0.16
<properties> <magnoliaVersion>4.5.24</magnoliaVersion> <stkVersion>2.0.22</stkVersion> <javaVersion>1.6</javaVersion> </properties>
Add the dependency for the migration module to your POM.xml as it will help you later to identify outdated code, templates and configuration.
<dependency> <groupId>info.magnolia</groupId> <artifactId>magnolia-4-5-migration</artifactId> <version>1.2.9</version> </dependency>
Also update your model descriptor with the new dependency.
<dependency> <name>magnolia-4-5-migration</name> <version>1.2.9/*</version> </dependency>
Remove magnolia-module-templating
in ./update-training-44-module/pom.xml
and ./pom.xml
You could replace magnolia-module-templating
by magnolia-templating-compatibility.
Then the code compiles but you would not be able to see the code that needs changes.
Don't forget the module descriptor
Version of Magnolia
The current version of the training uses Magnolia 4.5.24, STK-2.0.22 and Migration-1.2.9.
Update code
After you removed magnolia-module-templating in your pom.xml you should see some errors in your IDE because some legacy dependencies can't be removed anymore. You should update your code now with the new Magnolia 4.5 classes.
In NavigationParagraphDefinition
:
- Exchange
Paragraph
withConfiguredTemplateDefinition
In NavigationParagraphModel
:
In Magnolia 4.5 the RenderingModel was extended with RendableDefinition. Your class declaration should look like this:
public class NavigationParagraphModel<RD extends RenderableDefinition> extends RenderingModelImpl<RD>
- Update the constructor. Check the inherited class.
Replace
Content
with javax.jcr.Node
and use the new API. You can acquire the node in your constructor via the javax.jcr.Session object. One way to fetch it is the MgnlContext.getJCRSession method.
Add a delta to the version handler
Update the module descriptor
Add delta tasks to the provided UpdateTrainingModuleVersionHandler class. The following Tasks are needed: SimpleSTKRelatedModuleMigrationTask to update the site definition and ContentModuleMigrationTask to handle changes in website content.
Checkout Git
Nothing works? Just checkout Git and get an updated project.
$ git checkout -t origin/Ex2-UpdateYourProject // or if the branches already exist locally $ git checkout Ex2-UpdateYourProject
You will receive the updated project with:
- Updated POM files
- Updated module descriptor
- A version handler for the project
1 Comment
Fadi Wissa
When I checkout the Ex2-UpdateYourProject branch, the ./pom.xml file still contains the magnolia-module-templating dependency although the steps above ask us to remove it!
Why is this so?
(Check lines 60-63 here: pom.xml of Ex2-UpdateYourProject)