geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r486564 - in /geronimo/xbean/trunk: maven-xbean-plugin/src/main/java/org/apache/xbean/maven/ xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/ xbean-spring-itests/2.0/
Date Wed, 13 Dec 2006 09:38:37 GMT
Author: gnodet
Date: Wed Dec 13 01:38:36 2006
New Revision: 486564

URL: http://svn.apache.org/viewvc?view=rev&rev=486564
Log:
XBEAN-65: The maven plugin does not use the classpath, so that properties from parent classes
are ignored if they are not in this module

Modified:
    geronimo/xbean/trunk/maven-xbean-plugin/src/main/java/org/apache/xbean/maven/XBeanMojo.java
    geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java
    geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/Utils.java
    geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XsdGenerator.java
    geronimo/xbean/trunk/xbean-spring-itests/2.0/   (props changed)

Modified: geronimo/xbean/trunk/maven-xbean-plugin/src/main/java/org/apache/xbean/maven/XBeanMojo.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/maven-xbean-plugin/src/main/java/org/apache/xbean/maven/XBeanMojo.java?view=diff&rev=486564&r1=486563&r2=486564
==============================================================================
--- geronimo/xbean/trunk/maven-xbean-plugin/src/main/java/org/apache/xbean/maven/XBeanMojo.java
(original)
+++ geronimo/xbean/trunk/maven-xbean-plugin/src/main/java/org/apache/xbean/maven/XBeanMojo.java
Wed Dec 13 01:38:36 2006
@@ -18,14 +18,19 @@
 
 import java.beans.PropertyEditorManager;
 import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
 import java.util.StringTokenizer;
 
+import org.apache.maven.artifact.Artifact;
 import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -49,6 +54,7 @@
  * @goal mapping
  * @description Creates xbean mapping file
  * @phase generate-sources
+ * @requiresDependencyResolution compile
  */
 public class XBeanMojo extends AbstractMojo implements LogFacade {
 
@@ -150,6 +156,7 @@
             };
 
             // load the mappings
+            Thread.currentThread().setContextClassLoader(getClassLoader());
             Set namespaces = mappingLoader.loadNamespaces();
             if (namespaces.isEmpty()) {
                 System.out.println("Warning: no namespaces found!");
@@ -195,4 +202,38 @@
     public void log(String message, int level) {
         getLog().info(message);
     }
+
+    protected URLClassLoader getClassLoader() throws MojoExecutionException {
+        try {
+            Set urls = new HashSet();
+
+            URL mainClasses = new File(project.getBuild().getOutputDirectory())
+                    .toURL();
+            getLog().debug("Adding to classpath : " + mainClasses);
+            urls.add(mainClasses);
+
+            URL testClasses = new File(project.getBuild()
+                    .getTestOutputDirectory()).toURL();
+            getLog().debug("Adding to classpath : " + testClasses);
+            urls.add(testClasses);
+
+            Set dependencies = project.getArtifacts();
+            Iterator iter = dependencies.iterator();
+            while (iter.hasNext()) {
+                Artifact classPathElement = (Artifact) iter.next();
+                getLog().debug(
+                        "Adding artifact: " + classPathElement.getFile()
+                                + " to classpath");
+                urls.add(classPathElement.getFile().toURL());
+            }
+            URLClassLoader appClassloader = new URLClassLoader((URL[]) urls
+                    .toArray(new URL[urls.size()]), this.getClass()
+                    .getClassLoader());
+            return appClassloader;
+        } catch (MalformedURLException e) {
+            throw new MojoExecutionException(
+                    "Error during setting up classpath", e);
+        }
+    }
+
 }

Modified: geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java?view=diff&rev=486564&r1=486563&r2=486564
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java
(original)
+++ geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java
Wed Dec 13 01:38:36 2006
@@ -477,15 +477,18 @@
     }
 
     private org.apache.xbean.spring.generator.Type toMappingType(Type type, String nestedType)
{
-        if (type.isArray()) {
-            return org.apache.xbean.spring.generator.Type.newArrayType(type.getValue(), type.getDimensions());
-        } else if (type.isA(listType)) {
-            if (nestedType == null) nestedType = "java.lang.Object";
-            return org.apache.xbean.spring.generator.Type.newCollectionType(type.getValue(),
-                    org.apache.xbean.spring.generator.Type.newSimpleType(nestedType));
-        } else {
-            return org.apache.xbean.spring.generator.Type.newSimpleType(type.getValue());
+        try {
+            if (type.isArray()) {
+                return org.apache.xbean.spring.generator.Type.newArrayType(type.getValue(),
type.getDimensions());
+            } else if (type.isA(listType)) {
+                if (nestedType == null) nestedType = "java.lang.Object";
+                return org.apache.xbean.spring.generator.Type.newCollectionType(type.getValue(),
+                        org.apache.xbean.spring.generator.Type.newSimpleType(nestedType));
+            }
+        } catch (Throwable t){ 
+            log.debug("Could not load type mapping", t);
         }
+        return org.apache.xbean.spring.generator.Type.newSimpleType(type.getValue());
     }
 
     private static String toMethodLocator(JavaMethod method) {

Modified: geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/Utils.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/Utils.java?view=diff&rev=486564&r1=486563&r2=486564
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/Utils.java
(original)
+++ geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/Utils.java
Wed Dec 13 01:38:36 2006
@@ -64,13 +64,13 @@
         Class theClass;
         try {
             theClass = loadClass(type);
-        } catch (ClassNotFoundException e) {
-            System.out.println("Warning, could not load class: " + type);
+            // lets see if we can find a property editor for this type
+            PropertyEditor editor = PropertyEditorManager.findEditor(theClass);
+            return editor != null;
+        } catch (Throwable e) {
+            System.out.println("Warning, could not load class: " + type + ": " + e);
             return false;
         }
-        // lets see if we can find a property editor for this type
-        PropertyEditor editor = PropertyEditorManager.findEditor(theClass);
-        return editor != null;
     }
 
     /**

Modified: geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XsdGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XsdGenerator.java?view=diff&rev=486564&r1=486563&r2=486564
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XsdGenerator.java
(original)
+++ geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XsdGenerator.java
Wed Dec 13 01:38:36 2006
@@ -99,6 +99,7 @@
                     generateElementMappingComplexProperty(out, namespaceMapping, attributeMapping);
                 }
             }
+            out.println("        <xs:any namespace='##other'/>");
             out.println("      </xs:sequence>");
         }
 
@@ -188,14 +189,14 @@
         }
         out.println("          <xs:complexType>");
         if (types.isEmpty()) {
-            out.println("            <xs:sequence minOccurs='0' maxOccurs='" + maxOccurs
+ "'><xs:any/></xs:sequence>");
+            out.println("            <xs:sequence minOccurs='0' maxOccurs='" + maxOccurs
+ "'><xs:any namespace='##other'/></xs:sequence>");
         } else {
             out.println("            <xs:choice minOccurs='0' maxOccurs='" + maxOccurs
+ "'>");
             for (Iterator iterator = types.iterator(); iterator.hasNext();) {
                 ElementMapping element = (ElementMapping) iterator.next();
                 out.println("              <xs:element ref='tns:" + element.getElementName()
+ "'/>");
             }
-            out.println("              <xs:any/>");
+            out.println("              <xs:any namespace='##other'/>");
             out.println("            </xs:choice>");
         }
         out.println("          </xs:complexType>");

Propchange: geronimo/xbean/trunk/xbean-spring-itests/2.0/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Dec 13 01:38:36 2006
@@ -1 +1,3 @@
 target
+.classpath
+.project



Mime
View raw message