Repository: ant-ivy Updated Branches: refs/heads/master da7d5df6d -> 12d3f2818
IVY-1529 Add ivy.maven.sources.lookup and ivy.maven.javadoc.lookup variables to control the lookup of the additional artifacts. Defaults to true, for backward compatibility Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/12d3f281 Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/12d3f281 Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/12d3f281 Branch: refs/heads/master Commit: 12d3f281814ad5be2d1012b9ea41781414724529 Parents: da7d5df Author: qxo <[email protected]> Authored: Wed Jul 15 19:47:22 2015 +0800 Committer: Nicolas Lalevée <[email protected]> Committed: Sun Aug 30 17:12:32 2015 +0200 ---------------------------------------------------------------------- doc/release-notes.html | 1 + .../cache/DefaultResolutionCacheManager.java | 4 ++ .../ivy/core/cache/ParserSettingsMonitor.java | 4 ++ .../ivy/plugins/parser/ParserSettings.java | 1 + .../parser/m2/PomModuleDescriptorParser.java | 55 +++++++++++++------- .../ivy/plugins/resolver/AbstractResolver.java | 4 ++ 6 files changed, 50 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/12d3f281/doc/release-notes.html ---------------------------------------------------------------------- diff --git a/doc/release-notes.html b/doc/release-notes.html index b29528c..63c4fcf 100644 --- a/doc/release-notes.html +++ b/doc/release-notes.html @@ -64,6 +64,7 @@ List of changes since Ivy 2.4.0: - IMPROVEMENT: Optimization: limit the revision numbers scanned if revision prefix is specified (Thanks to Ernestas Vaiciukevičius) - NEW: Lets ssh-based resolvers use an ~/.ssh/config file to find username/hostname/keyfile options (Thanks to Colin Stanfill) +- NEW: Add ivy.maven.sources.lookup and ivy.maven.javadoc.lookup variables to control the lookup of the additional artifacts. Defaults to true, for backward compatibility (IVY-1529) <!-- Samples : - NEW: bla bla bla (IVY-1234) (Thanks to Jane Doe) http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/12d3f281/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 2683702..d6bc2d7 100644 --- a/src/java/org/apache/ivy/core/cache/DefaultResolutionCacheManager.java +++ b/src/java/org/apache/ivy/core/cache/DefaultResolutionCacheManager.java @@ -274,6 +274,10 @@ public class DefaultResolutionCacheManager implements ResolutionCacheManager, Iv public Namespace getContextNamespace() { return delegate.getContextNamespace(); } + + public String getVariable(String value) { + return delegate.getVariable(value); + } } private static class MapURLResolver extends RelativeUrlResolver { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/12d3f281/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 58c7f31..35da0bd 100644 --- a/src/java/org/apache/ivy/core/cache/ParserSettingsMonitor.java +++ b/src/java/org/apache/ivy/core/cache/ParserSettingsMonitor.java @@ -150,5 +150,9 @@ class ParserSettingsMonitor { } return r; } + + public String getVariable(String value) { + return delegatedSettings.getVariable(value); + } }; } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/12d3f281/src/java/org/apache/ivy/plugins/parser/ParserSettings.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/plugins/parser/ParserSettings.java b/src/java/org/apache/ivy/plugins/parser/ParserSettings.java index fc10fd3..662736c 100644 --- a/src/java/org/apache/ivy/plugins/parser/ParserSettings.java +++ b/src/java/org/apache/ivy/plugins/parser/ParserSettings.java @@ -59,4 +59,5 @@ public interface ParserSettings { */ Namespace getContextNamespace(); + String getVariable(String string); } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/12d3f281/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 f4d6206..f2d3cfc 100644 --- a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java +++ b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java @@ -315,6 +315,14 @@ public final class PomModuleDescriptorParser implements ModuleDescriptorParser { // no main artifact in pom, we don't need to search for meta artifacts return; } + + boolean sourcesLookup = !"false".equals(ivySettings.getVariable("ivy.maven.lookup.sources")); + boolean javadocLookup = !"false".equals(ivySettings.getVariable("ivy.maven.lookup.javadoc")); + if (!sourcesLookup && !javadocLookup) { + Message.debug("Sources and javadocs lookup disabled"); + return; + } + ModuleDescriptor md = mdBuilder.getModuleDescriptor(); ModuleRevisionId mrid = md.getModuleRevisionId(); DependencyResolver resolver = ivySettings.getResolver(mrid); @@ -328,30 +336,39 @@ public final class PomModuleDescriptorParser implements ModuleDescriptorParser { if (!ArtifactOrigin.isUnknown(mainArtifact)) { String mainArtifactLocation = mainArtifact.getLocation(); - ArtifactOrigin sourceArtifact = resolver.locate(mdBuilder.getSourceArtifact()); - if (!ArtifactOrigin.isUnknown(sourceArtifact) - && !sourceArtifact.getLocation().equals(mainArtifactLocation)) { - Message.debug("source artifact found for " + mrid); - mdBuilder.addSourceArtifact(); - } else { - // it seems that sometimes the 'src' classifier is used instead of 'sources' - // Cfr. IVY-1138 - ArtifactOrigin srcArtifact = resolver.locate(mdBuilder.getSrcArtifact()); - if (!ArtifactOrigin.isUnknown(srcArtifact) - && !srcArtifact.getLocation().equals(mainArtifactLocation)) { + if (sourcesLookup) { + ArtifactOrigin sourceArtifact = resolver.locate(mdBuilder.getSourceArtifact()); + if (!ArtifactOrigin.isUnknown(sourceArtifact) + && !sourceArtifact.getLocation().equals(mainArtifactLocation)) { Message.debug("source artifact found for " + mrid); - mdBuilder.addSrcArtifact(); + mdBuilder.addSourceArtifact(); } else { - Message.debug("no source artifact found for " + mrid); + // it seems that sometimes the 'src' classifier is used instead of 'sources' + // Cfr. IVY-1138 + ArtifactOrigin srcArtifact = resolver.locate(mdBuilder.getSrcArtifact()); + if (!ArtifactOrigin.isUnknown(srcArtifact) + && !srcArtifact.getLocation().equals(mainArtifactLocation)) { + Message.debug("source artifact found for " + mrid); + mdBuilder.addSrcArtifact(); + } else { + Message.debug("no source artifact found for " + mrid); + } } + } else { + Message.debug("sources lookup disabled"); } - ArtifactOrigin javadocArtifact = resolver.locate(mdBuilder.getJavadocArtifact()); - if (!ArtifactOrigin.isUnknown(javadocArtifact) - && !javadocArtifact.getLocation().equals(mainArtifactLocation)) { - Message.debug("javadoc artifact found for " + mrid); - mdBuilder.addJavadocArtifact(); + + if (javadocLookup) { + ArtifactOrigin javadocArtifact = resolver.locate(mdBuilder.getJavadocArtifact()); + if (!ArtifactOrigin.isUnknown(javadocArtifact) + && !javadocArtifact.getLocation().equals(mainArtifactLocation)) { + Message.debug("javadoc artifact found for " + mrid); + mdBuilder.addJavadocArtifact(); + } else { + Message.debug("no javadoc artifact found for " + mrid); + } } else { - Message.debug("no javadoc artifact found for " + mrid); + Message.debug("javadocs lookup disabled"); } } } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/12d3f281/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java b/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java index ff0fa3c..6030c9f 100644 --- a/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java +++ b/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java @@ -603,5 +603,9 @@ public abstract class AbstractResolver implements DependencyResolver, HasLatestS return AbstractResolver.this.getSettings().substitute(value); } + public String getVariable(String value) { + return AbstractResolver.this.getSettings().getVariable(value); + } + } }
