You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ja...@apache.org on 2017/07/27 15:42:21 UTC
[1/2] ant-ivy git commit: refactor System.getProperty() and loops
Repository: ant-ivy
Updated Branches:
refs/heads/master 366fb741f -> 1a283ab1b
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/resolver/AbstractWorkspaceResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/AbstractWorkspaceResolver.java b/src/java/org/apache/ivy/plugins/resolver/AbstractWorkspaceResolver.java
index 91991f4..466784a 100644
--- a/src/java/org/apache/ivy/plugins/resolver/AbstractWorkspaceResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/AbstractWorkspaceResolver.java
@@ -196,10 +196,8 @@ public abstract class AbstractWorkspaceResolver extends AbstractResolver {
newMd.setResolvedPublicationDate(md.getResolvedPublicationDate());
newMd.setStatus(md.getStatus());
- List<Artifact> artifacts = createWorkspaceArtifacts(md);
-
Configuration[] allConfs = md.getConfigurations();
- for (Artifact af : artifacts) {
+ for (Artifact af : createWorkspaceArtifacts(md)) {
if (allConfs.length == 0) {
newMd.addArtifact(ModuleDescriptor.DEFAULT_CONFIGURATION, af);
} else {
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java b/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
index e759764..9eb4eb5 100644
--- a/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
@@ -917,12 +917,11 @@ public abstract class BasicResolver extends AbstractResolver {
public OrganisationEntry[] listOrganisations() {
Collection<String> names = findNames(Collections.<String, String> emptyMap(),
IvyPatternHelper.ORGANISATION_KEY);
- OrganisationEntry[] ret = new OrganisationEntry[names.size()];
- int i = 0;
+ List<OrganisationEntry> ret = new ArrayList<>(names.size());
for (String org : names) {
- ret[i++] = new OrganisationEntry(this, org);
+ ret.add(new OrganisationEntry(this, org));
}
- return ret;
+ return ret.toArray(new OrganisationEntry[names.size()]);
}
@Override
@@ -930,12 +929,11 @@ public abstract class BasicResolver extends AbstractResolver {
Map<String, String> tokenValues = new HashMap<>();
tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org.getOrganisation());
Collection<String> names = findNames(tokenValues, IvyPatternHelper.MODULE_KEY);
- ModuleEntry[] ret = new ModuleEntry[names.size()];
- int i = 0;
+ List<ModuleEntry> ret = new ArrayList<>(names.size());
for (String name : names) {
- ret[i++] = new ModuleEntry(org, name);
+ ret.add(new ModuleEntry(org, name));
}
- return ret;
+ return ret.toArray(new ModuleEntry[names.size()]);
}
@Override
@@ -944,12 +942,11 @@ public abstract class BasicResolver extends AbstractResolver {
tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, mod.getOrganisation());
tokenValues.put(IvyPatternHelper.MODULE_KEY, mod.getModule());
Collection<String> names = findNames(tokenValues, IvyPatternHelper.REVISION_KEY);
- RevisionEntry[] ret = new RevisionEntry[names.size()];
- int i = 0;
+ List<RevisionEntry> ret = new ArrayList<>(names.size());
for (String name : names) {
- ret[i++] = new RevisionEntry(mod, name);
+ ret.add(new RevisionEntry(mod, name));
}
- return ret;
+ return ret.toArray(new RevisionEntry[names.size()]);
}
protected abstract Collection<String> findNames(Map<String, String> tokenValues, String token);
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/resolver/CacheResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/CacheResolver.java b/src/java/org/apache/ivy/plugins/resolver/CacheResolver.java
index 337afb9..2102b90 100644
--- a/src/java/org/apache/ivy/plugins/resolver/CacheResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/CacheResolver.java
@@ -172,8 +172,7 @@ public class CacheResolver extends FileSystemResolver {
if (getIvyPatterns().isEmpty()) {
setIvyPatterns(new ArrayList<String>());
setArtifactPatterns(new ArrayList<String>());
- RepositoryCacheManager[] caches = getSettings().getRepositoryCacheManagers();
- for (RepositoryCacheManager cache : caches) {
+ for (RepositoryCacheManager cache : getSettings().getRepositoryCacheManagers()) {
if (cache instanceof DefaultRepositoryCacheManager) {
DefaultRepositoryCacheManager c = (DefaultRepositoryCacheManager) cache;
addIvyPattern(c.getBasedir().getAbsolutePath() + "/" + c.getIvyPattern());
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java b/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java
index 51a7d7f..bf527a0 100644
--- a/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java
@@ -254,12 +254,11 @@ public class IvyRepResolver extends URLResolver {
Map<String, String> tokenValues = new HashMap<>();
tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org.getOrganisation());
Collection<String> names = findIvyNames(tokenValues, IvyPatternHelper.MODULE_KEY);
- ModuleEntry[] ret = new ModuleEntry[names.size()];
- int i = 0;
+ List<ModuleEntry> ret = new ArrayList<>(names.size());
for (String name : names) {
- ret[i] = new ModuleEntry(org, name);
+ ret.add(new ModuleEntry(org, name));
}
- return ret;
+ return ret.toArray(new ModuleEntry[names.size()]);
}
@Override
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/plugins/trigger/LogTrigger.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/trigger/LogTrigger.java b/src/java/org/apache/ivy/plugins/trigger/LogTrigger.java
index b66f1a3..96c8924 100644
--- a/src/java/org/apache/ivy/plugins/trigger/LogTrigger.java
+++ b/src/java/org/apache/ivy/plugins/trigger/LogTrigger.java
@@ -37,7 +37,7 @@ import org.apache.ivy.util.Message;
* </p>
*/
public class LogTrigger extends AbstractTrigger {
- private static final String LINE_SEPARATOR = System.getProperty("line.separator");
+ private static final String LINE_SEPARATOR = System.lineSeparator();
private String message = "";
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/util/ChecksumHelper.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/util/ChecksumHelper.java b/src/java/org/apache/ivy/util/ChecksumHelper.java
index 6bc1369..a859fc62 100644
--- a/src/java/org/apache/ivy/util/ChecksumHelper.java
+++ b/src/java/org/apache/ivy/util/ChecksumHelper.java
@@ -95,8 +95,7 @@ public final class ChecksumHelper {
// https://repo1.maven.org/maven2/org/apache/pdfbox/fontbox/0.8.0-incubator/fontbox-0.8.0-incubator.jar.md5
if (expected.endsWith(":")) {
StringBuilder result = new StringBuilder();
- char[] chars = csFileContent.substring(spaceIndex + 1).toCharArray();
- for (char ch : chars) {
+ for (char ch : csFileContent.substring(spaceIndex + 1).toCharArray()) {
if (!Character.isWhitespace(ch)) {
result.append(ch);
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/util/ConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/util/ConfigurationUtils.java b/src/java/org/apache/ivy/util/ConfigurationUtils.java
index 4bbb17c..ccb50ba 100644
--- a/src/java/org/apache/ivy/util/ConfigurationUtils.java
+++ b/src/java/org/apache/ivy/util/ConfigurationUtils.java
@@ -66,15 +66,13 @@ public final class ConfigurationUtils {
if ("*".equals(conf)) {
result.addAll(Arrays.asList(md.getConfigurationsNames()));
} else if ("*(public)".equals(conf)) {
- Configuration[] all = md.getConfigurations();
- for (Configuration cf : all) {
+ for (Configuration cf : md.getConfigurations()) {
if (cf.getVisibility().equals(Visibility.PUBLIC)) {
result.add(cf.getName());
}
}
} else if ("*(private)".equals(conf)) {
- Configuration[] all = md.getConfigurations();
- for (Configuration cf : all) {
+ for (Configuration cf : md.getConfigurations()) {
if (cf.getVisibility().equals(Visibility.PRIVATE)) {
result.add(cf.getName());
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/util/Configurator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/util/Configurator.java b/src/java/org/apache/ivy/util/Configurator.java
index deac6c8..c6b4082 100644
--- a/src/java/org/apache/ivy/util/Configurator.java
+++ b/src/java/org/apache/ivy/util/Configurator.java
@@ -311,8 +311,7 @@ public class Configurator {
public ObjectDescriptor(Object object, String objName) {
obj = object;
this.objName = objName;
- Method[] methods = object.getClass().getMethods();
- for (Method m : methods) {
+ for (Method m : object.getClass().getMethods()) {
if (m.getName().startsWith("create") && m.getParameterTypes().length == 0
&& !Void.TYPE.equals(m.getReturnType())) {
String name = StringUtils
@@ -636,8 +635,7 @@ public class Configurator {
convertedValue = fileResolver.resolveFile(value, od.getObjectName() + "."
+ attributeName);
} else {
- convertedValue = paramClass.getConstructor(new Class[] {String.class}).newInstance(
- value);
+ convertedValue = paramClass.getConstructor(String.class).newInstance(value);
}
} catch (Exception ex) {
throw new IllegalArgumentException("impossible to convert "
@@ -658,7 +656,7 @@ public class Configurator {
}
ObjectDescriptor od = objectStack.peek();
try {
- od.getObject().getClass().getMethod("addText", new Class[] {String.class})
+ od.getObject().getClass().getMethod("addText", String.class)
.invoke(od.getObject(), text);
} catch (Exception ex) {
throw new IllegalArgumentException("impossible to add text on "
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/src/java/org/apache/ivy/util/XMLHelper.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/util/XMLHelper.java b/src/java/org/apache/ivy/util/XMLHelper.java
index a62f34a..7112f45 100644
--- a/src/java/org/apache/ivy/util/XMLHelper.java
+++ b/src/java/org/apache/ivy/util/XMLHelper.java
@@ -197,8 +197,7 @@ public abstract class XMLHelper {
StringBuilder result = new StringBuilder(text.length());
- char[] chars = text.toCharArray();
- for (char ch : chars) {
+ for (char ch : text.toCharArray()) {
switch (ch) {
case '&':
result.append("&");
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java
index ad3de6a..bb582d0 100644
--- a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java
+++ b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java
@@ -54,7 +54,7 @@ public class XmlModuleUpdaterTest {
@After
public void tearDown() {
- XmlModuleDescriptorUpdater.LINE_SEPARATOR = System.getProperty("line.separator");
+ XmlModuleDescriptorUpdater.LINE_SEPARATOR = System.lineSeparator();
}
@Test
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java b/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java
index d93b4c5..a0cbd71 100644
--- a/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java
+++ b/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java
@@ -63,7 +63,7 @@ import static org.junit.Assert.*;
public class FileSystemResolverTest extends AbstractDependencyResolverTest {
// CheckStyle:MagicNumberCheck OFF
- private static final String FS = System.getProperty("file.separator");
+ private static final String FS = File.separator;
private static final String REL_IVY_PATTERN = "test" + FS + "repositories" + FS + "1" + FS
+ "[organisation]" + FS + "[module]" + FS + "ivys" + FS + "ivy-[revision].xml";
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1a283ab1/test/java/org/apache/ivy/plugins/trigger/LogTriggerTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/trigger/LogTriggerTest.java b/test/java/org/apache/ivy/plugins/trigger/LogTriggerTest.java
index a10191b..4956a95 100644
--- a/test/java/org/apache/ivy/plugins/trigger/LogTriggerTest.java
+++ b/test/java/org/apache/ivy/plugins/trigger/LogTriggerTest.java
@@ -34,7 +34,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class LogTriggerTest {
- private static final String LINE_SEPARATOR = System.getProperty("line.separator");
+ private static final String LINE_SEPARATOR = System.lineSeparator();
private StartResolveEvent ev;
[2/2] ant-ivy git commit: refactor System.getProperty() and loops
Posted by ja...@apache.org.
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 <g....@gmail.com>
Authored: Sun Jul 23 01:52:20 2017 +0200
Committer: Jaikiran Pai <ja...@apache.org>
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;
}