Author: ltheussl
Date: Tue Mar 29 10:04:50 2011
New Revision: 1086533

URL: http://svn.apache.org/viewvc?rev=1086533&view=rev
Log:
fix relativeDirectory in wagon upload

Modified:
    
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java
    
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java
    
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageMojo.java

Modified: 
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java?rev=1086533&r1=1086532&r2=1086533&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java
 Tue Mar 29 10:04:50 2011
@@ -123,12 +123,38 @@ public abstract class AbstractDeployMojo
 
     private PlexusContainer container;
 
+    /**
+     * The String "staging/".
+     */
+    protected static final String DEFAULT_STAGING_DIRECTORY = "staging/";
+
     /** {@inheritDoc} */
     public void execute()
         throws MojoExecutionException
     {
-        deployTo( new 
org.apache.maven.plugins.site.wagon.repository.Repository( 
getDeployRepositoryID(),
-                                                                               
  getDeployRepositoryURL() ) );
+        deployTo( new 
org.apache.maven.plugins.site.wagon.repository.Repository(
+            getDeployRepositoryID(),
+            appendSlash( getDeployRepositoryURL() ) ) );
+    }
+
+    /**
+     * Make sure the given url ends with a slash.
+     *
+     * @param url a String.
+     *
+     * @return if url already ends with '/' it is returned unchanged,
+     *      otherwise a '/' character is appended.
+     */
+    protected static String appendSlash( final String url )
+    {
+        if ( url.endsWith( "/" ) )
+        {
+            return url;
+        }
+        else
+        {
+            return url + "/";
+        }
     }
 
     /**
@@ -157,19 +183,21 @@ public abstract class AbstractDeployMojo
     /**
      * Find the relative path between the distribution URLs of the top parent 
and the current project.
      *
-     * @return a String starting with "/".
+     * @return the relative path or "./" if the two URLs are the same.
      *
      * @throws MojoExecutionException
      */
     private String getDeployModuleDirectory()
         throws MojoExecutionException
     {
-        String relative = "/" + siteTool.getRelativePath( getSite( project 
).getUrl(),
+        String relative = siteTool.getRelativePath( getSite( project 
).getUrl(),
             getRootSite( project ).getUrl() );
 
         // SiteTool.getRelativePath() uses File.separatorChar,
         // so we need to convert '\' to '/' in order for the URL to be valid 
for Windows users
-        return relative.replace( '\\', '/' );
+        relative = relative.replace( '\\', '/' );
+
+        return ( "".equals( relative ) ) ? "./" : relative;
     }
 
     /**
@@ -340,14 +368,16 @@ public abstract class AbstractDeployMojo
                 {
                     // TODO: this also uploads the non-default locales,
                     // is there a way to exclude directories in wagon?
+                    log.info( "   >>> to " + repository.getUrl() + relativeDir 
);
+
                     wagon.putDirectory( inputDirectory, relativeDir );
-                    log.info( "   to " + repository.getUrl() + relativeDir + 
": done" );
                 }
                 else
                 {
+                    log.info( "   >>> to " + repository.getUrl() + 
locale.getLanguage() + "/" + relativeDir );
+
                     wagon.putDirectory( new File( inputDirectory, 
locale.getLanguage() ),
-                        locale.getLanguage() + relativeDir );
-                    log.info( "   to " + repository.getUrl() + 
locale.getLanguage() + relativeDir + ": done" );
+                        locale.getLanguage() + "/" + relativeDir );
                 }
             }
         }

Modified: 
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java?rev=1086533&r1=1086532&r2=1086533&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java
 Tue Mar 29 10:04:50 2011
@@ -64,9 +64,6 @@ public class SiteStageDeployMojo
      */
     private String stagingRepositoryId;
 
-    private static final String DEFAULT_STAGING_DIRECTORY = "staging";
-
-
     @Override
     protected String getDeployRepositoryID()
         throws MojoExecutionException
@@ -106,8 +103,8 @@ public class SiteStageDeployMojo
         else
         {
             // The user didn't specify a URL, use the top level target dir
-            topLevelURL =
-                getRootSite( project ).getUrl() + "/" + 
DEFAULT_STAGING_DIRECTORY;
+            topLevelURL = appendSlash( getRootSite( project ).getUrl() )
+                + DEFAULT_STAGING_DIRECTORY;
             getLog().debug( "stagingSiteURL NOT specified, using the top level 
project: " + topLevelURL );
         }
 

Modified: 
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageMojo.java?rev=1086533&r1=1086532&r2=1086533&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageMojo.java
 Tue Mar 29 10:04:50 2011
@@ -40,8 +40,6 @@ import org.apache.maven.plugin.MojoExecu
 public class SiteStageMojo
     extends AbstractDeployMojo
 {
-    protected static final String DEFAULT_STAGING_DIRECTORY = "staging";
-
     /**
      * Staging directory location. This needs to be an absolute path, like
      * <code>C:\stagingArea\myProject\</code> on Windows or


Reply via email to