[Arakhnę-Dev] [262] * Prepare for Maven 3

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


Revision: 262
Author:   galland
Date:     2011-08-18 12:03:30 +0200 (Thu, 18 Aug 2011)
Log Message:
-----------
* Prepare for Maven 3

Modified Paths:
--------------
    trunk/license-installer/src/main/java/org/arakhne/maven/plugins/licenseinstaller/InstallLicenseMojo.java
    trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java
    trunk/maventools/src/main/java/org/arakhne/maven/ExtendedArtifact.java
    trunk/pom.xml
    trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/AbstractReplaceMojo.java

Modified: trunk/license-installer/src/main/java/org/arakhne/maven/plugins/licenseinstaller/InstallLicenseMojo.java
===================================================================
--- trunk/license-installer/src/main/java/org/arakhne/maven/plugins/licenseinstaller/InstallLicenseMojo.java	2011-08-13 17:30:11 UTC (rev 261)
+++ trunk/license-installer/src/main/java/org/arakhne/maven/plugins/licenseinstaller/InstallLicenseMojo.java	2011-08-18 10:03:30 UTC (rev 262)
@@ -32,10 +32,13 @@
 
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Contributor;
 import org.apache.maven.model.Developer;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.repository.RepositorySystem;
 import org.arakhne.maven.AbstractArakhneMojo;
 
 /**
@@ -122,8 +125,24 @@
      */
     private String name;
 
-    /** {@inheritDoc}
+	/** Reference to the current session.
+	 * @parameter expression="${session}"
+	 * @required
 	 */
+	private MavenSession mavenSession;
+
+	/** Reference to the current repository system.
+	 * @component
+	 */
+	private RepositorySystem repositorySystem;
+
+	/** Refenrece to the current resolution handler.
+	 * @component
+	 */
+	private ResolutionErrorHandler resolutionErrorHandler;
+
+	/** {@inheritDoc}
+	 */
     @Override
 	public synchronized void checkMojoAttributes() {
 		assertNotNull("copyrightDates", this.copyrightDates); //$NON-NLS-1$
@@ -132,6 +151,9 @@
 		assertNotNull("projectURL", this.projectURL); //$NON-NLS-1$
 		assertNotNull("outputDirectory", this.outputDirectory); //$NON-NLS-1$
 		assertNotNull("artifactHandlerManager", this.artifactHandlerManager); //$NON-NLS-1$
+		assertNotNull("mavenProject", this.mavenProject); //$NON-NLS-1$
+		assertNotNull("mavenSession", this.mavenSession); //$NON-NLS-1$
+		assertNotNull("repositorySystem", this.repositorySystem); //$NON-NLS-1$
 	}
 
 	/**
@@ -358,4 +380,28 @@
 		return this.artifactHandlerManager;
 	}
 
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	protected MavenSession getMavenSession() {
+		return this.mavenSession;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	protected RepositorySystem getRepositorySystem() {
+		return this.repositorySystem;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	protected ResolutionErrorHandler getResolutionErrorHandler() {
+		return this.resolutionErrorHandler;
+	}
+
 }

Modified: trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java
===================================================================
--- trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java	2011-08-13 17:30:11 UTC (rev 261)
+++ trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java	2011-08-18 10:03:30 UTC (rev 262)
@@ -19,11 +19,22 @@
 package org.arakhne.maven;
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.artifact.DefaultArtifact;
 import org.apache.maven.artifact.factory.DefaultArtifactFactory;
 import org.apache.maven.artifact.handler.ArtifactHandler;
 import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
+import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
+import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
 import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Contributor;
 import org.apache.maven.model.Developer;
 import org.apache.maven.model.License;
@@ -34,6 +45,8 @@
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.repository.RepositorySystem;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 import org.tmatesoft.svn.core.SVNException;
 import org.tmatesoft.svn.core.wc.SVNClientManager;
@@ -63,6 +76,7 @@
 import java.nio.charset.CodingErrorAction;
 import java.text.MessageFormat;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Date;
 import java.util.Iterator;
@@ -89,7 +103,7 @@
  * @component
  */
 public abstract class AbstractArakhneMojo extends AbstractMojo {
-	
+
 	/** Empty string constant.
 	 */
 	public static final String EMPTY_STRING = ExtendedArtifact.EMPTY_STRING;
@@ -98,12 +112,12 @@
 	 * Maven tag for artifcat id
 	 */
 	public static final String PROP_ARTIFACTID = "artifactId"; //$NON-NLS-1$
-	
+
 	/**
 	 * Maven tag for goup id
 	 */
 	public static final String PROP_GROUPID = "groupId"; //$NON-NLS-1$
-	
+
 	/**
 	 * Maven tag for version description
 	 */
@@ -144,7 +158,7 @@
 			if (outChannel!=null) outChannel.close();
 		}
 	}
-	
+
 	/** Copy a file.
 	 * 
 	 * @param in
@@ -184,7 +198,7 @@
 		text = MessageFormat.format(text, params);
 		return text;
 	}
-	
+
 	/** Remove the path prefix from a file.
 	 * 
 	 * @param prefix
@@ -200,24 +214,29 @@
 			return r.substring(File.separator.length());
 		return r;
 	}
-	
+
 	/** Invocation date.
 	 */
 	protected final Date invocationDate = new Date();
-	
+
 	/** Map the directory of pom.xml files to the definition
 	 * of the corresponding maven module.
 	 */
-	private final Map<File,ExtendedArtifact> artifactDescriptions = new TreeMap<File,ExtendedArtifact>();
+	private final Map<File,ExtendedArtifact> localArtifactDescriptions = new TreeMap<File,ExtendedArtifact>();
 
+	/** Map the artifact id to the definition
+	 * of the corresponding maven module.
+	 */
+	private final Map<String,ExtendedArtifact> remoteArtifactDescriptions = new TreeMap<String,ExtendedArtifact>();
+
 	/** Manager of the SVN repository.
 	 */
 	private SVNClientManager svnManager = null;
-	
+
 	/** Are the preferred charset in the preferred order.
 	 */
 	private Charset[] preferredCharsets;
-	
+
 	/**
 	 */
 	public AbstractArakhneMojo() {
@@ -231,12 +250,12 @@
 		addCharset(availableCharsets, PREFERRED_CHARSET_MACOS);
 		// Java Internal
 		addCharset(availableCharsets, PREFERRED_CHARSET_JVM);
-		
+
 		this.preferredCharsets = new Charset[availableCharsets.size()];
 		availableCharsets.toArray(this.preferredCharsets);
 		availableCharsets.clear();
 	}
-	
+
 	private static void addCharset(List<Charset> availableCharsets, String csName) {
 		try {
 			Charset cs = Charset.forName(csName);
@@ -256,7 +275,7 @@
 	protected Charset[] getPreferredCharsets() {
 		return this.preferredCharsets;
 	}
-	
+
 	/** Set the preferred charsets in the preferred order of use.
 	 * 
 	 * @param charsets are the preferred charsets in the preferred order of use.
@@ -275,7 +294,7 @@
 		}
 		return this.svnManager;
 	}
-	
+
 	/** Replies the artifact handler manager.
 	 * <p>
 	 * It is an attribute defined as:
@@ -318,6 +337,49 @@
 	 */
 	protected abstract File getBaseDirectory();
 
+	/** Replies the repository system used by this maven instance.
+	 * Basically it is an internal component of Maven.
+	 * <p>
+	 * It is an attribute defined as:
+	 * <code><pre>
+	 * <span>/</span>* <span>@</span>component
+	 * <span>*</span>/
+	 * private RepositorySystem repoSystem;
+	 * </pre></code>
+	 * 
+	 * @return the repository system
+	 */
+	protected abstract RepositorySystem getRepositorySystem();
+
+	/** Replies the current maven session.
+	 * Basically it is an internal component of Maven.
+	 * <p>
+	 * It is an attribute defined as:
+	 * <code><pre>
+	 * <span>/</span>* <span>@</span>parameter expression="&dollar;{session}"
+	 * * <span>@</span>required
+	 * <span>*</span>/
+	 * private MavenSession mvnSession;
+	 * </pre></code>
+	 * 
+	 * @return the maven session
+	 */
+	protected abstract MavenSession getMavenSession();
+
+	/** Replies the current resolution error handler.
+	 * Basically it is an internal component of Maven.
+	 * <p>
+	 * It is an attribute defined as:
+	 * <code><pre>
+	 * <span>/</span>* <span>@</span>component
+	 * <span>*</span>/
+	 * private ResolutionErrorHandler resolutionErrorHandler;
+	 * </pre></code>
+	 * 
+	 * @return the maven session
+	 */
+	protected abstract ResolutionErrorHandler getResolutionErrorHandler();
+
 	/** Search and reply the maven artifact which is corresponding to the given file.
 	 * 
 	 * @param file is the file for which the maven artifact should be retreived.
@@ -325,35 +387,35 @@
 	 */
 	protected synchronized ExtendedArtifact searchArtifact(File file) {
 		String filename = removePathPrefix(getBaseDirectory(), file);
-		
-    	getLog().debug("Retreiving module for "+filename); //$NON-NLS-1$
-    	
-    	File theFile = file;
-    	File pomDirectory = null;
-    	while (theFile!=null && pomDirectory==null) {
-    		if (theFile.isDirectory()) {
-    			File pomFile = new File(theFile, "pom.xml"); //$NON-NLS-1$
-    			if (pomFile.exists()) {
-    				pomDirectory = theFile;
-    			}
-    		}
-    		theFile = theFile.getParentFile();
-    	}
-    	
-    	if (pomDirectory!=null) {
-    		ExtendedArtifact a = this.artifactDescriptions.get(pomDirectory);
-    		if (a==null) {
-    			a = readPom(pomDirectory);
-    			this.artifactDescriptions.put(pomDirectory, a);
-    			getLog().debug("Found module description for " //$NON-NLS-1$
-    					+a.toString());
-    		}
-    		return a;
-    	}
 
+		getLog().debug("Retreiving module for "+filename); //$NON-NLS-1$
+
+		File theFile = file;
+		File pomDirectory = null;
+		while (theFile!=null && pomDirectory==null) {
+			if (theFile.isDirectory()) {
+				File pomFile = new File(theFile, "pom.xml"); //$NON-NLS-1$
+				if (pomFile.exists()) {
+					pomDirectory = theFile;
+				}
+			}
+			theFile = theFile.getParentFile();
+		}
+
+		if (pomDirectory!=null) {
+			ExtendedArtifact a = this.localArtifactDescriptions.get(pomDirectory);
+			if (a==null) {
+				a = readPom(pomDirectory);
+				this.localArtifactDescriptions.put(pomDirectory, a);
+				getLog().debug("Found local module description for " //$NON-NLS-1$
+						+a.toString());
+			}
+			return a;
+		}
+
 		getLog().warn("maven module not found"); //$NON-NLS-1$
-    	return null;
-    }
+		return null;
+	}
 
 	/** Replies a list of files which are found on the file system.
 	 * 
@@ -366,7 +428,7 @@
 		findFiles(directory, filter, files);
 		return files;
 	}
-	
+
 	/** Replies a list of files which are found on the file system.
 	 * 
 	 * @param directory is the directory to search in.
@@ -374,44 +436,44 @@
 	 * @param fileOut is the list of files to fill.
 	 */
 	protected synchronized void findFiles(File directory, FileFilter filter, Collection<? super File> fileOut) {
-    	if (directory!=null && filter!=null) {
-        	File candidate;
-	    	List<File> candidates = new ArrayList<File>();
-	    	
-	    	String relativePath = removePathPrefix(getBaseDirectory(), directory);
-	    	
-	    	getLog().debug("Retreiving " //$NON-NLS-1$
-        			+filter.toString()
-        			+" files from " //$NON-NLS-1$
-        			+relativePath);
+		if (directory!=null && filter!=null) {
+			File candidate;
+			List<File> candidates = new ArrayList<File>();
 
-	    	candidates.add(directory);
-	    	int nbFiles = 0;
-	    	
-	    	while (!candidates.isEmpty()) {
-	    		candidate = candidates.remove(0);
-	    		if (candidate.isDirectory()) {
-	    			File[] children = candidate.listFiles(filter);
-	    			if (children!=null) {
-	    				for(File child : children) {
-	    					if (child!=null && child.isDirectory()) {
-	    						candidates.add(child);
-	    					}
-	    					else {
-	    						fileOut.add(child);
-	    						++nbFiles;
-	    					}
-	    				}
-	    			}
-	    		}
-	    	}
+			String relativePath = removePathPrefix(getBaseDirectory(), directory);
 
-        	getLog().debug("Found " //$NON-NLS-1$
-        			+nbFiles
-        			+" file(s)"); //$NON-NLS-1$
-    	}
+			getLog().debug("Retreiving " //$NON-NLS-1$
+					+filter.toString()
+					+" files from " //$NON-NLS-1$
+					+relativePath);
+
+			candidates.add(directory);
+			int nbFiles = 0;
+
+			while (!candidates.isEmpty()) {
+				candidate = candidates.remove(0);
+				if (candidate.isDirectory()) {
+					File[] children = candidate.listFiles(filter);
+					if (children!=null) {
+						for(File child : children) {
+							if (child!=null && child.isDirectory()) {
+								candidates.add(child);
+							}
+							else {
+								fileOut.add(child);
+								++nbFiles;
+							}
+						}
+					}
+				}
+			}
+
+			getLog().debug("Found " //$NON-NLS-1$
+					+nbFiles
+					+" file(s)"); //$NON-NLS-1$
+		}
 	}
-	
+
 	/** Replies a map of files which are found on the file system.
 	 * The map has the found files as keys and the search directory
 	 * as values.
@@ -421,42 +483,42 @@
 	 * @param fileOut is the list of files to fill.
 	 */
 	protected synchronized void findFiles(File directory, FileFilter filter, Map<? super File,File> fileOut) {
-    	if (directory!=null && filter!=null) {
-        	File candidate;
-	    	List<File> candidates = new ArrayList<File>();
-	    	
-	    	String relativePath = removePathPrefix(getBaseDirectory(), directory);
-	    	
-	    	getLog().debug("Retreiving " //$NON-NLS-1$
-        			+filter.toString()
-        			+" files from " //$NON-NLS-1$
-        			+relativePath);
+		if (directory!=null && filter!=null) {
+			File candidate;
+			List<File> candidates = new ArrayList<File>();
 
-	    	candidates.add(directory);
-	    	int nbFiles = 0;
-	    	
-	    	while (!candidates.isEmpty()) {
-	    		candidate = candidates.remove(0);
-	    		if (candidate.isDirectory()) {
-	    			File[] children = candidate.listFiles(filter);
-	    			if (children!=null) {
-	    				for(File child : children) {
-	    					if (child!=null && child.isDirectory()) {
-	    						candidates.add(child);
-	    					}
-	    					else {
-	    						fileOut.put(child, directory);
-	    						++nbFiles;
-	    					}
-	    				}
-	    			}
-	    		}
-	    	}
+			String relativePath = removePathPrefix(getBaseDirectory(), directory);
 
-        	getLog().debug("Found " //$NON-NLS-1$
-        			+nbFiles
-        			+" file(s)"); //$NON-NLS-1$
-    	}
+			getLog().debug("Retreiving " //$NON-NLS-1$
+					+filter.toString()
+					+" files from " //$NON-NLS-1$
+					+relativePath);
+
+			candidates.add(directory);
+			int nbFiles = 0;
+
+			while (!candidates.isEmpty()) {
+				candidate = candidates.remove(0);
+				if (candidate.isDirectory()) {
+					File[] children = candidate.listFiles(filter);
+					if (children!=null) {
+						for(File child : children) {
+							if (child!=null && child.isDirectory()) {
+								candidates.add(child);
+							}
+							else {
+								fileOut.put(child, directory);
+								++nbFiles;
+							}
+						}
+					}
+				}
+			}
+
+			getLog().debug("Found " //$NON-NLS-1$
+					+nbFiles
+					+" file(s)"); //$NON-NLS-1$
+		}
 	}
 
 	/** Log an information message.
@@ -517,14 +579,24 @@
 		getLog().error(b.toString(), error);
 	}
 
-    /**
-     * Replies the maven artifact which is described by the <code>pom.xml</code>
-     * file in the given directory.
-     * 
-     * @param pomDirectory is the directory where to find the <code>pom.xml</code> file.
-     * @return the artifact or <code>null</code>.
-     */
+	/**
+	 * Replies the maven artifact which is described by the <code>pom.xml</code>
+	 * file in the given directory.
+	 * 
+	 * @param pomDirectory is the directory where to find the <code>pom.xml</code> file.
+	 * @return the artifact or <code>null</code>.
+	 */
 	protected synchronized final ExtendedArtifact readPom(File pomDirectory) {
+		return readPomFile(new File(pomDirectory, "pom.xml")); //$NON-NLS-1$
+	}
+	
+	/**
+	 * Replies the maven artifact which is described by the given <code>pom.xml</code>.
+	 * 
+	 * @param pomFile is the <code>pom.xml</code> file.
+	 * @return the artifact or <code>null</code>.
+	 */
+	protected synchronized final ExtendedArtifact readPomFile(File pomFile) {
 		String groupId = null;
 		String artifactId = null;
 		String name = null;
@@ -536,11 +608,14 @@
 		List<Contributor> contributors;
 		List<License> licenses;
 		Parent parent = null;
-		
-    	MavenXpp3Reader pomReader = new MavenXpp3Reader();
+				
+		getLog().debug("Read pom file: "+pomFile.toString()); //$NON-NLS-1$
+
+		if (!pomFile.canRead()) return null;
+
+		MavenXpp3Reader pomReader = new MavenXpp3Reader();
 		try {
-			Model model = pomReader.read(new FileReader(
-					new File(pomDirectory, "pom.xml"))); //$NON-NLS-1$
+			Model model = pomReader.read(new FileReader(pomFile));
 			groupId = model.getGroupId();
 			artifactId = model.getArtifactId();
 			name = model.getName();
@@ -548,11 +623,11 @@
 			url = model.getUrl();
 			organization = model.getOrganization();
 			scm = model.getScm();
-			
+
 			developers = model.getDevelopers();
 			contributors = model.getContributors();
 			licenses = model.getLicenses();
-			
+
 			parent = model.getParent();
 		}
 		catch (IOException e) {
@@ -586,23 +661,48 @@
 			list.addAll(licenses);
 			licenses = list;
 		}
-		
-    	if (parent!=null) {
+
+		if (parent!=null) {
 			String relPath = parent.getRelativePath();
-			File parentPomDirectory = new File(pomDirectory, relPath);
+			File parentPomDirectory = new File(pomFile.getParentFile(), relPath);
 			try {
 				parentPomDirectory = parentPomDirectory.getCanonicalFile();
 				if (!parentPomDirectory.isDirectory()) {
 					parentPomDirectory = parentPomDirectory.getParentFile();
 				}
-				ExtendedArtifact parentArtifact = this.artifactDescriptions.get(parentPomDirectory);
+				ExtendedArtifact parentArtifact = this.localArtifactDescriptions.get(parentPomDirectory);
 				if (parentArtifact==null) {
 					parentArtifact = readPom(parentPomDirectory);
 					if (parentArtifact!=null) {
-						this.artifactDescriptions.put(parentPomDirectory, parentArtifact);
-						getLog().info("Found module description for " //$NON-NLS-1$
+						this.localArtifactDescriptions.put(parentPomDirectory, parentArtifact);
+						getLog().debug("Add local module description for " //$NON-NLS-1$
 								+parentArtifact.toString());
 					}
+					else {
+						String key = ArtifactUtils.key(parent.getGroupId(), parent.getArtifactId(), parent.getVersion());
+						Artifact artifact = createArtifact(parent.getGroupId(), parent.getArtifactId(), parent.getVersion());
+						ArtifactRepository repo = getMavenSession().getLocalRepository();
+						String artifactPath = repo.pathOf(artifact);
+						artifactPath = artifactPath.replaceFirst("\\.jar$", ".pom"); //$NON-NLS-1$ //$NON-NLS-2$
+						File artifactFile = new File(repo.getBasedir(), artifactPath);
+						getLog().debug("Getting pom file in local repository for " //$NON-NLS-1$
+								+key+": "+artifactFile.getAbsolutePath()); //$NON-NLS-1$
+						if (artifactFile.canRead()) {
+							parentArtifact = readPomFile(artifactFile);
+							if (parentArtifact!=null) {
+								this.remoteArtifactDescriptions.put(key, parentArtifact);
+								getLog().debug("Add remote module description for " //$NON-NLS-1$
+										+parentArtifact.toString());
+							}
+							else {
+								getLog().warn("Unable to retreive the pom file of "+key); //$NON-NLS-1$
+							}
+						}
+						else {
+							getLog().warn("Cannot read for '"+key //$NON-NLS-1$
+									+"': "+artifactFile.getAbsolutePath()); //$NON-NLS-1$
+						}
+					}
 				}
 				if (parentArtifact!=null) {
 					developers.addAll(parentArtifact.getDevelopers());
@@ -613,12 +713,12 @@
 				getLog().warn(e);
 			}
 		}
-    	
-    	String scmRevision = null;
-    	
-    	try {
-        	SVNClientManager svnManager = getSVNClientManager();
-			SVNInfo svnInfo = svnManager.getWCClient().doInfo(pomDirectory, SVNRevision.UNDEFINED);
+
+		String scmRevision = null;
+
+		try {
+			SVNClientManager svnManager = getSVNClientManager();
+			SVNInfo svnInfo = svnManager.getWCClient().doInfo(pomFile.getParentFile(), SVNRevision.UNDEFINED);
 			if (svnInfo!=null) {
 				SVNRevision revision = svnInfo.getRevision();
 				if (revision!=null) {
@@ -626,7 +726,7 @@
 				}
 			}
 		}
-    	catch (SVNException _) {
+		catch (SVNException _) {
 			//
 		}
 
@@ -636,8 +736,66 @@
 				url, organization, scmRevision, scm,
 				developers, contributors,
 				licenses);
-    }
-	
+	}
+
+	/** Retreive the extended artifact definition of the given artifact id.
+	 *
+	 * @param groupId is the identifier of the group.
+	 * @param artifactId is the identifier of the artifact.
+	 * @param version is the version of the artifact to retreive.
+	 * @param fireExceptions indicates if the resolution exceptions should be thrown.
+	 * @return the artifact definition.
+	 * @throws ArtifactResolutionException 
+	 */
+	protected Set<Artifact> resolveArtifact(String groupId, String artifactId, String version, boolean fireExceptions) throws ArtifactResolutionException {
+		Artifact mavenArtifact = createArtifact(
+				groupId,
+				artifactId,
+				version);
+		assert(mavenArtifact!=null);
+
+		MavenSession session = getMavenSession();
+		assert(session!=null);
+		
+		MavenProject project = session.getCurrentProject();
+		assert(project!=null);
+		
+		ArtifactFilter collectionFilter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM );
+		/*
+		 * NOTE: This is a hack to support maven-deploy-plugin:[2.2.1,2.4] which has dependencies on old/buggy wagons.
+		 * Under our class loader hierarchy those would take precedence over the wagons from the distro, causing grief
+		 * due to their bugs (e.g. MNG-4528).
+		 */
+		if ( "maven-deploy-plugin".equals( artifactId ) //$NON-NLS-1$
+				&& "org.apache.maven.plugins".equals( groupId ) ) { //$NON-NLS-1$
+			collectionFilter =
+				new AndArtifactFilter( Arrays.asList( collectionFilter,
+						new ExclusionSetFilter( new String[] { "maven-core" } ) ) ); //$NON-NLS-1$
+		}
+		
+		ArtifactResolutionRequest request = new ArtifactResolutionRequest();
+		request.setLocalRepository( session.getLocalRepository() );
+		request.setRemoteRepositories( project.getPluginArtifactRepositories() );
+		request.setOffline( session.isOffline() );
+		request.setForceUpdate( session.getRequest().isUpdateSnapshots() );
+		request.setServers( session.getRequest().getServers() );
+		request.setMirrors( session.getRequest().getMirrors() );
+		request.setProxies( session.getRequest().getProxies() );
+		request.setArtifact( mavenArtifact );
+		//request.setArtifactDependencies( overrideArtifacts );
+		request.setCollectionFilter( collectionFilter );
+		//request.setResolutionFilter( resolutionFilter );
+		request.setResolveRoot( true );
+		request.setResolveTransitively( true );
+		
+		ArtifactResolutionResult result = getRepositorySystem().resolve(request);
+		
+		if (fireExceptions)
+			getResolutionErrorHandler().throwErrors( request, result );
+		
+		return result.getArtifacts();
+	}
+
 	/** Create an Jar runtime artifact from the given values.
 	 * 
 	 * @param groupId
@@ -669,38 +827,38 @@
 			String version,
 			String scope,
 			String type) {
-        VersionRange versionRange = null;
-        if (version!=null) {
-            versionRange = VersionRange.createFromVersion( version );
-        }
-        String desiredScope = scope;
+		VersionRange versionRange = null;
+		if (version!=null) {
+			versionRange = VersionRange.createFromVersion( version );
+		}
+		String desiredScope = scope;
 
-        if ( Artifact.SCOPE_TEST.equals( desiredScope ) )
-        {
-            desiredScope = Artifact.SCOPE_TEST;
-        }
+		if ( Artifact.SCOPE_TEST.equals( desiredScope ) )
+		{
+			desiredScope = Artifact.SCOPE_TEST;
+		}
 
-        if ( Artifact.SCOPE_PROVIDED.equals( desiredScope ) )
-        {
-            desiredScope = Artifact.SCOPE_PROVIDED;
-        }
+		if ( Artifact.SCOPE_PROVIDED.equals( desiredScope ) )
+		{
+			desiredScope = Artifact.SCOPE_PROVIDED;
+		}
 
-        if ( Artifact.SCOPE_SYSTEM.equals( desiredScope ) )
-        {
-            // system scopes come through unchanged...
-            desiredScope = Artifact.SCOPE_SYSTEM;
-        }
+		if ( Artifact.SCOPE_SYSTEM.equals( desiredScope ) )
+		{
+			// system scopes come through unchanged...
+			desiredScope = Artifact.SCOPE_SYSTEM;
+		}
 
-        ArtifactHandler handler = getArtifactHandlerManager().getArtifactHandler(type);
+		ArtifactHandler handler = getArtifactHandlerManager().getArtifactHandler(type);
 
-        return new DefaultArtifact(
-        		groupId, artifactId,
-        		versionRange,
-        		desiredScope,
-        		type,
-        		null, //classifier
-        		handler,
-        		false); //optional
+		return new DefaultArtifact(
+				groupId, artifactId,
+				versionRange,
+				desiredScope,
+				type,
+				null, //classifier
+				handler,
+				false); //optional
 	}
 
 	/** Check if the values of the attributes of this Mojo are
@@ -711,22 +869,22 @@
 	 * @throws MojoExecutionException
 	 */
 	public abstract void checkMojoAttributes() throws MojoExecutionException;
-	
+
 	private String getLogType(Object o) {
 		if (o instanceof Boolean
-			|| o instanceof AtomicBoolean) return "B"; //$NON-NLS-1$
+				|| o instanceof AtomicBoolean) return "B"; //$NON-NLS-1$
 		if (o instanceof Byte) return "b"; //$NON-NLS-1$
 		if (o instanceof Short) return "s"; //$NON-NLS-1$
 		if (o instanceof Integer
-			|| o instanceof AtomicInteger) return "i"; //$NON-NLS-1$
+				|| o instanceof AtomicInteger) return "i"; //$NON-NLS-1$
 		if (o instanceof Long
-			|| o instanceof AtomicLong) return "l"; //$NON-NLS-1$
+				|| o instanceof AtomicLong) return "l"; //$NON-NLS-1$
 		if (o instanceof Float) return "f"; //$NON-NLS-1$
 		if (o instanceof Double) return "d"; //$NON-NLS-1$
 		if (o instanceof BigDecimal) return "D"; //$NON-NLS-1$
 		if (o instanceof BigInteger) return "I"; //$NON-NLS-1$
 		if (o instanceof String
-			|| o instanceof StringBuffer) return "s"; //$NON-NLS-1$
+				|| o instanceof StringBuffer) return "s"; //$NON-NLS-1$
 		if (o instanceof Array) {
 			Array a = (Array)o;
 			return a.getClass().getComponentType().getName()+"[]"; //$NON-NLS-1$
@@ -737,7 +895,7 @@
 		if (o instanceof Collection<?>) return "col"; //$NON-NLS-1$
 		return "o"; //$NON-NLS-1$
 	}
-	
+
 	/** Throw an exception when the given object is null.
 	 * 
 	 * @param message is the message to put in the exception.
@@ -758,8 +916,8 @@
 	}
 
 	/**
-     * {@inheritDoc}
-     */
+	 * {@inheritDoc}
+	 */
 	public final void execute() throws MojoExecutionException {
 		try {
 			checkMojoAttributes();
@@ -769,13 +927,14 @@
 			clearInternalBuffers();
 		}
 	}
-	
+
 	/** Clear internal buffers.
 	 */
 	public synchronized void clearInternalBuffers() {
-		this.artifactDescriptions.clear();
+		this.localArtifactDescriptions.clear();
+		this.remoteArtifactDescriptions.clear();
 	}
-	
+
 	/** Invoked when the Mojo should be executed.
 	 * 
 	 * @throws MojoExecutionException
@@ -800,7 +959,7 @@
 		}
 		return b.toString();
 	}
-	
+
 	private void detectEncoding(File file, CharsetDecoder decoder) throws IOException, CharacterCodingException {
 		decoder.onMalformedInput(CodingErrorAction.REPORT);
 		decoder.onUnmappableCharacter(CodingErrorAction.REPORT);
@@ -817,7 +976,7 @@
 			channel.close();
 		}
 	}
-	
+
 	/** Try to detect and reply the encoding of the given file.
 	 * This function uses the charsets replied by {@link #getPreferredCharsets()}
 	 * to select a charset when many are possible.
@@ -843,21 +1002,21 @@
 		if (getLog().isDebugEnabled()) {
 			getLog().debug("Valid charsets for "+file.getName()+":\n"+fittingCharsets.toString()); //$NON-NLS-1$ //$NON-NLS-2$
 		}
-		
+
 		for(Charset prefCharset : getPreferredCharsets()) {
 			if (prefCharset.canEncode() && fittingCharsets.contains(prefCharset)) {
 				getLog().debug("Use preferred charset for "+file.getName()+": "+prefCharset.displayName()); //$NON-NLS-1$ //$NON-NLS-2$
 				return prefCharset;
 			}
 		}
-		
+
 		Charset platformCharset = Charset.defaultCharset();
-		
+
 		if (platformCharset.canEncode() && fittingCharsets.contains(platformCharset)) {
 			getLog().debug("Use platform default charset for "+file.getName()+": "+platformCharset.displayName()); //$NON-NLS-1$ //$NON-NLS-2$
 			return Charset.defaultCharset();
 		}
-		
+
 		Iterator<Charset> iterator = fittingCharsets.iterator();
 		while (iterator.hasNext()) {
 			Charset c = iterator.next();
@@ -866,7 +1025,7 @@
 				return c;
 			}
 		}
-		
+
 		return null;
 	}
 

Modified: trunk/maventools/src/main/java/org/arakhne/maven/ExtendedArtifact.java
===================================================================
--- trunk/maventools/src/main/java/org/arakhne/maven/ExtendedArtifact.java	2011-08-13 17:30:11 UTC (rev 261)
+++ trunk/maventools/src/main/java/org/arakhne/maven/ExtendedArtifact.java	2011-08-18 10:03:30 UTC (rev 262)
@@ -36,6 +36,7 @@
 import org.apache.maven.model.License;
 import org.apache.maven.model.Organization;
 import org.apache.maven.model.Scm;
+import org.apache.maven.plugin.logging.Log;
 
 /**
  * Artifact implementation which also includes the artifact name,
@@ -149,27 +150,76 @@
 		return this.developers==null ? Collections.<Developer>emptyList() : this.developers;
 	}
 
-	/** Replies the contributor for the given login.
+	/** Replies the people with the given login.
+	 * This function checks the peoples replied
+	 * by {@link #getDevelopers()} and
+	 * {@link #getContributors()}.
 	 * 
 	 * @param login
-	 * @return the contributor or <code>null</code>
+	 * @return the people or <code>null</code>
 	 */
-	public Contributor getContributor(String login) {
+	public Contributor getPeople(String login) {
+		return getPeople(login, null);
+	}
+	
+	/** Replies the people with the given login.
+	 * This function checks the peoples replied
+	 * by {@link #getDevelopers()} and
+	 * {@link #getContributors()}.
+	 * 
+	 * @param login
+	 * @param logger
+	 * @return the people or <code>null</code>
+	 */
+	public Contributor getPeople(String login, Log logger) {
 		for(Developer devel : getDevelopers()) {
+			if (devel!=null && logger!=null && logger.isDebugEnabled()) {
+				logger.debug(
+						"Comparing '"+login //$NON-NLS-1$
+						+" to the developer [ID="+devel.getId() //$NON-NLS-1$
+						+";NAME="+devel.getName() //$NON-NLS-1$
+						+";EMAIL="+devel.getEmail() //$NON-NLS-1$
+						+"]"); //$NON-NLS-1$
+			}
 			if (devel!=null && 
 					(login.equals(devel.getId())
 							||login.equals(devel.getName())
 							||login.equals(devel.getEmail()))) {
+				if (logger!=null && logger.isDebugEnabled()) {
+					logger.debug(
+							"Selecting the developer [ID="+devel.getId() //$NON-NLS-1$
+							+";NAME="+devel.getName() //$NON-NLS-1$
+							+";EMAIL="+devel.getEmail() //$NON-NLS-1$
+							+"]"); //$NON-NLS-1$
+				}
 				return devel;
 			}
 		}
 		for(Contributor contrib : getContributors()) {
+			if (contrib!=null && logger!=null && logger.isDebugEnabled()) {
+				logger.debug(
+						"Comparing '"+login //$NON-NLS-1$
+						+" to the contributor [NAME="+contrib.getName() //$NON-NLS-1$
+						+";EMAIL="+contrib.getEmail() //$NON-NLS-1$
+						+"]"); //$NON-NLS-1$
+			}
 			if (contrib!=null &&
 					(login.equals(contrib.getName())
 							||login.equals(contrib.getEmail()))) {
+				if (logger!=null && logger.isDebugEnabled()) {
+					logger.debug(
+							"Selecting the contributor [NAME="+contrib.getName() //$NON-NLS-1$
+							+";EMAIL="+contrib.getEmail() //$NON-NLS-1$
+							+"]"); //$NON-NLS-1$
+				}
 				return contrib;
 			}
 		}
+		if (logger!=null && logger.isDebugEnabled()) {
+			logger.debug("No people found for: "+login); //$NON-NLS-1$
+			logger.debug("Developers are: "+this.developers.toString()); //$NON-NLS-1$
+			logger.debug("Contributors are: "+this.contributors.toString()); //$NON-NLS-1$
+		}
 		return null;
 	}
 

Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml	2011-08-13 17:30:11 UTC (rev 261)
+++ trunk/pom.xml	2011-08-18 10:03:30 UTC (rev 262)
@@ -370,5 +370,15 @@
 			<url>http://download.tuxfamily.org/arakhne/maven/</url>
 		</repository>
 	</repositories>
+	<pluginRepositories>
+		<pluginRepository>
+			<id>org.arakhne-maven</id>
+			<name>Arakhn&amp;ecirc; Maven Repository</name>
+			<url>http://download.tuxfamily.org/arakhne/maven/</url>
+			<snapshots>
+				<enabled>true</enabled>
+			</snapshots>
+		</pluginRepository>
+	</pluginRepositories>
 
 </project>

Modified: trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/AbstractReplaceMojo.java
===================================================================
--- trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/AbstractReplaceMojo.java	2011-08-13 17:30:11 UTC (rev 261)
+++ trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/AbstractReplaceMojo.java	2011-08-18 10:03:30 UTC (rev 262)
@@ -22,10 +22,13 @@
 
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
+import org.apache.maven.execution.MavenSession;
 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.apache.maven.repository.RepositorySystem;
 import org.arakhne.maven.AbstractArakhneMojo;
 import org.arakhne.maven.ExtendedArtifact;
 
@@ -124,11 +127,27 @@
 	private boolean overrideArtifactGroup;
 	
 	/** Reference to the current maven project.
-	 * 
 	 * @parameter expression="${project}"
+	 * @required
 	 */
 	private MavenProject mavenProject;
+	
+	/** Reference to the current session.
+	 * @parameter expression="${session}"
+	 * @required
+	 */
+	private MavenSession mavenSession;
 
+	/** Reference to the current repository system.
+	 * @component
+	 */
+	private RepositorySystem repositorySystem;
+
+	/** Refenrece to the current resolution handler.
+	 * @component
+	 */
+	private ResolutionErrorHandler resolutionErrorHandler;
+	
 	private String ensureArtifactId(ExtendedArtifact artifact) {
 		if (artifact!=null) {
 			if (this.overrideArtifactGroup && this.mavenProject.getArtifact().equals(artifact)) {
@@ -302,7 +321,6 @@
 	 */
     protected synchronized final String replaceMacro(String macroName, String text, String replacement, ReplacementType type, boolean enableWarning) {
     	if (replacement!=null && !EMPTY_STRING.equals(replacement)) {
-    		getLog().debug("Replacing "+macroName+" by "+type.name()+": "+replacement); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	    	Pattern p = buildMacroPattern(macroName);
 	    	Matcher m = p.matcher(text);
 	    	return m.replaceAll(Matcher.quoteReplacement(replacement));
@@ -338,7 +356,7 @@
             		if (login.length()>0) {
         				replacement.setLength(0);
             			if (artifact!=null) {
-	            			contributor = artifact.getContributor(login);
+	            			contributor = artifact.getPeople(login, getLog());
 	            			if (contributor!=null) {
 	            				link = contributor.getUrl();
 	            				if (link==null || EMPTY_STRING.equals(link)) {
@@ -362,7 +380,11 @@
 	            				}
 	            			}
 	            			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$
+	            				String msg = "unable to find a developer or a contributor with an id, a name or an email equal to: "+login; //$NON-NLS-1$
+	            				if (getLog().isDebugEnabled()) {
+	            					throw new MojoExecutionException(msg);
+	            				}
+            					getLog().warn(msg);
 	            			}
             			}
             			if (replacement.length()!=0) {
@@ -370,11 +392,19 @@
             			}
             		}
             		else {
-                		throw new MojoExecutionException("no login for Author tag: "+m.group(0)); //$NON-NLS-1$
+            			String msg = "no login for Author tag: "+m.group(0); //$NON-NLS-1$
+                		if (getLog().isDebugEnabled()) {
+                			throw new MojoExecutionException(msg);
+                		}
+                		getLog().warn(msg);
             		}
             	}
             	else {
-            		throw new MojoExecutionException("no login for Author tag: "+m.group(0)); //$NON-NLS-1$
+            		String msg = "no login for Author tag: "+m.group(0); //$NON-NLS-1$
+            		if (getLog().isDebugEnabled()) {
+            			throw new MojoExecutionException(msg);
+            		}
+            		getLog().warn(msg);
             	}
                 hasResult = m.find();
             }
@@ -484,6 +514,9 @@
 		assertNotNull("generatedSourceDirectory", this.generatedSourceDirectory); //$NON-NLS-1$
 		assertNotNull("artifactHandlerManager", this.artifactHandlerManager); //$NON-NLS-1$
 		assertNotNull("mavenProject", this.mavenProject); //$NON-NLS-1$
+		assertNotNull("mavenSession", this.mavenSession); //$NON-NLS-1$
+		assertNotNull("repositorySystem", this.repositorySystem); //$NON-NLS-1$
+		assertNotNull("resolutionErrorHandler", this.resolutionErrorHandler); //$NON-NLS-1$
 		assertNotNull("artifactId", this.projectArtifactId); //$NON-NLS-1$
 		assertNotNull("groupId", this.projectGroupId); //$NON-NLS-1$
 		if (this.encoding==null)
@@ -494,6 +527,30 @@
 	 * {@inheritDoc}
 	 */
 	@Override
+	protected MavenSession getMavenSession() {
+		return this.mavenSession;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	protected RepositorySystem getRepositorySystem() {
+		return this.repositorySystem;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	protected ResolutionErrorHandler getResolutionErrorHandler() {
+		return this.resolutionErrorHandler;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
 	protected File getBaseDirectory() {
 		return this.baseDirectory;
 	}


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