Configuring Liferay Workspace
Liferay Workspace is simple to use, and you can learn the basics by starting at the beginning. If you’re happily creating projects, deploying code, or using a Docker container, you may not need the information here. If, however, you want to do a deep dive and learn about all the things Workspace can do, this is the place for you.
Here are the topics covered:
- Updating Liferay Workspace and Bundled Plugins
- Using Development, UAT, and production environments
- Managing the Target Platform
Updating Liferay Workspace and Bundled Plugins
Liferay Workspace is constantly updated to help developers be more productive, and bringing your Workspace up to date is a painless process.
-
Go to Workspace’s releases on Liferay’s repository. The versions appear in a list; take note of the version number you need.
-
Open the
settings.gradle
file in your Workspace’s root folder. -
In the
dependencies
block, update the version with the version you found in the repository. If you want to stay on the latest release, supply the textlatest.release
instead of the version number.dependencies { classpath group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "[WORKSPACE_VERSION]" }
-
Save and close the file. To run the upgrade, execute any Gradle command, such as
tasks
:./gradlew tasks
Congratulations! Your Workspace is now upgraded.
Updating Your Liferay Version
You may want to update the version of Liferay that Workspace compiles for. This is handled by a single property:
liferay.workspace.product=portal-7.4-ga120
Update the property’s value to the version of Liferay for which you’re developing code. Your workspace’s dependencies are then automatically updated to the new version.
Using JDKs 11, 17, or 21
As of Liferay DXP 2024.Q2+/Portal 7.4 GA120+, Liferay supports JDK 17 and 21. JDK 8 is out of support, and JDK 11 is deprecated.
If you compile under a JDK, you must run under that same JDK. Make sure your app servers are running under the new JDK before making any changes to Workspace. Note that Liferay’s Docker images still use JDK 8 by default and have not been updated with JDK 17 or 21. Create your Docker image using the -e JAVA_VERSION=zulu11
environment variable to use a supported JDK.
Prerequisite: If you’re using an older version of Workspace, you must upgrade two things:
- Update Gradle to version 8.5
- Update your Workspace version to at least 10.1.0 (see above for upgrade procedure).
To upgrade Gradle, edit the gradle/wrapper/gradle-wrapper.properties
file in your Workspace:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
If you upgraded your Workspace too, make sure you have the liferay.workspace.product
property set. Remember, you can always get a current list for this property using Blade CLI by typing blade init -l
.
If you upgraded an older workspace, make sure the Liferay CDN is declared in your Workspace’s settings.gradle
file:
maven {
url "http://repository.liferay.com/nexus/content/groups/public"
}
Great! You’re now ready to use JDKs newer than Java 8 with your Liferay projects. If you have existing projects, there are additional steps you must take.
Service Builder Projects
If you upgraded an older Workspace with Service Builder projects, add this configuration to the build.gradle
file in the Service Builder -service
module:
tasks.withType(JavaCompile) {
// Generated classes using Jodd library are unable to be read when compiled against JDK 11
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
JAX-WS Projects
If you have any JAX-WS projects, they require classes from javax.xml.soap
which were removed from JDK 11. Now you must specify them as a dependency manually:
compile 'com.sun.xml.ws:jaxws-ri:2.3.2'
Managing the Target Platform
Normally when defining Gradle dependencies, you must provide versions of those dependencies, like this:
dependencies {
compileOnly group: "javax.portlet", name: "portlet-api", version: "3.0.1"
compileOnly group: "javax.servlet", name: "javax.servlet-api", version: "4.0.1"
}
Since any application written on Liferay’s platform targets that platform, Liferay has made it easy for you to specify all dependencies in one shot by declaring the version of Liferay and then inheriting other dependencies from Liferay. That way, you don’t have the mess shown above.
Target platform is enabled by default; there’s nothing extra to do to use it. Here’s what most dependencies look like now:
dependencies {
compileOnly group: "com.liferay.portal", name: "release.portal.api"
}
This brings in all the dependencies that come with Liferay. If for some reason you must specify a particular dependency, you still can:
dependencies {
compileOnly group: "com.liferay.portal", name: "release.portal.api"
cssBuilder group: "com.liferay", name: "com.liferay.css.builder", version: "3.0.2"
}