diff --git a/src/main/org/apache/tools/ant/ProjectComponent.java b/src/main/org/apache/tools/ant/ProjectComponent.java
index d6d8f7e31..3a5c04422 100644
--- a/src/main/org/apache/tools/ant/ProjectComponent.java
+++ b/src/main/org/apache/tools/ant/ProjectComponent.java
@@ -45,6 +45,13 @@ public abstract class ProjectComponent implements Cloneable {
protected Location location = Location.UNKNOWN_LOCATION;
// CheckStyle:VisibilityModifier ON
+ /**
+ * Description of this component, if any.
+ * @deprecated since 1.6.x.
+ * You should not be accessing this variable directly.
+ */
+ protected String description;
+
/** Sole constructor. */
public ProjectComponent() {
}
@@ -97,6 +104,29 @@ public abstract class ProjectComponent implements Cloneable {
this.location = location;
}
+ /**
+ * Sets a description of the current action. This may be used for logging
+ * purposes.
+ *
+ * @param desc Description of the current action.
+ * May be null
, indicating that no description is
+ * available.
+ *
+ */
+ public void setDescription(String desc) {
+ description = desc;
+ }
+
+ /**
+ * Returns the description of the current action.
+ *
+ * @return the description of the current action, or null
if
+ * no description is available.
+ */
+ public String getDescription() {
+ return description;
+ }
+
/**
* Logs a message with the default (INFO) priority.
*
diff --git a/src/main/org/apache/tools/ant/Task.java b/src/main/org/apache/tools/ant/Task.java
index 1ad26b064..c8254da35 100644
--- a/src/main/org/apache/tools/ant/Task.java
+++ b/src/main/org/apache/tools/ant/Task.java
@@ -41,13 +41,6 @@ public abstract class Task extends ProjectComponent {
*/
protected Target target;
- /**
- * Description of this task, if any.
- * @deprecated since 1.6.x.
- * You should not be accessing this variable directly.
- */
- protected String description;
-
/**
* Name of this task to be used for logging purposes.
* This defaults to the same as the type, but may be
@@ -141,29 +134,6 @@ public abstract class Task extends ProjectComponent {
this.taskType = type;
}
- /**
- * Sets a description of the current action. This may be used for logging
- * purposes.
- *
- * @param desc Description of the current action.
- * May be null
, indicating that no description is
- * available.
- *
- */
- public void setDescription(String desc) {
- description = desc;
- }
-
- /**
- * Returns the description of the current action.
- *
- * @return the description of the current action, or null
if
- * no description is available.
- */
- public String getDescription() {
- return description;
- }
-
/**
* Called by the project to let the task initialize properly.
* The default implementation is a no-op.
diff --git a/src/tests/junit/org/apache/tools/ant/ProjectComponentTest.java b/src/tests/junit/org/apache/tools/ant/ProjectComponentTest.java
new file mode 100644
index 000000000..e195b4ec0
--- /dev/null
+++ b/src/tests/junit/org/apache/tools/ant/ProjectComponentTest.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.tools.ant;
+
+import junit.framework.TestCase;
+
+public class ProjectComponentTest extends TestCase {
+
+ public ProjectComponentTest(String name) {
+ super(name);
+ }
+
+ public void testClone() throws CloneNotSupportedException {
+ Project expectedProject = new Project();
+ Location expectedLocation = new Location("foo");
+ String expectedDescription = "bar";
+
+ // use an anonymous subclass since ProjectComponent is abstract
+ ProjectComponent pc = new ProjectComponent() {
+ };
+ pc.setProject(expectedProject);
+ pc.setLocation(expectedLocation);
+ pc.setDescription(expectedDescription);
+
+ ProjectComponent cloned = (ProjectComponent) pc.clone();
+ assertNotSame(pc, cloned);
+ assertSame(cloned.getProject(), expectedProject);
+ assertSame(cloned.getLocation(), expectedLocation);
+ assertSame(cloned.getDescription(), expectedDescription);
+ }
+}
\ No newline at end of file