dion        2002/06/16 10:39:15

  Modified:    src/java/org/apache/maven/project Project.java
  Log:
  Added new constructors to get the project from a file, instead of using MavenUtils
  
  Revision  Changes    Path
  1.26      +65 -1     
jakarta-turbine-maven/src/java/org/apache/maven/project/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/project/Project.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Project.java      11 Jun 2002 01:21:58 -0000      1.25
  +++ Project.java      16 Jun 2002 17:39:15 -0000      1.26
  @@ -56,6 +56,8 @@
    * ====================================================================
    */
   
  +import java.io.File;
  +import java.io.FileInputStream;
   import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.Iterator;
  @@ -63,6 +65,7 @@
   import java.util.Map;
   
   import org.apache.maven.MavenConstants;
  +import org.apache.maven.build.BeanReader;
   
   /**
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
  @@ -177,6 +180,13 @@
        */
       private HashMap versionMap;
   
  +    
  +    /**
  +     * File name the project was read from, or null if the project was
  +     * created without a file
  +     */
  +    private String descriptorFileName;
  +    
       /**
        * Default constructor.
        */
  @@ -189,7 +199,61 @@
           versions = new ArrayList();
           //distributionMap = new HashMap();
       }
  +    
  +   /**
  +     * Create a Project object given a file descriptor.
  +     *
  +     * @param projectDescriptor a maven project.xml {@link File}
  +     * @throws Exception when any errors occur
  +     */
  +    public Project(File projectDescriptor)
  +        throws Exception
   
  +    {
  +        this();
  +        BeanReader reader = new BeanReader(Project.class);
  +        Project project = (Project) reader.parse(
  +            new FileInputStream(projectDescriptor));
  +        // copy across fields
  +        currentVersion = project.currentVersion;
  +        description = project.description;
  +        descriptorFileName = projectDescriptor.getCanonicalPath();
  +        distributionDirectory = project.distributionDirectory;
  +        inceptionYear = project.inceptionYear;
  +        issueTrackingUrl = project.issueTrackingUrl;
  +        logo = project.logo;
  +        pomVersion = project.pomVersion;
  +        projectPackage = project.projectPackage;
  +        siteAddress = project.siteAddress;
  +        siteDirectory = project.siteDirectory;
  +        url = project.url;
  +        versionMap = project.versionMap;
  +        contributors = project.contributors;
  +        dependencies = project.dependencies;
  +        developers = project.developers;
  +        mailingLists = project.mailingLists;
  +        versions = project.versions;
  +        build = project.build;
  +        organization = project.organization;
  +        repository = project.repository;
  +        setName(project.getName());
  +        setId(project.getId());
  +    }
  +
  +
  +    /**
  +     * Create a Project object given a descriptor file name
  +     *
  +     * @param fileName a maven project.xml {@link File} name
  +     * @throws Exception when any errors occur
  +     */
  +    public Project(String fileName) throws Exception
  +    {
  +        this(new File(fileName));
  +        descriptorFileName = fileName;
  +    }
  +     
  +    
       /**
        * Set the site address where the documentation lives.
        *
  
  
  

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

Reply via email to