[validation] Fixed problems with buildvalidations (classloading and classpath issues)
authorAntonio Moreno <antonio.moreno@openbravo.com>
Wed, 31 Mar 2010 14:18:01 +0200
changeset 6904 a3266e52e42c
parent 6903 ffc2d0f3cec7
child 6905 d9b02b7308f5
[validation] Fixed problems with buildvalidations (classloading and classpath issues)
src-core/src/org/openbravo/buildvalidation/BuildValidationHandler.java
src-core/src/org/openbravo/modulescript/ModuleScriptHandler.java
src-util/buildvalidation/build.xml
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
--- a/src-core/src/org/openbravo/buildvalidation/BuildValidationHandler.java	Wed Mar 31 11:34:10 2010 +0200
+++ b/src-core/src/org/openbravo/buildvalidation/BuildValidationHandler.java	Wed Mar 31 14:18:01 2010 +0200
@@ -6,17 +6,18 @@
 import java.util.List;
 
 import org.apache.log4j.Logger;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
+import org.apache.log4j.PropertyConfigurator;
 
-public class BuildValidationHandler extends Task {
+public class BuildValidationHandler {
   private static final Logger log4j = Logger.getLogger(BuildValidationHandler.class);
 
-  private File basedir;
-  private String module;
+  private static File basedir;
+  private static String module;
 
-  @Override
-  public void execute() {
+  public static void main(String[] args) {
+    basedir = new File(args[0]);
+    module = args[1];
+    PropertyConfigurator.configure("log4j.lcf");
     String errorMessage = "";
     List<String> classes = new ArrayList<String>();
     File modFolders[];
@@ -54,24 +55,26 @@
         }
       } catch (Exception e) {
         log4j.info("Error executing build-validation: " + s, e);
-        throw new BuildException("The build validation " + s + " couldn't be properly executed");
+        log4j.error("The build validation " + s + " couldn't be properly executed" + e);
+        System.exit(1);
       }
       if (errors.size() > 0) {
-        throw new BuildException(
-            errorMessage
-                + "\nThe build validation failed. The system hasn't been modified. Fix the problems described in the validation messages, and then start the build again.");
+        log4j.error(errorMessage);
+        log4j
+            .error("The build validation failed. The system hasn't been modified. Fix the problems described in the validation messages, and then start the build again.");
+        System.exit(1);
       }
     }
   }
 
   @SuppressWarnings("unchecked")
-  private ArrayList<String> callExecute(Class<?> myClass, Object instance)
+  private static ArrayList<String> callExecute(Class<?> myClass, Object instance)
       throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
     return (ArrayList<String>) myClass.getMethod("execute", new Class[0]).invoke(instance,
         new Object[0]);
   }
 
-  private void readClassFiles(List<String> coreClasses, File file) {
+  private static void readClassFiles(List<String> coreClasses, File file) {
     if (!file.exists()) {
       return;
     }
@@ -81,9 +84,11 @@
         readClassFiles(coreClasses, f);
       }
     } else {
-      String fileName = file.getAbsolutePath();
-      fileName = fileName.split("build" + File.separatorChar + "classes" + File.separatorChar)[1];
-      coreClasses.add(fileName.replace(".class", "").replace(File.separatorChar, '.'));
+      if (file.getAbsolutePath().endsWith(".class")) {
+        String fileName = file.getAbsolutePath();
+        fileName = fileName.split("build" + File.separatorChar + "classes" + File.separatorChar)[1];
+        coreClasses.add(fileName.replace(".class", "").replace(File.separatorChar, '.'));
+      }
     }
   }
 
--- a/src-core/src/org/openbravo/modulescript/ModuleScriptHandler.java	Wed Mar 31 11:34:10 2010 +0200
+++ b/src-core/src/org/openbravo/modulescript/ModuleScriptHandler.java	Wed Mar 31 14:18:01 2010 +0200
@@ -69,9 +69,11 @@
         readClassFiles(coreClasses, f);
       }
     } else {
-      String fileName = file.getAbsolutePath();
-      fileName = fileName.split("build" + File.separatorChar + "classes" + File.separatorChar)[1];
-      coreClasses.add(fileName.replace(".class", "").replace(File.separatorChar, '.'));
+      if (file.getAbsolutePath().endsWith(".class")) {
+        String fileName = file.getAbsolutePath();
+        fileName = fileName.split("build" + File.separatorChar + "classes" + File.separatorChar)[1];
+        coreClasses.add(fileName.replace(".class", "").replace(File.separatorChar, '.'));
+      }
     }
   }
 
--- a/src-util/buildvalidation/build.xml	Wed Mar 31 11:34:10 2010 +0200
+++ b/src-util/buildvalidation/build.xml	Wed Mar 31 14:18:01 2010 +0200
@@ -25,11 +25,10 @@
   <property name="main.dir" value="${basedir}/../.." />
 
   <path id="pre.class.path">
-    <pathelement path="build/classes" />
+    <pathelement path="build/classes/" />
     <dirset dir="${base.modules}">
       <include name="*/build/classes/" />
     </dirset>
-    <pathelement path="${base.src}"/>
     <fileset dir="${base.lib}">
       <include name="**/*.jar" />
     </fileset>
@@ -92,10 +91,11 @@
   </target>
 
   <target name="buildvalidation" >
-    <taskdef name="ValidationHandler" classname="org.openbravo.buildvalidation.BuildValidationHandler" onerror="failall">
+    <java classname="org.openbravo.buildvalidation.BuildValidationHandler" jvm="${env.JAVA_HOME}/bin/java" fork="yes" maxmemory="${build.maxmemory}" failonerror="yes">
+      <arg value="${base.src}/../"/>
+      <arg value="${module}"/>
       <classpath refid="pre.class.path" />
-    </taskdef>
-    <ValidationHandler basedir="${base.src}/../" module="${module}" />
+    </java>
   </target>
   
   <target name="checkmodule"  if="module.not.provided">
--- a/src-util/buildvalidation/log4j.lcf	Wed Mar 31 11:34:10 2010 +0200
+++ b/src-util/buildvalidation/log4j.lcf	Wed Mar 31 14:18:01 2010 +0200
@@ -15,8 +15,9 @@
 # * Contributor(s):  ______________________________________.
 # ************************************************************************
 
-log4j.rootCategory=INFO, C
+log4j.rootCategory=INFO, C, O2
 log4j.category.org.openbravo=INFO
 log4j.appender.C=org.apache.log4j.ConsoleAppender
 log4j.appender.C.layout=org.apache.log4j.PatternLayout
 log4j.appender.C.layout.ConversionPattern=%-4r [%t] %-5p %c - %m%n
+log4j.appender.O2=org.openbravo.utils.OBRebuildAppender