Include Versions or Not?

When using the Target Platform, sometimes you need the version, sometimes you don't.

Just a quick post today...

So I've been using the Target Platform like all the time now. I don't want to have to worry about versions, especially those Liferay modules that change version numbers on every fix pack...

However, I've found that sometimes the version numbers just aren't there. But often I only find this out after I've stripped out the version and tried a build.

My friend Greg Amerson shared a trick with me today to help figure out if I can strip the versions or not, and I wanted to share it with you...

So, assuming you've enabled the target platform in your gradle.properties file in the root of your workspace, you can issue the following command:

$ gradlew dependencyManagement | grep osgi.service.component
<-------------> 0% EXECUTING [0s]
> :modules:headless-vitamins-test:dependencyManagement
    org.osgi:org.osgi.service.component.annotations 1.3.0
    org.osgi:org.osgi.service.component.annotations 1.3.0

If you get a match for what you're looking for, then you don't need to specify the version.

If you don't get a match, then the version is not available in the target platform BOMs and you will need to include the version in your dependency list.

Enjoy!

Blogs

Great but it is possible in maven ? 

Yes, in your maven poms you can import the 3 Liferay BOMs located at this coordinates: com.liferay.portal:release.portal.bom:${liferayVersion} com.liferay.portal:release.portal.bom.compile.only:${liferayVersion} com.liferay.portal:release.portal.bom.third.party:${liferayVersion}