Author: gscokart
Date: Mon Aug  6 08:02:31 2007
New Revision: 563162

URL: http://svn.apache.org/viewvc?view=rev&rev=563162
Log:
IMPROVEMENT: replace * by *(public) when resolving inline (IVY-589)

Modified:
    incubator/ivy/core/trunk/doc/use/postresolvetask.html
    incubator/ivy/core/trunk/doc/use/resolve.html
    incubator/ivy/core/trunk/src/example/go-ivy/build.xml
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java
    
incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java

Modified: incubator/ivy/core/trunk/doc/use/postresolvetask.html
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/doc/use/postresolvetask.html?view=diff&rev=563162&r1=563161&r2=563162
==============================================================================
--- incubator/ivy/core/trunk/doc/use/postresolvetask.html (original)
+++ incubator/ivy/core/trunk/doc/use/postresolvetask.html Mon Aug  6 08:02:31 
2007
@@ -42,11 +42,12 @@
 <li>organisation and module are not set</li>
 </ul>
 
-Since Ivy 1.4, there are two ways to run a [[ant:resolve]]: with an ivy file, 
or with the inline mode.
+<span class="since">Since Ivy 1.4</span>, there are two ways to run a 
[[ant:resolve]]: with an ivy file, or with the inline mode.
 When you call resolve with an ivy file, the default for it is to keep the 
resolved data for use by the subsequent post resolve tasks. When you run an 
inline resolve, the default is not to keep the data. You can override this 
behaviour by setting the keep attribute as you like.
 
 If you want to to reuse the resolved data obtained through a call to resolve 
in another build (i.e. not the current one), then you have to set the 
organisation and module attributes. This work only if the cache was not cleaned 
since your last resolve call. This does not work with inline calls, which must 
be performed in the same build.
 
+
 The attributes listed are then mostly used only if a resolve is triggered 
automatically.
 
 <h1>Attributes</h1>
@@ -55,9 +56,10 @@
     <tr><th class="ant-att">Attribute</th><th 
class="ant-desc">Description</th><th class="ant-req">Required</th></tr>
 </thead>
 <tbody>
-    <tr><td>conf</td><td>a comma separated list of the configurations to 
retrieve</td>
-        <td>No. Defaults to the configurations resolved by the last resolve 
call, or * if no resolve was explicitly called</td></tr>
-    <tr><td>inline</td><td>true to use inline mode, false to resolve an ivy 
file <span class="since">since 1.4</span></td><td>No. defaults false</td></tr>
+    <tr><td>conf</td><td>a comma separated list of the configurations to 
retrieve or '*'.
+<span class="since">Since 2.0</span> you can also use '*(public)' or 
'*(private)'.  Note that '*' is interpreted as '*(public)' when inline is 
true.</td>
+        <td>No. Defaults to the configurations resolved by the last resolve 
call, or '*' if no resolve was explicitly called</td></tr>
+    <tr><td>inline</td><td>true to use inline mode, false to resolve an ivy 
file <span class="since">(since 1.4)</span></td><td>No. defaults false</td></tr>
     <tr><td>organisation</td><td>the organisation of the module to retrieve. 
This usually doesn't need to be set since it defaults to the last resolved one, 
except for inline mode where it is required.</td><td>Yes in inline mode, 
otherwise no, it then defaults to last resolved module name</td></tr>
     <tr><td>module</td><td>the name of the module to retrieve. This usually 
doesn't need to be set since it defaults to the last resolved one, except for 
inline mode where it is required.</td><td>Yes in inline mode, otherwise no, it 
then defaults to last resolved module name</td></tr>
     <tr><td>revision</td><td>the revision constraint of the module to 
retrieve. Used only in inline mode. <span class="since">since 
1.4</span></td><td>No. Defaults to latest.integration</td></tr>

Modified: incubator/ivy/core/trunk/doc/use/resolve.html
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/doc/use/resolve.html?view=diff&rev=563162&r1=563161&r2=563162
==============================================================================
--- incubator/ivy/core/trunk/doc/use/resolve.html (original)
+++ incubator/ivy/core/trunk/doc/use/resolve.html Mon Aug  6 08:02:31 2007
@@ -88,6 +88,7 @@
 <i>Note for developers:
 After the call to this task, a reference to the module descriptor resolved is 
put in the ant project under the id <code>"ivy.resolved.descriptor"</code>.</i>
 
+<h1>Attributes</h1>
 <table class="ant">
 <thead>
     <tr><th class="ant-att">Attribute</th><th 
class="ant-desc">Description</th><th class="ant-req">Required</th></tr>
@@ -95,21 +96,37 @@
 <tbody>
     <tr><td>file</td><td>path to the ivy file to use for resolution</td>
         <td>No. Defaults to ${ivy.dep.file} or nothing in inline mode</td></tr>
-    <tr><td>conf</td><td>a comma separated list of the configurations to 
resolve</td><td>No. Defaults to ${ivy.configurations}</td></tr>
+
+    <tr><td>conf</td><td>a comma separated list of the configurations to 
resolve, or '*'.  
+<span class="since">Since 2.0</span>, you can also use '*(private)', 
'*(public)'.  Note that when inline is true, the configuration '*' is 
equivalent as '*(public)'.</td><td>No. Defaults to 
${ivy.configurations}</td></tr>
+
     <tr><td>useOrigin</td><td>true to avoid the copy of local artifacts to the 
cache and use directly their original location, false otherwise <span 
class="since">since 1.4</span>. 
 To know if an artifact is local ivy asks to the resolver. Only filesystem 
resolver is considered local by default, but this can be disabled if you want 
to force the copy on one filesystem resolver and use the original location on 
another. Note that it is safe to use useOrigin even if you some no local 
resolvers, Ivy will behave as usual in this case. Note also that this only 
applies to artifacts, not to ivy files, which are still copied in the 
cache.</td><td>No. defaults to false</td></tr>
+
     <tr><td>inline</td><td>true to use inline mode, false to resolve an ivy 
file <span class="since">since 1.4</span></td><td>No. defaults to 
false</td></tr>
+
     <tr><td>organisation</td><td>the organisation of the module to resolve in 
inline mode <span class="since">since 1.4</span></td><td>Yes in inline mode, no 
otherwise.</td></tr>
+
     <tr><td>module</td><td>the name of the module to resolve in inline mode 
<span class="since">since 1.4</span></td><td>Yes in inline mode, no 
otherwise.</td></tr>
+
     <tr><td>revision</td><td>the revision constraint to apply to the module to 
resolve in inline mode <span class="since">since 1.4</span></td><td>No. 
Defaults to "latest.integration" in inline mode, nothing in standard 
mode.</td></tr>
+
     <tr><td>type</td><td>comma separated list of accepted artifact types 
(<span class="since">since 1.2</span>)</td><td>No. defaults to 
${ivy.resolve.default.type.filter}</td></tr>
+
     <tr><td>haltonfailure</td><td>true to halt the build on ivy failure, false 
to continue</td><td>No. Defaults to true</td></tr>
+
     <tr><td>failureproperty</td><td>the name of the property to set if the 
resolve failed <span class="since">since 1.4</span></td><td>No. No property is 
set by default.</td></tr>
+
     <tr><td>transitive</td><td>true to resolve dependencies transitively, 
false otherwise <span class="since">since 1.4</span></td><td>No. Defaults to 
true</td></tr>
+
     <tr><td>showprogress</td><td>true to show dots while downloading, false 
otherwise</td><td>No. Defaults to true</td></tr>
+
     <tr><td>validate</td><td>true to force ivy files validation against 
ivy.xsd, false to force no validation</td><td>No. Defaults to default ivy value 
(as configured in configuration file)</td></tr>
+
     <tr><td>settingsRef</td><td>A reference to the ivy settings that must be 
used by this task <span class="since">(since 2.0)</span></td><td>No, 
'ivy.instance' is taken by default.</td></tr>
+
     <tr><td>resolveId</td><td>An id which can be used later to refer to the 
results of this resolve <span class="since">(since 2.0)</span></td><td>No, 
defaults to '[org]-[module]'.</td></tr>
+
 </tbody>
 </table>
 <h1>Examples</h1>

Modified: incubator/ivy/core/trunk/src/example/go-ivy/build.xml
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/example/go-ivy/build.xml?view=diff&rev=563162&r1=563161&r2=563162
==============================================================================
--- incubator/ivy/core/trunk/src/example/go-ivy/build.xml (original)
+++ incubator/ivy/core/trunk/src/example/go-ivy/build.xml Mon Aug  6 08:02:31 
2007
@@ -81,7 +81,7 @@
                <echo message="using ivy to resolve commons-lang 2.1..."/>
         <!-- here comes the magic line: asks ivy to resolve a dependency on 
              commons-lang 2.1 and to build an ant path with it from its cache  
-->
-        <ivy:cachepath organisation="commons-lang" module="commons-lang" 
revision="2.1" conf="default"
+        <ivy:cachepath organisation="commons-lang" module="commons-lang" 
revision="2.1" 
                        pathid="lib.path.id" inline="true"/>
         
                <echo message="compiling..."/>

Modified: 
incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java?view=diff&rev=563162&r1=563161&r2=563162
==============================================================================
--- 
incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java 
(original)
+++ 
incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java 
Mon Aug  6 08:02:31 2007
@@ -109,6 +109,12 @@
             }
             String[] toResolve = getConfsToResolve(getOrganisation(), 
getModule() + "-caller",
                 conf, true);
+            //When we make an inline resolution, we can not resolve private 
confs.
+            for (int i = 0; i < toResolve.length; i++) {
+                if ("*".equals(toResolve[i])) {
+                    toResolve[i] = "*(public)";
+                }
+            }
             if (toResolve.length > 0) {
                 Message.verbose("using inline mode to resolve " + 
getOrganisation() + " "
                         + getModule() + " " + getRevision() + " ("

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java?view=diff&rev=563162&r1=563161&r2=563162
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java 
(original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java Mon 
Aug  6 08:02:31 2007
@@ -186,6 +186,11 @@
                 if (file != null) {
                     throw new BuildException("'file' not allowed when using 
inline mode");
                 }
+                for (int i = 0; i < confs.length; i++) {
+                    if ("*".equals(confs[i])) {
+                        confs[i] = "*(public)";
+                    }
+                }
                 if (revision == null) {
                     revision = "latest.integration";
                 }
@@ -292,11 +297,17 @@
     }
 
     private ResolveOptions getResolveOptions(String[] confs, IvySettings 
settings) {
-        return new 
ResolveOptions().setConfs(confs).setValidate(doValidate(settings))
+        return new ResolveOptions()
+                .setConfs(confs)
+                .setValidate(doValidate(settings))
                 .setArtifactFilter(FilterHelper.getArtifactTypeFilter(type))
-                
.setRevision(revision).setCache(CacheManager.getInstance(settings, cache))
-                .setDate(getPubDate(pubdate, 
null)).setUseCacheOnly(useCacheOnly).setUseOrigin(
-                    
useOrigin).setTransitive(transitive).setResolveId(resolveId);
+                .setRevision(revision)
+                .setCache(CacheManager.getInstance(settings, cache))
+                .setDate(getPubDate(pubdate, null))
+                .setUseCacheOnly(useCacheOnly)
+                .setUseOrigin(useOrigin)
+                .setTransitive(transitive)
+                .setResolveId(resolveId);
     }
 
     public String getModule() {

Modified: 
incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java?view=diff&rev=563162&r1=563161&r2=563162
==============================================================================
--- 
incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java 
(original)
+++ 
incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java 
Mon Aug  6 08:02:31 2007
@@ -786,6 +786,55 @@
                 .exists());
     }
 
+    
+    public void testResolveWithStartPublicConf() throws Exception {
+        // mod2.2 depends on mod1.3 and selects its artifacts
+        ResolveReport report = ivy.resolve(new File(
+                "test/repositories/1/org2/mod2.2/ivys/ivy-0.8.xml").toURL(),
+            getResolveOptions(new String[] {"*(public)"}));
+        assertNotNull(report);
+        ModuleDescriptor md = report.getModuleDescriptor();
+        assertNotNull(md);
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.2", 
"0.8");
+        assertEquals(mrid, md.getModuleRevisionId());
+
+        assertTrue(cacheManager.getResolvedIvyFileInCache(mrid).exists());
+
+        // dependencies
+        assertTrue(cacheManager.getIvyFileInCache(
+            ModuleRevisionId.newInstance("org1", "mod1.3", "3.0")).exists());
+        assertTrue(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3-A", 
"jar", "jar")
+                .exists());
+        assertTrue(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3-B", 
"jar", "jar")
+                .exists());
+        assertTrue(!getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3", 
"jar", "jar")
+                    .exists());
+    }
+
+    public void testResolveWithPrivateConf() throws Exception {
+        // mod2.2 depends on mod1.3 and selects its artifacts
+        ResolveReport report = ivy.resolve(new File(
+                "test/repositories/1/org2/mod2.2/ivys/ivy-0.8.xml").toURL(),
+            getResolveOptions(new String[] {"*(private)"}));
+        assertNotNull(report);
+        ModuleDescriptor md = report.getModuleDescriptor();
+        assertNotNull(md);
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.2", 
"0.8");
+        assertEquals(mrid, md.getModuleRevisionId());
+
+        assertTrue(cacheManager.getResolvedIvyFileInCache(mrid).exists());
+
+        assertTrue(cacheManager.getIvyFileInCache(
+            ModuleRevisionId.newInstance("org1", "mod1.3", "3.0")).exists());
+        assertTrue(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3-A", 
"jar", "jar")
+                .exists());
+        assertTrue(!getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3-B", 
"jar", "jar")
+                .exists());
+        assertTrue(!getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3", 
"jar", "jar")
+                .exists());
+    }
+    
+    
     public void testResolveDefaultWithArtifactsConf1() throws Exception {
         // mod2.2 depends on mod1.3 and selects its artifacts
         ResolveReport report = ivy.resolve(new File(
@@ -831,6 +880,9 @@
         assertTrue(!getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3", 
"jar", "jar").exists());
     }
 
+    
+    
+    
     public void testResolveDefaultWithArtifactsAndConfMapping() throws 
Exception {
         // mod2.2 depends on mod1.3 and specify its artifacts and a conf 
mapping
         ResolveReport report = ivy.resolve(new File(


Reply via email to