[validation] Some improvements to execution order of buildvalidations and modulescripts. Minor javadoc and other improvements.
authorAntonio Moreno <antonio.moreno@openbravo.com>
Wed, 31 Mar 2010 18:23:35 +0200
changeset 6906 3d2e9c4893c5
parent 6905 d9b02b7308f5
child 6907 544cfe0036ca
[validation] Some improvements to execution order of buildvalidations and modulescripts. Minor javadoc and other improvements.
src-core/src/org/openbravo/buildvalidation/BuildValidation.java
src-core/src/org/openbravo/buildvalidation/BuildValidationHandler.java
src-core/src/org/openbravo/modulescript/ModuleScript.java
src-core/src/org/openbravo/modulescript/ModuleScriptHandler.java
src-db/database/lib/dbsourcemanager.jar
src-util/buildvalidation/log4j.lcf
src-util/diagnostic/.classpath
src-util/diagnostic/.project
src-util/diagnostic/.settings/.jsdtscope
src-util/diagnostic/.settings/org.eclipse.jdt.core.prefs
src-util/diagnostic/.settings/org.eclipse.jst.common.project.facet.core.prefs
src-util/diagnostic/.settings/org.eclipse.wst.common.component
src-util/diagnostic/.settings/org.eclipse.wst.common.project.facet.core.xml
src-util/diagnostic/.settings/org.eclipse.wst.jsdt.ui.superType.container
src-util/diagnostic/.settings/org.eclipse.wst.jsdt.ui.superType.name
src-util/diagnostic/WebContent/META-INF/MANIFEST.MF
src-util/diagnostic/WebContent/WEB-INF/web.xml
src-util/diagnostic/build-create.xml
src-util/diagnostic/build.xml
src-util/diagnostic/build/.keep
src-util/diagnostic/check-ob-perms.sh
src-util/diagnostic/config/diagnostics.properties
src-util/diagnostic/config/log4j.properties
src-util/diagnostic/src/Test.java
src-util/diagnostic/src/org/openbravo/check/Check.java
src-util/diagnostic/src/org/openbravo/task/CheckDB.java
src-util/diagnostic/src/org/openbravo/task/CheckEnvironmentVariables.java
src-util/diagnostic/src/org/openbravo/task/CheckJVMVersion.java
src-util/diagnostic/src/org/openbravo/task/CheckMemory.java
src-util/diagnostic/src/org/openbravo/task/CheckTomcatAntExecution.java
src-util/diagnostic/src/org/openbravo/task/CheckTomcatFilePermissions.java
src-util/diagnostic/src/org/openbravo/task/CheckTomcatMemory.java
src-util/diagnostic/src/org/openbravo/task/CheckTomcatVersion.java
src-util/diagnostic/src/org/openbravo/task/CheckX.java
src-util/diagnostic/src/org/openbravo/task/CompareVersion.java
src-util/diagnostic/src/org/openbravo/utils/PropertiesManager.java
src-util/diagnostic/src/org/openbravo/utils/ServerConnection.java
src-util/diagnostic/src/org/openbravo/utils/Version.java
src-util/modulescript/build.xml
--- a/src-core/src/org/openbravo/buildvalidation/BuildValidation.java	Wed Mar 31 16:49:37 2010 +0200
+++ b/src-core/src/org/openbravo/buildvalidation/BuildValidation.java	Wed Mar 31 18:23:35 2010 +0200
@@ -6,6 +6,11 @@
 import org.openbravo.database.CPStandAlone;
 import org.openbravo.database.ConnectionProvider;
 
+/**
+ * A class extending the BuildValidation class can be used to implement a validation which will be
+ * executed before applying a module, or even Openbravo Core.
+ * 
+ */
 public abstract class BuildValidation {
 
   private ConnectionProvider cp;
@@ -30,7 +35,7 @@
    * 
    * @return a ConnectionProvider
    */
-  protected ConnectionProvider getConnectionProvider() {
+  public ConnectionProvider getConnectionProvider() {
     if (cp != null) {
       return cp;
     }
--- a/src-core/src/org/openbravo/buildvalidation/BuildValidationHandler.java	Wed Mar 31 16:49:37 2010 +0200
+++ b/src-core/src/org/openbravo/buildvalidation/BuildValidationHandler.java	Wed Mar 31 18:23:35 2010 +0200
@@ -3,6 +3,7 @@
 import java.io.File;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.log4j.Logger;
@@ -20,16 +21,22 @@
     PropertyConfigurator.configure("log4j.lcf");
     String errorMessage = "";
     List<String> classes = new ArrayList<String>();
-    File modFolders[];
+    ArrayList<File> modFolders = new ArrayList<File>();
     if (module != null && !module.equals("%")) {
-      File moduleFolder = new File(basedir, "modules/" + module);
-      modFolders = new File[1];
-      modFolders[0] = moduleFolder;
+      String[] javapackages = module.split(",");
+      for (String javapackage : javapackages) {
+        File moduleFolder = new File(basedir, "modules/" + javapackage);
+        modFolders.add(moduleFolder);
+      }
+      Collections.sort(modFolders);
     } else {
       File coreBuildFolder = new File(basedir, "src-util/buildvalidation/build/classes");
       readClassFiles(classes, coreBuildFolder);
       File moduleFolder = new File(basedir, "modules");
-      modFolders = moduleFolder.listFiles();
+      for (File f : moduleFolder.listFiles()) {
+        modFolders.add(f);
+      }
+      Collections.sort(modFolders);
     }
     for (File modFolder : modFolders) {
       if (modFolder.isDirectory()) {
@@ -39,7 +46,6 @@
         }
       }
     }
-
     for (String s : classes) {
       ArrayList<String> errors = new ArrayList<String>();
       try {
@@ -75,6 +81,13 @@
   }
 
   private static void readClassFiles(List<String> coreClasses, File file) {
+    ArrayList<String> newClasses = new ArrayList<String>();
+    readClassFilesExt(newClasses, file);
+    Collections.sort(newClasses);
+    coreClasses.addAll(newClasses);
+  }
+
+  private static void readClassFilesExt(List<String> coreClasses, File file) {
     if (!file.exists()) {
       return;
     }
--- a/src-core/src/org/openbravo/modulescript/ModuleScript.java	Wed Mar 31 16:49:37 2010 +0200
+++ b/src-core/src/org/openbravo/modulescript/ModuleScript.java	Wed Mar 31 18:23:35 2010 +0200
@@ -3,6 +3,12 @@
 import org.openbravo.database.CPStandAlone;
 import org.openbravo.database.ConnectionProvider;
 
+/**
+ * Clases extending ModuleScript can be included in Openbravo Core or a module and will be
+ * automatically executed when the system is rebuilt (technically in: update.database and
+ * update.database.mod)
+ * 
+ */
 public abstract class ModuleScript {
 
   private ConnectionProvider cp = null;
--- a/src-core/src/org/openbravo/modulescript/ModuleScriptHandler.java	Wed Mar 31 16:49:37 2010 +0200
+++ b/src-core/src/org/openbravo/modulescript/ModuleScriptHandler.java	Wed Mar 31 18:23:35 2010 +0200
@@ -3,6 +3,7 @@
 import java.io.File;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.log4j.Logger;
@@ -26,7 +27,12 @@
       File coreBuildFolder = new File(basedir, "src-util/modulescript/build/classes");
       readClassFiles(classes, coreBuildFolder);
       File moduleFolder = new File(basedir, "modules");
-      File modFolders[] = moduleFolder.listFiles();
+      File modFoldersA[] = moduleFolder.listFiles();
+      ArrayList<File> modFolders = new ArrayList<File>();
+      for (File f : modFoldersA) {
+        modFolders.add(f);
+      }
+      Collections.sort(modFolders);
       for (File modFolder : modFolders) {
         if (modFolder.isDirectory()) {
           File validationFolder = new File(modFolder, "build/classes");
@@ -59,7 +65,14 @@
         new Object[0]);
   }
 
-  private void readClassFiles(List<String> coreClasses, File file) {
+  private static void readClassFiles(List<String> coreClasses, File file) {
+    ArrayList<String> newClasses = new ArrayList<String>();
+    readClassFilesExt(newClasses, file);
+    Collections.sort(newClasses);
+    coreClasses.addAll(newClasses);
+  }
+
+  private static void readClassFilesExt(List<String> coreClasses, File file) {
     if (!file.exists()) {
       return;
     }
Binary file src-db/database/lib/dbsourcemanager.jar has changed
--- a/src-util/buildvalidation/log4j.lcf	Wed Mar 31 16:49:37 2010 +0200
+++ b/src-util/buildvalidation/log4j.lcf	Wed Mar 31 18:23:35 2010 +0200
@@ -15,6 +15,9 @@
 # * Contributor(s):  ______________________________________.
 # ************************************************************************
 
+# this logging config will be used for both
+# - execution of SqlC in ant compile.buildvalidation
+# - at runtime of the validation with ant buildvalidation (or inside update.database.(mod)
 log4j.rootCategory=INFO, C, O2
 log4j.category.org.openbravo=INFO
 log4j.appender.C=org.apache.log4j.ConsoleAppender
--- a/src-util/modulescript/build.xml	Wed Mar 31 16:49:37 2010 +0200
+++ b/src-util/modulescript/build.xml	Wed Mar 31 18:23:35 2010 +0200
@@ -29,7 +29,6 @@
     <dirset dir="${base.modules}">
       <include name="*/build/classes/" />
     </dirset>
-    <pathelement path="${base.src}"/>
     <fileset dir="${base.lib}">
       <include name="**/*.jar" />
     </fileset>