Author: xavier
Date: Mon Jul  7 11:15:52 2008
New Revision: 674574

URL: http://svn.apache.org/viewvc?rev=674574&view=rev
Log:
IMPROVEMENT: Support atomic publish with sub directory structure (IVY-856)

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=674574&r1=674573&r2=674574&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Mon Jul  7 11:15:52 2008
@@ -76,6 +76,7 @@
 - NEW: Add transitive dependency version and branch override mechanism 
(IVY-784)
 - NEW: Add new packager resolver (IVY-829) (thanks to Archie Cobbs)
 
+- IMPROVEMENT: Support atomic publish with sub directory structure (IVY-856)
 - IMPROVEMENT: Provide ant task to retrieve information from published ivy 
modules (IVY-838) (thanks to David Maplesden)
 - IMPROVEMENT: Install task fails but reason is not displayed without using 
-debug or -verbose (IVY-834)
 - IMPROVEMENT: SSH resolver doesn't support keyboard-interactive 
authentication (IVY-836) (thanks to Tobias Himstedt)

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=674574&r1=674573&r2=674574&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 Jul  7 11:15:52 2008
@@ -39,7 +39,7 @@
 
     private static final String TRANSACTION_DESTINATION_SUFFIX = ".part";
     private static final Pattern TRANSACTION_PATTERN = 
-        Pattern.compile("(.*\\[revision\\])([/\\\\][^/\\\\]+)");
+        Pattern.compile("(.*[/\\\\]\\[revision\\])([/\\\\].+)");
     
     /**
      * Transactional mode.
@@ -139,7 +139,8 @@
             if (transactionDestDir.exists()) {
                 throw new IOException(
                     "impossible to commit transaction: transaction destination 
directory "
-                    + "already exists: " + transactionDestDir);
+                    + "already exists: " + transactionDestDir
+                    + "\npossible cause: usage of identifying tokens after the 
revision token");
             }
             try {
                 getFileRepository().move(transactionTempDir, 
transactionDestDir);
@@ -179,13 +180,14 @@
                 initTransaction(module);
                 if (transactionDestDir.exists()) {
                     unsupportedTransaction(
-                        "transaction destination directory already exists: " + 
transactionDestDir);
+                        "transaction destination directory already exists: " + 
transactionDestDir
+                        + "\npossible cause: usage of identifying tokens after 
the revision token");
                     closeTransaction();
                 } else {
                     Message.verbose(
                         "\tstarting transaction: publish during transaction 
will be done in \n\t\t" 
                         + transactionTempDir 
-                        + "\n\t\tand on commit moved to \n\t\t" + 
transactionDestDir);
+                        + "\n\tand on commit moved to \n\t\t" + 
transactionDestDir);
                 }
             }
         }
@@ -229,7 +231,7 @@
                 String pattern = (String) ivyPatterns.get(0);
                 Matcher m = TRANSACTION_PATTERN.matcher(pattern);
                 if (!m.matches()) {
-                    unsupportedTransaction("ivy pattern does not use revision 
as last directory");
+                    unsupportedTransaction("ivy pattern does not use revision 
as a directory");
                     return;
                 } else {
                     baseTransactionPattern = m.group(1);
@@ -241,7 +243,7 @@
                 String pattern = (String) artifactPatterns.get(0);
                 Matcher m = TRANSACTION_PATTERN.matcher(pattern);
                 if (!m.matches()) {
-                    unsupportedTransaction("ivy pattern does not use revision 
as last directory");
+                    unsupportedTransaction("artifact pattern does not use 
revision as a directory");
                     return;
                 } else if (baseTransactionPattern != null) {
                     if (!baseTransactionPattern.equals(m.group(1))) {

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=674574&r1=674573&r2=674574&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 Jul  7 11:15:52 2008
@@ -660,7 +660,7 @@
 
             resolver.publish(artifact, src, false);
             assertFalse(new File(
-                
"test/repositories/1/myorg/mymodule/mytypes/myartifact-myrevision.myext")
+                
"test/repositories/1/myorg/mymodule/myrevision/myartifact-myrevision.myext")
                 .exists());
 
             resolver.commitPublishTransaction();
@@ -712,6 +712,45 @@
             FileUtil.forceDelete(new File("test/repositories/1/myorg"));
         }
     }
+    
+    public void testPublishTransactionWithSubDirectories() throws Exception {
+        try {
+            FileSystemResolver resolver = new FileSystemResolver();
+            resolver.setName("test");
+            resolver.setSettings(settings);
+
+            resolver.addIvyPattern(
+                
"test/repositories/1/[organisation]/[module]/[revision]/[type]/[artifact].[ext]");
+            resolver.addArtifactPattern(
+                 
"test/repositories/1/[organisation]/[module]/[revision]/[type]/[artifact]-[revision].[ext]");
+
+            ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", 
"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/1/myorg/mymodule/myrevision/ivy/ivy.xml").exists());
+
+            resolver.publish(artifact, src, false);
+            assertFalse(new File(
+                
"test/repositories/1/myorg/mymodule/myrevision/mytype/myartifact-myrevision.myext")
+                .exists());
+
+            resolver.commitPublishTransaction();
+
+            assertTrue(new 
File("test/repositories/1/myorg/mymodule/myrevision/ivy/ivy.xml").exists());
+            assertTrue(
+                new 
File("test/repositories/1/myorg/mymodule/myrevision/mytype/myartifact-myrevision.myext").exists());
+        } finally {
+            FileUtil.forceDelete(new File("test/repositories/1/myorg"));
+        }
+    }
+
 
     public void testAbortTransaction() throws Exception {
         try {


Reply via email to