incubator-easyant-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlboud...@apache.org
Subject svn commit: r1360878 - /incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntEngine.java
Date Thu, 12 Jul 2012 19:36:22 GMT
Author: jlboudart
Date: Thu Jul 12 19:36:22 2012
New Revision: 1360878

URL: http://svn.apache.org/viewvc?rev=1360878&view=rev
Log:
temporary hack to handle target injection into extensionPoint

Modified:
    incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntEngine.java

Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntEngine.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntEngine.java?rev=1360878&r1=1360877&r2=1360878&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntEngine.java
(original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntEngine.java
Thu Jul 12 19:36:22 2012
@@ -26,11 +26,10 @@ import java.net.JarURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
-import java.util.ArrayList;
 import java.util.Enumeration;
+import java.util.Hashtable;
 import java.util.Properties;
 
-import org.apache.easyant.core.ant.Phase;
 import org.apache.easyant.core.ant.ProjectUtils;
 import org.apache.easyant.core.ant.listerners.DefaultEasyAntLogger;
 import org.apache.easyant.core.descriptor.PluginDescriptor;
@@ -48,12 +47,15 @@ import org.apache.tools.ant.BuildListene
 import org.apache.tools.ant.BuildLogger;
 import org.apache.tools.ant.DemuxInputStream;
 import org.apache.tools.ant.DemuxOutputStream;
+import org.apache.tools.ant.ExtensionPoint;
 import org.apache.tools.ant.Location;
 import org.apache.tools.ant.MagicNames;
 import org.apache.tools.ant.Main;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.ProjectHelper;
+import org.apache.tools.ant.ProjectHelper.OnMissingExtensionPoint;
 import org.apache.tools.ant.PropertyHelper;
+import org.apache.tools.ant.Target;
 import org.apache.tools.ant.input.DefaultInputHandler;
 import org.apache.tools.ant.input.InputHandler;
 import org.apache.tools.ant.util.ClasspathUtils;
@@ -552,6 +554,41 @@ public class EasyAntEngine {
             lm.setLocation(mainscriptLocation);
             lm.execute();
         }
+        
+        
+        // FIXME:resolve extensionOf attributes this should be exposed by Apache Ant
+        injectTargetIntoExtensionPoint(project, helper);
+    }
+
+    private void injectTargetIntoExtensionPoint(Project project, ProjectHelper helper) {
+        for (Object extensionInfos : helper.getExtensionStack()) {
+            String[] extensionInfo = (String[])extensionInfos;
+            String tgName = extensionInfo[0];
+            String name = extensionInfo[1];
+            OnMissingExtensionPoint missingBehaviour = OnMissingExtensionPoint.FAIL;
+            Hashtable projectTargets = project.getTargets();
+            if (!projectTargets.containsKey(tgName)) {
+                String message = "can't add target " + name
+                    + " to extension-point " + tgName
+                    + " 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);
+                }
+            } else {
+                Target t = (Target) projectTargets.get(tgName);
+                if (!(t instanceof ExtensionPoint)) {
+                    throw new BuildException("referenced target "
+                                             + tgName
+                                             + " is not an extension-point");
+                }
+                t.addDependency(name);
+            }
+        }
     }
 
     /**



Mime
View raw message