Add generics and Java 7 syntax to core This closes #52 pull request at github/apache/ant-ivy
Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/69207179 Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/69207179 Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/69207179 Branch: refs/heads/master Commit: 6920717979fe3c0d29f4704404492e1c5c0d7c2c Parents: 844100a Author: twogee <[email protected]> Authored: Thu Jul 6 08:04:24 2017 +0200 Committer: Jaikiran Pai <[email protected]> Committed: Mon Jul 17 11:07:59 2017 +0530 ---------------------------------------------------------------------- .checkstyle | 1 + src/java/org/apache/ivy/Ivy14.java | 207 ++++++-------- src/java/org/apache/ivy/Main.java | 60 ++-- src/java/org/apache/ivy/ant/BuildOBRTask.java | 5 +- src/java/org/apache/ivy/ant/IvyBuildList.java | 11 +- src/java/org/apache/ivy/ant/IvyBuildNumber.java | 9 +- .../org/apache/ivy/ant/IvyCacheFileset.java | 6 +- src/java/org/apache/ivy/ant/IvyCacheTask.java | 3 +- src/java/org/apache/ivy/ant/IvyConfigure.java | 4 +- .../org/apache/ivy/ant/IvyDependencyTree.java | 3 +- .../ivy/ant/IvyDependencyUpdateChecker.java | 6 +- .../org/apache/ivy/ant/IvyPostResolveTask.java | 10 +- .../org/apache/ivy/ant/IvyRepositoryReport.java | 5 +- src/java/org/apache/ivy/ant/IvyRetrieve.java | 3 +- src/java/org/apache/ivy/core/IvyContext.java | 63 ++--- .../org/apache/ivy/core/IvyPatternHelper.java | 49 ++-- .../apache/ivy/core/cache/ArtifactOrigin.java | 2 +- .../cache/DefaultRepositoryCacheManager.java | 28 +- .../cache/DefaultResolutionCacheManager.java | 27 +- .../core/cache/ModuleDescriptorMemoryCache.java | 8 +- .../ivy/core/cache/ParserSettingsMonitor.java | 26 +- .../org/apache/ivy/core/check/CheckEngine.java | 50 ++-- .../apache/ivy/core/deliver/DeliverEngine.java | 47 ++-- .../org/apache/ivy/core/event/EventManager.java | 10 +- .../ivy/core/event/FilteredIvyListener.java | 6 +- .../org/apache/ivy/core/event/IvyEvent.java | 2 +- .../apache/ivy/core/event/IvyEventFilter.java | 42 ++- .../event/publish/EndArtifactPublishEvent.java | 3 - .../publish/StartArtifactPublishEvent.java | 3 - .../apache/ivy/core/install/InstallEngine.java | 49 ++-- .../ivy/core/install/InstallEngineSettings.java | 4 +- .../apache/ivy/core/install/InstallOptions.java | 9 +- .../module/descriptor/AbstractArtifact.java | 6 +- .../descriptor/AbstractIncludeExcludeRule.java | 7 +- .../core/module/descriptor/Configuration.java | 28 +- .../module/descriptor/ConfigurationGroup.java | 12 +- .../descriptor/ConfigurationIntersection.java | 12 +- .../core/module/descriptor/DefaultArtifact.java | 4 +- .../DefaultDependencyArtifactDescriptor.java | 6 +- .../descriptor/DefaultDependencyDescriptor.java | 276 +++++++++---------- .../module/descriptor/DefaultExcludeRule.java | 2 +- .../descriptor/DefaultExtendsDescriptor.java | 6 +- .../module/descriptor/DefaultIncludeRule.java | 2 +- .../descriptor/DefaultModuleDescriptor.java | 159 +++++------ .../core/module/descriptor/ExtraInfoHolder.java | 4 +- .../ivy/core/module/descriptor/MDArtifact.java | 8 +- .../module/descriptor/ModuleDescriptor.java | 2 +- .../ivy/core/module/id/ArtifactRevisionId.java | 5 +- .../ivy/core/module/id/MatcherLookup.java | 40 +-- .../org/apache/ivy/core/module/id/ModuleId.java | 14 +- .../ivy/core/module/id/ModuleRevisionId.java | 10 +- .../apache/ivy/core/module/id/ModuleRules.java | 29 +- .../ivy/core/module/status/StatusManager.java | 44 ++- .../apache/ivy/core/pack/PackagingManager.java | 7 +- .../apache/ivy/core/pack/PackingRegistry.java | 2 +- .../org/apache/ivy/core/pack/ZipPacking.java | 12 +- .../apache/ivy/core/publish/PublishEngine.java | 22 +- .../ivy/core/report/ArtifactDownloadReport.java | 9 +- .../core/report/ConfigurationResolveReport.java | 35 +-- .../apache/ivy/core/report/DownloadReport.java | 15 +- .../apache/ivy/core/report/ResolveReport.java | 66 +++-- .../repository/RepositoryManagementEngine.java | 72 +++-- .../org/apache/ivy/core/resolve/IvyNode.java | 82 +++--- .../apache/ivy/core/resolve/IvyNodeCallers.java | 30 +- .../ivy/core/resolve/IvyNodeEviction.java | 50 ++-- .../apache/ivy/core/resolve/IvyNodeUsage.java | 30 +- .../apache/ivy/core/resolve/ResolveData.java | 57 ++-- .../apache/ivy/core/resolve/ResolveEngine.java | 180 ++++++------ .../apache/ivy/core/resolve/ResolveOptions.java | 7 +- .../org/apache/ivy/core/resolve/VisitData.java | 4 +- .../org/apache/ivy/core/resolve/VisitNode.java | 6 +- .../ivy/core/retrieve/RetrieveEngine.java | 71 +++-- .../ivy/core/retrieve/RetrieveOptions.java | 7 +- .../ivy/core/retrieve/RetrieveReport.java | 12 +- .../apache/ivy/core/search/SearchEngine.java | 132 +++++---- .../apache/ivy/core/settings/IvySettings.java | 56 ++-- .../ivy/core/settings/XmlSettingsParser.java | 176 ++++++------ .../core/sort/CollectionOfModulesToSort.java | 6 +- .../ivy/core/sort/ModuleDescriptorSorter.java | 6 +- .../org/apache/ivy/core/sort/ModuleInSort.java | 10 +- .../org/apache/ivy/core/sort/SortEngine.java | 11 +- .../ivy/osgi/core/ManifestHeaderValue.java | 2 +- .../apache/ivy/osgi/core/ManifestParser.java | 2 +- .../ivy/osgi/filter/OSGiFilterParser.java | 2 +- .../ivy/osgi/obr/xml/RequirementAdapter.java | 4 +- .../apache/ivy/osgi/p2/P2ArtifactParser.java | 2 +- .../apache/ivy/osgi/p2/P2CompositeParser.java | 2 +- .../apache/ivy/osgi/p2/P2MetadataParser.java | 2 +- .../org/apache/ivy/osgi/p2/XMLInputParser.java | 2 +- .../ivy/osgi/repo/AbstractOSGiResolver.java | 9 +- .../ivy/osgi/repo/EditableRepoDescriptor.java | 9 +- .../ivy/osgi/repo/ModuleDescriptorWrapper.java | 2 +- .../ivy/osgi/updatesite/UpdateSiteLoader.java | 7 +- .../org/apache/ivy/osgi/util/ParseUtil.java | 4 +- .../apache/ivy/osgi/util/VersionComparator.java | 2 +- .../circular/CircularDependencyHelper.java | 23 +- .../LatestCompatibleConflictManager.java | 10 +- .../plugins/conflict/LatestConflictManager.java | 2 +- .../plugins/latest/AbstractLatestStrategy.java | 3 +- .../ivy/plugins/lock/DeleteOnExitHook.java | 3 +- .../apache/ivy/plugins/parser/m2/PomReader.java | 2 +- .../parser/xml/XmlModuleDescriptorParser.java | 12 +- .../parser/xml/XmlModuleDescriptorUpdater.java | 62 ++--- .../parser/xml/XmlModuleDescriptorWriter.java | 201 ++++++-------- .../ivy/plugins/report/XmlReportWriter.java | 6 +- .../plugins/repository/sftp/SFTPRepository.java | 14 +- .../ssh/AbstractSshBasedRepository.java | 8 +- .../apache/ivy/plugins/repository/ssh/Scp.java | 10 +- .../ivy/plugins/repository/ssh/SshCache.java | 1 - .../plugins/repository/ssh/SshRepository.java | 2 +- .../plugins/repository/vfs/VfsRepository.java | 2 +- .../ivy/plugins/repository/vfs/VfsResource.java | 2 +- .../repository/vsftp/VsftpRepository.java | 26 +- .../resolver/AbstractPatternsBasedResolver.java | 11 +- .../ivy/plugins/resolver/AbstractResolver.java | 1 + .../ivy/plugins/resolver/BasicResolver.java | 10 +- .../ivy/plugins/resolver/ChainResolver.java | 1 + .../plugins/resolver/FileSystemResolver.java | 21 +- .../ivy/plugins/resolver/VsftpResolver.java | 2 +- .../bouncycastle/OpenPGPSignatureGenerator.java | 7 +- .../ivy/plugins/trigger/AbstractTrigger.java | 6 +- .../org/apache/ivy/plugins/trigger/Trigger.java | 3 +- .../plugins/version/ChainVersionMatcher.java | 9 +- .../analyser/JarJarDependencyAnalyser.java | 19 +- src/java/org/apache/ivy/util/Configurator.java | 24 +- src/java/org/apache/ivy/util/Credentials.java | 10 +- src/java/org/apache/ivy/util/FileUtil.java | 4 +- src/java/org/apache/ivy/util/MemoryUtil.java | 2 +- .../apache/ivy/util/MessageLoggerHelper.java | 2 +- src/java/org/apache/ivy/util/StringUtils.java | 7 +- .../org/apache/ivy/util/filter/AndFilter.java | 14 +- .../apache/ivy/util/filter/FilterHelper.java | 6 +- .../org/apache/ivy/util/filter/NoFilter.java | 8 +- .../org/apache/ivy/util/filter/NotFilter.java | 10 +- .../org/apache/ivy/util/filter/OrFilter.java | 14 +- .../apache/ivy/util/url/HttpClientHandler.java | 2 +- .../apache/ivy/util/url/URLHandlerRegistry.java | 2 +- .../ivy/plugins/resolver/CustomResolver.java | 2 +- test/java/org/apache/ivy/TestHelper.java | 36 +-- .../org/apache/ivy/ant/AntCallTriggerTest.java | 4 +- .../org/apache/ivy/ant/IvyCacheFilesetTest.java | 12 +- .../org/apache/ivy/ant/IvyConfigureTest.java | 11 +- .../java/org/apache/ivy/ant/IvyDeliverTest.java | 9 +- .../java/org/apache/ivy/ant/IvyPublishTest.java | 8 +- .../org/apache/ivy/ant/IvyResourcesTest.java | 12 +- test/java/org/apache/ivy/ant/IvyTaskTest.java | 3 +- .../ivy/ant/testutil/AntTestListener.java | 18 ++ .../cache/ModuleDescriptorMemoryCacheTest.java | 13 +- .../core/module/descriptor/IvyMakePomTest.java | 23 +- .../core/module/id/ModuleRevisionIdTest.java | 14 +- .../ivy/core/module/id/ModuleRulesTest.java | 38 +-- .../ivy/core/publish/PublishEventsTest.java | 17 +- .../apache/ivy/core/retrieve/RetrieveTest.java | 15 +- .../core/settings/XmlSettingsParserTest.java | 36 +-- .../ivy/osgi/core/OsgiLatestStrategyTest.java | 8 +- .../osgi/updatesite/UpdateSiteLoaderTest.java | 8 +- .../conflict/LatestConflictManagerTest.java | 12 +- .../m2/PomModuleDescriptorParserTest.java | 130 ++++----- .../xml/XmlModuleDescriptorParserTest.java | 23 +- .../parser/xml/XmlModuleUpdaterTest.java | 16 +- .../ivy/plugins/resolver/ChainResolverTest.java | 20 +- .../plugins/resolver/IBiblioResolverTest.java | 16 +- .../plugins/resolver/IvyRepResolverTest.java | 16 +- test/java/org/apache/ivy/util/CacheCleaner.java | 5 +- .../org/apache/ivy/util/ConfiguratorTest.java | 10 +- .../apache/ivy/util/IvyPatternHelperTest.java | 4 +- .../java/org/apache/ivy/util/TestXmlHelper.java | 9 +- .../ivy/util/url/ArtifactoryListingTest.java | 8 +- 168 files changed, 1788 insertions(+), 2013 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/.checkstyle ---------------------------------------------------------------------- diff --git a/.checkstyle b/.checkstyle index 59fdb69..c6310ea 100644 --- a/.checkstyle +++ b/.checkstyle @@ -25,5 +25,6 @@ <fileset name="Ivy Checkstyle config" enabled="true" check-config-name="Ivy Checkstyle Config" local="true"> <file-match-pattern match-pattern="^src.java.*.java$" include-pattern="true"/> <file-match-pattern match-pattern="^src.example.*.java$" include-pattern="true"/> + <file-match-pattern match-pattern="^test.java.*.java$" include-pattern="true"/> </fileset> </fileset-config> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/Ivy14.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/Ivy14.java b/src/java/org/apache/ivy/Ivy14.java index 28bc4ca..5e1de65 100644 --- a/src/java/org/apache/ivy/Ivy14.java +++ b/src/java/org/apache/ivy/Ivy14.java @@ -26,6 +26,7 @@ import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.Set; import org.apache.ivy.core.deliver.DeliverOptions; import org.apache.ivy.core.deliver.PublishingDependencyRevisionResolver; @@ -117,18 +118,18 @@ public class Ivy14 { deliver(mrid, revision, cache, destIvyPattern, status, pubdate, pdrResolver, validate, true); } - public Map determineArtifactsToCopy(ModuleId moduleId, String[] confs, File cache, - String destFilePattern, String destIvyPattern, Filter artifactFilter) - throws ParseException, IOException { + public Map<ArtifactDownloadReport, Set<String>> determineArtifactsToCopy(ModuleId moduleId, + String[] confs, File cache, String destFilePattern, String destIvyPattern, + Filter<Artifact> artifactFilter) throws ParseException, IOException { return ivy.getRetrieveEngine().determineArtifactsToCopy( - new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()), - destFilePattern, + new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()), destFilePattern, new RetrieveOptions().setConfs(confs).setDestIvyPattern(destIvyPattern) .setArtifactFilter(artifactFilter)); } - public Map determineArtifactsToCopy(ModuleId moduleId, String[] confs, File cache, - String destFilePattern, String destIvyPattern) throws ParseException, IOException { + public Map<ArtifactDownloadReport, Set<String>> determineArtifactsToCopy(ModuleId moduleId, + String[] confs, File cache, String destFilePattern, String destIvyPattern) + throws ParseException, IOException { return ivy.getRetrieveEngine().determineArtifactsToCopy( new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()), destFilePattern, new RetrieveOptions().setConfs(confs).setDestIvyPattern(destIvyPattern)); @@ -147,26 +148,20 @@ public class Ivy14 { public IvyNode[] getDependencies(ModuleDescriptor md, String[] confs, File cache, Date date, ResolveReport report, boolean validate, boolean transitive) { - return ivy.getResolveEngine().getDependencies( - md, - newResolveOptions(confs, null, cache, date, validate, false, transitive, false, true, - true, FilterHelper.NO_FILTER), report); + return ivy.getResolveEngine().getDependencies(md, newResolveOptions(confs, null, cache, + date, validate, false, transitive, false, true, true, FilterHelper.NO_FILTER), report); } public IvyNode[] getDependencies(ModuleDescriptor md, String[] confs, File cache, Date date, ResolveReport report, boolean validate) { - return ivy.getResolveEngine().getDependencies( - md, - newResolveOptions(confs, null, cache, date, validate, false, true, false, true, true, - FilterHelper.NO_FILTER), report); + return ivy.getResolveEngine().getDependencies(md, newResolveOptions(confs, null, cache, + date, validate, false, true, false, true, true, FilterHelper.NO_FILTER), report); } public IvyNode[] getDependencies(URL ivySource, String[] confs, File cache, Date date, boolean validate) throws ParseException, IOException { - return ivy.getResolveEngine().getDependencies( - ivySource, - newResolveOptions(confs, null, cache, date, validate, false, true, false, true, true, - FilterHelper.NO_FILTER)); + return ivy.getResolveEngine().getDependencies(ivySource, newResolveOptions(confs, null, + cache, date, validate, false, true, false, true, true, FilterHelper.NO_FILTER)); } public String getVariable(String name) { @@ -174,11 +169,12 @@ public class Ivy14 { } public ResolveReport install(ModuleRevisionId mrid, String from, String to, boolean transitive, - boolean validate, boolean overwrite, Filter artifactFilter, File cache, + boolean validate, boolean overwrite, Filter<Artifact> artifactFilter, File cache, String matcherName) throws IOException { - return ivy.install(mrid, from, to, new InstallOptions().setTransitive(transitive) - .setValidate(validate).setOverwrite(overwrite).setArtifactFilter(artifactFilter) - .setMatcherName(matcherName)); + return ivy.install(mrid, from, to, + new InstallOptions().setTransitive(transitive).setValidate(validate) + .setOverwrite(overwrite).setArtifactFilter(artifactFilter) + .setMatcherName(matcherName)); } public void interrupt() { @@ -225,36 +221,30 @@ public class Ivy14 { return ivy.listRevisions(org, module); } - public String[] listTokenValues(String token, Map otherTokenValues) { + public String[] listTokenValues(String token, Map<String, Object> otherTokenValues) { return ivy.listTokenValues(token, otherTokenValues); } - public Collection publish(ModuleDescriptor md, DependencyResolver resolver, - Collection srcArtifactPattern, String srcIvyPattern, Artifact[] extraArtifacts, + public Collection<Artifact> publish(ModuleDescriptor md, DependencyResolver resolver, + Collection<String> srcArtifactPattern, String srcIvyPattern, Artifact[] extraArtifacts, boolean overwrite, String conf) throws IOException { - return ivy.getPublishEngine().publish( - md, - srcArtifactPattern, - resolver, + return ivy.getPublishEngine().publish(md, srcArtifactPattern, resolver, new PublishOptions().setSrcIvyPattern(srcIvyPattern).setExtraArtifacts(extraArtifacts) .setOverwrite(overwrite).setConfs(splitConfs(conf))); } - public Collection publish(ModuleRevisionId mrid, String pubrevision, File cache, - Collection srcArtifactPattern, String resolverName, String srcIvyPattern, + public Collection<Artifact> publish(ModuleRevisionId mrid, String pubrevision, File cache, + Collection<String> srcArtifactPattern, String resolverName, String srcIvyPattern, String status, Date pubdate, Artifact[] extraArtifacts, boolean validate, boolean overwrite, boolean update, String conf) throws IOException { - return ivy.publish( - mrid, - srcArtifactPattern, - resolverName, + return ivy.publish(mrid, srcArtifactPattern, resolverName, new PublishOptions().setStatus(status).setPubdate(pubdate).setPubrevision(pubrevision) .setSrcIvyPattern(srcIvyPattern).setExtraArtifacts(extraArtifacts) .setUpdate(update).setValidate(validate).setOverwrite(overwrite) .setConfs(splitConfs(conf))); } - public Collection publish(ModuleRevisionId mrid, String pubrevision, File cache, + public Collection<Artifact> publish(ModuleRevisionId mrid, String pubrevision, File cache, String srcArtifactPattern, String resolverName, String srcIvyPattern, boolean validate, boolean overwrite) throws IOException { return ivy.publish(mrid, Collections.singleton(srcArtifactPattern), resolverName, @@ -262,7 +252,7 @@ public class Ivy14 { .setValidate(validate).setOverwrite(overwrite)); } - public Collection publish(ModuleRevisionId mrid, String pubrevision, File cache, + public Collection<Artifact> publish(ModuleRevisionId mrid, String pubrevision, File cache, String srcArtifactPattern, String resolverName, String srcIvyPattern, boolean validate) throws IOException { return ivy.publish(mrid, Collections.singleton(srcArtifactPattern), resolverName, @@ -270,14 +260,11 @@ public class Ivy14 { .setValidate(validate)); } - public Collection publish(ModuleRevisionId mrid, String pubrevision, File cache, + public Collection<Artifact> publish(ModuleRevisionId mrid, String pubrevision, File cache, String srcArtifactPattern, String resolverName, String srcIvyPattern, String status, Date pubdate, Artifact[] extraArtifacts, boolean validate, boolean overwrite, boolean update, String conf) throws IOException { - return ivy.publish( - mrid, - Collections.singleton(srcArtifactPattern), - resolverName, + return ivy.publish(mrid, Collections.singleton(srcArtifactPattern), resolverName, new PublishOptions().setStatus(status).setPubdate(pubdate).setPubrevision(pubrevision) .setSrcIvyPattern(srcIvyPattern).setExtraArtifacts(extraArtifacts) .setUpdate(update).setValidate(validate).setOverwrite(overwrite) @@ -290,17 +277,15 @@ public class Ivy14 { public ResolveReport resolve(ModuleDescriptor md, String[] confs, File cache, Date date, boolean validate, boolean useCacheOnly, boolean transitive, boolean useOrigin, - boolean download, boolean outputReport, Filter artifactFilter) throws ParseException, - IOException { - return ivy.resolve( - md, - newResolveOptions(confs, null, cache, date, validate, useCacheOnly, transitive, - useOrigin, download, outputReport, artifactFilter)); + boolean download, boolean outputReport, Filter<Artifact> artifactFilter) + throws ParseException, IOException { + return ivy.resolve(md, newResolveOptions(confs, null, cache, date, validate, useCacheOnly, + transitive, useOrigin, download, outputReport, artifactFilter)); } - private ResolveOptions newResolveOptions(String[] confs, String revision, File cache, - Date date, boolean validate, boolean useCacheOnly, boolean transitive, - boolean useOrigin, boolean download, boolean outputReport, Filter artifactFilter) { + private ResolveOptions newResolveOptions(String[] confs, String revision, File cache, Date date, + boolean validate, boolean useCacheOnly, boolean transitive, boolean useOrigin, + boolean download, boolean outputReport, Filter<Artifact> artifactFilter) { if (useOrigin) { ivy.getSettings().useDeprecatedUseOrigin(); } @@ -311,98 +296,77 @@ public class Ivy14 { public ResolveReport resolve(ModuleDescriptor md, String[] confs, File cache, Date date, boolean validate, boolean useCacheOnly, boolean transitive, boolean download, - boolean outputReport, Filter artifactFilter) throws ParseException, IOException { - return ivy.resolve( - md, - newResolveOptions(confs, null, cache, date, validate, useCacheOnly, transitive, false, - download, outputReport, artifactFilter)); + boolean outputReport, Filter<Artifact> artifactFilter) + throws ParseException, IOException { + return ivy.resolve(md, newResolveOptions(confs, null, cache, date, validate, useCacheOnly, + transitive, false, download, outputReport, artifactFilter)); } public ResolveReport resolve(ModuleDescriptor md, String[] confs, File cache, Date date, - boolean validate, boolean useCacheOnly, boolean transitive, Filter artifactFilter) - throws ParseException, IOException { - return ivy.resolve( - md, - newResolveOptions(confs, null, cache, date, validate, useCacheOnly, transitive, false, - true, true, artifactFilter)); + boolean validate, boolean useCacheOnly, boolean transitive, + Filter<Artifact> artifactFilter) throws ParseException, IOException { + return ivy.resolve(md, newResolveOptions(confs, null, cache, date, validate, useCacheOnly, + transitive, false, true, true, artifactFilter)); } public ResolveReport resolve(ModuleDescriptor md, String[] confs, File cache, Date date, - boolean validate, boolean useCacheOnly, Filter artifactFilter) throws ParseException, - IOException { - return ivy.resolve( - md, - newResolveOptions(confs, null, cache, date, validate, useCacheOnly, true, false, true, - true, artifactFilter)); + boolean validate, boolean useCacheOnly, Filter<Artifact> artifactFilter) + throws ParseException, IOException { + return ivy.resolve(md, newResolveOptions(confs, null, cache, date, validate, useCacheOnly, + true, false, true, true, artifactFilter)); } public ResolveReport resolve(ModuleRevisionId mrid, String[] confs, boolean transitive, boolean changing, File cache, Date date, boolean validate, boolean useCacheOnly, - boolean useOrigin, Filter artifactFilter) throws ParseException, IOException { - return ivy.resolve( - mrid, - newResolveOptions(confs, null, cache, date, validate, useCacheOnly, transitive, - useOrigin, true, true, artifactFilter), changing); + boolean useOrigin, Filter<Artifact> artifactFilter) throws ParseException, IOException { + return ivy.resolve(mrid, newResolveOptions(confs, null, cache, date, validate, useCacheOnly, + transitive, useOrigin, true, true, artifactFilter), changing); } public ResolveReport resolve(ModuleRevisionId mrid, String[] confs, boolean transitive, boolean changing, File cache, Date date, boolean validate, boolean useCacheOnly, - Filter artifactFilter) throws ParseException, IOException { - return ivy.resolve( - mrid, - newResolveOptions(confs, null, cache, date, validate, useCacheOnly, transitive, false, - true, true, artifactFilter), changing); + Filter<Artifact> artifactFilter) throws ParseException, IOException { + return ivy.resolve(mrid, newResolveOptions(confs, null, cache, date, validate, useCacheOnly, + transitive, false, true, true, artifactFilter), changing); } - public ResolveReport resolve(ModuleRevisionId mrid, String[] confs) throws ParseException, - IOException { - return ivy.resolve( - mrid, - newResolveOptions(confs, null, ivy.getSettings().getDefaultCache(), null, true, false, - true, false, true, true, FilterHelper.NO_FILTER), false); + public ResolveReport resolve(ModuleRevisionId mrid, String[] confs) + throws ParseException, IOException { + return ivy.resolve(mrid, newResolveOptions(confs, null, ivy.getSettings().getDefaultCache(), + null, true, false, true, false, true, true, FilterHelper.NO_FILTER), false); } public ResolveReport resolve(URL ivySource, String revision, String[] confs, File cache, Date date, boolean validate, boolean useCacheOnly, boolean transitive, - boolean useOrigin, Filter artifactFilter) throws ParseException, IOException { - return ivy.resolve( - ivySource, - newResolveOptions(confs, revision, cache, date, validate, useCacheOnly, transitive, - useOrigin, true, true, artifactFilter)); + boolean useOrigin, Filter<Artifact> artifactFilter) throws ParseException, IOException { + return ivy.resolve(ivySource, newResolveOptions(confs, revision, cache, date, validate, + useCacheOnly, transitive, useOrigin, true, true, artifactFilter)); } public ResolveReport resolve(URL ivySource, String revision, String[] confs, File cache, Date date, boolean validate, boolean useCacheOnly, boolean transitive, - Filter artifactFilter) throws ParseException, IOException { - return ivy.resolve( - ivySource, - newResolveOptions(confs, revision, cache, date, validate, useCacheOnly, transitive, - false, true, true, artifactFilter)); + Filter<Artifact> artifactFilter) throws ParseException, IOException { + return ivy.resolve(ivySource, newResolveOptions(confs, revision, cache, date, validate, + useCacheOnly, transitive, false, true, true, artifactFilter)); } public ResolveReport resolve(URL ivySource, String revision, String[] confs, File cache, - Date date, boolean validate, boolean useCacheOnly, Filter artifactFilter) + Date date, boolean validate, boolean useCacheOnly, Filter<Artifact> artifactFilter) throws ParseException, IOException { - return ivy.resolve( - ivySource, - newResolveOptions(confs, revision, cache, date, validate, useCacheOnly, true, false, - true, true, artifactFilter)); + return ivy.resolve(ivySource, newResolveOptions(confs, revision, cache, date, validate, + useCacheOnly, true, false, true, true, artifactFilter)); } public ResolveReport resolve(URL ivySource, String revision, String[] confs, File cache, Date date, boolean validate, boolean useCacheOnly) throws ParseException, IOException { - return ivy.resolve( - ivySource, - newResolveOptions(confs, revision, cache, date, validate, useCacheOnly, true, false, - true, true, FilterHelper.NO_FILTER)); + return ivy.resolve(ivySource, newResolveOptions(confs, revision, cache, date, validate, + useCacheOnly, true, false, true, true, FilterHelper.NO_FILTER)); } public ResolveReport resolve(URL ivySource, String revision, String[] confs, File cache, Date date, boolean validate) throws ParseException, IOException { - return ivy.resolve( - ivySource, - newResolveOptions(confs, revision, cache, date, validate, false, true, false, true, - true, FilterHelper.NO_FILTER)); + return ivy.resolve(ivySource, newResolveOptions(confs, revision, cache, date, validate, + false, true, false, true, true, FilterHelper.NO_FILTER)); } public ResolveReport resolve(URL ivySource) throws ParseException, IOException { @@ -410,7 +374,7 @@ public class Ivy14 { } public int retrieve(ModuleId moduleId, String[] confs, File cache, String destFilePattern, - String destIvyPattern, Filter artifactFilter, boolean sync, boolean useOrigin, + String destIvyPattern, Filter<Artifact> artifactFilter, boolean sync, boolean useOrigin, boolean makeSymlinks) { try { return ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()), @@ -424,7 +388,8 @@ public class Ivy14 { } public int retrieve(ModuleId moduleId, String[] confs, File cache, String destFilePattern, - String destIvyPattern, Filter artifactFilter, boolean sync, boolean useOrigin) { + String destIvyPattern, Filter<Artifact> artifactFilter, boolean sync, + boolean useOrigin) { try { return ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()), destFilePattern, @@ -436,12 +401,11 @@ public class Ivy14 { } public int retrieve(ModuleId moduleId, String[] confs, File cache, String destFilePattern, - String destIvyPattern, Filter artifactFilter) { + String destIvyPattern, Filter<Artifact> artifactFilter) { try { return ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()), - destFilePattern, - new RetrieveOptions().setConfs(confs).setDestIvyPattern(destIvyPattern) - .setArtifactFilter(artifactFilter)); + destFilePattern, new RetrieveOptions().setConfs(confs) + .setDestIvyPattern(destIvyPattern).setArtifactFilter(artifactFilter)); } catch (IOException e) { throw new RuntimeException(e); } @@ -471,16 +435,15 @@ public class Ivy14 { ivy.setVariable(varName, value); } - public List sortModuleDescriptors(Collection moduleDescriptors) { - return ivy - .sortModuleDescriptors(moduleDescriptors, new SortOptions() - .setNonMatchingVersionReporter(new SilentNonMatchingVersionReporter())); + public List<ModuleDescriptor> sortModuleDescriptors( + Collection<ModuleDescriptor> moduleDescriptors) { + return ivy.sortModuleDescriptors(moduleDescriptors, new SortOptions() + .setNonMatchingVersionReporter(new SilentNonMatchingVersionReporter())); } - public List sortNodes(Collection nodes) { - return ivy - .sortNodes(nodes, new SortOptions() - .setNonMatchingVersionReporter(new SilentNonMatchingVersionReporter())); + public List<IvyNode> sortNodes(Collection<IvyNode> nodes) { + return ivy.sortNodes(nodes, new SortOptions() + .setNonMatchingVersionReporter(new SilentNonMatchingVersionReporter())); } public String substitute(String str) { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/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 c256319..99690c1 100644 --- a/src/java/org/apache/ivy/Main.java +++ b/src/java/org/apache/ivy/Main.java @@ -30,7 +30,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.StringTokenizer; @@ -278,8 +277,8 @@ public final class Main { "working")); DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, ModuleRevisionId.newInstance(dep[0], dep[1], dep[2]), false, false, true); - for (int i = 0; i < confs.length; i++) { - dd.addDependencyConfiguration("default", confs[i]); + for (String conf : confs) { + dd.addDependencyConfiguration("default", conf); } md.addDependency(dd); XmlModuleDescriptorWriter.write(md, ivyfile); @@ -319,8 +318,8 @@ public final class Main { } if (line.hasOption("retrieve")) { String retrievePattern = settings.substitute(line.getOptionValue("retrieve")); - if (retrievePattern.indexOf("[") == -1) { - retrievePattern = retrievePattern + "/lib/[conf]/[artifact].[ext]"; + if (!retrievePattern.contains("[")) { + retrievePattern += "/lib/[conf]/[artifact].[ext]"; } String ivyPattern = settings.substitute(line.getOptionValue("ivypattern")); ivy.retrieve( @@ -366,7 +365,7 @@ public final class Main { } if (line.hasOption("main")) { // check if the option cp has been set - List fileList = getExtraClasspathFileList(line); + List<File> fileList = getExtraClasspathFileList(line); // merge -args and left over args String[] fargs = line.getOptionValues("args"); @@ -399,13 +398,12 @@ public final class Main { * @return a List of files to include as extra classpath entries, or <code>null</code> if no cp * option was provided. */ - private static List/* <File> */getExtraClasspathFileList(CommandLine line) { - List fileList = null; + private static List<File> getExtraClasspathFileList(CommandLine line) { + List<File> fileList = null; if (line.hasOption("cp")) { - fileList = new ArrayList/* <File> */(); - String[] cpArray = line.getOptionValues("cp"); - for (int index = 0; index < cpArray.length; index++) { - StringTokenizer tokenizer = new StringTokenizer(cpArray[index], + fileList = new ArrayList<>(); + for (String cp : line.getOptionValues("cp")) { + StringTokenizer tokenizer = new StringTokenizer(cp, System.getProperty("path.separator")); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); @@ -472,19 +470,18 @@ public final class Main { String outFile) { try { String pathSeparator = System.getProperty("path.separator"); - StringBuffer buf = new StringBuffer(); - Collection all = new LinkedHashSet(); + StringBuilder buf = new StringBuilder(); + Collection<ArtifactDownloadReport> all = new LinkedHashSet<>(); ResolutionCacheManager cacheMgr = ivy.getResolutionCacheManager(); XmlReportParser parser = new XmlReportParser(); - for (int i = 0; i < confs.length; i++) { + for (String conf : confs) { String resolveId = ResolveOptions.getDefaultResolveId(md); - File report = cacheMgr.getConfigurationResolveReportInCache(resolveId, confs[i]); + File report = cacheMgr.getConfigurationResolveReportInCache(resolveId, conf); parser.parse(report); all.addAll(Arrays.asList(parser.getArtifactReports())); } - for (Iterator iter = all.iterator(); iter.hasNext();) { - ArtifactDownloadReport artifact = (ArtifactDownloadReport) iter.next(); + for (ArtifactDownloadReport artifact : all) { if (artifact.getLocalFile() != null) { buf.append(artifact.getLocalFile().getCanonicalPath()); buf.append(pathSeparator); @@ -505,13 +502,12 @@ public final class Main { @SuppressWarnings("resource") private static void invoke(Ivy ivy, File cache, ModuleDescriptor md, String[] confs, - List fileList, String mainclass, String[] args) { - List urls = new ArrayList(); + List<File> fileList, String mainclass, String[] args) { + List<URL> urls = new ArrayList<>(); // Add option cp (extra classpath) urls if (fileList != null && fileList.size() > 0) { - for (Iterator iter = fileList.iterator(); iter.hasNext();) { - File file = (File) iter.next(); + for (File file : fileList) { try { urls.add(file.toURI().toURL()); } catch (MalformedURLException e) { @@ -521,19 +517,17 @@ public final class Main { } try { - Collection all = new LinkedHashSet(); + Collection<ArtifactDownloadReport> all = new LinkedHashSet<>(); ResolutionCacheManager cacheMgr = ivy.getResolutionCacheManager(); XmlReportParser parser = new XmlReportParser(); - for (int i = 0; i < confs.length; i++) { + for (String conf : confs) { String resolveId = ResolveOptions.getDefaultResolveId(md); - File report = cacheMgr.getConfigurationResolveReportInCache(resolveId, confs[i]); + File report = cacheMgr.getConfigurationResolveReportInCache(resolveId, conf); parser.parse(report); all.addAll(Arrays.asList(parser.getArtifactReports())); } - for (Iterator iter = all.iterator(); iter.hasNext();) { - ArtifactDownloadReport artifact = (ArtifactDownloadReport) iter.next(); - + for (ArtifactDownloadReport artifact : all) { if (artifact.getLocalFile() != null) { urls.add(artifact.getLocalFile().toURI().toURL()); } @@ -542,21 +536,19 @@ public final class Main { throw new RuntimeException("impossible to build ivy cache path: " + ex.getMessage(), ex); } - URLClassLoader classLoader = new URLClassLoader((URL[]) urls.toArray(new URL[urls.size()]), + URLClassLoader classLoader = new URLClassLoader(urls.toArray(new URL[urls.size()]), Main.class.getClassLoader()); try { - Class c = classLoader.loadClass(mainclass); + Class<?> c = classLoader.loadClass(mainclass); - Method mainMethod = c.getMethod("main", new Class[] {String[].class}); + Method mainMethod = c.getMethod("main", String[].class); Thread.currentThread().setContextClassLoader(classLoader); mainMethod.invoke(null, new Object[] {(args == null ? new String[0] : args)}); } catch (ClassNotFoundException cnfe) { throw new RuntimeException("Could not find class: " + mainclass, cnfe); - } catch (SecurityException e) { - throw new RuntimeException("Could not find main method: " + mainclass, e); - } catch (NoSuchMethodException e) { + } catch (SecurityException | NoSuchMethodException e) { throw new RuntimeException("Could not find main method: " + mainclass, e); } catch (IllegalAccessException e) { throw new RuntimeException("No permissions to invoke main method: " + mainclass, e); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/ant/BuildOBRTask.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/BuildOBRTask.java b/src/java/org/apache/ivy/ant/BuildOBRTask.java index 226167a..35945ac 100644 --- a/src/java/org/apache/ivy/ant/BuildOBRTask.java +++ b/src/java/org/apache/ivy/ant/BuildOBRTask.java @@ -158,12 +158,9 @@ public class BuildOBRTask extends IvyCacheTask { prepareAndCheck(); try { it = new ArtifactReportManifestIterable(getArtifactReports(), sourceTypes); - } catch (ParseException e) { + } catch (ParseException | IOException e) { throw new BuildException("Impossible to parse the artifact reports: " + e.getMessage(), e); - } catch (IOException e) { - throw new BuildException("Impossible to read the artifact reports: " - + e.getMessage(), e); } } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/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 84cc0c6..9ff9b75 100644 --- a/src/java/org/apache/ivy/ant/IvyBuildList.java +++ b/src/java/org/apache/ivy/ant/IvyBuildList.java @@ -25,7 +25,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; -import java.util.ListIterator; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; @@ -273,14 +272,12 @@ public class IvyBuildList extends IvyTask { sortedModules = keptModules; } StringBuilder order = new StringBuilder(); - for (ListIterator<ModuleDescriptor> iter = sortedModules.listIterator(); iter.hasNext();) { - ModuleDescriptor md = iter.next(); - order.append(md.getModuleRevisionId().getModuleId()); - if (iter.hasNext()) { + for (ModuleDescriptor md : sortedModules) { + if (order.length() > 0) { order.append(", "); } - File buildFile = buildFiles.get(md); - addBuildFile(path, buildFile); + order.append(md.getModuleRevisionId().getModuleId()); + addBuildFile(path, buildFiles.get(md)); } if (OnMissingDescriptor.TAIL.equals(onMissingDescriptor)) { for (File buildFile : noDescriptor) { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/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 8634472..3216532 100644 --- a/src/java/org/apache/ivy/ant/IvyBuildNumber.java +++ b/src/java/org/apache/ivy/ant/IvyBuildNumber.java @@ -153,10 +153,10 @@ public class IvyBuildNumber extends IvyTask { if (revision == null || revision.length() == 0) { revision = "latest.integration"; } else if (!revision.endsWith("+")) { - revision = revision + "+"; + revision += "+"; } if (!prefix.endsWith(".") && prefix.length() > 0) { - prefix = prefix + "."; + prefix += "."; } SearchEngine searcher = new SearchEngine(settings); @@ -205,13 +205,14 @@ public class IvyBuildNumber extends IvyTask { VersionMatcher matcher = settings.getVersionMatcher(); LatestStrategy latestStrategy = settings.getLatestStrategy("latest-revision"); - List sorted = latestStrategy.sort(infos); + List<ArtifactInfo> sorted = latestStrategy.sort(infos); ModuleRevisionId askedMrid = ModuleRevisionId.newInstance(organisation, module, branch, revision); String foundRevision = null; - for (ListIterator iter = sorted.listIterator(sorted.size()); iter.hasPrevious();) { + ListIterator<ArtifactInfo> iter = sorted.listIterator(sorted.size()); + while (iter.hasPrevious()) { ResolvedModuleRevisionArtifactInfo info = (ResolvedModuleRevisionArtifactInfo) iter .previous(); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/ant/IvyCacheFileset.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/IvyCacheFileset.java b/src/java/org/apache/ivy/ant/IvyCacheFileset.java index 56bcc6d..0c92804 100644 --- a/src/java/org/apache/ivy/ant/IvyCacheFileset.java +++ b/src/java/org/apache/ivy/ant/IvyCacheFileset.java @@ -167,11 +167,11 @@ public class IvyCacheFileset extends IvyCacheTask { if (file1 == null || file2 == null) { return null; } - final Iterator file1Parents = getParents(file1).iterator(); - final Iterator file2Parents = getParents(file2.getAbsoluteFile()).iterator(); + final Iterator<File> file1Parents = getParents(file1).iterator(); + final Iterator<File> file2Parents = getParents(file2.getAbsoluteFile()).iterator(); File result = null; while (file1Parents.hasNext() && file2Parents.hasNext()) { - File next = (File) file1Parents.next(); + File next = file1Parents.next(); if (next.equals(file2Parents.next())) { result = next; } else { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/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 72c14a7..d053257 100644 --- a/src/java/org/apache/ivy/ant/IvyCacheTask.java +++ b/src/java/org/apache/ivy/ant/IvyCacheTask.java @@ -56,8 +56,7 @@ public abstract class IvyCacheTask extends IvyPostResolveTask { return ret; } - private Collection<ArtifactDownloadReport> getAllArtifactReports() throws ParseException, - IOException { + private Collection<ArtifactDownloadReport> getAllArtifactReports() throws ParseException { String[] confs = splitConfs(getConf()); Collection<ArtifactDownloadReport> all = new LinkedHashSet<>(); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/ant/IvyConfigure.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/IvyConfigure.java b/src/java/org/apache/ivy/ant/IvyConfigure.java index f41cb5c..94747fa 100644 --- a/src/java/org/apache/ivy/ant/IvyConfigure.java +++ b/src/java/org/apache/ivy/ant/IvyConfigure.java @@ -48,8 +48,8 @@ public class IvyConfigure extends Task { */ public static final String OVERRIDE_NOT_ALLOWED = "notallowed"; - private static final Collection OVERRIDE_VALUES = Arrays.asList(OVERRIDE_TRUE, - OVERRIDE_FALSE, OVERRIDE_NOT_ALLOWED); + private static final Collection<String> OVERRIDE_VALUES = Arrays.asList(OVERRIDE_TRUE, + OVERRIDE_FALSE, OVERRIDE_NOT_ALLOWED); private String override = OVERRIDE_NOT_ALLOWED; http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/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 7c30f25..1817063 100644 --- a/src/java/org/apache/ivy/ant/IvyDependencyTree.java +++ b/src/java/org/apache/ivy/ant/IvyDependencyTree.java @@ -117,8 +117,7 @@ public class IvyDependencyTree extends IvyPostResolveTask { private void populateDependencyTree(IvyNode dependency) { registerNodeIfNecessary(dependency.getId()); - for (int i = 0; i < dependency.getAllCallers().length; i++) { - Caller caller = dependency.getAllCallers()[i]; + for (Caller caller : dependency.getAllCallers()) { addDependency(caller.getModuleRevisionId(), dependency); } } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/ant/IvyDependencyUpdateChecker.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/IvyDependencyUpdateChecker.java b/src/java/org/apache/ivy/ant/IvyDependencyUpdateChecker.java index 1eb628d..e6499d5 100644 --- a/src/java/org/apache/ivy/ant/IvyDependencyUpdateChecker.java +++ b/src/java/org/apache/ivy/ant/IvyDependencyUpdateChecker.java @@ -51,13 +51,11 @@ public class IvyDependencyUpdateChecker extends IvyPostResolveTask { originalModuleDescriptor.getModuleRevisionId(), originalModuleDescriptor.getStatus(), originalModuleDescriptor.getPublicationDate()); // copy configurations - for (int i = 0; i < originalModuleDescriptor.getConfigurations().length; i++) { - Configuration configuration = originalModuleDescriptor.getConfigurations()[i]; + for (Configuration configuration : originalModuleDescriptor.getConfigurations()) { latestModuleDescriptor.addConfiguration(configuration); } // clone dependency and add new one with the requested revisionToCheck - for (int i = 0; i < originalModuleDescriptor.getDependencies().length; i++) { - DependencyDescriptor dependencyDescriptor = originalModuleDescriptor.getDependencies()[i]; + for (DependencyDescriptor dependencyDescriptor : originalModuleDescriptor.getDependencies()) { ModuleRevisionId upToDateMrid = ModuleRevisionId.newInstance( dependencyDescriptor.getDependencyRevisionId(), revisionToCheck); latestModuleDescriptor.addDependency(dependencyDescriptor.clone(upToDateMrid)); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/ant/IvyPostResolveTask.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/IvyPostResolveTask.java b/src/java/org/apache/ivy/ant/IvyPostResolveTask.java index bcca68c..36d2d2d 100644 --- a/src/java/org/apache/ivy/ant/IvyPostResolveTask.java +++ b/src/java/org/apache/ivy/ant/IvyPostResolveTask.java @@ -20,9 +20,11 @@ package org.apache.ivy.ant; import java.io.File; import java.util.Arrays; import java.util.HashSet; +import java.util.Set; import org.apache.ivy.Ivy; import org.apache.ivy.core.cache.ResolutionCacheManager; +import org.apache.ivy.core.module.descriptor.Artifact; import org.apache.ivy.core.module.descriptor.ModuleDescriptor; import org.apache.ivy.core.module.id.ModuleId; import org.apache.ivy.core.module.id.ModuleRevisionId; @@ -61,7 +63,7 @@ public abstract class IvyPostResolveTask extends IvyTask { private File file; - private Filter artifactFilter = null; + private Filter<Artifact> artifactFilter = null; private boolean useOrigin = false; @@ -265,7 +267,7 @@ public abstract class IvyPostResolveTask extends IvyTask { confs = splitConfs(conf); } - HashSet<String> rconfsSet = new HashSet<>(); + Set<String> rconfsSet = new HashSet<>(); // for each resolved configuration, check if the report still exists ResolutionCacheManager cache = getSettings().getResolutionCacheManager(); @@ -281,7 +283,7 @@ public abstract class IvyPostResolveTask extends IvyTask { } } - HashSet<String> confsSet = new HashSet<>(Arrays.asList(confs)); + Set<String> confsSet = new HashSet<>(Arrays.asList(confs)); Message.debug("resolved configurations: " + rconfsSet); Message.debug("asked configurations: " + confsSet); confsSet.removeAll(rconfsSet); @@ -384,7 +386,7 @@ public abstract class IvyPostResolveTask extends IvyTask { revision = rev; } - public Filter getArtifactFilter() { + public Filter<Artifact> getArtifactFilter() { return artifactFilter; } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/ant/IvyRepositoryReport.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/IvyRepositoryReport.java b/src/java/org/apache/ivy/ant/IvyRepositoryReport.java index da27edd..6ce7445 100644 --- a/src/java/org/apache/ivy/ant/IvyRepositoryReport.java +++ b/src/java/org/apache/ivy/ant/IvyRepositoryReport.java @@ -129,8 +129,7 @@ public class IvyRepositoryReport extends IvyTask { } } - private void genreport(ResolutionCacheManager cache, String organisation, String module) - throws IOException { + private void genreport(ResolutionCacheManager cache, String organisation, String module) { // first process the report with xslt XSLTProcess xslt = new XSLTProcess(); xslt.setTaskName(getTaskName()); @@ -187,7 +186,7 @@ public class IvyRepositoryReport extends IvyTask { } private void gen(ResolutionCacheManager cache, String organisation, String module, - String style, String ext) throws IOException { + String style, String ext) { XSLTProcess xslt = new XSLTProcess(); xslt.setTaskName(getTaskName()); xslt.setProject(getProject()); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/ant/IvyRetrieve.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/IvyRetrieve.java b/src/java/org/apache/ivy/ant/IvyRetrieve.java index 0fc0f7f..f90403a 100644 --- a/src/java/org/apache/ivy/ant/IvyRetrieve.java +++ b/src/java/org/apache/ivy/ant/IvyRetrieve.java @@ -22,6 +22,7 @@ import java.util.Arrays; import java.util.Collection; import org.apache.ivy.core.LogOptions; +import org.apache.ivy.core.module.descriptor.Artifact; import org.apache.ivy.core.retrieve.RetrieveOptions; import org.apache.ivy.core.retrieve.RetrieveReport; import org.apache.ivy.util.filter.Filter; @@ -94,7 +95,7 @@ public class IvyRetrieve extends IvyPostResolveTask { pattern = getProperty(pattern, getSettings(), "ivy.retrieve.pattern"); try { - Filter artifactFilter = getArtifactFilter(); + Filter<Artifact> artifactFilter = getArtifactFilter(); RetrieveReport report = getIvyInstance().retrieve( getResolvedMrid(), ((RetrieveOptions) new RetrieveOptions().setLog(getLog())) http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/IvyContext.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/core/IvyContext.java b/src/java/org/apache/ivy/core/IvyContext.java index ab73511..b26d69e 100644 --- a/src/java/org/apache/ivy/core/IvyContext.java +++ b/src/java/org/apache/ivy/core/IvyContext.java @@ -41,13 +41,13 @@ import org.apache.ivy.util.MessageLogger; */ public class IvyContext { - private static ThreadLocal/* <Stack<IvyContext>> */current = new ThreadLocal(); + private static ThreadLocal<Stack<IvyContext>> current = new ThreadLocal<>(); private Ivy defaultIvy; - private WeakReference/* <Ivy> */ivy = new WeakReference(null); + private WeakReference<Ivy> ivy = new WeakReference<>(null); - private Map contextMap = new HashMap(); + private Map<String, Object> contextMap = new HashMap<>(); private Thread operatingThread; @@ -61,24 +61,24 @@ public class IvyContext { public IvyContext(IvyContext ctx) { defaultIvy = ctx.defaultIvy; ivy = ctx.ivy; - contextMap = new HashMap(ctx.contextMap); + contextMap = new HashMap<>(ctx.contextMap); operatingThread = ctx.operatingThread; resolveData = ctx.resolveData; dd = ctx.dd; } public static IvyContext getContext() { - Stack cur = getCurrentStack(); + Stack<IvyContext> cur = getCurrentStack(); if (cur.isEmpty()) { cur.push(new IvyContext()); } - return (IvyContext) cur.peek(); + return cur.peek(); } - private static Stack/* <IvyContext> */getCurrentStack() { - Stack cur = (Stack) current.get(); + private static Stack<IvyContext> getCurrentStack() { + Stack<IvyContext> cur = current.get(); if (cur == null) { - cur = new Stack(); + cur = new Stack<>(); current.set(cur); } return cur; @@ -133,7 +133,7 @@ public class IvyContext { * @return the popped context */ public static IvyContext popContext() { - return (IvyContext) getCurrentStack().pop(); + return getCurrentStack().pop(); } /** @@ -153,9 +153,9 @@ public class IvyContext { */ public static Object peekInContextStack(String key) { Object value = null; - Stack contextStack = getCurrentStack(); + Stack<IvyContext> contextStack = getCurrentStack(); for (int i = contextStack.size() - 1; i >= 0 && value == null; i--) { - IvyContext ctx = (IvyContext) contextStack.get(i); + IvyContext ctx = contextStack.get(i); value = ctx.peek(key); } return value; @@ -191,8 +191,7 @@ public class IvyContext { * @return the current ivy instance, or <code>null</code> if there is no current ivy instance. */ public Ivy peekIvy() { - Ivy ivy = (Ivy) this.ivy.get(); - return ivy; + return this.ivy.get(); } private Ivy getDefaultIvy() { @@ -209,7 +208,7 @@ public class IvyContext { } public void setIvy(Ivy ivy) { - this.ivy = new WeakReference(ivy); + this.ivy = new WeakReference<>(ivy); operatingThread = Thread.currentThread(); } @@ -221,13 +220,14 @@ public class IvyContext { return getSettings().getCircularDependencyStrategy(); } - public Object get(String key) { - WeakReference ref = (WeakReference) contextMap.get(key); - return ref == null ? null : ref.get(); + @SuppressWarnings("unchecked") + public <T> T get(String key) { + WeakReference<T> ref = (WeakReference<T>) contextMap.get(key); + return (ref == null) ? null : ref.get(); } - public void set(String key, Object value) { - contextMap.put(key, new WeakReference(value)); + public <T> void set(String key, T value) { + contextMap.put(key, new WeakReference<>(value)); } /** @@ -238,6 +238,7 @@ public class IvyContext { * context key for the string * @return top object from the list (index 0) or null if no key or list empty */ + @SuppressWarnings("unchecked") public Object peek(String key) { synchronized (contextMap) { Object o = contextMap.get(key); @@ -245,11 +246,10 @@ public class IvyContext { return null; } if (o instanceof List) { - if (((List) o).size() == 0) { + if (((List<Object>) o).size() == 0) { return null; } - Object ret = ((List) o).get(0); - return ret; + return ((List<Object>) o).get(0); } else { throw new RuntimeException("Cannot top from non List object " + o); } @@ -264,6 +264,7 @@ public class IvyContext { * context key for the string * @return top object from the list (index 0) or null if no key or list empty */ + @SuppressWarnings("unchecked") public Object pop(String key) { synchronized (contextMap) { Object o = contextMap.get(key); @@ -271,11 +272,10 @@ public class IvyContext { return null; } if (o instanceof List) { - if (((List) o).size() == 0) { + if (((List<Object>) o).size() == 0) { return null; } - Object ret = ((List) o).remove(0); - return ret; + return ((List<Object>) o).remove(0); } else { throw new RuntimeException("Cannot pop from non List object " + o); } @@ -293,6 +293,7 @@ public class IvyContext { * expected value of the key * @return true if the r */ + @SuppressWarnings("unchecked") public boolean pop(String key, Object expectedValue) { synchronized (contextMap) { Object o = contextMap.get(key); @@ -300,14 +301,14 @@ public class IvyContext { return false; } if (o instanceof List) { - if (((List) o).size() == 0) { + if (((List<Object>) o).size() == 0) { return false; } - Object top = ((List) o).get(0); + Object top = ((List<Object>) o).get(0); if (!top.equals(expectedValue)) { return false; } - ((List) o).remove(0); + ((List<Object>) o).remove(0); return true; } else { throw new RuntimeException("Cannot pop from non List object " + o); @@ -330,11 +331,11 @@ public class IvyContext { public void push(String key, Object value) { synchronized (contextMap) { if (!contextMap.containsKey(key)) { - contextMap.put(key, new LinkedList()); + contextMap.put(key, new LinkedList<>()); } Object o = contextMap.get(key); if (o instanceof List) { - ((List) o).add(0, value); + ((List<Object>) o).add(0, value); } else { throw new RuntimeException("Cannot push to non List object " + o); } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/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 e8fb47e..70bebcd 100644 --- a/src/java/org/apache/ivy/core/IvyPatternHelper.java +++ b/src/java/org/apache/ivy/core/IvyPatternHelper.java @@ -19,7 +19,6 @@ package org.apache.ivy.core; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Stack; @@ -118,20 +117,19 @@ public final class IvyPatternHelper { } public static String substitute(String pattern, String org, String module, String revision, - String artifact, String type, String ext, String conf, Map extraModuleAttributes, - Map extraArtifactAttributes) { + String artifact, String type, String ext, String conf, Map<String, String> extraModuleAttributes, + Map<String, String> extraArtifactAttributes) { return substitute(pattern, org, module, null, revision, artifact, type, ext, conf, null, extraModuleAttributes, extraArtifactAttributes); } public static String substitute(String pattern, String org, String module, String branch, String revision, String artifact, String type, String ext, String conf, - ArtifactOrigin origin, Map extraModuleAttributes, Map extraArtifactAttributes) { - Map tokens = new HashMap(); + ArtifactOrigin origin, Map<String, String> extraModuleAttributes, Map<String, String> extraArtifactAttributes) { + Map<String, Object> tokens = new HashMap<>(); if (extraModuleAttributes != null) { - for (Iterator entries = extraModuleAttributes.entrySet().iterator(); entries.hasNext();) { - Map.Entry entry = (Map.Entry) entries.next(); - String token = (String) entry.getKey(); + for (Map.Entry<String, String> entry : extraModuleAttributes.entrySet()) { + String token = entry.getKey(); if (token.indexOf(':') > 0) { token = token.substring(token.indexOf(':') + 1); } @@ -139,10 +137,8 @@ public final class IvyPatternHelper { } } if (extraArtifactAttributes != null) { - for (Iterator entries = extraArtifactAttributes.entrySet().iterator(); entries - .hasNext();) { - Map.Entry entry = (Map.Entry) entries.next(); - String token = (String) entry.getKey(); + for (Map.Entry<String, String> entry : extraArtifactAttributes.entrySet()) { + String token = entry.getKey(); if (token.indexOf(':') > 0) { token = token.substring(token.indexOf(':') + 1); } @@ -172,16 +168,16 @@ public final class IvyPatternHelper { // CheckStyle:ParameterNumber ON - public static String substituteVariables(String pattern, Map variables) { - return substituteVariables(pattern, new IvyVariableContainerImpl(variables), new Stack()); + public static String substituteVariables(String pattern, Map<String, String> variables) { + return substituteVariables(pattern, new IvyVariableContainerImpl(variables), new Stack<String>()); } public static String substituteVariables(String pattern, IvyVariableContainer variables) { - return substituteVariables(pattern, variables, new Stack()); + return substituteVariables(pattern, variables, new Stack<String>()); } private static String substituteVariables(String pattern, IvyVariableContainer variables, - Stack substituting) { + Stack<String> substituting) { // if you supply null, null is what you get if (pattern == null) { return null; @@ -201,7 +197,7 @@ public final class IvyPatternHelper { if (val != null) { int index = substituting.indexOf(var); if (index != -1) { - List cycle = new ArrayList(substituting.subList(index, substituting.size())); + List<String> cycle = new ArrayList<>(substituting.subList(index, substituting.size())); cycle.add(var); throw new IllegalArgumentException("cyclic variable definition: cycle = " + cycle); @@ -222,8 +218,9 @@ public final class IvyPatternHelper { } } + @SuppressWarnings({"rawtypes", "unchecked"}) public static String substituteTokens(String pattern, Map tokens) { - Map tokensCopy = new HashMap(tokens); + Map<String, Object> tokensCopy = new HashMap<>(tokens); if (tokensCopy.containsKey(ORGANISATION_KEY) && !tokensCopy.containsKey(ORGANISATION_KEY2)) { tokensCopy.put(ORGANISATION_KEY2, tokensCopy.get(ORGANISATION_KEY)); } @@ -233,7 +230,7 @@ public final class IvyPatternHelper { tokensCopy.put(ORGANISATION_PATH_KEY, org == null ? "" : org.replace('.', '/')); } - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); char[] chars = pattern.toCharArray(); @@ -367,12 +364,12 @@ public final class IvyPatternHelper { return "[" + token + "]"; } - public static String substituteParams(String pattern, Map params) { - return substituteParams(pattern, new IvyVariableContainerImpl(params), new Stack()); + public static String substituteParams(String pattern, Map<String, String> params) { + return substituteParams(pattern, new IvyVariableContainerImpl(params), new Stack<String>()); } private static String substituteParams(String pattern, IvyVariableContainer params, - Stack substituting) { + Stack<String> substituting) { // TODO : refactor this with substituteVariables // if you supply null, null is what you get if (pattern == null) { @@ -388,7 +385,7 @@ public final class IvyPatternHelper { if (val != null) { int index = substituting.indexOf(var); if (index != -1) { - List cycle = new ArrayList(substituting.subList(index, substituting.size())); + List<String> cycle = new ArrayList<>(substituting.subList(index, substituting.size())); cycle.add(var); throw new IllegalArgumentException("cyclic param definition: cycle = " + cycle); } @@ -420,7 +417,7 @@ public final class IvyPatternHelper { private String revision; - private Map extraModuleAttributes; + private Map<String, String> extraModuleAttributes; // artifact properties private String artifactName; @@ -429,14 +426,14 @@ public final class IvyPatternHelper { private String artifactExt; - private Map extraArtifactAttributes; + private Map<String, String> extraArtifactAttributes; // cached origin; private ArtifactOrigin origin; public OriginalArtifactNameValue(String org, String moduleName, String branch, String revision, String artifactName, String artifactType, String artifactExt, - Map extraModuleAttributes, Map extraArtifactAttributes) { + Map<String, String> extraModuleAttributes, Map<String, String> extraArtifactAttributes) { this.org = org; this.moduleName = moduleName; this.branch = branch; http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java b/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java index b3449a2..e65a683 100644 --- a/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java +++ b/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java @@ -150,7 +150,7 @@ public class ArtifactOrigin { if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { + if (!(o instanceof ArtifactOrigin)) { return false; } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java b/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java index 1a1fa0f..c0d2eb5 100644 --- a/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java +++ b/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java @@ -119,7 +119,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv private Boolean useOrigin; - private ModuleRules<Long> ttlRules = new ModuleRules<Long>(); + private ModuleRules<Long> ttlRules = new ModuleRules<>(); private Long defaultTTL = null; @@ -127,7 +127,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv private PackagingManager packagingManager = new PackagingManager(); - private final List<ConfiguredTTL> configuredTTLs = new ArrayList<ConfiguredTTL>(); + private final List<ConfiguredTTL> configuredTTLs = new ArrayList<>(); public DefaultRepositoryCacheManager() { } @@ -202,17 +202,17 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv public long getDefaultTTL() { if (defaultTTL == null) { - defaultTTL = Long.valueOf(parseDuration(settings.getVariable("ivy.cache.ttl.default"))); + defaultTTL = parseDuration(settings.getVariable("ivy.cache.ttl.default")); } - return defaultTTL.longValue(); + return defaultTTL; } public void setDefaultTTL(long defaultTTL) { - this.defaultTTL = Long.valueOf(defaultTTL); + this.defaultTTL = defaultTTL; } public void setDefaultTTL(String defaultTTL) { - this.defaultTTL = Long.valueOf(parseDuration(defaultTTL)); + this.defaultTTL = parseDuration(defaultTTL); } public String getDataFilePattern() { @@ -254,7 +254,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv } public void addTTL(Map<String, String> attributes, PatternMatcher matcher, long duration) { - ttlRules.defineRule(new MapMatcher(attributes, matcher), new Long(duration)); + ttlRules.defineRule(new MapMatcher(attributes, matcher), duration); } public void addConfiguredTtl(final Map<String, String> attributes) { @@ -330,7 +330,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv return getSettings() != null && Boolean .parseBoolean(getSettings().getVariable("ivy.resolver.default.check.modified")); } - return checkmodified.booleanValue(); + return checkmodified; } public void setCheckmodified(boolean check) { @@ -937,7 +937,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv public long getTTL(ModuleRevisionId mrid) { Long ttl = ttlRules.getRule(mrid); - return ttl == null ? getDefaultTTL() : ttl.longValue(); + return ttl == null ? getDefaultTTL() : ttl; } @Override @@ -1128,7 +1128,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv } } else { long start = System.currentTimeMillis(); - origin.setLastChecked(new Long(start)); + origin.setLastChecked(start); try { ResolvedResource artifactRef = new ResolvedResource(resource, Ivy.getWorkingRevision()); @@ -1216,7 +1216,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv ArtifactOrigin savedOrigin, ArtifactOrigin origin, long ttl) { long time = System.currentTimeMillis(); if (savedOrigin.getLastChecked() != null - && (time - savedOrigin.getLastChecked().longValue()) < ttl) { + && (time - savedOrigin.getLastChecked()) < ttl) { // still in the ttl period, no need to check, trust the cache return archiveFile.exists() || !savedOrigin.isExists(); } @@ -1224,7 +1224,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv // the the file doesn't exist in the cache, obviously not up to date return false; } - origin.setLastChecked(Long.valueOf(time)); + origin.setLastChecked(time); // check if the local resource is up to date regarding the remote one return archiveFile.lastModified() >= resource.getLastModified(); } @@ -1580,7 +1580,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv private static final class ConfiguredTTL { // attributes on the TTL, that don't contribute to module matching - private static final Set<String> attributesNotContributingToMatching = new HashSet<String>(); + private static final Set<String> attributesNotContributingToMatching = new HashSet<>(); static { attributesNotContributingToMatching.add("duration"); attributesNotContributingToMatching.add("matcher"); @@ -1596,7 +1596,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv if (attributes == null) { this.attributes = Collections.emptyMap(); } else { - final Map<String, String> attrs = new HashMap<String, String>(attributes); + final Map<String, String> attrs = new HashMap<>(attributes); for (final String removable : attributesNotContributingToMatching) { attrs.remove(removable); } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/cache/DefaultResolutionCacheManager.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/core/cache/DefaultResolutionCacheManager.java b/src/java/org/apache/ivy/core/cache/DefaultResolutionCacheManager.java index d1ccfc3..2d08c44 100644 --- a/src/java/org/apache/ivy/core/cache/DefaultResolutionCacheManager.java +++ b/src/java/org/apache/ivy/core/cache/DefaultResolutionCacheManager.java @@ -136,7 +136,7 @@ public class DefaultResolutionCacheManager implements ResolutionCacheManager, Iv final String suffix = ".xml"; return getResolutionCacheRoot().listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { - return (name.startsWith(prefix) && name.endsWith(suffix)); + return name.startsWith(prefix) && name.endsWith(suffix); } }); } @@ -195,22 +195,21 @@ public class DefaultResolutionCacheManager implements ResolutionCacheManager, Iv private void saveLocalParents(ModuleRevisionId baseMrevId, ModuleDescriptor md, File mdFile, Properties paths) throws ParseException, IOException { - ExtendsDescriptor[] parents = md.getInheritedDescriptors(); - for (int i = 0; i < parents.length; i++) { - if (!parents[i].isLocal()) { + for (ExtendsDescriptor parent : md.getInheritedDescriptors()) { + if (!parent.isLocal()) { // we store only local parents in the cache! continue; } - ModuleDescriptor parent = parents[i].getParentMd(); + ModuleDescriptor parentMd = parent.getParentMd(); ModuleRevisionId pRevId = ModuleRevisionId.newInstance(baseMrevId, baseMrevId.getRevision() + "-parent." + paths.size()); File parentFile = getResolvedIvyFileInCache(pRevId); - parent.toIvyFile(parentFile); + parentMd.toIvyFile(parentFile); - paths.setProperty(mdFile.getName() + "|" + parents[i].getLocation(), + paths.setProperty(mdFile.getName() + "|" + parent.getLocation(), parentFile.getAbsolutePath()); - saveLocalParents(baseMrevId, parent, parentFile, paths); + saveLocalParents(baseMrevId, parentMd, parentFile, paths); } } @@ -226,9 +225,9 @@ public class DefaultResolutionCacheManager implements ResolutionCacheManager, Iv private ParserSettings delegate; - private Map parentPaths; + private Map<Object, Object> parentPaths; - public CacheParserSettings(ParserSettings delegate, Map parentPaths) { + public CacheParserSettings(ParserSettings delegate, Map<Object, Object> parentPaths) { this.delegate = delegate; this.parentPaths = parentPaths; } @@ -237,7 +236,7 @@ public class DefaultResolutionCacheManager implements ResolutionCacheManager, Iv return delegate.substitute(value); } - public Map substitute(Map strings) { + public Map<String, String> substitute(Map<String, String> strings) { return delegate.substitute(strings); } @@ -288,18 +287,18 @@ public class DefaultResolutionCacheManager implements ResolutionCacheManager, Iv private static final class MapURLResolver extends RelativeUrlResolver { - private Map paths; + private Map<Object, Object> paths; private RelativeUrlResolver delegate; - private MapURLResolver(Map paths, RelativeUrlResolver delegate) { + private MapURLResolver(Map<Object, Object> paths, RelativeUrlResolver delegate) { this.paths = paths; this.delegate = delegate; } public URL getURL(URL context, String url) throws MalformedURLException { String path = context.getPath(); - if (path.indexOf('/') >= 0) { + if (path.contains("/")) { String file = path.substring(path.lastIndexOf('/') + 1); if (paths.containsKey(file + "|" + url)) { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/cache/ModuleDescriptorMemoryCache.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/core/cache/ModuleDescriptorMemoryCache.java b/src/java/org/apache/ivy/core/cache/ModuleDescriptorMemoryCache.java index cd2b0bd..357c130 100644 --- a/src/java/org/apache/ivy/core/cache/ModuleDescriptorMemoryCache.java +++ b/src/java/org/apache/ivy/core/cache/ModuleDescriptorMemoryCache.java @@ -37,7 +37,7 @@ class ModuleDescriptorMemoryCache { private final int maxSize; - private final LinkedHashMap/* <File,CacheEntry> */valueMap; + private final LinkedHashMap<File, CacheEntry> valueMap; /** * Create a cache of the given size @@ -46,7 +46,7 @@ class ModuleDescriptorMemoryCache { */ public ModuleDescriptorMemoryCache(int size) { this.maxSize = size; - this.valueMap = new LinkedHashMap(size); + this.valueMap = new LinkedHashMap<>(size); } public ModuleDescriptor get(File ivyFile, ParserSettings ivySettings, boolean validated, @@ -76,7 +76,7 @@ class ModuleDescriptorMemoryCache { // cache is disabled return null; } - CacheEntry entry = (CacheEntry) valueMap.get(ivyFile); + CacheEntry entry = valueMap.get(ivyFile); if (entry != null) { if (entry.isStale(validated, ivySettings)) { Message.debug("Entry is found in the ModuleDescriptorCache but entry should be " @@ -104,7 +104,7 @@ class ModuleDescriptorMemoryCache { } if (valueMap.size() >= maxSize) { Message.debug("ModuleDescriptorCache is full, remove one entry"); - Iterator it = valueMap.values().iterator(); + Iterator<CacheEntry> it = valueMap.values().iterator(); it.next(); it.remove(); } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/cache/ParserSettingsMonitor.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/core/cache/ParserSettingsMonitor.java b/src/java/org/apache/ivy/core/cache/ParserSettingsMonitor.java index c0a971d..f383578 100644 --- a/src/java/org/apache/ivy/core/cache/ParserSettingsMonitor.java +++ b/src/java/org/apache/ivy/core/cache/ParserSettingsMonitor.java @@ -19,10 +19,8 @@ package org.apache.ivy.core.cache; import java.io.File; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; -import java.util.Map.Entry; import org.apache.ivy.core.RelativeUrlResolver; import org.apache.ivy.core.module.id.ModuleId; @@ -50,11 +48,11 @@ class ParserSettingsMonitor { private ParserSettings delegatedSettings; - private final Map/* <String,String> */substitutes; + private final Map<String, String> substitutes; public ParserSettingsMonitor(ParserSettings settings) { this.delegatedSettings = settings; - this.substitutes = new HashMap(); + this.substitutes = new HashMap<>(); } /** @@ -79,13 +77,10 @@ class ParserSettingsMonitor { * Only the info that was actually used is compared. */ public boolean hasChanged(ParserSettings newSettings) { - for (Iterator it = substitutes.entrySet().iterator(); it.hasNext();) { - Map.Entry entry = (Entry) it.next(); - String key = (String) entry.getKey(); - Object oldValue = entry.getValue(); - String newValue = newSettings.substitute(key); - if (!oldValue.equals(newValue)) { - Message.debug("settings variable has changed for : " + entry.getKey()); + for (Map.Entry<String, String> entry : substitutes.entrySet()) { + String key = entry.getKey(); + if (!entry.getValue().equals(newSettings.substitute(key))) { + Message.debug("settings variable has changed for : " + key); return true; } } @@ -134,11 +129,10 @@ class ParserSettingsMonitor { return delegatedSettings.getContextNamespace(); } - public Map substitute(Map strings) { - Map substituted = new LinkedHashMap(); - for (Iterator it = strings.entrySet().iterator(); it.hasNext();) { - Map.Entry entry = (Map.Entry) it.next(); - substituted.put(entry.getKey(), substitute((String) entry.getValue())); + public Map<String, String> substitute(Map<String, String> strings) { + Map<String, String> substituted = new LinkedHashMap<>(); + for (Map.Entry<String, String> entry : strings.entrySet()) { + substituted.put(entry.getKey(), substitute(entry.getValue())); } return substituted; }
