You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/03/18 22:01:34 UTC
[maven-doxia-sitetools] branch replace-old-resolution updated (83ae4ad -> f6a70cc)
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a change to branch replace-old-resolution
in repository https://gitbox.apache.org/repos/asf/maven-doxia-sitetools.git
discard 83ae4ad [DOXIASITETOOLS-294] Replace legacy artifact resolution with Maven Resolver
new b10c91f [DOXIASITETOOLS-293] Remove menu items link in the sidebar to submodule that are not present in the same build (reactor)
new f6a70cc [DOXIASITETOOLS-294] Replace legacy artifact resolution with Maven Resolver
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (83ae4ad)
\
N -- N -- N refs/heads/replace-old-resolution (f6a70cc)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../java/org/apache/maven/doxia/tools/SiteToolTest.java | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
[maven-doxia-sitetools] 01/02: [DOXIASITETOOLS-293] Remove menu items link in the sidebar to submodule that are not present in the same build (reactor)
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch replace-old-resolution
in repository https://gitbox.apache.org/repos/asf/maven-doxia-sitetools.git
commit b10c91f0d941fc23ee9b0726df417414e729a34b
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sat Mar 18 22:59:10 2023 +0100
[DOXIASITETOOLS-293] Remove menu items link in the sidebar to submodule that are not present in the same build (reactor)
---
.../apache/maven/doxia/tools/DefaultSiteTool.java | 37 ++++------------------
1 file changed, 7 insertions(+), 30 deletions(-)
diff --git a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
index b1df33f..3c1fb4c 100644
--- a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
+++ b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
@@ -397,7 +397,7 @@ public class DefaultSiteTool implements SiteTool {
}
try {
- populateModulesMenu(decorationModel, locale, project, reactorProjects, localRepository, true);
+ populateModulesMenu(decorationModel, locale, project, reactorProjects, true);
} catch (IOException e) {
throw new SiteToolException("Error while populating modules menu", e);
}
@@ -520,7 +520,6 @@ public class DefaultSiteTool implements SiteTool {
* @param locale the locale used for the i18n in DecorationModel, not null.
* @param project a Maven project, not null.
* @param reactorProjects the Maven reactor projects, not null.
- * @param localRepository the Maven local repository, not null.
* @param keepInheritedRefs used for inherited references.
* @throws SiteToolException if any
* @throws IOException
@@ -530,14 +529,12 @@ public class DefaultSiteTool implements SiteTool {
Locale locale,
MavenProject project,
List<MavenProject> reactorProjects,
- ArtifactRepository localRepository,
boolean keepInheritedRefs)
throws SiteToolException, IOException {
Objects.requireNonNull(decorationModel, "decorationModel cannot be null");
Objects.requireNonNull(locale, "locale cannot be null");
Objects.requireNonNull(project, "project cannot be null");
Objects.requireNonNull(reactorProjects, "reactorProjects cannot be null");
- Objects.requireNonNull(localRepository, "localRepository cannot be null");
Menu menu = decorationModel.getMenuRef("modules");
@@ -550,37 +547,17 @@ public class DefaultSiteTool implements SiteTool {
}
// we require child modules and reactors to process module menu
- if (project.getModules().size() > 0) {
+ if (!project.getModules().isEmpty()) {
if (menu.getName() == null) {
menu.setName(i18n.getString("site-tool", locale, "decorationModel.menu.projectmodules"));
}
- for (String module : (List<String>) project.getModules()) {
+ for (String module : project.getModules()) {
MavenProject moduleProject = getModuleFromReactor(project, reactorProjects, module);
if (moduleProject == null) {
- LOGGER.warn("Module " + module + " not found in reactor: loading locally");
-
- File f = new File(project.getBasedir(), module + "/pom.xml");
- if (f.exists()) {
- try {
- ProjectBuildingRequest request = new DefaultProjectBuildingRequest();
- request.setLocalRepository(localRepository);
-
- ProjectBuildingResult result = projectBuilder.build(f, request);
- moduleProject = result.getProject();
- } catch (ProjectBuildingException e) {
- throw new SiteToolException("Unable to read local module POM", e);
- }
- } else {
- LOGGER.warn("No filesystem module POM available");
-
- moduleProject = new MavenProject();
- moduleProject.setName(module);
- moduleProject.setDistributionManagement(new DistributionManagement());
- moduleProject.getDistributionManagement().setSite(new Site());
- moduleProject.getDistributionManagement().getSite().setUrl(module);
- }
+ LOGGER.debug("Module " + module + " not found in reactor");
+ continue;
}
final String pluginId = "org.apache.maven.plugins:maven-site-plugin";
@@ -602,8 +579,8 @@ public class DefaultSiteTool implements SiteTool {
}
}
- private static MavenProject getModuleFromReactor(
- MavenProject project, List<MavenProject> reactorProjects, String module) throws IOException {
+ private MavenProject getModuleFromReactor(MavenProject project, List<MavenProject> reactorProjects, String module)
+ throws IOException {
File moduleBasedir = new File(project.getBasedir(), module).getCanonicalFile();
for (MavenProject reactorProject : reactorProjects) {
[maven-doxia-sitetools] 02/02: [DOXIASITETOOLS-294] Replace legacy artifact resolution with Maven Resolver
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch replace-old-resolution
in repository https://gitbox.apache.org/repos/asf/maven-doxia-sitetools.git
commit f6a70cc38fc45538b92c360c8e123a8a40bfc985
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sat Mar 18 23:00:40 2023 +0100
[DOXIASITETOOLS-294] Replace legacy artifact resolution with Maven Resolver
---
.../apache/maven/doxia/tools/DefaultSiteTool.java | 264 ++++++++++-----------
.../org/apache/maven/doxia/tools/SiteTool.java | 25 +-
.../org/apache/maven/doxia/tools/SiteToolTest.java | 38 +--
.../tools/stubs/SiteToolMavenProjectStub.java | 7 +
4 files changed, 169 insertions(+), 165 deletions(-)
diff --git a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
index 3c1fb4c..b177cbe 100644
--- a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
+++ b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
@@ -40,12 +40,11 @@ import java.util.Objects;
import java.util.StringTokenizer;
import org.apache.commons.io.FilenameUtils;
+import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.doxia.site.decoration.DecorationModel;
@@ -57,13 +56,8 @@ import org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader;
import org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Writer;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Plugin;
-import org.apache.maven.model.Site;
-import org.apache.maven.project.DefaultProjectBuildingRequest;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuilder;
-import org.apache.maven.project.ProjectBuildingException;
-import org.apache.maven.project.ProjectBuildingRequest;
-import org.apache.maven.project.ProjectBuildingResult;
import org.apache.maven.reporting.MavenReport;
import org.codehaus.plexus.i18n.I18N;
import org.codehaus.plexus.interpolation.EnvarBasedValueSource;
@@ -77,6 +71,13 @@ import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.ArtifactRequest;
+import org.eclipse.aether.resolution.ArtifactResolutionException;
+import org.eclipse.aether.resolution.ArtifactResult;
+import org.eclipse.aether.transfer.ArtifactNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -95,16 +96,16 @@ public class DefaultSiteTool implements SiteTool {
// ----------------------------------------------------------------------
/**
- * The component that is used to resolve additional artifacts required.
+ * The component that is used to resolve additional required artifacts.
*/
@Inject
- private ArtifactResolver artifactResolver;
+ protected RepositorySystem repositorySystem;
/**
- * The component used for creating artifact instances.
+ * The component used for getting artifact handlers.
*/
@Inject
- private ArtifactFactory artifactFactory;
+ private ArtifactHandlerManager artifactHandlerManager;
/**
* Internationalization.
@@ -128,36 +129,43 @@ public class DefaultSiteTool implements SiteTool {
// Public methods
// ----------------------------------------------------------------------
+ /** {@inheritDoc} */
public Artifact getSkinArtifactFromRepository(
- ArtifactRepository localRepository,
- List<ArtifactRepository> remoteArtifactRepositories,
- DecorationModel decoration)
+ RepositorySystemSession repoSession, List<RemoteRepository> remoteProjectRepositories, Skin skin)
throws SiteToolException {
- Objects.requireNonNull(localRepository, "localRepository cannot be null");
- Objects.requireNonNull(remoteArtifactRepositories, "remoteArtifactRepositories cannot be null");
- Objects.requireNonNull(decoration, "decoration cannot be null");
- Skin skin = Objects.requireNonNull(decoration.getSkin(), "decoration.skin cannot be null");
+ Objects.requireNonNull(repoSession, "repoSession cannot be null");
+ Objects.requireNonNull(remoteProjectRepositories, "remoteProjectRepositories cannot be null");
+ Objects.requireNonNull(skin, "skin cannot be null");
String version = skin.getVersion();
- Artifact artifact;
try {
if (version == null) {
version = Artifact.RELEASE_VERSION;
}
VersionRange versionSpec = VersionRange.createFromVersionSpec(version);
- artifact = artifactFactory.createDependencyArtifact(
- skin.getGroupId(), skin.getArtifactId(), versionSpec, "jar", null, null);
-
- artifactResolver.resolve(artifact, remoteArtifactRepositories, localRepository);
+ String type = "jar";
+ Artifact artifact = new DefaultArtifact(
+ skin.getGroupId(),
+ skin.getArtifactId(),
+ versionSpec,
+ Artifact.SCOPE_RUNTIME,
+ type,
+ null,
+ artifactHandlerManager.getArtifactHandler(type));
+ ArtifactRequest request =
+ new ArtifactRequest(RepositoryUtils.toArtifact(artifact), remoteProjectRepositories, "remote-skin");
+ ArtifactResult result = repositorySystem.resolveArtifact(repoSession, request);
+
+ return RepositoryUtils.toArtifact(result.getArtifact());
} catch (InvalidVersionSpecificationException e) {
throw new SiteToolException("The skin version '" + version + "' is not valid", e);
} catch (ArtifactResolutionException e) {
+ if (e.getCause() instanceof ArtifactNotFoundException) {
+ throw new SiteToolException("The skin does not exist", e.getCause());
+ }
+
throw new SiteToolException("Unable to find skin", e);
- } catch (ArtifactNotFoundException e) {
- throw new SiteToolException("The skin does not exist", e);
}
-
- return artifact;
}
/**
@@ -325,8 +333,8 @@ public class DefaultSiteTool implements SiteTool {
* Get a site descriptor from one of the repositories.
*
* @param project the Maven project, not null.
- * @param localRepository the Maven local repository, not null.
- * @param repositories the Maven remote repositories, not null.
+ * @param repoSession the repository system session, not null.
+ * @param remoteProjectRepositories the Maven remote project repositories, not null.
* @param locale the locale wanted for the site descriptor, not null.
* See {@link #getSiteDescriptor(File, Locale)} for details.
* @return the site descriptor into the local repository after download of it from repositories or null if not
@@ -335,17 +343,17 @@ public class DefaultSiteTool implements SiteTool {
*/
File getSiteDescriptorFromRepository(
MavenProject project,
- ArtifactRepository localRepository,
- List<ArtifactRepository> repositories,
+ RepositorySystemSession repoSession,
+ List<RemoteRepository> remoteProjectRepositories,
Locale locale)
throws SiteToolException {
Objects.requireNonNull(project, "project cannot be null");
- Objects.requireNonNull(localRepository, "localRepository cannot be null");
- Objects.requireNonNull(repositories, "repositories cannot be null");
+ Objects.requireNonNull(repoSession, "repoSession cannot be null");
+ Objects.requireNonNull(remoteProjectRepositories, "remoteProjectRepositories cannot be null");
Objects.requireNonNull(locale, "locale cannot be null");
try {
- return resolveSiteDescriptor(project, localRepository, repositories, locale);
+ return resolveSiteDescriptor(project, repoSession, remoteProjectRepositories, locale);
} catch (ArtifactNotFoundException e) {
LOGGER.debug("Unable to locate site descriptor", e);
return null;
@@ -362,20 +370,20 @@ public class DefaultSiteTool implements SiteTool {
Locale locale,
MavenProject project,
List<MavenProject> reactorProjects,
- ArtifactRepository localRepository,
- List<ArtifactRepository> repositories)
+ RepositorySystemSession repoSession,
+ List<RemoteRepository> remoteProjectRepositories)
throws SiteToolException {
Objects.requireNonNull(locale, "locale cannot be null");
Objects.requireNonNull(project, "project cannot be null");
Objects.requireNonNull(reactorProjects, "reactorProjects cannot be null");
- Objects.requireNonNull(localRepository, "localRepository cannot be null");
- Objects.requireNonNull(repositories, "repositories cannot be null");
+ Objects.requireNonNull(repoSession, "repoSession cannot be null");
+ Objects.requireNonNull(remoteProjectRepositories, "remoteProjectRepositories cannot be null");
LOGGER.debug("Computing decoration model of '" + project.getId() + "' for "
+ (locale.equals(SiteTool.DEFAULT_LOCALE) ? "default locale" : "locale '" + locale + "'"));
Map.Entry<DecorationModel, MavenProject> result =
- getDecorationModel(0, siteDirectory, locale, project, reactorProjects, localRepository, repositories);
+ getDecorationModel(0, siteDirectory, locale, project, repoSession, remoteProjectRepositories);
DecorationModel decorationModel = result.getKey();
MavenProject parentProject = result.getValue();
@@ -763,8 +771,30 @@ public class DefaultSiteTool implements SiteTool {
/**
* @param project not null
- * @param localRepository not null
- * @param repositories not null
+ * @param localeStr not null
+ * @param remoteProjectRepositories not null
+ * @return the site descriptor artifact request
+ */
+ private ArtifactRequest createSiteDescriptorArtifactRequest(
+ MavenProject project, String localeStr, List<RemoteRepository> remoteProjectRepositories) {
+ String type = "xml";
+ ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler(type);
+ Artifact artifact = new DefaultArtifact(
+ project.getGroupId(),
+ project.getArtifactId(),
+ project.getVersion(),
+ Artifact.SCOPE_RUNTIME,
+ type,
+ "site" + (localeStr.isEmpty() ? "" : "_" + localeStr),
+ artifactHandler);
+ return new ArtifactRequest(
+ RepositoryUtils.toArtifact(artifact), remoteProjectRepositories, "remote-site-descriptor");
+ }
+
+ /**
+ * @param project not null
+ * @param repoSession the repository system session not null
+ * @param remoteProjectRepositories not null
* @param locale not null
* @return the resolved site descriptor
* @throws IOException if any
@@ -773,128 +803,93 @@ public class DefaultSiteTool implements SiteTool {
*/
private File resolveSiteDescriptor(
MavenProject project,
- ArtifactRepository localRepository,
- List<ArtifactRepository> repositories,
+ RepositorySystemSession repoSession,
+ List<RemoteRepository> remoteProjectRepositories,
Locale locale)
throws IOException, ArtifactResolutionException, ArtifactNotFoundException {
String variant = locale.getVariant();
String country = locale.getCountry();
String language = locale.getLanguage();
- Artifact artifact = null;
+ String localeStr = null;
File siteDescriptor = null;
boolean found = false;
if (!variant.isEmpty()) {
- String localeStr = language + "_" + country + "_" + variant;
- // TODO: this is a bit crude - proper type, or proper handling as metadata rather than an artifact in 2.1?
- artifact = artifactFactory.createArtifactWithClassifier(
- project.getGroupId(), project.getArtifactId(), project.getVersion(), "xml", "site_" + localeStr);
+ localeStr = language + "_" + country + "_" + variant;
+ ArtifactRequest request =
+ createSiteDescriptorArtifactRequest(project, localeStr, remoteProjectRepositories);
try {
- artifactResolver.resolve(artifact, repositories, localRepository);
-
- siteDescriptor = artifact.getFile();
+ ArtifactResult result = repositorySystem.resolveArtifact(repoSession, request);
- // we use zero length files to avoid re-resolution (see below)
- if (siteDescriptor.length() > 0) {
- found = true;
- } else {
+ siteDescriptor = result.getArtifact().getFile();
+ found = true;
+ } catch (ArtifactResolutionException e) {
+ if (e.getCause() instanceof ArtifactNotFoundException) {
LOGGER.debug("No site descriptor found for '" + project.getId() + "' for locale '" + localeStr
+ "', trying without variant...");
+ } else {
+ throw e;
}
- } catch (ArtifactNotFoundException e) {
- LOGGER.debug("Unable to locate site descriptor for locale '" + localeStr + "'", e);
-
- // we can afford to write an empty descriptor here as we don't expect it to turn up later in the
- // remote repository, because the parent was already released (and snapshots are updated
- // automatically if changed)
- siteDescriptor = new File(localRepository.getBasedir(), localRepository.pathOf(artifact));
- siteDescriptor.getParentFile().mkdirs();
- siteDescriptor.createNewFile();
}
}
if (!found && !country.isEmpty()) {
- String localeStr = language + "_" + country;
- // TODO: this is a bit crude - proper type, or proper handling as metadata rather than an artifact in 2.1?
- artifact = artifactFactory.createArtifactWithClassifier(
- project.getGroupId(), project.getArtifactId(), project.getVersion(), "xml", "site_" + localeStr);
+ localeStr = language + "_" + country;
+ ArtifactRequest request =
+ createSiteDescriptorArtifactRequest(project, localeStr, remoteProjectRepositories);
try {
- artifactResolver.resolve(artifact, repositories, localRepository);
+ ArtifactResult result = repositorySystem.resolveArtifact(repoSession, request);
- siteDescriptor = artifact.getFile();
-
- // we use zero length files to avoid re-resolution (see below)
- if (siteDescriptor.length() > 0) {
- found = true;
- } else {
+ siteDescriptor = result.getArtifact().getFile();
+ found = true;
+ } catch (ArtifactResolutionException e) {
+ if (e.getCause() instanceof ArtifactNotFoundException) {
LOGGER.debug("No site descriptor found for '" + project.getId() + "' for locale '" + localeStr
+ "', trying without country...");
+ } else {
+ throw e;
}
- } catch (ArtifactNotFoundException e) {
- LOGGER.debug("Unable to locate site descriptor for locale '" + localeStr + "'", e);
-
- // we can afford to write an empty descriptor here as we don't expect it to turn up later in the
- // remote repository, because the parent was already released (and snapshots are updated
- // automatically if changed)
- siteDescriptor = new File(localRepository.getBasedir(), localRepository.pathOf(artifact));
- siteDescriptor.getParentFile().mkdirs();
- siteDescriptor.createNewFile();
}
}
if (!found && !language.isEmpty()) {
- String localeStr = language;
- // TODO: this is a bit crude - proper type, or proper handling as metadata rather than an artifact in 2.1?
- artifact = artifactFactory.createArtifactWithClassifier(
- project.getGroupId(), project.getArtifactId(), project.getVersion(), "xml", "site_" + localeStr);
+ localeStr = language;
+ ArtifactRequest request =
+ createSiteDescriptorArtifactRequest(project, localeStr, remoteProjectRepositories);
try {
- artifactResolver.resolve(artifact, repositories, localRepository);
+ ArtifactResult result = repositorySystem.resolveArtifact(repoSession, request);
- siteDescriptor = artifact.getFile();
-
- // we use zero length files to avoid re-resolution (see below)
- if (siteDescriptor.length() > 0) {
- found = true;
- } else {
+ siteDescriptor = result.getArtifact().getFile();
+ found = true;
+ } catch (ArtifactResolutionException e) {
+ if (e.getCause() instanceof ArtifactNotFoundException) {
LOGGER.debug("No site descriptor found for '" + project.getId() + "' for locale '" + localeStr
- + "', trying default locale...");
+ + "', trying without language (default locale)...");
+ } else {
+ throw e;
}
- } catch (ArtifactNotFoundException e) {
- LOGGER.debug("Unable to locate site descriptor for locale '" + localeStr + "'", e);
-
- // we can afford to write an empty descriptor here as we don't expect it to turn up later in the
- // remote repository, because the parent was already released (and snapshots are updated
- // automatically if changed)
- siteDescriptor = new File(localRepository.getBasedir(), localRepository.pathOf(artifact));
- siteDescriptor.getParentFile().mkdirs();
- siteDescriptor.createNewFile();
}
}
if (!found) {
- artifact = artifactFactory.createArtifactWithClassifier(
- project.getGroupId(), project.getArtifactId(), project.getVersion(), "xml", "site");
+ localeStr = "";
+ ArtifactRequest request =
+ createSiteDescriptorArtifactRequest(project, localeStr, remoteProjectRepositories);
try {
- artifactResolver.resolve(artifact, repositories, localRepository);
- } catch (ArtifactNotFoundException e) {
- // see above regarding this zero length file
- siteDescriptor = new File(localRepository.getBasedir(), localRepository.pathOf(artifact));
- siteDescriptor.getParentFile().mkdirs();
- siteDescriptor.createNewFile();
-
- throw e;
- }
+ ArtifactResult result = repositorySystem.resolveArtifact(repoSession, request);
- siteDescriptor = artifact.getFile();
+ siteDescriptor = result.getArtifact().getFile();
+ } catch (ArtifactResolutionException e) {
+ if (e.getCause() instanceof ArtifactNotFoundException) {
+ LOGGER.debug("No site descriptor found for '" + project.getId() + "' with default locale.");
+ throw (ArtifactNotFoundException) e.getCause();
+ }
- // we use zero length files to avoid re-resolution (see below)
- if (siteDescriptor.length() == 0) {
- LOGGER.debug("No site descriptor found for '" + project.getId() + "' with default locale.");
- siteDescriptor = null;
+ throw e;
}
}
@@ -906,9 +901,8 @@ public class DefaultSiteTool implements SiteTool {
* @param siteDirectory, can be null if project.basedir is null, ie POM from repository
* @param locale not null
* @param project not null
- * @param reactorProjects not null
- * @param localRepository not null
- * @param repositories not null
+ * @param repoSession not null
+ * @param remoteProjectRepositories not null
* @return the decoration model depending the locale and the parent project
* @throws SiteToolException if any
*/
@@ -917,16 +911,16 @@ public class DefaultSiteTool implements SiteTool {
File siteDirectory,
Locale locale,
MavenProject project,
- List<MavenProject> reactorProjects,
- ArtifactRepository localRepository,
- List<ArtifactRepository> repositories)
+ RepositorySystemSession repoSession,
+ List<RemoteRepository> remoteProjectRepositories)
throws SiteToolException {
// 1. get site descriptor File
File siteDescriptor;
if (project.getBasedir() == null) {
// POM is in the repository: look into the repository for site descriptor
try {
- siteDescriptor = getSiteDescriptorFromRepository(project, localRepository, repositories, locale);
+ siteDescriptor =
+ getSiteDescriptorFromRepository(project, repoSession, remoteProjectRepositories, locale);
} catch (SiteToolException e) {
throw new SiteToolException("The site descriptor cannot be resolved from the repository", e);
}
@@ -983,13 +977,7 @@ public class DefaultSiteTool implements SiteTool {
}
DecorationModel parentDecorationModel = getDecorationModel(
- depth,
- parentSiteDirectory,
- locale,
- parentProject,
- reactorProjects,
- localRepository,
- repositories)
+ depth, parentSiteDirectory, locale, parentProject, repoSession, remoteProjectRepositories)
.getKey();
// MSHARED-116 requires an empty decoration model (instead of a null one)
diff --git a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java
index 5478915..cc29dd8 100644
--- a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java
+++ b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java
@@ -24,10 +24,12 @@ import java.util.Locale;
import java.util.Map;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.doxia.site.decoration.DecorationModel;
+import org.apache.maven.doxia.site.decoration.Skin;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.MavenReport;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.RemoteRepository;
/**
* Tool to play with <a href="http://maven.apache.org/doxia/">Doxia</a> objects
@@ -46,17 +48,14 @@ public interface SiteTool {
/**
* Get a skin artifact from one of the repositories.
*
- * @param localRepository the Maven local repository, not null.
- * @param remoteArtifactRepositories the Maven remote repositories, not null.
- * @param decoration the Doxia site descriptor model, not null.
- * @return the <code>Skin</code> artifact defined in a <code>DecorationModel</code> from a given project and a
- * local repository
+ * @param repoSession the repository system session, not null.
+ * @param remoteProjectRepositories the Maven remote project repositories, not null.
+ * @param skin the Skin model, not null.
+ * @return the <code>Skin</code> artifact defined in a <code>DecorationModel</code> from a given project
* @throws SiteToolException if any
*/
Artifact getSkinArtifactFromRepository(
- ArtifactRepository localRepository,
- List<ArtifactRepository> remoteArtifactRepositories,
- DecorationModel decoration)
+ RepositorySystemSession repoSession, List<RemoteRepository> remoteProjectRepositories, Skin skin)
throws SiteToolException;
/**
@@ -115,8 +114,8 @@ public interface SiteTool {
* See {@link #getSiteDescriptor(File, Locale)} for details.
* @param project the Maven project, not null.
* @param reactorProjects the Maven reactor projects, not null.
- * @param localRepository the Maven local repository, not null.
- * @param repositories the Maven remote repositories, not null.
+ * @param repoSession the repository system session, not null.
+ * @param remoteProjectRepositories the Maven remote project repositories, not null.
* @return the <code>DecorationModel</code> object corresponding to the <code>site.xml</code> file with some
* interpolations.
* @throws SiteToolException if any
@@ -127,8 +126,8 @@ public interface SiteTool {
Locale locale,
MavenProject project,
List<MavenProject> reactorProjects,
- ArtifactRepository localRepository,
- List<ArtifactRepository> repositories)
+ RepositorySystemSession repoSession,
+ List<RemoteRepository> remoteProjectRepositories)
throws SiteToolException;
/**
diff --git a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
index 34ce2e4..cf14221 100644
--- a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
+++ b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
@@ -41,11 +41,16 @@ import org.apache.maven.doxia.site.decoration.Skin;
import org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Writer;
import org.apache.maven.doxia.tools.stubs.SiteToolMavenProjectStub;
import org.apache.maven.project.MavenProject;
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.WriterFactory;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
+import org.eclipse.aether.repository.LocalRepository;
import org.junit.jupiter.api.Test;
import static org.codehaus.plexus.testing.PlexusExtension.getTestFile;
@@ -105,6 +110,13 @@ public class SiteToolTest {
return new File(getLocalRepo().getBasedir());
}
+ protected RepositorySystemSession newRepoSession() throws Exception {
+ DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession();
+ repoSession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory()
+ .newInstance(repoSession, new LocalRepository(getLocalRepoDir())));
+ return repoSession;
+ }
+
/**
* @throws Exception
*/
@@ -113,13 +125,11 @@ public class SiteToolTest {
assertNotNull(tool);
SiteToolMavenProjectStub project = new SiteToolMavenProjectStub("site-tool-test");
- DecorationModel decorationModel = new DecorationModel();
Skin skin = new Skin();
skin.setGroupId("org.apache.maven.skins");
skin.setArtifactId("maven-stylus-skin");
- decorationModel.setSkin(skin);
- assertNotNull(tool.getSkinArtifactFromRepository(
- getLocalRepo(), project.getRemoteArtifactRepositories(), decorationModel));
+ assertNotNull(
+ tool.getSkinArtifactFromRepository(newRepoSession(), project.getRemoteProjectRepositories(), skin));
}
private void checkGetRelativePathDirectory(SiteTool tool, String relative, String to, String from) {
@@ -330,8 +340,8 @@ public class SiteToolTest {
assertEquals(
tool.getSiteDescriptorFromRepository(
project,
- getLocalRepo(),
- project.getRemoteArtifactRepositories(),
+ newRepoSession(),
+ project.getRemoteProjectRepositories(),
SiteTool.DEFAULT_LOCALE)
.toString(),
result);
@@ -353,8 +363,8 @@ public class SiteToolTest {
SiteTool.DEFAULT_LOCALE,
project,
reactorProjects,
- getLocalRepo(),
- project.getRemoteArtifactRepositories());
+ newRepoSession(),
+ project.getRemoteProjectRepositories());
assertNotNull(model);
assertNotNull(model.getBannerLeft());
assertEquals("Maven Site", model.getBannerLeft().getName());
@@ -379,8 +389,8 @@ public class SiteToolTest {
SiteTool.DEFAULT_LOCALE,
project,
reactorProjects,
- getLocalRepo(),
- project.getRemoteArtifactRepositories());
+ newRepoSession(),
+ project.getRemoteProjectRepositories());
assertNotNull(modelFromRepo);
assertNotNull(modelFromRepo.getBannerLeft());
assertEquals("dummy", modelFromRepo.getBannerLeft().getName());
@@ -407,8 +417,8 @@ public class SiteToolTest {
SiteTool.DEFAULT_LOCALE,
project,
reactorProjects,
- getLocalRepo(),
- project.getRemoteArtifactRepositories());
+ newRepoSession(),
+ project.getRemoteProjectRepositories());
assertNotNull(model);
}
@@ -469,8 +479,8 @@ public class SiteToolTest {
SiteTool.DEFAULT_LOCALE,
childProject,
reactorProjects,
- getLocalRepo(),
- childProject.getRemoteArtifactRepositories());
+ newRepoSession(),
+ childProject.getRemoteProjectRepositories());
assertNotNull(model);
writeModel(model, "unit/interpolation-child-test/effective-site.xml");
diff --git a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/stubs/SiteToolMavenProjectStub.java b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/stubs/SiteToolMavenProjectStub.java
index b426d4f..eecf089 100644
--- a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/stubs/SiteToolMavenProjectStub.java
+++ b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/stubs/SiteToolMavenProjectStub.java
@@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Properties;
+import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
@@ -33,6 +34,7 @@ import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Model;
import org.apache.maven.model.Site;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.eclipse.aether.repository.RemoteRepository;
/**
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
@@ -111,6 +113,11 @@ public class SiteToolMavenProjectStub extends MavenProjectStub {
return Collections.singletonList(repository);
}
+ /** {@inheritDoc} */
+ public List<RemoteRepository> getRemoteProjectRepositories() {
+ return RepositoryUtils.toRepos(getRemoteArtifactRepositories());
+ }
+
/** {@inheritDoc} */
public Properties getProperties() {
return properties;