You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2005/07/13 07:22:21 UTC
svn commit: r216115 [2/2] - in /geronimo/trunk: etc/ modules/assembly/
modules/assembly/src/plan/ modules/axis-builder/
modules/axis-builder/src/java/org/apache/geronimo/axis/builder/
modules/client-builder/ modules/client-builder/src/schema/ modules/c...
Added: geronimo/trunk/plugins/maven-xmlbeans2-plugin/NOTICE.txt
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/maven-xmlbeans2-plugin/NOTICE.txt?rev=216115&view=auto
==============================================================================
--- geronimo/trunk/plugins/maven-xmlbeans2-plugin/NOTICE.txt (added)
+++ geronimo/trunk/plugins/maven-xmlbeans2-plugin/NOTICE.txt Tue Jul 12 22:22:18 2005
@@ -0,0 +1,3 @@
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
Added: geronimo/trunk/plugins/maven-xmlbeans2-plugin/maven.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/maven-xmlbeans2-plugin/maven.xml?rev=216115&view=auto
==============================================================================
--- geronimo/trunk/plugins/maven-xmlbeans2-plugin/maven.xml (added)
+++ geronimo/trunk/plugins/maven-xmlbeans2-plugin/maven.xml Tue Jul 12 22:22:18 2005
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright 2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+
+<!-- $Rev: 54655 $ $Date: 2004-10-11 23:58:41 -0700 (Mon, 11 Oct 2004) $ -->
+
+<project default="default"
+ xmlns:ant="jelly:ant"
+ xmlns:j="jelly:core">
+
+ <!-- ================= -->
+ <!-- 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="jar:jar"/>
+ <attainGoal name="doinstall"/>
+ </goal>
+
+ <goal name="build">
+ <attainGoal name="default"/>
+ </goal>
+
+ <goal name="rebuild">
+ <attainGoal name="clean"/>
+ <attainGoal name="build"/>
+ </goal>
+
+ <postGoal name="plugin:install">
+ <attainGoal name="doinstall"/>
+ </postGoal>
+
+ <goal name="doinstall">
+ <!--this seems to be needed for the dependency on the plugin to work-->
+ <ant:property name="pluginsDir" value="${maven.repo.local}/${pom.artifactDirectory}/plugins"/>
+ <ant:mkdir dir="${pluginsDir}"/>
+ <ant:copy
+ file="${basedir}/target/${pom.artifactId}-${pom.currentVersion}.jar"
+ todir="${pluginsDir}"
+ overwrite="true"
+ />
+ <!--actually install the plugin into the cache-->
+ <mkdir dir="${maven.plugin.unpacked.dir}/${pom.artifactId}-${pom.currentVersion}"/>
+ <ant:unjar
+ src="${basedir}/target/${pom.artifactId}-${pom.currentVersion}.jar"
+ dest="${maven.plugin.unpacked.dir}/${pom.artifactId}-${pom.currentVersion}/"/>
+ </goal>
+
+ <goal name="clover.wrapper">
+ <!-- no src/test, don't run clover -->
+ <!--attainGoal name="clover"/-->
+ </goal>
+
+ <!-- Remove the log files -->
+ <goal name="clobber"
+ description="Removes all (non-repository installed) build generated files">
+
+ <!-- Let clean:clean do some work first -->
+ <attainGoal name="clean:clean"/>
+
+ <j:jelly xmlns="jelly:ant">
+ <delete quiet="false" failonerror="false">
+ <fileset dir="${basedir}">
+ <include name="maven.log"/>
+ <include name="velocity.log*"/>
+ <include name="junit*.properties"/>
+ </fileset>
+ </delete>
+ </j:jelly>
+ </goal>
+
+ <goal name="java-src"
+ description="Creates an archive containing only java source.">
+
+ <ant:mkdir dir="${basedir}/target"/>
+ <ant:jar destfile="${basedir}/target/${pom.artifactId}-${pom.currentVersion}-java-src.jar">
+ <fileset dir="${basedir}/src/java"/>
+ </ant:jar>
+ </goal>
+
+ <goal name="jar:deploy">
+ <attainGoal name="plugin:repository-deploy"/>
+ </goal>
+</project>
Added: geronimo/trunk/plugins/maven-xmlbeans2-plugin/plugin.jelly
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/maven-xmlbeans2-plugin/plugin.jelly?rev=216115&view=auto
==============================================================================
--- geronimo/trunk/plugins/maven-xmlbeans2-plugin/plugin.jelly (added)
+++ geronimo/trunk/plugins/maven-xmlbeans2-plugin/plugin.jelly Tue Jul 12 22:22:18 2005
@@ -0,0 +1,87 @@
+<?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="xmlbeans2:maven"
+ >
+
+ <define:taglib uri="xmlbeans2:maven">
+ <define:jellybean
+ name="SchemaCompilerWrapper"
+ className="org.apache.xmlbeans.maven.SchemaCompilerWrapper"
+ method="compileSchemas"/>
+
+
+ <define:tag name="schema2java" xmlns="jelly:ant">
+
+ <j:if test="${targetdir == null}">
+ <fail>Missing required attribute: targetdir</fail>
+ </j:if>
+ <j:if test="${sourcedir == null}">
+ <fail>Missing required attribute: sourcedir</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>
+
+ <!-- set up classpath for already-compiled schemas -->
+ <j:forEach var="artifact" items="${pom.artifacts}">
+ <j:set var="dependency" value="${artifact.dependency}"/>
+ <j:if test="${dependency.getProperty('xmlbeans') == 'true'}">
+ <j:set var="xmlbeans.classpath" value="${xmlbeans.classpath},${artifact.path}"/>
+ </j:if>
+ </j:forEach>
+
+ <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="${sourcedir}"
+ includes="${sourceschema}"/>
+ </uptodate>
+
+ <xmlbeans:SchemaCompilerWrapper
+ sourceDir="${sourcedir}"
+ sourceSchemas="${sourceschema}"
+ xmlConfigs="${xmlconfigs}"
+ javaTargetDir="${targetdir}"
+ classTargetDir="${maven.build.dest}"
+ catalogLocation="${cataloglocation}"
+ classPath="${xmlbeans.classpath}"
+ resources="${pom.build.resources}"
+ buildSchemas="${context.getVariable(uptodatePropName) == null}"
+ />
+ <j:if test="${context.getVariable(uptodatePropName) == null}">
+ <touch file="${uptodateFile}"/>
+ </j:if>
+
+ <path id="maven.xmlbeans.compile.src.set"
+ location="${targetdir}"/>
+ <j:if test="${context.antProject.getReference('maven.compile.src.set') != null}">
+ <maven:addPath id="maven.compile.src.set"
+ refid="maven.xmlbeans.compile.src.set"/>
+ </j:if>
+ <j:if test="${context.antProject.getReference('maven.compile.src.set') == null}">
+ <echo message="Maven cannot find the generated sources unless you provide a dummy source directory in project.xml"/>
+ </j:if>
+
+ </j:jelly>
+ </define:tag>
+
+
+ </define:taglib>
+
+</project>
\ No newline at end of file
Added: geronimo/trunk/plugins/maven-xmlbeans2-plugin/project.properties
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/maven-xmlbeans2-plugin/project.properties?rev=216115&view=auto
==============================================================================
--- geronimo/trunk/plugins/maven-xmlbeans2-plugin/project.properties (added)
+++ geronimo/trunk/plugins/maven-xmlbeans2-plugin/project.properties Tue Jul 12 22:22:18 2005
@@ -0,0 +1,16 @@
+# Copyright 2004 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+maven.multiproject.type=plugin
+
Added: geronimo/trunk/plugins/maven-xmlbeans2-plugin/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/maven-xmlbeans2-plugin/project.xml?rev=216115&view=auto
==============================================================================
--- geronimo/trunk/plugins/maven-xmlbeans2-plugin/project.xml (added)
+++ geronimo/trunk/plugins/maven-xmlbeans2-plugin/project.xml Tue Jul 12 22:22:18 2005
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright 2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project>
+ <pomVersion>3</pomVersion>
+
+ <groupId>geronimo</groupId>
+ <id>xmlbeans-maven-plugin</id>
+ <currentVersion>2.0.0-beta1</currentVersion>
+ <name>xmlbeans maven plugin</name>
+ <organization>
+ <name>Apache Software Foundation</name>
+ <url>http://www.apache.org/</url>
+ <logo></logo>
+ </organization>
+ <inceptionYear>2004</inceptionYear>
+ <package>org.apache.xmlbeans.maven</package>
+ <logo></logo>
+
+ <dependencies>
+ <dependency>
+ <groupId>xml-resolver</groupId>
+ <artifactId>xml-resolver</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>xmlbeans</groupId>
+ <artifactId>xbean</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax</artifactId>
+ <version>1.1.1-dev</version>
+ </dependency>
+
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>maven</groupId>
+ <artifactId>maven</artifactId>
+ <version>1.0.2</version>
+ </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>
Added: geronimo/trunk/plugins/maven-xmlbeans2-plugin/src/java/org/apache/xmlbeans/maven/SchemaCompilerWrapper.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/maven-xmlbeans2-plugin/src/java/org/apache/xmlbeans/maven/SchemaCompilerWrapper.java?rev=216115&view=auto
==============================================================================
--- geronimo/trunk/plugins/maven-xmlbeans2-plugin/src/java/org/apache/xmlbeans/maven/SchemaCompilerWrapper.java (added)
+++ geronimo/trunk/plugins/maven-xmlbeans2-plugin/src/java/org/apache/xmlbeans/maven/SchemaCompilerWrapper.java Tue Jul 12 22:22:18 2005
@@ -0,0 +1,257 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.maven;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.maven.project.Resource;
+import org.apache.xml.resolver.CatalogManager;
+import org.apache.xml.resolver.tools.CatalogResolver;
+import org.apache.xmlbeans.impl.tool.SchemaCompiler;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+
+/**
+ *
+ *
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ *
+ * */
+public class SchemaCompilerWrapper {
+
+ private String sourceDir;
+ private String sourceSchemas;
+ private String xmlConfigs;
+ private String javaTargetDir;
+ private String classTargetDir;
+ private String catalogLocation;
+ private String classPath;
+ private List resources;
+ private boolean buildSchemas;
+
+ public String getSourceDir() {
+ return sourceDir;
+ }
+
+ public void setSourceDir(String sourceDir) {
+ this.sourceDir = sourceDir;
+ }
+
+ public String getSourceSchemas() {
+ return sourceSchemas;
+ }
+
+ public void setSourceSchemas(String sourceSchemas) {
+ this.sourceSchemas = sourceSchemas;
+ }
+
+ public String getXmlConfigs() {
+ return xmlConfigs;
+ }
+
+ public void setXmlConfigs(String xmlConfigs) {
+ this.xmlConfigs = xmlConfigs;
+ }
+
+ public String getJavaTargetDir() {
+ return javaTargetDir;
+ }
+
+ public void setJavaTargetDir(String javaTargetDir) {
+ this.javaTargetDir = javaTargetDir;
+ }
+
+ public String getClassTargetDir() {
+ return classTargetDir;
+ }
+
+ public void setClassTargetDir(String classTargetDir) {
+ this.classTargetDir = classTargetDir;
+ }
+
+ public String getCatalogLocation() {
+ return catalogLocation;
+ }
+
+ public void setCatalogLocation(String catalogLocation) {
+ this.catalogLocation = catalogLocation;
+ }
+
+ public String getClassPath() {
+ return classPath;
+ }
+
+ public void setClassPath(String classPath) {
+ this.classPath = classPath;
+ }
+
+ public List getResources() {
+ return resources;
+ }
+
+ public void setResources(List resources) {
+ System.out.println("setResources: " + resources);
+ this.resources = resources;
+ }
+
+ public boolean isBuildSchemas() {
+ return buildSchemas;
+ }
+
+ public void setBuildSchemas(boolean buildSchemas) {
+ System.out.println("setBuildSchemas: " + buildSchemas);
+ this.buildSchemas = buildSchemas;
+ }
+
+ public void compileSchemas() throws Exception {
+ List schemas = new ArrayList();
+ File base = new File(sourceDir);
+ Resource resource = new Resource();
+ resource.setDirectory(sourceDir);
+ resource.setTargetPath("META-INF");
+ for (StringTokenizer st = new StringTokenizer(sourceSchemas, ","); st.hasMoreTokens();) {
+ String schemaName = st.nextToken();
+ schemas.add(new File(base, schemaName));
+ resource.addInclude(schemaName);
+ }
+ resources.add(resource);
+ if (buildSchemas) {
+ List configs = new ArrayList();
+
+ if (xmlConfigs != null) {
+ for (StringTokenizer st = new StringTokenizer(xmlConfigs, ","); st.hasMoreTokens();) {
+ String configName = st.nextToken();
+ configs.add(new File(configName));
+ }
+ }
+ List classPathList = new ArrayList();
+ List urls = new ArrayList();
+ if (classPath != null) {
+ for (StringTokenizer st = new StringTokenizer(classPath, ","); st.hasMoreTokens();) {
+ String classpathElement = st.nextToken();
+ File file = new File(classpathElement);
+ classPathList.add(file);
+ urls.add(file.toURL());
+ System.out.println("Adding to classpath: " + file);
+ }
+ }
+ ClassLoader cl = new URLClassLoader((URL[]) urls.toArray(new URL[] {}));
+ EntityResolver entityResolver = null;
+ if (catalogLocation != null) {
+ CatalogManager catalogManager = CatalogManager.getStaticManager();
+ catalogManager.setCatalogFiles(catalogLocation);
+ entityResolver = new CatalogResolver();
+ }
+ URI sourceDirURI = new File(sourceDir).toURI();
+ entityResolver = new PassThroughResolver(cl, entityResolver, sourceDirURI);
+
+ 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((File[])classPathList.toArray(new File[] {}));
+ params.setOutputJar(null);
+ params.setName(null);
+ params.setSrcDir(new File(javaTargetDir));
+ params.setClassesDir(new File(classTargetDir));
+ params.setCompiler(null);
+ params.setMemoryInitialSize(null);
+ params.setMemoryMaximumSize(null);
+ params.setNojavac(true);
+ params.setQuiet(false);
+ params.setVerbose(true);
+ params.setDownload(false);
+ params.setNoUpa(false);
+ params.setNoPvr(false);
+ params.setDebug(true);
+ params.setErrorListener(new ArrayList());
+ params.setRepackage(null);
+ params.setExtensions(null);
+ params.setMdefNamespaces(null);
+ params.setEntityResolver(entityResolver);
+
+ 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");
+ }
+ }
+
+ }
+
+ private static class PassThroughResolver implements EntityResolver {
+ private final ClassLoader cl;
+ private final EntityResolver delegate;
+ private URI sourceDir;
+
+ public PassThroughResolver(ClassLoader cl, EntityResolver delegate, URI sourceDir) {
+ this.cl = cl;
+ this.delegate = delegate;
+ this.sourceDir = sourceDir;
+ }
+ public InputSource resolveEntity(String publicId,
+ String systemId)
+ throws SAXException, IOException {
+ if (delegate != null) {
+ InputSource is = delegate.resolveEntity(publicId, systemId);
+ if (is != null) {
+ return is;
+ }
+ }
+ System.out.println("Could not resolve publicId: " + publicId + ", systemId: " + systemId + " from catalog");
+ String localSystemId;
+ try {
+ localSystemId = sourceDir.relativize(new URI(systemId)).toString();
+ } catch (URISyntaxException e) {
+ throw (IOException)new IOException("Could not relativeize systemId").initCause(e);
+ }
+ InputStream in = cl.getResourceAsStream(localSystemId);
+ if (in != null) {
+ System.out.println("found in classpath at: " + localSystemId);
+ return new InputSource(in);
+ }
+ in = cl.getResourceAsStream("META-INF/" + localSystemId);
+ if (in != null) {
+ System.out.println("found in classpath at: META-INF/" + localSystemId);
+ return new InputSource(in);
+ }
+ System.out.println("Not found in classpath, looking in current director: " + systemId);
+ return new InputSource(systemId);
+ }
+
+ }
+}