Specifying Dependencies

Compiling your project and deploying it to Liferay DXP requires satisfying its dependencies on external artifacts. After finding the attributes of an artifact, set a dependency for it in your build file. Here’s how:

  1. Determine whether Liferay DXP provides the Java packages you use from the artifact. These files list the packages Liferay DXP exports:

    • modules/core/portal-bootstrap/system.packages.extra.bnd file in the GitHub repository. It lists exported packages on separate lines, making them easy to read.

    • META-INF/system.packages.extra.mf file in [LIFERAY_HOME]/osgi/core/com.liferay.portal.bootstrap.jar. The file is available in Liferay DXP bundles. It lists exported packages in a paragraph wrapped at 70 columns–they’re harder to read here than in the system.packages.extra.bnd file.

  2. If Liferay DXP exports all the packages you use from the artifact, specify the artifact as a compile-only dependency. This prevents your build framework from bundling the artifact with your project. Here’s how to make the dependency compile-only:

    Gradle: Add the compileOnly directive to the dependency

    Maven: Add the <scope>provided</scope> element to the dependency.

  3. Add a dependency entry for the artifact. Here’s the artifact terminology for the Gradle and Maven build frameworks:

Artifact Terminology

FrameworkGroup IDArtifact IDVersion

Here is an example dependency on Liferay’s Journal API module for Gradle, and Maven:

Gradle (build.gradle entry):

dependencies {
    compileOnly group: "com.liferay", name: "com.liferay.journal.api", version: "1.0.1"

Maven (pom.xml entry):


Nice! You know how to specify artifact dependencies. Now that’s a skill you can depend on!

Finding Artifacts

Importing Packages

Exporting Packages

Resolving Third Party Library Package Dependencies

Deploying WARs (WAB Generator)

« Finding ArtifactsResolving Third Party Library Package Dependencies »
Was this article helpful?
0 out of 0 found this helpful