ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1507801 - in /ant/ivy/core/trunk: ./ doc/ doc/use/ src/java/org/apache/ivy/ant/ src/java/org/apache/ivy/core/report/ test/java/org/apache/ivy/core/report/
Date Sun, 28 Jul 2013 14:09:36 GMT
Author: hibou
Date: Sun Jul 28 14:09:36 2013
New Revision: 1507801

URL: http://svn.apache.org/r1507801
Log:
- improve the fixdeps task to handle a multi project environment
- add tests and documentation of the task

Added:
    ant/ivy/core/trunk/test/java/org/apache/ivy/core/report/
    ant/ivy/core/trunk/test/java/org/apache/ivy/core/report/ResolveReportTest.java   (with
props)
Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/doc/toc.json
    ant/ivy/core/trunk/doc/use/fixdeps.html
    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/FixDepsTask.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=1507801&r1=1507800&r2=1507801&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Sun Jul 28 14:09:36 2013
@@ -139,6 +139,7 @@ for detailed view of each issue, please 
 =====================================
 - DOCUMENTATION: Broken link in <dependency> documentation (IVY-1405)
 
+- NEW: fixdeps task: serializes transitively resolved dependencies into an ivy.xml file
 - NEW: IvyDependencyTree task : display a dependency tree on the console
 - NEW: Support Conditional Setting of a Property (IVY-1367)
 - NEW: Exposing some parent metadata (organisation, module, revision, branch) as properties
(IVY-1288)

Modified: ant/ivy/core/trunk/doc/toc.json
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/toc.json?rev=1507801&r1=1507800&r2=1507801&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/toc.json (original)
+++ ant/ivy/core/trunk/doc/toc.json Sun Jul 28 14:09:36 2013
@@ -751,6 +751,13 @@
                             ]
                         },
                         {
+                          "id":"use/fixdeps",
+                          "title":"fixdeps",
+                          "children": [
+
+                            ]
+                        },
+                        {
                           "id":"use/info",
                           "title":"info",
                           "children": [

Modified: ant/ivy/core/trunk/doc/use/fixdeps.html
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/use/fixdeps.html?rev=1507801&r1=1507800&r2=1507801&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/use/fixdeps.html (original)
+++ ant/ivy/core/trunk/doc/use/fixdeps.html Sun Jul 28 14:09:36 2013
@@ -26,11 +26,20 @@
 <body>
 	<textarea id="xooki-source">
 <span class="since">since 2.4</span>
-From some resolved dependencies against an ivy.xml, generate another ivy.xml which will have
all transitive dependencies declared at the resolved revision.
+The <tt>fixdeps</tt> task serializes transitively resolved dependencies into
an ivy.xml file. 
 
-This task is usefull to always resolve the same set of dependencies. From an ivy.xml where
dependencies are declared with ranges and the immediate required modules, <tt>fixdeps</tt>
will produce an ivy.xml with all dependencies, with fixed versions, and no more transitive
resolve to do.
+The dependencies declared in an ivy.xml can be specified as range of revisions. And the transitive
dependencies too. As new versions of modules can be added to the repository anytime, resolved
versions of ranges can change over time. It is then safer to resolve a range once and stick
with the resolved revision. This way a resolve process is highly reproductible.
 
-Nota Bene: this task is not suited to be used in a multi project environement where some
dependencies still need to be maintained loose: the one between the projects.
+It is especially useful in a very dynamic environment like the <a href="../osgi.html">OSGi</a>
one.
+
+In a multi project environment some dependencies still need to be maintained loose: the one
between the projects. These dependencies, as soon as they are declared in the original ivy.xml,
can be kept from being fixed. In order to do so, use the inner element <tt>keep</tt>.
+
+The recommended setup is then to:
+<ul>
+<li>have an <tt>ivy-spec.xml</tt> in your project which specifies the dependencies,
with ranges if needed</li>
+<li>have an Ant target which resolve the <tt>ivy-spec.xml</tt> and call
<tt>fixdeps</tt> to generate an <tt>ivy.xml</tt>. This target should
then only be called after <tt>ivy-spec.xml</tt> is modified. The generated <tt>ivy.xml</tt>
can safely be shared in a version control repository (svn, git,...).</li>
+<li>make the entire build workflow based on the resolve of the generated <tt>ivy.xml</tt></li>
+</ul>
 
 This is a [[ant:postresolvetask post resolve task]], with all the behaviour and attributes
common to all post resolve tasks.
 
@@ -45,10 +54,34 @@ This is a [[ant:postresolvetask post res
 </tbody>
 </table>
 
+<h1>Child elements</h1>
+
+<table class="ant">
+<thead>
+    <tr><th class="ant-att">Element</th><th class="ant-desc">Description</th><th
class="ant-req">Cardinality</th></tr>
+</thead>
+<tbody>
+    <tr><td>keep</td><td>declares a dependency to keep from being
fixed, and keep its original declaration from the original ivy.xml
+    <br/>These elements takes two attributes: <ul><li>org</li> the
organization<li>module</li>the name of the module</ul></td>
+        <td>0..n</td></tr>
+</tbody>
+</table>
+
 <h1>Examples</h1>
+
 <code type="xml">
 <ivy:fixdeps tofile="ivy-fixed.xml" />
 </code>
+Simple fix of some dependencies.
+
+<hr/>
+
+<code type="xml">
+<ivy:fixdeps tofile="ivy-fixed.xml">
+    <keep org="com.acme" module="mymodule" />
+</ivy:fixdeps>
+</code>
+Fix of the dependencies but keep the dependency on <tt>com.acme#mymodule</tt>
as defined in the original ivy.xml.
 
 	</textarea>
 <script type="text/javascript">xooki.postProcess();</script>

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/FixDepsTask.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/FixDepsTask.java?rev=1507801&r1=1507800&r2=1507801&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/FixDepsTask.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/FixDepsTask.java Sun Jul 28 14:09:36 2013
@@ -19,8 +19,11 @@ package org.apache.ivy.ant;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.report.ResolveReport;
 import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorWriter;
 import org.apache.tools.ant.BuildException;
@@ -29,10 +32,33 @@ public class FixDepsTask extends IvyPost
 
     private File dest;
 
+    private List/* <Keep> */keeps = new ArrayList();
+
     public void setToFile(File dest) {
         this.dest = dest;
     }
 
+    public static class Keep {
+
+        private String org;
+
+        private String module;
+
+        public void setOrg(String org) {
+            this.org = org;
+        }
+
+        public void setModule(String module) {
+            this.module = module;
+        }
+    }
+
+    public Keep createKeep() {
+        Keep k = new Keep();
+        keeps.add(k);
+        return k;
+    }
+
     public void doExecute() throws BuildException {
         prepareAndCheck();
 
@@ -45,7 +71,13 @@ public class FixDepsTask extends IvyPost
         }
 
         ResolveReport report = getResolvedReport();
-        ModuleDescriptor md = report.toFixedModuleDescriptor(getSettings());
+
+        List/*<ModuleId>*/ midToKeep = new ArrayList();
+        for (int i = 0; i < keeps.size(); i++) {
+            midToKeep.add(ModuleId.newInstance(((Keep) keeps.get(i)).org, ((Keep) keeps.get(i)).module));

+        }
+        
+        ModuleDescriptor md = report.toFixedModuleDescriptor(getSettings(), midToKeep);
         try {
             XmlModuleDescriptorWriter.write(md, dest);
         } catch (IOException e) {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java?rev=1507801&r1=1507800&r2=1507801&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java Sun Jul 28 14:09:36
2013
@@ -22,28 +22,25 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Date;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.ivy.core.cache.ResolutionCacheManager;
 import org.apache.ivy.core.module.descriptor.Configuration;
 import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
 import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
-import org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor;
 import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
-import org.apache.ivy.core.module.descriptor.ExcludeRule;
-import org.apache.ivy.core.module.descriptor.IncludeRule;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
-import org.apache.ivy.core.module.id.ArtifactId;
 import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.resolve.IvyNode;
 import org.apache.ivy.core.resolve.ResolveOptions;
 import org.apache.ivy.core.settings.IvySettings;
-import org.apache.ivy.plugins.namespace.Namespace;
 import org.apache.ivy.plugins.report.ReportOutputter;
 import org.apache.ivy.util.filter.Filter;
 
@@ -61,9 +58,9 @@ public class ResolveReport {
     /**
      * the list of all dependencies resolved, ordered from the more dependent to the less
dependent
      */
-    private List/*<IvyNode>*/ dependencies = new ArrayList();
+    private List/* <IvyNode> */dependencies = new ArrayList();
 
-    private List/*<Artifact>*/ artifacts = new ArrayList();
+    private List/* <Artifact> */artifacts = new ArrayList();
 
     private long resolveTime;
 
@@ -103,9 +100,8 @@ public class ResolveReport {
         return hasError;
     }
 
-    public void output(
-            ReportOutputter[] outputters, ResolutionCacheManager cacheMgr, ResolveOptions
options)
-            throws IOException {
+    public void output(ReportOutputter[] outputters, ResolutionCacheManager cacheMgr,
+            ResolveOptions options) throws IOException {
         for (int i = 0; i < outputters.length; i++) {
             outputters[i].output(this, cacheMgr, options);
         }
@@ -139,8 +135,8 @@ public class ResolveReport {
      * @return the list of reports, never <code>null</code>
      */
     public ArtifactDownloadReport[] getFailedArtifactsReports() {
-        return ConfigurationResolveReport.filterOutMergedArtifacts(
-            getArtifactsReports(DownloadStatus.FAILED, true));
+        return ConfigurationResolveReport.filterOutMergedArtifacts(getArtifactsReports(
+            DownloadStatus.FAILED, true));
     }
 
     /**
@@ -157,8 +153,8 @@ public class ResolveReport {
      * specific download status, and also remove the download report for the evicted modules.
      * 
      * @param downloadStatus
-     *            the status of download to retreive. Set it to <code>null</code>
for no
-     *            restriction on the download status
+     *            the status of download to retreive. Set it to <code>null</code>
for no restriction
+     *            on the download status
      * @param withEvicted
      *            set it to <code>true</code> if the report for the evicted modules
have to be
      *            retrieved, <code>false</code> to exclude reports from modules
evicted in all
@@ -166,13 +162,13 @@ public class ResolveReport {
      * @return the list of reports, never <code>null</code>
      * @see ConfigurationResolveReport#getArtifactsReports(DownloadStatus, boolean)
      */
-    public ArtifactDownloadReport[] getArtifactsReports(
-            DownloadStatus downloadStatus, boolean withEvicted) {
+    public ArtifactDownloadReport[] getArtifactsReports(DownloadStatus downloadStatus,
+            boolean withEvicted) {
         Collection all = new LinkedHashSet();
         for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
             ConfigurationResolveReport report = (ConfigurationResolveReport) iter.next();
-            ArtifactDownloadReport[] reports = 
-                report.getArtifactsReports(downloadStatus, withEvicted);
+            ArtifactDownloadReport[] reports = report.getArtifactsReports(downloadStatus,
+                withEvicted);
             all.addAll(Arrays.asList(reports));
         }
         return (ArtifactDownloadReport[]) all.toArray(new ArtifactDownloadReport[all.size()]);
@@ -187,7 +183,6 @@ public class ResolveReport {
         return (ArtifactDownloadReport[]) all.toArray(new ArtifactDownloadReport[all.size()]);
     }
 
-    
     public void checkIfChanged() {
         for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
             ConfigurationResolveReport report = (ConfigurationResolveReport) iter.next();
@@ -195,7 +190,6 @@ public class ResolveReport {
         }
     }
 
-    
     /** Can only be called if checkIfChanged has been called */
     public boolean hasChanged() {
         for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
@@ -332,7 +326,51 @@ public class ResolveReport {
         return resolveId;
     }
 
-    public ModuleDescriptor toFixedModuleDescriptor(IvySettings settings) {
+    /**
+     * Get every configuration which extends the specified one. The returned list also includes
the
+     * specified one.
+     * 
+     * @param extended
+     * @return
+     */
+    private String[] getExtendingConfs(String extended) {
+        String[] allConfs = md.getConfigurationsNames();
+        Set/* <String> */extendingConfs = new HashSet();
+        extendingConfs.add(extended);
+        for (int i = 0; i < allConfs.length; i++) {
+            gatherExtendingConfs(extendingConfs, allConfs[i], extended);
+        }
+        return (String[]) extendingConfs.toArray(new String[extendingConfs.size()]);
+    }
+
+    private boolean gatherExtendingConfs(Set/* <String> */extendingConfs, String conf,
+            String extended) {
+        if (extendingConfs.contains(conf)) {
+            return true;
+        }
+        String[] ext = md.getConfiguration(conf).getExtends();
+        if (ext == null || ext.length == 0) {
+            return false;
+        }
+        for (int i = 0; i < ext.length; i++) {
+            if (extendingConfs.contains(ext[i])) {
+                extendingConfs.add(conf);
+                return true;
+            }
+            if (ext[i].equals(extended)) {
+                extendingConfs.add(conf);
+                return true;
+            }
+            if (gatherExtendingConfs(extendingConfs, ext[i], extended)) {
+                extendingConfs.add(conf);
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public ModuleDescriptor toFixedModuleDescriptor(IvySettings settings,
+            List/* <ModuleId> */midToKeep) {
         DefaultModuleDescriptor fixedmd = new DefaultModuleDescriptor(md.getModuleRevisionId(),
                 md.getStatus(), new Date());
 
@@ -342,9 +380,34 @@ public class ResolveReport {
             fixedmd.addConfiguration(new Configuration(resolvedConf[i]));
         }
 
-        // get dependencies
+        if (midToKeep != null && !midToKeep.isEmpty()) {
+            // add dependency we want to keep from the original module descriptor
+            DependencyDescriptor[] deps = md.getDependencies();
+            for (int i = 0; i < deps.length; i++) {
+                if (midToKeep.contains(deps[i].getDependencyId())) {
+                    DefaultDependencyDescriptor dep = new DefaultDependencyDescriptor(fixedmd,
+                            deps[i].getDependencyRevisionId(), true, false, false);
+                    String[] confs = deps[i].getModuleConfigurations();
+                    for (int j = 0; j < confs.length; j++) {
+                        String[] extendedConf = getExtendingConfs(confs[j]);
+                        String[] depConfs = deps[i].getDependencyConfigurations(confs[j]);
+                        for (int k = 0; k < extendedConf.length; k++) {
+                            for (int l = 0; l < depConfs.length; l++) {
+                                dep.addDependencyConfiguration(extendedConf[k], depConfs[l]);
+                            }
+                        }
+                    }
+                    fixedmd.addDependency(dep);
+                }
+            }
+        }
+
+        // add resolved dependencies
         for (int i = 0; i < dependencies.size(); i++) {
             IvyNode node = (IvyNode) dependencies.get(i);
+            if (midToKeep != null && midToKeep.contains(node.getModuleId())) {
+                continue;
+            }
             String[] rootConfs = node.getRootModuleConfigurations();
             for (int j = 0; j < rootConfs.length; j++) {
                 if (node.isEvicted(rootConfs[j])) {

Added: ant/ivy/core/trunk/test/java/org/apache/ivy/core/report/ResolveReportTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/report/ResolveReportTest.java?rev=1507801&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/report/ResolveReportTest.java (added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/report/ResolveReportTest.java Sun Jul
28 14:09:36 2013
@@ -0,0 +1,204 @@
+/*
+ *  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.
+ *
+ */
+package org.apache.ivy.core.report;
+
+import java.io.File;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+import org.apache.ivy.Ivy;
+import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.resolve.ResolveOptions;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.util.CacheCleaner;
+import org.apache.ivy.util.FileUtil;
+
+public class ResolveReportTest extends TestCase {
+
+    private Ivy ivy;
+
+    private File cache;
+
+    private File deliverDir;
+
+    private File workDir;
+
+    protected void setUp() throws Exception {
+        cache = new File("build/cache");
+        System.setProperty("ivy.cache.dir", cache.getAbsolutePath());
+        createCache();
+
+        deliverDir = new File("build/test/deliver");
+        deliverDir.mkdirs();
+
+        workDir = new File("build/test/work");
+        workDir.mkdirs();
+
+        ivy = Ivy.newInstance();
+        ivy.configure(new File("test/repositories/ivysettings.xml"));
+    }
+
+    private void createCache() {
+        cache.mkdirs();
+    }
+
+    protected void tearDown() throws Exception {
+        CacheCleaner.deleteDir(cache);
+        FileUtil.forceDelete(deliverDir);
+        FileUtil.forceDelete(workDir);
+    }
+
+    private ResolveOptions getResolveOptions(String[] confs) {
+        return getResolveOptions(ivy.getSettings(), confs);
+    }
+
+    private ResolveOptions getResolveOptions(IvySettings settings, String[] confs) {
+        return new ResolveOptions().setConfs(confs);
+    }
+
+    private void checkFixedMdDependency(DependencyDescriptor dep, String org, String mod,
+            String rev, String conf, String[] targetConfs) {
+        assertEquals(ModuleRevisionId.newInstance(org, mod, rev), dep.getDependencyRevisionId());
+        assertEquals(Arrays.asList(new String[] {conf}),
+            Arrays.asList(dep.getModuleConfigurations()));
+        assertEquals(Arrays.asList(targetConfs),
+            Arrays.asList(dep.getDependencyConfigurations(conf)));
+    }
+
+    public void testFixedMdSimple() throws Exception {
+        ResolveReport report = ivy.resolve(new File(
+                "test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"),
+            getResolveOptions(new String[] {"*"}));
+        assertNotNull(report);
+        assertFalse(report.hasError());
+        ModuleDescriptor fixedMd = report.toFixedModuleDescriptor(ivy.getSettings(), null);
+
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
+        assertEquals(mrid, fixedMd.getModuleRevisionId());
+
+        assertEquals(Arrays.asList(new String[] {"default"}),
+            Arrays.asList(fixedMd.getConfigurationsNames()));
+
+        assertEquals(1, fixedMd.getDependencies().length);
+        checkFixedMdDependency(fixedMd.getDependencies()[0], "org1", "mod1.2", "2.0", "default",
+            new String[] {"*"});
+    }
+
+    public void testFixedMdTransitiveDependencies() throws Exception {
+        // mod2.1 depends on mod1.1 which depends on mod1.2
+        ResolveReport report = ivy.resolve(new File(
+                "test/repositories/1/org2/mod2.1/ivys/ivy-0.3.xml"),
+            getResolveOptions(new String[] {"*"}));
+        assertNotNull(report);
+        assertFalse(report.hasError());
+        ModuleDescriptor fixedMd = report.toFixedModuleDescriptor(ivy.getSettings(), null);
+
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.1", "0.3");
+        assertEquals(mrid, fixedMd.getModuleRevisionId());
+
+        assertEquals(Arrays.asList(new String[] {"default"}),
+            Arrays.asList(fixedMd.getConfigurationsNames()));
+
+        assertEquals(2, fixedMd.getDependencies().length);
+
+        checkFixedMdDependency(fixedMd.getDependencies()[0], "org1", "mod1.1", "1.0", "default",
+            new String[] {"*"});
+        checkFixedMdDependency(fixedMd.getDependencies()[1], "org1", "mod1.2", "2.0", "default",
+            new String[] {"*"});
+    }
+
+    public void testFixedMdMultipleExtends() throws Exception {
+        // mod6.2 has two confs default and extension
+        // mod6.2 depends on mod6.1 in conf (default->extension)
+        // conf extension extends default
+        // mod6.1 has two confs default and extension
+        // mod6.1 depends on mod1.2 2.0 in conf (default->default)
+        // conf extension extends default
+        ResolveReport report = ivy.resolve(new File(
+                "test/repositories/1/org6/mod6.2/ivys/ivy-0.3.xml"),
+            getResolveOptions(new String[] {"default", "extension"}));
+        assertNotNull(report);
+        assertFalse(report.hasError());
+        ModuleDescriptor fixedMd = report.toFixedModuleDescriptor(ivy.getSettings(), null);
+
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.2", "0.3");
+        assertEquals(mrid, fixedMd.getModuleRevisionId());
+
+        assertEquals(Arrays.asList(new String[] {"default", "extension"}),
+            Arrays.asList(fixedMd.getConfigurationsNames()));
+
+        assertEquals(4, fixedMd.getDependencies().length);
+
+        checkFixedMdDependency(fixedMd.getDependencies()[0], "org6", "mod6.1", "0.4", "extension",
+            new String[] {"extension", "default"});
+        checkFixedMdDependency(fixedMd.getDependencies()[1], "org6", "mod6.1", "0.4", "default",
+            new String[] {"extension", "default"});
+        checkFixedMdDependency(fixedMd.getDependencies()[2], "org1", "mod1.2", "2.0", "extension",
+            new String[] {"default"});
+        checkFixedMdDependency(fixedMd.getDependencies()[3], "org1", "mod1.2", "2.0", "default",
+            new String[] {"default"});
+    }
+
+    public void testFixedMdRange() throws Exception {
+        ResolveReport report = ivy.resolve(new File(
+                "test/repositories/1/org1/mod1.4/ivys/ivy-1.0.2.xml"),
+            getResolveOptions(new String[] {"*"}));
+        assertNotNull(report);
+        assertFalse(report.hasError());
+        ModuleDescriptor fixedMd = report.toFixedModuleDescriptor(ivy.getSettings(), null);
+
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.4", "1.0.2");
+        assertEquals(mrid, fixedMd.getModuleRevisionId());
+
+        assertEquals(Arrays.asList(new String[] {"default", "compile"}),
+            Arrays.asList(fixedMd.getConfigurationsNames()));
+
+        assertEquals(2, fixedMd.getDependencies().length);
+
+        checkFixedMdDependency(fixedMd.getDependencies()[0], "org1", "mod1.2", "1.1", "default",
+            new String[] {"*"});
+        checkFixedMdDependency(fixedMd.getDependencies()[1], "org1", "mod1.2", "1.1", "compile",
+            new String[] {"default"});
+    }
+
+    public void testFixedMdKeep() throws Exception {
+        ResolveReport report = ivy.resolve(new File(
+                "test/repositories/1/org1/mod1.4/ivys/ivy-1.0.2.xml"),
+            getResolveOptions(new String[] {"*"}));
+        assertNotNull(report);
+        assertFalse(report.hasError());
+        ModuleDescriptor fixedMd = report.toFixedModuleDescriptor(ivy.getSettings(),
+            Arrays.asList(new ModuleId[] {ModuleId.newInstance("org1", "mod1.2")}));
+
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.4", "1.0.2");
+        assertEquals(mrid, fixedMd.getModuleRevisionId());
+
+        assertEquals(Arrays.asList(new String[] {"default", "compile"}),
+            Arrays.asList(fixedMd.getConfigurationsNames()));
+
+        assertEquals(1, fixedMd.getDependencies().length);
+
+        checkFixedMdDependency(fixedMd.getDependencies()[0], "org1", "mod1.2", "[1.0,2.0[",
"*",
+            new String[] {"*"});
+    }
+
+}

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/core/report/ResolveReportTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/core/report/ResolveReportTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/core/report/ResolveReportTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message