From 638f9baba802e1d83e445a974b063bf505890b2e Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 1 Apr 2014 01:45:38 +0000 Subject: [PATCH] fix jdk1.8 build git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1583508 13f79535-47bb-0310-9956-ffa450edef68 --- .../metadata/RepositoryMetadataWriter.java | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriter.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriter.java index 535be967e..ab47e78c1 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriter.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriter.java @@ -35,12 +35,13 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; +import java.util.Collections; +import java.util.Comparator; import java.util.Iterator; +import java.util.List; /** * RepositoryMetadataWriter - * - * */ public class RepositoryMetadataWriter { @@ -86,6 +87,10 @@ public class RepositoryMetadataWriter if ( CollectionUtils.isNotEmpty( metadata.getPlugins() ) ) { Element plugins = root.addElement( "plugins" ); + + List pluginList = metadata.getPlugins(); + Collections.sort( pluginList, PluginComparator.INSTANCE ); + for ( Plugin plugin : metadata.getPlugins() ) { Element p = plugins.addElement( "plugin" ); @@ -95,9 +100,11 @@ public class RepositoryMetadataWriter } } - if ( CollectionUtils.isNotEmpty( metadata.getAvailableVersions() ) || StringUtils.isNotBlank( - metadata.getReleasedVersion() ) || StringUtils.isNotBlank( metadata.getLatestVersion() ) - || StringUtils.isNotBlank( metadata.getLastUpdated() ) || ( metadata.getSnapshotVersion() != null ) ) + if ( CollectionUtils.isNotEmpty( metadata.getAvailableVersions() ) // + || StringUtils.isNotBlank( metadata.getReleasedVersion() ) // + || StringUtils.isNotBlank( metadata.getLatestVersion() ) // + || StringUtils.isNotBlank( metadata.getLastUpdated() ) // + || ( metadata.getSnapshotVersion() != null ) ) { Element versioning = root.addElement( "versioning" ); @@ -145,4 +152,25 @@ public class RepositoryMetadataWriter elem.addElement( elemName ).setText( text ); } + + private static class PluginComparator + implements Comparator + { + private static final PluginComparator INSTANCE = new PluginComparator(); + + @Override + public int compare( Plugin plugin, Plugin plugin2 ) + { + if ( plugin.getPrefix() != null && plugin2.getPrefix() != null ) + { + return plugin.getPrefix().compareTo( plugin2.getPrefix() ); + } + if ( plugin.getName() != null && plugin2.getName() != null ) + { + return plugin.getName().compareTo( plugin2.getName() ); + } + // we assume artifactId is not null which sounds good :-) + return plugin.getArtifactId().compareTo( plugin2.getArtifactId() ); + } + } } -- 2.39.5