You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gn...@apache.org on 2006/04/28 17:32:10 UTC

svn commit: r397923 - in /geronimo/xbean/trunk: maven-xbean-plugin/src/main/java/org/apache/xbean/maven/XBeanMojo.java xbean-jmx/pom.xml xbean-server/pom.xml xbean-tiger/pom.xml

Author: gnodet
Date: Fri Apr 28 08:32:07 2006
New Revision: 397923

URL: http://svn.apache.org/viewcvs?rev=397923&view=rev
Log:
XBEAN-4: Use maven plugin for other modules.

Modified:
    geronimo/xbean/trunk/maven-xbean-plugin/src/main/java/org/apache/xbean/maven/XBeanMojo.java
    geronimo/xbean/trunk/xbean-jmx/pom.xml
    geronimo/xbean/trunk/xbean-server/pom.xml
    geronimo/xbean/trunk/xbean-tiger/pom.xml

Modified: geronimo/xbean/trunk/maven-xbean-plugin/src/main/java/org/apache/xbean/maven/XBeanMojo.java
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/maven-xbean-plugin/src/main/java/org/apache/xbean/maven/XBeanMojo.java?rev=397923&r1=397922&r2=397923&view=diff
==============================================================================
--- geronimo/xbean/trunk/maven-xbean-plugin/src/main/java/org/apache/xbean/maven/XBeanMojo.java (original)
+++ geronimo/xbean/trunk/maven-xbean-plugin/src/main/java/org/apache/xbean/maven/XBeanMojo.java Fri Apr 28 08:32:07 2006
@@ -19,7 +19,6 @@
 
 import java.beans.PropertyEditorManager;
 import java.io.File;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Iterator;
@@ -28,9 +27,11 @@
 import java.util.Set;
 import java.util.StringTokenizer;
 
+import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
 import org.apache.tools.ant.BuildException;
 import org.apache.xbean.spring.generator.DocumentationGenerator;
 import org.apache.xbean.spring.generator.GeneratorPlugin;
@@ -46,11 +47,16 @@
  * @version $Id: GenerateApplicationXmlMojo.java 314956 2005-10-12 16:27:15Z brett $
  * @goal mapping
  * @description Creates xbean mapping file
- * @phase process-classes
- * @requiresDependencyResolution runtime
+ * @phase generate-sources
  */
 public class XBeanMojo extends AbstractMojo implements LogFacade {
 
+    /**
+     * @parameter expression="${project}"
+     * @required
+     */
+    private MavenProject project;
+    
 	/**
      * @parameter
      * @required
@@ -64,16 +70,15 @@
     private File srcDir;
     
     /**
-     * @parameter expression="${basedir}/target/classes/schema.xsd"
+     * @parameter expression="${basedir}/target/xbean/"
      * @required
      */
-    private File destFile;
+    private File outputDir;
     
     /**
-     * @parameter expression="${basedir}/target/classes/"
-     * @required
+     * @parameter
      */
-    private File metaInfDir;
+    private File schema;
     
     /**
      * @parameter expression="org.apache.xbean.spring.context.impl"
@@ -85,10 +90,14 @@
         getLog().debug( " ======= XBeanMojo settings =======" );
         getLog().debug( "namespace[" + namespace + "]" );
         getLog().debug( "srcDir[" + srcDir + "]" );
-        getLog().debug( "destFile[" + destFile + "]" );
-        getLog().debug( "metaInfDir[" + metaInfDir + "]" );
+        getLog().debug( "schema[" + schema + "]" );
+        getLog().debug( "outputDir[" + outputDir + "]" );
         getLog().debug( "propertyEditorPaths[" + propertyEditorPaths + "]" );
 
+        if (schema == null) {
+            schema = new File(outputDir, project.getArtifactId() + ".xsd");
+        }
+        
         if (propertyEditorPaths != null) {
             List editorSearchPath = new LinkedList(Arrays.asList(PropertyEditorManager.getEditorSearchPath()));
             StringTokenizer paths = new StringTokenizer(propertyEditorPaths, " ,");
@@ -99,13 +108,13 @@
         ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
         try {
-        	destFile.getParentFile().mkdirs();
+        	schema.getParentFile().mkdirs();
         	
             MappingLoader mappingLoader = new QdoxMappingLoader(namespace, new File[] { srcDir });
             GeneratorPlugin[] plugins = new GeneratorPlugin[]{
-                new XmlMetadataGenerator(this, metaInfDir.getAbsolutePath()),
-                new DocumentationGenerator(this, destFile),
-                new XsdGenerator(this, destFile)
+                new XmlMetadataGenerator(this, outputDir.getAbsolutePath()),
+                new DocumentationGenerator(this, schema),
+                new XsdGenerator(this, schema)
             };
 
             // load the mappings
@@ -122,6 +131,10 @@
                     plugin.generate(namespaceMapping);
                 }
             }
+            
+            Resource res = new Resource();
+            res.setDirectory(outputDir.toString());
+            project.addResource(res);
 
             log("...done.");
         } catch (Exception e) {
@@ -130,26 +143,6 @@
             Thread.currentThread().setContextClassLoader(oldCL);
         }
 	}
-
-    private File[] getFiles(File path) {
-        if (path == null) {
-            return null;
-        }
-        ArrayList files = new ArrayList();
-        recursiveList(path, files);
-        return (File[]) files.toArray(new File[files.size()]);
-    }
-    
-    private void recursiveList(File path, List files) {
-    	File[] children = path.listFiles();
-    	for (int i = 0; i < children.length; i++) {
-			if (children[i].isFile()) {
-				files.add(children[i]);
-			} else if (children[i].isDirectory()) {
-				recursiveList(children[i], files);
-			}
-		}
-    }
 
 	public void log(String message) {
 		getLog().info(message);

Modified: geronimo/xbean/trunk/xbean-jmx/pom.xml
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/pom.xml?rev=397923&r1=397922&r2=397923&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/pom.xml (original)
+++ geronimo/xbean/trunk/xbean-jmx/pom.xml Fri Apr 28 08:32:07 2006
@@ -21,33 +21,21 @@
         </resources>
 
         <plugins>
-            <plugin>
-                <artifactId>maven-antrun-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <phase>process-classes</phase>
-                        <goals>
-                            <goal>run</goal>
-                        </goals>
-                        <configuration>
-                            <tasks>
-                                <taskdef classname="org.apache.xbean.spring.generator.MappingGeneratorTask"
-                                         name="mapping">
-                                    <classpath>
-                                        <pathelement path="${basedir}/target/classes"></pathelement>
-                                        <path refid="maven.runtime.classpath"></path>
-                                    </classpath>
-                                </taskdef>
-                                <mapping namespace="http://xbean.apache.org/schemas/jmx" srcdir="src/main/java"
-                                         destFile="target/jmx.xsd" metaInfDir="${basedir}/target/generated/"></mapping>
-                                <copy todir="${basedir}/target/classes">
-                                    <fileset dir="${basedir}/target/generated"></fileset>
-                                </copy>
-                            </tasks>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
+          <plugin>
+            <groupId>org.apache.xbean</groupId>
+            <artifactId>maven-xbean-plugin</artifactId>
+            <version>${pom.version}</version>
+            <executions>
+              <execution>
+                <goals>
+                  <goal>mapping</goal>
+                </goals>
+              </execution>
+            </executions>
+            <configuration>
+              <namespace>http://xbean.apache.org/schemas/jmx</namespace>
+            </configuration>
+          </plugin>
         </plugins>
     </build>
 

Modified: geronimo/xbean/trunk/xbean-server/pom.xml
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-server/pom.xml?rev=397923&r1=397922&r2=397923&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-server/pom.xml (original)
+++ geronimo/xbean/trunk/xbean-server/pom.xml Fri Apr 28 08:32:07 2006
@@ -11,9 +11,6 @@
   <build>
     <resources>
       <resource>
-        <directory>target/generated</directory>
-      </resource>
-      <resource>
         <directory>src/main/resources</directory>
       </resource>
     </resources>
@@ -27,29 +24,19 @@
         </configuration>
       </plugin>
       <plugin>
-        <artifactId>maven-antrun-plugin</artifactId>
+        <groupId>org.apache.xbean</groupId>
+        <artifactId>maven-xbean-plugin</artifactId>
+        <version>${pom.version}</version>
         <executions>
           <execution>
-            <phase>process-classes</phase>
             <goals>
-              <goal>run</goal>
+              <goal>mapping</goal>
             </goals>
-            <configuration>
-              <tasks>
-                <taskdef classname="org.apache.xbean.spring.generator.MappingGeneratorTask" name="mapping">
-                  <classpath>
-                    <pathelement path="${basedir}/target/classes"></pathelement>
-                    <path refid="maven.runtime.classpath"></path>
-                  </classpath>
-                </taskdef>
-                <mapping namespace="http://xbean.apache.org/schemas/jmx" srcdir="src/main/java" destFile="target/jmx.xsd" metaInfDir="${basedir}/target/generated/"></mapping>
-                <copy todir="${basedir}/target/classes">
-                  <fileset dir="${basedir}/target/generated"></fileset>
-                </copy>
-              </tasks>
-            </configuration>
           </execution>
         </executions>
+        <configuration>
+          <namespace>http://xbean.apache.org/schemas/server</namespace>
+        </configuration>
       </plugin>
     </plugins>
   </build>
@@ -74,4 +61,4 @@
       <artifactId>commons-logging</artifactId>
     </dependency>
   </dependencies>
-</project>
\ No newline at end of file
+</project>

Modified: geronimo/xbean/trunk/xbean-tiger/pom.xml
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-tiger/pom.xml?rev=397923&r1=397922&r2=397923&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-tiger/pom.xml (original)
+++ geronimo/xbean/trunk/xbean-tiger/pom.xml Fri Apr 28 08:32:07 2006
@@ -27,6 +27,22 @@
         </configuration>
       </plugin>
       <plugin>
+        <groupId>org.apache.xbean</groupId>
+        <artifactId>maven-xbean-plugin</artifactId>
+        <version>${pom.version}</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>mapping</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <namespace>http://xbean.apache.org/schemas/tiger</namespace>
+        </configuration>
+      </plugin>
+      <!--
+      <plugin>
         <artifactId>maven-antrun-plugin</artifactId>
         <executions>
           <execution>
@@ -51,6 +67,7 @@
           </execution>
         </executions>
       </plugin>
+      -->
     </plugins>
   </build>
   <dependencies>