Author: jochen
Date: Mon Dec 26 15:20:49 2005
New Revision: 359126

URL: http://svn.apache.org/viewcvs?rev=359126&view=rev
Log:
Release 1.0 - Added support for external binding files.

Modified:
    webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/pom.xml
    
webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/main/java/org/apache/ws/jaxme/maven/plugins/JaxMeGoal.java
    
webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/site/apt/properties.apt

Modified: webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/pom.xml
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/pom.xml?rev=359126&r1=359125&r2=359126&view=diff
==============================================================================
--- webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/pom.xml (original)
+++ webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/pom.xml Mon Dec 26 
15:20:49 2005
@@ -22,7 +22,7 @@
   <artifactId>maven-jaxme-plugin</artifactId>
   <packaging>maven-plugin</packaging>
   <name>Maven JaxMe Plugin</name>
-  <version>1.0-SNAPSHOT</version>
+  <version>1.0</version>
   <description>
     This plugin allows running the JaxMe binding compiler on
     your XML schema files and add the generated sources to

Modified: 
webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/main/java/org/apache/ws/jaxme/maven/plugins/JaxMeGoal.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/main/java/org/apache/ws/jaxme/maven/plugins/JaxMeGoal.java?rev=359126&r1=359125&r2=359126&view=diff
==============================================================================
--- 
webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/main/java/org/apache/ws/jaxme/maven/plugins/JaxMeGoal.java
 (original)
+++ 
webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/main/java/org/apache/ws/jaxme/maven/plugins/JaxMeGoal.java
 Mon Dec 26 15:20:49 2005
@@ -16,6 +16,7 @@
 package org.apache.ws.jaxme.maven.plugins;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
@@ -23,6 +24,8 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.xml.parsers.ParserConfigurationException;
+
 import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -38,6 +41,8 @@
 import org.apache.ws.jaxme.logging.LoggerAccess;
 import org.apache.ws.jaxme.logging.LoggerFactory;
 import org.codehaus.plexus.util.DirectoryScanner;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
 
 
 /** This is the "jaxme:jaxme" goal. It runs the source
@@ -49,6 +54,12 @@
  * @requiresDependencyResolution test
  */
 public class JaxMeGoal extends AbstractMojo {
+       /** This property specifies a set of external
+        * binding files, which are being applied.
+        * @parameter
+        */
+       private String[] bindings;
+
        /** Specifies classpath elements, which should be added to
         * the plugins classpath.
         * @parameter expression="${project.compileClasspathElements}"
@@ -167,6 +178,10 @@
         */
        private boolean validating;
 
+       protected String[] getBindings() {
+               return bindings;
+       }
+
        protected List getClasspathElements() {
                return classpathElements;
        }
@@ -278,11 +293,15 @@
                return schemaFiles;
        }
 
+       private File[] getBindingFiles() {
+               return getFiles(getBindings());
+       }
+
        private File[] getDependencies() {
                return getFiles(getDepends());
        }
 
-       private boolean isUptodate(File[] pSchemaFiles, File[] pDependencies, 
File[] pProducedFiles) {
+       private boolean isUptodate(File[] pSourceFiles, File[] pProducedFiles) {
                if (isForce()) {
                        getLog().debug("Force flag set, disabling uptodate 
check.");
                        return false;
@@ -306,9 +325,7 @@
                        }
                }
 
-               final File[] deps = new File[pSchemaFiles.length + 
pDependencies.length];
-               System.arraycopy(pSchemaFiles, 0, deps, 0, pSchemaFiles.length);
-               System.arraycopy(pDependencies, 0, deps, pSchemaFiles.length, 
pDependencies.length);
+               final File[] deps = pSourceFiles;
                long maxDepTime = 0;
                File maxDepFile = null;
                for (int i = 0;  i < deps.length;  i++) {
@@ -333,6 +350,13 @@
                }
        }
 
+       private File[] concat(File[] pFiles1, File[] pFiles2) {
+               final File[] deps = new File[pFiles1.length + pFiles2.length];
+               System.arraycopy(pFiles1, 0, deps, 0, pFiles1.length);
+               System.arraycopy(pFiles2, 0, deps, pFiles1.length, 
pFiles2.length);
+               return deps;
+       }
+
        private void removeOldOutput(File[] pProducedFiles) throws 
MojoExecutionException {
                if (isRemovingOldOutput()) {
                        for (int i = 0;  i < pProducedFiles.length;  i++) {
@@ -468,7 +492,8 @@
                        }
                        final File[] producedFiles = getProducedFiles();
                        final File[] dependencies = getDependencies();
-                       final boolean uptodate = isUptodate(schemaFiles, 
dependencies, producedFiles);
+                       final File[] bindingFiles = getBindingFiles();
+                       final boolean uptodate = 
isUptodate(concat(concat(schemaFiles, dependencies), bindingFiles), 
producedFiles);
                        if (uptodate) {
                                getLog().info("Generated files are uptodate.");
                                return;
@@ -476,8 +501,23 @@
        
                        removeOldOutput(producedFiles);
        
+                       Generator g = new GeneratorImpl();
+                       for (int i = 0;  i < bindingFiles.length;  i++) {
+                               File f = bindingFiles[i];
+                               try {
+                                       g.addBindings(new 
InputSource(f.toURL().toExternalForm()));
+                               } catch (ParserConfigurationException e) {
+                                       throw new 
MojoExecutionException("Failed to add binding file "
+                                                       + f.getPath() + ": " + 
e.getMessage(), e);
+                               } catch (SAXException e) {
+                                       throw new 
MojoExecutionException("Failed to add binding file "
+                                                       + f.getPath() + ": " + 
e.getMessage(), e);
+                               } catch (IOException e) {
+                                       throw new 
MojoExecutionException("Failed to add binding file "
+                                                       + f.getPath() + ": " + 
e.getMessage(), e);
+                               }
+                       }
                        for (int i = 0;  i < schemaFiles.length;  i++) {
-                               Generator g = new GeneratorImpl();
                                final SchemaReader reader = 
getSchemaReaderInstance();
                                g.setSchemaReader(reader);
                                g.setForcingOverwrite(isForce());

Modified: 
webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/site/apt/properties.apt
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/site/apt/properties.apt?rev=359126&r1=359125&r2=359126&view=diff
==============================================================================
--- 
webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/site/apt/properties.apt 
(original)
+++ 
webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/site/apt/properties.apt 
Mon Dec 26 15:20:49 2005
@@ -27,16 +27,20 @@
 
*-------------------+--------------------------------------------------+-----------------------+
 | Name              | Description                                      | 
Example               |
 
*-------------------+--------------------------------------------------+-----------------------+
-| depends           | Specifies additional                             | 
\<depends\>           |
-|                   | dependencies. Typically, these are files, which  |   
\<value\>           |
-|                   | are imported from within some schema, but        |     
src/jaxme/*.xsi   |
-|                   | aren't compiled themselves. The plugin uses      |   
\</value>           |
-|                   | these files within the uptodate check: Generated | 
\</depends\>          |
-|                   | sources aren't considered uptodate, if an        |       
                |
-|                   | additional dependency has a more recent          |       
                |
-|                   | modification date. Multiple dependencies may be  |       
                |
-|                   | specified (by repeating the "depends" element),  |       
                |
-|                   | all of which may contain wildcards.              |       
                |
+| bindings          | Specifies a set of external binding files, which | 
\<bindings\>          |
+|                   | are being applied. Multiple bindings may be      |   
\<value\>           |
+|                   | specified, each of which containing wildcards.   |     
src/jaxme/*.jxb   |
+|                   |                                                  |   
\</value\>          |
+|                   |                                                  | 
\</bindings\>         |
+*-------------------+--------------------------------------------------+-----------------------+
+| depends           | Specifies additional dependencies. Typically,    | 
\<depends\>           |
+|                   | these are files, which are imported from within  |   
\<value\>           |
+|                   | some schema, but aren't compiled themselves.     |     
src/jaxme/*.xsi   |
+|                   | The plugin uses these files within the uptodate  |   
\</value>           |
+|                   | check: Generated sources aren't considered       | 
\</depends\>          |
+|                   | uptodate, if an additional dependency has a more |       
                |
+|                   | recent modification date. Multiple dependencies  |       
                |
+|                   | may be, each of which may contain wildcards.     |       
                |
 
*-------------------+--------------------------------------------------+-----------------------+
 | extension         | A boolean property, which may be used to enable  | 
\<extension\>         |
 |                   | JaxMe's vendor extensions. By default, JaxMe     |   
true                |



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to