- Is there any way to programmatically load LAR files out of the box?
- All Liferay Versions
- At this time there is no out-of-the-box method for auto-deploying LAR files.
- LAR files cannot be imported via the auto deploy folder either, only through the UI export/import menu.
With that said please see the following potential alternatives firstly noting this liferay developer's blog which covers the important points for consideration when using LAR files.
One option you could try are 'internal APIs' (for example, if you deploy your own module to Liferay and make the appropriate API calls there). You can see a sample of what that code looks like inside of GroupLocalServiceImpl.java#L4028-L4063
A second option you could also try are 'remote APIs'. If you search your bundle for /api/jsonws for a method named import-layouts, you’ll find two methods which theoretically allow the import of a LAR, provided the right objects are passed to allow the import to happen.
Further Considerations (As automating the LAR import process may depend on a variety of factors, including, but not limited to):
- Whether it’s a one-time site initialization or continuous updates (CI/CD Pipeline)
- Whether there is an upgrade plan that accounts for LAR files not being compatible across versions
- The row-locking and table-locking characteristics of the database in use
- How long the LAR import takes to complete