jvanzyl     02/05/29 06:46:24

  Modified:    src/java/org/apache/maven MavenUtils.java
  Log:
  Adding the code to use betwixt instead of the mapper but it's commented
  out at the moment until some final issues are sorted out with
  betwixt.
  
  Revision  Changes    Path
  1.18      +53 -27    jakarta-turbine-maven/src/java/org/apache/maven/MavenUtils.java
  
  Index: MavenUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/MavenUtils.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- MavenUtils.java   27 May 2002 12:19:51 -0000      1.17
  +++ MavenUtils.java   29 May 2002 13:46:24 -0000      1.18
  @@ -57,6 +57,7 @@
    */
   
   import java.io.File;
  +import java.io.FileInputStream;
   import java.util.Iterator;
   
   import org.apache.commons.lang.Strings;
  @@ -65,24 +66,28 @@
   import org.apache.maven.project.Profile;
   import org.apache.maven.project.Workspace;
   
  +import org.apache.commons.betwixt.XMLIntrospector;
  +import org.apache.commons.betwixt.io.BeanReader;
  +import org.apache.commons.betwixt.io.BeanWriter;
  +import org.apache.commons.betwixt.strategy.DecapitalizeNameMapper;
  +
   import org.apache.commons.xo.Mapper;
   
   import org.apache.tools.ant.DirectoryScanner;
   
   /**
  - * An ant task that takes values from the project descriptor and
  - * creates the necessary patternsets and paths required to build
  - * the project.
  + * An ant task that takes values from the project descriptor and creates the
  + * necessary patternsets and paths required to build the project.
    *
    * @author <a href="[EMAIL PROTECTED]">Jason van Zyl</a>
  - * @version $Id: MavenUtils.java,v 1.17 2002/05/27 12:19:51 dion Exp $
  + * @version $Id: MavenUtils.java,v 1.18 2002/05/29 13:46:24 jvanzyl Exp $
    */
   public class MavenUtils
   {
       /**
        * Maven project class name.
        */
  -    private static final String PROJECT_CLASS =
  +    private final static String PROJECT_CLASS =
           "org.apache.maven.project.Project";
   
       /**
  @@ -100,7 +105,8 @@
   
       /**
        * Create a Project object given a file descriptor.
  -     * @param projectDescriptor a maven project.xml {@link File} 
  +     *
  +     * @param projectDescriptor a maven project.xml {@link File}
        * @return the Maven project object for the given project descriptor
        * @throws Exception when any errors occur
        */
  @@ -108,75 +114,95 @@
           throws Exception
       {
           Mapper mapper = new Mapper();
  -        Project project = (Project) mapper.map(projectDescriptor, 
  +        Project project = (Project) mapper.map(projectDescriptor,
               PROJECT_CLASS);
           return project;
  +
  +        /*
  +        XMLIntrospector introspector = new XMLIntrospector();
  +
  +        // set elements for attributes to true
  +        introspector.setAttributesForPrimitives(false);
  +
  +        // wrap collections in an XML element
  +        //introspector.setWrapCollectionsInElement(true);
  +
  +        // turn bean elements into lower case
  +        introspector.setNameMapper(new DecapitalizeNameMapper());
  +
  +        BeanReader reader = new BeanReader();
  +        reader.setXMLIntrospector(introspector);
  +        reader.registerBeanClass(Project.class);
  +
  +        Project project = (Project) reader.parse(new 
FileInputStream(projectDescriptor));
  +        
  +        return project;
  +        */
       }
   
       /**
  -     * Create a Workspace object given a workspace and profile
  -     * descriptor.
  -     * 
  +     * Create a Workspace object given a workspace and profile descriptor.
  +     *
        * @param workspaceDescriptor the file name of a maven workspace descriptor
        * @param profileDescriptor the file name of a maven project descriptor
        * @param mavenLocalRepo a local maven repository
        * @return a maven {@link Workspace} specifed by the given descriptors
        * @throws Exception when any error occurs
        */
  -    public static Workspace getWorkspace(String workspaceDescriptor, 
  +    public static Workspace getWorkspace(String workspaceDescriptor,
                                            String profileDescriptor,
                                            String mavenLocalRepo)
           throws Exception
       {
  -        return getWorkspace(new File(workspaceDescriptor), 
  -                            new File(profileDescriptor),
  -                            new File(mavenLocalRepo));
  +        return getWorkspace(new File(workspaceDescriptor),
  +            new File(profileDescriptor),
  +            new File(mavenLocalRepo));
       }
   
       /**
  -     * Create a <code>{@link Workspace}</code> object given a workspace 
  +     * Create a <code>{@link Workspace}</code> object given a workspace
        * descriptor, a project descriptor and a local repository.
  +     *
        * @param workspaceDescriptor the xml file describing the workspace
        * @param profileDescriptor the xml file describing the projects to build
        * @param mavenLocalRepo the local maven repository
        * @return a {@link Workspace} object ready for building
  -     *
        * @throws Exception when an error occurs
        */
  -    public static Workspace getWorkspace(File workspaceDescriptor, 
  +    public static Workspace getWorkspace(File workspaceDescriptor,
                                            File profileDescriptor,
                                            File mavenLocalRepo)
           throws Exception
       {
           // Create our workspace
  -        Mapper workspaceMapper = new Mapper();        
  +        Mapper workspaceMapper = new Mapper();
           Workspace workspace = (Workspace) workspaceMapper.map(
               workspaceDescriptor, Workspace.class.getName());
  -            
  +
           // Create our profile
  -        Mapper profileMapper = new Mapper();        
  -        Profile profile = (Profile) profileMapper.map(profileDescriptor, 
  +        Mapper profileMapper = new Mapper();
  +        Profile profile = (Profile) profileMapper.map(profileDescriptor,
               Profile.class.getName());
           workspace.setProfile(profile);
  -            
  +
           // Create our set of project.
  -        for (Iterator i = profile.getProjectIds().iterator(); i.hasNext();)
  +        for (Iterator i = profile.getProjectIds().iterator(); i.hasNext(); )
           {
               String projectId = (String) i.next();
               // This should take care of any trailing slashes, or the directory
               // formatted in any arbitrary fashion. I don't want to expect a
               // particular format because people do everything different.
  -            File baseDir = new File(new File(mavenLocalRepo, "project"), 
  +            File baseDir = new File(new File(mavenLocalRepo, "project"),
                   projectId);
               File projectDescriptor = new File(baseDir, "project.xml");
  -            
  +
               // Map the project descriptors and add them to the profile.
               Mapper projectMapper = new Mapper();
  -            Project project = (Project) projectMapper.map(projectDescriptor, 
  +            Project project = (Project) projectMapper.map(projectDescriptor,
                   Project.class.getName());
               profile.addProject(project);
           }
  -        
  +
           return workspace;
       }
   
  
  
  

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

Reply via email to