This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch DOXIASITETOOLS-303 in repository https://gitbox.apache.org/repos/asf/maven-doxia-sitetools.git
commit ce0c7c53bdc0d5d6a707d366d1328a628763a4ff Author: Michael Osipov <[email protected]> AuthorDate: Sun Apr 9 21:58:58 2023 +0200 [DOXIASITETOOLS-303] Implement workaround for MNG-7758/MRESOLVER-335 This closes #103 --- .../apache/maven/doxia/tools/DefaultSiteTool.java | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 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 bd63cd0..7733f3b 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 @@ -354,10 +354,13 @@ public class DefaultSiteTool implements SiteTool { Objects.requireNonNull(locale, "locale cannot be null"); try { - return resolveSiteDescriptor(project, repoSession, remoteProjectRepositories, locale); - } catch (ArtifactNotFoundException e) { - LOGGER.debug("Unable to locate site descriptor", e); - return null; + File siteDescriptor = resolveSiteDescriptor(project, repoSession, remoteProjectRepositories, locale); + if (siteDescriptor == null) { + LOGGER.debug("Site descriptor not found"); + return null; + } else { + return siteDescriptor; + } } catch (ArtifactResolutionException e) { throw new SiteToolException("Unable to locate site descriptor", e); } catch (IOException e) { @@ -811,17 +814,16 @@ public class DefaultSiteTool implements SiteTool { * @param repoSession the repository system session not null * @param remoteProjectRepositories not null * @param locale not null - * @return the resolved site descriptor + * @return the resolved site descriptor or null if not found in repositories. * @throws IOException if any * @throws ArtifactResolutionException if any - * @throws ArtifactNotFoundException if any */ private File resolveSiteDescriptor( MavenProject project, RepositorySystemSession repoSession, List<RemoteRepository> remoteProjectRepositories, Locale locale) - throws IOException, ArtifactResolutionException, ArtifactNotFoundException { + throws IOException, ArtifactResolutionException { String variant = locale.getVariant(); String country = locale.getCountry(); String language = locale.getLanguage(); @@ -841,7 +843,8 @@ public class DefaultSiteTool implements SiteTool { siteDescriptor = result.getArtifact().getFile(); found = true; } catch (ArtifactResolutionException e) { - if (e.getCause() instanceof ArtifactNotFoundException) { + // This is a workaround for MNG-7758/MRESOLVER-335 + if (e.getResult().getExceptions().stream().anyMatch(re -> re instanceof ArtifactNotFoundException)) { LOGGER.debug("No site descriptor found for '" + project.getId() + "' for locale '" + localeStr + "', trying without variant..."); } else { @@ -861,7 +864,8 @@ public class DefaultSiteTool implements SiteTool { siteDescriptor = result.getArtifact().getFile(); found = true; } catch (ArtifactResolutionException e) { - if (e.getCause() instanceof ArtifactNotFoundException) { + // This is a workaround for MNG-7758/MRESOLVER-335 + if (e.getResult().getExceptions().stream().anyMatch(re -> re instanceof ArtifactNotFoundException)) { LOGGER.debug("No site descriptor found for '" + project.getId() + "' for locale '" + localeStr + "', trying without country..."); } else { @@ -881,7 +885,8 @@ public class DefaultSiteTool implements SiteTool { siteDescriptor = result.getArtifact().getFile(); found = true; } catch (ArtifactResolutionException e) { - if (e.getCause() instanceof ArtifactNotFoundException) { + // This is a workaround for MNG-7758/MRESOLVER-335 + if (e.getResult().getExceptions().stream().anyMatch(re -> re instanceof ArtifactNotFoundException)) { LOGGER.debug("No site descriptor found for '" + project.getId() + "' for locale '" + localeStr + "', trying without language (default locale)..."); } else { @@ -899,9 +904,10 @@ public class DefaultSiteTool implements SiteTool { siteDescriptor = result.getArtifact().getFile(); } catch (ArtifactResolutionException e) { - if (e.getCause() instanceof ArtifactNotFoundException) { + // This is a workaround for MNG-7758/MRESOLVER-335 + if (e.getResult().getExceptions().stream().anyMatch(re -> re instanceof ArtifactNotFoundException)) { LOGGER.debug("No site descriptor found for '" + project.getId() + "' with default locale."); - throw (ArtifactNotFoundException) e.getCause(); + return null; } throw e;
