svn commit: r1826656 - /ofbiz/ofbiz-framework/trunk/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: r1826656 - /ofbiz/ofbiz-framework/trunk/build.gradle

Taher Alkhateeb
Author: taher
Date: Tue Mar 13 16:32:00 2018
New Revision: 1826656

URL: http://svn.apache.org/viewvc?rev=1826656&view=rev
Log:
Implemented: make documentation tasks delete their artifacts
(OFBIZ-9873)

As per the discussion thread[1], and due to a limitation in the gradle
implementation of "asciidoctor" it was agreed to make documentation tasks clean
their own artifacts before re-running. The limitation is that changes in
included documents (sub-documents) does not re-run the gradle tasks i.e. gradle
thinks no changes happened to require re-running the tasks.

Thus this commit applies the following:
- create delete tasks for ofbiz & plugin docs
- link dependencies on these tasks from the documentation generation tasks

it was a bit tricky to get it right bacause of task dependency order, and thus
we had to add the "mustRunAfter" directive.

Thank you Michael Brohl and Sharan Foga for your input.

[1] https://s.apache.org/aBUR

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

Modified: ofbiz/ofbiz-framework/trunk/build.gradle
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/build.gradle?rev=1826656&r1=1826655&r2=1826656&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/build.gradle (original)
+++ ofbiz/ofbiz-framework/trunk/build.gradle Tue Mar 13 16:32:00 2018
@@ -494,24 +494,42 @@ tasks.withType(AsciidoctorTask) { task -
     attributes toc: ''
 }
 
+task deleteOfbizDocumentation {
+    doFirst { delete "${buildDir}/asciidoc/ofbiz" }
+}
+
+task deletePluginDocumentation {
+    def activeComponents = []
+    iterateOverActiveComponents { component ->
+        activeComponents.add(component.name)
+    }
+    doFirst {
+        if (!project.hasProperty('pluginId')) {
+            throw new GradleException('Missing property \"pluginId\"')
+        }
+        if(!activeComponents.contains(pluginId)) {
+            throw new GradleException("Could not find plugin with id ${pluginId}")
+        }
+        delete "${buildDir}/asciidoc/${pluginId}"
+    }
+}
+
 task generateOfbizDocumentation(group: docsGroup, type: AsciidoctorTask) {
+    dependsOn deleteOfbizDocumentation
     description 'Generate OFBiz documentation manual'
     sourceDir "${rootDir}/docs/asciidoc"
     outputDir file("${buildDir}/asciidoc/ofbiz")
 }
 
 task generatePluginDocumentation(group: docsGroup) {
+    dependsOn deletePluginDocumentation
     description 'Generate plugin documentation. Expects pluginId flag'
-    doFirst {
-        if (!project.hasProperty('pluginId')) {
-            throw new GradleException('Missing property \"pluginId\"')
-        }
-    }
     iterateOverActiveComponents { component ->
-        if(project.hasProperty('pluginId')) {
-            def pluginAsciidoc = task "${component.name}" (type: AsciidoctorTask) {
+        if (project.hasProperty('pluginId') && component.name == pluginId) {
+            def pluginAsciidoc = task "${component.name}Documentation" (type: AsciidoctorTask) {
                 sourceDir file("${component}/src/docs/asciidoc")
                 outputDir file("${buildDir}/asciidoc/${component.name}")
+                mustRunAfter deletePluginDocumentation
             }
             dependsOn pluginAsciidoc
         }