Skip to content

Liferay Workspace

Liferay Workspace is a predefined project structure that simplifies Liferay module development, providing:

  • Standardized directory layout
  • Built-in Gradle support
  • Environment configuration management
  • Deployment automation
  • Tooling integration
liferay-workspace/
├── configs/ # Environment configurations
│ ├── common/
│ ├── dev/
│ └── prod/
├── gradle/ # Gradle wrapper files
├── modules/ # Custom modules
│ ├── apps/
│ ├── core/
│ └── themes/
├── plugins-sdk/ # Legacy plugins (if needed)
├── build.gradle # Main build file
├── gradle.properties # Gradle properties
├── gradlew # Gradle wrapper (Unix)
└── gradlew.bat # Gradle wrapper (Windows)
  • configs/ folder holds environment-specific configurations
  • Automatically applies settings based on active profile (-Pliferay.workspace.environment=dev)
  • Logical separation of module types (apps, core, themes)
  • Supports multiple module projects within one workspace
  • Preconfigured build scripts
  • Dependency management
  • Liferay-specific tasks
  1. Install prerequisites:

    • Java JDK 8/11
    • Gradle (or use wrapper)
    • Liferay Blade CLI
  2. Create workspace:

    Terminal window
    blade init -v 7.4 my-liferay-workspace
  3. Import into IDE:

    • IntelliJ: Open as Gradle project
    • Eclipse: Import Gradle project
  • Group related modules together
  • Use clear naming conventions
  • Separate by functionality (not by technical layer)
  • Use build.gradle for common dependencies
  • Leverage BOM (Bill of Materials) for version alignment:
    dependencies {
    compileOnly group: "com.liferay", name: "com.liferay.portal.kernel"
    compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
    }
  • Keep environment-specific settings in configs/
  • Use separate configurations for DB, portal properties, etc.
  • Example structure:
    configs/
    ├── dev/
    │ ├── portal-ext.properties
    │ └── osgi/
    └── prod/
    ├── portal-ext.properties
    └── osgi/
  • Use Gradle’s incremental builds
  • Configure parallel execution in gradle.properties:
    org.gradle.parallel=true
    org.gradle.daemon=true
  • Include in VCS:
    • build.gradle
    • gradle.properties
    • configs/ (without secrets)
  • Exclude:
    • build/ folders
    • .gradle/
    • Local deployment artifacts
TaskDescription
gradle deployDeploy all modules to Liferay
gradle buildBuild all modules
gradle cleanClean build artifacts
gradle formatSourceFormat Java sources
gradle checkFormatVerify source formatting
gradle testRun unit tests
gradle watchContinuous deployment mode
liferay.workspace.bundle.url=https://releases-cdn.liferay.com/portal/7.4.3.4-ga4/liferay-ce-portal-tomcat-7.4.3.4-ga4-20210419214101527.tar.gz
liferay.workspace.home.dir=/path/to/bundles
liferay.workspace.modules.dir=modules
liferay.workspace.themes.dir=themes
subprojects {
apply plugin: "com.liferay.plugin"
dependencies {
compileOnly group: "com.liferay", name: "com.liferay.portal.kernel"
compileOnly group: "org.osgi", name: "osgi.cmpn"
}
repositories {
maven {
url "https://repository.liferay.com/nexus/content/groups/public"
}
}
}
settings.gradle
include 'modules:apps:my-app', 'modules:core:my-core'
sourceSets {
main {
resources {
srcDirs += ["src/main/resources", "../configs/common"]
}
}
}
Terminal window
./gradlew build -Pliferay.workspace.environment=prod
task buildDockerImage(type: Exec) {
commandLine 'docker', 'build', '-t', 'my-liferay-app', '.'
}
  1. Deployment Issues:

    • Check [LIFERAY_HOME]/osgi/logs
    • Verify bundle status with blade sh lb
  2. Build Failures:

    • Run with --stacktrace flag
    • Check dependency versions
  3. Module Not Found:

    • Verify settings.gradle includes the module
    • Check module directory structure

Liferay Workspace with Gradle provides:

  • Standardized project structure
  • Simplified build configuration
  • Environment management
  • Powerful development tools

Best practices include:

  • Logical module organization
  • Proper environment separation
  • Consistent dependency management
  • Leveraging Blade CLI for productivity

The combination of Liferay Workspace, Gradle, and Blade CLI creates a powerful development environment for building modular, maintainable Liferay applications.