[Arakhnę-Dev] [315] * Copy in "apidocs" target subdirectory.

[ Thread Index | Date Index | More arakhne.org/dev Archives ]


Revision: 315
Author:   galland
Date:     2011-11-05 14:20:01 +0100 (Sat, 05 Nov 2011)
Log Message:
-----------
* Copy in "apidocs" target subdirectory.
* Do not copy hidden files

Modified Paths:
--------------
    trunk/atomicdeploy/src/main/java/org/arakhne/maven/plugins/atomicdeploy/JavadocMojo.java

Modified: trunk/atomicdeploy/src/main/java/org/arakhne/maven/plugins/atomicdeploy/JavadocMojo.java
===================================================================
--- trunk/atomicdeploy/src/main/java/org/arakhne/maven/plugins/atomicdeploy/JavadocMojo.java	2011-11-05 13:19:10 UTC (rev 314)
+++ trunk/atomicdeploy/src/main/java/org/arakhne/maven/plugins/atomicdeploy/JavadocMojo.java	2011-11-05 13:20:01 UTC (rev 315)
@@ -65,6 +65,7 @@
 		assertNotNull("repositorySystem", this.repoSystem); //$NON-NLS-1$
 		assertNotNull("repositorySystemSession", this.repoSession); //$NON-NLS-1$
 		assertNotNull("remoteRepositoryList", this.remoteRepos); //$NON-NLS-1$
+		assertNotNull("targetDirectoryName", this.targetDirectoryName); //$NON-NLS-1$
 	}
 
 	//-----------------------------------------------------
@@ -187,9 +188,9 @@
 	}
 
 	//-----------------------------------------------------
-	// Mojo dedicated attributes
+	// Mojo dedicated stuffs
 	
-	private static URL getSiteDeploymentURL(MavenProject project) {
+	private static URL getSiteDeploymentURL(MavenProject project, String targetDirectoryName) {
 		DistributionManagement distManagement = project.getDistributionManagement();
 		if (distManagement!=null) {
 			Site site = distManagement.getSite();
@@ -197,7 +198,7 @@
 				String url = site.getUrl();
 				if (url!=null && url.length()>0) {
 					try {
-						return new URL(url);
+						return new URL(url+"/"+targetDirectoryName); //$NON-NLS-1$
 					}
 					catch(Throwable e) {
 						//
@@ -208,11 +209,11 @@
 		return null;
 	}
 
-	private static URL getInheritedSiteDeploymentURL(MavenProject project) {
+	private static URL getInheritedSiteDeploymentURL(MavenProject project, String targetDirectoryName) {
 		URL deployementURL = null;
 		MavenProject p = project; 
 		while(deployementURL==null && p!=null) {
-			deployementURL = getSiteDeploymentURL(p);
+			deployementURL = getSiteDeploymentURL(p, targetDirectoryName);
 			p = p.getParent();
 		}
 		return deployementURL;
@@ -221,25 +222,35 @@
 	/**
 	 * Directory of the javadoc.
 	 * 
-	 * @parameter expression="${project.build.directory}/site/javadoc"
+	 * @parameter expression="${project.build.directory}/site/apidocs"
 	 */
 	private String javadocDirectory;
 
 	/**
+	 * Name of the target subdirectory in the site deployment directory.
+	 * 
+	 * @parameter default-value="apidocs"
+	 */
+	private String targetDirectoryName;
+
+	/**
 	 * {@inheritDoc}
 	 */
 	@Override
 	public synchronized void executeMojo() throws MojoExecutionException {
+		MavenProject project = this.mavenSession.getCurrentProject();
 		File javadocDir = new File(this.javadocDirectory);
-		if (javadocDir.isDirectory()) {
-			MavenProject project = this.mavenSession.getCurrentProject();
-			URL deployementURL = getInheritedSiteDeploymentURL(project);
+		File indexFile = new File(javadocDir, "index.html"); //$NON-NLS-1$
+		if (javadocDir.isDirectory() && indexFile.isFile()) {
+			URL deployementURL = getInheritedSiteDeploymentURL(project, this.targetDirectoryName);
 			if (deployementURL!=null) {
 				if ("file".equalsIgnoreCase(deployementURL.getProtocol())) { //$NON-NLS-1$
 					File output = new File(deployementURL.getPath());
+					info("Input: "+javadocDir); //$NON-NLS-1$
+					info("Output: "+output); //$NON-NLS-1$
 					try {
 						dirRemove(output);
-						dirCopy(javadocDir, output);
+						dirCopy(javadocDir, output, true);
 					}
 					catch (IOException e) {
 						error(e);
@@ -259,9 +270,7 @@
 			}
 		}
 		else {
-			String message = "Javadoc directory not found: "+this.javadocDirectory; //$NON-NLS-1$
-			error(message);
-			throw new MojoExecutionException(message);
+			info("Skipping project, no javadoc directory found"); //$NON-NLS-1$
 		}
 	}
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/