jvanzyl     2002/11/11 19:08:12

  Modified:    src/java/org/apache/maven/app App.java Maven.java
  Log:
  o Removing setProjectFile(file) and making it the responsibility of
    the wrapper to instantiate the project and give it to the Maven bean.
    We will push all this helper code to MavenUtils to make it easy
    for integrators to work with the Maven bean.
  
  Revision  Changes    Path
  1.29      +26 -7     jakarta-turbine-maven/src/java/org/apache/maven/app/App.java
  
  Index: App.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/app/App.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- App.java  12 Nov 2002 02:38:34 -0000      1.28
  +++ App.java  12 Nov 2002 03:08:11 -0000      1.29
  @@ -81,6 +81,7 @@
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  +import org.apache.maven.MavenUtils;
   import org.apache.maven.project.Project;
   
   import com.werken.werkz.Goal;
  @@ -213,12 +214,12 @@
               File file = find (getCli().getOptionValue("f"));
               if (file != null) 
               {
  -                getMaven().setDir (file.getParentFile());
  -                getMaven().setProjectFile(file);
  +                getMaven().setDir(file.getParentFile());
  +                initializeProject(file);
               }
               else 
               {
  -                getMaven().setProjectFile(new File(getCli().getOptionValue("f")));
  +                initializeProject(new File(getCli().getOptionValue("f")));
               }
           }
   
  @@ -235,11 +236,11 @@
   
           if (getCli().hasOption("p"))
           {
  -            getMaven().setProjectFile(new File(getCli().getOptionValue("p")));
  +            initializeProject(new File(getCli().getOptionValue("p")));
           }
           else if (!getCli().hasOption("f"))
           {
  -            getMaven().setProjectFile( new File(getMaven().getDir(), 
POM_FILE_NAME));
  +            initializeProject(new File(getMaven().getDir(), POM_FILE_NAME));
           }
   
           if (getCli().hasOption("D"))
  @@ -257,13 +258,31 @@
           System.setProperty("user.dir", getMaven().getDir().getPath());
       }
   
  +    /** Load the maven project descriptor.
  +     *
  +     *  @throws DescriptorException If there is an error while
  +     *          reading the project descriptor.
  +     */
  +    private void initializeProject(File projectFile)
  +        throws Exception
  +    {
  +        if (projectFile.length() == 0)
  +        {
  +            throw new Exception("The " + projectFile.getName() + 
  +                               " file you specified has a length of zero.");
  +        }
  +        
  +        getMaven().setProject(MavenUtils.getProject(projectFile, 
getMaven().getDir()));
  +    }
  +
       /**
        *  Initialize the IO streams.
        *
        * @throws IOException on error creating XML output and handling System.err
        *         and out
        */
  -    protected void initializeIO() throws IOException
  +    protected void initializeIO() 
  +        throws IOException
       {
           this.consoleOut = System.out;
           this.consoleErr = System.err;
  
  
  
  1.127     +2 -58     jakarta-turbine-maven/src/java/org/apache/maven/app/Maven.java
  
  Index: Maven.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/app/Maven.java,v
  retrieving revision 1.126
  retrieving revision 1.127
  diff -u -r1.126 -r1.127
  --- Maven.java        12 Nov 2002 02:38:34 -0000      1.126
  +++ Maven.java        12 Nov 2002 03:08:11 -0000      1.127
  @@ -213,24 +213,6 @@
       // A C C E S S O R S
       // ------------------------------------------------------------
   
  -    /** Set the project descriptor file.
  -     *
  -     *  @param projectFile The project descriptor file.
  -     */
  -    public void setProjectFile(File projectFile) throws Exception
  -    {
  -        this.projectFile = projectFile;
  -    }
  -
  -    /** Retrieve the project descriptor file.
  -     *
  -     *  @return The project descriptor file.
  -     */
  -    public File getProjectFile()
  -    {
  -        return this.projectFile;
  -    }
  -
       /** Set the project-specific build file.
        *
        *  @see #hasProjectBuildFile
  @@ -590,42 +572,6 @@
           }
       }
       
  -    /** Produce a string representation, suitable for debugging.
  -     *
  -     *  @return A debug string.
  -     */
  -    public String toString()
  -    {
  -        return "[Maven: mavenHome=" + getMavenHome()
  -            + "; dir=" + getDir()
  -            + "; projectFile=" + getProjectFile()
  -            + "; goalNames=" + getGoalNames()
  -            + "]";
  -    }
  -
  -    /** Load the maven project descriptor.
  -     *
  -     *  @throws DescriptorException If there is an error while
  -     *          reading the project descriptor.
  -     */
  -    private void initializeProject()
  -        throws Exception
  -    {
  -        // The project may already be set
  -        if (project != null)
  -        {
  -            return;
  -        }            
  -    
  -        if (getProjectFile().length() == 0)
  -        {
  -            throw new Exception("The " + getProjectFile().getName() + 
  -                               " file you specified has a length of zero.");
  -        }
  -        
  -        this.project = MavenUtils.getProject(getProjectFile(), getDir());
  -    }
  -
       /** Initialize Jelly.
        */
       public void initializeJelly() 
  @@ -685,8 +631,7 @@
           getJellyContext().registerTagLibrary("", jeezTagLib);
           getJellyContext().registerTagLibrary("jelly:maven", new MavenTagLibrary());
   
  -        AntTagLibrary.setProject( getJellyContext(),
  -                                  getAntProject() );
  +        AntTagLibrary.setProject( getJellyContext(), getAntProject() );
       }
   
       /** Initialize Ant.
  @@ -727,7 +672,6 @@
           initializeAnt();
           initializeJellyListener();        
           initializeTagLibs();
  -        initializeProject();
           loadProperties();
           initializeDriver();
           createProjectVerifier();
  
  
  

--
To unsubscribe, e-mail:   <mailto:turbine-maven-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:turbine-maven-dev-help@;jakarta.apache.org>

Reply via email to