1 package org.apache.maven.jelly.tags.maven;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 }