The DB Support Gradle plugin lets you run the Liferay DB Support tool to execute certain actions on a local Liferay database. So far, the following actions are available:
- Cleans the Liferay database from the Service Builder tables and rows of a module.
The plugin has been successfully tested with Gradle 4.10.2.
Usage
To use the plugin, include it in your build script:
buildscript {
dependencies {
classpath group: "com.liferay", name: "com.liferay.gradle.plugins.db.support", version: "1.0.5"
}
repositories {
maven {
url "https://repository-cdn.liferay.com/nexus/content/groups/public"
}
}
}
apply plugin: "com.liferay.portal.tools.db.support"
Since the plugin automatically resolves the Liferay DB Support library as a dependency, you have to configure a repository that hosts the library and its transitive dependencies. The Liferay CDN repository hosts them all:
repositories {
maven {
url "https://repository-cdn.liferay.com/nexus/content/groups/public"
}
}
Tasks
The plugin adds one task to your project:
Name | Depends On | Type | Description |
---|---|---|---|
cleanServiceBuilder | - | CleanServiceBuilderTask | Cleans the Liferay database from the Service Builder tables and rows of a module. |
The cleanServiceBuilder
task is automatically configured with sensible
defaults, depending on whether the base
plugin is applied:
Property Name | Default Value |
---|---|
servletContextName | If the Otherwise: |
serviceXmlFile | "${project.projectDir}/service.xml" |
CleanServiceBuilderTask
Tasks of type BuildDeploymentHelperTask
extend JavaExec
,
so all its properties and methods, such as args
and maxHeapSize
,
are available. They also have the following properties set by default:
Property Name | Default Value |
---|---|
args | The DB Support command line arguments. |
classpath | project.configurations.dbSupport + project.configurations.dbSupportTool |
main | "com.liferay.portal.tools.db.support.DBSupport" |
Task Properties
Property Name | Type | Default Value | Description |
---|---|---|---|
password | String | null | The user password for connecting to the Liferay database. It sets the --password argument. If propertiesFile is set, this property has no effect. |
propertiesFile | File | null | The portal-ext.properties file that contains the JDBC settings for connecting to the Liferay database. It sets the --properties-file argument. |
servletContextName | String | null | The servlet context name (usually the value of the Bundle-Symbolic-Name manifest header) of the module. It sets the --servlet-context-name argument. |
serviceXmlFile | File | null | The service.xml file of the module. It sets the --service-xml-file argument. |
url | String | null | The JDBC URL for connecting to the Liferay database. It sets the --url argument. If propertiesFile is set, this property has no effect. |
userName | String | null | The user name for connecting to the Liferay database. It sets the --user-name argument. If propertiesFile is set, this property has no effect. |
The properties of type File
support any type that can be resolved by project.file
.
Moreover, it is possible to use Closures and Callables as values for the int
and String
properties to defer evaluation until task execution.
Additional Configuration
There are additional configurations that can help you use the Deployment Helper.
JDBC Drivers Dependency
The plugin creates a configuration called dbSupport
, which can be used to
provide the suitable JDBC driver for your Liferay database:
dependencies {
dbSupport group: "mysql", name: "mysql-connector-java", version: "5.1.23"
dbSupport group: "org.mariadb.jdbc", name: "mariadb-java-client", version: "1.1.9"
dbSupport group: "org.postgresql", name: "postgresql", version: "9.4-1201-jdbc41"
}
Liferay DB Support Dependency
By default, the plugin creates a configuration called dbSupportTool
and adds a
dependency to the latest released version of the Liferay DB Support. It is
possible to override this setting and use a specific version of the tool by
manually adding a dependency to the dbSupportTool
configuration:
dependencies {
dbSupportTool group: "com.liferay", name: "com.liferay.portal.tools.db.support", version: "1.0.8"
}