ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicola Ken Barozzi <nicola...@apache.org>
Subject Re: Alias names for imported targets
Date Fri, 04 Jun 2004 14:50:18 GMT
Stefan Bodewig wrote:

> Hi,
> 
> Erik already brought that up.  Target foo imported from project named
> bar is known as "foo" in my build file unless I override it (in which
> case it becomes "bar.foo".  I'd like to have the alias name "bar.foo"
> available even if I don't override it.
> 
> I haven't looked into the code yet, but are there any principal
> objections?  Target time-frame would be 1.6.2.

I've looked into the code (gosh, I still remember part of it :-)

The following path is OTOMH, without even compiling, it should be a start.

Index: ProjectHelper2.java
===================================================================
RCS file: 
/home/cvspublic/ant/src/main/org/apache/tools/ant/helper/ProjectHelper2.java,v
retrieving revision 1.46
diff -u -r1.46 ProjectHelper2.java
--- ProjectHelper2.java	26 Apr 2004 17:49:51 -0000	1.46
+++ ProjectHelper2.java	4 Jun 2004 14:49:03 -0000
@@ -823,14 +823,36 @@
                  }
              }

+            Target fullTarget = null;
+
+            if (context.isIgnoringProjectTag()) {
+                fullTarget = new Target();
+            }
+
              if (name != null) {
                  target.setName(name);
                  project.addOrReplaceTarget(name, target);
+                if (fullTarget!=null) {
+                   fullTarget.setProject(target.getProject());
+                   fullTarget.setLocation(target.getLocation());
+                   context.addTarget(fullTarget);
+                   fullTarget.setIf(target.getIf());
+                   fullTarget.setUnless(target.getUnless());
+                   fullTarget.setDescription(target.getDescription());
+
+                   String 
newName=project.addOrReplaceTarget(context.getCurrentProjectName()
+                                            + "." + name, target);
+                   fullTarget.setName(newName);
+                   project.addOrReplaceTarget(newName, fullTarget);
+                }
              }

              // take care of dependencies
              if (depends.length() > 0) {
                  target.setDepends(depends);
+                if (fullTarget!=null) {
+                    fullTarget.setDepends(depends);
+                }
              }
          }


-- 
Nicola Ken Barozzi                   nicolaken@apache.org
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)
---------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message