Explore the capabilities of Liferay's SiteInitializer interface. Implementation based on the model of
- https://github.com/liferay/liferay-portal/tree/master/modules/apps/frontend-theme-fjord/frontend-theme-fjord-site-initializer
- https://github.com/liferay/com-liferay-commerce/tree/7.1.x/commerce-theme-minium/commerce-theme-minium-site-initializer
- https://github.com/liferay/com-liferay-commerce/tree/7.1.x/commerce-theme-speedwell/commerce-theme-speedwell-site-initializer
- Add
compileOnly group: "com.liferay", name: "com.liferay.site.api"
dependency inbuild.gradle
in order to use thecom.liferay.site.initializer.SiteInitializer
interface - Add
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
dependency inbuild.gradle
in order to usecom.liferay.site.exception.InitializationException
etc. - Add
compileOnly group: "com.liferay", name: "com.liferay.petra.string"
dependency inbuild.gradle
in order to usecom.liferay.petra.string.StringPool
et al. - (Optional) Add
compileOnly group: "javax.servlet", name: "javax.servlet-api"
in order to usejavax.servlet.ServletContext
+
any Liferay API modules you need to initialize your theme site, e.g.com.liferay.fragment.api
,com.liferay.layout.api
, etc.
- Break down initialization tasks into manageable private helper methods, e.g.
_createServiceContext
, ... - Wrap initialization code with a try-catch block, catch any
Exception
that might occur and throw anInitializationException
.
After you have deployed the module to your server, you should see a message like the following in your server's log:
2020-01-03 10:16:09.676 INFO [pipe-start 1113][BundleStartStopLogger:39] STARTED com.chberndt.liferay.site.initializer_1.0.0 [1113]
git clone git@github.com:chrberndt/liferay-site-initializer.git
into$WORKSPACE_HOME/modules
- Refresh the liferay-workspace with Gradle → Refresh Gradle Project (
CTRL + F5
) - ...
- Create a directory
$WORKSPACE_HOME/configs/local/deploy
- Store your (developer) license in
$WORKSPACE_HOME/configs/local/deploy
so that it gets automatically deployed whenever you run theinitBundle
task
Version: 3.7.1.201910160309-ga2
liferay.workspace.bundle.token.download=true
liferay.workspace.bundle.url=https://api.liferay.com/downloads/portal/7.2.10.1/liferay-dxp-tomcat-7.2.10.1-sp1-20191009103614075.7z
liferay.workspace.target.platform.version=7.2.10.1
buildscript {
dependencies {
classpath group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "2.1.5"
classpath group: "net.saliman", name: "gradle-properties-plugin", version: "1.4.6"
}
repositories {
maven {
url "https://repository-cdn.liferay.com/nexus/content/groups/public"
}
}
}
apply plugin: "net.saliman.properties"
apply plugin: "com.liferay.workspace"