From 50f3eb885fd6929d10c9f1644ce37ac18ecefac8 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Wed, 7 Jun 2017 23:28:13 +0200 Subject: [PATCH] Fixed #34 o Added implementation to report the plugin dependencies as well. o Added IT's for reporting updates about dependencies in plugins, plugins defined in pluginManagement. --- .../invoker.properties | 1 + .../pom.xml | 80 ++++++++++ .../verify.groovy | 18 +++ .../invoker.properties | 1 + .../pom.xml | 82 ++++++++++ .../verify.groovy | 18 +++ .../invoker.properties | 1 + .../pom.xml | 81 ++++++++++ .../verify.groovy | 18 +++ .../invoker.properties | 1 + .../pom.xml | 81 ++++++++++ .../verify.groovy | 18 +++ .../invoker.properties | 1 + .../pom.xml | 81 ++++++++++ .../verify.groovy | 18 +++ .../DisplayDependencyUpdatesMojo.java | 146 +++++++++++++++--- 16 files changed, 622 insertions(+), 24 deletions(-) create mode 100644 src/it/it-display-dependency-updates-issue-34-1/invoker.properties create mode 100644 src/it/it-display-dependency-updates-issue-34-1/pom.xml create mode 100644 src/it/it-display-dependency-updates-issue-34-1/verify.groovy create mode 100644 src/it/it-display-dependency-updates-issue-34-2/invoker.properties create mode 100644 src/it/it-display-dependency-updates-issue-34-2/pom.xml create mode 100644 src/it/it-display-dependency-updates-issue-34-2/verify.groovy create mode 100644 src/it/it-display-dependency-updates-issue-34-3/invoker.properties create mode 100644 src/it/it-display-dependency-updates-issue-34-3/pom.xml create mode 100644 src/it/it-display-dependency-updates-issue-34-3/verify.groovy create mode 100644 src/it/it-display-dependency-updates-issue-34-4/invoker.properties create mode 100644 src/it/it-display-dependency-updates-issue-34-4/pom.xml create mode 100644 src/it/it-display-dependency-updates-issue-34-4/verify.groovy create mode 100644 src/it/it-display-dependency-updates-issue-34-5/invoker.properties create mode 100644 src/it/it-display-dependency-updates-issue-34-5/pom.xml create mode 100644 src/it/it-display-dependency-updates-issue-34-5/verify.groovy diff --git a/src/it/it-display-dependency-updates-issue-34-1/invoker.properties b/src/it/it-display-dependency-updates-issue-34-1/invoker.properties new file mode 100644 index 0000000000..d065873965 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-34-1/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates diff --git a/src/it/it-display-dependency-updates-issue-34-1/pom.xml b/src/it/it-display-dependency-updates-issue-34-1/pom.xml new file mode 100644 index 0000000000..4ef89883cb --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-34-1/pom.xml @@ -0,0 +1,80 @@ + + 4.0.0 + localhost + it-display-dependency-updates-issue-34-1 + 1.0 + pom + display-dependency-updates-issue-34-1 + We should get reporting about dependencies in dependencyManagement, dependencies, dependencies of plugins defined in pluginManagement and + of dependencies given in plugins defined. + http://localhost/ + + + + localhost + dummy-api + 1.0 + + + + + + localhost + dummy-api + 2.0 + + + + + + + localhost + dummy-maven-plugin + 1.0 + + + localhost + dummy-api + 1.2 + + + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + maven-project-info-reports-plugin + 2.1 + + + + + + localhost + dummy-maven-plugin + + + localhost + dummy-api + 1.1 + + + + + + diff --git a/src/it/it-display-dependency-updates-issue-34-1/verify.groovy b/src/it/it-display-dependency-updates-issue-34-1/verify.groovy new file mode 100644 index 0000000000..4324fba3cc --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-34-1/verify.groovy @@ -0,0 +1,18 @@ + +def buildLog = new File( basedir, "build.log") + +assert buildLog.text.contains( '[INFO] The following dependencies in Dependency Management have newer versions:') +assert buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 1.0 -> 3.0') + +assert buildLog.text.contains( '[INFO] The following dependencies in Dependencies have newer versions:' ) +assert buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 2.0 -> 3.0' ) + +assert buildLog.text.contains( '[INFO] The following dependencies in pluginManagement of plugins have newer versions:' ) +assert buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 1.2 -> 3.0' ) + +assert buildLog.text.contains( '[INFO] The following dependencies in Plugin Dependencies have newer versions:') +assert buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 1.1 -> 3.0' ) + +assert buildLog.text.contains( '[INFO] BUILD SUCCESS' ) + +return true diff --git a/src/it/it-display-dependency-updates-issue-34-2/invoker.properties b/src/it/it-display-dependency-updates-issue-34-2/invoker.properties new file mode 100644 index 0000000000..b02a2b4d62 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-34-2/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates -DprocessPluginDependencies=false diff --git a/src/it/it-display-dependency-updates-issue-34-2/pom.xml b/src/it/it-display-dependency-updates-issue-34-2/pom.xml new file mode 100644 index 0000000000..153704dd86 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-34-2/pom.xml @@ -0,0 +1,82 @@ + + 4.0.0 + localhost + it-display-dependency-updates-issue-34-2 + 1.0 + pom + display-dependency-updates-issue-34-2 + We should get reporting dependencies in dependencyManagement, dependencies and of dependencies of plugins defined in pluginManagement. + Should be reported being updateable. + -DprocessPluginDependencies=false + + http://localhost/ + + + + localhost + dummy-api + 1.0 + + + + + + localhost + dummy-api + 2.0 + + + + + + + localhost + dummy-maven-plugin + 1.0 + + + localhost + dummy-api + 1.2 + + + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + maven-project-info-reports-plugin + 2.1 + + + + + + localhost + dummy-maven-plugin + + + localhost + dummy-api + 1.1 + + + + + + diff --git a/src/it/it-display-dependency-updates-issue-34-2/verify.groovy b/src/it/it-display-dependency-updates-issue-34-2/verify.groovy new file mode 100644 index 0000000000..536e943313 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-34-2/verify.groovy @@ -0,0 +1,18 @@ + +def buildLog = new File( basedir, "build.log") + +assert buildLog.text.contains( '[INFO] The following dependencies in Dependency Management have newer versions:') +assert buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 1.0 -> 3.0') + +assert buildLog.text.contains( '[INFO] The following dependencies in Dependencies have newer versions:' ) +assert buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 2.0 -> 3.0' ) + +assert buildLog.text.contains( '[INFO] The following dependencies in pluginManagement of plugins have newer versions:' ) +assert buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 1.2 -> 3.0' ) + +assert !buildLog.text.contains( '[INFO] The following dependencies in Plugin Dependencies have newer versions:') +assert !buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 1.1 -> 3.0' ) + +assert buildLog.text.contains( '[INFO] BUILD SUCCESS' ) + +return true diff --git a/src/it/it-display-dependency-updates-issue-34-3/invoker.properties b/src/it/it-display-dependency-updates-issue-34-3/invoker.properties new file mode 100644 index 0000000000..46685a2d78 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-34-3/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates -DprocessPluginDependencies=false -DprocessPluginDependenciesInPluginManagement=false diff --git a/src/it/it-display-dependency-updates-issue-34-3/pom.xml b/src/it/it-display-dependency-updates-issue-34-3/pom.xml new file mode 100644 index 0000000000..d6ff2b667a --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-34-3/pom.xml @@ -0,0 +1,81 @@ + + 4.0.0 + localhost + it-display-dependency-updates-issue-34-3 + 1.0 + pom + display-dependency-updates-issue-34-3 + We should get reports about dependencies in dependencyManagement and of dependencies. + -DprocessPluginDependencies=false -DprocessPluginDependenciesInPluginManagement=false + + http://localhost/ + + + + localhost + dummy-api + 1.0 + + + + + + localhost + dummy-api + 2.0 + + + + + + + localhost + dummy-maven-plugin + 1.0 + + + localhost + dummy-api + 1.2 + + + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + maven-project-info-reports-plugin + 2.1 + + + + + + localhost + dummy-maven-plugin + + + localhost + dummy-api + 1.1 + + + + + + diff --git a/src/it/it-display-dependency-updates-issue-34-3/verify.groovy b/src/it/it-display-dependency-updates-issue-34-3/verify.groovy new file mode 100644 index 0000000000..7a60a2cac1 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-34-3/verify.groovy @@ -0,0 +1,18 @@ + +def buildLog = new File( basedir, "build.log") + +assert buildLog.text.contains( '[INFO] The following dependencies in Dependency Management have newer versions:') +assert buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 1.0 -> 3.0') + +assert buildLog.text.contains( '[INFO] The following dependencies in Dependencies have newer versions:' ) +assert buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 2.0 -> 3.0' ) + +assert !buildLog.text.contains( '[INFO] The following dependencies in pluginManagement of plugins have newer versions:' ) +assert !buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 1.2 -> 3.0' ) + +assert !buildLog.text.contains( '[INFO] The following dependencies in Plugin Dependencies have newer versions:') +assert !buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 1.1 -> 3.0' ) + +assert buildLog.text.contains( '[INFO] BUILD SUCCESS' ) + +return true diff --git a/src/it/it-display-dependency-updates-issue-34-4/invoker.properties b/src/it/it-display-dependency-updates-issue-34-4/invoker.properties new file mode 100644 index 0000000000..41225f4ed5 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-34-4/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates -DprocessPluginDependencies=false -DprocessPluginDependenciesInPluginManagement=false -DprocessDependencies=false diff --git a/src/it/it-display-dependency-updates-issue-34-4/pom.xml b/src/it/it-display-dependency-updates-issue-34-4/pom.xml new file mode 100644 index 0000000000..1cf6688dde --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-34-4/pom.xml @@ -0,0 +1,81 @@ + + 4.0.0 + localhost + it-display-dependency-updates-issue-34-4 + 1.0 + pom + display-dependency-updates-issue-34-4 + We should get only update report of dependencies in dependencyManagement. + -DprocessPluginDependencies=false -DprocessPluginDependenciesInPluginManagement=false -DprocessDependencies=false + + http://localhost/ + + + + localhost + dummy-api + 1.0 + + + + + + localhost + dummy-api + 2.0 + + + + + + + localhost + dummy-maven-plugin + 1.0 + + + localhost + dummy-api + 1.2 + + + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + maven-project-info-reports-plugin + 2.1 + + + + + + localhost + dummy-maven-plugin + + + localhost + dummy-api + 1.1 + + + + + + diff --git a/src/it/it-display-dependency-updates-issue-34-4/verify.groovy b/src/it/it-display-dependency-updates-issue-34-4/verify.groovy new file mode 100644 index 0000000000..889ab19d66 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-34-4/verify.groovy @@ -0,0 +1,18 @@ + +def buildLog = new File( basedir, "build.log") + +assert buildLog.text.contains( '[INFO] The following dependencies in Dependency Management have newer versions:') +assert buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 1.0 -> 3.0') + +assert !buildLog.text.contains( '[INFO] The following dependencies in Dependencies have newer versions:' ) +assert !buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 2.0 -> 3.0' ) + +assert !buildLog.text.contains( '[INFO] The following dependencies in pluginManagement of plugins have newer versions:' ) +assert !buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 1.2 -> 3.0' ) + +assert !buildLog.text.contains( '[INFO] The following dependencies in Plugin Dependencies have newer versions:') +assert !buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 1.1 -> 3.0' ) + +assert buildLog.text.contains( '[INFO] BUILD SUCCESS' ) + +return true diff --git a/src/it/it-display-dependency-updates-issue-34-5/invoker.properties b/src/it/it-display-dependency-updates-issue-34-5/invoker.properties new file mode 100644 index 0000000000..819f19356f --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-34-5/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates -DprocessPluginDependencies=false -DprocessPluginDependenciesInPluginManagement=false -DprocessDependencies=false -DprocessDependencyManagement=false diff --git a/src/it/it-display-dependency-updates-issue-34-5/pom.xml b/src/it/it-display-dependency-updates-issue-34-5/pom.xml new file mode 100644 index 0000000000..9cfeac0820 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-34-5/pom.xml @@ -0,0 +1,81 @@ + + 4.0.0 + localhost + it-display-dependency-updates-issue-34-5 + 1.0 + pom + display-dependency-updates-issue-34-5 + we should not get any repoting about updated cause we forbid everything. + -DprocessPluginDependencies=false -DprocessPluginDependenciesInPluginManagement=false -DprocessDependencies=false -DprocessDependencyManagement=false + + http://localhost/ + + + + localhost + dummy-api + 1.0 + + + + + + localhost + dummy-api + 2.0 + + + + + + + localhost + dummy-maven-plugin + 1.0 + + + localhost + dummy-api + 1.2 + + + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + maven-project-info-reports-plugin + 2.1 + + + + + + localhost + dummy-maven-plugin + + + localhost + dummy-api + 1.1 + + + + + + diff --git a/src/it/it-display-dependency-updates-issue-34-5/verify.groovy b/src/it/it-display-dependency-updates-issue-34-5/verify.groovy new file mode 100644 index 0000000000..408f638afc --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-34-5/verify.groovy @@ -0,0 +1,18 @@ + +def buildLog = new File( basedir, "build.log") + +assert !buildLog.text.contains( '[INFO] The following dependencies in Dependency Management have newer versions:') +assert !buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 1.0 -> 3.0') + +assert !buildLog.text.contains( '[INFO] The following dependencies in Dependencies have newer versions:' ) +assert !buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 2.0 -> 3.0' ) + +assert !buildLog.text.contains( '[INFO] The following dependencies in pluginManagement of plugins have newer versions:' ) +assert !buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 1.2 -> 3.0' ) + +assert !buildLog.text.contains( '[INFO] The following dependencies in Plugin Dependencies have newer versions:') +assert !buildLog.text.contains( '[INFO] localhost:dummy-api ....................................... 1.1 -> 3.0' ) + +assert buildLog.text.contains( '[INFO] BUILD SUCCESS' ) + +return true diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index c8ab8f016e..71295ac68c 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -23,7 +23,9 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; +import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; +import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; @@ -34,8 +36,6 @@ import org.codehaus.mojo.versions.utils.DependencyComparator; import org.codehaus.plexus.util.StringUtils; -import javax.xml.stream.XMLStreamException; - import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -43,6 +43,8 @@ import java.util.Set; import java.util.TreeSet; +import javax.xml.stream.XMLStreamException; + /** * Displays all dependencies that have newer versions available. * @@ -79,6 +81,22 @@ public class DisplayDependencyUpdatesMojo @Parameter( property = "processDependencies", defaultValue = "true" ) protected boolean processDependencies; + /** + * Whether to process the dependencies sections of plugins. + * + * @since 2.5 + */ + @Parameter( property = "processPluginDependencies", defaultValue = "true" ) + protected boolean processPluginDependencies; + + /** + * Whether to process the dependencies sections of plugins which are defined in pluginManagement. + * + * @since 2.5 + */ + @Parameter( property = "processPluginDependenciesInPluginManagement", defaultValue = "true" ) + protected boolean processPluginDependenciesInPluginManagement; + /** * Whether to show additional information such as dependencies that do not need updating. * @@ -89,6 +107,41 @@ public class DisplayDependencyUpdatesMojo // --------------------- GETTER / SETTER METHODS --------------------- + private static Set extractPluginDependenciesFromPluginsInPluginManagement( Build build ) + { + Set result = new TreeSet( new DependencyComparator() ); + if ( build.getPluginManagement() != null ) + { + for ( Plugin plugin : build.getPluginManagement().getPlugins() ) + { + if ( plugin.getDependencies() != null && !plugin.getDependencies().isEmpty() ) + { + for ( Dependency pluginDependency : plugin.getDependencies() ) + { + result.add( pluginDependency ); + } + } + } + } + return result; + } + + private static Set extractDependenciesFromPlugins( List plugins ) + { + Set result = new TreeSet( new DependencyComparator() ); + for ( Plugin plugin : plugins ) + { + if ( plugin.getDependencies() != null && !plugin.getDependencies().isEmpty() ) + { + for ( Dependency pluginDependency : plugin.getDependencies() ) + { + result.add( pluginDependency ); + } + } + } + return result; + } + /** * Returns a set of dependencies where the dependencies which are defined in the dependency management section have * been filtered out. @@ -99,9 +152,9 @@ public class DisplayDependencyUpdatesMojo * management dependencies. * @since 1.0-beta-1 */ - private static Set removeDependencyManagment( Set dependencies, Set dependencyManagement ) + private static Set removeDependencyManagment( Set dependencies, Set dependencyManagement ) { - Set result = new TreeSet( new DependencyComparator() ); + Set result = new TreeSet( new DependencyComparator() ); for ( Iterator i = dependencies.iterator(); i.hasNext(); ) { Dependency c = (Dependency) i.next(); @@ -139,6 +192,16 @@ public boolean isProcessingDependencies() return processDependencies; } + public boolean isProcessingPluginDependencies() + { + return processPluginDependencies; + } + + public boolean isProcessPluginDependenciesInDependencyManagement() + { + return processPluginDependenciesInPluginManagement; + } + public boolean isVerbose() { return verbose; @@ -159,7 +222,7 @@ public void execute() { logInit(); - Set dependencyManagement = new TreeSet( new DependencyComparator() ); + Set dependencyManagement = new TreeSet( new DependencyComparator() ); if ( getProject().getDependencyManagement() != null ) { @@ -206,7 +269,7 @@ public void execute() } } - Set dependencies = new TreeSet( new DependencyComparator() ); + Set dependencies = new TreeSet( new DependencyComparator() ); dependencies.addAll( getProject().getDependencies() ); if ( isProcessingDependencyManagement() ) @@ -214,6 +277,20 @@ public void execute() dependencies = removeDependencyManagment( dependencies, dependencyManagement ); } + Set pluginDependencies = new TreeSet( new DependencyComparator() ); + + if ( isProcessingPluginDependencies() ) + { + pluginDependencies = extractDependenciesFromPlugins( getProject().getBuildPlugins() ); + } + + Set pluginDependenciesInPluginManagement = new TreeSet( new DependencyComparator() ); + if ( isProcessPluginDependenciesInDependencyManagement() ) + { + pluginDependenciesInPluginManagement = + extractPluginDependenciesFromPluginsInPluginManagement( getProject().getBuild() ); + } + try { if ( isProcessingDependencyManagement() ) @@ -225,6 +302,15 @@ public void execute() { logUpdates( getHelper().lookupDependenciesUpdates( dependencies, false ), "Dependencies" ); } + if ( isProcessPluginDependenciesInDependencyManagement() ) + { + logUpdates( getHelper().lookupDependenciesUpdates( pluginDependenciesInPluginManagement, false ), + "pluginManagement of plugins" ); + } + if ( isProcessingPluginDependencies() ) + { + logUpdates( getHelper().lookupDependenciesUpdates( pluginDependencies, false ), "Plugin Dependencies" ); + } } catch ( InvalidVersionSpecificationException e ) { @@ -236,7 +322,7 @@ public void execute() } } - private void logUpdates( Map updates, String section ) + private void logUpdates( Map updates, String section ) { List withUpdates = new ArrayList(); List usingCurrent = new ArrayList(); @@ -266,7 +352,7 @@ private void logUpdates( Map updates, String section ) } } String right = " " + ( latest == null ? current : current + " -> " + latest.toString() ); - List t = latest == null ? usingCurrent : withUpdates; + List t = latest == null ? usingCurrent : withUpdates; if ( right.length() + left.length() + 3 > INFO_PAD_SIZE ) { t.add( left + "..." ); @@ -278,27 +364,39 @@ private void logUpdates( Map updates, String section ) t.add( StringUtils.rightPad( left, INFO_PAD_SIZE - right.length(), "." ) + right ); } } - if ( isVerbose() && usingCurrent.isEmpty() && !withUpdates.isEmpty() ) - { - logLine( false, "No dependencies in " + section + " are using the newest version." ); - logLine( false, "" ); - } - else if ( isVerbose() && !usingCurrent.isEmpty() ) + + if ( isVerbose() ) { - logLine( false, "The following dependencies in " + section + " are using the newest version:" ); - i = usingCurrent.iterator(); - while ( i.hasNext() ) + if ( usingCurrent.isEmpty() ) { - logLine( false, (String) i.next() ); + if ( !withUpdates.isEmpty() ) + { + logLine( false, "No dependencies in " + section + " are using the newest version." ); + logLine( false, "" ); + } } - logLine( false, "" ); - } - if ( withUpdates.isEmpty() && !usingCurrent.isEmpty() ) + else + { + logLine( false, "The following dependencies in " + section + " are using the newest version:" ); + i = usingCurrent.iterator(); + while ( i.hasNext() ) + { + logLine( false, (String) i.next() ); + } + logLine( false, "" ); + } + } + + + if ( withUpdates.isEmpty() ) { - logLine( false, "No dependencies in " + section + " have newer versions." ); - logLine( false, "" ); + if ( !usingCurrent.isEmpty() ) + { + logLine( false, "No dependencies in " + section + " have newer versions." ); + logLine( false, "" ); + } } - else if ( !withUpdates.isEmpty() ) + else { logLine( false, "The following dependencies in " + section + " have newer versions:" ); i = withUpdates.iterator();