"Nothing to generate" error if only specifying xsdJars
------------------------------------------------------

                 Key: MXMLBEANS-45
                 URL: http://jira.codehaus.org/browse/MXMLBEANS-45
             Project: Maven 2.x Xmlbeans Plugin
          Issue Type: Bug
    Affects Versions: 2.3.0
            Reporter: Kevin Stembridge


An empty jar is produced if the xmlbeans plugin configuration section only 
contains an <xsdJars> element and no XSD source files in the project.


For example:


{code:xml}
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>xmlbeans-maven-plugin</artifactId>
  <executions>
    <execution>
      <goals>
        <goal>xmlbeans</goal>
      </goals>
    </execution>
  </executions>
  <inherited>true</inherited>
  <configuration>
    <xsdJars>
      <xsdJar 
implementation="java.lang.String">someGroupId:someArtifactId</xsdJar>
    </xsdJars>
  </configuration>
</plugin>
{code}

I get the following output:


[INFO] [xmlbeans:xmlbeans {execution: default}]
[DEBUG] The schema Directory is 
c:\dev\workspaces\abfo-workspace-trunk\abfo-bof-xmlbeans\src\main\xsd
[DEBUG] Artifact count: 1
[DEBUG] looking for artifact schemas.
[DEBUG] resolving someGroupId:someArtifactId into a file path.
[DEBUG] Filtering META-INF/MANIFEST.MF
[DEBUG] Accepting assetflow.xsd
[DEBUG] adding and extracting assetflow.xsd

---TRUNCATED


[DEBUG] adding and extracting settlementinstruction.xsd
[DEBUG] Accepting simplecash.xsd
[DEBUG] adding and extracting simplecash.xsd
[DEBUG] Accepting trade.xsd
[DEBUG] adding and extracting trade.xsd
[DEBUG] Adding trade.xsdfrom an artifact.
[INFO] Nothing to generate.


This logic from the {{AbstractXmlBeansPlugin.getXsdFiles}} method doesn't look 
quite right. If {{sourceSchemas}} is null it doesn't do anything with 
{{artifactSchemas}}.

{code}
/**
     * Returns a file array of xsd files to translate to object models.
     *
     * @return An array of schema files to be parsed by the schema compiler.
     * @number MXMLBEANS-21
     */
    public final File[] getXsdFiles() throws XmlBeansException
    {

        if ( xsdFiles == 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();
                    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 = {"**/*.xsd"};
                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] ) );
                    }
                }
            }

            xsdFiles = ( File[] ) schemas.toArray( new File[]{} );
        }

        return xsdFiles;
    }
{code}


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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

    http://xircles.codehaus.org/manage_email


Reply via email to