Using apache xmlbeans for java model generation and i found the
xmlbeans-maven-plugin quite useful, but it currently (as of version 2.3.1)
doesn't support model generation from one or more wsdl files.

The attached patch addresses this problem and is provided
without restrictions to use and/or distribution but without
warranty of any kind.

--
Best regards,
 Markus Müller
Index: src/main/java/org/codehaus/mojo/xmlbeans/PluginProperties.java
===================================================================
--- src/main/java/org/codehaus/mojo/xmlbeans/PluginProperties.java      
(revision 7971)
+++ src/main/java/org/codehaus/mojo/xmlbeans/PluginProperties.java      
(working copy)
@@ -87,7 +87,7 @@
      *
      * @return A file array of wsdl files.
      */
-    File[] getWsdlFiles();
+    File[] getWsdlFiles() throws XmlBeansException;
 
     /**
      * Returns the java source files to compile.
Index: src/main/java/org/codehaus/mojo/xmlbeans/AbstractXmlBeansPlugin.java
===================================================================
--- src/main/java/org/codehaus/mojo/xmlbeans/AbstractXmlBeansPlugin.java        
(revision 7971)
+++ src/main/java/org/codehaus/mojo/xmlbeans/AbstractXmlBeansPlugin.java        
(working copy)
@@ -261,6 +261,11 @@
     private File[] xsdFiles;
 
     /**
+     * WSDL files to parse and generate models for.
+     */
+    private File[] wsdlFiles;
+    
+    /**
      * Empty constructor for the XML Beans plugin.
      */
     public AbstractXmlBeansPlugin()
@@ -710,9 +715,71 @@
      *
      * @return An empty file array.
      */
-    public final File[] getWsdlFiles()
+    public final File[] getWsdlFiles() throws XmlBeansException
     {
-        return new File[]{};
+       if ( wsdlFiles == null )
+        {
+            File schemaDirectory = getSchemaDirectory();
+            getLog().debug( "The schema Directory is " + schemaDirectory );
+
+            final List schemas = new ArrayList();
+            // collect artifacts first.
+            Map artifactSchemas = getArtifactSchemas();
+
+            // take care of the schema directory next.
+            if ( sourceSchemas != null )
+            {
+                File nextFile = null;
+                for ( Iterator iterator = sourceSchemas.iterator(); 
iterator.hasNext(); )
+                {
+                    String schemaName = ( String ) iterator.next();
+                    if(schemaName.toLowerCase().endsWith(".wsdl")) {
+                       nextFile = new File( schemaDirectory, schemaName );
+                       if ( nextFile.exists() )
+                       {
+                               schemas.add( nextFile );
+                       }
+                       else if ( artifactSchemas.containsKey( schemaName ) )
+                       {
+                               schemas.add( artifactSchemas.get( schemaName ) 
);
+                       }
+                       else
+                       {
+                               String[] fields = new String[2];
+                               fields[0] = schemaName;
+                               fields[1] = schemaDirectory.getAbsolutePath();
+                               fields[3] = ( artifactMap.isEmpty() ? "" : " or 
the schema artifact(s)" );
+                               throw new XmlBeansException( 
XmlBeansException.MISSING_SCHEMA_FILE, fields );
+                       }
+                    }
+                }
+            }
+            else if ( schemaDirectory.exists() )
+            {
+                DirectoryScanner scanner = new DirectoryScanner();
+                scanner.setBasedir( schemaDirectory );
+
+                String[] includes = {"**/*.wsdl"};
+                scanner.setIncludes( includes );
+                scanner.addDefaultExcludes();
+
+                scanner.setCaseSensitive( false );
+                scanner.scan();
+
+                String[] files = scanner.getIncludedFiles();
+                if ( files != null )
+                {
+                    for ( int i = 0; i < files.length; i++ )
+                    {
+                        getLog().debug( "Adding " + files[i] );
+                        schemas.add( new File( schemaDirectory, files[i] ) );
+                    }
+                }
+            }
+
+            wsdlFiles = ( File[] ) schemas.toArray( new File[]{} );
+        }
+        return wsdlFiles;
     }
 
     /**
@@ -764,23 +831,25 @@
                 for ( Iterator iterator = sourceSchemas.iterator(); 
iterator.hasNext(); )
                 {
                     String schemaName = ( String ) iterator.next();
-                    nextFile = new File( schemaDirectory, schemaName );
-                    if ( nextFile.exists() )
-                    {
-                        schemas.add( nextFile );
+                    if(schemaName.toLowerCase().endsWith(".xsd")) {
+                       nextFile = new File( schemaDirectory, schemaName );
+                       if ( nextFile.exists() )
+                       {
+                               schemas.add( nextFile );
+                       }
+                       else if ( artifactSchemas.containsKey( schemaName ) )
+                       {
+                               schemas.add( artifactSchemas.get( schemaName ) 
);
+                       }
+                       else
+                       {
+                               String[] fields = new String[2];
+                               fields[0] = schemaName;
+                               fields[1] = schemaDirectory.getAbsolutePath();
+                               fields[3] = ( artifactMap.isEmpty() ? "" : " or 
the schema artifact(s)" );
+                               throw new XmlBeansException( 
XmlBeansException.MISSING_SCHEMA_FILE, fields );
+                       }
                     }
-                    else if ( artifactSchemas.containsKey( schemaName ) )
-                    {
-                        schemas.add( artifactSchemas.get( schemaName ) );
-                    }
-                    else
-                    {
-                        String[] fields = new String[2];
-                        fields[0] = schemaName;
-                        fields[1] = schemaDirectory.getAbsolutePath();
-                        fields[3] = ( artifactMap.isEmpty() ? "" : " or the 
schema artifact(s)" );
-                        throw new XmlBeansException( 
XmlBeansException.MISSING_SCHEMA_FILE, fields );
-                    }
                 }
             }
             else if ( schemaDirectory.exists() )
begin:vcard
fn;quoted-printable:Markus M=C3=BCller
n;quoted-printable:M=C3=BCller;Markus
email;internet:[EMAIL PROTECTED]
x-mozilla-html:FALSE
version:2.1
end:vcard


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to