You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jv...@apache.org on 2002/11/30 18:18:11 UTC

cvs commit: jakarta-turbine-maven/src/java/org/apache/maven/cli App.java

jvanzyl     2002/11/30 09:18:11

  Modified:    src/java/org/apache/maven/cli App.java
  Log:
  refactoring
  
  Revision  Changes    Path
  1.9       +43 -16    jakarta-turbine-maven/src/java/org/apache/maven/cli/App.java
  
  Index: App.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/cli/App.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- App.java	25 Nov 2002 18:30:24 -0000	1.8
  +++ App.java	30 Nov 2002 17:18:11 -0000	1.9
  @@ -69,6 +69,7 @@
   import org.apache.maven.app.Maven;
   import org.apache.maven.app.RepoConfigException;
   import org.apache.maven.app.UnknownGoalException;
  +import org.apache.maven.jelly.MavenJellyContext;
   import org.apache.maven.project.Project;
   
   import java.io.File;
  @@ -216,11 +217,38 @@
       /** Descriptor directory. */
       private File descriptorDirectory;
   
  +    /** Maven Jelly context. */
  +    private MavenJellyContext context;
  +
       /** Constructor. */
       public App()
       {
       }
   
  +    // ----------------------------------------------------------------------
  +    // A C C E S S O R S
  +    // ----------------------------------------------------------------------
  +
  +   /**
  +     * Set Jelly context.
  +     *
  +     * @param context The maven jelly context.
  +     */
  +    public void setContext( MavenJellyContext context )
  +    {
  +        this.context = context;
  +    }
  +
  +    /**
  +     * Retrieve the Jelly context.
  +     *
  +     * @return The Jelly context.
  +     */
  +    public MavenJellyContext getContext()
  +    {
  +        return context;
  +    }
  +
       /**
        * Set the Maven instance.
        *
  @@ -339,7 +367,8 @@
           }
   
           // Create the MavenJellyContext
  -        getMaven().setContext( MavenUtils.createContext( getDescriptorDirectory() ) );
  +        setContext( MavenUtils.createContext( getDescriptorDirectory() ) );
  +        getMaven().setContext( getContext() );
   
           initializeIO();
   
  @@ -384,11 +413,13 @@
               ||
               getCli().hasOption( DEBUG_X ) )
           {
  -            getMaven().setXMLOutput( output, true );
  +            getContext().setXMLOutput( output );
  +            getContext().setDebugOn( Boolean.TRUE );
           }
           else
           {
  -            getMaven().setXMLOutput( output, false );
  +            getContext().setXMLOutput( output );
  +            getContext().setDebugOn( Boolean.FALSE );
           }
   
           if ( getCli().hasOption( EMACS_OUTPUT ) )
  @@ -402,18 +433,18 @@
        */
       private void checkOnline()
       {
  -        if ( getMaven().getVariable( MavenConstants.ONLINE ) != null )
  +        if ( getContext().getOnline() != null )
           {
               return;
           }
   
           if ( getCli().hasOption( WORK_OFFLINE ) )
           {
  -            getMaven().setVariable( MavenConstants.ONLINE, Boolean.FALSE );
  +            getContext().setOnline( Boolean.FALSE );
           }
           else
           {
  -            getMaven().setVariable( MavenConstants.ONLINE, Boolean.TRUE );
  +            getContext().setOnline( Boolean.TRUE );
           }
       }
   
  @@ -439,9 +470,6 @@
               value = defStr.substring( equalLoc + 1 ).trim();
           }
   
  -        // We consider this value a System property and will later be
  -        // treated as such in Maven::loadProperties(). Values set here
  -        // have the final say.
           System.setProperty( name, value );
       }
   
  @@ -519,7 +547,7 @@
           try
           {
               checkOnline();
  -            getMaven().runtimeInitialization();
  +            getMaven().initialize();
   
               if ( getCli().hasOption( DISPLAY_GOALS ) )
               {
  @@ -763,7 +791,7 @@
           System.out.println( format( "", title.length(), '`' ) );
   
   
  -        Set goals = getMaven().getPluginManager().getGoalNames();
  +        Set goals = getContext().getPluginManager().getGoalNames();
   
           List list = new ArrayList( goals );
   
  @@ -790,7 +818,7 @@
           for ( Iterator i = list.iterator(); i.hasNext(); )
           {
               String goalName = (String) i.next(); // goal name
  -            String goalDescription = getMaven().getPluginManager().getGoalDescription( goalName );
  +            String goalDescription = getContext().getPluginManager().getGoalDescription( goalName );
   
               StringTokenizer st = new StringTokenizer( goalName, ":" );
               String pluginName = st.nextToken(); //ex. java
  @@ -926,7 +954,7 @@
           {
               String goalName = (String) i.next();
               
  -            String goalDescription = getMaven().getPluginManager().getGoalDescription( goalName );
  +            String goalDescription = getContext().getPluginManager().getGoalDescription( goalName );
               
               boolean hasDesc = false;
   
  @@ -1074,11 +1102,10 @@
        * @param args CLI arguments.
        */
       public static void main( String[] args )
  +        throws Exception
       {
           Date start = new Date();
  -        File mavenHome = new File( System.getProperty( MavenConstants.HOME ) );
           Maven maven = new Maven();
  -        maven.setMavenHome( mavenHome );
   
           App app = new App();
           app.setMaven( maven );