[Arakhnę-Dev] [306] * Add replacement mojo into HTML files of the javadoc by default.

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


Revision: 306
Author:   galland
Date:     2011-11-05 11:31:55 +0100 (Sat, 05 Nov 2011)
Log Message:
-----------
* Add replacement mojo into HTML files of the javadoc by default.

Added Paths:
-----------
    trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/ReplaceHtmlMojo.java

Added: trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/ReplaceHtmlMojo.java
===================================================================
--- trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/ReplaceHtmlMojo.java	                        (rev 0)
+++ trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/ReplaceHtmlMojo.java	2011-11-05 10:31:55 UTC (rev 306)
@@ -0,0 +1,89 @@
+/* 
+ * $Id$
+ * 
+ * Copyright (C) 2011 Stephane GALLAND This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * This program is free software; you can redistribute it and/or modify
+ */
+package org.arakhne.maven.plugins.tagreplacer;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.arakhne.maven.PropertyFileFilter;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * Replace the macros by the corresponding values
+ * on the fly in HTML files.
+ * Supported macros are described in {@link AbstractReplaceMojo}.
+ *
+ * @author $Author: galland$
+ * @version $FullVersion$
+ * @mavengroupid $GroupId$
+ * @mavenartifactid $ArtifactId$
+ * @since 2.3
+ * 
+ * @goal replaceresource
+ * @phase process-resources
+ * @requireProject true
+ * @threadSafe
+ */
+public class ReplaceHtmlMojo extends AbstractReplaceMojo {
+
+	/** Are the directories where the HTML files are located.
+	 * By default, the directory "target/site/javadoc" is used.
+	 * 
+	 * @parameter
+	 */
+	private File[] htmls;
+
+	/**
+     * {@inheritDoc}
+     */
+	@Override
+    protected synchronized void executeMojo() throws MojoExecutionException {
+		File[] htmlDirs;
+		if (this.htmls==null || this.htmls.length==0) {
+			htmlDirs = new File[] {
+					new File(getSiteDirectory(), "javadoc"), //$NON-NLS-1$
+			};
+		}
+		else {
+			htmlDirs = this.htmls;
+		}
+		
+		clearInternalBuffers();
+
+		Collection<File> textBasedFiles = new ArrayList<File>();
+		
+		for(File htmlDir : htmlDirs) {
+    		if ( htmlDir.isDirectory() ) {
+    			// Search for .html files
+    			findFiles(htmlDir, new PropertyFileFilter(), textBasedFiles);
+    		}
+    	}
+
+		for(File file : textBasedFiles) {
+			replaceInFile(
+					null,
+					file,
+					ReplacementType.HTML,
+					htmlDirs,
+					true);
+		}
+	}
+    
+}


Property changes on: trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/ReplaceHtmlMojo.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain


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