[Arakhnę-Dev] [238] * Prepare for Maven 3 |
[ Thread Index |
Date Index
| More arakhne.org/dev Archives
]
Revision: 238
Author: galland
Date: 2011-08-05 22:43:42 +0200 (Fri, 05 Aug 2011)
Log Message:
-----------
* Prepare for Maven 3
Modified Paths:
--------------
trunk/arakhneLog4J/pom.xml
trunk/arakhneLogger/pom.xml
trunk/arakhneRefs/pom.xml
trunk/arakhneVmutils/java/pom.xml
trunk/arakhneVmutils/native/josuuid/linux32/pom.xml
trunk/arakhneVmutils/native/josuuid/linux64/pom.xml
trunk/arakhneVmutils/native/josuuid/mingw32/pom.xml
trunk/arakhneVmutils/native/josuuid/mingw64/pom.xml
trunk/arakhneVmutils/native/josuuid/pom.xml
trunk/arakhneVmutils/native/pom.xml
trunk/arakhneVmutils/pom.xml
trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java
trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/javadoctagreplacer/ReplaceHtmlMojo.java
Added Paths:
-----------
trunk/maventools/src/main/java/org/arakhne/maven/HtmlFileFilter.java
trunk/maventools/src/main/java/org/arakhne/maven/JavaSourceFileFilter.java
trunk/maventools/src/main/java/org/arakhne/maven/MultiFileFilter.java
trunk/maventools/src/main/java/org/arakhne/maven/PropertyFileFilter.java
trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/javadoctagreplacer/AbstractReplaceMojo.java
trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/javadoctagreplacer/Macros.java
trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/javadoctagreplacer/ReplaceSourceMojo.java
Modified: trunk/arakhneLog4J/pom.xml
===================================================================
--- trunk/arakhneLog4J/pom.xml 2011-08-05 16:51:52 UTC (rev 237)
+++ trunk/arakhneLog4J/pom.xml 2011-08-05 20:43:42 UTC (rev 238)
@@ -13,7 +13,7 @@
<artifactId>arakhneLog4J</artifactId>
<packaging>jar</packaging>
<version>1.3</version>
- <name>${project.artifactId}</name>
+ <name>Log4J Binder</name>
<url>http://www.arakhne.org/arakhneLogger/</url>
<properties>
Modified: trunk/arakhneLogger/pom.xml
===================================================================
--- trunk/arakhneLogger/pom.xml 2011-08-05 16:51:52 UTC (rev 237)
+++ trunk/arakhneLogger/pom.xml 2011-08-05 20:43:42 UTC (rev 238)
@@ -12,7 +12,7 @@
<artifactId>arakhneLogger</artifactId>
<packaging>jar</packaging>
<version>1.5</version>
- <name>${project.artifactId}</name>
+ <name>Logging API</name>
<url>http://www.arakhne.org/arakhneLogger/</url>
<properties>
Modified: trunk/arakhneRefs/pom.xml
===================================================================
--- trunk/arakhneRefs/pom.xml 2011-08-05 16:51:52 UTC (rev 237)
+++ trunk/arakhneRefs/pom.xml 2011-08-05 20:43:42 UTC (rev 238)
@@ -12,7 +12,7 @@
<artifactId>arakhneRefs</artifactId>
<packaging>jar</packaging>
<version>5.5</version>
- <name>${project.artifactId}</name>
+ <name>Weak Reference Utilities</name>
<url>http://www.arakhne.org/arakhneRefs/</url>
<properties>
Modified: trunk/arakhneVmutils/java/pom.xml
===================================================================
--- trunk/arakhneVmutils/java/pom.xml 2011-08-05 16:51:52 UTC (rev 237)
+++ trunk/arakhneVmutils/java/pom.xml 2011-08-05 20:43:42 UTC (rev 238)
@@ -19,7 +19,7 @@
<packaging>jar</packaging>
<groupId>org.arakhne.afc</groupId>
<version>6.1</version>
- <name>${project.artifactId}</name>
+ <name>VM Utilities</name>
<url>http://www.arakhne.org/arakhneVmutils/</url>
<properties>
@@ -91,6 +91,10 @@
</goals>
</execution>
</executions>
+ <configuration>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>arakhneVmutils</artifactId>
+ </configuration>
</plugin>
<plugin>
<groupId>org.arakhne.afc</groupId>
Modified: trunk/arakhneVmutils/native/josuuid/linux32/pom.xml
===================================================================
--- trunk/arakhneVmutils/native/josuuid/linux32/pom.xml 2011-08-05 16:51:52 UTC (rev 237)
+++ trunk/arakhneVmutils/native/josuuid/linux32/pom.xml 2011-08-05 20:43:42 UTC (rev 238)
@@ -13,7 +13,7 @@
<artifactId>josuuid-linux32</artifactId>
<packaging>so</packaging>
<version>6.1</version>
- <name>${project.artifactId}</name>
+ <name>Linux 32 OS UUID Library</name>
<!-- ======================================= -->
<!-- ==== Project Information === -->
Modified: trunk/arakhneVmutils/native/josuuid/linux64/pom.xml
===================================================================
--- trunk/arakhneVmutils/native/josuuid/linux64/pom.xml 2011-08-05 16:51:52 UTC (rev 237)
+++ trunk/arakhneVmutils/native/josuuid/linux64/pom.xml 2011-08-05 20:43:42 UTC (rev 238)
@@ -13,7 +13,7 @@
<artifactId>josuuid-linux64</artifactId>
<packaging>so</packaging>
<version>6.1</version>
- <name>${project.artifactId}</name>
+ <name>Linux 64 OS UUID Library</name>
<!-- ======================================= -->
<!-- ==== Project Information === -->
Modified: trunk/arakhneVmutils/native/josuuid/mingw32/pom.xml
===================================================================
--- trunk/arakhneVmutils/native/josuuid/mingw32/pom.xml 2011-08-05 16:51:52 UTC (rev 237)
+++ trunk/arakhneVmutils/native/josuuid/mingw32/pom.xml 2011-08-05 20:43:42 UTC (rev 238)
@@ -13,7 +13,7 @@
<artifactId>josuuid-mingw32</artifactId>
<packaging>dll</packaging>
<version>6.1</version>
- <name>${project.artifactId}</name>
+ <name>Win 32 OS UUID Library</name>
<!-- ======================================= -->
<!-- ==== Project Information === -->
Modified: trunk/arakhneVmutils/native/josuuid/mingw64/pom.xml
===================================================================
--- trunk/arakhneVmutils/native/josuuid/mingw64/pom.xml 2011-08-05 16:51:52 UTC (rev 237)
+++ trunk/arakhneVmutils/native/josuuid/mingw64/pom.xml 2011-08-05 20:43:42 UTC (rev 238)
@@ -13,7 +13,7 @@
<artifactId>josuuid-mingw64</artifactId>
<packaging>dll</packaging>
<version>6.1</version>
- <name>${project.artifactId}</name>
+ <name>Win 64 OS UUID Library</name>
<!-- ======================================= -->
<!-- ==== Project Information === -->
Modified: trunk/arakhneVmutils/native/josuuid/pom.xml
===================================================================
--- trunk/arakhneVmutils/native/josuuid/pom.xml 2011-08-05 16:51:52 UTC (rev 237)
+++ trunk/arakhneVmutils/native/josuuid/pom.xml 2011-08-05 20:43:42 UTC (rev 238)
@@ -12,7 +12,7 @@
<artifactId>josuuid</artifactId>
<packaging>pom</packaging>
<version>6.1</version>
- <name>${project.artifactId}</name>
+ <name>OS UUID Library</name>
<!-- ======================================= -->
<!-- ==== Project Information === -->
Modified: trunk/arakhneVmutils/native/pom.xml
===================================================================
--- trunk/arakhneVmutils/native/pom.xml 2011-08-05 16:51:52 UTC (rev 237)
+++ trunk/arakhneVmutils/native/pom.xml 2011-08-05 20:43:42 UTC (rev 238)
@@ -18,7 +18,7 @@
<groupId>org.arakhne.afc</groupId>
<packaging>pom</packaging>
<version>6.1</version>
- <name>${project.artifactId}</name>
+ <name>Native VM Utilities</name>
<url>http://www.arakhne.org/arakhneVmutils/</url>
<!-- ======================================= -->
Modified: trunk/arakhneVmutils/pom.xml
===================================================================
--- trunk/arakhneVmutils/pom.xml 2011-08-05 16:51:52 UTC (rev 237)
+++ trunk/arakhneVmutils/pom.xml 2011-08-05 20:43:42 UTC (rev 238)
@@ -13,7 +13,7 @@
<artifactId>arakhneVmutils</artifactId>
<packaging>pom</packaging>
<version>6.1</version>
- <name>${project.artifactId}</name>
+ <name>Java and Native VM Utilities</name>
<description>Additional tools dedicated to low-level and virtual machine features</description>
<url>http://www.arakhne.org/arakhneVmutils/</url>
Modified: trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java
===================================================================
--- trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java 2011-08-05 16:51:52 UTC (rev 237)
+++ trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java 2011-08-05 20:43:42 UTC (rev 238)
@@ -202,7 +202,7 @@
private void fillJavaFileMap(File root) {
if (!this.isClassToPomDirectoryFilled.getAndSet(true)) {
getLog().info("Building module descriptions"); //$NON-NLS-1$
- Collection<File> javaFiles = findFiles(root, new JavaFileFilter());
+ Collection<File> javaFiles = findFiles(root, new PropertyFileFilter());
String pattern = "^(.*)"+File.separator //$NON-NLS-1$
+"src"+File.separator //$NON-NLS-1$
+"main"+File.separator //$NON-NLS-1$
@@ -595,40 +595,4 @@
*/
protected abstract void executeMojo() throws MojoExecutionException;
- /**
- * File filter for HTML Java file.
- *
- * @author $Author: galland$
- * @version $Name$ $Revision$ $Date$
- * @mavengroupid $GroupId$
- * @mavenartifactid $ArtifactId$
- */
- private class JavaFileFilter implements FileFilter {
-
- /**
- */
- public JavaFileFilter() {
- //
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean accept(File pathname) {
- return pathname!=null &&
- (pathname.isDirectory() ||
- pathname.getName().endsWith(".java")); //$NON-NLS-1$
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "Java Source (.java)"; //$NON-NLS-1$
- }
-
- } // class JavaFileFilter
-
}
\ No newline at end of file
Added: trunk/maventools/src/main/java/org/arakhne/maven/HtmlFileFilter.java
===================================================================
--- trunk/maventools/src/main/java/org/arakhne/maven/HtmlFileFilter.java (rev 0)
+++ trunk/maventools/src/main/java/org/arakhne/maven/HtmlFileFilter.java 2011-08-05 20:43:42 UTC (rev 238)
@@ -0,0 +1,60 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2010-11 Stéphane 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;
+
+import java.io.File;
+import java.io.FileFilter;
+
+/**
+ * File filter for HTML file.
+ *
+ * @author $Author: galland$
+ * @version $Name$ $Revision$ $Date$
+ * @mavengroupid $GroupId$
+ * @mavenartifactid $ArtifactId$
+ */
+public class HtmlFileFilter implements FileFilter {
+
+ /**
+ */
+ public HtmlFileFilter() {
+ //
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean accept(File pathname) {
+ return pathname!=null &&
+ (pathname.isDirectory() ||
+ pathname.getName().endsWith(".html")); //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return "Hypertext (.html)"; //$NON-NLS-1$
+ }
+
+}
Added: trunk/maventools/src/main/java/org/arakhne/maven/JavaSourceFileFilter.java
===================================================================
--- trunk/maventools/src/main/java/org/arakhne/maven/JavaSourceFileFilter.java (rev 0)
+++ trunk/maventools/src/main/java/org/arakhne/maven/JavaSourceFileFilter.java 2011-08-05 20:43:42 UTC (rev 238)
@@ -0,0 +1,60 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2010-11 Stéphane 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;
+
+import java.io.File;
+import java.io.FileFilter;
+
+/**
+ * File filter for HTML Java file.
+ *
+ * @author $Author: galland$
+ * @version $Name$ $Revision$ $Date$
+ * @mavengroupid $GroupId$
+ * @mavenartifactid $ArtifactId$
+ */
+public class JavaSourceFileFilter implements FileFilter {
+
+ /**
+ */
+ public JavaSourceFileFilter() {
+ //
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean accept(File pathname) {
+ return pathname!=null &&
+ (pathname.isDirectory() ||
+ pathname.getName().endsWith(".java")); //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return "Java Source (.java)"; //$NON-NLS-1$
+ }
+
+}
Added: trunk/maventools/src/main/java/org/arakhne/maven/MultiFileFilter.java
===================================================================
--- trunk/maventools/src/main/java/org/arakhne/maven/MultiFileFilter.java (rev 0)
+++ trunk/maventools/src/main/java/org/arakhne/maven/MultiFileFilter.java 2011-08-05 20:43:42 UTC (rev 238)
@@ -0,0 +1,121 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2011 Stéphane 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;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+/**
+ * File filter that is matching a collection
+ * of file filters.
+ *
+ * @author $Author: galland$
+ * @version $Name$ $Revision$ $Date$
+ * @mavengroupid $GroupId$
+ * @mavenartifactid $ArtifactId$
+ */
+public class MultiFileFilter implements FileFilter {
+
+ private final Collection<FileFilter> filters = new ArrayList<FileFilter>();
+
+ /**
+ */
+ public MultiFileFilter() {
+ //
+ }
+
+ /**
+ * @param filters
+ */
+ public MultiFileFilter(Collection<? extends FileFilter> filters) {
+ if (filters!=null) this.filters.addAll(filters);
+ }
+
+ /**
+ * @param filters
+ */
+ public MultiFileFilter(FileFilter... filters) {
+ this.filters.addAll(Arrays.asList(filters));
+ }
+
+ /** Add file filter.
+ *
+ * @param filter
+ */
+ public void addFileFilter(FileFilter... filter) {
+ this.filters.addAll(Arrays.asList(filter));
+ }
+
+ /** Add file filters.
+ *
+ * @param filters
+ */
+ public void addFileFilter(Collection<? extends FileFilter> filters) {
+ if (filters!=null) this.filters.addAll(filters);
+ }
+
+ /** Remove all the filter filters.
+ */
+ public void clear() {
+ this.filters.clear();
+ }
+
+ /** Remove the given filter filter.
+ *
+ * @param filter
+ */
+ public void removeFileFilter(FileFilter... filter) {
+ this.filters.removeAll(Arrays.asList(filter));
+ }
+
+ /** Remove the given filter filters.
+ *
+ * @param filters
+ */
+ public void removeFileFilter(Collection<? super FileFilter> filters) {
+ this.filters.removeAll(filters);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean accept(File pathname) {
+ if (pathname==null) return false;
+ if (pathname.isDirectory()) return true;
+ for(FileFilter filter : this.filters) {
+ if (filter.accept(pathname)) return true;
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return "Multiple file"; //$NON-NLS-1$
+ }
+
+}
\ No newline at end of file
Added: trunk/maventools/src/main/java/org/arakhne/maven/PropertyFileFilter.java
===================================================================
--- trunk/maventools/src/main/java/org/arakhne/maven/PropertyFileFilter.java (rev 0)
+++ trunk/maventools/src/main/java/org/arakhne/maven/PropertyFileFilter.java 2011-08-05 20:43:42 UTC (rev 238)
@@ -0,0 +1,60 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2011 Stéphane 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;
+
+import java.io.File;
+import java.io.FileFilter;
+
+/**
+ * File filter for property file.
+ *
+ * @author $Author: galland$
+ * @version $Name$ $Revision$ $Date$
+ * @mavengroupid $GroupId$
+ * @mavenartifactid $ArtifactId$
+ */
+public class PropertyFileFilter implements FileFilter {
+
+ /**
+ */
+ public PropertyFileFilter() {
+ //
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean accept(File pathname) {
+ return pathname!=null &&
+ (pathname.isDirectory() ||
+ pathname.getName().endsWith(".properties")); //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return "Java Properties (.properties)"; //$NON-NLS-1$
+ }
+
+}
\ No newline at end of file
Added: trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/javadoctagreplacer/AbstractReplaceMojo.java
===================================================================
--- trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/javadoctagreplacer/AbstractReplaceMojo.java (rev 0)
+++ trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/javadoctagreplacer/AbstractReplaceMojo.java 2011-08-05 20:43:42 UTC (rev 238)
@@ -0,0 +1,414 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2010-11 Stéphane 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.javadoctagreplacer;
+
+import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+import org.apache.maven.model.Contributor;
+import org.apache.maven.model.Organization;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.arakhne.maven.AbstractArakhneMojo;
+import org.arakhne.maven.ExtendedArtifact;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Replace all the tags variables by the corresponding values.
+ * Supported variables are:<table>
+ * <thead>
+ * <tr><th>Name (case-sensitive)</th><th>Description</th></tr>
+ * </thead>
+ * <tbody>
+ * <tr><td>$ArtifactId$</td><td>The artifact id of the Maven module</td></tr>
+ * <tr><td>$Author: id$</td><td>The name and link to the author with the given id. The id is the
+ * identifier of the author or contributor defined the <code>pom.xml</code> file; or it is the
+ * email address of the author.</td></tr>
+ * <tr><td>$Date$</td><td>The date of the last compilation of the Maven module</td></tr>
+ * <tr><td>$GroupId$</td><td>The group id of the Maven module</td></tr>
+ * <tr><td>$Id$</td><td>The id of file</td></tr>
+ * <tr><td>$Name$</td><td>The name of the Maven module</td></tr>
+ * <tr><td>$Organization$</td><td>The name of organization that publishs the Maven module</td></tr>
+ * <tr><td>$Revision$</td><td>The version of the Maven module</td></tr>
+ * <tr><td>$Version$</td><td>The version of the Maven module</td></tr>
+ * <tr><td>$Website$</td><td>The link to the website of the Maven module</td></tr>
+ * </tbody>
+ * </table>
+ *
+ * @author $Author: galland$
+ * @version $Name$ $Revision$ $Date$
+ * @mavengroupid $GroupId$
+ * @mavenartifactid $ArtifactId$
+ */
+public abstract class AbstractReplaceMojo extends AbstractArakhneMojo implements Macros {
+
+ /** @component
+ */
+ private ArtifactHandlerManager artifactHandlerManager;
+
+ /** @parameter expression="${project.build.directory}"
+ */
+ private File outputDirectory;
+
+ /** @parameter expression="${project.basedir}/src"
+ */
+ private File sourceDirectory;
+
+ /** Is the artifact id that should replace the project's artifact id.
+ * @parameter default-value="${project.artifactId}"
+ */
+ private String artifactId;
+
+ /** Is the group id that should replace the project's group id.
+ * @parameter default-value="${project.groupId}"
+ */
+ private String groupId;
+
+ /** Indicates if the group id and artifact id of the current
+ * project should be replaced by <var>userArtifactId</var>
+ * and <var>artifactId</var>
+ * @parameter default-value="true"
+ */
+ private boolean overrideArtifactGroup;
+
+ /** Reference to the current maven project.
+ *
+ * @parameter expression="${project}"
+ */
+ private MavenProject mavenProject;
+
+ private String ensureArtifactId(ExtendedArtifact artifact) {
+ if (artifact!=null) {
+ if (this.overrideArtifactGroup && this.mavenProject.getArtifact().equals(artifact)) {
+ String a = this.artifactId;
+ if (a!=null && !EMPTY_STRING.equals(a)) {
+ return this.artifactId;
+ }
+ }
+ return artifact.getArtifactId();
+ }
+ return EMPTY_STRING;
+ }
+
+ private String ensureGroupId(ExtendedArtifact artifact) {
+ if (artifact!=null) {
+ if (this.overrideArtifactGroup && this.mavenProject.getArtifact().equals(artifact)) {
+ String g = this.groupId;
+ if (g!=null && !EMPTY_STRING.equals(g)) {
+ return this.groupId;
+ }
+ }
+ return artifact.getGroupId();
+ }
+ return EMPTY_STRING;
+ }
+
+ /** Replace the Javadoc tags in the given file.
+ *
+ * @param file is the name of the file on the local file system.
+ * @param filename is the name of the file in the javadoc hierarchy.
+ * @param replacementType is the type of replacement to be done.
+ * @throws MojoExecutionException
+ */
+ protected void replaceInFile(File file, String filename, ReplacementType replacementType) throws MojoExecutionException {
+
+ ExtendedArtifact artifact = searchArtifact(file);
+
+ if (artifact!=null) {
+ getLog().info("Replacing in "+file.getAbsolutePath()+" with artifact "+ //$NON-NLS-1$ //$NON-NLS-2$
+ ArtifactUtils.key(artifact));
+ }
+ else {
+ getLog().info("Replacing in "+file.getAbsolutePath()+" without artifact"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ File outputFile = null;
+ try {
+ outputFile = new File(file.getAbsolutePath()+".maven.tmp"); //$NON-NLS-1$
+ BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile));
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ String line = reader.readLine();
+ while (line!=null) {
+ line = replaceInString(filename, artifact, line, replacementType);
+ writer.write(line);
+ writer.write("\n"); //$NON-NLS-1$
+ line = reader.readLine();
+ }
+ writer.close();
+ reader.close();
+ fileCopy(outputFile, file);
+ outputFile.delete();
+ }
+ catch(IOException e) {
+ throw new MojoExecutionException(e.getLocalizedMessage(), e);
+ }
+ finally {
+ if (outputFile!=null && outputFile.exists()) outputFile.delete();
+ }
+ }
+
+ private Pattern buildMacroPattern(String macroName) {
+ StringBuffer b = new StringBuffer();
+ b.append(Pattern.quote("$")); //$NON-NLS-1$
+ b.append(macroName);
+ b.append("(?:"); //$NON-NLS-1$
+ b.append(Pattern.quote(":")); //$NON-NLS-1$
+ b.append("[^\\$]*)?"); //$NON-NLS-1$
+ b.append(Pattern.quote("$")); //$NON-NLS-1$
+ return Pattern.compile(b.toString(), Pattern.CASE_INSENSITIVE);
+ }
+
+ private Pattern buildMacroPatternWithGroup(String macroName) {
+ StringBuffer b = new StringBuffer();
+ b.append(Pattern.quote("$")); //$NON-NLS-1$
+ b.append(macroName);
+ b.append("(?:"); //$NON-NLS-1$
+ b.append(Pattern.quote(":")); //$NON-NLS-1$
+ b.append("([^\\$]*))?"); //$NON-NLS-1$
+ b.append(Pattern.quote("$")); //$NON-NLS-1$
+ return Pattern.compile(b.toString(), Pattern.CASE_INSENSITIVE);
+ }
+
+ private String quoteReplacementText(String replacement) {
+ // Protect the dollar and backslashs signs
+ String s = replacement.replaceAll(Pattern.quote("$"), "$"); //$NON-NLS-1$//$NON-NLS-2$
+ s = s.replaceAll(Pattern.quote("\\\\"), "&backslash;"); //$NON-NLS-1$//$NON-NLS-2$
+ return s;
+ }
+
+ private String unquoteReplacementText(String replacement) {
+ // Unprotect the dollar and backslashs signs
+ String s = replacement.replaceAll(Pattern.quote("$"), "\\$"); //$NON-NLS-1$//$NON-NLS-2$
+ s = s.replaceAll(Pattern.quote("&backslash;"), "\\\\"); //$NON-NLS-1$//$NON-NLS-2$
+ return s;
+ }
+
+ /** Uitility function that replace the macros by the replacement text in the given text.
+ *
+ * @param macroName is the name of the macro to replace.
+ * @param text is the text in which the replacement should occur
+ * @param replacement is the replacement text.
+ * @return the result of the replacement
+ */
+ protected final String replaceMacro(String macroName, String text, String replacement) {
+ Pattern p = buildMacroPattern(macroName);
+ Matcher m = p.matcher(text);
+ return unquoteReplacementText(m.replaceAll(quoteReplacementText(replacement)));
+ }
+
+ /** Replace the author information tags in the given text.
+ *
+ * @param text is the text in which the author tags should be replaced
+ * @param artifact
+ * @param replacementType is the type of replacement.
+ * @return the result of the replacement.
+ * @throws MojoExecutionException
+ */
+ protected String replaceAuthor(String text, ExtendedArtifact artifact, ReplacementType replacementType) throws MojoExecutionException {
+ String result = text;
+ Pattern p = buildMacroPatternWithGroup(MACRO_AUTHOR);
+ Matcher m = p.matcher(text);
+ boolean hasResult = m.find();
+
+ if (hasResult) {
+ StringBuffer sb = new StringBuffer();
+ StringBuffer replacement = new StringBuffer();
+ String login, link;
+ Contributor contributor;
+ do {
+ login = m.group(1);
+ if (login!=null) {
+ login = login.trim();
+ if (login.length()>0) {
+ replacement.setLength(0);
+ if (artifact!=null) {
+ contributor = artifact.getContributor(login);
+ if (contributor!=null) {
+ link = contributor.getUrl();
+ if (link==null || EMPTY_STRING.equals(link)) {
+ link = contributor.getEmail();
+ }
+ if (link==null || EMPTY_STRING.equals(link)) {
+ replacement.append(contributor.getName());
+ }
+ else if (replacementType==ReplacementType.HTML) {
+ replacement.append("<a target=\"_blank\" href=\""); //$NON-NLS-1$
+ replacement.append(link);
+ replacement.append("\">"); //$NON-NLS-1$
+ replacement.append(contributor.getName());
+ replacement.append("</a>"); //$NON-NLS-1$
+ }
+ else {
+ replacement.append(contributor.getName());
+ replacement.append(" ["); //$NON-NLS-1$
+ replacement.append(link);
+ replacement.append("]"); //$NON-NLS-1$
+ }
+ }
+ else {
+ throw new MojoExecutionException("unable to find a developer or a contributor with an id, a name or an email equal to: "+login); //$NON-NLS-1$
+ }
+ }
+ m.appendReplacement(sb, quoteReplacementText(replacement.toString()));
+ }
+ else {
+ throw new MojoExecutionException("no login for Author tag: "+m.group(0)); //$NON-NLS-1$
+ }
+ }
+ else {
+ throw new MojoExecutionException("no login for Author tag: "+m.group(0)); //$NON-NLS-1$
+ }
+ hasResult = m.find();
+ }
+ while (hasResult);
+
+ m.appendTail(sb);
+
+ result = unquoteReplacementText(sb.toString());
+ }
+ return result;
+ }
+
+ /** Replace Javadoc tags in a string.
+ *
+ * @param file is the name of the file in the javadoc hierarchy from which the string was extracted.
+ * @param artifact is the artifact in which the file is located. If <code>null</code>
+ * the tags dedicated to the artifact will be replaced by the empty string.
+ * @param line is the line in which the tags should be replaced.
+ * @param replacementType is the type of replacement to be done.
+ * @return the result of the replacement.
+ * @throws MojoExecutionException
+ */
+ protected String replaceInString(String file, ExtendedArtifact artifact, String line, ReplacementType replacementType) throws MojoExecutionException {
+ String nline = line;
+
+ StringBuffer buffer = new StringBuffer();
+
+ String replacementName = (artifact==null) ? EMPTY_STRING : artifact.getName();
+ String replacementVersion = (artifact==null) ? EMPTY_STRING : artifact.getVersion();
+ String replacementArtifactId = ensureArtifactId(artifact);
+ String replacementGroupId = ensureGroupId(artifact);
+ String replacementWebsite = (artifact==null) ? EMPTY_STRING : artifact.getWebsite();
+
+ String replacementOrganization = EMPTY_STRING;
+
+ if (artifact!=null) {
+ Organization orga = artifact.getOrganization();
+ if (orga!=null) {
+ replacementOrganization = orga.getName();
+ }
+ }
+
+ nline = replaceMacro(MACRO_NAME, nline, replacementName);
+ nline = replaceMacro(MACRO_REVISION, nline, replacementVersion);
+ nline = replaceMacro(MACRO_VERSION, nline, replacementVersion);
+ nline = replaceMacro(MACRO_ARTIFACTID, nline, replacementArtifactId);
+ nline = replaceMacro(MACRO_GROUPID, nline, replacementGroupId);
+ nline = replaceMacro(MACRO_WEBSITE, nline, replacementWebsite);
+ nline = replaceMacro(MACRO_ORGANIZATION, nline, replacementOrganization);
+
+ SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //$NON-NLS-1$
+ String currentDate = fmt.format(this.invocationDate);
+ nline = replaceMacro(MACRO_DATE, nline, currentDate);
+
+ buffer.setLength(0);
+ buffer.append("$Id: "); //$NON-NLS-1$
+ buffer.append(file);
+ buffer.append(' ');
+ if (artifact!=null) {
+ buffer.append(replacementVersion);
+ buffer.append(' ');
+ }
+ buffer.append(currentDate);
+ buffer.append("$"); //$NON-NLS-1$
+ nline = replaceMacro(MACRO_ID, nline, buffer.toString());
+
+ nline = replaceAuthor(nline, artifact, replacementType);
+
+ return nline;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void checkMojoAttributes() {
+ assertNotNull("outputDirectory", this.outputDirectory); //$NON-NLS-1$
+ assertNotNull("sourceDirectory", this.sourceDirectory); //$NON-NLS-1$
+ assertNotNull("artifactHandlerManager", this.artifactHandlerManager); //$NON-NLS-1$
+ assertNotNull("mavenProject", this.mavenProject); //$NON-NLS-1$
+ assertNotNull("artifactId", this.artifactId); //$NON-NLS-1$
+ assertNotNull("groupId", this.groupId); //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected File getOutputDirectory() {
+ return this.outputDirectory;
+ }
+
+ /**
+ * Replies the directory where source are located.
+ *
+ * @return the directory where source are located.
+ */
+ protected File getSourceDirectory() {
+ return this.sourceDirectory;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ArtifactHandlerManager getArtifactHandlerManager() {
+ return this.artifactHandlerManager;
+ }
+
+ /**
+ * Types of replacement.
+ *
+ * @author $Author: galland$
+ * @version $Name$ $Revision$ $Date$
+ * @mavengroupid $GroupId$
+ * @mavenartifactid $ArtifactId$
+ */
+ protected enum ReplacementType {
+ /** HTML replacement.
+ */
+ HTML,
+
+ /** Raw text replacement.
+ */
+ TEXT;
+
+ }
+
+}
Added: trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/javadoctagreplacer/Macros.java
===================================================================
--- trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/javadoctagreplacer/Macros.java (rev 0)
+++ trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/javadoctagreplacer/Macros.java 2011-08-05 20:43:42 UTC (rev 238)
@@ -0,0 +1,73 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2010-11 Stéphane 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.javadoctagreplacer;
+
+/**
+ * List of the macros strings.
+ *
+ * @author $Author: galland$
+ * @version $Name$ $Revision$ $Date$
+ * @mavengroupid $GroupId$
+ * @mavenartifactid $ArtifactId$
+ */
+public interface Macros {
+
+ /** $ArtifactId$
+ */
+ public static final String MACRO_ARTIFACTID = "ArtifactId"; //$NON-NLS-1$
+
+ /** $Author$
+ */
+ public static final String MACRO_AUTHOR = "Author"; //$NON-NLS-1$
+
+ /** $Date$
+ */
+ public static final String MACRO_DATE = "Date"; //$NON-NLS-1$
+
+ /** $GroupId$
+ */
+ public static final String MACRO_GROUPID = "GroupId"; //$NON-NLS-1$
+
+ /** $Id$
+ */
+ public static final String MACRO_ID = "Id"; //$NON-NLS-1$
+
+ /** $Name$
+ */
+ public static final String MACRO_NAME = "Name"; //$NON-NLS-1$
+
+ /** $Organization$
+ */
+ public static final String MACRO_ORGANIZATION = "Organization"; //$NON-NLS-1$
+
+ /** $Revision$
+ */
+ public static final String MACRO_REVISION = "Revision"; //$NON-NLS-1$
+
+ /** $Version$
+ */
+ public static final String MACRO_VERSION = "Version"; //$NON-NLS-1$
+
+ /** $Website$
+ */
+ public static final String MACRO_WEBSITE = "Website"; //$NON-NLS-1$
+
+}
Modified: trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/javadoctagreplacer/ReplaceHtmlMojo.java
===================================================================
--- trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/javadoctagreplacer/ReplaceHtmlMojo.java 2011-08-05 16:51:52 UTC (rev 237)
+++ trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/javadoctagreplacer/ReplaceHtmlMojo.java 2011-08-05 20:43:42 UTC (rev 238)
@@ -20,25 +20,11 @@
*/
package org.arakhne.maven.plugins.javadoctagreplacer;
-import org.apache.maven.artifact.ArtifactUtils;
-import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
-import org.apache.maven.model.Contributor;
-import org.apache.maven.model.Organization;
import org.apache.maven.plugin.MojoExecutionException;
-import org.arakhne.maven.AbstractArakhneMojo;
-import org.arakhne.maven.ExtendedArtifact;
+import org.arakhne.maven.HtmlFileFilter;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileFilter;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
import java.util.Collection;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
/**
* Replace all the Javadoc variables by the corresponding values.
@@ -62,7 +48,7 @@
* </tbody>
* </table>
*
- * @author Stéphane GALLAND <galland@xxxxxxxxxxx>
+ * @author $Author: galland$
* @version $Name$ $Revision$ $Date$
* @mavengroupid $GroupId$
* @mavenartifactid $ArtifactId$
@@ -71,16 +57,8 @@
* @phase site
* @requireProject true
*/
-public class ReplaceHtmlMojo extends AbstractArakhneMojo {
+public class ReplaceHtmlMojo extends AbstractReplaceMojo {
- /** @component
- */
- private ArtifactHandlerManager artifactHandlerManager;
-
- /** @parameter expression="${project.build.directory}"
- */
- private File outputDirectory;
-
/**
* {@inheritDoc}
*/
@@ -96,260 +74,15 @@
if ( javadocDir.isDirectory() ) {
// Search for files
- Collection<File> htmlFiles = findFiles(javadocDir, new HTMLFileFilter());
+ Collection<File> htmlFiles = findFiles(javadocDir, new HtmlFileFilter());
// Replace in files
for(File file : htmlFiles) {
String filename = file.toString().replace(javadocDir.toString(), EMPTY_STRING);
- replaceInFile(file, filename);
+ replaceInFile(file, filename, ReplacementType.HTML);
}
}
}
}
-
- /** Replace the Javadoc tags in the given file.
- *
- * @param file is the name of the file on the local file system.
- * @param filename is the name of the file in the javadoc hierarchy.
- * @throws MojoExecutionException
- */
- protected void replaceInFile(File file, String filename) throws MojoExecutionException {
-
- ExtendedArtifact artifact = searchArtifact(file);
-
- if (artifact!=null) {
- getLog().info("Replacing in "+file.getAbsolutePath()+" with artifact "+ //$NON-NLS-1$ //$NON-NLS-2$
- ArtifactUtils.key(artifact));
- }
- else {
- getLog().info("Replacing in "+file.getAbsolutePath()+" without artifact"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- File outputFile = null;
- try {
- outputFile = new File(file.getAbsolutePath()+".maven.tmp"); //$NON-NLS-1$
- BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile));
- BufferedReader reader = new BufferedReader(new FileReader(file));
- String line = reader.readLine();
- while (line!=null) {
- line = replaceInString(filename, artifact, line);
- writer.write(line);
- writer.write("\n"); //$NON-NLS-1$
- line = reader.readLine();
- }
- writer.close();
- reader.close();
- fileCopy(outputFile, file);
- outputFile.delete();
- }
- catch(IOException e) {
- throw new MojoExecutionException(e.getLocalizedMessage(), e);
- }
- finally {
- if (outputFile!=null && outputFile.exists()) outputFile.delete();
- }
- }
-
- /** Uitility function that replace the macros by the replacement text in the given text.
- *
- * @param macroName is the name of the macro to replace.
- * @param text is the text in which the replacement should occur
- * @param replacement is the replacement text.
- * @return the result of the replacement
- */
- protected final String replaceMacro(String macroName, String text, String replacement) {
- StringBuffer b = new StringBuffer();
- b.append("\\Q$\\E"); //$NON-NLS-1$
- b.append(macroName);
- b.append("(?:\\Q:\\E[^\\$]*)?\\Q$\\E"); //$NON-NLS-1$
- Pattern p = Pattern.compile(b.toString(), Pattern.CASE_INSENSITIVE);
- Matcher m = p.matcher(text);
- return m.replaceAll(replacement);
- }
-
- /** Replace the author information tags in the given text.
- *
- * @param text is the text in which the author tags should be replaced
- * @param artifact
- * @return the result of the replacement.
- * @throws MojoExecutionException
- */
- protected String replaceAuthor(String text, ExtendedArtifact artifact) throws MojoExecutionException {
- String result = text;
- Pattern p = Pattern.compile("[$]Author:([^$]+)[$]", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
- Matcher m = p.matcher(text);
- boolean hasResult = m.find();
- if (hasResult) {
- StringBuffer sb = new StringBuffer();
- StringBuffer replacement = new StringBuffer();
- String login, link;
- Contributor contributor;
- do {
- login = m.group(1);
- if (login!=null) {
- login = login.trim();
- if (login.length()>0) {
- replacement.setLength(0);
- if (artifact!=null) {
- contributor = artifact.getContributor(login);
- if (contributor!=null) {
- link = contributor.getUrl();
- if (link==null || EMPTY_STRING.equals(link)) {
- link = contributor.getEmail();
- }
- if (link==null || EMPTY_STRING.equals(link)) {
- replacement.append(contributor.getName());
- }
- else {
- replacement.append("<a target=\"_blank\" href=\""); //$NON-NLS-1$
- replacement.append(link);
- replacement.append("\">"); //$NON-NLS-1$
- replacement.append(contributor.getName());
- replacement.append("</a>"); //$NON-NLS-1$
- }
- }
- else {
- throw new MojoExecutionException("unable to find a developer or a contributor with an id, a name or an email equal to: "+login); //$NON-NLS-1$
- }
- }
- m.appendReplacement(sb, replacement.toString());
- }
- else {
- throw new MojoExecutionException("no login for Author tag: "+m.group(0)); //$NON-NLS-1$
- }
- }
- else {
- throw new MojoExecutionException("no login for Author tag: "+m.group(0)); //$NON-NLS-1$
- }
- hasResult = m.find();
- }
- while (hasResult);
-
- m.appendTail(sb);
-
- result = sb.toString();
- }
- return result;
- }
-
- /** Replace Javadoc tags in a string.
- *
- * @param file is the name of the file in the javadoc hierarchy from which the string was extracted.
- * @param artifact is the artifact in which the file is located. If <code>null</code>
- * the tags dedicated to the artifact will be replaced by the empty string.
- * @param line is the line in which the tags should be replaced.
- * @return the result of the replacement.
- * @throws MojoExecutionException
- */
- protected String replaceInString(String file, ExtendedArtifact artifact, String line) throws MojoExecutionException {
- String nline = line;
-
- StringBuffer buffer = new StringBuffer();
-
- String replacementName = (artifact==null) ? EMPTY_STRING : artifact.getName();
- String replacementVersion = (artifact==null) ? EMPTY_STRING : artifact.getVersion();
- String replacementArtifactId = (artifact==null) ? EMPTY_STRING : artifact.getArtifactId();
- String replacementGroupId = (artifact==null) ? EMPTY_STRING : artifact.getGroupId();
- String replacementWebsite = (artifact==null) ? EMPTY_STRING : artifact.getWebsite();
-
- String replacementOrganization = EMPTY_STRING;
-
- if (artifact!=null) {
- Organization orga = artifact.getOrganization();
- if (orga!=null) {
- replacementOrganization = orga.getName();
- }
- }
-
- nline = replaceMacro("Name", nline, replacementName); //$NON-NLS-1$
- nline = replaceMacro("Revision", nline, replacementVersion); //$NON-NLS-1$
- nline = replaceMacro("Version", nline, replacementVersion); //$NON-NLS-1$
- nline = replaceMacro("ArtifactId", nline, replacementArtifactId); //$NON-NLS-1$
- nline = replaceMacro("GroupId", nline, replacementGroupId); //$NON-NLS-1$
- nline = replaceMacro("Website", nline, replacementWebsite); //$NON-NLS-1$
- nline = replaceMacro("Organization", nline, replacementOrganization); //$NON-NLS-1$
-
- SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //$NON-NLS-1$
- String currentDate = fmt.format(this.invocationDate);
- nline = replaceMacro("Date", nline, currentDate); //$NON-NLS-1$
-
- buffer.setLength(0);
- buffer.append("$Id: "); //$NON-NLS-1$
- buffer.append(file);
- buffer.append(' ');
- if (artifact!=null) {
- buffer.append(replacementVersion);
- buffer.append(' ');
- }
- buffer.append(currentDate);
- buffer.append("$"); //$NON-NLS-1$
- nline = replaceMacro("Id", nline, buffer.toString()); //$NON-NLS-1$
-
- nline = replaceAuthor(nline, artifact);
-
- return nline;
- }
-
- /**
- * File filter for HTML file.
- *
- * @author Stéphane GALLAND <galland@xxxxxxxxxxx>
- * @version $Name$ $Revision$ $Date$
- * @mavengroupid $GroupId$
- * @mavenartifactid $ArtifactId$
- */
- private class HTMLFileFilter implements FileFilter {
-
- /**
- */
- public HTMLFileFilter() {
- //
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean accept(File pathname) {
- return pathname!=null &&
- (pathname.isDirectory() ||
- pathname.getName().endsWith(".html")); //$NON-NLS-1$
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "Hypertext (.html)"; //$NON-NLS-1$
- }
-
- } // class HTMLFileFilter
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void checkMojoAttributes() {
- assertNotNull("outputDirectory", this.outputDirectory); //$NON-NLS-1$
- assertNotNull("artifactHandlerManager", this.artifactHandlerManager); //$NON-NLS-1$
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected File getOutputDirectory() {
- return this.outputDirectory;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ArtifactHandlerManager getArtifactHandlerManager() {
- return this.artifactHandlerManager;
- }
-
}
Added: trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/javadoctagreplacer/ReplaceSourceMojo.java
===================================================================
--- trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/javadoctagreplacer/ReplaceSourceMojo.java (rev 0)
+++ trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/javadoctagreplacer/ReplaceSourceMojo.java 2011-08-05 20:43:42 UTC (rev 238)
@@ -0,0 +1,93 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2010-11 Stéphane 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.javadoctagreplacer;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.arakhne.maven.JavaSourceFileFilter;
+import org.arakhne.maven.PropertyFileFilter;
+
+import java.io.File;
+import java.util.Collection;
+
+/**
+ * Replace all the source file's variables by the corresponding values.
+ * Supported variables are:<table>
+ * <thead>
+ * <tr><th>Name (case-sensitive)</th><th>Description</th></tr>
+ * </thead>
+ * <tbody>
+ * <tr><td>$ArtifactId$</td><td>The artifact id of the Maven module</td></tr>
+ * <tr><td>$Author: id$</td><td>The name and link to the author with the given id. The id is the
+ * identifier of the author or contributor defined the <code>pom.xml</code> file; or it is the
+ * email address of the author.</td></tr>
+ * <tr><td>$Date$</td><td>The date of the last compilation of the Maven module</td></tr>
+ * <tr><td>$GroupId$</td><td>The group id of the Maven module</td></tr>
+ * <tr><td>$Id$</td><td>The id of file</td></tr>
+ * <tr><td>$Name$</td><td>The name of the Maven module</td></tr>
+ * <tr><td>$Organization$</td><td>The name of organization that publishs the Maven module</td></tr>
+ * <tr><td>$Revision$</td><td>The version of the Maven module</td></tr>
+ * <tr><td>$Version$</td><td>The version of the Maven module</td></tr>
+ * <tr><td>$Website$</td><td>The link to the website of the Maven module</td></tr>
+ * </tbody>
+ * </table>
+ *
+ * @author $Author: galland$
+ * @version $Name$ $Revision$ $Date$
+ * @mavengroupid $GroupId$
+ * @mavenartifactid $ArtifactId$
+ *
+ * @goal replacesrc
+ * @phase site
+ * @requireProject true
+ */
+public class ReplaceSourceMojo extends AbstractReplaceMojo {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void executeMojo() throws MojoExecutionException {
+ File sourceDir = getSourceDirectory();
+
+ clearInternalBuffers();
+ if ( sourceDir.isDirectory() ) {
+
+ // Search for .java files
+ Collection<File> sourceFiles = findFiles(sourceDir, new JavaSourceFileFilter());
+
+ // Replace in .java files
+ for(File file : sourceFiles) {
+ String filename = file.toString().replace(sourceDir.getParent().toString(), EMPTY_STRING);
+ replaceInFile(file, filename, ReplacementType.HTML);
+ }
+
+ // Search for .properties files
+ Collection<File> propertyFiles = findFiles(sourceDir, new PropertyFileFilter());
+
+ // Replace in .properties files
+ for(File file : propertyFiles) {
+ String filename = file.toString().replace(sourceDir.getParent().toString(), EMPTY_STRING);
+ replaceInFile(file, filename, ReplacementType.TEXT);
+ }
+ }
+ }
+
+}