directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 55189 - in incubator/directory/eve/trunk/backend/maven-eve-plugin: . src/java/org/apache/eve/tools/schema
Date Thu, 21 Oct 2004 03:12:05 GMT
Author: akarasulu
Date: Wed Oct 20 20:12:04 2004
New Revision: 55189

Added:
   incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/EveSchemaToolTask.java
Modified:
   incubator/directory/eve/trunk/backend/maven-eve-plugin/plugin.jelly
   incubator/directory/eve/trunk/backend/maven-eve-plugin/plugin.properties
   incubator/directory/eve/trunk/backend/maven-eve-plugin/project.properties
   incubator/directory/eve/trunk/backend/maven-eve-plugin/project.xml
Log:
Commit changes ...

 o added ant task
 o finished off jelly in our own little way
 o got all generations working
 o setup defaults and tested

Notes ...

 o we still need to make sure we use the proper paths from maven
   we currently have things like src/java hard coded in the system



Modified: incubator/directory/eve/trunk/backend/maven-eve-plugin/plugin.jelly
==============================================================================
--- incubator/directory/eve/trunk/backend/maven-eve-plugin/plugin.jelly	(original)
+++ incubator/directory/eve/trunk/backend/maven-eve-plugin/plugin.jelly	Wed Oct 20 20:12:04
2004
@@ -2,10 +2,12 @@
  
 <project xmlns:j="jelly:core" xmlns:ant="jelly:ant" xmlns:util="jelly:util" xmlns:maven="jelly:maven">
 
-  <!-- Dir for generated source files -->
-  <j:set var="eveTargetDir" value="${maven.eve.schema.target.dir}"/>
-  <j:set var="eveSchemaDir" value="${maven.eve.schema.dir}"/>
-  <j:set var="eveSchemas" value="${maven.eve.schemas}"/>
+  <goal name="eve:init">
+	<!-- Dir for generated source files -->
+	<j:set var="eveTargetDir" value="${maven.eve.schema.target.dir}"/>
+	<j:set var="eveSchemaDir" value="${maven.eve.schema.dir}"/>
+	<j:set var="eveSchemas" value="${maven.eve.schemas}"/>
+  </goal>
 
   <goal name="eve:prepare-filesystem">
     <j:if test="${!eveTargetDir.equals('MAVEN_EVE_TARGET_DIR_NOT_SET')}">
@@ -23,43 +25,50 @@
       <maven:addPath id="maven.compile.src.set"
                      refid="maven.eve.schema.compile.src.set"/>
 
-
-      <ant:taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask" />
-      
       <!-- TODO: use this for src.dir, but smarter for individual schemas -->
       <!-- TODO: it seems that if target exists but the flagfile doesn't, it doesn't compile?
-->
-      <ant:uptodate property="maven.jaxb.buildNotRequired" targetfile="${maven.build.dir}/jaxb/.flagfile">
+      <ant:uptodate property="maven.eve.schema.buildNotRequired" targetfile="${maven.build.dir}/schema/.flagfile">
         <ant:srcfiles
-          dir   = "${maven.jaxb.src.dir}"
-          includes = "*.xsd"/>
+          dir   = "${maven.eve.schema.dir}"
+          includes = "*.schema"/>
       </ant:uptodate>
       
-      <j:set var="jaxbBuildNotRequired" value="${maven.jaxb.buildNotRequired}" />
-      <j:if test="${jaxbBuildNotRequired == null}">
-        <j:if test="${jaxbSchemas.equals('MAVEN_JAXB_SCHEMAS_NOT_SET')}">
-          <xjc target="${maven.build.dir}/jaxb">
-            <ant:schema dir="${maven.jaxb.src.dir}" includes="*.xsd" />
-            <ant:classpath>
-              <ant:pathelement path="${maven.build.dest}" />
-            </ant:classpath>
-          </xjc>
-        </j:if>
-        <j:if test="${!jaxbSchemas.equals('MAVEN_JAXB_SCHEMAS_NOT_SET')}">
-          <util:tokenize var="schemas" delim=" ">
-            ${maven.jaxb.schemas}
+      <j:set var="eveSchemaBuildNotRequired" value="${maven.eve.schema.buildNotRequired}"
/>
+      <j:if test="${eveSchemaBuildNotRequired == null}">
+      
+        <j:if test="${!eveSchemas.equals('MAVEN_EVE_SCHEMAS_NOT_SET')}">
+          <util:tokenize var="schemas" delim=",">
+            ${maven.eve.schemas}
           </util:tokenize>
+          
           <j:forEach var="schema" items="${schemas.iterator()}">
-            <xjc target="${maven.build.dir}/jaxb" schema="${maven.jaxb.src.dir}/${schema}">
-              <ant:classpath>
-                <ant:pathelement path="${maven.build.dest}" />
-              </ant:classpath>
-            </xjc>
+          
+            <j:set var="ownerProp" value="maven.eve.schema.owner.${schema}"/>
+            <j:set var="owner" value="${context.getVariable(ownerProp)}"
+            	defaultValue="${maven.eve.schema.ownerDefault}"/>
+			
+            <j:set var="packageProp" value="maven.eve.schema.package.${schema}"/>
+            <j:set var="package" value="${context.getVariable(packageProp)}"
+            	defaultValue="${maven.eve.schema.packageDefault}"/>
+			
+            <j:set var="depsProp" value="maven.eve.schema.deps.${schema}"/>
+            <j:set var="deps" value="${context.getVariable(depsProp)}"/>
+
+			<!--
+			<echo>======= schema: ${schema} ======= </echo>
+			<echo>maven.eve.schema.owner.${schema} = ${owner}</echo>
+			<echo>maven.eve.schema.package.${schema} = ${package}</echo>
+			<echo>maven.eve.schema.deps.${schema} = ${deps}</echo>
+			-->
+
+			<j:useBean var="task" class="org.apache.eve.tools.schema.EveSchemaToolTask" 
+				name="${schema}" owner="${owner}" package="${package}" dependencies="${deps}"/>
+			<j:expr value="${task.execute()}"/>
           </j:forEach>
+          
         </j:if>
-        <ant:copy todir="${maven.build.dest}">
-          <ant:fileset dir="${maven.build.dir}/jaxb" includes="**/*.properties,**/bgm.ser"
/>
-        </ant:copy>
-        <ant:touch file="${maven.build.dir}/jaxb/.flagfile" />
+        
+        <ant:touch file="${maven.build.dir}/schema/.flagfile" />
       </j:if>
       
     </j:if>
@@ -67,12 +76,13 @@
 
 
   <preGoal name="java:compile">
-    <j:if test="${!jaxbSrcDir.equals('MAVEN_JAXB_SRC_DIR_NOT_SET')}">
-      <attainGoal name="jaxb:generate"/>
+    <j:if test="${!eveSchemaDir.equals('MAVEN_EVE_SCHEMA_DIR_NOT_SET')}">
+      <attainGoal name="eve:generate"/>
     </j:if>
   </preGoal>
 
   <goal name="eve"> 
+    <attainGoal name="eve:init"/>
     <attainGoal name="eve:generate"/>
   </goal> 
   

Modified: incubator/directory/eve/trunk/backend/maven-eve-plugin/plugin.properties
==============================================================================
--- incubator/directory/eve/trunk/backend/maven-eve-plugin/plugin.properties	(original)
+++ incubator/directory/eve/trunk/backend/maven-eve-plugin/plugin.properties	Wed Oct 20 20:12:04
2004
@@ -1 +1,4 @@
 maven.eve.schema.dir=src/schema
+maven.eve.schema.target.dir=target/schema
+maven.eve.schema.packageDefault=org.apache.eve.schema.bootstrap
+maven.eve.schema.ownerDefault=cn=admin,ou=system

Modified: incubator/directory/eve/trunk/backend/maven-eve-plugin/project.properties
==============================================================================
--- incubator/directory/eve/trunk/backend/maven-eve-plugin/project.properties	(original)
+++ incubator/directory/eve/trunk/backend/maven-eve-plugin/project.properties	Wed Oct 20 20:12:04
2004
@@ -22,4 +22,14 @@
 maven.antlr.src.dir=src/antlr
 
 # eve schema configuration
-maven.eve.schema.dir=src/schema
\ No newline at end of file
+maven.eve.schemas=core,java,inetorgperson
+
+maven.eve.schema.deps.core=system
+maven.eve.schema.owner.core=cn=admin,ou=system
+
+maven.eve.schema.deps.java=system,core
+maven.eve.schema.owner.java=cn=admin,ou=system
+maven.eve.schema.package.java=org.apache.eve.schema.optional
+
+maven.eve.schema.deps.inetorgperson=system,core
+

Modified: incubator/directory/eve/trunk/backend/maven-eve-plugin/project.xml
==============================================================================
--- incubator/directory/eve/trunk/backend/maven-eve-plugin/project.xml	(original)
+++ incubator/directory/eve/trunk/backend/maven-eve-plugin/project.xml	Wed Oct 20 20:12:04
2004
@@ -1,20 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- 
-/*
- * Copyright 2001-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.
- */
+<!-- 
+/*
+ * Copyright 2001-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>
   <extend>${basedir}/../../project.xml</extend>
@@ -24,17 +24,23 @@
   <id>maven-eve-plugin</id>
   <name>maven-eve-plugin</name>
   <package>org.apache.eve.tools</package>
-  <currentVersion>SNAPSHOT</currentVersion>
+  <currentVersion>1.0</currentVersion>
   <inceptionYear>2004</inceptionYear>
   <shortDescription>A collection of eve tools as a maven plugin</shortDescription>
-  <description>
-    A collection of tools as plugins to be used to develop Eve and program for Eve.
+  <description>
+    A collection of tools as plugins to be used to develop Eve and program for Eve.
   </description>
   <dependencies>
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>3.8.1</version>
+      <type>jar</type>
+    </dependency>
+    <dependency>
+      <groupId>ant</groupId>
+      <artifactId>ant</artifactId>
+      <version>1.6.2</version>
       <type>jar</type>
     </dependency>
     <dependency>

Added: incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/EveSchemaToolTask.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/EveSchemaToolTask.java
Wed Oct 20 20:12:04 2004
@@ -0,0 +1,116 @@
+/*
+ *   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.
+ *
+ */
+package org.apache.eve.tools.schema;
+
+
+import org.apache.tools.ant.BuildException;
+import org.apache.eve.schema.bootstrap.AbstractBootstrapSchema;
+
+
+/**
+ * Document this class.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class EveSchemaToolTask extends org.apache.tools.ant.Task
+{
+    private String pkg;
+    private String name;
+    private String owner;
+    private String[] dependencies;
+
+
+    public void setPackage( String pkg )
+    {
+        this.pkg = pkg;
+    }
+
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+
+    public void setOwner( String owner )
+    {
+        this.owner = owner;
+    }
+
+
+    public void setDependencies( String deps )
+    {
+        dependencies = deps.split( "," );
+
+        for ( int ii = 0; ii < dependencies.length; ii++ )
+        {
+            dependencies[ii] = dependencies[ii].trim();
+        }
+    }
+
+
+    public void execute() throws BuildException
+    {
+        super.execute();
+        EveSchemaTool tool;
+
+        try
+        {
+            tool = new EveSchemaTool();
+        }
+        catch ( Exception e )
+        {
+            throw new BuildException( "Failed to create schema tool", e );
+        }
+
+        AbstractBootstrapSchema schema =
+                new AbstractBootstrapSchema( owner, name, pkg, dependencies ){};
+        tool.setSchema( schema );
+
+        try
+        {
+            tool.generate();
+        }
+        catch ( Exception e )
+        {
+            throw new BuildException( "Failed to generate " + name +
+                    " schema classes in package " + pkg, e );
+        }
+    }
+    
+    
+    public String toString()
+    {
+    	StringBuffer buf = new StringBuffer();
+    	buf.append( "\nSCHEMA:\nname = " ).append( name ).append( '\n' );
+    	buf.append( "owner = " ).append( owner ).append( '\n' );
+    	buf.append( "package = " ).append( pkg ).append( '\n' );
+    	buf.append( "dependencies = " );
+    	
+    	for ( int ii = 0; ii < dependencies.length; ii++ )
+    	{
+    		buf.append( dependencies[ii] );
+    		if ( ii < dependencies.length-1 )
+    		{
+    			buf.append( ',' );
+    		}
+    	}
+    	
+    	return buf.toString();
+    }
+}

Mime
View raw message