mavenliferayliferay-7liferay-7.1

Liferay versions and correct dependencies


I'm rather new to Liferay, Maven and Java so it may be more of a general question about dependencies. I am maintaining a Liferay portlet that has been migrated from 6.2 to 7.1 and there are a number of Liferay maven dependencies with version numbers (eg. com.liferay.portal.kernel).

How does one know which versions of these dependencies one is to use for the version of the product that they are using?

Is this a typical case where one should always be trying to use the most recent version of dependencies even if the version of the product is a minor release behind?


Solution

  • Probably the easiest thing to do to make sure you compile agains JAR version that is in your target environment is to use the respective BOM (bill of material).

    You can have a look at this code sample's POM for Liferay Portal 7.2 for example. Note the dependencyManagement that indicates which BOM to use:

        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>com.liferay.portal</groupId>
                    <artifactId>release.portal.bom</artifactId>
                    <version>${portal.version}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>
    

    Then note how the actual dependency for com.liferay.portal.kernel JAR does not have a version specified.

            <dependency>
                <groupId>com.liferay.portal</groupId>
                <artifactId>com.liferay.portal.kernel</artifactId>
            </dependency>
    

    The JAR version will be taken from the BOM which ensures it will match with the one the given version of Liferay Portal contains.

    For comparison, here is the exact same POM but for Liferay Portal 7.1. As you can see the only difference is the portal.version property.