bodewig 01/05/10 23:22:47
Modified: . build.xml
src/main/org/apache/tools/ant/taskdefs Javadoc.java
Log:
Make javadoc expand properties for the new nested elements.
Use this to make the year of the copyright message in Ant's javadoc
dynamic - nice demonstration of tstamp's format element at the same
time.
Inspired by: Jon Stevens <[EMAIL PROTECTED]>
Revision Changes Path
1.152 +4 -2 jakarta-ant/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/build.xml,v
retrieving revision 1.151
retrieving revision 1.152
diff -u -r1.151 -r1.152
--- build.xml 2001/05/10 12:14:30 1.151
+++ build.xml 2001/05/11 06:22:41 1.152
@@ -151,7 +151,9 @@
===================================================================
-->
<target name="prepare">
- <tstamp />
+ <tstamp>
+ <format property="year" pattern="yyyy" />
+ </tstamp>
</target>
<!--
@@ -561,7 +563,7 @@
<group title="Core Tasks" packages="org.apache.tools.ant.taskdefs*" />
<group title="Optional Tasks"
packages="org.apache.tools.ant.taskdefs.optional*" />
- <bottom>Copyright © 1999-2001 Apache Software Foundation. All
Rights Reserved.</bottom>
+ <bottom>Copyright © 1999-${year} Apache Software Foundation. All
Rights Reserved.</bottom>
</javadoc>
</target>
1.48 +20 -10
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
Index: Javadoc.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- Javadoc.java 2001/05/10 12:14:36 1.47
+++ Javadoc.java 2001/05/11 06:22:44 1.48
@@ -58,6 +58,7 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectHelper;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.*;
@@ -627,22 +628,23 @@
}
public class GroupArgument {
- private String title;
- private Html title2;
+ private Html title;
private Vector packages = new Vector(3);
public GroupArgument() {
}
public void setTitle(String src) {
- title = src;
+ Html h = new Html();
+ h.addText(src);
+ addTitle(h);
}
public void addTitle(Html text) {
- title2 = text;
+ title = text;
}
public String getTitle() {
- return title2 != null ? title2.getText() : title;
+ return title != null ? title.getText() : null;
}
public void setPackages(String src) {
@@ -700,19 +702,19 @@
if (doctitle != null) {
cmd.createArgument().setValue("-doctitle");
- cmd.createArgument().setValue(doctitle.getText());
+ cmd.createArgument().setValue(expand(doctitle.getText()));
}
if (header != null) {
cmd.createArgument().setValue("-header");
- cmd.createArgument().setValue(header.getText());
+ cmd.createArgument().setValue(expand(header.getText()));
}
if (footer != null) {
cmd.createArgument().setValue("-footer");
- cmd.createArgument().setValue(footer.getText());
+ cmd.createArgument().setValue(expand(footer.getText()));
}
if (bottom != null) {
cmd.createArgument().setValue("-bottom");
- cmd.createArgument().setValue(bottom.getText());
+ cmd.createArgument().setValue(expand(bottom.getText()));
}
Commandline toExecute = (Commandline)cmd.clone();
@@ -844,7 +846,7 @@
throw new BuildException("The title and packages
must be specified for group elements.");
}
toExecute.createArgument().setValue("-group");
- toExecute.createArgument().setValue(title);
+ toExecute.createArgument().setValue(expand(title));
toExecute.createArgument().setValue(packages);
}
}
@@ -1037,6 +1039,14 @@
queuedLine = null;
}
}
+ }
+
+ /**
+ * Convenience method to expand properties.
+ */
+ protected String expand(String content) {
+ return ProjectHelper.replaceProperties(project, content,
+ project.getProperties());
}
}