KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > cms > ant > SetAreaProperties


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 /* $Id: SetAreaProperties.java 42616 2004-03-03 12:56:33Z gregor $ */
19
20 package org.apache.lenya.cms.ant;
21
22 import org.apache.tools.ant.BuildException;
23 import org.apache.tools.ant.Project;
24 import org.apache.tools.ant.Target;
25 import org.apache.tools.ant.Task;
26
27 /**
28  * ant task to set the properties of the project dependent of the area
29  */

30 public class SetAreaProperties extends Task {
31     private String JavaDoc area;
32     private String JavaDoc dirpropertyname;
33     /**
34      * Creates a new instance of SetAreaProperties
35      */

36     public SetAreaProperties() {
37         super();
38     }
39     /**
40      * @return String The area.
41      */

42     public String JavaDoc getArea() {
43         return area;
44     }
45
46     /**
47      * @param area The area.
48      */

49     public void setArea(String JavaDoc area) {
50         this.area = area;
51     }
52
53     /**
54      * @return String The name of the property for the content directory.
55      */

56     public String JavaDoc getDirpropertyname() {
57         return dirpropertyname;
58     }
59
60     /**
61      * @param dirpropertyname The name of the property for the content directory.
62      */

63     public void setDirpropertyname(String JavaDoc dirpropertyname) {
64         this.dirpropertyname = dirpropertyname;
65     }
66
67     /**
68      * Sets the properties dependent of the area for the project
69      * @param area The area.
70      * @param dirpropertyname The name of the property for the content directory.
71      */

72     protected void setNewProperties(String JavaDoc area, String JavaDoc dirpropertyname) {
73         Target target = getOwningTarget();
74         Project project = target.getProject();
75
76         String JavaDoc dirproperty = project.getProperty(area+".dir");
77         project.setProperty(dirpropertyname, dirproperty);
78     }
79
80     /**
81      * @see org.apache.tools.ant.Task#execute()
82      **/

83     public void execute() throws BuildException {
84         try {
85             log("area " + this.getArea());
86             log("name of the property for the directory " + this.getDirpropertyname());
87             setNewProperties(this.getArea(), this.getDirpropertyname());
88         } catch (Exception JavaDoc e) {
89             throw new BuildException(e);
90         }
91     }
92 }
93
Popular Tags