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
The following commit(s) were added to refs/heads/replace-old-resolution by this push: new 38bec82 Replace ArtifactRepository with RemoteRepository 38bec82 is described below commit 38bec82f71a8b1509ea18a4974048682e58a446e Author: Michael Osipov <micha...@apache.org> AuthorDate: Tue Mar 14 21:57:28 2023 +0100 Replace ArtifactRepository with RemoteRepository --- .../apache/maven/doxia/tools/DefaultSiteTool.java | 53 ++++++++++------------ .../org/apache/maven/doxia/tools/SiteTool.java | 9 ++-- .../org/apache/maven/doxia/tools/SiteToolTest.java | 12 ++--- .../tools/stubs/SiteToolMavenProjectStub.java | 7 +++ 4 files changed, 43 insertions(+), 38 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 4bf1808..8c1ba7f 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 @@ -74,6 +74,7 @@ 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; @@ -131,10 +132,10 @@ public class DefaultSiteTool implements SiteTool { /** {@inheritDoc} */ public Artifact getSkinArtifactFromRepository( - RepositorySystemSession repoSession, List<ArtifactRepository> remoteArtifactRepositories, Skin skin) + RepositorySystemSession repoSession, List<RemoteRepository> remoteProjectRepositories, Skin skin) throws SiteToolException { Objects.requireNonNull(repoSession, "repoSession cannot be null"); - Objects.requireNonNull(remoteArtifactRepositories, "remoteArtifactRepositories cannot be null"); + Objects.requireNonNull(remoteProjectRepositories, "remoteProjectRepositories cannot be null"); Objects.requireNonNull(skin, "skin cannot be null"); String version = skin.getVersion(); @@ -152,10 +153,8 @@ public class DefaultSiteTool implements SiteTool { type, null, artifactHandlerManager.getArtifactHandler(type)); - ArtifactRequest request = new ArtifactRequest( - RepositoryUtils.toArtifact(artifact), - RepositoryUtils.toRepos(remoteArtifactRepositories), - "remote-skin"); + ArtifactRequest request = + new ArtifactRequest(RepositoryUtils.toArtifact(artifact), remoteProjectRepositories, "remote-skin"); ArtifactResult result = repositorySystem.resolveArtifact(repoSession, request); // TODO Can "result.isMissing()" happen here? @@ -337,7 +336,7 @@ public class DefaultSiteTool implements SiteTool { * * @param project the Maven project, not null. * @param repoSession the repository system session, not null. - * @param remoteArtifactRepositories the Maven remote repositories, 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 @@ -347,16 +346,16 @@ public class DefaultSiteTool implements SiteTool { File getSiteDescriptorFromRepository( MavenProject project, RepositorySystemSession repoSession, - List<ArtifactRepository> remoteArtifactRepositories, + List<RemoteRepository> remoteProjectRepositories, Locale locale) throws SiteToolException { Objects.requireNonNull(project, "project cannot be null"); Objects.requireNonNull(repoSession, "repoSession cannot be null"); - Objects.requireNonNull(remoteArtifactRepositories, "remoteArtifactRepositories cannot be null"); + Objects.requireNonNull(remoteProjectRepositories, "remoteProjectRepositories cannot be null"); Objects.requireNonNull(locale, "locale cannot be null"); try { - return resolveSiteDescriptor(project, repoSession, remoteArtifactRepositories, locale); + return resolveSiteDescriptor(project, repoSession, remoteProjectRepositories, locale); } catch (ArtifactNotFoundException e) { LOGGER.debug("Unable to locate site descriptor", e); return null; @@ -373,18 +372,18 @@ public class DefaultSiteTool implements SiteTool { Locale locale, MavenProject project, RepositorySystemSession repoSession, - List<ArtifactRepository> remoteArtifactRepositories) + List<RemoteRepository> remoteProjectRepositories) throws SiteToolException { Objects.requireNonNull(locale, "locale cannot be null"); Objects.requireNonNull(project, "project cannot be null"); Objects.requireNonNull(repoSession, "repoSession cannot be null"); - Objects.requireNonNull(remoteArtifactRepositories, "remoteArtifactRepositories 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, repoSession, remoteArtifactRepositories); + getDecorationModel(0, siteDirectory, locale, project, repoSession, remoteProjectRepositories); DecorationModel decorationModel = result.getKey(); MavenProject parentProject = result.getValue(); @@ -757,11 +756,11 @@ public class DefaultSiteTool implements SiteTool { /** * @param project not null * @param localeStr could be null - * @param remoteArtifactRepositories not null + * @param remoteProjectRepositories not null * @return the site descriptor artifact request */ private ArtifactRequest createSiteDescriptorArtifactRequest( - MavenProject project, String localeStr, List<ArtifactRepository> remoteArtifactRepositories) { + MavenProject project, String localeStr, List<RemoteRepository> remoteProjectRepositories) { String type = "xml"; ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler(type); Artifact artifact = new DefaultArtifact( @@ -773,15 +772,13 @@ public class DefaultSiteTool implements SiteTool { (localeStr == null || localeStr.isEmpty()) ? "site" : "site_" + localeStr, artifactHandler); return new ArtifactRequest( - RepositoryUtils.toArtifact(artifact), - RepositoryUtils.toRepos(remoteArtifactRepositories), - "remote-site-descriptor"); + RepositoryUtils.toArtifact(artifact), remoteProjectRepositories, "remote-site-descriptor"); } /** * @param project not null * @param repoSession the repository system session not null - * @param remoteArtifactRepositories not null + * @param remoteProjectRepositories not null * @param locale not null * @return the resolved site descriptor * @throws IOException if any @@ -791,7 +788,7 @@ public class DefaultSiteTool implements SiteTool { private File resolveSiteDescriptor( MavenProject project, RepositorySystemSession repoSession, - List<ArtifactRepository> remoteArtifactRepositories, + List<RemoteRepository> remoteProjectRepositories, Locale locale) throws IOException, ArtifactResolutionException, ArtifactNotFoundException { String variant = locale.getVariant(); @@ -805,7 +802,7 @@ public class DefaultSiteTool implements SiteTool { if (!variant.isEmpty()) { localeStr = language + "_" + country + "_" + variant; ArtifactRequest request = - createSiteDescriptorArtifactRequest(project, localeStr, remoteArtifactRepositories); + createSiteDescriptorArtifactRequest(project, localeStr, remoteProjectRepositories); try { ArtifactResult result = repositorySystem.resolveArtifact(repoSession, request); @@ -826,7 +823,7 @@ public class DefaultSiteTool implements SiteTool { if (!found && !country.isEmpty()) { localeStr = language + "_" + country; ArtifactRequest request = - createSiteDescriptorArtifactRequest(project, localeStr, remoteArtifactRepositories); + createSiteDescriptorArtifactRequest(project, localeStr, remoteProjectRepositories); try { ArtifactResult result = repositorySystem.resolveArtifact(repoSession, request); @@ -847,7 +844,7 @@ public class DefaultSiteTool implements SiteTool { if (!found && !language.isEmpty()) { localeStr = language; ArtifactRequest request = - createSiteDescriptorArtifactRequest(project, localeStr, remoteArtifactRepositories); + createSiteDescriptorArtifactRequest(project, localeStr, remoteProjectRepositories); try { ArtifactResult result = repositorySystem.resolveArtifact(repoSession, request); @@ -868,7 +865,7 @@ public class DefaultSiteTool implements SiteTool { if (!found) { localeStr = ""; ArtifactRequest request = - createSiteDescriptorArtifactRequest(project, localeStr, remoteArtifactRepositories); + createSiteDescriptorArtifactRequest(project, localeStr, remoteProjectRepositories); try { ArtifactResult result = repositorySystem.resolveArtifact(repoSession, request); @@ -893,7 +890,7 @@ public class DefaultSiteTool implements SiteTool { * @param locale not null * @param project not null * @param repoSession not null - * @param remoteArtifactRepositories not null + * @param remoteProjectRepositories not null * @return the decoration model depending the locale and the parent project * @throws SiteToolException if any */ @@ -903,7 +900,7 @@ public class DefaultSiteTool implements SiteTool { Locale locale, MavenProject project, RepositorySystemSession repoSession, - List<ArtifactRepository> remoteArtifactRepositories) + List<RemoteRepository> remoteProjectRepositories) throws SiteToolException { // 1. get site descriptor File File siteDescriptor; @@ -911,7 +908,7 @@ public class DefaultSiteTool implements SiteTool { // POM is in the repository: look into the repository for site descriptor try { siteDescriptor = - getSiteDescriptorFromRepository(project, repoSession, remoteArtifactRepositories, locale); + getSiteDescriptorFromRepository(project, repoSession, remoteProjectRepositories, locale); } catch (SiteToolException e) { throw new SiteToolException("The site descriptor cannot be resolved from the repository", e); } @@ -968,7 +965,7 @@ public class DefaultSiteTool implements SiteTool { } DecorationModel parentDecorationModel = getDecorationModel( - depth, parentSiteDirectory, locale, parentProject, repoSession, remoteArtifactRepositories) + 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 632e8c1..65b7af9 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 @@ -30,6 +30,7 @@ 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 @@ -49,13 +50,13 @@ public interface SiteTool { * Get a skin artifact from one of the repositories. * * @param repoSession the repository system session, not null. - * @param remoteArtifactRepositories the Maven remote repositories, 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( - RepositorySystemSession repoSession, List<ArtifactRepository> remoteArtifactRepositories, Skin skin) + RepositorySystemSession repoSession, List<RemoteRepository> remoteProjectRepositories, Skin skin) throws SiteToolException; /** @@ -114,7 +115,7 @@ public interface SiteTool { * See {@link #getSiteDescriptor(File, Locale)} for details. * @param project the Maven project, not null. * @param repoSession the repository system session, not null. - * @param remoteArtifactRepositories the Maven remote repositories, 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 @@ -125,7 +126,7 @@ public interface SiteTool { Locale locale, MavenProject project, RepositorySystemSession repoSession, - List<ArtifactRepository> remoteArtifactRepositories) + 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 22c50ff..d89732f 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 @@ -126,7 +126,7 @@ public class SiteToolTest { skin.setGroupId("org.apache.maven.skins"); skin.setArtifactId("maven-stylus-skin"); assertNotNull( - tool.getSkinArtifactFromRepository(newRepoSession(), project.getRemoteArtifactRepositories(), skin)); + tool.getSkinArtifactFromRepository(newRepoSession(), project.getRemoteProjectRepositories(), skin)); } private void checkGetRelativePathDirectory(SiteTool tool, String relative, String to, String from) { @@ -338,7 +338,7 @@ public class SiteToolTest { tool.getSiteDescriptorFromRepository( project, newRepoSession(), - project.getRemoteArtifactRepositories(), + project.getRemoteProjectRepositories(), SiteTool.DEFAULT_LOCALE) .toString(), result); @@ -359,7 +359,7 @@ public class SiteToolTest { SiteTool.DEFAULT_LOCALE, project, newRepoSession(), - project.getRemoteArtifactRepositories()); + project.getRemoteProjectRepositories()); assertNotNull(model); assertNotNull(model.getBannerLeft()); assertEquals("Maven Site", model.getBannerLeft().getName()); @@ -380,7 +380,7 @@ public class SiteToolTest { project.setArtifactId("maven"); project.setVersion("3.8.6"); DecorationModel modelFromRepo = tool.getDecorationModel( - null, SiteTool.DEFAULT_LOCALE, project, newRepoSession(), project.getRemoteArtifactRepositories()); + null, SiteTool.DEFAULT_LOCALE, project, newRepoSession(), project.getRemoteProjectRepositories()); assertNotNull(modelFromRepo); assertNotNull(modelFromRepo.getBannerLeft()); assertEquals("dummy", modelFromRepo.getBannerLeft().getName()); @@ -406,7 +406,7 @@ public class SiteToolTest { SiteTool.DEFAULT_LOCALE, project, newRepoSession(), - project.getRemoteArtifactRepositories()); + project.getRemoteProjectRepositories()); assertNotNull(model); } @@ -465,7 +465,7 @@ public class SiteToolTest { SiteTool.DEFAULT_LOCALE, childProject, newRepoSession(), - childProject.getRemoteArtifactRepositories()); + 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.sive...@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;