Author: xavier
Date: Thu Aug 28 05:48:19 2008
New Revision: 689804
URL: http://svn.apache.org/viewvc?rev=689804&view=rev
Log:
improve source and javadoc artifacts detection in poms, to avoid considering
the main artifact as being also javadoc and source artifact, when the pattern
used for artifacts doesn't use neither type nor classifier token (related to
IVY-325 and IVYDE-117)
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/CacheResolver.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java?rev=689804&r1=689803&r2=689804&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
Thu Aug 28 05:48:19 2008
@@ -181,6 +181,8 @@
private ModuleRevisionId mrid;
+ private DefaultArtifact mainArtifact;
+
public PomModuleDescriptorBuilder(ModuleDescriptorParser parser, Resource
res) {
ivyModuleDescriptor = new DefaultModuleDescriptor(parser, res);
@@ -212,7 +214,7 @@
}
- public void addArtifact(String artifactId, String packaging) {
+ public void addMainArtifact(String artifactId, String packaging) {
String ext;
if ("pom".equals(packaging)) {
// no artifact defined!
@@ -238,8 +240,8 @@
}
}
- ivyModuleDescriptor.addArtifact("master",
- new DefaultArtifact(mrid, new Date(), artifactId, packaging,
ext));
+ mainArtifact = new DefaultArtifact(mrid, new Date(), artifactId,
packaging, ext);
+ ivyModuleDescriptor.addArtifact("master", mainArtifact);
}
@@ -487,6 +489,9 @@
addExtraInfo(getPropertyExtraInfoKey(propertyName), value);
}
+ public Artifact getMainArtifact() {
+ return mainArtifact;
+ }
public Artifact getSourceArtifact() {
return new MDArtifact(
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java?rev=689804&r1=689803&r2=689804&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
Thu Aug 28 05:48:19 2008
@@ -241,7 +241,7 @@
mdBuilder.addPlugin(plugin);
}
- mdBuilder.addArtifact(artifactId , domReader.getPackaging());
+ mdBuilder.addMainArtifact(artifactId ,
domReader.getPackaging());
addSourcesAndJavadocArtifactsIfPresent(mdBuilder, ivySettings);
}
@@ -263,15 +263,17 @@
Message.debug("no resolver found for " + mrid
+ ": no source or javadoc artifact lookup");
} else {
- Artifact sourceArtifact = mdBuilder.getSourceArtifact();
- if (resolver.exists(sourceArtifact)) {
+ String mainArtifact = resolver.locate(mdBuilder.getMainArtifact());
+
+ String sourceArtifact =
resolver.locate(mdBuilder.getSourceArtifact());
+ if (sourceArtifact != null &&
!sourceArtifact.equals(mainArtifact)) {
Message.debug("source artifact found for " + mrid);
mdBuilder.addSourceArtifact();
} else {
Message.debug("no source artifact found for " + mrid);
}
- Artifact javadocArtifact = mdBuilder.getJavadocArtifact();
- if (resolver.exists(javadocArtifact)) {
+ String javadocArtifact =
resolver.locate(mdBuilder.getJavadocArtifact());
+ if (javadocArtifact != null &&
!javadocArtifact.equals(mainArtifact)) {
Message.debug("javadoc artifact found for " + mrid);
mdBuilder.addJavadocArtifact();
} else {
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java?rev=689804&r1=689803&r2=689804&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
Thu Aug 28 05:48:19 2008
@@ -191,11 +191,15 @@
return getClass().getName();
}
+ public boolean exists(Artifact artifact) {
+ return locate(artifact) != null;
+ }
+
/**
* Default implementation actually download the artifact Subclasses should
overwrite this to
* avoid the download
*/
- public boolean exists(Artifact artifact) {
+ public String locate(Artifact artifact) {
DownloadReport dr = download(new Artifact[] {artifact}, new
DownloadOptions());
if (dr == null) {
/*
@@ -207,7 +211,8 @@
+ " when trying to download " + artifact);
}
ArtifactDownloadReport adr = dr.getArtifactReport(artifact);
- return adr.getDownloadStatus() != DownloadStatus.FAILED;
+ return adr.getDownloadStatus() == DownloadStatus.FAILED ||
adr.getArtifactOrigin() == null
+ ? null : adr.getArtifactOrigin().getLocation();
}
public LatestStrategy getLatestStrategy() {
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java?rev=689804&r1=689803&r2=689804&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
Thu Aug 28 05:48:19 2008
@@ -739,6 +739,14 @@
}
return false;
}
+
+ public String locate(Artifact artifact) {
+ ResolvedResource artifactRef = getArtifactRef(artifact, null);
+ if (artifactRef != null && artifactRef.getResource().exists()) {
+ return artifactRef.getResource().getName();
+ }
+ return null;
+ }
protected long getPublicationDate(ModuleDescriptor md,
DependencyDescriptor dd,
ResolveData data) {
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/CacheResolver.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/CacheResolver.java?rev=689804&r1=689803&r2=689804&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/CacheResolver.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/CacheResolver.java
Thu Aug 28 05:48:19 2008
@@ -129,6 +129,11 @@
ensureConfigured();
return super.exists(artifact);
}
+
+ public String locate(Artifact artifact) {
+ ensureConfigured();
+ return super.locate(artifact);
+ }
public void publish(Artifact artifact, File src, boolean overwrite) throws
IOException {
ensureConfigured();
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java?rev=689804&r1=689803&r2=689804&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java
Thu Aug 28 05:48:19 2008
@@ -301,7 +301,7 @@
}
return false;
}
-
+
private static void setLatest(DependencyResolver resolver, LatestStrategy
latest) {
if (resolver instanceof HasLatestStrategy) {
HasLatestStrategy r = (HasLatestStrategy) resolver;
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java?rev=689804&r1=689803&r2=689804&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
Thu Aug 28 05:48:19 2008
@@ -91,8 +91,28 @@
*/
DownloadReport download(Artifact[] artifacts, DownloadOptions options);
+ /**
+ * Returns <code>true</code> if the given artifact can be located by this
resolver and
+ * actually exist.
+ *
+ * @param artifact
+ * the artifact which should be tested.
+ * @return <code>true</code> if the given artifact can be located by this
resolver and
+ * actually exist.
+ */
boolean exists(Artifact artifact);
+ /**
+ * Locates the given artifact and returns a String identifying its
location if it can be located
+ * by this resolver and if it actually exists, or <code>null</code> in
other cases.
+ *
+ * @param artifact
+ * the artifact which should be located
+ * @return a String identifying the artifact location, or
<code>null</code> if it can't be
+ * located or doesn't exist.
+ */
+ String locate(Artifact artifact);
+
void publish(Artifact artifact, File src, boolean overwrite) throws
IOException;
void beginPublishTransaction(ModuleRevisionId module, boolean overwrite)
throws IOException;
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java?rev=689804&r1=689803&r2=689804&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java
Thu Aug 28 05:48:19 2008
@@ -160,6 +160,10 @@
public boolean exists(Artifact artifact) {
return artifactResolver.exists(artifact);
}
+
+ public String locate(Artifact artifact) {
+ return artifactResolver.locate(artifact);
+ }
public boolean isAllownomd() {
return allownomd;
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java?rev=689804&r1=689803&r2=689804&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java
Thu Aug 28 05:48:19 2008
@@ -507,6 +507,11 @@
ensureConfigured(getSettings());
return super.exists(artifact);
}
+
+ public String locate(Artifact artifact) {
+ ensureConfigured(getSettings());
+ return super.locate(artifact);
+ }
public List getArtifactPatterns() {
ensureConfigured(getSettings());
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java?rev=689804&r1=689803&r2=689804&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java
Thu Aug 28 05:48:19 2008
@@ -290,6 +290,11 @@
ensureArtifactConfigured(getSettings());
return super.exists(artifact);
}
+
+ public String locate(Artifact artifact) {
+ ensureArtifactConfigured(getSettings());
+ return super.locate(artifact);
+ }
public List getIvyPatterns() {
ensureIvyConfigured(getSettings());