incubator-easyant-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlboud...@apache.org
Subject svn commit: r1393723 - in /incubator/easyant/core/trunk/src: main/java/org/apache/easyant/core/report/ main/java/org/apache/easyant/man/ test/java/org/apache/easyant/core/services/
Date Wed, 03 Oct 2012 19:43:39 GMT
Author: jlboudart
Date: Wed Oct  3 19:43:38 2012
New Revision: 1393723

URL: http://svn.apache.org/viewvc?rev=1393723&view=rev
Log:
Simplify EasyAntReport mechanism

Modified:
    incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/EasyAntReport.java
    incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/Describe.java
    incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListExtensionPoints.java
    incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListTargets.java
    incubator/easyant/core/trunk/src/test/java/org/apache/easyant/core/services/PluginServiceTest.java

Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/EasyAntReport.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/EasyAntReport.java?rev=1393723&r1=1393722&r2=1393723&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/EasyAntReport.java
(original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/EasyAntReport.java
Wed Oct  3 19:43:38 2012
@@ -74,19 +74,6 @@ public class EasyAntReport {
         return null;
     }
 
-    public TargetReport getTargetReport(String name, boolean includeImports) {
-        TargetReport retVal = getTargetReport(name);
-        if (retVal == null && includeImports) {
-            List<TargetReport> targets = getAvailableTargets();
-            for (TargetReport target : targets) {
-                if (target.getName().equals(name)) {
-                    retVal = target;
-                }
-            }
-        }
-        return retVal;
-    }
-
     /**
      * Add a given targetReport to the list of know target
      * 
@@ -97,6 +84,13 @@ public class EasyAntReport {
         if (targetReport == null) {
             throw new IllegalArgumentException("targetReport cannot be null");
         }
+        if (targetReport.getExtensionPoint() != null) {
+            for (ExtensionPointReport extensionPoint : extensionPointReports) {
+                if (extensionPoint.getName().equals(targetReport.getExtensionPoint())) {
+                    extensionPoint.addTargetReport(targetReport);
+                }
+            }
+        }
         targetReports.add(targetReport);
     }
 
@@ -120,29 +114,6 @@ public class EasyAntReport {
     }
 
     /**
-     * Get an extension point by its name Return null if no extensionPointReport where found
with this name. The
-     * includeImports parameters can be additionally used to extend the search to include
imports by the current module.
-     * 
-     * @param name
-     *            represent the extensionPoint name
-     * @param includeImports
-     *            should the method search included modules
-     * @return an extension point report
-     */
-    public ExtensionPointReport getExtensionPointReport(String name, boolean includeImports)
{
-        ExtensionPointReport retVal = getExtensionPointReport(name);
-        if (includeImports && retVal == null) {
-            List<ExtensionPointReport> extensionPoints = getAvailableExtensionPoints();
-            for (ExtensionPointReport extensionPoint : extensionPoints) {
-                if (extensionPoint.getName().equals(name)) {
-                    retVal = extensionPoint;
-                }
-            }
-        }
-        return retVal;
-    }
-
-    /**
      * Get a list of extension points available in this module
      * 
      * @return a list of extension points
@@ -329,42 +300,11 @@ public class EasyAntReport {
     }
 
     /**
-     * This utilitary function allow us to retrieve a list of all targetReport available
in this module and in all
-     * imported subModules
-     * 
-     * @return a list of all TargetReport available in the module or in its submodules
-     */
-    public List<TargetReport> getAvailableTargets() {
-        List<TargetReport> targets = new ArrayList<TargetReport>();
-        targets.addAll(targetReports);
-        for (ImportedModuleReport importedModuleReport : importedModuleReports) {
-            if (importedModuleReport.getEasyantReport() != null)
-                for (TargetReport targetReport : importedModuleReport.getEasyantReport().getAvailableTargets())
{
-                    TargetReport target = new TargetReport();
-                    if (importedModuleReport.getAs() == null)
-                        targets.add(targetReport);
-                    else {
-                        target.setName(importedModuleReport.getAs() + targetReport.getName());
-                        target.setDepends(targetReport.getDepends());
-                        target.setIfCase(targetReport.getIfCase());
-                        target.setUnlessCase(targetReport.getUnlessCase());
-                        target.setExtensionPoint(targetReport.getExtensionPoint());
-                        targets.add(target);
-                    }
-                }
-
-        }
-
-        return targets;
-
-    }
-
-    /**
      * Return a list of target that are not bound to any extension-points
      */
     public List<TargetReport> getUnboundTargets() {
         List<TargetReport> targets = new ArrayList<TargetReport>();
-        for (TargetReport targetReport : getAvailableTargets()) {
+        for (TargetReport targetReport : targetReports) {
             if (targetReport.getExtensionPoint() == null) {
                 targets.add(targetReport);
             }
@@ -372,43 +312,6 @@ public class EasyAntReport {
         return targets;
     }
 
-    private List<ExtensionPointReport> getAvailableExtensionPointsWithoutTarget() {
-        List<ExtensionPointReport> extensionPoints = new ArrayList<ExtensionPointReport>();
-
-        extensionPoints.addAll(extensionPointReports);
-        for (ImportedModuleReport importedModuleReport : importedModuleReports) {
-            if (importedModuleReport.getEasyantReport() != null) {
-                extensionPoints.addAll(importedModuleReport.getEasyantReport()
-                        .getAvailableExtensionPointsWithoutTarget());
-            }
-        }
-        return extensionPoints;
-    }
-
-    /**
-     * This utilitary function allow us to retrieve a list of all ExtensionPointReport available
in this module and in
-     * all imported subModules
-     * 
-     * @return a list of all ExtensionPointReport available in the module or in its submodules
-     */
-    public List<ExtensionPointReport> getAvailableExtensionPoints() {
-        List<ExtensionPointReport> extensionPoints = getAvailableExtensionPointsWithoutTarget();
-
-        // associate target to extension-points
-        List<TargetReport> targets = getAvailableTargets();
-        for (int i = 0; i < extensionPoints.size(); i++) {
-            ExtensionPointReport extensionPoint = extensionPoints.get(i);
-            for (TargetReport target : targets) {
-                if (extensionPoint.getName().equals(target.getExtensionPoint())) {
-                    extensionPoint.addTargetReport(target);
-                    extensionPoints.set(i, extensionPoint);
-                }
-            }
-        }
-
-        return extensionPoints;
-    }
-
     public ResolveReport getResolveReport() {
         return resolveReport;
     }

Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/Describe.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/Describe.java?rev=1393723&r1=1393722&r2=1393723&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/Describe.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/Describe.java Wed Oct
 3 19:43:38 2012
@@ -49,7 +49,7 @@ public class Describe extends EasyantOpt
                 LINE_SEP + "--- Available references for: " + target + " in current project:
" + getProject().getName()
                         + " ---" + LINE_SEP);
 
-        ExtensionPointReport extensionPointRep = getEareport().getExtensionPointReport(target,
true);
+        ExtensionPointReport extensionPointRep = getEareport().getExtensionPointReport(target);
         if (extensionPointRep != null) {
             getProject().log("\tExtension Point: " + target);
             getProject().log(
@@ -62,7 +62,7 @@ public class Describe extends EasyantOpt
         } else {
             getProject().log("\tNo extrnsion point found for name: " + target);
         }
-        TargetReport targetRep = getEareport().getTargetReport(target, true);
+        TargetReport targetRep = getEareport().getTargetReport(target);
         if (targetRep != null) {
             getProject().log("\tTarget: " + target);
             getProject().log(

Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListExtensionPoints.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListExtensionPoints.java?rev=1393723&r1=1393722&r2=1393723&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListExtensionPoints.java
(original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListExtensionPoints.java
Wed Oct  3 19:43:38 2012
@@ -40,9 +40,9 @@ public class ListExtensionPoints extends
                 LINE_SEP + "--- Available ExtensionPoints for current project: " + getProject().getName()
+ " ---"
                         + LINE_SEP);
 
-        List<ExtensionPointReport> extensionPoints = getEareport().getAvailableExtensionPoints();
-        for (int i = 0; i < extensionPoints.size(); i++) {
-            getProject().log("\t" + extensionPoints.get(i).getName());
+        List<ExtensionPointReport> extensionPoints = getEareport().getExtensionPointReports();
+        for (ExtensionPointReport extensionPointReport : extensionPoints) {
+            getProject().log("\t" + extensionPointReport.getName());
         }
 
         getProject().log(

Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListTargets.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListTargets.java?rev=1393723&r1=1393722&r2=1393723&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListTargets.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListTargets.java Wed
Oct  3 19:43:38 2012
@@ -64,10 +64,10 @@ public class ListTargets extends Easyant
             getProject().log(
                     LINE_SEP + "No ExtensionPoint / Plugin specified. Listing all targets
available in the project.");
 
-            List<TargetReport> targets = getEareport().getAvailableTargets();
+            List<TargetReport> targets = getEareport().getTargetReports();
             printTargets(targets, getProject());
         } else {
-            ExtensionPointReport extensionPointRep = getEareport().getExtensionPointReport(container,
true);
+            ExtensionPointReport extensionPointRep = getEareport().getExtensionPointReport(container);
 
             if (extensionPointRep != null) {
                 getProject().log("Targets for ExtensionPoint: " + container);

Modified: incubator/easyant/core/trunk/src/test/java/org/apache/easyant/core/services/PluginServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/test/java/org/apache/easyant/core/services/PluginServiceTest.java?rev=1393723&r1=1393722&r2=1393723&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/test/java/org/apache/easyant/core/services/PluginServiceTest.java
(original)
+++ incubator/easyant/core/trunk/src/test/java/org/apache/easyant/core/services/PluginServiceTest.java
Wed Oct  3 19:43:38 2012
@@ -127,7 +127,7 @@ public class PluginServiceTest {
         // check that package ExtensionPoint exists and that jar:jar target is bound to
         // this extension-point
         ExtensionPointReport packageEP = null;
-        for (ExtensionPointReport extensionPoint : eaReport.getAvailableExtensionPoints())
{
+        for (ExtensionPointReport extensionPoint : eaReport.getExtensionPointReports()) {
             if ("package".equals(extensionPoint.getName())) {
                 packageEP = extensionPoint;
                 break;
@@ -144,15 +144,9 @@ public class PluginServiceTest {
             Assert.assertTrue("expected to find " + target.getName(), expectedTargets.remove(target.getName()));
         }
 
-        boolean hasHelloWorldTarget = false;
-        for (TargetReport targetReport : eaReport.getAvailableTargets()) {
-            if ("hello-world".equals(targetReport.getName())) {
-                Assert.assertTrue("package".equals(targetReport.getExtensionPoint()));
-                hasHelloWorldTarget = true;
-                break;
-            }
-        }
-        Assert.assertTrue(hasHelloWorldTarget);
+        TargetReport helloWorld = eaReport.getTargetReport("hello-world");
+        Assert.assertNotNull(helloWorld);
+        Assert.assertTrue("package".equals(helloWorld.getExtensionPoint()));
     }
 
     @Test



Mime
View raw message