DB Support Gradle Plugin

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:

NameDepends OnTypeDescription
cleanServiceBuilder-CleanServiceBuilderTaskCleans 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 NameDefault Value
servletContextName

If the base plugin is applied: The bundle symbolic name of the project inferred via the OsgiHelper class.

Otherwise: null

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 NameDefault Value
argsThe DB Support command line arguments.
classpathproject.configurations.dbSupport + project.configurations.dbSupportTool
main"com.liferay.portal.tools.db.support.DBSupport"

Task Properties

Property NameTypeDefault ValueDescription
passwordStringnullThe user password for connecting to the Liferay database. It sets the --password argument. If propertiesFile is set, this property has no effect.
propertiesFileFilenullThe portal-ext.properties file that contains the JDBC settings for connecting to the Liferay database. It sets the --properties-file argument.
servletContextNameStringnullThe servlet context name (usually the value of the Bundle-Symbolic-Name manifest header) of the module. It sets the --servlet-context-name argument.
serviceXmlFileFilenullThe service.xml file of the module. It sets the --service-xml-file argument.
urlStringnullThe JDBC URL for connecting to the Liferay database. It sets the --url argument. If propertiesFile is set, this property has no effect.
userNameStringnullThe 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"
}
« CSS Builder Gradle PluginDependency Checker Gradle Plugin »
この記事は役に立ちましたか?
0人中0人がこの記事が役に立ったと言っています