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.jelly.tags.ant.AntTagLibrary;
24 import org.apache.maven.jelly.tags.BaseTagSupport;
25 import org.apache.tools.ant.Project;
26 import org.apache.tools.ant.types.Path;
27
28 /**
29 * This class takes a given path using an <code>id</code> and appends another
30 * path (using <code>refid</code>) to it.
31 *
32 * @author Bob McWhirter
33 * @version $Id: AddPathTag.java 517014 2007-03-11 21:15:50Z ltheussl $
34 */
35 public class AddPathTag
36 extends BaseTagSupport
37 {
38 /** the id of the path to be appended to. */
39 private String id;
40
41 /** the path to append */
42 private String refid;
43
44 /**
45 * Perform the tag processing. Look up the path by {@link #getId id} and append
46 * the {@link #getRefid other path} to it.
47 *
48 * @param output used to write output
49 * @throws JellyTagException when anything goes wrong.
50 */
51 public void doTag( XMLOutput output )
52 throws JellyTagException
53 {
54 Project project = AntTagLibrary.getProject( getContext() );
55
56 if ( project == null )
57 {
58 throw new JellyTagException( "cannot find ant project" );
59 }
60
61 checkAttribute( getId(), "id" );
62 checkAttribute( getRefid(), "refid" );
63
64 Path path = (Path) project.getReferences().get( getId() );
65 if ( path == null )
66 {
67 throw new JellyTagException( "cannot find the path to add to specified by 'id': " + getId() );
68 }
69 Path addPath = (Path) project.getReferences().get( getRefid() );
70 if ( addPath == null )
71 {
72 throw new JellyTagException( "cannot find the path to add specified by 'refid': " + getRefid() );
73 }
74 path.append( addPath );
75 }
76
77 /**
78 * Setter for the id property
79 *
80 * @param pathId the reference id of the path in the ant project that will be
81 * appended to
82 */
83 public void setId( String pathId )
84 {
85 id = pathId;
86 }
87
88 /**
89 * Getter for the id property
90 *
91 * @return the reference id of the path in the ant project that will be
92 * appended to
93 */
94 public String getId()
95 {
96 return id;
97 }
98
99 /**
100 * Setter for the refid property
101 *
102 * @param pathToAppendId the reference id of the path in the ant project that will
103 * be appended
104 */
105 public void setRefid( String pathToAppendId )
106 {
107 refid = pathToAppendId;
108 }
109
110 /**
111 * Getter for the refid property
112 *
113 * @return the reference id of the path in the ant project that will be
114 * appended
115 */
116 public String getRefid()
117 {
118 return refid;
119 }
120 }