Author: xavier Date: Tue Aug 26 07:29:53 2008 New Revision: 689093 URL: http://svn.apache.org/viewvc?rev=689093&view=rev Log: FIX: PackagerResolverTest was failing
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/packager/PackagerCacheEntry.java ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/packager/PackagerResolver.java ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/PackagerResolverTest.java 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=689093&r1=689092&r2=689093&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 Tue Aug 26 07:29:53 2008 @@ -20,6 +20,9 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; import org.apache.ivy.core.IvyPatternHelper; import org.apache.ivy.core.module.descriptor.Artifact; @@ -67,11 +70,17 @@ /** * Attempt to build this entry. - * - * @param packagerXML packager XML input stream - * @throws IllegalStateException if this entry has already been built + * + * @param packagerResource + * packager metadata resource + * @param properties + * a map of properties to pass to the child Ant build responsible for dependency + * packaging + * + * @throws IllegalStateException + * if this entry has already been built */ - public synchronized void build(Resource packagerResource) throws IOException { + public synchronized void build(Resource packagerResource, Map properties) throws IOException { // Sanity check if (this.built) { throw new IllegalStateException("build in directory `" @@ -134,6 +143,12 @@ if (this.validate) { project.setUserProperty("ivy.packager.validate", "true"); } + if (properties != null) { + for (Iterator it = properties.entrySet().iterator(); it.hasNext();) { + Entry entry = (Entry) it.next(); + project.setUserProperty((String) entry.getKey(), (String) entry.getValue()); + } + } // Execute task Message.verbose("performing packager resolver build in " + this.dir); Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/packager/PackagerResolver.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/packager/PackagerResolver.java?rev=689093&r1=689092&r2=689093&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/packager/PackagerResolver.java (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/packager/PackagerResolver.java Tue Aug 26 07:29:53 2008 @@ -23,6 +23,8 @@ import java.util.Date; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; import org.apache.ivy.core.module.descriptor.Artifact; import org.apache.ivy.core.module.descriptor.DefaultArtifact; @@ -51,6 +53,8 @@ private File buildRoot; private File resourceCache; private String resourceURL; + private Map/*<String,String>*/ properties = new LinkedHashMap(); + private boolean validate = true; private boolean preserve; private boolean verbose; @@ -147,6 +151,16 @@ } super.setDescriptor(rule); } + + /** + * Sets a property to be passed to the child Ant build responsible for packaging the dependency. + * + * @param propertyKey the property to pass + * @param propertyValue the value of the property to pass + */ + public void setProperty(String propertyKey, String propertyValue) { + properties.put(propertyKey, propertyValue); + } // @Override public void validate() { @@ -190,7 +204,7 @@ entry = new PackagerCacheEntry(mr, this.buildRoot, this.resourceCache, this.resourceURL, this.validate, this.preserve, this.verbose, this.quiet); try { - entry.build(packager.getResource()); + entry.build(packager.getResource(), properties); } catch (IOException e) { throw new RuntimeException("can't build artifact " + artifact, e); } Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/PackagerResolverTest.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/PackagerResolverTest.java?rev=689093&r1=689092&r2=689093&view=diff ============================================================================== --- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/PackagerResolverTest.java (original) +++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/PackagerResolverTest.java Tue Aug 26 07:29:53 2008 @@ -122,7 +122,8 @@ resolver.setPreserveBuildDirectories(true); resolver.setVerbose(true); - System.setProperty("packager.website.url", new File("test/repositories/packager/website").getAbsoluteFile().toURL().toExternalForm()); + resolver.setProperty("packager.website.url", + new File("test/repositories/packager/website").getAbsoluteFile().toURL().toExternalForm()); resolver.setName("packager"); assertEquals("packager", resolver.getName());