Author: maartenc
Date: Thu Jun 18 21:54:09 2009
New Revision: 786304
URL: http://svn.apache.org/viewvc?rev=786304&view=rev
Log:
FIX: [originalname] not expanded during retrieve when module descriptor
contains extra attributes (IVY-1096)
Added:
ant/ivy/core/trunk/test/repositories/2/mod15.3/
ant/ivy/core/trunk/test/repositories/2/mod15.3/ivy-1.1.xml
ant/ivy/core/trunk/test/repositories/2/mod15.3/library.jar (with props)
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyReport.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/packager/PackagerCacheEntry.java
ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
ant/ivy/core/trunk/test/repositories/2/mod15.2/ivy-1.1.xml
Modified: ant/ivy/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=786304&r1=786303&r2=786304&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Thu Jun 18 21:54:09 2009
@@ -94,6 +94,7 @@
- IMPROVEMENT: Standalone runner should accept all the same parameters as ant
tasks (IVY-1090)
- IMPROVEMENT: Pre and post retrieve artifact events (IVY-1084)
+- FIX: [originalname] not expanded during retrieve when module descriptor
contains extra attributes (IVY-1096)
- FIX: The Ant output wasn't always prefixed by the name of the task
- FIX: Ivy buildnumber task does not find artifact in Sonatype Nexus repo
(IVY-1069)
- FIX: Publish with SSH (sftp or ssh) prevents enclosing java process to
terminate (IVY-1075)
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyReport.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyReport.java?rev=786304&r1=786303&r2=786304&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyReport.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyReport.java Thu Jun 18
21:54:09 2009
@@ -297,7 +297,7 @@
return IvyPatternHelper.substitute(
outputpattern, mRevId.getOrganisation(), mRevId.getName(),
- mRevId.getRevision(), "", "", ext, conf, mRevId.getAttributes());
+ mRevId.getRevision(), "", "", ext, conf, mRevId.getAttributes(),
null);
}
private void genStyled(String[] confs, File style, String ext) throws
IOException {
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java?rev=786304&r1=786303&r2=786304&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java Thu
Jun 18 21:54:09 2009
@@ -70,13 +70,13 @@
public static String substitute(String pattern, ModuleRevisionId
moduleRevision) {
return substitute(pattern, moduleRevision.getOrganisation(),
moduleRevision.getName(),
moduleRevision.getBranch(), moduleRevision.getRevision(), "ivy",
"ivy", "xml", null,
- null, moduleRevision.getAttributes());
+ null, moduleRevision.getAttributes(), null);
}
public static String substitute(String pattern, ModuleRevisionId
moduleRevision,
String artifact, String type, String ext) {
return substitute(pattern, moduleRevision, new
DefaultArtifact(moduleRevision, null,
- artifact, type, ext), null);
+ artifact, type, ext));
}
public static String substitute(String pattern, Artifact artifact) {
@@ -84,60 +84,54 @@
}
public static String substitute(String pattern, Artifact artifact,
ArtifactOrigin origin) {
- return substitute(pattern, artifact.getModuleRevisionId(), artifact,
null, origin);
+ return substitute(pattern, artifact.getModuleRevisionId(), artifact,
(String) null, origin);
}
public static String substitute(String pattern, Artifact artifact, String
conf) {
- return substitute(pattern, artifact.getModuleRevisionId(), artifact,
conf);
+ return substitute(pattern, artifact.getModuleRevisionId(), artifact,
conf, (ArtifactOrigin) null);
}
public static String substitute(String pattern, ModuleRevisionId mrid,
Artifact artifact) {
- return substitute(pattern, mrid, artifact, null);
- }
-
- public static String substitute(String pattern, ModuleRevisionId mrid,
Artifact artifact,
- String conf) {
- return substitute(pattern, mrid, artifact, conf, null);
+ return substitute(pattern, mrid, artifact, (String) null,
(ArtifactOrigin) null);
}
public static String substitute(String pattern, ModuleRevisionId mrid,
Artifact artifact,
String conf, ArtifactOrigin origin) {
- Map attributes = new HashMap();
- attributes.putAll(mrid.getAttributes());
- attributes.putAll(artifact.getAttributes());
return substitute(pattern, mrid.getOrganisation(), mrid.getName(),
mrid.getBranch(), mrid
.getRevision(), artifact.getName(), artifact.getType(),
artifact.getExt(), conf,
- origin, attributes);
+ origin, mrid.getExtraAttributes(), artifact.getExtraAttributes());
}
public static String substitute(String pattern, String org, String module,
String revision,
String artifact, String type, String ext) {
- return substitute(pattern, org, module, revision, artifact, type, ext,
null);
+ return substitute(pattern, org, module, (String) null, revision,
artifact, type, ext, (String) null,
+ (ArtifactOrigin) null, (Map) null, (Map) null);
}
// CheckStyle:ParameterNumber OFF
public static String substitute(String pattern, String org, String module,
String revision,
String artifact, String type, String ext, String conf) {
- return substitute(pattern, org, module, revision, artifact, type, ext,
conf, null);
+ return substitute(pattern, org, module, (String) null, revision,
artifact, type, ext, conf,
+ (ArtifactOrigin) null, (Map) null, (Map) null);
}
public static String substitute(String pattern, String org, String module,
String revision,
- String artifact, String type, String ext, String conf, Map
extraAttributes) {
- return substitute(pattern, org, module, revision, artifact, type, ext,
conf, null,
- extraAttributes);
- }
-
- public static String substitute(String pattern, String org, String module,
String revision,
- String artifact, String type, String ext, String conf,
ArtifactOrigin origin,
- Map extraAttributes) {
- return substitute(pattern, org, module, null, revision, artifact,
type, ext, conf, origin,
- extraAttributes);
+ String artifact, String type, String ext, String conf, Map
extraModuleAttributes,
+ Map extraArtifactAttributes) {
+ return substitute(pattern, org, module, (String) null, revision,
artifact, type, ext, conf,
+ (ArtifactOrigin) 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 extraAttributes) {
- Map tokens = new HashMap(extraAttributes == null ?
Collections.EMPTY_MAP : extraAttributes);
+ ArtifactOrigin origin, Map extraModuleAttributes, Map
extraArtifactAttributes) {
+ Map tokens = new HashMap();
+ if (extraModuleAttributes != null) {
+ tokens.putAll(extraModuleAttributes);
+ }
+ if (extraArtifactAttributes != null) {
+ tokens.putAll(extraArtifactAttributes);
+ }
tokens.put(ORGANISATION_KEY, org == null ? "" : org);
tokens.put(ORGANISATION_KEY2, org == null ? "" : org);
tokens.put(MODULE_KEY, module == null ? "" : module);
@@ -147,9 +141,13 @@
tokens.put(TYPE_KEY, type == null ? "jar" : type);
tokens.put(EXT_KEY, ext == null ? "jar" : ext);
tokens.put(CONF_KEY, conf == null ? "default" : conf);
- tokens.put(ORIGINAL_ARTIFACTNAME_KEY, origin == null ? new
OriginalArtifactNameValue(org,
- module, branch, revision, artifact, type, ext) : new
OriginalArtifactNameValue(
- origin));
+ if (origin == null) {
+ tokens.put(ORIGINAL_ARTIFACTNAME_KEY, new
OriginalArtifactNameValue(org,
+ module, branch, revision, artifact, type, ext,
extraModuleAttributes, extraArtifactAttributes));
+ } else {
+ tokens.put(ORIGINAL_ARTIFACTNAME_KEY, new
OriginalArtifactNameValue(origin));
+ }
+
return substituteTokens(pattern, tokens);
}
// CheckStyle:ParameterNumber ON
@@ -400,18 +398,23 @@
private String revision;
+ private Map extraModuleAttributes;
+
// artifact properties
private String artifactName;
private String artifactType;
private String artifactExt;
+
+ private Map extraArtifactAttributes;
// cached origin;
private ArtifactOrigin origin;
-
+
public OriginalArtifactNameValue(String org, String moduleName, String
branch,
- String revision, String artifactName, String artifactType,
String artifactExt) {
+ String revision, String artifactName, String artifactType,
String artifactExt,
+ Map extraModuleAttributes, Map extraArtifactAttributes) {
this.org = org;
this.moduleName = moduleName;
this.branch = branch;
@@ -419,6 +422,8 @@
this.artifactName = artifactName;
this.artifactType = artifactType;
this.artifactExt = artifactExt;
+ this.extraModuleAttributes = extraModuleAttributes;
+ this.extraArtifactAttributes = extraArtifactAttributes;
}
/**
@@ -432,9 +437,9 @@
public String toString() {
if (origin == null) {
ModuleRevisionId revId = ModuleRevisionId.newInstance(org,
moduleName, branch,
- revision);
+ revision, extraModuleAttributes);
Artifact artifact = new DefaultArtifact(revId, null,
artifactName, artifactType,
- artifactExt);
+ artifactExt, extraArtifactAttributes);
// TODO cache: see how we could know which actual cache
manager to use, since this
// will fail when using a resolver in a chain with a specific
cache manager
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/packager/PackagerCacheEntry.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/packager/PackagerCacheEntry.java?rev=786304&r1=786303&r2=786304&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/packager/PackagerCacheEntry.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/packager/PackagerCacheEntry.java
Thu Jun 18 21:54:09 2009
@@ -218,7 +218,7 @@
private String getResourceURL() {
String baseURL = IvyPatternHelper.substitute(this.resourceURL,
this.mr.getOrganisation(),
this.mr.getName(), this.mr.getRevision(), null, null, null, null,
- this.mr.getAttributes());
+ this.mr.getAttributes(), null);
int slash = baseURL.lastIndexOf('/');
if (slash != -1) {
baseURL = baseURL.substring(0, slash + 1);
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java?rev=786304&r1=786303&r2=786304&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
(original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
Thu Jun 18 21:54:09 2009
@@ -129,6 +129,40 @@
.endsWith("mod14.1-1.1.jar"));
}
+ public void testResolveWithRetainingArtifactNameAndExtraAttributes()
throws Exception {
+ ((DefaultRepositoryCacheManager)
settings.getDefaultRepositoryCacheManager())
+
.setArtifactPattern(ivy.substitute("[module]/[originalname].[ext]"));
+ ResolveReport report = ivy.resolve(new
File("test/repositories/2/mod15.4/ivy-1.1.xml")
+ .toURL(), getResolveOptions(new String[]
{"default"}).setValidate(false));
+ assertNotNull(report);
+
+ Map extra = new HashMap();
+ extra.put("extra", "foo");
+ ArtifactDownloadReport[] dReports =
report.getConfigurationReport("default")
+ .getDownloadReports(ModuleRevisionId.newInstance("org15",
"mod15.3", "1.1", extra));
+ assertNotNull(dReports);
+ assertEquals("number of downloaded artifacts not correct", 1,
dReports.length);
+
+ Artifact artifact = dReports[0].getArtifact();
+ assertNotNull(artifact);
+
+ String cachePath = getArchivePathInCache(artifact);
+ assertTrue("artifact name has not been retained: " + cachePath,
cachePath
+ .endsWith("library.jar"));
+
+ dReports = report.getConfigurationReport("default").getDownloadReports(
+ ModuleRevisionId.newInstance("org14", "mod14.1", "1.1"));
+ assertNotNull(dReports);
+ assertEquals("number of downloaded artifacts not correct", 1,
dReports.length);
+
+ artifact = dReports[0].getArtifact();
+ assertNotNull(artifact);
+
+ cachePath = getArchivePathInCache(artifact);
+ assertTrue("artifact name has not been retained: " + cachePath,
cachePath
+ .endsWith("mod14.1-1.1.jar"));
+ }
+
public void testArtifactOrigin() throws Exception {
ResolveReport report = ivy.resolve(new File(
"test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURL(),
Modified: ant/ivy/core/trunk/test/repositories/2/mod15.2/ivy-1.1.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/2/mod15.2/ivy-1.1.xml?rev=786304&r1=786303&r2=786304&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/repositories/2/mod15.2/ivy-1.1.xml (original)
+++ ant/ivy/core/trunk/test/repositories/2/mod15.2/ivy-1.1.xml Thu Jun 18
21:54:09 2009
@@ -18,13 +18,13 @@
-->
<ivy-module version="1.0">
<info organisation="org15"
- module="mod15.2"
+ module="mod15.4"
revision="1.1"
status="integration"
publication="20050930110000"
/>
<dependencies>
- <dependency org="org15" name="mod15.1" rev="1.1"
conf="default->default"/>
- <dependency org="org14" name="mod14.1" rev="1.1"
conf="default->default" transitive="false" />
+ <dependency org="org15" name="mod15.3" rev="1.1"
conf="default->default"/>
+ <dependency org="org14" name="mod14.1" rev="1.1"
conf="default->default" transitive="false" />
</dependencies>
</ivy-module>
Added: ant/ivy/core/trunk/test/repositories/2/mod15.3/ivy-1.1.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/2/mod15.3/ivy-1.1.xml?rev=786304&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/2/mod15.3/ivy-1.1.xml (added)
+++ ant/ivy/core/trunk/test/repositories/2/mod15.3/ivy-1.1.xml Thu Jun 18
21:54:09 2009
@@ -0,0 +1,30 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<ivy-module version="1.0">
+ <info organisation="org15"
+ module="mod15.3"
+ revision="1.1"
+ status="integration"
+ publication="20050930110000"
+ extra="foo"
+ />
+ <publications>
+ <artifact name="library" type="jar" conf="default" />
+ </publications>
+</ivy-module>
Added: ant/ivy/core/trunk/test/repositories/2/mod15.3/library.jar
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/2/mod15.3/library.jar?rev=786304&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ant/ivy/core/trunk/test/repositories/2/mod15.3/library.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream