OpenOffice Gradle Integration

From Apache OpenOffice Wiki
Jump to: navigation, search


Gradle is a modern build framework for Java and Apache Groovy applications and is released under the Apache 2.0 License. Gradle build scripts are written in Groovy rather than XML. Gradle manages the project dependencies which are fetched from local or remote Maven or Ivy repositories or Gradle can use local files as well.

There a few parallel efforts to this with the first being a Groovy UNO Extension that adds convenience methods to the Java UNO API's that allow much less code when using Groovy compared to Java.

The second effort is Lazybones templates to create Gradle build based UNO Extensions. Lazybones is a project creation tool that allows you to create a new project structure for any framework or library for which the tool has a template. The first and only template completed so far is for an OpenOffice Client. Lazybones is release under the Apache 2.0 License.

Once the project is created you should be able to use any Gradle capable IDE for editing.

Getting Started

Getting the ToolChain

A convenient method of getting Gradle, Groovy, and Lazybones is to use SdkMan. SdkMan is a tool for managing parallel versions of multiple Software Development Kits on most Unix based systems. It provides a convenient Command Line Interface (CLI) and API for installing, switching, removing and listing Candidates. SdkMan is released under the Apache 2.0 License.

On UNIX based machines enter the following at the command prompt:

   curl -s | bash 

See the SdkMan website for a link to a windows version.

To install the latest version of Lazybones:

   sdk install lazybones

Repeat if needed for Groovy and Gradle:

   sdk install groovy
   sdk install gradle

See SdkMan Usage for all SdkMan commands to list and change default versions. Current versions are:

  • gradle: 2.7
  • groovy: 2.4.5
  • lazybones: 0.8.1

Getting the Source Code

The source can be checked out of the Apache SVN repository. Use "http" for read-only access and committers can use "https".

From the parent directory where you want the working copies.

Checkout the Groovy UNO Extension:

   svn co guno-extension

Check out the Lazybones Templates:

   svn co lazybones-templates

Building the Groovy Extension

From the guno-extension directory:

  gradle jar

This will run the gradle tasks clean, compileJava, compileGroovy, processResources, classes, groovydoc, and jar.
The jar file will be in ./build/libs and HTML GroovyDocs files in ./build/docs/groovydoc and are similar to JavaDoc files.

Installing the Templates

Until the templates are made available on Bintray the templates can be installed into the local lazybones cache.
From the lazybones-templates directory:

   gradle installTemplateAooClient

Verify the template is available:

   lazybones list --cached

Creating an UNO Client Application

From a parent directory where you want to create the application:
lazybones create <template> <template-version> <project-dir> where project-dir can be CamelCase or hyphenated.

   lazybones create aoo-client 0.1.0 TestClient

You will be prompted for group, artifactId, version, package, and classname. Group and package will normally be the same. ArtifactId is a hyphenated version of the project name and className is CamelCase.

   Creating project from template aoo-client 0.1.0 in 'TestClient'
   Define value for 'group' [org.example]: 
   Define value for 'artifactId' [test-client]: 
   Define value for 'version' [0.1.0]: 
   Define value for 'package' [org.example]: 
   Define value for 'className' [TestClient]: 

Edit the ./<project-dir>/build.gradle file and update the location and version number of the guno-extension.jar in the file. To run the extension from the project directory:

   gradle runJar

Using the Groovy UNO Extension

See Groovy_UNO_Extension

Further Development

Bugzilla Issue 126770 has been created to capture additional work on these efforts.

Personal tools