[Arakhnę-Dev] [263] Modif Mojo to integrate maven 3 artifact resolution |
[ Thread Index |
Date Index
| More arakhne.org/dev Archives
]
Revision: 263
Author: labset
Date: 2011-08-19 16:44:31 +0200 (Fri, 19 Aug 2011)
Log Message:
-----------
Modif Mojo to integrate maven 3 artifact resolution
Modified Paths:
--------------
trunk/license-installer/src/main/java/org/arakhne/maven/plugins/licenseinstaller/InstallLicenseMojo.java
trunk/maventools/pom.xml
trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.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-18 10:03:30 UTC (rev 262)
+++ trunk/license-installer/src/main/java/org/arakhne/maven/plugins/licenseinstaller/InstallLicenseMojo.java 2011-08-19 14:44:31 UTC (rev 263)
@@ -24,6 +24,7 @@
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@@ -32,22 +33,23 @@
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;
+import org.sonatype.aether.RepositorySystem;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.repository.RemoteRepository;
/**
- * Add license files in the META-INF directory of the target directory.
- * The created files are:<ul>
+ * Add license files in the META-INF directory of the target directory. The created files are:
+ * <ul>
* <li>LICENSE.soft.txt: the text of the license of the soft</li>
* <li>NOTICE.soft.txt: a list of the authors and contributors</li>
* </ul>
- *
+ *
* @author $Author: galland$
* @version $FullVersion$
* @mavengroupid $GroupId$
@@ -60,90 +62,110 @@
*/
public class InstallLicenseMojo extends AbstractArakhneMojo implements Constants {
- /** @component
+ /**
+ * @component
*/
private ArtifactHandlerManager artifactHandlerManager;
-
- /** @parameter expression="${project.basedir}"
+
+ /**
+ * @parameter expression="${project.basedir}"
*/
private File baseDirectory;
- /** @parameter expression="${project.build.directory}"
+ /**
+ * @parameter expression="${project.build.directory}"
*/
private File outputDirectory;
/**
- * Licenses to install.
- *
- * @parameter
- * @required
- */
+ * Licenses to install.
+ *
+ * @parameter
+ * @required
+ */
private String[] licenses;
/**
- * Third-party licenses. A file to license name map.
- *
- * @parameter
- */
- private String[] thirdPartyLicenses;
+ * Third-party licenses. A file to license name map.
+ *
+ * @parameter
+ */
+ private String[] thirdPartyLicenses;
/**
- * Copyright dates.
- *
- * @parameter
- * @required
- */
- private String copyrightDates;
+ * Copyright dates.
+ *
+ * @parameter
+ * @required
+ */
+ private String copyrightDates;
/**
- * Copyrighters.
- *
- * @parameter
- * @required
- */
- private String copyrighters;
+ * Copyrighters.
+ *
+ * @parameter
+ * @required
+ */
+ private String copyrighters;
/**
- * Project url.
- *
- * @parameter default-value="${project.url}"
- * @required
- */
- private URL projectURL;
+ * Project url.
+ *
+ * @parameter default-value="${project.url}"
+ * @required
+ */
+ private URL projectURL;
- /** Reference to the current maven project.
+ /**
+ * Reference to the current maven project.
*
* @parameter expression="${project}"
*/
private MavenProject mavenProject;
/**
- * Name of the pom project.
- *
- * @parameter expression="${project.name}"
- * @required
- */
- private String name;
+ * Name of the pom project.
+ *
+ * @parameter expression="${project.name}"
+ * @required
+ */
+ private String name;
- /** Reference to the current session.
+ /**
+ * Reference to the current session.
+ *
* @parameter expression="${session}"
* @required
*/
private MavenSession mavenSession;
- /** Reference to the current repository system.
+ /**
+ * The entry point to Aether, i.e. the component doing all the work.
+ *
* @component
*/
- private RepositorySystem repositorySystem;
+ private RepositorySystem repoSystem;
- /** Refenrece to the current resolution handler.
- * @component
+ /**
+ * The current repository/network configuration of Maven.
+ *
+ * @parameter default-value="${repositorySystemSession}"
+ * @readonly
*/
- private ResolutionErrorHandler resolutionErrorHandler;
+ private RepositorySystemSession repoSession;
- /** {@inheritDoc}
+ /**
+ * The project's remote repositories to use for the resolution of plugins and their dependencies.
+ *
+ * @parameter default-value="${project.remotePluginRepositories}"
+ * @readonly
*/
- @Override
+ private List<RemoteRepository> remoteRepos;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public synchronized void checkMojoAttributes() {
assertNotNull("copyrightDates", this.copyrightDates); //$NON-NLS-1$
assertNotNull("copyrighters", this.copyrighters); //$NON-NLS-1$
@@ -153,209 +175,193 @@
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("repositorySystem", this.repoSystem); //$NON-NLS-1$
+ assertNotNull("repositorySystemSession", this.repoSession); //$NON-NLS-1$
+ assertNotNull("remoteRepositoryList", this.remoteRepos); //$NON-NLS-1$
}
/**
- * {@inheritDoc}
- */
- @Override
+ * {@inheritDoc}
+ */
+ @Override
public synchronized void executeMojo() throws MojoExecutionException {
- if ("pom".equalsIgnoreCase(this.mavenProject.getPackaging())) { //$NON-NLS-1$
- String key = ArtifactUtils.key(
- this.mavenProject.getGroupId(),
- this.mavenProject.getArtifactId(),
- this.mavenProject.getVersion());
- info("Ignoring project ", //$NON-NLS-1$
- key,
- " because it is a source-less project."); //$NON-NLS-1$
- return;
- }
-
- File classesDirectory = new File(getOutputDirectory(), CLASSES_DIR);
- File metainfDirectory = new File(classesDirectory, METAINF_DIR);
- File licenseDirectory = new File(metainfDirectory, LICENSE_DIR);
+ if ("pom".equalsIgnoreCase(this.mavenProject.getPackaging())) { //$NON-NLS-1$
+ String key = ArtifactUtils.key(this.mavenProject.getGroupId(), this.mavenProject.getArtifactId(), this.mavenProject.getVersion());
+ info("Ignoring project ", //$NON-NLS-1$
+ key, " because it is a source-less project."); //$NON-NLS-1$
+ return;
+ }
- licenseDirectory.mkdirs();
-
- Set<License> coreInstalled = new HashSet<License>();
- License lic;
- URL resource;
- String filename;
- File licFile;
-
- Map<String,License> includedLicenses = new HashMap<String,License>();
- Pattern re = Pattern.compile("^([^:]+):(.+)$"); //$NON-NLS-1$
- if (this.thirdPartyLicenses!=null) {
- for(String tpl : this.thirdPartyLicenses) {
- Matcher matcher = re.matcher(tpl);
- if (matcher.matches()) {
- String l = matcher.group(1);
- String f = matcher.group(2);
- lic = License.parse(l, null);
- if (lic!=null) {
- includedLicenses.put(f, lic);
- }
- }
- }
- }
+ File classesDirectory = new File(getOutputDirectory(), CLASSES_DIR);
+ File metainfDirectory = new File(classesDirectory, METAINF_DIR);
+ File licenseDirectory = new File(metainfDirectory, LICENSE_DIR);
- try {
+ licenseDirectory.mkdirs();
- //----------------------------------------------------
- // SOFTWARE LICENCES
- //----------------------------------------------------
-
- for(String license : this.licenses) {
- lic = License.parse(license, License.GPLv3);
- if (!coreInstalled.contains(lic)) {
- resource = lic.getFullTextResource();
- if (resource!=null) {
+ Set<License> coreInstalled = new HashSet<License>();
+ License lic;
+ URL resource;
+ String filename;
+ File licFile;
- filename = LICENSE_FILENAME_PATTERN.replaceAll("%s", this.name); //$NON-NLS-1$
- filename = filename.replaceAll("%l", lic.name()); //$NON-NLS-1$
+ Map<String, License> includedLicenses = new HashMap<String, License>();
+ Pattern re = Pattern.compile("^([^:]+):(.+)$"); //$NON-NLS-1$
+ if (this.thirdPartyLicenses != null) {
+ for (String tpl : this.thirdPartyLicenses) {
+ Matcher matcher = re.matcher(tpl);
+ if (matcher.matches()) {
+ String l = matcher.group(1);
+ String f = matcher.group(2);
+ lic = License.parse(l, null);
+ if (lic != null) {
+ includedLicenses.put(f, lic);
+ }
+ }
+ }
+ }
- info( "Installing license: ", //$NON-NLS-1$
- lic.getLicenseName(),
- ", into ", //$NON-NLS-1$
- filename);
-
- licFile = new File(licenseDirectory, filename);
- fileCopy(resource, licFile);
-
- coreInstalled.add(lic);
- }
- else {
- throw new MojoExecutionException("Unable to find the full text of the license: "+lic.getLicenseName()); //$NON-NLS-1$
- }
- }
- }
+ try {
- //----------------------------------------------------
- // THIRD-PARTY LICENCES
- //----------------------------------------------------
-
- for(Entry<String,License> licenseMap : includedLicenses.entrySet()) {
- lic = licenseMap.getValue();
- resource = lic.getFullTextResource();
- if (resource!=null) {
-
- StringBuffer sb = new StringBuffer();
- sb.append(this.name);
- sb.append("_"); //$NON-NLS-1$
- String b = licenseMap.getKey().replace(File.separatorChar, '.').replaceAll("^\\.", ""); //$NON-NLS-1$ //$NON-NLS-2$
- sb.append(b);
-
- filename = LICENSE_FILENAME_PATTERN.replaceAll("%s", sb.toString()); //$NON-NLS-1$
- filename = filename.replaceAll("%l", lic.name()); //$NON-NLS-1$
+ // ----------------------------------------------------
+ // SOFTWARE LICENCES
+ // ----------------------------------------------------
- info( "Installing included source code license: ", //$NON-NLS-1$
- lic.getLicenseName(),
- ", into ", //$NON-NLS-1$
- filename);
+ for (String license : this.licenses) {
+ lic = License.parse(license, License.GPLv3);
+ if (!coreInstalled.contains(lic)) {
+ resource = lic.getFullTextResource();
+ if (resource != null) {
- licFile = new File(licenseDirectory, filename);
- fileCopy(resource, licFile);
- }
- else {
- throw new MojoExecutionException("Unable to find the full text of the license: "+lic.getLicenseName()); //$NON-NLS-1$
- }
- }
+ filename = LICENSE_FILENAME_PATTERN.replaceAll("%s", this.name); //$NON-NLS-1$
+ filename = filename.replaceAll("%l", lic.name()); //$NON-NLS-1$
- //----------------------------------------------------
- // NOTICES
- //----------------------------------------------------
+ info("Installing license: ", //$NON-NLS-1$
+ lic.getLicenseName(), ", into ", //$NON-NLS-1$
+ filename);
+ licFile = new File(licenseDirectory, filename);
+ fileCopy(resource, licFile);
+
+ coreInstalled.add(lic);
+ } else {
+ throw new MojoExecutionException("Unable to find the full text of the license: " + lic.getLicenseName()); //$NON-NLS-1$
+ }
+ }
+ }
+
+ // ----------------------------------------------------
+ // THIRD-PARTY LICENCES
+ // ----------------------------------------------------
+
+ for (Entry<String, License> licenseMap : includedLicenses.entrySet()) {
+ lic = licenseMap.getValue();
+ resource = lic.getFullTextResource();
+ if (resource != null) {
+
+ StringBuffer sb = new StringBuffer();
+ sb.append(this.name);
+ sb.append("_"); //$NON-NLS-1$
+ String b = licenseMap.getKey().replace(File.separatorChar, '.').replaceAll("^\\.", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ sb.append(b);
+
+ filename = LICENSE_FILENAME_PATTERN.replaceAll("%s", sb.toString()); //$NON-NLS-1$
+ filename = filename.replaceAll("%l", lic.name()); //$NON-NLS-1$
+
+ info("Installing included source code license: ", //$NON-NLS-1$
+ lic.getLicenseName(), ", into ", //$NON-NLS-1$
+ filename);
+
+ licFile = new File(licenseDirectory, filename);
+ fileCopy(resource, licFile);
+ } else {
+ throw new MojoExecutionException("Unable to find the full text of the license: " + lic.getLicenseName()); //$NON-NLS-1$
+ }
+ }
+
+ // ----------------------------------------------------
+ // NOTICES
+ // ----------------------------------------------------
+
filename = NOTICE_FILENAME_PATTERN.replaceAll("%s", this.name); //$NON-NLS-1$
-
- info( "Installing license notice: ", //$NON-NLS-1$
- filename);
+ info("Installing license notice: ", //$NON-NLS-1$
+ filename);
+
StringBuffer addParts = new StringBuffer();
- for(Entry<String,License> licenseMap : includedLicenses.entrySet()) {
- lic = licenseMap.getValue();
- if (lic!=null) {
- String s = getLString(InstallLicenseMojo.class, "NOTICE_SENTENCE", //$NON-NLS-1$
- lic.getLicenseName(), licenseMap.getKey());
- addParts.append(s);
- }
- }
-
-
+ for (Entry<String, License> licenseMap : includedLicenses.entrySet()) {
+ lic = licenseMap.getValue();
+ if (lic != null) {
+ String s = getLString(InstallLicenseMojo.class, "NOTICE_SENTENCE", //$NON-NLS-1$
+ lic.getLicenseName(), licenseMap.getKey());
+ addParts.append(s);
+ }
+ }
+
StringBuffer fullLicenseText = new StringBuffer();
int n = 0;
- for(License l : coreInstalled) {
- if (n>0) {
- if (n==coreInstalled.size()-1) {
+ for (License l : coreInstalled) {
+ if (n > 0) {
+ if (n == coreInstalled.size() - 1) {
fullLicenseText.append(getLString(InstallLicenseMojo.class, "AND")); //$NON-NLS-1$
- }
- else {
+ } else {
fullLicenseText.append(getLString(InstallLicenseMojo.class, "COMMA")); //$NON-NLS-1$
}
}
fullLicenseText.append(l.getLicenseName());
++n;
}
-
+
String noticeText = getLString(InstallLicenseMojo.class, "NOTICE_TEXT", //$NON-NLS-1$
- this.name, this.copyrightDates, this.copyrighters,
- fullLicenseText.toString(),
- addParts.toString());
-
+ this.name, this.copyrightDates, this.copyrighters, fullLicenseText.toString(), addParts.toString());
+
File noticeFile = new File(metainfDirectory, filename);
FileWriter fileWriter = new FileWriter(noticeFile);
fileWriter.write(noticeText);
fileWriter.close();
-
- //----------------------------------------------------
- // AUTHORS
- //----------------------------------------------------
+ // ----------------------------------------------------
+ // AUTHORS
+ // ----------------------------------------------------
+
filename = AUTHOR_FILENAME_PATTERN.replaceAll("%s", this.name); //$NON-NLS-1$
-
- info( "Installing authors: ", //$NON-NLS-1$
- filename);
-
+
+ info("Installing authors: ", //$NON-NLS-1$
+ filename);
+
StringBuffer authorsText = new StringBuffer();
- if (this.projectURL!=null) {
+ if (this.projectURL != null) {
authorsText.append(getLString(InstallLicenseMojo.class, "AUTHOR_INTRO", this.projectURL.toExternalForm())); //$NON-NLS-1$
- }
- else {
+ } else {
authorsText.append(getLString(InstallLicenseMojo.class, "AUTHOR_INTRO", "")); //$NON-NLS-1$ //$NON-NLS-2$
}
authorsText.append("\n\n"); //$NON-NLS-1$
authorsText.append(getLString(InstallLicenseMojo.class, "DEVELOPER_TITLE", this.name)); //$NON-NLS-1$
authorsText.append("\n\n"); //$NON-NLS-1$
- for(Developer developer : this.mavenProject.getDevelopers()) {
- authorsText.append(getLString(InstallLicenseMojo.class,
- "DEVELOPER", //$NON-NLS-1$
- developer.getName(),
- developer.getEmail()));
+ for (Developer developer : this.mavenProject.getDevelopers()) {
+ authorsText.append(getLString(InstallLicenseMojo.class, "DEVELOPER", //$NON-NLS-1$
+ developer.getName(), developer.getEmail()));
authorsText.append("\n"); //$NON-NLS-1$
}
-
+
authorsText.append("\n\n\n"); //$NON-NLS-1$
authorsText.append(getLString(InstallLicenseMojo.class, "CONTRIBUTOR_TITLE", this.name)); //$NON-NLS-1$
authorsText.append("\n\n"); //$NON-NLS-1$
- for(Contributor contributor : this.mavenProject.getContributors()) {
- authorsText.append(getLString(InstallLicenseMojo.class,
- "DEVELOPER", //$NON-NLS-1$
- contributor.getName(),
- contributor.getEmail()));
+ for (Contributor contributor : this.mavenProject.getContributors()) {
+ authorsText.append(getLString(InstallLicenseMojo.class, "DEVELOPER", //$NON-NLS-1$
+ contributor.getName(), contributor.getEmail()));
authorsText.append("\n"); //$NON-NLS-1$
}
File authorFile = new File(metainfDirectory, filename);
fileWriter = new FileWriter(authorFile);
fileWriter.write(authorsText.toString());
- fileWriter.close();
- }
- catch(IOException e) {
- throw new RuntimeException(e);
- }
-
- }
+ fileWriter.close();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
/**
* {@inheritDoc}
*/
@@ -363,7 +369,7 @@
protected File getOutputDirectory() {
return this.outputDirectory;
}
-
+
/**
* {@inheritDoc}
*/
@@ -392,16 +398,24 @@
* {@inheritDoc}
*/
@Override
- protected RepositorySystem getRepositorySystem() {
- return this.repositorySystem;
+ protected RepositorySystemSession getRepositorySystemSession() {
+ return this.repoSession;
}
/**
* {@inheritDoc}
*/
@Override
- protected ResolutionErrorHandler getResolutionErrorHandler() {
- return this.resolutionErrorHandler;
+ protected List<RemoteRepository> getRemoteRepositoryList() {
+ return this.remoteRepos;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RepositorySystem getRepositorySystem() {
+ return this.repoSystem;
+ }
+
}
Modified: trunk/maventools/pom.xml
===================================================================
--- trunk/maventools/pom.xml 2011-08-18 10:03:30 UTC (rev 262)
+++ trunk/maventools/pom.xml 2011-08-19 14:44:31 UTC (rev 263)
@@ -37,6 +37,14 @@
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.sonatype.aether</groupId>
+ <artifactId>aether-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.sonatype.aether</groupId>
+ <artifactId>aether-util</artifactId>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java
===================================================================
--- trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java 2011-08-18 10:03:30 UTC (rev 262)
+++ trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java 2011-08-19 14:44:31 UTC (rev 263)
@@ -18,41 +18,6 @@
*/
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;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Organization;
-import org.apache.maven.model.Parent;
-import org.apache.maven.model.Scm;
-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;
-import org.tmatesoft.svn.core.wc.SVNInfo;
-import org.tmatesoft.svn.core.wc.SVNRevision;
-
import java.io.BufferedReader;
import java.io.File;
import java.io.FileFilter;
@@ -76,7 +41,6 @@
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;
@@ -91,9 +55,38 @@
import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Pattern;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.ArtifactUtils;
+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.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;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Organization;
+import org.apache.maven.model.Parent;
+import org.apache.maven.model.Scm;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.sonatype.aether.RepositorySystem;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.repository.RemoteRepository;
+import org.sonatype.aether.resolution.ArtifactRequest;
+import org.sonatype.aether.resolution.ArtifactResolutionException;
+import org.sonatype.aether.resolution.ArtifactResult;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+import org.tmatesoft.svn.core.wc.SVNInfo;
+import org.tmatesoft.svn.core.wc.SVNRevision;
+
/**
- * Abstract implementation for all Arakhnê maven modules.
- * This implementation is thread safe.
+ * Abstract implementation for all Arakhnê maven modules. This implementation is thread safe.
*
* @author $Author: galland$
* @version $FullVersion$
@@ -104,7 +97,8 @@
*/
public abstract class AbstractArakhneMojo extends AbstractMojo {
- /** Empty string constant.
+ /**
+ * Empty string constant.
*/
public static final String EMPTY_STRING = ExtendedArtifact.EMPTY_STRING;
@@ -123,50 +117,57 @@
*/
public static final String PROP_VERSION = "version"; //$NON-NLS-1$
- /** Preferred charset for the new MacOS and Linux operating systems.
+ /**
+ * Preferred charset for the new MacOS and Linux operating systems.
*/
public static final String PREFERRED_CHARSET_UNIX = "UTF-8"; //$NON-NLS-1$
- /** Preferred charset for the Windows operating systems.
+ /**
+ * Preferred charset for the Windows operating systems.
*/
public static final String PREFERRED_CHARSET_WINDOWS = "windows-1250"; //$NON-NLS-1$
- /** Preferred charset for the old MacOS operating systems.
+ /**
+ * Preferred charset for the old MacOS operating systems.
*/
public static final String PREFERRED_CHARSET_MACOS = "MacRoman"; //$NON-NLS-1$
- /** Preferred charset for the Java virtual machine (internal charset).
+ /**
+ * Preferred charset for the Java virtual machine (internal charset).
*/
public static final String PREFERRED_CHARSET_JVM = "UTF-16"; //$NON-NLS-1$
- /** Copy a file.
+ /**
+ * Copy a file.
*
* @param in
* @param out
* @throws IOException
*/
public void fileCopy(File in, File out) throws IOException {
- assert(in!=null);
- assert(out!=null);
+ assert (in != null);
+ assert (out != null);
FileChannel inChannel = new FileInputStream(in).getChannel();
FileChannel outChannel = new FileOutputStream(out).getChannel();
try {
inChannel.transferTo(0, inChannel.size(), outChannel);
+ } finally {
+ if (inChannel != null)
+ inChannel.close();
+ if (outChannel != null)
+ outChannel.close();
}
- finally {
- if (inChannel!=null) inChannel.close();
- if (outChannel!=null) outChannel.close();
- }
}
- /** Copy a file.
+ /**
+ * Copy a file.
*
* @param in
* @param out
* @throws IOException
*/
public void fileCopy(URL in, File out) throws IOException {
- assert(in!=null);
+ assert (in != null);
InputStream inStream = in.openStream();
OutputStream outStream = new FileOutputStream(out);
try {
@@ -175,31 +176,35 @@
while ((len = inStream.read(buf)) > 0) {
outStream.write(buf, 0, len);
}
- }
- finally {
- if (inStream!=null) inStream.close();
+ } finally {
+ if (inStream != null)
+ inStream.close();
outStream.close();
}
}
- /** Read a resource property and replace the parametrized macros by the
- * given parameters.
+ /**
+ * Read a resource property and replace the parametrized macros by the given parameters.
*
- * @param source is the source of the properties.
- * @param label is the name of the property.
- * @param params are the parameters to replace.
+ * @param source
+ * is the source of the properties.
+ * @param label
+ * is the name of the property.
+ * @param params
+ * are the parameters to replace.
* @return the read text.
*/
public String getLString(Class<?> source, String label, Object... params) {
ResourceBundle rb = ResourceBundle.getBundle(source.getCanonicalName());
String text = rb.getString(label);
- text = text.replaceAll("[\\n\\r]","\n"); //$NON-NLS-1$ //$NON-NLS-2$
- text = text.replaceAll("\\t","\t"); //$NON-NLS-1$ //$NON-NLS-2$
+ text = text.replaceAll("[\\n\\r]", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ text = text.replaceAll("\\t", "\t"); //$NON-NLS-1$ //$NON-NLS-2$
text = MessageFormat.format(text, params);
return text;
}
- /** Remove the path prefix from a file.
+ /**
+ * Remove the path prefix from a file.
*
* @param prefix
* @param file
@@ -215,25 +220,28 @@
return r;
}
- /** Invocation date.
+ /**
+ * Invocation date.
*/
protected final Date invocationDate = new Date();
- /** Map the directory of pom.xml files to the definition
- * of the corresponding maven module.
+ /**
+ * Map the directory of pom.xml files to the definition of the corresponding maven module.
*/
- private final Map<File,ExtendedArtifact> localArtifactDescriptions = 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.
+ /**
+ * Map the artifact id to the definition of the corresponding maven module.
*/
- private final Map<String,ExtendedArtifact> remoteArtifactDescriptions = new TreeMap<String,ExtendedArtifact>();
+ private final Map<String, ExtendedArtifact> remoteArtifactDescriptions = new TreeMap<String, ExtendedArtifact>();
- /** Manager of the SVN repository.
+ /**
+ * Manager of the SVN repository.
*/
private SVNClientManager svnManager = null;
- /** Are the preferred charset in the preferred order.
+ /**
+ * Are the preferred charset in the preferred order.
*/
private Charset[] preferredCharsets;
@@ -262,13 +270,13 @@
if (!availableCharsets.contains(cs)) {
availableCharsets.add(cs);
}
- }
- catch(Throwable _) {
+ } catch (Throwable _) {
//
}
}
- /** Replies the preferred charsets in the preferred order of use.
+ /**
+ * Replies the preferred charsets in the preferred order of use.
*
* @return the preferred charsets in the preferred order of use.
*/
@@ -276,29 +284,32 @@
return this.preferredCharsets;
}
- /** Set the preferred charsets in the preferred order of use.
+ /**
+ * Set the preferred charsets in the preferred order of use.
*
- * @param charsets are the preferred charsets in the preferred order of use.
+ * @param charsets
+ * are the preferred charsets in the preferred order of use.
*/
protected void setPreferredCharsets(Charset... charsets) {
this.preferredCharsets = charsets;
}
- /** Replies the manager of the SVN repository.
+ /**
+ * Replies the manager of the SVN repository.
*
* @return the manager of the SVN repository.
*/
protected synchronized final SVNClientManager getSVNClientManager() {
- if (this.svnManager==null) {
+ if (this.svnManager == null) {
this.svnManager = SVNClientManager.newInstance();
}
return this.svnManager;
}
- /** Replies the artifact handler manager.
+ /**
+ * Replies the artifact handler manager.
* <p>
- * It is an attribute defined as:
- * <code><pre>
+ * It is an attribute defined as: <code><pre>
* <span>/</span>* <span>@</span>component
* <span>*</span>/
* private ArtifactHandlerManager manager;
@@ -308,11 +319,10 @@
*/
protected abstract ArtifactHandlerManager getArtifactHandlerManager();
- /** Replies the output directory of the project.
- * Basically it is <code>getRootDirectory()+"/target"</code>.
+ /**
+ * Replies the output directory of the project. Basically it is <code>getRootDirectory()+"/target"</code>.
* <p>
- * It is an attribute defined as:
- * <code><pre>
+ * It is an attribute defined as: <code><pre>
* <span>/</span>* <span>@</span>parameter expression="${project.build.directory}"
* <span>*</span>/
* private File outputDirectory;
@@ -322,12 +332,10 @@
*/
protected abstract File getOutputDirectory();
- /** Replies the root directory of the project.
- * Basically it is the value stored inside the
- * Maven property named <code>project.basedir</code>.
+ /**
+ * Replies the root directory of the project. Basically it is the value stored inside the Maven property named <code>project.basedir</code>.
* <p>
- * It is an attribute defined as:
- * <code><pre>
+ * It is an attribute defined as: <code><pre>
* <span>/</span>* <span>@</span>parameter expression="${project.basedir}"
* <span>*</span>/
* private File baseDirectory;
@@ -337,11 +345,25 @@
*/
protected abstract File getBaseDirectory();
- /** Replies the repository system used by this maven instance.
- * Basically it is an internal component of Maven.
+ /**
+ * Replies the current maven session. Basically it is an internal component of Maven.
* <p>
- * It is an attribute defined as:
- * <code><pre>
+ * It is an attribute defined as: <code><pre>
+ * <span>/</span>* <span>@</span>parameter expression="${session}"
+ * * <span>@</span>required
+ * <span>*</span>/
+ * private MavenSession mvnSession;
+ * </pre></code>
+ *
+ * @return the maven session
+ */
+ protected abstract MavenSession getMavenSession();
+
+
+ /**
+ * 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;
@@ -349,50 +371,50 @@
*
* @return the repository system
*/
- protected abstract RepositorySystem getRepositorySystem();
+ protected abstract RepositorySystem getRepositorySystem();
- /** Replies the current maven session.
- * Basically it is an internal component of Maven.
+ /**
+ * Replies the current repository/network configuration of Maven..
* <p>
- * It is an attribute defined as:
- * <code><pre>
- * <span>/</span>* <span>@</span>parameter expression="${session}"
- * * <span>@</span>required
+ * It is an attribute defined as: <code><pre>
+ * <span>/</span>* <span>@</span>component
* <span>*</span>/
- * private MavenSession mvnSession;
+ * private RepositorySystemSession repoSession;
* </pre></code>
*
- * @return the maven session
+ * @return the repository system
*/
- protected abstract MavenSession getMavenSession();
+ protected abstract RepositorySystemSession getRepositorySystemSession();
- /** Replies the current resolution error handler.
- * Basically it is an internal component of Maven.
+ /**
+ * Replies the project's remote repositories to use for the resolution of plugins and their dependencies..
* <p>
- * It is an attribute defined as:
- * <code><pre>
+ * It is an attribute defined as: <code><pre>
* <span>/</span>* <span>@</span>component
* <span>*</span>/
- * private ResolutionErrorHandler resolutionErrorHandler;
+ * private List<RemoteRepository> remoteRepos;
* </pre></code>
*
- * @return the maven session
+ * @return the repository system
*/
- protected abstract ResolutionErrorHandler getResolutionErrorHandler();
+ protected abstract List<RemoteRepository> getRemoteRepositoryList();
+
- /** Search and reply the maven artifact which is corresponding to the given file.
+ /**
+ * 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.
+ * @param file
+ * is the file for which the maven artifact should be retreived.
* @return the maven artifact or <code>null</code> if none.
*/
protected synchronized ExtendedArtifact searchArtifact(File file) {
String filename = removePathPrefix(getBaseDirectory(), file);
- getLog().debug("Retreiving module for "+filename); //$NON-NLS-1$
+ getLog().debug("Retreiving module for " + filename); //$NON-NLS-1$
File theFile = file;
File pomDirectory = null;
- while (theFile!=null && pomDirectory==null) {
+ while (theFile != null && pomDirectory == null) {
if (theFile.isDirectory()) {
File pomFile = new File(theFile, "pom.xml"); //$NON-NLS-1$
if (pomFile.exists()) {
@@ -402,13 +424,13 @@
theFile = theFile.getParentFile();
}
- if (pomDirectory!=null) {
+ if (pomDirectory != null) {
ExtendedArtifact a = this.localArtifactDescriptions.get(pomDirectory);
- if (a==null) {
+ if (a == null) {
a = readPom(pomDirectory);
this.localArtifactDescriptions.put(pomDirectory, a);
getLog().debug("Found local module description for " //$NON-NLS-1$
- +a.toString());
+ + a.toString());
}
return a;
}
@@ -417,10 +439,13 @@
return null;
}
- /** Replies a list of files which are found on the file system.
+ /**
+ * Replies a list of files which are found on the file system.
*
- * @param directory is the directory to search in.
- * @param filter is the file selector
+ * @param directory
+ * is the directory to search in.
+ * @param filter
+ * is the file selector
* @return the list of files.
*/
protected final Collection<File> findFiles(File directory, FileFilter filter) {
@@ -429,23 +454,26 @@
return files;
}
- /** Replies a list of files which are found on the file system.
+ /**
+ * Replies a list of files which are found on the file system.
*
- * @param directory is the directory to search in.
- * @param filter is the file selector
- * @param fileOut is the list of files to fill.
+ * @param directory
+ * is the directory to search in.
+ * @param filter
+ * is the file selector
+ * @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) {
+ 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);
+ + filter.toString() + " files from " //$NON-NLS-1$
+ + relativePath);
candidates.add(directory);
int nbFiles = 0;
@@ -454,12 +482,11 @@
candidate = candidates.remove(0);
if (candidate.isDirectory()) {
File[] children = candidate.listFiles(filter);
- if (children!=null) {
- for(File child : children) {
- if (child!=null && child.isDirectory()) {
+ if (children != null) {
+ for (File child : children) {
+ if (child != null && child.isDirectory()) {
candidates.add(child);
- }
- else {
+ } else {
fileOut.add(child);
++nbFiles;
}
@@ -469,30 +496,30 @@
}
getLog().debug("Found " //$NON-NLS-1$
- +nbFiles
- +" file(s)"); //$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.
+ /**
+ * 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.
*
- * @param directory is the directory to search in.
- * @param filter is the file selector
- * @param fileOut is the list of files to fill.
+ * @param directory
+ * is the directory to search in.
+ * @param filter
+ * is the file selector
+ * @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) {
+ 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);
+ + filter.toString() + " files from " //$NON-NLS-1$
+ + relativePath);
candidates.add(directory);
int nbFiles = 0;
@@ -501,12 +528,11 @@
candidate = candidates.remove(0);
if (candidate.isDirectory()) {
File[] children = candidate.listFiles(filter);
- if (children!=null) {
- for(File child : children) {
- if (child!=null && child.isDirectory()) {
+ if (children != null) {
+ for (File child : children) {
+ if (child != null && child.isDirectory()) {
candidates.add(child);
- }
- else {
+ } else {
fileOut.put(child, directory);
++nbFiles;
}
@@ -516,63 +542,96 @@
}
getLog().debug("Found " //$NON-NLS-1$
- +nbFiles
- +" file(s)"); //$NON-NLS-1$
+ + nbFiles + " file(s)"); //$NON-NLS-1$
}
}
- /** Log an information message.
+ /**
+ * Log an information message.
*
* @param message
*/
protected synchronized void info(Object... message) {
StringBuffer b = new StringBuffer();
- for(Object o : message) {
- if (o!=null) {
+ for (Object o : message) {
+ if (o != null) {
b.append(o.toString());
}
}
getLog().info(b.toString());
}
- /** Log an information message.
+ /**
+ * Log an information message.
*
* @param error
* @param message
*/
protected synchronized void info(Throwable error, Object... message) {
StringBuffer b = new StringBuffer();
- for(Object o : message) {
- if (o!=null) {
+ for (Object o : message) {
+ if (o != null) {
b.append(o.toString());
}
}
getLog().info(b.toString(), error);
}
- /** Log an error message.
+ /**
+ * Log debugging message.
*
+ * @param messages
+ * are the messages to log.
+ */
+ protected void debug(Object... messages) {
+ StringBuffer buffer = new StringBuffer();
+ for (Object s : messages) {
+ if (s != null)
+ buffer.append(s);
+ }
+ getLog().debug(buffer.toString());
+ }
+
+ /**
+ * Log warning message.
+ *
+ * @param messages
+ * are the messages to log.
+ */
+ protected void warn(Object... messages) {
+ StringBuffer buffer = new StringBuffer();
+ for (Object s : messages) {
+ if (s != null)
+ buffer.append(s);
+ }
+ getLog().warn(buffer.toString());
+ }
+
+ /**
+ * Log an error message.
+ *
* @param message
*/
protected synchronized void error(Object... message) {
StringBuffer b = new StringBuffer();
- for(Object o : message) {
- if (o!=null) {
+ for (Object o : message) {
+ if (o != null) {
b.append(o.toString());
}
}
getLog().error(b.toString());
}
- /** Log an error message.
+ /**
+ * Log an error message.
*
* @param error
* @param message
*/
protected synchronized void error(Throwable error, Object... message) {
StringBuffer b = new StringBuffer();
- for(Object o : message) {
- if (o!=null) {
+ for (Object o : message) {
+ if (o != null) {
b.append(o.toString());
}
}
@@ -580,20 +639,21 @@
}
/**
- * Replies the maven artifact which is described by the <code>pom.xml</code>
- * file in the given directory.
+ * 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.
+ * @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.
+ * @param pomFile
+ * is the <code>pom.xml</code> file.
* @return the artifact or <code>null</code>.
*/
protected synchronized final ExtendedArtifact readPomFile(File pomFile) {
@@ -608,11 +668,12 @@
List<Contributor> contributors;
List<License> licenses;
Parent parent = null;
-
- getLog().debug("Read pom file: "+pomFile.toString()); //$NON-NLS-1$
- if (!pomFile.canRead()) return null;
+ 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(pomFile));
@@ -629,40 +690,35 @@
licenses = model.getLicenses();
parent = model.getParent();
- }
- catch (IOException e) {
+ } catch (IOException e) {
return null;
- }
- catch (XmlPullParserException e) {
+ } catch (XmlPullParserException e) {
return null;
}
- if (developers==null) {
+ if (developers == null) {
developers = new ArrayList<Developer>();
- }
- else {
+ } else {
List<Developer> list = new ArrayList<Developer>();
list.addAll(developers);
developers = list;
}
- if (contributors==null) {
+ if (contributors == null) {
contributors = new ArrayList<Contributor>();
- }
- else {
+ } else {
List<Contributor> list = new ArrayList<Contributor>();
list.addAll(contributors);
contributors = list;
}
- if (licenses==null) {
+ if (licenses == null) {
licenses = new ArrayList<License>();
- }
- else {
+ } else {
List<License> list = new ArrayList<License>();
list.addAll(licenses);
licenses = list;
}
- if (parent!=null) {
+ if (parent != null) {
String relPath = parent.getRelativePath();
File parentPomDirectory = new File(pomFile.getParentFile(), relPath);
try {
@@ -671,14 +727,13 @@
parentPomDirectory = parentPomDirectory.getParentFile();
}
ExtendedArtifact parentArtifact = this.localArtifactDescriptions.get(parentPomDirectory);
- if (parentArtifact==null) {
+ if (parentArtifact == null) {
parentArtifact = readPom(parentPomDirectory);
- if (parentArtifact!=null) {
+ if (parentArtifact != null) {
this.localArtifactDescriptions.put(parentPomDirectory, parentArtifact);
getLog().debug("Add local module description for " //$NON-NLS-1$
- +parentArtifact.toString());
- }
- else {
+ + 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();
@@ -686,30 +741,27 @@
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$
+ + key + ": " + artifactFile.getAbsolutePath()); //$NON-NLS-1$
if (artifactFile.canRead()) {
parentArtifact = readPomFile(artifactFile);
- if (parentArtifact!=null) {
+ if (parentArtifact != null) {
this.remoteArtifactDescriptions.put(key, parentArtifact);
getLog().debug("Add remote module description for " //$NON-NLS-1$
- +parentArtifact.toString());
+ + parentArtifact.toString());
+ } else {
+ getLog().warn("Unable to retreive the pom file of " + key); //$NON-NLS-1$
}
- 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$
}
- else {
- getLog().warn("Cannot read for '"+key //$NON-NLS-1$
- +"': "+artifactFile.getAbsolutePath()); //$NON-NLS-1$
- }
}
}
- if (parentArtifact!=null) {
+ if (parentArtifact != null) {
developers.addAll(parentArtifact.getDevelopers());
contributors.addAll(parentArtifact.getContributors());
}
- }
- catch (IOException e) {
+ } catch (IOException e) {
getLog().warn(e);
}
}
@@ -719,99 +771,77 @@
try {
SVNClientManager svnManager = getSVNClientManager();
SVNInfo svnInfo = svnManager.getWCClient().doInfo(pomFile.getParentFile(), SVNRevision.UNDEFINED);
- if (svnInfo!=null) {
+ if (svnInfo != null) {
SVNRevision revision = svnInfo.getRevision();
- if (revision!=null) {
+ if (revision != null) {
scmRevision = Long.toString(revision.getNumber());
}
}
- }
- catch (SVNException _) {
+ } catch (SVNException _) {
//
}
Artifact a = createArtifact(groupId, artifactId, version);
- return new ExtendedArtifact(
- a, name,
- url, organization, scmRevision, scm,
- developers, contributors,
- licenses);
+ return new ExtendedArtifact(a, name, 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.
+
+
+ /**
+ * 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.
* @return the artifact definition.
- * @throws ArtifactResolutionException
+ * @throws MojoExecutionException
*/
- protected Set<Artifact> resolveArtifact(String groupId, String artifactId, String version, boolean fireExceptions) throws ArtifactResolutionException {
- Artifact mavenArtifact = createArtifact(
- groupId,
- artifactId,
- version);
+ protected org.sonatype.aether.artifact.Artifact resolveArtifact(String groupId, String artifactId, String version) throws MojoExecutionException {
+ return this.resolveArtifact(new org.sonatype.aether.util.artifact.DefaultArtifact(groupId, artifactId,"jar", version));//$NON-NLS-1$
+ }
+
+ /**
+ * Retreive the extended artifact definition of the given artifact.
+ * @param mavenArtifact - the artifact to resolve
+ * @return the artifact definition.
+ * @throws MojoExecutionException
+ */
+ protected org.sonatype.aether.artifact.Artifact resolveArtifact(org.sonatype.aether.artifact.Artifact mavenArtifact) throws MojoExecutionException {
assert(mavenArtifact!=null);
+ ArtifactRequest request = new ArtifactRequest();
+ request.setArtifact(mavenArtifact);
+ request.setRepositories(this.getRemoteRepositoryList());
- 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$
+ this.info("Resolving artifact " + mavenArtifact.toString() + " from " + this.getRemoteRepositoryList()); //$NON-NLS-1$//$NON-NLS-2$
+
+ ArtifactResult result;
+ try {
+ result = this.getRepositorySystem().resolveArtifact(this.getRepositorySystemSession(), request);
+ } catch (ArtifactResolutionException e) {
+ throw new MojoExecutionException(e.getMessage(), e);
}
-
- 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();
+
+ this.info("Resolved artifact " + mavenArtifact.toString() + " to " + result.getArtifact().getFile() + " from " + result.getRepository());//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ return result.getArtifact();
}
- /** Create an Jar runtime artifact from the given values.
+ /**
+ * Create an Jar runtime artifact from the given values.
*
* @param groupId
* @param artifactId
* @param version
* @return the artifact
*/
- public Artifact createArtifact(
- String groupId,
- String artifactId,
- String version) {
- return createArtifact(groupId, artifactId, version,
- "runtime", "jar"); //$NON-NLS-1$//$NON-NLS-2$
+ public Artifact createArtifact(String groupId, String artifactId, String version) {
+ return createArtifact(groupId, artifactId, version, "runtime", "jar"); //$NON-NLS-1$//$NON-NLS-2$
}
- /** Create an artifact from the given values.
+ /**
+ * Create an artifact from the given values.
*
* @param groupId
* @param artifactId
@@ -821,84 +851,80 @@
* @return the artifact
* @see DefaultArtifactFactory
*/
- public Artifact createArtifact(
- String groupId,
- String artifactId,
- String version,
- String scope,
- String type) {
+ public Artifact createArtifact(String groupId, String artifactId, String version, String scope, String type) {
VersionRange versionRange = null;
- if (version!=null) {
- versionRange = VersionRange.createFromVersion( version );
+ if (version != null) {
+ versionRange = VersionRange.createFromVersion(version);
}
String desiredScope = scope;
- if ( Artifact.SCOPE_TEST.equals( desiredScope ) )
- {
+ if (Artifact.SCOPE_TEST.equals(desiredScope)) {
desiredScope = Artifact.SCOPE_TEST;
}
- if ( Artifact.SCOPE_PROVIDED.equals( desiredScope ) )
- {
+ if (Artifact.SCOPE_PROVIDED.equals(desiredScope)) {
desiredScope = Artifact.SCOPE_PROVIDED;
}
- if ( Artifact.SCOPE_SYSTEM.equals( desiredScope ) )
- {
+ if (Artifact.SCOPE_SYSTEM.equals(desiredScope)) {
// system scopes come through unchanged...
desiredScope = Artifact.SCOPE_SYSTEM;
}
ArtifactHandler handler = getArtifactHandlerManager().getArtifactHandler(type);
- return new DefaultArtifact(
- groupId, artifactId,
- versionRange,
- desiredScope,
- type,
- null, //classifier
- handler,
- false); //optional
+ return new org.apache.maven.artifact.DefaultArtifact(groupId, artifactId, versionRange, desiredScope, type, null, // classifier
+ handler, false); // optional
}
- /** Check if the values of the attributes of this Mojo are
- * correctly set.
- * This function may be overridden by subclasses to
- * test subclasse's attributes.
+ /**
+ * Check if the values of the attributes of this Mojo are correctly set. This function may be overridden by subclasses to test subclasse's attributes.
*
* @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$
- 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$
- if (o instanceof Long
- || 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$
+ if (o instanceof Boolean || 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$
+ if (o instanceof Long || 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$
if (o instanceof Array) {
- Array a = (Array)o;
- return a.getClass().getComponentType().getName()+"[]"; //$NON-NLS-1$
+ Array a = (Array) o;
+ return a.getClass().getComponentType().getName() + "[]"; //$NON-NLS-1$
}
- if (o instanceof Set<?>) return "set"; //$NON-NLS-1$
- if (o instanceof Map<?,?>) return "map"; //$NON-NLS-1$
- if (o instanceof List<?>) return "list"; //$NON-NLS-1$
- if (o instanceof Collection<?>) return "col"; //$NON-NLS-1$
+ if (o instanceof Set<?>)
+ return "set"; //$NON-NLS-1$
+ if (o instanceof Map<?, ?>)
+ return "map"; //$NON-NLS-1$
+ if (o instanceof List<?>)
+ return "list"; //$NON-NLS-1$
+ if (o instanceof Collection<?>)
+ return "col"; //$NON-NLS-1$
return "o"; //$NON-NLS-1$
}
- /** Throw an exception when the given object is null.
+ /**
+ * Throw an exception when the given object is null.
*
- * @param message is the message to put in the exception.
+ * @param message
+ * is the message to put in the exception.
* @param o
*/
protected void assertNotNull(String message, Object o) {
@@ -912,7 +938,8 @@
b.append(o);
getLog().debug(b.toString());
}
- if (o==null) throw new AssertionError("assertNotNull: "+message); //$NON-NLS-1$
+ if (o == null)
+ throw new AssertionError("assertNotNull: " + message); //$NON-NLS-1$
}
/**
@@ -922,26 +949,28 @@
try {
checkMojoAttributes();
executeMojo();
- }
- finally {
+ } finally {
clearInternalBuffers();
}
}
- /** Clear internal buffers.
+ /**
+ * Clear internal buffers.
*/
public synchronized void clearInternalBuffers() {
this.localArtifactDescriptions.clear();
this.remoteArtifactDescriptions.clear();
}
- /** Invoked when the Mojo should be executed.
+ /**
+ * Invoked when the Mojo should be executed.
*
* @throws MojoExecutionException
*/
protected abstract void executeMojo() throws MojoExecutionException;
- /** Join the values with the given joint
+ /**
+ * Join the values with the given joint
*
* @param joint
* @param values
@@ -949,9 +978,9 @@
*/
protected static String join(String joint, String... values) {
StringBuffer b = new StringBuffer();
- for(String value : values) {
- if (value!=null && !EMPTY_STRING.equals(value)) {
- if (b.length()>0) {
+ for (String value : values) {
+ if (value != null && !EMPTY_STRING.equals(value)) {
+ if (b.length() > 0) {
b.append(joint);
}
b.append(value);
@@ -968,44 +997,41 @@
BufferedReader bReader = new BufferedReader(reader);
try {
String line = bReader.readLine();
- while (line!=null) {
+ while (line != null) {
line = bReader.readLine();
}
- }
- finally {
+ } finally {
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.
+ /**
+ * 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.
*
- * @param file is the file to read.
- * @return the encoding charset of the given file or <code>null</code>
- * if the encoding could not be detected.
+ * @param file
+ * is the file to read.
+ * @return the encoding charset of the given file or <code>null</code> if the encoding could not be detected.
* @see #getPreferredCharsets()
* @see #setPreferredCharsets(Charset...)
*/
protected Charset detectEncoding(File file) {
Collection<Charset> fittingCharsets = new TreeSet<Charset>();
- for(Charset c : Charset.availableCharsets().values()) {
+ for (Charset c : Charset.availableCharsets().values()) {
CharsetDecoder decoder = c.newDecoder();
try {
detectEncoding(file, decoder);
fittingCharsets.add(c);
- }
- catch(Throwable e) {
+ } catch (Throwable e) {
//
}
}
if (getLog().isDebugEnabled()) {
- getLog().debug("Valid charsets for "+file.getName()+":\n"+fittingCharsets.toString()); //$NON-NLS-1$ //$NON-NLS-2$
+ getLog().debug("Valid charsets for " + file.getName() + ":\n" + fittingCharsets.toString()); //$NON-NLS-1$ //$NON-NLS-2$
}
- for(Charset prefCharset : getPreferredCharsets()) {
+ 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$
+ getLog().debug("Use preferred charset for " + file.getName() + ": " + prefCharset.displayName()); //$NON-NLS-1$ //$NON-NLS-2$
return prefCharset;
}
}
@@ -1013,7 +1039,7 @@
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$
+ getLog().debug("Use platform default charset for " + file.getName() + ": " + platformCharset.displayName()); //$NON-NLS-1$ //$NON-NLS-2$
return Charset.defaultCharset();
}
@@ -1021,7 +1047,7 @@
while (iterator.hasNext()) {
Charset c = iterator.next();
if (c.canEncode()) {
- getLog().debug("Use first valid charset for "+file.getName()+": "+c.displayName()); //$NON-NLS-1$ //$NON-NLS-2$
+ getLog().debug("Use first valid charset for " + file.getName() + ": " + c.displayName()); //$NON-NLS-1$ //$NON-NLS-2$
return c;
}
}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-08-18 10:03:30 UTC (rev 262)
+++ trunk/pom.xml 2011-08-19 14:44:31 UTC (rev 263)
@@ -16,7 +16,7 @@
</properties>
<!-- ======================================= -->
- <!-- ==== Dependencies === -->
+ <!-- ==== Dependencies === -->
<!-- ======================================= -->
<dependencyManagement>
@@ -118,6 +118,16 @@
<version>1.3.5</version>
</dependency>
<dependency>
+ <groupId>org.sonatype.aether</groupId>
+ <artifactId>aether-api</artifactId>
+ <version>1.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.sonatype.aether</groupId>
+ <artifactId>aether-util</artifactId>
+ <version>1.8</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
@@ -127,7 +137,7 @@
</dependencyManagement>
<!-- ======================================= -->
- <!-- ==== Project Information === -->
+ <!-- ==== Project Information === -->
<!-- ======================================= -->
<modules>
@@ -158,7 +168,7 @@
</mailingLists>
<!-- ======================================= -->
- <!-- ==== Organization Information === -->
+ <!-- ==== Organization Information === -->
<!-- ======================================= -->
<organization>
@@ -211,7 +221,7 @@
</developers>
<!-- ======================================= -->
- <!-- ==== Devel Configuration === -->
+ <!-- ==== Devel Configuration === -->
<!-- ======================================= -->
<distributionManagement>
@@ -355,7 +365,7 @@
</build>
<!-- ======================================= -->
- <!-- ==== Repositories === -->
+ <!-- ==== Repositories === -->
<!-- ======================================= -->
<repositories>
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-18 10:03:30 UTC (rev 262)
+++ trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/AbstractReplaceMojo.java 2011-08-19 14:44:31 UTC (rev 263)
@@ -20,18 +20,6 @@
*/
package org.arakhne.maven.plugins.tagreplacer;
-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;
-
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -45,34 +33,84 @@
import java.nio.channels.WritableByteChannel;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
+import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+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.arakhne.maven.AbstractArakhneMojo;
+import org.arakhne.maven.ExtendedArtifact;
+import org.sonatype.aether.RepositorySystem;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.repository.RemoteRepository;
+
/**
- * Replace all the tags variables by the corresponding values.
- * Supported variables are:<table>
+ * 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>$Filename$</td><td>The name of file</td></tr>
- * <tr><td>$FullVersion$</td><td>The name, version, revision and date of the Maven module.
- * It is equivalent to<br><code>$Version$ (rev:$Revision$) - $Date$</code></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 SCM/SVN revision number 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>
+ * <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>$Filename$</td>
+ * <td>The name of file</td>
+ * </tr>
+ * <tr>
+ * <td>$FullVersion$</td>
+ * <td>The name, version, revision and date of the Maven module. It is equivalent to<br>
+ * <code>$Version$ (rev:$Revision$) - $Date$</code></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 SCM/SVN revision number 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 $FullVersion$
* @mavengroupid $GroupId$
@@ -80,79 +118,108 @@
*/
public abstract class AbstractReplaceMojo extends AbstractArakhneMojo implements Macros {
- /** @component
+ /**
+ * @component
*/
private ArtifactHandlerManager artifactHandlerManager;
-
- /** @parameter expression="${project.basedir}"
+
+ /**
+ * @parameter expression="${project.basedir}"
*/
private File baseDirectory;
- /** @parameter expression="${project.build.directory}"
+ /**
+ * @parameter expression="${project.build.directory}"
*/
private File outputDirectory;
-
- /** @parameter expression="${project.build.outputDirectory}"
+
+ /**
+ * @parameter expression="${project.build.outputDirectory}"
*/
private File classDirectory;
- /** @parameter expression="${project.basedir}/src"
+ /**
+ * @parameter expression="${project.basedir}/src"
*/
private File sourceDirectory;
- /** @parameter expression="${project.build.directory}/generated-sources"
+ /**
+ * @parameter expression="${project.build.directory}/generated-sources"
*/
private File generatedSourceDirectory;
- /** Is the artifact id that should replace the project's artifact id.
+ /**
+ * Is the artifact id that should replace the project's artifact id.
+ *
* @parameter default-value="${project.artifactId}"
*/
private String projectArtifactId;
-
- /** Is the group id that should replace the project's group id.
+
+ /**
+ * Is the group id that should replace the project's group id.
+ *
* @parameter default-value="${project.groupId}"
*/
private String projectGroupId;
-
- /** Is the file encoding.
+
+ /**
+ * Is the file encoding.
+ *
* @parameter default-value="${project.build.sourceEncoding}"
*/
private String encoding;
- /** Indicates if the group id and artifact id of the current
- * project should be replaced by <var>userArtifactId</var>
- * and <var>artifactId</var>
+ /**
+ * 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.
+
+ /**
+ * Reference to the current maven project.
+ *
* @parameter expression="${project}"
* @required
*/
private MavenProject mavenProject;
-
- /** Reference to the current session.
+
+ /**
+ * Reference to the current session.
+ *
* @parameter expression="${session}"
* @required
*/
private MavenSession mavenSession;
- /** Reference to the current repository system.
+ /**
+ * The entry point to Aether, i.e. the component doing all the work.
+ *
* @component
*/
- private RepositorySystem repositorySystem;
+ private RepositorySystem repoSystem;
- /** Refenrece to the current resolution handler.
- * @component
+ /**
+ * The current repository/network configuration of Maven.
+ *
+ * @parameter default-value="${repositorySystemSession}"
+ * @readonly
*/
- private ResolutionErrorHandler resolutionErrorHandler;
-
+ private RepositorySystemSession repoSession;
+
+ /**
+ * The project's remote repositories to use for the resolution of plugins and their dependencies.
+ *
+ * @parameter default-value="${project.remotePluginRepositories}"
+ * @readonly
+ */
+ private List<RemoteRepository> remoteRepos;
+
private String ensureArtifactId(ExtendedArtifact artifact) {
- if (artifact!=null) {
+ if (artifact != null) {
if (this.overrideArtifactGroup && this.mavenProject.getArtifact().equals(artifact)) {
String a = this.projectArtifactId;
- if (a!=null && !EMPTY_STRING.equals(a)) {
+ if (a != null && !EMPTY_STRING.equals(a)) {
return this.projectArtifactId;
}
}
@@ -160,12 +227,12 @@
}
return EMPTY_STRING;
}
-
+
private String ensureGroupId(ExtendedArtifact artifact) {
- if (artifact!=null) {
+ if (artifact != null) {
if (this.overrideArtifactGroup && this.mavenProject.getArtifact().equals(artifact)) {
String g = this.projectGroupId;
- if (g!=null && !EMPTY_STRING.equals(g)) {
+ if (g != null && !EMPTY_STRING.equals(g)) {
return this.projectGroupId;
}
}
@@ -173,337 +240,341 @@
}
return EMPTY_STRING;
}
-
- /** Replace the Javadoc tags in the given file.
- *
- * @param sourceFile is the name of the file to read out. It may be <code>null</code>
- * @param targetFile is the name of the file to write in. It cannot be <code>null</code>
- * @param replacementType is the type of replacement to be done.
- * @param classpath are the directories from which the file is extracted.
- * @param detectEncoding when <code>true</code> the encoding of the file
- * will be detected and preserved. When <code>false</code> the encoding
- * may be loose.
- * @throws MojoExecutionException
- */
- protected synchronized void replaceInFile(
- File sourceFile, File targetFile,
- ReplacementType replacementType,
- File[] classpath,
- boolean detectEncoding) throws MojoExecutionException {
- File outputFile, inputFile;
- assert(targetFile!=null);
-
- if (sourceFile==null) {
- inputFile = targetFile;
- outputFile = new File(targetFile.getAbsolutePath()+".maven.tmp"); //$NON-NLS-1$
- }
- else {
- inputFile = sourceFile;
- outputFile = targetFile;
- }
- ExtendedArtifact artifact = searchArtifact(inputFile);
-
- String filename = removePathPrefix(getBaseDirectory(), inputFile);
-
- String shortFilename = null;
- for(int i=0; shortFilename==null && i<classpath.length; ++i) {
- if (inputFile.getAbsolutePath().startsWith(classpath[i].getAbsolutePath())) {
- shortFilename = removePathPrefix(classpath[i], inputFile);
- }
- }
-
- if (artifact!=null) {
- getLog().debug("Replacing in "+filename+" with artifact "+ //$NON-NLS-1$ //$NON-NLS-2$
- ArtifactUtils.key(artifact));
- }
- else {
- getLog().debug("Replacing in "+filename+" without artifact"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- try {
- outputFile.getParentFile().mkdirs();
- Reader r = null;
-
- Charset charset = null;
+ /**
+ * Replace the Javadoc tags in the given file.
+ *
+ * @param sourceFile
+ * is the name of the file to read out. It may be <code>null</code>
+ * @param targetFile
+ * is the name of the file to write in. It cannot be <code>null</code>
+ * @param replacementType
+ * is the type of replacement to be done.
+ * @param classpath
+ * are the directories from which the file is extracted.
+ * @param detectEncoding
+ * when <code>true</code> the encoding of the file will be detected and preserved. When <code>false</code> the encoding may be loose.
+ * @throws MojoExecutionException
+ */
+ protected synchronized void replaceInFile(File sourceFile, File targetFile, ReplacementType replacementType, File[] classpath, boolean detectEncoding) throws MojoExecutionException {
+ File outputFile, inputFile;
+ assert (targetFile != null);
- if (detectEncoding) {
- charset = detectEncoding(inputFile);
- }
+ if (sourceFile == null) {
+ inputFile = targetFile;
+ outputFile = new File(targetFile.getAbsolutePath() + ".maven.tmp"); //$NON-NLS-1$
+ } else {
+ inputFile = sourceFile;
+ outputFile = targetFile;
+ }
- if (charset==null)
- charset = Charset.defaultCharset();
+ ExtendedArtifact artifact = searchArtifact(inputFile);
- getLog().info("Copying file '" //$NON-NLS-1$
- +inputFile.getName()
- +"' with '" //$NON-NLS-1$
- +charset.displayName()
- +"' encoding"); //$NON-NLS-1$
+ String filename = removePathPrefix(getBaseDirectory(), inputFile);
- ReadableByteChannel channel = Channels.newChannel(new FileInputStream(inputFile));
+ String shortFilename = null;
+ for (int i = 0; shortFilename == null && i < classpath.length; ++i) {
+ if (inputFile.getAbsolutePath().startsWith(classpath[i].getAbsolutePath())) {
+ shortFilename = removePathPrefix(classpath[i], inputFile);
+ }
+ }
+
+ if (artifact != null) {
+ getLog().debug("Replacing in " + filename + " with artifact " + //$NON-NLS-1$ //$NON-NLS-2$
+ ArtifactUtils.key(artifact));
+ } else {
+ getLog().debug("Replacing in " + filename + " without artifact"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ try {
+ outputFile.getParentFile().mkdirs();
+ Reader r = null;
+
+ Charset charset = null;
+
+ if (detectEncoding) {
+ charset = detectEncoding(inputFile);
+ }
+
+ if (charset == null)
+ charset = Charset.defaultCharset();
+
+ getLog().info("Copying file '" //$NON-NLS-1$
+ + inputFile.getName() + "' with '" //$NON-NLS-1$
+ + charset.displayName() + "' encoding"); //$NON-NLS-1$
+
+ ReadableByteChannel channel = Channels.newChannel(new FileInputStream(inputFile));
r = Channels.newReader(channel, charset.newDecoder(), -1);
- if (r==null) {
- r = new FileReader(inputFile);
- }
+ if (r == null) {
+ r = new FileReader(inputFile);
+ }
- BufferedReader br = new BufferedReader(r);
-
- WritableByteChannel wChannel = Channels.newChannel(new FileOutputStream(outputFile));
- Writer w = Channels.newWriter(wChannel, charset.newEncoder(), -1);
+ BufferedReader br = new BufferedReader(r);
- String line;
-
- while ((line = br.readLine())!=null) {
- line = replaceInString(shortFilename, artifact, line, replacementType);
- w.write(line);
- w.write("\n"); //$NON-NLS-1$
- }
- w.flush();
- br.close();
- w.close();
-
- if (sourceFile==null) {
- fileCopy(outputFile, targetFile);
- outputFile.delete();
- }
- }
- catch(IOException e) {
- throw new MojoExecutionException(e.getLocalizedMessage(), e);
- }
- finally {
- if (sourceFile==null && outputFile.exists()) outputFile.delete();
- }
- }
-
+ WritableByteChannel wChannel = Channels.newChannel(new FileOutputStream(outputFile));
+ Writer w = Channels.newWriter(wChannel, charset.newEncoder(), -1);
+
+ String line;
+
+ while ((line = br.readLine()) != null) {
+ line = replaceInString(shortFilename, artifact, line, replacementType);
+ w.write(line);
+ w.write("\n"); //$NON-NLS-1$
+ }
+ w.flush();
+ br.close();
+ w.close();
+
+ if (sourceFile == null) {
+ fileCopy(outputFile, targetFile);
+ outputFile.delete();
+ }
+ } catch (IOException e) {
+ throw new MojoExecutionException(e.getLocalizedMessage(), e);
+ } finally {
+ if (sourceFile == 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);
+ 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);
+ 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);
}
-
- /** Utility function that replace the macros by the replacement text in the given text.
+
+ /**
+ * Utility 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.
- * @param type is the type of replacement to be done.
+ * @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.
+ * @param type
+ * is the type of replacement to be done.
* @return the result of the replacement
*/
- protected final String replaceMacro(String macroName, String text, String replacement, ReplacementType type) {
- return replaceMacro(macroName, text, replacement, type, true);
- }
-
- /** Utility function that replace the macros by the replacement text in the given text.
+ protected final String replaceMacro(String macroName, String text, String replacement, ReplacementType type) {
+ return replaceMacro(macroName, text, replacement, type, true);
+ }
+
+ /**
+ * Utility 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.
- * @param type is the type of replacement to be done.
- * @param enableWarning indicates if the warnings should be output or not.
+ * @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.
+ * @param type
+ * is the type of replacement to be done.
+ * @param enableWarning
+ * indicates if the warnings should be output or not.
* @return the result of the replacement
*/
- protected synchronized final String replaceMacro(String macroName, String text, String replacement, ReplacementType type, boolean enableWarning) {
- if (replacement!=null && !EMPTY_STRING.equals(replacement)) {
- Pattern p = buildMacroPattern(macroName);
- Matcher m = p.matcher(text);
- return m.replaceAll(Matcher.quoteReplacement(replacement));
- }
- if (enableWarning)
- getLog().warn("cannot replace empty macro "+macroName); //$NON-NLS-1$
- return text;
- }
-
- /** 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 synchronized 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();
+ protected synchronized final String replaceMacro(String macroName, String text, String replacement, ReplacementType type, boolean enableWarning) {
+ if (replacement != null && !EMPTY_STRING.equals(replacement)) {
+ Pattern p = buildMacroPattern(macroName);
+ Matcher m = p.matcher(text);
+ return m.replaceAll(Matcher.quoteReplacement(replacement));
+ }
+ if (enableWarning)
+ getLog().warn("cannot replace empty macro " + macroName); //$NON-NLS-1$
+ return text;
+ }
- if (hasResult) {
- StringBuffer sb = new StringBuffer();
+ /**
+ * 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 synchronized 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.getPeople(login, getLog());
- 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 {
- 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) {
- m.appendReplacement(sb, Matcher.quoteReplacement(replacement.toString()));
- }
- }
- else {
- String msg = "no login for Author tag: "+m.group(0); //$NON-NLS-1$
- if (getLog().isDebugEnabled()) {
- throw new MojoExecutionException(msg);
- }
- getLog().warn(msg);
- }
- }
- else {
- 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();
- }
- while (hasResult);
+ 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.getPeople(login, getLog());
+ 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 {
+ 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) {
+ m.appendReplacement(sb, Matcher.quoteReplacement(replacement.toString()));
+ }
+ } else {
+ String msg = "no login for Author tag: " + m.group(0); //$NON-NLS-1$
+ if (getLog().isDebugEnabled()) {
+ throw new MojoExecutionException(msg);
+ }
+ getLog().warn(msg);
+ }
+ } else {
+ 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();
+ } while (hasResult);
- m.appendTail(sb);
-
- result = sb.toString();
- }
- return result;
- }
+ m.appendTail(sb);
- /** Replace Javadoc tags in a string.
- *
- * @param file is the name of the file in the 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 synchronized String replaceInString(String file, ExtendedArtifact artifact, String line, ReplacementType replacementType) throws MojoExecutionException {
- String nline = line;
-
- String replacementName = (artifact==null) ? null : artifact.getName();
- String replacementVersion = (artifact==null) ? null : artifact.getVersion();
- String replacementRevision = (artifact==null) ? null : artifact.getScmRevision();
- String replacementArtifactId = ensureArtifactId(artifact);
- String replacementGroupId = ensureGroupId(artifact);
- String replacementWebsite = (artifact==null) ? null : artifact.getWebsite();
- String replacementFilename = (artifact==null) ? null : file;
-
- String replacementOrganization = null;
-
- if (artifact!=null) {
- Organization orga = artifact.getOrganization();
- if (orga!=null) {
- replacementOrganization = orga.getName();
- }
- }
-
+ result = sb.toString();
+ }
+ return result;
+ }
+
+ /**
+ * Replace Javadoc tags in a string.
+ *
+ * @param file
+ * is the name of the file in the 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 synchronized String replaceInString(String file, ExtendedArtifact artifact, String line, ReplacementType replacementType) throws MojoExecutionException {
+ String nline = line;
+
+ String replacementName = (artifact == null) ? null : artifact.getName();
+ String replacementVersion = (artifact == null) ? null : artifact.getVersion();
+ String replacementRevision = (artifact == null) ? null : artifact.getScmRevision();
+ String replacementArtifactId = ensureArtifactId(artifact);
+ String replacementGroupId = ensureGroupId(artifact);
+ String replacementWebsite = (artifact == null) ? null : artifact.getWebsite();
+ String replacementFilename = (artifact == null) ? null : file;
+
+ String replacementOrganization = null;
+
+ if (artifact != null) {
+ Organization orga = artifact.getOrganization();
+ if (orga != null) {
+ replacementOrganization = orga.getName();
+ }
+ }
+
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //$NON-NLS-1$
String currentDate = fmt.format(this.invocationDate);
String replacementFullVersion;
- if (artifact==null) {
- replacementFullVersion = null;
- }
- else {
- String rev = null;
- if (replacementRevision!=null) {
- StringBuffer b = new StringBuffer();
- b.append("(rev:"); //$NON-NLS-1$
- b.append(replacementRevision);
- b.append(")"); //$NON-NLS-1$
- rev = b.toString();
- }
- replacementFullVersion = join(" ", //$NON-NLS-1$
- replacementVersion,
- rev,
- currentDate);
- }
+ if (artifact == null) {
+ replacementFullVersion = null;
+ } else {
+ String rev = null;
+ if (replacementRevision != null) {
+ StringBuffer b = new StringBuffer();
+ b.append("(rev:"); //$NON-NLS-1$
+ b.append(replacementRevision);
+ b.append(")"); //$NON-NLS-1$
+ rev = b.toString();
+ }
+ replacementFullVersion = join(" ", //$NON-NLS-1$
+ replacementVersion, rev, currentDate);
+ }
- nline = replaceMacro(MACRO_NAME, nline, replacementName, replacementType);
- nline = replaceMacro(MACRO_REVISION, nline, replacementRevision, replacementType);
- nline = replaceMacro(MACRO_VERSION, nline, replacementVersion, replacementType);
- nline = replaceMacro(MACRO_ARTIFACTID, nline, replacementArtifactId, replacementType);
- nline = replaceMacro(MACRO_GROUPID, nline, replacementGroupId, replacementType);
- nline = replaceMacro(MACRO_WEBSITE, nline, replacementWebsite, replacementType, false);
- nline = replaceMacro(MACRO_ORGANIZATION, nline, replacementOrganization, replacementType, false);
- nline = replaceMacro(MACRO_DATE, nline, currentDate, replacementType);
- nline = replaceMacro(MACRO_FULLVERSION, nline, replacementFullVersion, replacementType);
- nline = replaceMacro(MACRO_FILENAME, nline, replacementFilename, replacementType);
+ nline = replaceMacro(MACRO_NAME, nline, replacementName, replacementType);
+ nline = replaceMacro(MACRO_REVISION, nline, replacementRevision, replacementType);
+ nline = replaceMacro(MACRO_VERSION, nline, replacementVersion, replacementType);
+ nline = replaceMacro(MACRO_ARTIFACTID, nline, replacementArtifactId, replacementType);
+ nline = replaceMacro(MACRO_GROUPID, nline, replacementGroupId, replacementType);
+ nline = replaceMacro(MACRO_WEBSITE, nline, replacementWebsite, replacementType, false);
+ nline = replaceMacro(MACRO_ORGANIZATION, nline, replacementOrganization, replacementType, false);
+ nline = replaceMacro(MACRO_DATE, nline, currentDate, replacementType);
+ nline = replaceMacro(MACRO_FULLVERSION, nline, replacementFullVersion, replacementType);
+ nline = replaceMacro(MACRO_FILENAME, nline, replacementFilename, replacementType);
- StringBuffer buffer = new StringBuffer();
- buffer.setLength(0);
- buffer.append("$Id: "); //$NON-NLS-1$
- buffer.append(file);
- buffer.append(' ');
- if (replacementRevision!=null) {
- buffer.append("rev:"); //$NON-NLS-1$
- buffer.append(replacementRevision);
- buffer.append(' ');
- }
- if (replacementVersion!=null) {
- buffer.append('v');
- buffer.append(replacementVersion);
- buffer.append(' ');
- }
- buffer.append(currentDate);
- buffer.append("$"); //$NON-NLS-1$
- nline = replaceMacro(MACRO_ID, nline, buffer.toString(), ReplacementType.TEXT);
+ StringBuffer buffer = new StringBuffer();
+ buffer.setLength(0);
+ buffer.append("$Id: "); //$NON-NLS-1$
+ buffer.append(file);
+ buffer.append(' ');
+ if (replacementRevision != null) {
+ buffer.append("rev:"); //$NON-NLS-1$
+ buffer.append(replacementRevision);
+ buffer.append(' ');
+ }
+ if (replacementVersion != null) {
+ buffer.append('v');
+ buffer.append(replacementVersion);
+ buffer.append(' ');
+ }
+ buffer.append(currentDate);
+ buffer.append("$"); //$NON-NLS-1$
+ nline = replaceMacro(MACRO_ID, nline, buffer.toString(), ReplacementType.TEXT);
- nline = replaceAuthor(nline, artifact, replacementType);
-
- return nline;
- }
-
+ nline = replaceAuthor(nline, artifact, replacementType);
+
+ return nline;
+ }
+
/**
* {@inheritDoc}
*/
@@ -515,11 +586,12 @@
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("repositorySystem", this.repoSystem); //$NON-NLS-1$
+ assertNotNull("repositorySystemSession", this.repoSession); //$NON-NLS-1$
+ assertNotNull("remoteRepositoryList", this.remoteRepos); //$NON-NLS-1$
assertNotNull("artifactId", this.projectArtifactId); //$NON-NLS-1$
assertNotNull("groupId", this.projectGroupId); //$NON-NLS-1$
- if (this.encoding==null)
+ if (this.encoding == null)
this.encoding = System.getProperty("file.encoding"); //$NON-NLS-1$
}
@@ -535,22 +607,6 @@
* {@inheritDoc}
*/
@Override
- protected RepositorySystem getRepositorySystem() {
- return this.repositorySystem;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResolutionErrorHandler getResolutionErrorHandler() {
- return this.resolutionErrorHandler;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
protected File getBaseDirectory() {
return this.baseDirectory;
}
@@ -605,22 +661,48 @@
}
/**
- * Types of replacement.
- *
- * @author $Author: galland$
- * @version $FullVersion$
- * @mavengroupid $GroupId$
- * @mavenartifactid $ArtifactId$
- */
- protected enum ReplacementType {
- /** HTML replacement.
- */
- HTML,
-
- /** Raw text replacement.
- */
- TEXT;
-
- }
-
+ * Types of replacement.
+ *
+ * @author $Author: galland$
+ * @version $FullVersion$
+ * @mavengroupid $GroupId$
+ * @mavenartifactid $ArtifactId$
+ */
+ protected enum ReplacementType {
+ /**
+ * HTML replacement.
+ */
+ HTML,
+
+ /**
+ * Raw text replacement.
+ */
+ TEXT;
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RepositorySystemSession getRepositorySystemSession() {
+ return this.repoSession;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected List<RemoteRepository> getRemoteRepositoryList() {
+ return this.remoteRepos;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RepositorySystem getRepositorySystem() {
+ return this.repoSystem;
+ }
+
}