public Artifact getSkinArtifactFromRepository()

in doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java [142:178]


    public Artifact getSkinArtifactFromRepository(
            RepositorySystemSession repoSession, List<RemoteRepository> remoteProjectRepositories, Skin skin)
            throws SiteToolException {
        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();
        try {
            if (version == null) {
                version = Artifact.RELEASE_VERSION;
            }
            VersionRange versionSpec = VersionRange.createFromVersionSpec(version);
            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);
        }
    }