fixes issue 9780: Module which adds system level information (e.g. ad_ref_list) and add system reference data can not be (un)installed
authorMartin Taal <martin.taal@openbravo.com>
Mon, 06 Jul 2009 23:26:21 +0200
changeset 4287 d3aa261a64fc
parent 4286 3d46064a2975
child 4288 1d9ad040a512
fixes issue 9780: Module which adds system level information (e.g. ad_ref_list) and add system reference data can not be (un)installed
build.xml
src/build.xml
src/org/openbravo/erpCommon/modules/ApplyModuleTask.java
--- a/build.xml	Mon Jul 06 22:26:30 2009 +0200
+++ b/build.xml	Mon Jul 06 23:26:21 2009 +0200
@@ -504,11 +504,9 @@
     <antcall target="trl.lib" />
 
     <antcall target="compile.complete.deploy" />
-    <echo message="applying modules" />
-    <taskdef name="applyModule" classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
-      <classpath refid="project.class.path" />
-    </taskdef>
-    <applyModule userId="0" propertiesFile="${base.config}/Openbravo.properties" />
+    
+    <echo message="applying modules" />    
+    <antcall inheritall="true" inheritrefs="true" target="apply.module" />
 
     <antcall target="import.sample.data" />
 
@@ -525,11 +523,8 @@
     <antcall target="eclipse.wad.lib"/>
     <antcall target="eclipse.trl.lib"/>
     <antcall target="eclipse.compile.complete"/>
-    <echo message="applying modules" />
-    <taskdef name="applyModule" classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
-      <classpath refid="project.class.path" />
-    </taskdef>
-    <applyModule userId="0" propertiesFile="${base.config}/Openbravo.properties" />
+    <echo message="applying modules" />    
+    <antcall inheritall="true" inheritrefs="true" target="apply.module" />
     <antcall target="import.sample.data" />
   </target>
 
@@ -544,16 +539,14 @@
     <antcall target="database.lib" />
     <antcall target="core.lib" />
     <ant dir="${base.db}" target="update.database" inheritAll="true" inheritRefs="true" />
+    <antcall target="generate.entities.quick" />
     <antcall target="db.apply.modules" />
-    <antcall target="generate.entities.quick" />
   </target>
 
   <target name="update.database.mod" depends="init,code.rev">
     <antcall target="database.lib" />
     <antcall target="core.lib" />
     <ant dir="${base.db}" target="update.database.mod" inheritAll="true" inheritRefs="true" />
-    <antcall target="db.apply.modules" />
-    <antcall target="generate.entities" />
   </target>
 
   <target name="update.customized.database" depends="init,code.rev">
@@ -609,36 +602,25 @@
   </target>
 
   <target name="db.apply.modules" if="apply.modules.on.create">
-    <echo message="applying modules" />
-    <taskdef name="applyModule" classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
-      <classpath refid="project.class.path" />
-    </taskdef>
-    <applyModule userId="0" propertiesFile="${base.config}/Openbravo.properties" />
+    <echo message="applying modules" />    
+    <antcall inheritall="true" inheritrefs="true" target="apply.module" />
   </target>
 
   <target name="db.apply.modules.sampledata" if="apply.modules.on.create">
-    <echo message="applying modules" />
-    <taskdef name="applyModule" classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
-      <classpath refid="project.class.path" />
-    </taskdef>
-    <applyModule userId="0" propertiesFile="${base.config}/Openbravo.properties" />
+    <echo message="applying modules" />    
+    <antcall inheritall="true" inheritrefs="true" target="apply.module" />
     <antcall target="import.sample.data" />
   </target>
 
+
   <target name="apply.modules">
     <echo>Applying ${module} modules...</echo>
-    <taskdef name="applyModule" classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
-      <classpath refid="project.class.path" />
-    </taskdef>
     <antcall target="update.database.mod" />
-    <!-- 
-    Note: set reinitializeModel to false because otherwise the dal is re-initialized with classes and a model
-    which are not in sync (see issue: https://issues.openbravo.com/view.php?id=9376)
-    Note: applyModule can also be moved to a java task to fork it (to prevent this from occuring)
-    but then no output is visible for the user.
-    -->
-    <applyModule userId="0" propertiesFile="${base.config}/Openbravo.properties" reinitializemodel="false"/>
     
+    <antcall target="generate.entities" />
+    
+    <antcall inheritall="true" inheritrefs="true" target="apply.module" />
+
     <condition property="apply.modules.complete.compilation.var">
       <istrue value="${apply.modules.complete.compilation}"  />
     </condition>
@@ -650,6 +632,25 @@
     <antcall target="apply.modules.compile"/>
   </target>
   
+  <target name="apply.module.forked">
+    <!-- 
+    Note: set reinitializeModel to false because otherwise the dal is re-initialized with classes and a model
+    which are not in sync (see issue: https://issues.openbravo.com/view.php?id=9376)
+    Note: applyModule can also be moved to a java task to fork it (to prevent this from occuring)
+    but then no output is visible for the user.
+    -->
+    <taskdef name="applyModule" classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
+      <classpath refid="project.class.path" />
+    </taskdef>
+    <applyModule userId="0" propertiesFile="${base.config}/Openbravo.properties"/>
+  </target>
+
+  <target name="apply.module">
+    <java classname="org.openbravo.erpCommon.modules.ApplyModuleTask" fork="true" maxmemory="${build.maxmemory}">
+      <arg line="${base.src}" />
+      <classpath refid="project.class.path" />
+    </java>
+  </target>
   
   <target name="apply.modules.compile">
     <antcall target="apply.modules.compile.simple"/>
--- a/src/build.xml	Mon Jul 06 22:26:30 2009 +0200
+++ b/src/build.xml	Mon Jul 06 23:26:21 2009 +0200
@@ -182,7 +182,7 @@
   </target>
 
   <target name="generate.entities" depends="compile.src.gen,clean.src.gen">
-      <taskdef name="workflow" classpathref="project.class.path" classname="org.openbravo.base.gen.GenerateEntitiesTask" />
+    <taskdef name="workflow" classpathref="project.class.path" classname="org.openbravo.base.gen.GenerateEntitiesTask" />
     <!-- debug="true" will perform the in-memory model initialization before generating entities
 	if an error occurs then, then a stacktrace is printed. -->
     <workflow debug="false" srcGenPath="${base.src.gen}" propertiesFile="${base.config}/Openbravo.properties" file="${base.src}/org/openbravo/base/gen/gen_entity.oaw" fork="true" maxmemory="${build.maxmemory}">
--- a/src/org/openbravo/erpCommon/modules/ApplyModuleTask.java	Mon Jul 06 22:26:30 2009 +0200
+++ b/src/org/openbravo/erpCommon/modules/ApplyModuleTask.java	Mon Jul 06 23:26:21 2009 +0200
@@ -19,9 +19,13 @@
 
 package org.openbravo.erpCommon.modules;
 
+import java.io.File;
+
 import org.apache.tools.ant.BuildException;
+import org.openbravo.base.exception.OBException;
 import org.openbravo.dal.core.DalInitializingTask;
 import org.openbravo.database.CPStandAlone;
+import org.openbravo.erpCommon.utility.AntExecutor;
 
 /**
  * Ant task for ApplyModule class
@@ -31,6 +35,19 @@
   // private String propertiesFile;
   private String obDir;
 
+  public static void main(String[] args) throws Exception {
+    final String srcPath = args[0];
+    final File srcDir = new File(srcPath);
+    final File baseDir = srcDir.getParentFile();
+    try {
+      final AntExecutor antExecutor = new AntExecutor(baseDir.getAbsolutePath());
+      antExecutor.runTask("apply.module.forked");
+    } catch (final Exception e) {
+      e.printStackTrace(System.err);
+      throw new OBException(e);
+    }
+  }
+
   @Override
   public void doExecute() {
     try {
@@ -51,14 +68,14 @@
   public void setObDir(String obDir) {
     this.obDir = obDir;
   }
-
-  public static void main(String[] args) {
-    final ApplyModuleTask t = new ApplyModuleTask();
-    t.setObDir("/ws/trunk/openbravo");
-    t.setUserId("0");
-    t.setPropertiesFile("/ws/trunk/openbravo/config/Openbravo.properties");
-    t.execute();
-
-  }
+  //
+  // public static void main(String[] args) {
+  // final ApplyModuleTask t = new ApplyModuleTask();
+  // t.setObDir("/ws/trunk/openbravo");
+  // t.setUserId("0");
+  // t.setPropertiesFile("/ws/trunk/openbravo/config/Openbravo.properties");
+  // t.execute();
+  //
+  // }
 
 }