Liferay Target Platform

Enabling the Target Platform

What is the Target Platform?

Target Platform is a set of Maven's BOMs, which define all the exposed artifacts (Liferay's and third-party ones) in a specific Liferay version. Those BOMs are listed here.

Why we need it?

You need target platform for dependencies versions management: this way you don't worry about the specific library versions, and just use the ones Liferay exposes.
For example, when you use target platform - Gradle dependencies, like:
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "4.4.0"
compileOnly group: "com.liferay", name: "com.liferay.journal.api", version: "4.2.0"
compileOnly group: "com.liferay", name: "com.liferay.journal.service", version: "5.0.18"
compileOnly group: "com.liferay", name: "com.liferay.dynamic.data.mapping.api", version: "5.2.0"
will become just:
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compileOnly group: "com.liferay", name: "com.liferay.journal.api"
compileOnly group: "com.liferay", name: "com.liferay.journal.service"
compileOnly group: "com.liferay", name: "com.liferay.dynamic.data.mapping.api"
(you don't define versions, the ones from BOM will be used in this case).
This gives you several benefits:
  • you save time, because you don't spent it for finding the correct versions; 
  • you don't get unexpected errors (both compile and runtime) due to wrongly defined versions; 
  • if you'll need to migrate project to future Liferay versions - you'll not need to update those library versions manually.

How to enable the Target platform?

To enabled target platform in your Gradle workspace - add to gradle.properties:
liferay.workspace.target.platform.version=7.3.0
Define the version, you need here. Currently the latest one is 7.3.0.
The list of versions is available here.
If you need to check the individual library version - open the appropriate POM (sample: 7.3.0.pom), and check it there.
Once target platform is enabled - you may omit the versions in your dependencies declarations. Just make sure dependency you include is present in the BOM for your Liferay version.
Enjoy 😏

Comments

Popular posts from this blog

Liferay Search Container Example

Liferay DXP - max upload file size

Liferay Keycloak integration