svn commit: r1856179 - in /ofbiz/ofbiz-framework/trunk: README.adoc build.gradle

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1856179 - in /ofbiz/ofbiz-framework/trunk: README.adoc build.gradle

mthl
Author: mthl
Date: Mon Mar 25 11:30:08 2019
New Revision: 1856179

URL: http://svn.apache.org/viewvc?rev=1856179&view=rev
Log:
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.

[1] https://docs.gradle.org/current/userguide/distribution_plugin.html
[2] https://docs.gradle.org/current/userguide/application_plugin.html

Thanks to Antoine Ouvrard for contributing to this work.

Modified:
    ofbiz/ofbiz-framework/trunk/README.adoc
    ofbiz/ofbiz-framework/trunk/build.gradle

Modified: ofbiz/ofbiz-framework/trunk/README.adoc
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/README.adoc?rev=1856179&r1=1856178&r2=1856179&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/README.adoc (original)
+++ ofbiz/ofbiz-framework/trunk/README.adoc Mon Mar 25 11:30:08 2019
@@ -585,7 +585,24 @@ it will download source packages availab
 
 `gradlew eclipse`
 
+[[package-and-distribute-ofbiz]]
+==== 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]]
 == OFBiz plugin system

Modified: ofbiz/ofbiz-framework/trunk/build.gradle
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/build.gradle?rev=1856179&r1=1856178&r2=1856179&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/build.gradle (original)
+++ ofbiz/ofbiz-framework/trunk/build.gradle Mon Mar 25 11:30:08 2019
@@ -24,6 +24,7 @@ import org.asciidoctor.gradle.Asciidocto
  * Project setup
  * ======================================================== */
 plugins {
+    id 'application'
     id 'java'
     id 'groovy'
     id 'eclipse'
@@ -51,11 +52,22 @@ apply from: 'common.gradle'
 ext.os = System.getProperty('os.name').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.
+assemble.setDependsOn([jar])
 
 javadoc {
     failOnError = true
@@ -284,7 +296,7 @@ sourceSets {
 
 jar.manifest.attributes(
     'Implementation-Title': project.name,
-    'Main-Class': ofbizMainClass,
+    'Main-Class': application.mainClassName,
     'Class-Path': getJarManifestClasspathForCurrentOs()
 )
 
@@ -980,9 +992,9 @@ tasks.addRule('Pattern: ofbizBackground
 
 def createOfbizCommandTask(taskName, arguments) {
     task(type: JavaExec, dependsOn: build, taskName) {
-        jvmArgs(jvmArguments)
+        jvmArgs(application.applicationDefaultJvmArgs)
         classpath = files(jar.outputs)
-        main = ofbizMainClass
+        main = application.mainClassName
         args arguments
         if (taskName ==~ /^ofbiz.*(--test|-t).*/) {
             finalizedBy(createTestReports)