refactor System.getProperty() and loops
Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/1a283ab1 Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/1a283ab1 Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/1a283ab1 Branch: refs/heads/master Commit: 1a283ab1be5b495f5be8cf6c2ab2b96453dd32f9 Parents: 366fb74 Author: twogee <[email protected]> Authored: Sun Jul 23 01:52:20 2017 +0200 Committer: Jaikiran Pai <[email protected]> Committed: Thu Jul 27 21:10:47 2017 +0530 ---------------------------------------------------------------------- src/java/org/apache/ivy/Main.java | 9 +- .../org/apache/ivy/ant/AntBuildTrigger.java | 3 +- src/java/org/apache/ivy/ant/IvyBuildList.java | 4 +- src/java/org/apache/ivy/ant/IvyBuildNumber.java | 9 +- src/java/org/apache/ivy/ant/IvyCacheTask.java | 14 +- src/java/org/apache/ivy/ant/IvyCheck.java | 3 +- src/java/org/apache/ivy/ant/IvyCleanCache.java | 3 +- .../org/apache/ivy/ant/IvyDependencyTree.java | 3 +- .../apache/ivy/ant/IvyExtractFromSources.java | 4 +- src/java/org/apache/ivy/ant/IvyInfo.java | 6 +- src/java/org/apache/ivy/ant/IvyResolve.java | 5 +- .../org/apache/ivy/core/IvyPatternHelper.java | 14 +- .../apache/ivy/core/event/IvyEventFilter.java | 9 +- .../apache/ivy/core/install/InstallEngine.java | 7 +- .../descriptor/DefaultModuleDescriptor.java | 6 +- .../apache/ivy/core/module/id/ModuleRules.java | 6 +- .../apache/ivy/core/publish/PublishEngine.java | 24 +- .../core/report/ConfigurationResolveReport.java | 6 +- .../ivy/core/retrieve/RetrieveEngine.java | 3 +- .../apache/ivy/core/settings/IvySettings.java | 3 +- .../ivy/core/settings/XmlSettingsParser.java | 5 +- .../apache/ivy/osgi/core/BundleInfoAdapter.java | 7 +- .../apache/ivy/osgi/core/ManifestParser.java | 3 +- .../org/apache/ivy/osgi/p2/P2Descriptor.java | 3 +- .../ivy/osgi/repo/AbstractOSGiResolver.java | 7 +- .../repo/ArtifactReportManifestIterable.java | 15 +- .../LatestCompatibleConflictManager.java | 20 +- .../plugins/latest/WorkspaceLatestStrategy.java | 4 +- .../ivy/plugins/matcher/GlobPatternMatcher.java | 3 +- .../plugins/matcher/RegexpPatternMatcher.java | 3 +- .../parser/AbstractModuleDescriptorParser.java | 65 ++--- .../parser/m2/PomModuleDescriptorBuilder.java | 9 +- .../parser/m2/PomModuleDescriptorParser.java | 28 +-- .../parser/m2/PomModuleDescriptorWriter.java | 6 +- .../parser/xml/XmlModuleDescriptorUpdater.java | 2 +- .../parser/xml/XmlModuleDescriptorWriter.java | 6 +- .../ivy/plugins/report/XmlReportParser.java | 241 ++++++++++--------- .../plugins/repository/vfs/VfsRepository.java | 7 +- .../resolver/AbstractPatternsBasedResolver.java | 12 +- .../resolver/AbstractWorkspaceResolver.java | 4 +- .../ivy/plugins/resolver/BasicResolver.java | 21 +- .../ivy/plugins/resolver/CacheResolver.java | 3 +- .../ivy/plugins/resolver/IvyRepResolver.java | 7 +- .../apache/ivy/plugins/trigger/LogTrigger.java | 2 +- .../org/apache/ivy/util/ChecksumHelper.java | 3 +- .../org/apache/ivy/util/ConfigurationUtils.java | 6 +- src/java/org/apache/ivy/util/Configurator.java | 8 +- src/java/org/apache/ivy/util/XMLHelper.java | 3 +- .../parser/xml/XmlModuleUpdaterTest.java | 2 +- .../resolver/FileSystemResolverTest.java | 2 +- .../ivy/plugins/trigger/LogTriggerTest.java | 2 +- 51 files changed, 292 insertions(+), 358 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/Main.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/Main.java b/src/java/org/apache/ivy/Main.java index 9dc058a..c1d71a7 100644 --- a/src/java/org/apache/ivy/Main.java +++ b/src/java/org/apache/ivy/Main.java @@ -403,8 +403,7 @@ public final class Main { if (line.hasOption("cp")) { fileList = new ArrayList<>(); for (String cp : line.getOptionValues("cp")) { - StringTokenizer tokenizer = new StringTokenizer(cp, - System.getProperty("path.separator")); + StringTokenizer tokenizer = new StringTokenizer(cp, File.pathSeparator); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); File file = new File(token); @@ -469,7 +468,6 @@ public final class Main { private static void outputCachePath(Ivy ivy, File cache, ModuleDescriptor md, String[] confs, String outFile) { try { - String pathSeparator = System.getProperty("path.separator"); StringBuilder buf = new StringBuilder(); Collection<ArtifactDownloadReport> all = new LinkedHashSet<>(); ResolutionCacheManager cacheMgr = ivy.getResolutionCacheManager(); @@ -484,13 +482,14 @@ public final class Main { for (ArtifactDownloadReport artifact : all) { if (artifact.getLocalFile() != null) { buf.append(artifact.getLocalFile().getCanonicalPath()); - buf.append(pathSeparator); + buf.append(File.pathSeparator); } } PrintWriter writer = new PrintWriter(new FileOutputStream(outFile)); if (buf.length() > 0) { - writer.println(buf.substring(0, buf.length() - pathSeparator.length())); + buf.setLength(buf.length() - File.pathSeparator.length()); + writer.println(buf); } writer.close(); System.out.println("cachepath output to " + outFile); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/ant/AntBuildTrigger.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/AntBuildTrigger.java b/src/java/org/apache/ivy/ant/AntBuildTrigger.java index 735fe23..cde8d74 100644 --- a/src/java/org/apache/ivy/ant/AntBuildTrigger.java +++ b/src/java/org/apache/ivy/ant/AntBuildTrigger.java @@ -90,8 +90,7 @@ public class AntBuildTrigger extends AbstractTrigger implements Trigger { if (target != null) { ant.setTarget(target); } - Map<String, String> atts = event.getAttributes(); - for (Map.Entry<String, String> entry : atts.entrySet()) { + for (Map.Entry<String, String> entry : event.getAttributes().entrySet()) { if (entry.getValue() != null) { Property p = ant.createProperty(); p.setName(prefix == null ? entry.getKey() : prefix + entry.getKey()); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/ant/IvyBuildList.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/IvyBuildList.java b/src/java/org/apache/ivy/ant/IvyBuildList.java index 9ff9b75..7eacfed 100644 --- a/src/java/org/apache/ivy/ant/IvyBuildList.java +++ b/src/java/org/apache/ivy/ant/IvyBuildList.java @@ -462,8 +462,8 @@ public class IvyBuildList extends IvyTask { Map<ModuleId, ModuleDescriptor> moduleIdMap) { for (ModuleDescriptor md : moduleIdMap.values()) { for (DependencyDescriptor dep : md.getDependencies()) { - ModuleId id = dep.getDependencyId(); - if (node.getModuleRevisionId().getModuleId().equals(id) && !toKeep.contains(md)) { + if (node.getModuleRevisionId().getModuleId().equals(dep.getDependencyId()) + && !toKeep.contains(md)) { toKeep.add(md); if (!getOnlydirectdep()) { processFilterNodeFromLeaf(md, toKeep, moduleIdMap); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/ant/IvyBuildNumber.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/IvyBuildNumber.java b/src/java/org/apache/ivy/ant/IvyBuildNumber.java index 3216532..8673585 100644 --- a/src/java/org/apache/ivy/ant/IvyBuildNumber.java +++ b/src/java/org/apache/ivy/ant/IvyBuildNumber.java @@ -17,6 +17,7 @@ */ package org.apache.ivy.ant; +import java.util.ArrayList; import java.util.List; import java.util.ListIterator; import java.util.regex.Pattern; @@ -198,14 +199,14 @@ public class IvyBuildNumber extends IvyTask { revisions = searcher.listModules(depResolver, mrid, patternMatcher); } - ArtifactInfo[] infos = new ArtifactInfo[revisions.length]; - for (int i = 0; i < revisions.length; i++) { - infos[i] = new ResolvedModuleRevisionArtifactInfo(revisions[i]); + List<ArtifactInfo> infos = new ArrayList<>(revisions.length); + for (ModuleRevisionId rev : revisions) { + infos.add(new ResolvedModuleRevisionArtifactInfo(rev)); } VersionMatcher matcher = settings.getVersionMatcher(); LatestStrategy latestStrategy = settings.getLatestStrategy("latest-revision"); - List<ArtifactInfo> sorted = latestStrategy.sort(infos); + List<ArtifactInfo> sorted = latestStrategy.sort(infos.toArray(new ArtifactInfo[revisions.length])); ModuleRevisionId askedMrid = ModuleRevisionId.newInstance(organisation, module, branch, revision); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/ant/IvyCacheTask.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/IvyCacheTask.java b/src/java/org/apache/ivy/ant/IvyCacheTask.java index d053257..e382ce3 100644 --- a/src/java/org/apache/ivy/ant/IvyCacheTask.java +++ b/src/java/org/apache/ivy/ant/IvyCacheTask.java @@ -25,7 +25,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashSet; import java.util.List; -import java.util.Set; import org.apache.ivy.core.cache.ResolutionCacheManager; import org.apache.ivy.core.module.id.ModuleRevisionId; @@ -45,9 +44,8 @@ public abstract class IvyCacheTask extends IvyPostResolveTask { protected List<ArtifactDownloadReport> getArtifactReports() throws BuildException, ParseException, IOException { - Collection<ArtifactDownloadReport> artifacts = getAllArtifactReports(); List<ArtifactDownloadReport> ret = new ArrayList<>(); - for (ArtifactDownloadReport artifactReport : artifacts) { + for (ArtifactDownloadReport artifactReport : getAllArtifactReports()) { if (getArtifactFilter().accept(artifactReport.getArtifact())) { ret.add(artifactReport); } @@ -70,11 +68,8 @@ public abstract class IvyCacheTask extends IvyPostResolveTask { throw new BuildException("bad confs provided: " + conf + " not found among " + Arrays.asList(report.getConfigurations())); } - Set<ModuleRevisionId> revisions = configurationReport.getModuleRevisionIds(); - for (ModuleRevisionId revId : revisions) { - ArtifactDownloadReport[] aReports = configurationReport - .getDownloadReports(revId); - all.addAll(Arrays.asList(aReports)); + for (ModuleRevisionId revId : configurationReport.getModuleRevisionIds()) { + all.addAll(Arrays.asList(configurationReport.getDownloadReports(revId))); } } } else { @@ -91,8 +86,7 @@ public abstract class IvyCacheTask extends IvyPostResolveTask { conf); parser.parse(reportFile); - ArtifactDownloadReport[] aReports = parser.getArtifactReports(); - all.addAll(Arrays.asList(aReports)); + all.addAll(Arrays.asList(parser.getArtifactReports())); } } return all; http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/ant/IvyCheck.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/IvyCheck.java b/src/java/org/apache/ivy/ant/IvyCheck.java index 50a353e..20fa18c 100644 --- a/src/java/org/apache/ivy/ant/IvyCheck.java +++ b/src/java/org/apache/ivy/ant/IvyCheck.java @@ -81,8 +81,7 @@ public class IvyCheck extends IvyTask { File fromDir = fs.getDir(getProject()); - String[] srcFiles = ds.getIncludedFiles(); - for (String srcFile : srcFiles) { + for (String srcFile : ds.getIncludedFiles()) { File file = new File(fromDir, srcFile); if (ivy.check(file.toURI().toURL(), resolvername)) { Message.verbose("checked " + file + ": OK"); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/ant/IvyCleanCache.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/IvyCleanCache.java b/src/java/org/apache/ivy/ant/IvyCleanCache.java index 6e1612f..95726ff 100644 --- a/src/java/org/apache/ivy/ant/IvyCleanCache.java +++ b/src/java/org/apache/ivy/ant/IvyCleanCache.java @@ -69,8 +69,7 @@ public class IvyCleanCache extends IvyTask { settings.getResolutionCacheManager().clean(); } if (ALL.equals(getCache())) { - RepositoryCacheManager[] caches = settings.getRepositoryCacheManagers(); - for (RepositoryCacheManager cache : caches) { + for (RepositoryCacheManager cache : settings.getRepositoryCacheManagers()) { cache.clean(); } } else if (!NONE.equals(getCache())) { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/ant/IvyDependencyTree.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/IvyDependencyTree.java b/src/java/org/apache/ivy/ant/IvyDependencyTree.java index 1817063..43def69 100644 --- a/src/java/org/apache/ivy/ant/IvyDependencyTree.java +++ b/src/java/org/apache/ivy/ant/IvyDependencyTree.java @@ -130,8 +130,7 @@ public class IvyDependencyTree extends IvyPostResolveTask { private void addDependency(final ModuleRevisionId moduleRevisionId, final IvyNode dependency) { registerNodeIfNecessary(moduleRevisionId); - final List<IvyNode> dependencyList = dependencies.get(moduleRevisionId); - dependencyList.add(dependency); + dependencies.get(moduleRevisionId).add(dependency); } public boolean isShowEvicted() { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/ant/IvyExtractFromSources.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/IvyExtractFromSources.java b/src/java/org/apache/ivy/ant/IvyExtractFromSources.java index 588c2a6..7943f37 100644 --- a/src/java/org/apache/ivy/ant/IvyExtractFromSources.java +++ b/src/java/org/apache/ivy/ant/IvyExtractFromSources.java @@ -24,7 +24,6 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.io.Writer; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -132,9 +131,8 @@ public class IvyExtractFromSources extends Task { Writer out = new StringWriter(); concat.setWriter(out); concat.execute(); - Set<String> importsSet = new HashSet<>(Arrays.asList(out.toString().split("\n"))); Set<ModuleRevisionId> dependencies = new HashSet<>(); - for (String pack : importsSet) { + for (String pack : out.toString().split("\n")) { ModuleRevisionId mrid = getMapping(pack.trim()); if (mrid != null) { dependencies.add(mrid); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/ant/IvyInfo.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/IvyInfo.java b/src/java/org/apache/ivy/ant/IvyInfo.java index df5c880..e9b9cdb 100644 --- a/src/java/org/apache/ivy/ant/IvyInfo.java +++ b/src/java/org/apache/ivy/ant/IvyInfo.java @@ -161,8 +161,7 @@ public class IvyInfo extends IvyTask { Long.toString(md.getPublicationDate().getTime())); } - Map<String, String> extra = mrid.getExtraAttributes(); - for (Map.Entry<String, String> entry : extra.entrySet()) { + for (Map.Entry<String, String> entry : mrid.getExtraAttributes().entrySet()) { getProject().setProperty(property + ".extra." + entry.getKey(), entry.getValue()); } @@ -195,8 +194,7 @@ public class IvyInfo extends IvyTask { getProject().setProperty(property + ".artifact." + id + ".conf", mergeConfs(artifact.getConfigurations())); - Map<String, String> artiExtra = artifact.getExtraAttributes(); - for (Map.Entry<String, String> entry : artiExtra.entrySet()) { + for (Map.Entry<String, String> entry : artifact.getExtraAttributes().entrySet()) { getProject().setProperty(property + ".artifact." + id + ".extra." + entry.getKey(), entry.getValue()); } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/ant/IvyResolve.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/IvyResolve.java b/src/java/org/apache/ivy/ant/IvyResolve.java index 92513d8..a611ac8 100644 --- a/src/java/org/apache/ivy/ant/IvyResolve.java +++ b/src/java/org/apache/ivy/ant/IvyResolve.java @@ -350,8 +350,9 @@ public class IvyResolve extends IvyTask { settings.setVariable("ivy.module", mdName); getProject().setProperty("ivy.revision", mdRev); settings.setVariable("ivy.revision", mdRev); - for (int i = 0; i < md.getInheritedDescriptors().length; i++) { - ExtendsDescriptor parent = md.getInheritedDescriptors()[i]; + List<ExtendsDescriptor> parents = Arrays.asList(md.getInheritedDescriptors()); + for (ExtendsDescriptor parent : parents) { + int i = parents.indexOf(parent); String parentOrg = parent.getResolvedParentRevisionId().getOrganisation(); String parentModule = parent.getResolvedParentRevisionId().getName(); String parentRevision = parent.getResolvedParentRevisionId().getRevision(); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/core/IvyPatternHelper.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/core/IvyPatternHelper.java b/src/java/org/apache/ivy/core/IvyPatternHelper.java index 70bebcd..613d7ac 100644 --- a/src/java/org/apache/ivy/core/IvyPatternHelper.java +++ b/src/java/org/apache/ivy/core/IvyPatternHelper.java @@ -232,8 +232,6 @@ public final class IvyPatternHelper { StringBuilder buffer = new StringBuilder(); - char[] chars = pattern.toCharArray(); - StringBuffer optionalPart = null; StringBuffer tokenBuffer = null; boolean insideOptionalPart = false; @@ -241,8 +239,9 @@ public final class IvyPatternHelper { boolean tokenSeen = false; boolean tokenHadValue = false; - for (int i = 0; i < chars.length; i++) { - switch (chars[i]) { + for (char ch : pattern.toCharArray()) { + int i = pattern.indexOf(ch); + switch (ch) { case '(': if (insideOptionalPart) { throw new IllegalArgumentException( @@ -308,13 +307,12 @@ public final class IvyPatternHelper { default: if (insideToken) { - tokenBuffer.append(chars[i]); + tokenBuffer.append(ch); } else if (insideOptionalPart) { - optionalPart.append(chars[i]); + optionalPart.append(ch); } else { - buffer.append(chars[i]); + buffer.append(ch); } - break; } } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/core/event/IvyEventFilter.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/core/event/IvyEventFilter.java b/src/java/org/apache/ivy/core/event/IvyEventFilter.java index 2958513..629360d 100644 --- a/src/java/org/apache/ivy/core/event/IvyEventFilter.java +++ b/src/java/org/apache/ivy/core/event/IvyEventFilter.java @@ -26,6 +26,9 @@ import org.apache.ivy.util.filter.NoFilter; import org.apache.ivy.util.filter.NotFilter; import org.apache.ivy.util.filter.OrFilter; +import java.util.ArrayList; +import java.util.List; + /** * A filter implementation filtering {@link IvyEvent} based upon an event name and a filter * expression. The name will be matched against the event name using the {@link PatternMatcher} used @@ -119,9 +122,9 @@ public class IvyEventFilter implements Filter<IvyEvent> { } final String attname = filterExpression.substring(0, index).trim(); String[] values = filterExpression.substring(index + 1).trim().split(","); - final Matcher[] matchers = new Matcher[values.length]; - for (int i = 0; i < values.length; i++) { - matchers[i] = matcher.getMatcher(values[i].trim()); + final List<Matcher> matchers = new ArrayList<>(values.length); + for (String value : values) { + matchers.add(matcher.getMatcher(value.trim())); } return new Filter<IvyEvent>() { public boolean accept(IvyEvent e) { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/core/install/InstallEngine.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/core/install/InstallEngine.java b/src/java/org/apache/ivy/core/install/InstallEngine.java index db9a4cb..0ec0d65 100644 --- a/src/java/org/apache/ivy/core/install/InstallEngine.java +++ b/src/java/org/apache/ivy/core/install/InstallEngine.java @@ -102,9 +102,7 @@ public class InstallEngine { dd.addDependencyConfiguration("default", depConf); md.addDependency(dd); } else { - ModuleRevisionId[] mrids = searchEngine.listModules(fromResolver, mrid, matcher); - - for (ModuleRevisionId imrid : mrids) { + for (ModuleRevisionId imrid : searchEngine.listModules(fromResolver, mrid, matcher)) { Message.info("\tfound " + imrid + " to install: adding to the list"); DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, imrid, false, false, options.isTransitive()); @@ -139,8 +137,7 @@ public class InstallEngine { toResolver.beginPublishTransaction(depMrid, options.isOverwrite()); // publish artifacts - ArtifactDownloadReport[] artifacts = report.getArtifactsReports(depMrid); - for (ArtifactDownloadReport artifact : artifacts) { + for (ArtifactDownloadReport artifact : report.getArtifactsReports(depMrid)) { if (artifact.getLocalFile() != null) { toResolver.publish(artifact.getArtifact(), artifact.getLocalFile(), options.isOverwrite()); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java b/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java index 2d2b97b..2a4628c 100644 --- a/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java +++ b/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java @@ -53,6 +53,8 @@ import org.apache.ivy.plugins.repository.Resource; import org.apache.ivy.plugins.version.VersionMatcher; import org.apache.ivy.util.Message; +import static org.apache.ivy.core.module.descriptor.Configuration.findConfigurationExtending; + /** * */ @@ -507,14 +509,12 @@ public class DefaultModuleDescriptor implements ModuleDescriptor { } private Collection<Artifact> getArtifactsIncludingExtending(String conf) { - Collection<Configuration> extendingConfs = Configuration.findConfigurationExtending(conf, - getConfigurations()); Set<Artifact> artifacts = new LinkedHashSet<>(); Collection<Artifact> arts = artifactsByConf.get(conf); if (arts != null) { artifacts.addAll(arts); } - for (Configuration extendingConf : extendingConfs) { + for (Configuration extendingConf : findConfigurationExtending(conf, getConfigurations())) { arts = artifactsByConf.get(extendingConf.getName()); if (arts != null) { artifacts.addAll(arts); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/core/module/id/ModuleRules.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/core/module/id/ModuleRules.java b/src/java/org/apache/ivy/core/module/id/ModuleRules.java index 19b3d67..fe6851c 100644 --- a/src/java/org/apache/ivy/core/module/id/ModuleRules.java +++ b/src/java/org/apache/ivy/core/module/id/ModuleRules.java @@ -172,8 +172,7 @@ public class ModuleRules<T> { } private T getRule(Map<String, String> moduleAttributes, Filter<T> filter) { - List<MapMatcher> matchers = matcherLookup.get(moduleAttributes); - for (MapMatcher midm : matchers) { + for (MapMatcher midm : matcherLookup.get(moduleAttributes)) { T rule = rules.get(midm); if (filter.accept(rule)) { return rule; @@ -203,9 +202,8 @@ public class ModuleRules<T> { } private List<T> getRules(Map<String, String> moduleAttributes, Filter<T> filter) { - List<MapMatcher> matchers = matcherLookup.get(moduleAttributes); List<T> matchingRules = new ArrayList<>(); - for (MapMatcher midm : matchers) { + for (MapMatcher midm : matcherLookup.get(moduleAttributes)) { T rule = rules.get(midm); if (filter.accept(rule)) { matchingRules.add(rule); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/core/publish/PublishEngine.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/core/publish/PublishEngine.java b/src/java/org/apache/ivy/core/publish/PublishEngine.java index 9730957..2a801b6 100644 --- a/src/java/org/apache/ivy/core/publish/PublishEngine.java +++ b/src/java/org/apache/ivy/core/publish/PublishEngine.java @@ -47,10 +47,11 @@ import org.apache.ivy.plugins.parser.xml.UpdateOptions; import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser; import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorUpdater; import org.apache.ivy.plugins.resolver.DependencyResolver; -import org.apache.ivy.util.ConfigurationUtils; import org.apache.ivy.util.Message; import org.xml.sax.SAXException; +import static org.apache.ivy.util.ConfigurationUtils.replaceWildcards; + public class PublishEngine { private PublishEngineSettings settings; @@ -117,7 +118,7 @@ public class PublishEngine { File tmp = File.createTempFile("ivy", ".xml"); tmp.deleteOnExit(); - String[] confs = ConfigurationUtils.replaceWildcards(options.getConfs(), md); + String[] confs = replaceWildcards(options.getConfs(), md); Set<String> confsToRemove = new HashSet<>(Arrays.asList(md .getConfigurationsNames())); confsToRemove.removeAll(Arrays.asList(confs)); @@ -128,14 +129,12 @@ public class PublishEngine { tmp, new UpdateOptions() .setSettings(settings) - .setStatus( - options.getStatus() == null ? md.getStatus() : options - .getStatus()) + .setStatus(options.getStatus() == null ? md.getStatus() + : options.getStatus()) .setRevision(options.getPubrevision()) .setBranch(options.getPubBranch()) - .setPubdate( - options.getPubdate() == null ? new Date() : options - .getPubdate()) + .setPubdate(options.getPubdate() == null ? new Date() + : options.getPubdate()) .setMerge(options.isMerge()) .setMergedDescriptor(md) .setConfsToExclude( @@ -185,11 +184,9 @@ public class PublishEngine { DependencyResolver resolver, PublishOptions options) throws IOException { Collection<Artifact> missing = new ArrayList<>(); Set<Artifact> artifactsSet = new LinkedHashSet<>(); - String[] confs = ConfigurationUtils.replaceWildcards(options.getConfs(), md); - for (String conf : confs) { - Artifact[] artifacts = md.getArtifacts(conf); - artifactsSet.addAll(Arrays.asList(artifacts)); + for (String conf : replaceWildcards(options.getConfs(), md)) { + artifactsSet.addAll(Arrays.asList(md.getArtifacts(conf))); } Artifact[] extraArtifacts = options.getExtraArtifacts(); if (extraArtifacts != null) { @@ -214,7 +211,8 @@ public class PublishEngine { StringBuilder sb = new StringBuilder(); sb.append("missing artifact ").append(artifact).append(":\n"); for (String pattern : srcArtifactPattern) { - sb.append("\t").append(settings.resolveFile(IvyPatternHelper.substitute(pattern, artifact))).append(" file does not exist\n"); + sb.append("\t").append(settings.resolveFile(IvyPatternHelper.substitute(pattern, + artifact))).append(" file does not exist\n"); } if (options.isWarnOnMissing() || options.isHaltOnMissing()) { Message.warn(sb.toString()); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java b/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java index c8e2854..55f678d 100644 --- a/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java +++ b/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java @@ -149,8 +149,7 @@ public class ConfigurationResolveReport { dependencies.put(node.getId(), node); dependencies.put(node.getResolvedId(), node); List<ArtifactDownloadReport> adrs = new ArrayList<>(); - Artifact[] artifacts = node.getArtifacts(conf); - for (Artifact artifact : artifacts) { + for (Artifact artifact : node.getArtifacts(conf)) { ArtifactDownloadReport artifactReport = report.getArtifactReport(artifact); if (artifactReport != null) { adrs.add(artifactReport); @@ -199,8 +198,7 @@ public class ConfigurationResolveReport { private Set<ModuleRevisionId> getEvictedMrids() { Set<ModuleRevisionId> evicted = new LinkedHashSet<>(); - IvyNode[] evictedNodes = getEvictedNodes(); - for (IvyNode node : evictedNodes) { + for (IvyNode node : getEvictedNodes()) { evicted.add(node.getId()); } return evicted; http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java b/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java index e3d16a7..e5d44e0 100644 --- a/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java +++ b/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java @@ -145,9 +145,8 @@ public class RetrieveEngine { Message.verbose("\tno local file available for " + artifact + ": skipping"); continue; } - Set<String> paths = artifactAndPaths.getValue(); Message.verbose("\tretrieving " + archive); - for (String path : paths) { + for (String path : artifactAndPaths.getValue()) { IvyContext.getContext().checkInterrupted(); File destFile = settings.resolveFile(path); if (!settings.isCheckUpToDate() || !upToDate(archive, destFile, options)) { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/core/settings/IvySettings.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/core/settings/IvySettings.java b/src/java/org/apache/ivy/core/settings/IvySettings.java index 8e9af4b..5eb0b3bc 100644 --- a/src/java/org/apache/ivy/core/settings/IvySettings.java +++ b/src/java/org/apache/ivy/core/settings/IvySettings.java @@ -371,8 +371,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P public synchronized void typeDefs(Properties p, boolean silentFail) { for (Entry<Object, Object> entry : p.entrySet()) { - String name = entry.getKey().toString(); - typeDef(name, entry.getValue().toString(), silentFail); + typeDef(entry.getKey().toString(), entry.getValue().toString(), silentFail); } } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java b/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java index e749337..a8ca618 100644 --- a/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java +++ b/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java @@ -139,9 +139,8 @@ public class XmlSettingsParser extends DefaultHandler { } }); // put every type definition from ivy to configurator - Map<String, Class<?>> typeDefs = ivy.getTypeDefs(); - for (String name : typeDefs.keySet()) { - configurator.typeDef(name, typeDefs.get(name)); + for (Map.Entry<String, Class<?>> entry : ivy.getTypeDefs().entrySet()) { + configurator.typeDef(entry.getKey(), entry.getValue()); } doParse(settings); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java b/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java index 79c2ad9..41bfa0f 100644 --- a/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java +++ b/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java @@ -160,8 +160,7 @@ public class BundleInfoAdapter { PatternMatcher.ANY_EXPRESSION); DefaultExcludeRule rule = new DefaultExcludeRule(id, ExactOrRegexpPatternMatcher.INSTANCE, null); - String[] confs = md.getConfigurationsNames(); - for (String conf : confs) { + for (String conf : md.getConfigurationsNames()) { rule.addConfiguration(conf); } md.addExcludeRule(rule); @@ -277,9 +276,7 @@ public class BundleInfoAdapter { org = path.substring(1, i); name = path.substring(i + 1); - String query = uri.getQuery(); - String[] parameters = query.split("&"); - for (String parameter : parameters) { + for (String parameter : uri.getQuery().split("&")) { if (parameter.length() == 0) { continue; } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/osgi/core/ManifestParser.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/osgi/core/ManifestParser.java b/src/java/org/apache/ivy/osgi/core/ManifestParser.java index 5ccf3d7..c07596f 100644 --- a/src/java/org/apache/ivy/osgi/core/ManifestParser.java +++ b/src/java/org/apache/ivy/osgi/core/ManifestParser.java @@ -273,8 +273,7 @@ public class ManifestParser { */ public static String formatLines(String manifest) { StringBuilder buffer = new StringBuilder(manifest.length()); - String[] lines = manifest.split("\n"); - for (String line : lines) { + for (String line : manifest.split("\n")) { if (line.length() <= 72) { buffer.append(line); buffer.append('\n'); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java b/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java index df77956..93784af 100644 --- a/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java +++ b/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java @@ -84,8 +84,7 @@ public class P2Descriptor extends EditableRepoDescriptor { return; } for (String bundleId : bundleIds) { - Set<ModuleDescriptorWrapper> modules = findModules(BundleInfo.BUNDLE_TYPE, bundleId); - for (ModuleDescriptorWrapper mdw : modules) { + for (ModuleDescriptorWrapper mdw : findModules(BundleInfo.BUNDLE_TYPE, bundleId)) { String symbolicName = mdw.getBundleInfo().getSymbolicName(); Map<Version, BundleInfo> byVersion = sourceTargetBundles.get(symbolicName); if (byVersion == null) { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java b/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java index f469264..c5f284b 100644 --- a/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java +++ b/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java @@ -178,17 +178,16 @@ public abstract class AbstractOSGiResolver extends BasicResolver { public ResolvedResource[] findCapability(DependencyDescriptor dd, ResolveData data, Collection<ModuleDescriptor> mds) { - ResolvedResource[] ret = new ResolvedResource[mds.size()]; - int i = 0; + List<ResolvedResource> ret = new ArrayList<>(mds.size()); for (ModuleDescriptor md : mds) { IvyNode node = data.getNode(md.getModuleRevisionId()); if (node != null && node.getDescriptor() != null) { // already resolved import, no need to go further return new ResolvedResource[] {buildResolvedCapabilityMd(dd, node.getDescriptor())}; } - ret[i++] = buildResolvedCapabilityMd(dd, md); + ret.add(buildResolvedCapabilityMd(dd, md)); } - return ret; + return ret.toArray(new ResolvedResource[mds.size()]); } private MDResolvedResource buildResolvedCapabilityMd(DependencyDescriptor dd, http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/osgi/repo/ArtifactReportManifestIterable.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/osgi/repo/ArtifactReportManifestIterable.java b/src/java/org/apache/ivy/osgi/repo/ArtifactReportManifestIterable.java index 920f42f..9140855 100644 --- a/src/java/org/apache/ivy/osgi/repo/ArtifactReportManifestIterable.java +++ b/src/java/org/apache/ivy/osgi/repo/ArtifactReportManifestIterable.java @@ -72,10 +72,9 @@ public class ArtifactReportManifestIterable implements Iterable<ManifestAndLocat public boolean hasNext() { while (next == null && it.hasNext()) { ModuleRevisionId mrid = it.next(); - List<ArtifactDownloadReport> reports = artifactReports.get(mrid); ArtifactDownloadReport jar = null; ArtifactDownloadReport source = null; - for (ArtifactDownloadReport report : reports) { + for (ArtifactDownloadReport report : artifactReports.get(mrid)) { if (sourceTypes != null && sourceTypes.contains(report.getArtifact().getType())) { source = report; } else { @@ -124,9 +123,7 @@ public class ArtifactReportManifestIterable implements Iterable<ManifestAndLocat } else { artifact = jar.getLocalFile(); } - JarInputStream in = null; - try { - in = new JarInputStream(new FileInputStream(artifact)); + try (JarInputStream in = new JarInputStream(new FileInputStream(artifact))) { Manifest manifest = in.getManifest(); if (manifest != null) { next = new ManifestAndLocation(manifest, artifact.toURI(), sourceURI); @@ -137,14 +134,6 @@ public class ArtifactReportManifestIterable implements Iterable<ManifestAndLocat Message.debug("Jar file just removed: " + artifact, e); } catch (IOException e) { Message.warn("Unreadable jar: " + artifact, e); - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException e) { - // Don't care - } - } } } } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java b/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java index f0676d6..48821af 100644 --- a/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java +++ b/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java @@ -85,14 +85,12 @@ public class LatestCompatibleConflictManager extends LatestConflictManager { if (versionMatcher.isDynamic(mrid)) { while (iter.hasNext()) { IvyNode other = iter.next(); - if (versionMatcher.isDynamic(other.getResolvedId())) { + if (versionMatcher.isDynamic(other.getResolvedId()) + || !versionMatcher.accept(mrid, other.getResolvedId()) + && !handleIncompatibleConflict(parent, conflicts, node, other)) { // two dynamic versions in conflict, not enough information yet + // or incompatibility found return null; - } else if (!versionMatcher.accept(mrid, other.getResolvedId())) { - // incompatibility found - if (!handleIncompatibleConflict(parent, conflicts, node, other)) { - return null; - } } } // no incompatibility nor dynamic version found, let's return the latest static version @@ -110,11 +108,10 @@ public class LatestCompatibleConflictManager extends LatestConflictManager { // the first node is a static revision, let's see if all other versions match while (iter.hasNext()) { IvyNode other = iter.next(); - if (!versionMatcher.accept(other.getResolvedId(), mrid)) { + if (!versionMatcher.accept(other.getResolvedId(), mrid) + && !handleIncompatibleConflict(parent, conflicts, node, other)) { // incompatibility found - if (!handleIncompatibleConflict(parent, conflicts, node, other)) { - return null; - } + return null; } } // no incompatibility found, let's return this static version @@ -258,8 +255,7 @@ public class LatestCompatibleConflictManager extends LatestConflictManager { Collection<IvyNodeBlacklist> blacklisted = new ArrayList<>(); IvyNode node = callerStack.peek(); String rootModuleConf = conflictParent.getData().getReport().getConfiguration(); - Caller[] callers = node.getCallers(rootModuleConf); - for (Caller caller : callers) { + for (Caller caller : node.getCallers(rootModuleConf)) { IvyNode callerNode = node.findNode(caller.getModuleRevisionId()); if (callerNode.isBlacklisted(rootModuleConf)) { continue; http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/latest/WorkspaceLatestStrategy.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/plugins/latest/WorkspaceLatestStrategy.java b/src/java/org/apache/ivy/plugins/latest/WorkspaceLatestStrategy.java index 61ef1f7..d22b9ef 100644 --- a/src/java/org/apache/ivy/plugins/latest/WorkspaceLatestStrategy.java +++ b/src/java/org/apache/ivy/plugins/latest/WorkspaceLatestStrategy.java @@ -35,12 +35,10 @@ public class WorkspaceLatestStrategy extends AbstractLatestStrategy { } public List<ArtifactInfo> sort(ArtifactInfo[] infos) { - List<ArtifactInfo> sorted = delegate.sort(infos); - List<ArtifactInfo> head = new ArrayList<>(); List<ArtifactInfo> tail = new ArrayList<>(); - for (ArtifactInfo ai : sorted) { + for (ArtifactInfo ai : delegate.sort(infos)) { String rev = ai.getRevision(); boolean latestRev = rev.startsWith("latest") || rev.startsWith("working"); if (latestRev) { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/matcher/GlobPatternMatcher.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/plugins/matcher/GlobPatternMatcher.java b/src/java/org/apache/ivy/plugins/matcher/GlobPatternMatcher.java index b49cd20..405f877 100644 --- a/src/java/org/apache/ivy/plugins/matcher/GlobPatternMatcher.java +++ b/src/java/org/apache/ivy/plugins/matcher/GlobPatternMatcher.java @@ -90,8 +90,7 @@ public/* @Immutable */final class GlobPatternMatcher extends AbstractPatternMatc private Boolean calculateExact() { Boolean result = Boolean.TRUE; - char[] expressionChars = expression.toCharArray(); - for (char ch : expressionChars) { + for (char ch : expression.toCharArray()) { if (ch == '*' || ch == '?' || ch == '[' || ch == ']') { result = Boolean.FALSE; break; http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/matcher/RegexpPatternMatcher.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/plugins/matcher/RegexpPatternMatcher.java b/src/java/org/apache/ivy/plugins/matcher/RegexpPatternMatcher.java index 0e1df11..b80b358 100644 --- a/src/java/org/apache/ivy/plugins/matcher/RegexpPatternMatcher.java +++ b/src/java/org/apache/ivy/plugins/matcher/RegexpPatternMatcher.java @@ -75,8 +75,7 @@ public final/* @Immutable */class RegexpPatternMatcher extends AbstractPatternMa private Boolean calculateExact() { Boolean result = Boolean.TRUE; - char[] expressionChars = expression.toCharArray(); - for (char ch : expressionChars) { + for (char ch : expression.toCharArray()) { if (!Character.isLetterOrDigit(ch) && !Character.isWhitespace(ch) && ('-' != ch) && ('_' != ch)) { result = Boolean.FALSE; http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/parser/AbstractModuleDescriptorParser.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/plugins/parser/AbstractModuleDescriptorParser.java b/src/java/org/apache/ivy/plugins/parser/AbstractModuleDescriptorParser.java index 40dd925..c0c85d0 100644 --- a/src/java/org/apache/ivy/plugins/parser/AbstractModuleDescriptorParser.java +++ b/src/java/org/apache/ivy/plugins/parser/AbstractModuleDescriptorParser.java @@ -137,45 +137,46 @@ public abstract class AbstractModuleDescriptorParser implements ModuleDescriptor replaceConfigurationWildcards(md); for (String conf : confs) { String[] ops = conf.split("->"); - if (ops.length == 1) { - String[] modConfs = ops[0].split(","); - if (!useDefaultMappingToGuessRightOperand) { - for (String modConf : modConfs) { - dd.addDependencyConfiguration(modConf.trim(), modConf.trim()); - } - } else { - for (String modConf : modConfs) { - String[] depConfs = getDefaultConfMappingDescriptor() - .getDependencyConfigurations(modConf); - if (depConfs.length > 0) { - for (String depConf : depConfs) { - String mappedDependency = evaluateConditions ? evaluateCondition( - depConf.trim(), dd) : depConf.trim(); - if (mappedDependency != null) { - dd.addDependencyConfiguration(modConf.trim(), - mappedDependency); + switch (ops.length) { + case 1: + for (String modConf : ops[0].split(",")) { + if (useDefaultMappingToGuessRightOperand) { + String[] depConfs = getDefaultConfMappingDescriptor() + .getDependencyConfigurations(modConf); + if (depConfs.length > 0) { + for (String depConf : depConfs) { + String mappedDependency = evaluateConditions ? evaluateCondition( + depConf.trim(), dd) : depConf.trim(); + if (mappedDependency != null) { + dd.addDependencyConfiguration(modConf.trim(), + mappedDependency); + } } + } else { + // no default mapping found for this configuration, map + // configuration to itself + dd.addDependencyConfiguration(modConf.trim(), + modConf.trim()); } } else { - // no default mapping found for this configuration, map - // configuration to itself - dd.addDependencyConfiguration(modConf.trim(), - modConf.trim()); + dd.addDependencyConfiguration(modConf.trim(), modConf.trim()); } } - } - } else if (ops.length == 2) { - for (String modConf : ops[0].split(",")) { - for (String depConf : ops[1].split(",")) { - String mappedDependency = evaluateConditions ? evaluateCondition( - depConf.trim(), dd) : depConf.trim(); - if (mappedDependency != null) { - dd.addDependencyConfiguration(modConf.trim(), mappedDependency); + break; + case 2: + for (String modConf : ops[0].split(",")) { + for (String depConf : ops[1].split(",")) { + String mappedDependency = evaluateConditions ? evaluateCondition( + depConf.trim(), dd) : depConf.trim(); + if (mappedDependency != null) { + dd.addDependencyConfiguration(modConf.trim(), mappedDependency); + } } } - } - } else { - addError("invalid conf " + conf + " for " + dd); + break; + default: + addError("invalid conf " + conf + " for " + dd); + break; } } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java index e1d15dc..bc93a23 100644 --- a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java +++ b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java @@ -341,8 +341,7 @@ public class PomModuleDescriptorBuilder { if ("*".equals(excludedModule.getOrganisation()) && "*".equals(excludedModule.getName())) { continue; } - String[] confs = dd.getModuleConfigurations(); - for (String conf : confs) { + for (String conf : dd.getModuleConfigurations()) { dd.addExcludeRule(conf, new DefaultExcludeRule(new ArtifactId(excludedModule, PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION), ExactPatternMatcher.INSTANCE, null)); @@ -559,7 +558,7 @@ public class PomModuleDescriptorBuilder { } else { for (ExtraInfoHolder extraInfoHolder : md.getExtraInfos()) { String key = extraInfoHolder.getName(); - if ((key).startsWith(DEPENDENCY_MANAGEMENT)) { + if (key.startsWith(DEPENDENCY_MANAGEMENT)) { String[] parts = key.split(EXTRA_INFO_DELIMITER); if (parts.length != DEPENDENCY_MANAGEMENT_KEY_PARTS_COUNT) { Message.warn("what seem to be a dependency management extra info " @@ -645,8 +644,8 @@ public class PomModuleDescriptorBuilder { Map<String, String> r = new HashMap<>(); for (Map.Entry<String, String> extraInfoEntry : extraInfo.entrySet()) { if (extraInfoEntry.getKey().startsWith(PROPERTIES)) { - String prop = extraInfoEntry.getKey().substring( - PROPERTIES.length() + EXTRA_INFO_DELIMITER.length()); + String prop = extraInfoEntry.getKey().substring(PROPERTIES.length() + + EXTRA_INFO_DELIMITER.length()); r.put(prop, extraInfoEntry.getValue()); } } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java index ced6e55..92d81bb 100644 --- a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java +++ b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java @@ -23,7 +23,6 @@ import java.io.InputStream; import java.net.URL; import java.text.ParseException; import java.util.Date; -import java.util.List; import java.util.Map; import org.apache.ivy.core.IvyContext; @@ -56,6 +55,11 @@ import org.apache.ivy.plugins.resolver.DependencyResolver; import org.apache.ivy.util.Message; import org.xml.sax.SAXException; +import static org.apache.ivy.plugins.parser.m2.PomModuleDescriptorBuilder.MAVEN2_CONFIGURATIONS; +import static org.apache.ivy.plugins.parser.m2.PomModuleDescriptorBuilder.extractPomProperties; +import static org.apache.ivy.plugins.parser.m2.PomModuleDescriptorBuilder.getDependencyManagements; +import static org.apache.ivy.plugins.parser.m2.PomModuleDescriptorBuilder.getPlugins; + /** * A parser for Maven 2 POM. * <p> @@ -125,8 +129,7 @@ public final class PomModuleDescriptorParser implements ModuleDescriptorParser { domReader.setProperty("project.parent.version", domReader.getParentVersion()); domReader.setProperty("project.parent.groupId", domReader.getParentGroupId()); - Map<String, String> pomProperties = domReader.getPomProperties(); - for (Map.Entry<String, String> prop : pomProperties.entrySet()) { + for (Map.Entry<String, String> prop : domReader.getPomProperties().entrySet()) { domReader.setProperty(prop.getKey(), prop.getValue()); mdBuilder.addProperty(prop.getKey(), prop.getValue()); } @@ -145,9 +148,8 @@ public final class PomModuleDescriptorParser implements ModuleDescriptorParser { } parentDescr = parentModule.getDescriptor(); if (parentDescr != null) { - Map<String, String> parentPomProps = PomModuleDescriptorBuilder - .extractPomProperties(parentDescr.getExtraInfos()); - for (Map.Entry<String, String> prop : parentPomProps.entrySet()) { + for (Map.Entry<String, String> prop : + extractPomProperties(parentDescr.getExtraInfos()).entrySet()) { domReader.setProperty(prop.getKey(), prop.getValue()); } } @@ -199,8 +201,7 @@ public final class PomModuleDescriptorParser implements ModuleDescriptorParser { DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor( mdBuilder.getModuleDescriptor(), relocation, true, false, true); /* Map all public dependencies */ - Configuration[] m2Confs = PomModuleDescriptorBuilder.MAVEN2_CONFIGURATIONS; - for (Configuration m2Conf : m2Confs) { + for (Configuration m2Conf : MAVEN2_CONFIGURATIONS) { if (Visibility.PUBLIC.equals(m2Conf.getVisibility())) { dd.addDependencyConfiguration(m2Conf.getName(), m2Conf.getName()); } @@ -222,9 +223,7 @@ public final class PomModuleDescriptorParser implements ModuleDescriptorParser { mdBuilder.addExtraInfos(parentDescr.getExtraInfos()); // add dependency management info from parent - List<PomDependencyMgt> depMgt = PomModuleDescriptorBuilder - .getDependencyManagements(parentDescr); - for (PomDependencyMgt dep : depMgt) { + for (PomDependencyMgt dep : getDependencyManagements(parentDescr)) { if (dep instanceof PomDependencyMgtElement) { dep = domReader.new PomDependencyMgtElement( (PomDependencyMgtElement) dep); @@ -233,8 +232,7 @@ public final class PomModuleDescriptorParser implements ModuleDescriptorParser { } // add plugins from parent - for (PomDependencyMgt pomDependencyMgt : PomModuleDescriptorBuilder - .getPlugins(parentDescr)) { + for (PomDependencyMgt pomDependencyMgt : getPlugins(parentDescr)) { mdBuilder.addPlugin(pomDependencyMgt); } } @@ -303,9 +301,7 @@ public final class PomModuleDescriptorParser implements ModuleDescriptorParser { ModuleDescriptor importDescr = importModule.getDescriptor(); // add dependency management info from imported module - List<PomDependencyMgt> depMgt = PomModuleDescriptorBuilder - .getDependencyManagements(importDescr); - for (PomDependencyMgt importedDepMgt : depMgt) { + for (PomDependencyMgt importedDepMgt : getDependencyManagements(importDescr)) { mdBuilder.addDependencyMgt(new DefaultPomDependencyMgt(importedDepMgt.getGroupId(), importedDepMgt.getArtifactId(), importedDepMgt.getVersion(), importedDepMgt.getScope(), importedDepMgt.getExcludedModules())); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java index f21bf96..515d099 100644 --- a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java +++ b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java @@ -191,8 +191,7 @@ public final class PomModuleDescriptorWriter { * Returns the first artifact with the correct name and without a classifier. */ private static Artifact findArtifact(ModuleDescriptor md, String artifactName) { - Artifact[] artifacts = md.getAllArtifacts(); - for (Artifact artifact : artifacts) { + for (Artifact artifact : md.getAllArtifacts()) { if (artifact.getName().equals(artifactName) && artifact.getAttribute("classifier") == null) { return artifact; @@ -346,8 +345,7 @@ public final class PomModuleDescriptorWriter { String[] confs = ConfigurationUtils.replaceWildcards(options.getConfs(), md); List<DependencyDescriptor> result = new ArrayList<>(); - DependencyDescriptor[] dds = md.getDependencies(); - for (DependencyDescriptor dd : dds) { + for (DependencyDescriptor dd : md.getDependencies()) { String[] depConfs = dd.getDependencyConfigurations(confs); if ((depConfs != null) && (depConfs.length > 0)) { result.add(dd); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java index 7d09011..cdfcb85 100644 --- a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java +++ b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java @@ -73,7 +73,7 @@ import org.xml.sax.helpers.DefaultHandler; public final class XmlModuleDescriptorUpdater { // CheckStyle:StaticVariableName| OFF // LINE_SEPARATOR is actually a constant, but we have to modify it for the tests - public static String LINE_SEPARATOR = System.getProperty("line.separator"); + public static String LINE_SEPARATOR = System.lineSeparator(); // CheckStyle:StaticVariableName| ON http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java index 2f98464..6f0f0ad 100644 --- a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java +++ b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java @@ -335,8 +335,7 @@ public final class XmlModuleDescriptorWriter { private static void printPublications(ModuleDescriptor md, PrintWriter out) { out.println("\t<publications>"); - Artifact[] artifacts = md.getAllArtifacts(); - for (Artifact artifact : artifacts) { + for (Artifact artifact : md.getAllArtifacts()) { out.print(String.format("\t\t<artifact name=\"%s\" type=\"%s\" ext=\"%s\" conf=\"%s\"", XMLHelper.escape(artifact.getName()), XMLHelper.escape(artifact.getType()), @@ -411,8 +410,7 @@ public final class XmlModuleDescriptorWriter { } if (requireInnerInfoElement(md)) { out.println("\t>"); - ExtendsDescriptor[] parents = md.getInheritedDescriptors(); - for (ExtendsDescriptor parent : parents) { + for (ExtendsDescriptor parent : md.getInheritedDescriptors()) { ModuleRevisionId mrid = parent.getParentRevisionId(); out.print(String.format("\t\t<extends organisation=\"%s\" module=\"%s\" revision=\"%s\"", XMLHelper.escape(mrid.getOrganisation()), http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/report/XmlReportParser.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/plugins/report/XmlReportParser.java b/src/java/org/apache/ivy/plugins/report/XmlReportParser.java index a914ad2..b6f87f7 100644 --- a/src/java/org/apache/ivy/plugins/report/XmlReportParser.java +++ b/src/java/org/apache/ivy/plugins/report/XmlReportParser.java @@ -71,132 +71,139 @@ public class XmlReportParser { public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - if ("module".equals(qName)) { - organisation = attributes.getValue("organisation"); - module = attributes.getValue("name"); - } else if ("revision".equals(qName)) { - revisionArtifacts = new ArrayList<>(); - branch = attributes.getValue("branch"); - revision = attributes.getValue("name"); - isDefault = Boolean.valueOf(attributes.getValue("default")); - // retrieve position from file. If no position is found, it may be an old - // report generated with a previous version, - // in which case, we put it at the last position - String pos = attributes.getValue("position"); - position = pos == null ? getMaxPos() + 1 : Integer.valueOf(pos); - if (attributes.getValue("error") != null) { - hasError = true; - skip = true; - } else if (attributes.getValue("evicted") != null) { - skip = true; - } else { - revisionsMap.put(position, revisionArtifacts); - mrid = ModuleRevisionId.newInstance(organisation, module, branch, revision, - ExtendableItemHelper.getExtraAttributes(attributes, "extra-")); - mrids.add(mrid); - if (isDefault) { - defaultMrids.add(mrid); + switch (qName) { + case "module": + organisation = attributes.getValue("organisation"); + module = attributes.getValue("name"); + break; + case "revision": + revisionArtifacts = new ArrayList<>(); + branch = attributes.getValue("branch"); + revision = attributes.getValue("name"); + isDefault = Boolean.valueOf(attributes.getValue("default")); + // retrieve position from file. If no position is found, it may be an old + // report generated with a previous version, + // in which case, we put it at the last position + String pos = attributes.getValue("position"); + position = pos == null ? getMaxPos() + 1 : Integer.valueOf(pos); + if (attributes.getValue("error") != null) { + hasError = true; + skip = true; + } else if (attributes.getValue("evicted") != null) { + skip = true; } else { - Artifact metadataArtifact = DefaultArtifact.newIvyArtifact(mrid, - pubdate); - MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport( - metadataArtifact); - metadataReports.put(mrid, madr); - realMrids.add(mrid); + revisionsMap.put(position, revisionArtifacts); + mrid = ModuleRevisionId.newInstance(organisation, module, branch, revision, + ExtendableItemHelper.getExtraAttributes(attributes, "extra-")); + mrids.add(mrid); + if (isDefault) { + defaultMrids.add(mrid); + } else { + Artifact metadataArtifact = DefaultArtifact.newIvyArtifact(mrid, + pubdate); + MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport( + metadataArtifact); + metadataReports.put(mrid, madr); + realMrids.add(mrid); + } + try { + String pubDateAttr = attributes.getValue("pubdate"); + if (pubDateAttr != null) { + pubdate = DateUtil.parse(pubDateAttr); + } + skip = false; + } catch (ParseException e) { + throw new IllegalArgumentException("invalid publication date for " + + organisation + " " + module + " " + revision + ": " + + attributes.getValue("pubdate")); + } } - try { - String pubDateAttr = attributes.getValue("pubdate"); - if (pubDateAttr != null) { - pubdate = DateUtil.parse(pubDateAttr); + break; + case "metadata-artifact": + if (skip) { + return; + } + MetadataArtifactDownloadReport madr = metadataReports.get(mrid); + if (madr != null) { + madr.setDownloadStatus(DownloadStatus.fromString(attributes + .getValue("status"))); + madr.setDownloadDetails(attributes.getValue("details")); + madr.setSize(Long.parseLong(attributes.getValue("size"))); + madr.setDownloadTimeMillis(Long.parseLong(attributes.getValue("time"))); + madr.setSearched(parseBoolean(attributes.getValue("searched"))); + if (attributes.getValue("location") != null) { + madr.setLocalFile(new File(attributes.getValue("location"))); + } + if (attributes.getValue("original-local-location") != null) { + madr.setOriginalLocalFile(new File(attributes + .getValue("original-local-location"))); + } + if (attributes.getValue("origin-location") != null) { + if (ArtifactOrigin.isUnknown(attributes.getValue("origin-location"))) { + madr.setArtifactOrigin(ArtifactOrigin.unknown(madr.getArtifact())); + } else { + madr.setArtifactOrigin(new ArtifactOrigin(madr.getArtifact(), + parseBoolean(attributes.getValue("origin-is-local")), + attributes.getValue("origin-location"))); + } } - skip = false; - } catch (ParseException e) { - throw new IllegalArgumentException("invalid publication date for " - + organisation + " " + module + " " + revision + ": " - + attributes.getValue("pubdate")); } - } - } else if ("metadata-artifact".equals(qName)) { - if (skip) { - return; - } - MetadataArtifactDownloadReport madr = metadataReports.get(mrid); - if (madr != null) { - madr.setDownloadStatus(DownloadStatus.fromString(attributes - .getValue("status"))); - madr.setDownloadDetails(attributes.getValue("details")); - madr.setSize(Long.parseLong(attributes.getValue("size"))); - madr.setDownloadTimeMillis(Long.parseLong(attributes.getValue("time"))); - madr.setSearched(parseBoolean(attributes.getValue("searched"))); + break; + case "artifact": + if (skip) { + return; + } + String status = attributes.getValue("status"); + String artifactName = attributes.getValue("name"); + String type = attributes.getValue("type"); + String ext = attributes.getValue("ext"); + Artifact artifact = new DefaultArtifact(mrid, pubdate, artifactName, type, ext, + ExtendableItemHelper.getExtraAttributes(attributes, "extra-")); + ArtifactDownloadReport aReport = new ArtifactDownloadReport(artifact); + aReport.setDownloadStatus(DownloadStatus.fromString(status)); + aReport.setDownloadDetails(attributes.getValue("details")); + aReport.setSize(Long.parseLong(attributes.getValue("size"))); + aReport.setDownloadTimeMillis(Long.parseLong(attributes.getValue("time"))); if (attributes.getValue("location") != null) { - madr.setLocalFile(new File(attributes.getValue("location"))); + aReport.setLocalFile(new File(attributes.getValue("location"))); } - if (attributes.getValue("original-local-location") != null) { - madr.setOriginalLocalFile(new File(attributes - .getValue("original-local-location"))); + if (attributes.getValue("unpackedFile") != null) { + aReport.setUnpackedLocalFile(new File(attributes.getValue("unpackedFile"))); } - if (attributes.getValue("origin-location") != null) { - if (ArtifactOrigin.isUnknown(attributes.getValue("origin-location"))) { - madr.setArtifactOrigin(ArtifactOrigin.unknown(madr.getArtifact())); - } else { - madr.setArtifactOrigin(new ArtifactOrigin(madr.getArtifact(), - parseBoolean(attributes.getValue("origin-is-local")), - attributes.getValue("origin-location"))); - } + revisionArtifacts.add(aReport); + break; + case "origin-location": + if (skip) { + return; } - } - } else if ("artifact".equals(qName)) { - if (skip) { - return; - } - String status = attributes.getValue("status"); - String artifactName = attributes.getValue("name"); - String type = attributes.getValue("type"); - String ext = attributes.getValue("ext"); - Artifact artifact = new DefaultArtifact(mrid, pubdate, artifactName, type, ext, - ExtendableItemHelper.getExtraAttributes(attributes, "extra-")); - ArtifactDownloadReport aReport = new ArtifactDownloadReport(artifact); - aReport.setDownloadStatus(DownloadStatus.fromString(status)); - aReport.setDownloadDetails(attributes.getValue("details")); - aReport.setSize(Long.parseLong(attributes.getValue("size"))); - aReport.setDownloadTimeMillis(Long.parseLong(attributes.getValue("time"))); - if (attributes.getValue("location") != null) { - aReport.setLocalFile(new File(attributes.getValue("location"))); - } - if (attributes.getValue("unpackedFile") != null) { - aReport.setUnpackedLocalFile(new File(attributes.getValue("unpackedFile"))); - } - revisionArtifacts.add(aReport); - } else if ("origin-location".equals(qName)) { - if (skip) { - return; - } - ArtifactDownloadReport aReport = revisionArtifacts - .get(revisionArtifacts.size() - 1); - - if (ArtifactOrigin.isUnknown(attributes.getValue("location"))) { - aReport.setArtifactOrigin(ArtifactOrigin.unknown(aReport.getArtifact())); - } else { - aReport.setArtifactOrigin(new ArtifactOrigin(aReport.getArtifact(), - parseBoolean(attributes.getValue("is-local")), attributes - .getValue("location"))); - } - } else if ("info".equals(qName)) { - String organisation = attributes.getValue("organisation"); - String name = attributes.getValue("module"); - String branch = attributes.getValue("branch"); - String revision = attributes.getValue("revision"); - Map<String, String> extraAttributes = new HashMap<>(); - for (int i = 0; i < attributes.getLength(); i++) { - String attName = attributes.getQName(i); - if (attName.startsWith("extra-")) { - String extraAttrName = attName.substring("extra-".length()); - String extraAttrValue = attributes.getValue(i); - extraAttributes.put(extraAttrName, extraAttrValue); + ArtifactDownloadReport adr = revisionArtifacts + .get(revisionArtifacts.size() - 1); + + if (ArtifactOrigin.isUnknown(attributes.getValue("location"))) { + adr.setArtifactOrigin(ArtifactOrigin.unknown(adr.getArtifact())); + } else { + adr.setArtifactOrigin(new ArtifactOrigin(adr.getArtifact(), + parseBoolean(attributes.getValue("is-local")), + attributes.getValue("location"))); } - } - mRevisionId = ModuleRevisionId.newInstance(organisation, name, branch, - revision, extraAttributes); + break; + case "info": + String organisation = attributes.getValue("organisation"); + String name = attributes.getValue("module"); + String branch = attributes.getValue("branch"); + String revision = attributes.getValue("revision"); + Map<String, String> extraAttributes = new HashMap<>(); + for (int i = 0; i < attributes.getLength(); i++) { + String attName = attributes.getQName(i); + if (attName.startsWith("extra-")) { + String extraAttrName = attName.substring("extra-".length()); + String extraAttrValue = attributes.getValue(i); + extraAttributes.put(extraAttrName, extraAttrValue); + } + } + mRevisionId = ModuleRevisionId.newInstance(organisation, name, branch, + revision, extraAttributes); + break; } } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/repository/vfs/VfsRepository.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/plugins/repository/vfs/VfsRepository.java b/src/java/org/apache/ivy/plugins/repository/vfs/VfsRepository.java index 4eacea6..5325078 100644 --- a/src/java/org/apache/ivy/plugins/repository/vfs/VfsRepository.java +++ b/src/java/org/apache/ivy/plugins/repository/vfs/VfsRepository.java @@ -178,10 +178,9 @@ public class VfsRepository extends AbstractRepository { Message.debug("FileType.FOLDER" + FileType.FOLDER); if ((resourceImpl != null) && resourceImpl.exists() && (resourceImpl.getType() == FileType.FOLDER)) { - FileObject[] children = resourceImpl.getChildren(); - for (int i = 0; i < children.length; i++) { - FileObject child = children[i]; - Message.debug("child " + i + child.getName().getURI()); + List<FileObject> children = Arrays.asList(resourceImpl.getChildren()); + for (FileObject child : children) { + Message.debug("child " + children.indexOf(child) + child.getName().getURI()); list.add(VfsResource.normalize(child.getName().getURI())); } } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/resolver/AbstractPatternsBasedResolver.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/plugins/resolver/AbstractPatternsBasedResolver.java b/src/java/org/apache/ivy/plugins/resolver/AbstractPatternsBasedResolver.java index 6872f30..68361f8 100644 --- a/src/java/org/apache/ivy/plugins/resolver/AbstractPatternsBasedResolver.java +++ b/src/java/org/apache/ivy/plugins/resolver/AbstractPatternsBasedResolver.java @@ -164,26 +164,24 @@ public abstract class AbstractPatternsBasedResolver extends BasicResolver { Set<Map<String, String>> result = new LinkedHashSet<>(); // use ivy patterns - List<String> ivyPatterns = getIvyPatterns(); Map<String, Object> subcriteria = new HashMap<>(criteria); subcriteria.put(IvyPatternHelper.TYPE_KEY, "ivy"); subcriteria.put(IvyPatternHelper.EXT_KEY, getModuleDescriptorExtension()); if (isM2compatible()) { convertM2CriteriaForResourceSearch(subcriteria); } - for (String ivyPattern : ivyPatterns) { + for (String ivyPattern : getIvyPatterns()) { result.addAll(resolveTokenValues(tokens, ivyPattern, subcriteria, false)); } if (isAllownomd()) { - List<String> artifactPatterns = getArtifactPatterns(); subcriteria = new HashMap<>(criteria); subcriteria.put(IvyPatternHelper.TYPE_KEY, "jar"); subcriteria.put(IvyPatternHelper.EXT_KEY, "jar"); if (isM2compatible()) { convertM2CriteriaForResourceSearch(subcriteria); } - for (String artifactPattern : artifactPatterns) { + for (String artifactPattern : getArtifactPatterns()) { result.addAll(resolveTokenValues(tokens, artifactPattern, subcriteria, true)); } } @@ -236,10 +234,10 @@ public abstract class AbstractPatternsBasedResolver extends BasicResolver { return result; } - List<String> vals = new ArrayList<>(Arrays.asList(values)); - filterNames(vals); + List<String> valueList = new ArrayList<>(Arrays.asList(values)); + filterNames(valueList); - for (String value : vals) { + for (String value : valueList) { if ((matcher != null) && !matcher.matches(value)) { continue; }
