Author: maartenc
Date: Mon Nov 30 22:35:17 2009
New Revision: 885601

URL: http://svn.apache.org/viewvc?rev=885601&view=rev
Log:
FIX: FileSystem resolver with m2compatible=true throws error when publishing 
modules with dotted organisation names (IVY-968)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java
    
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=885601&r1=885600&r2=885601&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Mon Nov 30 22:35:17 2009
@@ -99,6 +99,7 @@
 - IMPROVEMENT: Trace a message when a property file referenced from the 
settings doesn't exixts (IVY-1074)
 - IMPROVEMENT: use defaultconf in combination with defaultconfmapping 
(IVY-1135) (thanks to Jon Schneider)
 
+- FIX: FileSystem resolver with m2compatible=true throws error when publishing 
modules with dotted organisation names (IVY-968)
 - FIX: ivy:retrieve sync="true" does nothing if first variable is optional 
(IVY-1142) (thanks to Andreas Axelsson)
 - FIX: Latest Compatible Conflict Manager + Extra Attributes in Dependencies' 
IVY files == infinite loop (IVY-956)
 - FIX: Resolve with Extra Attributes, Forced Dependencies causes invalid 
delivered ivy file (IVY-1079)

Modified: 
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java?rev=885601&r1=885600&r2=885601&view=diff
==============================================================================
--- 
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java
 (original)
+++ 
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java
 Mon Nov 30 22:35:17 2009
@@ -279,13 +279,18 @@
     }
 
     private void initTransaction(ModuleRevisionId module) {
+        ModuleRevisionId mrid = module;
+        if (isM2compatible()) {
+            mrid = convertM2IdForResourceSearch(module);
+        }
+        
         transactionTempDir = Checks.checkAbsolute(IvyPatternHelper.substitute(
             baseTransactionPattern, 
             ModuleRevisionId.newInstance(
-                module, module.getRevision() + 
TRANSACTION_DESTINATION_SUFFIX)),
+                mrid, mrid.getRevision() + TRANSACTION_DESTINATION_SUFFIX)),
                 "baseTransactionPattern");
         transactionDestDir = Checks.checkAbsolute(IvyPatternHelper.substitute(
-            baseTransactionPattern, module), "baseTransactionPattern");
+            baseTransactionPattern, mrid), "baseTransactionPattern");
     }
 
     public String getTransactional() {

Modified: 
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java?rev=885601&r1=885600&r2=885601&view=diff
==============================================================================
--- 
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java
 (original)
+++ 
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java
 Mon Nov 30 22:35:17 2009
@@ -752,6 +752,38 @@
         }
     }
 
+    public void testPublishTransactionWithDottedOrganisation() throws 
Exception {
+        try {
+            FileSystemResolver resolver = new FileSystemResolver();
+            resolver.setName("test");
+            resolver.setM2compatible(true);
+            resolver.setSettings(settings);
+
+            resolver.addIvyPattern(
+                settings.getBaseDir() + 
"/test/repositories/m2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]");
+            resolver.addArtifactPattern(
+                settings.getBaseDir() + 
"/test/repositories/m2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]");
+
+            ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", 
"mymodule", "myrevision");
+            Artifact ivyArtifact = new DefaultArtifact(mrid, new Date(), 
"ivy", "ivy", "xml");
+            Artifact artifact = new DefaultArtifact(mrid, new Date(), 
"myartifact", "mytype", "myext");
+            File src = new File("test/repositories/ivysettings.xml");
+            
+            resolver.beginPublishTransaction(mrid, false);
+            
+            // files should not be available until the transaction is committed
+            resolver.publish(ivyArtifact, src, false);
+            assertFalse(new 
File("test/repositories/m2/org/apache/mymodule/myrevision/ivy-myrevision.xml").exists());
+            resolver.publish(artifact, src, false);
+            assertFalse(new 
File("test/repositories/m2/org/apache/mymodule/myrevision/myartifact-myrevision.myext").exists());
+
+            resolver.commitPublishTransaction();
+            assertTrue(new 
File("test/repositories/m2/org/apache/mymodule/myrevision/ivy-myrevision.xml").exists());
+            assertTrue(new 
File("test/repositories/m2/org/apache/mymodule/myrevision/myartifact-myrevision.myext").exists());
+        } finally {
+            FileUtil.forceDelete(new 
File("test/repositories/m2/org/apache/mymodule"));
+        }
+    }
 
     public void testAbortTransaction() throws Exception {
         try {


Reply via email to