You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/09/20 23:05:04 UTC
svn commit: r290565 -
/maven/components/trunk/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/ScpSiteDeployMojo.java
Author: brett
Date: Tue Sep 20 14:05:00 2005
New Revision: 290565
URL: http://svn.apache.org/viewcvs?rev=290565&view=rev
Log:
o store temp file in temp directory, not target which may not exist
o error out if site doesn't exist to copy.
o clean up
Modified:
maven/components/trunk/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/ScpSiteDeployMojo.java
Modified: maven/components/trunk/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/ScpSiteDeployMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/ScpSiteDeployMojo.java?rev=290565&r1=290564&r2=290565&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/ScpSiteDeployMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/ScpSiteDeployMojo.java Tue Sep 20 14:05:00 2005
@@ -1,7 +1,20 @@
+package org.apache.maven.doxia;
+
/*
- * Copyright (c) 2005 Your Corporation. All Rights Reserved.
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
-package org.apache.maven.doxia;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.model.DistributionManagement;
@@ -23,13 +36,13 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
-
/**
* Deploys website using scp protocol.
* First website files are packaged into zip archive,
* then archive is transfred to remote host, nextly it is un-archived.
* This method of deployment should normally be much faster
* then making file by file copy.
+ *
* @author <a href="mailto:michal@codehaus.org">Michal Maczka</a>
* @version $Id$
* @goal deploy
@@ -41,13 +54,7 @@
* @parameter alias="siteDirectory" expression="${project.build.directory}/site"
* @required
*/
- private String inputDirectory;
-
- /**
- * @parameter expression="${project.build.directory}"
- * @required
- */
- private String workingDirectory;
+ private File inputDirectory;
/**
* @parameter
@@ -71,61 +78,67 @@
public void execute()
throws MojoExecutionException
{
- File baseDir = new File( inputDirectory );
+ if ( !inputDirectory.exists() )
+ {
+ throw new MojoExecutionException( "The site does not exist, please run site:site first" );
+ }
File zipFile;
try
{
- zipFile = File.createTempFile( "site", ".zip", new File( workingDirectory ) );
+ zipFile = File.createTempFile( "site", ".zip" );
}
catch ( IOException e )
{
throw new MojoExecutionException( "Cannot create site archive!", e );
}
- SshCommandExecutor commandExecutor = null;
- try
+ DistributionManagement distributionManagement = project.getDistributionManagement();
+
+ if ( distributionManagement == null )
{
- DistributionManagement distributionManagement = project.getDistributionManagement();
+ throw new MojoExecutionException( "Missing distribution management information in the project" );
+ }
- if ( distributionManagement == null )
- {
- throw new MojoExecutionException( "Missing distribution management information in the project" );
- }
+ Site site = distributionManagement.getSite();
- Site site = distributionManagement.getSite();
+ if ( site == null )
+ {
+ throw new MojoExecutionException(
+ "Missing site information in the distribution management element in the project.." );
+ }
- if ( site == null )
- {
- throw new MojoExecutionException( "Missing site information in the distribution management element in the project.." );
- }
+ String url = site.getUrl();
- String url = site.getUrl();
+ String id = site.getId();
- String id = site.getId();
+ if ( url == null )
+ {
+ throw new MojoExecutionException( "The URL to the site is missing in the project descriptor." );
+ }
- if ( url == null )
- {
- throw new MojoExecutionException( "The URL to the site is missing in the project descriptor." );
- }
+ Repository repository = new Repository( id, url );
- Repository repository = new Repository( id, url );
+ if ( !"scp".equals( repository.getProtocol() ) )
+ {
+ throw new MojoExecutionException(
+ "The deploy mojo currently only supports site deployment using the 'scp' protocol." );
+ }
- if ( !"scp".equals( repository.getProtocol() ) )
- {
- throw new MojoExecutionException( "The deploy mojo currently only supports site deployment using the 'scp' protocol." );
- }
+ SshCommandExecutor commandExecutor = null;
+ try
+ {
commandExecutor = (SshCommandExecutor) wagonManager.getWagon( "scp" );
commandExecutor.connect( repository, wagonManager.getAuthenticationInfo( id ) );
String basedir = repository.getBasedir();
- List files = FileUtils.getFileNames( baseDir, "**/**", "", false );
+ List files = FileUtils.getFileNames( inputDirectory, "**/**", "", false );
- createZip( files, zipFile, baseDir );
+ createZip( files, zipFile, inputDirectory );
Debug debug = new Debug();
@@ -171,7 +184,6 @@
if ( !zipFile.delete() )
{
-
zipFile.deleteOnExit();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org