You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by lt...@apache.org on 2011/03/01 14:22:13 UTC
svn commit: r1075810 - in
/maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site:
SiteStageDeployMojo.java SiteStageMojo.java
Author: ltheussl
Date: Tue Mar 1 13:22:12 2011
New Revision: 1075810
URL: http://svn.apache.org/viewvc?rev=1075810&view=rev
Log:
simplify code
Modified:
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/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=1075810&r1=1075809&r2=1075810&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 1 13:22:12 2011
@@ -90,59 +90,35 @@ public class SiteStageDeployMojo
* Find the URL where staging will take place.
*
* @param currentProject The currently executing project
- * @param reactorProjects The projects in the reactor
* @param usersStagingSiteURL The staging site URL as suggested by the user's configuration
+ *
* @return the site URL for staging
*/
private String getStagingSiteURL( MavenProject currentProject,
String usersStagingSiteURL )
{
+ // Find the relative path between the top parent and the current distribution URLs, if any
+ final MavenProject parentProject = getTopLevelParent( currentProject );
+ String relative = "/" + siteTool.getRelativePath( currentProject.getDistributionManagement().getSite().getUrl(),
+ parentProject.getDistributionManagement().getSite().getUrl() );
+ // SiteTool.getRelativePath() uses File.separatorChar,
+ // so we need to convert '\' to '/' in order for the URL to be valid for Windows users
+ relative = relative.replace( '\\', '/' );
+
String topLevelURL = null;
- String relative = "";
- // If the user has specified a stagingSiteURL - use it
if ( usersStagingSiteURL != null )
{
+ // the user has specified a stagingSiteURL - use it
getLog().debug( "stagingSiteURL specified by the user: " + usersStagingSiteURL );
topLevelURL = usersStagingSiteURL;
}
else
{
- getLog().debug( "stagingSiteURL NOT specified by the user." );
- }
-
- MavenProject parentProject = getTopLevelParent( currentProject );
-
- // Take the distributionManagement site url from the top level project,
- // if there is one, otherwise take it from the current project
- if ( parentProject == null )
- {
- if ( topLevelURL == null )
- {
- // The user didn't specify a URL and there is no top level project in the reactor
- // Use current project
- topLevelURL =
- currentProject.getDistributionManagement().getSite().getUrl() + "/" + DEFAULT_STAGING_DIRECTORY;
- getLog().debug( "No top level project found in the reactor, using the current project: " + topLevelURL );
- }
- }
- else
- {
- // Find the relative path between the parent and child distribution URLs, if any
- relative = "/" + siteTool.getRelativePath( currentProject.getDistributionManagement().getSite().getUrl(),
- parentProject.getDistributionManagement().getSite().getUrl() );
- // SiteTool.getRelativePath() uses File.separatorChar, so we need to convert '\' to '/' in order for the URL
- // to be valid for Windows users
- relative = relative.replace( '\\', '/' );
-
- if ( topLevelURL == null )
- {
- // The user didn't specify a URL and there is a top level project in the reactor
- // Use the top level project
- topLevelURL =
- parentProject.getDistributionManagement().getSite().getUrl() + "/" + DEFAULT_STAGING_DIRECTORY;
- getLog().debug( "Using the top level project: " + topLevelURL );
- }
+ // The user didn't specify a URL, use the top level target dir
+ topLevelURL =
+ parentProject.getDistributionManagement().getSite().getUrl() + "/" + DEFAULT_STAGING_DIRECTORY;
+ getLog().debug( "stagingSiteURL NOT specified, using the top level project: " + topLevelURL );
}
// Return either
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=1075810&r1=1075809&r2=1075810&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 1 13:22:12 2011
@@ -82,59 +82,35 @@ public class SiteStageMojo
* Find the directory where staging will take place.
*
* @param currentProject The currently executing project
- * @param reactorProjects The projects in the reactor
* @param usersStagingDirectory The staging directory as suggested by the user's configuration
+ *
* @return the directory for staging
*/
private String getStagingDirectory( MavenProject currentProject,
String usersStagingDirectory )
{
+ // Find the relative path between the top parent and the current distribution URLs, if any
+ final MavenProject parentProject = getTopLevelParent( currentProject );
+ String relative = "/" + siteTool.getRelativePath( currentProject.getDistributionManagement().getSite().getUrl(),
+ parentProject.getDistributionManagement().getSite().getUrl() );
+ // SiteTool.getRelativePath() uses File.separatorChar,
+ // so we need to convert '\' to '/' in order for the URL to be valid for Windows users
+ relative = relative.replace( '\\', '/' );
+
String topLevelURL = null;
- String relative = "";
- // If the user has specified a stagingDirectory - use it
if ( usersStagingDirectory != null )
{
+ // the user has specified a stagingDirectory - use it
getLog().debug( "stagingDirectory specified by the user: " + usersStagingDirectory );
topLevelURL = usersStagingDirectory;
}
else
{
- getLog().debug( "stagingDirectory NOT specified by the user." );
- }
-
- MavenProject parentProject = getTopLevelParent( currentProject );
-
- // Take the distributionManagement site url from the top level project,
- // if there is one, otherwise take it from the current project
- if ( parentProject == null )
- {
- if ( topLevelURL == null )
- {
- // The user didn't specify a URL and there is no top level project in the reactor
- // Use current project
- topLevelURL =
- getTopLevelBuildDirectory().getAbsolutePath() + "/" + DEFAULT_STAGING_DIRECTORY;
- getLog().debug( "No top level project found in the reactor, using the current project: " + topLevelURL );
- }
- }
- else
- {
- // Find the relative path between the parent and child distribution URLs, if any
- relative = "/" + siteTool.getRelativePath( currentProject.getDistributionManagement().getSite().getUrl(),
- parentProject.getDistributionManagement().getSite().getUrl() );
- // SiteTool.getRelativePath() uses File.separatorChar, so we need to convert '\' to '/' in order for the URL
- // to be valid for Windows users
- relative = relative.replace( '\\', '/' );
-
- if ( topLevelURL == null )
- {
- // The user didn't specify a URL and there is a top level project in the reactor
- // Use the top level project
- topLevelURL =
- getTopLevelBuildDirectory().getAbsolutePath() + "/" + DEFAULT_STAGING_DIRECTORY;
- getLog().debug( "Using the top level project: " + topLevelURL );
- }
+ // The user didn't specify a URL, use the top level target dir
+ topLevelURL =
+ getTopLevelBuildDirectory().getAbsolutePath() + "/" + DEFAULT_STAGING_DIRECTORY;
+ getLog().debug( "stagingDirectory NOT specified, using the top level project: " + topLevelURL );
}
// Return either