djencks     2004/02/02 14:04:22

  Added:       modules/maven-xmlbeans-plugin .cvsignore maven.xml
                        plugin.jelly project.xml
               
modules/maven-xmlbeans-plugin/src/java/org/apache/geronimo/tools/xmlbeans
                        SchemaCompilerWrapper.java
  Log:
  apache xmlbeans maven plugin
  
  Revision  Changes    Path
  1.1                  
incubator-geronimo/modules/maven-xmlbeans-plugin/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  .project
  .classpath
  maven.log
  junit*.properties
  target
  
  
  
  1.1                  
incubator-geronimo/modules/maven-xmlbeans-plugin/maven.xml
  
  Index: maven.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <!-- $Revision: 1.1 $ $Date: 2004/02/02 22:04:21 $ -->
  
  <project default="default"
      xmlns:j="jelly:core"
      xmlns:u="jelly:util"
      xmlns:ant="jelly:ant"
      xmlns:maven="jelly:maven"
      xmlns:define="jelly:define"
      xmlns:deploy="geronimo:xmlbeans">
  
      <!-- ================= -->
      <!-- Global Properties -->
      <!-- ================= -->
  
      <!-- Determine what the top-level project root is -->
      <j:set var="project.root" 
value="${pom.parentBasedir().getParentFile().getCanonicalFile()}"/>
  
      <!-- Load the global properties -->
      <ant:property file="${project.root}/etc/global.properties"/>
  
  
      <!-- ==================== -->
      <!-- Default Global Goals -->
      <!-- ==================== -->
  
      <goal name="default">
          <attainGoal name="plugin:install"/>
      </goal>
  
      <goal name="build">
          <attainGoal name="default"/>
      </goal>
  
      <goal name="rebuild">
          <attainGoal name="clean"/>
          <attainGoal name="build"/>
      </goal>
  
      <goal name="clover.wrapper">
          <!-- no src/test, don't run clover -->
          <!--attainGoal name="clover"/-->
      </goal>
  
  </project>
  
  
  
  1.1                  
incubator-geronimo/modules/maven-xmlbeans-plugin/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  <?xml version="1.0"?>
  
  <!-- ================================================================== -->
  <!-- Geronimo deployment plugin                                         -->
  <!-- ================================================================== -->
  <project xmlns:j="jelly:core"
      xmlns:u="jelly:util"
      xmlns:ant="jelly:ant"
      xmlns:maven="jelly:maven"
      xmlns:define="jelly:define"
      xmlns:xmlbeans="geronimo:xmlbeans"
      >
  
      <define:taglib uri="geronimo:xmlbeans">
  
  
          <define:tag name="schema2java" xmlns="jelly:ant">
  
              <j:if test="${targetdir == null}">
                  <fail>Missing required attribute: targetdir</fail>
              </j:if>
              <j:if test="${sourceschema == null}">
                  <fail>Missing required attribute: sourceschema</fail>
              </j:if>
              <j:if test="${xmlconfigs == null}">
                  <fail>Missing required attribute: xmlconfigs</fail>
              </j:if>
              <j:jelly xmlns="jelly:ant">
  
                  <j:set var="uptodatePropName" value="xmlbeans.uptodate"/>
                  <j:expr value="${context.setVariable(uptodatePropName, 
null)}"/>
                  <j:set var="uptodateFile" value="${targetdir}/tstamp"/>
  
                  <uptodate property="${uptodatePropName}"
                      targetfile="${uptodateFile}">
                      <srcfiles dir="${targetdir}" includes="**/*.xsd*"/>
                  </uptodate>
  
                  <j:if test="${context.getVariable(uptodatePropName) == null}">
                      <j:invokeStatic var="dummy" 
className="org.apache.geronimo.tools.xmlbeans.SchemaCompilerWrapper" 
method="CompileSchemas">
                          <j:arg type="java.lang.String" 
value="${sourceschema}"/>
                          <j:arg type="java.lang.String" value="${xmlconfigs}"/>
                          <j:arg type="java.lang.String" value="${targetdir}"/>
                      </j:invokeStatic>
  
                      <touch file="${uptodateFile}"/>
                  </j:if>
  
                  <ant:path id="maven.xmlbeans.compile.src.set"
                            location="${targetdir}"/>
                  <maven:addPath id="maven.compile.src.set"
                                 refid="maven.xmlbeans.compile.src.set"/>
  
  
              </j:jelly>
          </define:tag>
  
  
      </define:taglib>
  
  </project>
  
  
  1.1                  
incubator-geronimo/modules/maven-xmlbeans-plugin/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  <project>
      <pomVersion>3</pomVersion>
      <id>geronimo-maven-xmlbeans-plugin</id>
      <name>Geronimo maven xmlbeans plugin</name>
      <groupId>geronimo</groupId>
      <currentVersion>DEV</currentVersion>
      <organization>
          <name>Apache Software Foundation</name>
          <url>http://www.apache.org/</url>
          <logo></logo>
      </organization>
      <inceptionYear>2004</inceptionYear>
      <package>org.apache.geronimo</package>
      <logo></logo>
  
      <dependencies>
  
          <dependency>
              <groupId>xml-commons-resolver</groupId>
              <artifactId>xml-commons-resolver</artifactId>
              <version>1.1</version>
              <properties>
                  <classloader>root</classloader>
              </properties>
          </dependency>
  
          <dependency>
              <groupId>xmlbeans</groupId>
              <artifactId>xbean-apache</artifactId>
              <version>1.0-DEV</version>
              <properties>
                  <classloader>root</classloader>
              </properties>
          </dependency>
  
  
      </dependencies>
  
      <build>
          <sourceDirectory>src/java</sourceDirectory>
          <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
  
          <unitTest>
              <includes>
                  <include>**/*Test.java</include>
              </includes>
          </unitTest>
  
          <resources>
              <resource>
                  <directory>src/plugin-resources</directory>
                  <targetPath>plugin-resources</targetPath>
              </resource>
              <resource>
                  <directory>.</directory>
                  <includes>
                      <include>plugin.jelly</include>
                      <include>plugin.properties</include>
                      <include>project.properties</include>
                      <include>project.xml</include>
                  </includes>
              </resource>
          </resources>
  
      </build>
  
  
  </project>
  
  
  
  1.1                  
incubator-geronimo/modules/maven-xmlbeans-plugin/src/java/org/apache/geronimo/tools/xmlbeans/SchemaCompilerWrapper.java
  
  Index: SchemaCompilerWrapper.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.tools.xmlbeans;
  
  import java.io.File;
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.List;
  import java.util.StringTokenizer;
  
  import org.apache.xmlbeans.impl.tool.SchemaCompiler;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/02/02 22:04:21 $
   *
   * */
  public class SchemaCompilerWrapper {
  
      public static void CompileSchemas(String sourceSchemas, String 
xmlConfigs, String targetDir) throws Exception {
          List schemas = new ArrayList();
          for (StringTokenizer st = new StringTokenizer(sourceSchemas, ","); 
st.hasMoreTokens();) {
              String schemaName = st.nextToken();
              schemas.add(new File(schemaName));
          }
          List configs = new ArrayList();
  
          if (xmlConfigs != null) {
              for (StringTokenizer st = new StringTokenizer(xmlConfigs, ","); 
st.hasMoreTokens();) {
                  String configName = st.nextToken();
                  configs.add(new File(configName));
              }
          }
          SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
          params.setBaseDir(null);
          params.setXsdFiles((File[])schemas.toArray(new File[] {}));
          params.setWsdlFiles(new File[] {});
          params.setJavaFiles(new File[] {});
          params.setConfigFiles((File[])configs.toArray(new File[] {}));
          params.setClasspath(new File[] {});
          params.setOutputJar(null);
          params.setName(null);
          params.setSrcDir(new File(targetDir));
          params.setClassesDir(new File(targetDir));
          params.setCompiler(null);
          params.setJar(null);
          params.setMemoryInitialSize(null);
          params.setMemoryMaximumSize(null);
          params.setNojavac(true);
          params.setQuiet(false);
          params.setVerbose(true);
          params.setDownload(true);
          params.setNoUpa(true);
          params.setNoPvr(true);
          params.setDebug(true);
          params.setErrorListener(new ArrayList());
          params.setRepackage(null);
          params.setExtensions(null);
          params.setJaxb(false);
          params.setMdefNamespaces(null);
  
          boolean result = SchemaCompiler.compile(params);
          if (!result) {
              Collection errors = params.getErrorListener();
              for (Iterator iterator = errors.iterator(); iterator.hasNext();) {
                  Object o = (Object) iterator.next();
                  System.out.println("xmlbeans error: " + o);
              }
              throw new Exception("Schema compilation failed");
          }
  
      }
  
  }
  
  
  

Reply via email to