View Javadoc

1   package org.apache.maven.jelly.tags.maven;
2   
3   /* ====================================================================
4    *   Licensed to the Apache Software Foundation (ASF) under one or more
5    *   contributor license agreements.  See the NOTICE file distributed with
6    *   this work for additional information regarding copyright ownership.
7    *   The ASF licenses this file to You under the Apache License, Version 2.0
8    *   (the "License"); you may not use this file except in compliance with
9    *   the License.  You may obtain a copy of the License at
10   *
11   *       http://www.apache.org/licenses/LICENSE-2.0
12   *
13   *   Unless required by applicable law or agreed to in writing, software
14   *   distributed under the License is distributed on an "AS IS" BASIS,
15   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   *   See the License for the specific language governing permissions and
17   *   limitations under the License.
18   * ====================================================================
19   */
20  
21  import org.apache.commons.jelly.JellyTagException;
22  import org.apache.commons.jelly.XMLOutput;
23  import org.apache.commons.logging.Log;
24  import org.apache.commons.logging.LogFactory;
25  import org.apache.maven.jelly.MavenJellyContext;
26  import org.apache.maven.jelly.tags.BaseTagSupport;
27  import org.apache.maven.plugin.UnknownPluginException;
28  import org.apache.maven.project.Project;
29  
30  /**
31   * A tag to retrieve values from plugins
32   * @deprecated replaced by the GetTag tag
33   */
34  public class PluginVarTag
35      extends BaseTagSupport
36  {
37      /** LOGGER for debug output */
38      private static final Log LOGGER = LogFactory.getLog( PluginVarTag.class );
39  
40      /** the variable to set*/
41      private String var;
42  
43      /** the plugin to get the variable from*/
44      private String plugin;
45  
46      /** the name of the plugin property to retrieve */
47      private String property;
48  
49      /**
50       * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
51       * @deprecated replaced by the GetTag tag
52       */
53      public void doTag( XMLOutput output )
54          throws JellyTagException
55      {
56          checkAttribute( var, "var" );
57          checkAttribute( plugin, "plugin" );
58          checkAttribute( property, "property" );
59          Project project = getMavenContext().getProject();
60          try
61          {
62              MavenJellyContext context = project.getPluginContext( plugin );
63              if ( context != null )
64              {
65                  Object value = context.getVariable( property );
66                  getContext().setVariable( var, value );
67              }
68              else
69              {
70                  LOGGER.error( "context for plugin '" + plugin + "' in project '" + project + "' is null" );
71              }
72          }
73          catch ( UnknownPluginException e )
74          {
75              LOGGER.error( "Plugin '" + plugin + "' in project '" + project + "' is not available" );
76          }
77          catch ( Exception e )
78          {
79              throw new JellyTagException( "Error loading plugin", e );
80          }
81      }
82  
83      /**
84       * @return the plugin to retrieve the property from.
85       * @deprecated replaced by the GetTag tag
86       */
87      public String getPlugin()
88      {
89          return plugin;
90      }
91  
92      /**
93       * @return the name of the property being retrieved
94       * @deprecated replaced by the GetTag tag
95       */
96      public String getProperty()
97      {
98          return property;
99      }
100 
101     /**
102      * @return the variable name to set
103      * @deprecated replaced by the GetTag tag
104      */
105     public String getVar()
106     {
107         return var;
108     }
109 
110     /**
111      * @param pluginId the id of the plugin to retrieve the property from
112      * @deprecated replaced by the GetTag tag
113      */
114     public void setPlugin( String pluginId )
115     {
116         plugin = pluginId;
117     }
118 
119     /**
120      * @param propertyName the name of the property being retrieved
121      * @deprecated replaced by the GetTag tag
122      */
123     public void setProperty( String propertyName )
124     {
125         property = propertyName;
126     }
127 
128     /**
129      * @param variable the variable name to set
130      * @deprecated replaced by the GetTag tag
131      */
132     public void setVar( String variable )
133     {
134         this.var = variable;
135     }
136 
137 }