XSD Builder Gradle Plugin

The XSD Builder Gradle plugin lets you generate Apache XMLBeans bindings from XML Schema (XSD) files.

The plugin has been successfully tested with Gradle 4.10.2.


To use the plugin, include it in your build script:

buildscript {
    dependencies {
        classpath group: "com.liferay", name: "com.liferay.gradle.plugins.xsd.builder", version: "1.0.7"

    repositories {
        maven {
            url "https://repository-cdn.liferay.com/nexus/content/groups/public"

apply plugin: "com.liferay.xsd.builder"

The XSD Builder plugin automatically applies the java plugin.

Since the plugin automatically resolves the Liferay Service Builder 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"


The plugin adds three tasks to your project:

NameDepends OnTypeDescription
buildXSDbuildXSDCompileBuildXSDTaskGenerates XMLBeans bindings and compiles them in a JAR file.
buildXSDGeneratecleanBuildXSDGenerateJavaExecInvokes the XMLBeans Schema Compiler to generate Java types from XML Schema.
buildXSDCompilebuildXSDGenerate, cleanBuildXSDCompileJavaCompileCompiles the generated Java types.

By default, the buildXSD task looks for XSD files in the ${project.projectDir}/xsd directory, and saves the generated JAR file as ${project.projectDir}/lib/${project.archivesBaseName}-xbean.jar.

If the war plugin is applied, the task looks for XSD files in the ${project.webAppDir}/WEB-INF/xsd directory, and saves the generated JAR file as ${project.webAppDir}/WEB-INF/lib/${project.archivesBaseName}-xbean.jar.


Tasks of type BuildXSDTask extend Zip. They also have the following properties set by default:

Property NameDefault Value

For each task of type BuildXSDTask, the following helper tasks are created:

  • ${buildXSDTask.name}Compile
  • ${buildXSDTask.name}Generate

Task Properties

Property NameTypeDefault ValueDescription
inputDirFilenullA directory containing XSD files from which to generate Apache XMLBeans bindings.

The properties of type File support any type that can be resolved by project.file.

Additional Configuration

There are additional configurations that can help you use the XSD Builder.

Apache XMLBeans Dependency

By default, the XSD Builder Gradle plugin creates a configuration called xsdBuilder and adds a dependency to the 2.5.0 version of Apache XMLBeans. It is possible to override this setting and use a specific version of the library by manually adding a dependency to the xsdBuilder configuration:

dependencies {
    xsdBuilder group: "org.apache.xmlbeans", name: "xmlbeans", version: "2.6.0"
« XML Formatter Gradle PluginFelix Gogo Shell »
Este artigo foi útil?
Utilizadores que acharam útil: 0 de 0