Return-Path: X-Original-To: apmail-ant-notifications-archive@minotaur.apache.org Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 13BCCBCF for ; Wed, 15 Aug 2012 10:41:07 +0000 (UTC) Received: (qmail 30408 invoked by uid 500); 15 Aug 2012 10:41:06 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 30318 invoked by uid 500); 15 Aug 2012 10:41:06 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 30305 invoked by uid 99); 15 Aug 2012 10:41:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Aug 2012 10:41:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Aug 2012 10:41:02 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id AAD4F23888E3 for ; Wed, 15 Aug 2012 10:40:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1373326 - in /ant/core/trunk: ./ src/main/org/apache/tools/ant/ src/main/org/apache/tools/ant/helper/ src/tests/antunit/core/extension/ Date: Wed, 15 Aug 2012 10:40:17 -0000 To: notifications@ant.apache.org From: hibou@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120815104017.AAD4F23888E3@eris.apache.org> Author: hibou Date: Wed Aug 15 10:40:16 2012 New Revision: 1373326 URL: http://svn.apache.org/viewvc?rev=1373326&view=rev Log: BR 53550, thanks to Tim Pokorny Improve the resolution of the extension point to bind to: - first try the extension point which might be in the same file - then try the one in the root file Still some work to do: there might be intermediate file in the import stack which we would to resolve the name against, but the ProjectHelper doesn't hold the prefix stacking. Added: ant/core/trunk/src/tests/antunit/core/extension/ ant/core/trunk/src/tests/antunit/core/extension/include-test.xml (with props) ant/core/trunk/src/tests/antunit/core/extension/module1.xml (with props) Modified: ant/core/trunk/WHATSNEW ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java Modified: ant/core/trunk/WHATSNEW URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1373326&r1=1373325&r2=1373326&view=diff ============================================================================== --- ant/core/trunk/WHATSNEW (original) +++ ant/core/trunk/WHATSNEW Wed Aug 15 10:40:16 2012 @@ -88,6 +88,9 @@ Other changes: and extension points. Bugzilla Report 53549. + * Make extension point bindable to imported prefixed targets + Bugzilla Report 53550. + Changes from Ant 1.8.3 TO Ant 1.8.4 =================================== Modified: ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java?rev=1373326&r1=1373325&r2=1373326&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java Wed Aug 15 10:40:16 2012 @@ -629,27 +629,52 @@ public class ProjectHelper { public void resolveExtensionOfAttributes(Project project) throws BuildException { for (String[] extensionInfo : getExtensionStack()) { - String tgName = extensionInfo[0]; - String name = extensionInfo[1]; + String extPointName = extensionInfo[0]; + String targetName = extensionInfo[1]; OnMissingExtensionPoint missingBehaviour = OnMissingExtensionPoint.valueOf(extensionInfo[2]); + // if the file has been included or imported, it may have a prefix + // we should consider when trying to resolve the target it is + // extending + String prefixAndSep = extensionInfo.length > 3 ? extensionInfo[3] : null; + + // find the target we're extending Hashtable projectTargets = project.getTargets(); - if (!projectTargets.containsKey(tgName)) { - String message = "can't add target " + name - + " to extension-point " + tgName + Target extPoint = null; + if (prefixAndSep == null) { + // no prefix - not from an imported/included build file + extPoint = (Target) projectTargets.get(extPointName); + } else { + // we have a prefix, which means we came from an include/import + + // FIXME: here we handle no particular level of include. We try + // the fully prefixed name, and then the non-prefixed name. But + // there might be intermediate project in the import stack, + // which prefix should be tested before testing the non-prefix + // root name. + + extPoint = (Target) projectTargets.get(prefixAndSep + extPointName); + if (extPoint == null) { + extPoint = (Target) projectTargets.get(extPointName); + } + } + + // make sure we found a point to extend on + if (extPoint == null) { + String message = "can't add target " + targetName + + " to extension-point " + extPointName + " because the extension-point is unknown."; if (missingBehaviour == OnMissingExtensionPoint.FAIL) { throw new BuildException(message); } else if (missingBehaviour == OnMissingExtensionPoint.WARN) { - Target target = (Target) projectTargets.get(name); - project.log(target, "Warning: " + message, Project.MSG_WARN); + Target t = (Target) projectTargets.get(targetName); + project.log(t, "Warning: " + message, Project.MSG_WARN); } } else { - Target t = (Target) projectTargets.get(tgName); - if (!(t instanceof ExtensionPoint)) { - throw new BuildException("referenced target " + tgName + if (!(extPoint instanceof ExtensionPoint)) { + throw new BuildException("referenced target " + extPointName + " is not an extension-point"); } - t.addDependency(name); + extPoint.addDependency(targetName); } } } Modified: ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java?rev=1373326&r1=1373325&r2=1373326&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java Wed Aug 15 10:40:16 2012 @@ -1011,17 +1011,24 @@ public class ProjectHelper2 extends Proj ProjectHelper helper = (ProjectHelper) context.getProject(). getReference(ProjectHelper.PROJECTHELPER_REFERENCE); - for (String tgName : Target.parseDepends(extensionPoint, name, "extensionOf")) { - if (isInIncludeMode()) { - tgName = prefix + sep + tgName; - } + for (String extPointName : Target.parseDepends(extensionPoint, name, "extensionOf")) { if (extensionPointMissing == null) { extensionPointMissing = OnMissingExtensionPoint.FAIL; } // defer extensionpoint resolution until the full // import stack has been processed - helper.getExtensionStack().add(new String[] { - tgName, name, extensionPointMissing.name() }); + if (isInIncludeMode()) { + // if in include mode, provide prefix we're including by + // so that we can try and resolve extension point from + // the local file first + helper.getExtensionStack().add( + new String[] {extPointName, target.getName(), + extensionPointMissing.name(), prefix + sep}); + } else { + helper.getExtensionStack().add( + new String[] {extPointName, target.getName(), + extensionPointMissing.name()}); + } } } } Added: ant/core/trunk/src/tests/antunit/core/extension/include-test.xml URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/core/extension/include-test.xml?rev=1373326&view=auto ============================================================================== --- ant/core/trunk/src/tests/antunit/core/extension/include-test.xml (added) +++ ant/core/trunk/src/tests/antunit/core/extension/include-test.xml Wed Aug 15 10:40:16 2012 @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + Propchange: ant/core/trunk/src/tests/antunit/core/extension/include-test.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ant/core/trunk/src/tests/antunit/core/extension/include-test.xml ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: ant/core/trunk/src/tests/antunit/core/extension/include-test.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: ant/core/trunk/src/tests/antunit/core/extension/module1.xml URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/core/extension/module1.xml?rev=1373326&view=auto ============================================================================== --- ant/core/trunk/src/tests/antunit/core/extension/module1.xml (added) +++ ant/core/trunk/src/tests/antunit/core/extension/module1.xml Wed Aug 15 10:40:16 2012 @@ -0,0 +1,25 @@ + + + + + + + + + + Propchange: ant/core/trunk/src/tests/antunit/core/extension/module1.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ant/core/trunk/src/tests/antunit/core/extension/module1.xml ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: ant/core/trunk/src/tests/antunit/core/extension/module1.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml