Skip to content
Browse files

Improved: Add ‘:distTar’ and ‘:distZip’ gradle tasks (OFBIZ-10866)

Gradle provides some useful standard plugins for packaging
applications via the ‘distribution’ and ‘application’ plugins.

* The ‘distribution’ plugin [1] is providing a straightforward and
  easy way to distribute OFBiz with its dependencies which is
  convenient in a deployment context.  This is achieved by the new
  ‘distTar’ and ‘distZip’ tasks.

* The ‘application’ plugin [2] is complementing the ‘distribution’
  plugin by adding both a robust shell script and a batch script
  inside the distribution archives to allow launching OFBiz easily.


Thanks to Antoine Ouvrard for contributing to this work.

git-svn-id: 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed Mar 25, 2019
1 parent 2e1cacb commit 9fd02351a4920536f968f6d3d74759e2aa812f6f
Showing with 37 additions and 8 deletions.
  1. +17 −0 README.adoc
  2. +20 −8 build.gradle
@@ -585,7 +585,24 @@ it will download source packages available for project dependencies.

`gradlew eclipse`

==== Package and distribute OFBiz

In order to deploy OFBiz on a target system and in particular in a production
environment without requiring the target system to download Gradle and OFBiz
dependencies from the internet, it is possible to generate an archive bundling
OFBiz with all the Jars it depends on as a `tar` archive

`gradlew distTar`

or as a `zip` archive.

`gradlew distZip`

Those archives are available in the `build/distributions` directory. To run
OFBiz from those archive you must first unarchive them with `tar xf` or `unzip`
and then from that directory you can run either `bin/ofbiz` shell script or
`bin/ofbiz.bat` batch script with the appropriate ofbiz options.

== OFBiz plugin system
@@ -24,6 +24,7 @@ import org.asciidoctor.gradle.AsciidoctorTask
* Project setup
* ======================================================== */
plugins {
id 'application'
id 'java'
id 'groovy'
id 'eclipse'
@@ -51,11 +52,22 @@ apply from: 'common.gradle'
ext.os = System.getProperty('').toLowerCase()
ext.pluginsDir = "${rootDir}/plugins"

// java settings
ext.ofbizMainClass = 'org.apache.ofbiz.base.start.Start'
ext.jvmArguments = project.hasProperty('jvmArgs')
? jvmArgs.tokenize()
: ['-Xms128M', '-Xmx1024M']
application {
mainClassName = 'org.apache.ofbiz.base.start.Start'
applicationDefaultJvmArgs = project.hasProperty('jvmArgs')
? jvmArgs.tokenize()
: ['-Xms128M', '-Xmx1024M']

distributions.main.contents.from(rootDir) {
include 'framework/**', 'applications/**', 'themes/**', 'plugins/**'

// XXX: Remove the :distTar and :distZip tasks from the dependency
// graph of the :build task which cost an important amount of disk
// space and build time due to the huge number of dependencies to be
// packed.

javadoc {
failOnError = true
@@ -284,7 +296,7 @@ sourceSets {

'Main-Class': ofbizMainClass,
'Main-Class': application.mainClassName,
'Class-Path': getJarManifestClasspathForCurrentOs()

@@ -980,9 +992,9 @@ tasks.addRule('Pattern: ofbizBackground <Commands>: Execute OFBiz startup comman

def createOfbizCommandTask(taskName, arguments) {
task(type: JavaExec, dependsOn: build, taskName) {
classpath = files(jar.outputs)
main = ofbizMainClass
main = application.mainClassName
args arguments
if (taskName ==~ /^ofbiz.*(--test|-t).*/) {

0 comments on commit 9fd0235

Please sign in to comment.
You can’t perform that action at this time.