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:
-
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 thesystem.packages.extra.bnd
file.
-
-
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 dependencyMaven: Add the
<scope>provided</scope>
element to the dependency. -
Add a dependency entry for the artifact. Here’s the artifact terminology for the Gradle and Maven build frameworks:
Artifact Terminology
Framework | Group ID | Artifact ID | Version |
---|---|---|---|
Gradle | group | name | version |
Maven | groupId | artifactId | version |
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):
<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.journal.api</artifactId>
<version>1.0.1</version>
<scope>provided</scope>
</dependency>
Nice! You know how to specify artifact dependencies. Now that’s a skill you can depend on!