Author: maartenc
Date: Wed Oct  1 14:00:57 2008
New Revision: 700920

URL: http://svn.apache.org/viewvc?rev=700920&view=rev
Log:
FIX: ivy:settings doesn't work if id is a property (IVY-925)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyAntSettingsBuildFile.xml
    
ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyAntSettingsBuildFileTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=700920&r1=700919&r2=700920&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Wed Oct  1 14:00:57 2008
@@ -95,6 +95,7 @@
 - FIX: Maven packaging of "pom" should add a "jar" artifact if present 
(IVY-920)
 - FIX: StackOverflow when using ivy:settings with "ivy.instance" as id 
(IVY-924)
 - FIX: Maven Pom reader doesn't handle optional dependencies correctly in some 
instances (IVY-926) (thanks to Phil Messenger)
+- FIX: ivy:settings doesn't work if id is a property (IVY-925)
 
    2.0.0-rc1
 =====================================

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java?rev=700920&r1=700919&r2=700920&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java 
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java Wed Oct  
1 14:00:57 2008
@@ -134,6 +134,12 @@
             return (IvyAntSettings) defaultInstanceObj;
         }
     }
+    
+    public IvyAntSettings() {
+        super();
+        System.out.println(this);
+        Thread.dumpStack();
+    }
 
     public File getFile() {
         return file;
@@ -178,7 +184,7 @@
     public void setProject(Project p) {
         super.setProject(p);
         
-        if ("ivy.instance".equals(id) && getProject().getReferences().get(id) 
== null) {
+        if ("ivy.instance".equals(id) && 
!getProject().getReferences().containsKey(id)) {
             // register ourselfs as default settings, just in case the id 
attribute is not set
             getProject().addReference("ivy.instance", this);
             autoRegistered = true;
@@ -216,6 +222,10 @@
             autoRegistered = false;
         }
         this.id = id;
+        
+        if (getProject() != null) {
+            getProject().addReference(this.id, this);
+        }
     }
     
     public String getId() {

Modified: 
ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyAntSettingsBuildFile.xml
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyAntSettingsBuildFile.xml?rev=700920&r1=700919&r2=700920&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyAntSettingsBuildFile.xml 
(original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyAntSettingsBuildFile.xml 
Wed Oct  1 14:00:57 2008
@@ -39,4 +39,10 @@
                <ivy:configure settingsId="testUnnecessaryDefaultIvyInstance" 
file="test/repositories/ivysettings.xml" override="true" />
                <ivy:cachepath settingsRef="testUnnecessaryDefaultIvyInstance" 
file="test/java/org/apache/ivy/ant/ivy-simple.xml" pathid="ptest" />
          </target>
+       
+  <target name="testSettingsWithPropertyAsId">
+       <property name="my.property" value="whatever" />
+       <ivy:settings id="${my.property}" 
file="test/repositories/ivysettings.xml" />
+       <ivy:resolve settingsRef="${my.property}" 
file="test/java/org/apache/ivy/ant/ivy-simple.xml" />
+  </target>
 </project>
\ No newline at end of file

Modified: 
ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyAntSettingsBuildFileTest.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyAntSettingsBuildFileTest.java?rev=700920&r1=700919&r2=700920&view=diff
==============================================================================
--- 
ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyAntSettingsBuildFileTest.java
 (original)
+++ 
ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyAntSettingsBuildFileTest.java
 Wed Oct  1 14:00:57 2008
@@ -47,4 +47,12 @@
         assertNull("Default ivy.instance settings shouldn't have been loaded", 
                 getProject().getReference("ivy.instance"));
     }
+    
+    public void testSettingsWithIdIvyInstance() {
+        executeTarget("testSettingsWithPropertyAsId");
+        ResolveReport report = (ResolveReport) 
getProject().getReference("ivy.resolved.report");
+        assertNotNull(report);
+        assertFalse(report.hasError());
+        assertEquals(1, report.getDependencies().size());
+    }
 }


Reply via email to