Return-Path: Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 18372 invoked from network); 7 Dec 1999 00:57:11 -0000 Received: from hub1-20.san-jose.webnexus.net (HELO hub1.san-jose.webnexus.net) (209.140.224.20) by apache.org with SMTP; 7 Dec 1999 00:57:11 -0000 Received: from kbslaptop (fw.skytalk.com [209.141.22.50]) by hub1.san-jose.webnexus.net (8.9.1a/8.8.5/WN-1.3) with SMTP id QAA02023 for ; Mon, 6 Dec 1999 16:57:09 -0800 (PST) Reply-To: From: "KB Sriram" To: Subject: [PATCH] Check for duplicate targets in Ant specification files Date: Mon, 6 Dec 1999 17:03:41 -0800 Message-ID: <000801bf404e$e83e0a70$27a8a8c0@skytalk.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0009_01BF400B.DA1ACA70" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2910.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 ------=_NextPart_000_0009_01BF400B.DA1ACA70 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit This patch has Ant check and report an error for build specifications that contain duplicate targets. -kb- ------=_NextPart_000_0009_01BF400B.DA1ACA70 Content-Type: text/plain; name="patchfile.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="patchfile.txt" Index: build.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/cvspublic/jakarta-tools/ant/build.xml,v retrieving revision 1.4 diff -u -r1.4 build.xml --- build.xml 1999/12/01 05:37:31 1.4 +++ build.xml 1999/12/06 23:23:18 @@ -18,12 +18,6 @@ =20 - - - - - Index: src/main/org/apache/tools/ant/Project.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /home/cvspublic/jakarta-tools/ant/src/main/org/apache/tools/ant/Project.j= ava,v retrieving revision 1.15 diff -u -r1.15 Project.java --- Project.java 1999/12/03 12:41:42 1.15 +++ Project.java 1999/12/06 23:23:19 @@ -252,13 +252,56 @@ taskClassDefinitions.put(taskName, taskClass); } =20 - public void addTarget(Target target) { - String msg =3D " +Target: " + target.getName(); - log(msg, MSG_VERBOSE); - targets.put(target.getName(), target); + /** + * This call expects to add a new Target. + * @param target is the Target to be added to the current + * Project. + * @exception BuildException if the Target already exists + * in the project. + * @see Project#addOrReplaceTarget to replace existing Targets. + */ + + public void addTarget(Target target) throws BuildException { + String name =3D target.getName(); + if (targets.get(name) !=3D null) { + throw new BuildException("Duplicate target: `"+name+"'"); + } + addOrReplaceTarget(name, target); } =20 - public void addTarget(String targetName, Target target) { + /** + * This call expects to add a new Target. + * @param target is the Target to be added to the current + * Project. + * @param targetName is the name to use for the Target + * @exception BuildException if the Target already exists + * in the project. + * @see Project#addOrReplaceTarget to replace existing Targets. + */ + + public void addTarget(String targetName, Target target) + throws BuildException { + if (targets.get(targetName) !=3D null) { + throw new BuildException("Duplicate target: = `"+targetName+"'"); + } + addOrReplaceTarget(targetName, target); + } + + /** + * @param target is the Target to be added or replaced in + * the current Project. + */ + public void addOrReplaceTarget(Target target) { + addOrReplaceTarget(target.getName(), target); + } + =20 + /** + * @param target is the Target to be added/replaced in + * the current Project. + * @param targetName is the name to use for the Target + */ + + public void addOrReplaceTarget(String targetName, Target target) { String msg =3D " +Target: " + targetName; log(msg, MSG_VERBOSE); targets.put(targetName, target); ------=_NextPart_000_0009_01BF400B.DA1ACA70--