ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlboud...@apache.org
Subject svn commit: r1493256 - in /ant/ivy/core/trunk: src/java/org/apache/ivy/ant/IvyDependencyUpdateChecker.java test/java/org/apache/ivy/ant/IvyDependencyUpdateCheckerTest.java
Date Fri, 14 Jun 2013 21:43:15 GMT
Author: jlboudart
Date: Fri Jun 14 21:43:15 2013
New Revision: 1493256

URL: http://svn.apache.org/r1493256
Log:
add showTransitive attribute on dependencyUpdateChecker task

Modified:
    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyUpdateChecker.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyDependencyUpdateCheckerTest.java

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyUpdateChecker.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyUpdateChecker.java?rev=1493256&r1=1493255&r2=1493256&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyUpdateChecker.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyUpdateChecker.java Fri Jun
14 21:43:15 2013
@@ -41,6 +41,8 @@ public class IvyDependencyUpdateChecker 
 
     private boolean checkIfChanged = false;
 
+    private boolean showTransitive = false;
+
     public void doExecute() throws BuildException {
         prepareAndCheck();
 
@@ -75,8 +77,10 @@ public class IvyDependencyUpdateChecker 
                 resolveOptions);
 
             displayDependencyUpdates(getResolvedReport(), latestReport);
-            displayNewDependencyOnLatest(getResolvedReport(), latestReport);
-            displayMissingDependencyOnLatest(getResolvedReport(), latestReport);
+            if (showTransitive) {
+                displayNewDependencyOnLatest(getResolvedReport(), latestReport);
+                displayMissingDependencyOnLatest(getResolvedReport(), latestReport);
+            }
 
         } catch (ParseException e) {
             throw new BuildException("impossible to resolve dependencies:\n\t" + e, e);
@@ -102,18 +106,20 @@ public class IvyDependencyUpdateChecker 
                         // .isTranstive() methods doesn't have the same meaning)
                         boolean isTransitiveDependency = latest.getDependencyDescriptor(latest
                                 .getRoot()) == null;
-                        StringBuffer sb = new StringBuffer();
-                        sb.append("\t")//
-                                .append(originalDependency.getResolvedId().getOrganisation())
//
-                                .append('#')//
-                                .append(originalDependency.getResolvedId().getName())//
-                                .append(isTransitiveDependency ? " (transitive)" : "") //
-                                .append("\t")//
-                                .append(originalDependency.getResolvedId().getRevision())//
-                                .append(" -> ")//
-                                .append(latest.getResolvedId().getRevision());
-                        log(sb.toString());
-                        dependencyUpdateDetected = true;
+                        if ((!isTransitiveDependency) || (isTransitiveDependency &&
showTransitive)) {
+                            StringBuffer sb = new StringBuffer();
+                            sb.append("\t")//
+                                    .append(originalDependency.getResolvedId().getOrganisation())
//
+                                    .append('#')//
+                                    .append(originalDependency.getResolvedId().getName())//
+                                    .append(isTransitiveDependency ? " (transitive)" : "")
//
+                                    .append("\t")//
+                                    .append(originalDependency.getResolvedId().getRevision())//
+                                    .append(" -> ")//
+                                    .append(latest.getResolvedId().getRevision());
+                            log(sb.toString());
+                            dependencyUpdateDetected = true;
+                        }
                     }
 
                 }
@@ -197,4 +203,12 @@ public class IvyDependencyUpdateChecker 
         this.download = download;
     }
 
+    public boolean isShowTransitive() {
+        return showTransitive;
+    }
+
+    public void setShowTransitive(boolean showTransitive) {
+        this.showTransitive = showTransitive;
+    }
+
 }

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyDependencyUpdateCheckerTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyDependencyUpdateCheckerTest.java?rev=1493256&r1=1493255&r2=1493256&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyDependencyUpdateCheckerTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyDependencyUpdateCheckerTest.java Fri
Jun 14 21:43:15 2013
@@ -58,7 +58,7 @@ public class IvyDependencyUpdateCheckerT
 
     public void testSimple() throws Exception {
         // depends on org="org1" name="mod1.1" rev="1.0"
-        // has transitive dependecy on org="org1" name="mod1.2" rev="2.0"
+        // has transitive dependency on org="org1" name="mod1.2" rev="2.0"
         dependencyUpdateChecker.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple3.xml"));
         dependencyUpdateChecker.execute();
 
@@ -67,6 +67,21 @@ public class IvyDependencyUpdateCheckerT
 
         assertLogContaining("Dependencies updates available :");
         assertLogContaining("org1#mod1.1\t1.0 -> 2.0");
+        assertLogNotContaining("org1#mod1.2 (transitive)\t2.0 -> 2.1");
+    }
+
+    public void testSimpleAndShowTransitiveDependencies() throws Exception {
+        // depends on org="org1" name="mod1.1" rev="1.0"
+        // has transitive dependency on org="org1" name="mod1.2" rev="2.0"
+        dependencyUpdateChecker.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple3.xml"));
+        dependencyUpdateChecker.setShowTransitive(true);
+        dependencyUpdateChecker.execute();
+
+        assertEquals("resolve-simple", getIvy().getVariable("ivy.module"));
+        assertEquals("1.0", getIvy().getVariable("ivy.revision"));
+
+        assertLogContaining("Dependencies updates available :");
+        assertLogContaining("org1#mod1.1\t1.0 -> 2.0");
         assertLogContaining("org1#mod1.2 (transitive)\t2.0 -> 2.1");
     }
 



Mime
View raw message