Reduce drastically the size of the manipulator.
It does no more embed Xerces, but rely on any Sax parser implementation exporting org.xml.sax.
The main result is the reduction of the online manipulator size to 150Kb (instead of 1Mb).

Fix the junit4OSGi notice file : it does not includes OSGi code


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@772896 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/ant/pom.xml b/ipojo/ant/pom.xml
index 3116196..168655c 100644
--- a/ipojo/ant/pom.xml
+++ b/ipojo/ant/pom.xml
@@ -6,9 +6,9 @@
 	to you under the Apache License, Version 2.0 (the
 	"License"); you may not use this file except in compliance
 	with the License.  You may obtain a copy of the License at
-	
+
 	http://www.apache.org/licenses/LICENSE-2.0
-	
+
 	Unless required by applicable law or agreed to in writing,
 	software distributed under the License is distributed on an
 	"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -72,11 +72,11 @@
 							org.objectweb.asm.commons;-split-package:=merge-first,
 							org.apache.xerces.parsers, org.apache.xerces.xni*,
 							org.apache.xerces.impl*, org.apache.xerces.util.*,
-							org.apache.xerces.dom.*, org.apache.xerces.dom3.* 
+							org.apache.xerces.dom.*, org.apache.xerces.dom3.*
 						</Private-Package>
 						<Export-Package> org.apache.felix.ipojo.task </Export-Package>
 						<Include-Resource> META-INF/LICENCE=LICENSE,
-							META-INF/NOTICE=NOTICE, META-INF/LICENSE.asm=LICENSE.asm 
+							META-INF/NOTICE=NOTICE, META-INF/LICENSE.asm=LICENSE.asm
 						</Include-Resource>
 					</instructions>
 					<obrRepository>NONE</obrRepository>
diff --git a/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java b/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java
index acdb568..be224d1 100644
--- a/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java
+++ b/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java
@@ -1,4 +1,4 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -30,32 +30,32 @@
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
 public class IPojoTask extends Task {
-    
+
     /** Metadata file. */
     private File m_metadata;
-    
+
     /** Input bundle. */
     private File m_input;
-    
+
     /** Output bundle. */
     private File m_output;
-    
+
     /** Input directory. */
     private File m_directory;
-    
+
     /** Input manifest. */
     private File m_manifest;
 
     /** Flag describing if we need to ignore annotation of not. */
     private boolean m_ignoreAnnotations = false;
-    
+
     /**
      * Flag describing if we need or not use local XSD files
      * (i.e. use the {@link SchemaResolver} or not).
      * If <code>true</code> the local XSD are not used.
      */
     private boolean m_ignoreLocalXSD = false;
-    
+
     /**
      * Set the metadata file.
      * @param meta : the metadata file.
@@ -63,7 +63,7 @@
     public void setMetadata(File meta) {
         m_metadata = meta;
     }
-    
+
     /**
      * Set the manifest file.
      * @param manifest : the manifest file.
@@ -71,7 +71,7 @@
     public void setManifest(File manifest) {
         m_manifest = manifest;
     }
-    
+
     /**
      * Set the input bundle.
      * @param in : the input bundle
@@ -79,7 +79,7 @@
     public void setInput(File in) {
         m_input = in;
     }
-    
+
     /**
      * Set the input directory.
      * @param dir : the input directory
@@ -87,7 +87,7 @@
     public void setDir(File dir) {
         m_directory  = dir;
     }
-    
+
     /**
      * Set the output bundle.
      * @param out : the output bundle
@@ -95,7 +95,7 @@
     public void setOutput(File out) {
         m_output = out;
     }
-    
+
     /**
      * Set if we need to ignore annotations or not.
      * @param flag : true if we need to ignore annotations.
@@ -103,7 +103,7 @@
     public void setIgnoreAnnotations(boolean flag) {
         m_ignoreAnnotations = flag;
     }
-    
+
     /**
      * Set if we need to use embedded XSD files or not.
      * @param flag : true if we need to ignore embedded XSD files.
@@ -111,35 +111,35 @@
     public void setIgnoreEmbeddedSchemas(boolean flag) {
         m_ignoreLocalXSD = flag;
     }
-    
+
     /**
      * Execute the Ant Task.
      * @see org.apache.tools.ant.Task#execute()
      */
     public void execute() {
-        
+
         if (m_input == null  && m_directory == null) {
             throw new BuildException("Neither input bundle nor directory specified");
         }
-        
+
         if (m_input != null && !m_input.exists()) {
             throw new BuildException("The input bundle " + m_input.getAbsolutePath() + " does not exist");
         }
-        
+
         if (m_directory != null && !m_directory.exists()) {
             throw new BuildException("The input directory " + m_directory.getAbsolutePath() + " does not exist");
         }
         if (m_directory != null && !m_directory.isDirectory()) {
             throw new BuildException("The input directory " + m_directory.getAbsolutePath() + " is not a directory");
         }
-        
-        
+
+
         if (m_input != null) {
             log("Input bundle file : " + m_input.getAbsolutePath());
         } else {
             log("Input directory : " + m_directory.getAbsolutePath());
         }
-        
+
         if (m_manifest != null) {
             if (m_input != null) {
                 throw new BuildException("The manifest location cannot be used when manipulating an existing bundle");
@@ -148,7 +148,7 @@
                 throw new BuildException("The manifest file " + m_manifest.getAbsolutePath() + " does not exist");
             }
         }
-        
+
         // Get metadata file
         if (m_metadata == null) {
             m_metadata = new File("./metadata.xml");
@@ -172,10 +172,12 @@
                 log("Metadata file : " + m_metadata.getAbsolutePath());
             }
         }
-        
+
+        initializeSaxDriver();
+
 
         log("Start manipulation");
-        
+
         if (m_input != null) { // Prepare output file
             if (m_output == null) {
                 m_output = new File("./_out.jar");
@@ -185,7 +187,7 @@
                 if (!r) { throw new BuildException("The file " + m_output.getAbsolutePath() + " cannot be deleted"); }
             }
         }
-       
+
         Pojoization pojo = new Pojoization();
         if (! m_ignoreAnnotations) {
             pojo.setAnnotationProcessing();
@@ -202,14 +204,14 @@
             log((String) pojo.getWarnings().get(i), Project.MSG_WARN);
         }
         if (pojo.getErrors().size() > 0) { throw new BuildException((String) pojo.getErrors().get(0)); }
-        
+
         if (m_input != null) {
             String out;
             if (m_output.getName().equals("_out.jar")) {
                 if (m_input.delete()) {
                     if (! m_output.renameTo(m_input)) {
                         log("Cannot rename the output jar to " + m_input.getAbsolutePath(), Project.MSG_WARN);
-                    }   
+                    }
                 } else {
                     log("Cannot delete the input file : " + m_input.getAbsolutePath(), Project.MSG_WARN);
                 }
@@ -217,7 +219,7 @@
             } else {
                 out = m_output.getAbsolutePath();
             }
-        
+
             log("Bundle manipulation - SUCCESS");
             log("Output file : " + out);
         } else {
@@ -228,10 +230,23 @@
             }
 
         }
-        
+
     }
-    
-    
+
+    /**
+     * If Ant runs with Java 1.4, we should use the embedded Xerces.
+     * To achieve that, we set the org.xml.sax.driver property.
+     * Otherwise, the JVM sets the org.xml.sax.driver property.
+     */
+    private void initializeSaxDriver() {
+        String version = (String) System.getProperty("java.vm.version");
+        if (version.startsWith("1.4")) {
+            System.setProperty("org.xml.sax.driver", "org.apache.xerces.parsers.SAXParser");
+        }
+
+    }
+
+
 
 }