Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-8172] Fix site building #1594

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package org.apache.maven.internal.impl.resolver;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
Expand All @@ -33,6 +36,7 @@
import org.apache.maven.api.services.ModelResolver;
import org.apache.maven.api.services.ModelResolverException;
import org.apache.maven.api.services.ModelSource;
import org.apache.maven.api.services.Source;
import org.apache.maven.api.services.VersionRangeResolverException;

/**
Expand Down Expand Up @@ -74,7 +78,34 @@ public ModelSource resolveModel(

Map.Entry<org.apache.maven.api.Artifact, Path> resolved =
session.resolveArtifact(session.createArtifactCoordinate(groupId, artifactId, newVersion, "pom"));
return ModelSource.fromPath(resolved.getValue(), groupId + ":" + artifactId + ":" + newVersion);
Path path = resolved.getValue();
String location = groupId + ":" + artifactId + ":" + newVersion;
return new ModelSource() {
@Override
public ModelSource resolve(ModelLocator modelLocator, String relative) {
return null;
}

@Override
public Path getPath() {
return null;
}

@Override
public InputStream openStream() throws IOException {
return Files.newInputStream(path);
}

@Override
public String getLocation() {
return location;
}

@Override
public Source resolve(String relative) {
return null;
}
};
} catch (VersionRangeResolverException | ArtifactResolverException e) {
throw new ModelResolverException(
e.getMessage() + " (remote repositories: "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
import org.apache.maven.internal.impl.InternalSession;
import org.apache.maven.internal.impl.resolver.DefaultModelCache;
import org.apache.maven.internal.impl.resolver.DefaultModelRepositoryHolder;
import org.apache.maven.model.building.ArtifactModelSource;
import org.apache.maven.model.building.DefaultModelProblem;
import org.apache.maven.model.building.FileModelSource;
import org.apache.maven.model.building.ModelSource2;
Expand Down Expand Up @@ -150,8 +149,6 @@ public ProjectBuildingResult build(
static ModelSource toSource(org.apache.maven.model.building.ModelSource modelSource) {
if (modelSource instanceof FileModelSource fms) {
return ModelSource.fromPath(fms.getPath());
} else if (modelSource instanceof ArtifactModelSource ams) {
return ModelSource.fromPath(ams.getPath(), ams.toString());
} else {
return new ModelSource() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.apache.maven.api.model.Model;
import org.apache.maven.api.spi.ModelParser;
import org.apache.maven.api.spi.ModelParserException;
import org.apache.maven.building.Source;
import org.apache.maven.model.io.ModelParseException;
import org.apache.maven.model.io.ModelReader;
import org.apache.maven.model.locator.ModelLocator;
Expand Down Expand Up @@ -133,10 +132,6 @@ public Path locateExistingPom(Path projectDirectory) {

protected org.apache.maven.api.model.Model read(
Path pomFile, InputStream input, Reader reader, Map<String, ?> options) throws IOException {
Source source = (Source) options.get(ModelProcessor.SOURCE);
if (pomFile == null && source instanceof org.apache.maven.building.FileSource) {
pomFile = ((org.apache.maven.building.FileSource) source).getPath();
}
if (pomFile != null) {
Path projectDirectory = pomFile.getParent();
List<ModelParserException> exceptions = new ArrayList<>();
Expand Down