You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by pl...@apache.org on 2003/02/28 01:48:46 UTC

cvs commit: jakarta-turbine-maven/src/java/org/apache/maven/plugin DefaultPluginManager.java PluginManager.java

plynch      2003/02/27 16:48:41

  Modified:    src/java/org/apache/maven/plugin DefaultPluginManager.java
                        PluginManager.java
  Log:
  o storing the com.werken.werkz.Session object into the parent scope context so that jelly tags that accept an implementation of that object can have access to it.
  
   This feature was added after furious debate on IRC as to how to have the <attainGoal> tags use the global maven session when executing goals.
  
  To get access to the maven session in a jelly script one can use this syntax:
  
  ${context.getVariable('maven.session.global', 'parent')}
  
  The 'parent' is important as the context is per plugin, and the plguin's context is instatiated with the global context.
  
  In a future version of the werkz library this could be used like:
  
  <attainGoal session="${context.getVariable('maven.session.global', 'parent')}" name="foobar" />
  
  and if the foobar goal had prereqs that had already been attained, then they would
  not attain again.
  
  Revision  Changes    Path
  1.4       +10 -1     jakarta-turbine-maven/src/java/org/apache/maven/plugin/DefaultPluginManager.java
  
  Index: DefaultPluginManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/plugin/DefaultPluginManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultPluginManager.java	27 Feb 2003 13:15:36 -0000	1.3
  +++ DefaultPluginManager.java	28 Feb 2003 00:48:39 -0000	1.4
  @@ -136,6 +136,12 @@
       /** Plug-in default properties name. */
       public static final String PLUGIN_PROPERTIES_NAME = "plugin.properties";
   
  +    /**
  +     * The variable key that holds an implementation of the
  +     * <code>com.werken.werkz.Session</code> in the parent scope context.
  +     */
  +    private static final String GLOBAL_SESSION_KEY = "maven.session.global";
  +
       /** Logger */
       private static final Log log = LogFactory.getLog( PluginManager.class );
   
  @@ -377,6 +383,9 @@
   
           Session session = new JellySession( project.getContext().getXMLOutput() );
           Thread.currentThread().setContextClassLoader( null );
  +
  +        // add the global session to the context so that it can be used by tags
  +        project.getContext().setVariable(GLOBAL_SESSION_KEY, session);
   
           for ( Iterator i = project.getGoalNames().iterator(); i.hasNext(); )
           {
  
  
  
  1.41      +10 -1     jakarta-turbine-maven/src/java/org/apache/maven/plugin/PluginManager.java
  
  Index: PluginManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/plugin/PluginManager.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- PluginManager.java	27 Feb 2003 13:15:36 -0000	1.40
  +++ PluginManager.java	28 Feb 2003 00:48:39 -0000	1.41
  @@ -138,6 +138,12 @@
       /** Logger */
       private static final Log log = LogFactory.getLog( PluginManager.class );
   
  +    /**
  +     * The variable key that holds an implementation of the
  +     * <code>com.werken.werkz.Session</code> in the parent scope context.
  +     */
  +    private static final String GLOBAL_SESSION_KEY = "maven.session.global";
  +
       /** ${maven.home}/bin/plugins directory. */
       private File pluginsDir;
   
  @@ -377,6 +383,9 @@
   
           Session session = new JellySession( project.getContext().getXMLOutput() );
           Thread.currentThread().setContextClassLoader( null );
  +
  +        // add the global session to the context so that it can be used by tags
  +        project.getContext().setVariable(GLOBAL_SESSION_KEY, session);
   
           for ( Iterator i = project.getGoalNames().iterator(); i.hasNext(); )
           {
  
  
  

Re: cvs commit: jakarta-turbine-maven/src/java/org/apache/maven/plugin DefaultPluginManager.java PluginManager.java

Posted by Colin Sampaleanu <co...@exis.com>.
plynch@apache.org wrote:

>plynch      2003/02/27 16:48:41
>
>  Modified:    src/java/org/apache/maven/plugin DefaultPluginManager.java
>                        PluginManager.java
>  Log:
>  o storing the com.werken.werkz.Session object into the parent scope context so that jelly tags that accept an implementation of that object can have access to it.
>  
>   This feature was added after furious debate on IRC as to how to have the <attainGoal> tags use the global maven session when executing goals.
>  
>  To get access to the maven session in a jelly script one can use this syntax:
>  
>  ${context.getVariable('maven.session.global', 'parent')}
>  
>  The 'parent' is important as the context is per plugin, and the plguin's context is instatiated with the global context.
>  
>  In a future version of the werkz library this could be used like:
>  
>  <attainGoal session="${context.getVariable('maven.session.global', 'parent')}" name="foobar" />
>  
>  and if the foobar goal had prereqs that had already been attained, then they would
>  not attain again.
>  
>  
>
Good to see this is finally happening :-), albeit in simpler form than 
my submission.

I see werkz has actually been updated in CVS. When is the updated works 
going to be listed as a dependency? When that is done I volunteer to 
spend a few hours going through the plugins to see which ones need to 
change their use of attainGoal. From what I saw before it is the 
majority. Some code is also using attainGoal to run 'subroutines', and 
that should probably change to calling customs tags instead of goals 
entirely...

It's too bad the form of the tag that people will be using most of the 
time (wanting to use the seesion) is going to be so wordy, but it's 
still a lot better than not being able to do it at all. How about though 
having a new maven jelly tag called 'attainMavenGoal', which by default 
just calls out to the werkz attainGoal with the session preset as above?