Skip to content
Open
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
2 changes: 1 addition & 1 deletion apache-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-http</artifactId>
<artifactId>maven-resolver-transport-apache</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.maven.artifact.repository.metadata;

import java.io.File;
import java.nio.file.Path;
import java.util.Collections;
import java.util.Map;

Expand Down Expand Up @@ -92,6 +93,14 @@ public MetadataBridge setFile(File file) {
return this;
}

public Path getPath() {
return null;
}

public MetadataBridge setPath(Path file) {
return this;
}

public Nature getNature() {
if (metadata instanceof RepositoryMetadata) {
switch (((RepositoryMetadata) metadata).getNature()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public List<ArtifactResult> resolveArtifacts(
throw new IllegalStateException("Missing test POM for " + artifact, e);
}
} else {
result.addException(new ArtifactNotFoundException(artifact, null));
result.addException(new ArtifactNotFoundException(artifact, "not found"));
throw new ArtifactResolutionException(results);
}
}
Expand Down
13 changes: 7 additions & 6 deletions maven-core/src/main/java/org/apache/maven/DefaultMaven.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,16 @@ private MavenExecutionResult doExecute(MavenExecutionRequest request) {
// so that @SessionScoped components can be @Injected into AbstractLifecycleParticipants.
//
sessionScope.enter();
try {
DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) newRepositorySession(request);
MavenSession session = new MavenSession(container, repoSession, request, result);
try (RepositorySystemSession.CloseableSession repoSession = newRepositorySession(request)) {
DefaultRepositorySystemSession mutableSession = new DefaultRepositorySystemSession(repoSession);
MavenSession session = new MavenSession(container, mutableSession, request, result);

sessionScope.seed(RepositorySystemSession.class, mutableSession);
sessionScope.seed(MavenSession.class, session);

legacySupport.setSession(session);

return doExecute(request, session, result, repoSession);
return doExecute(request, session, result, mutableSession);
} finally {
sessionScope.exit();
}
Expand Down Expand Up @@ -308,8 +309,8 @@ private void afterSessionEnd(Collection<MavenProject> projects, MavenSession ses
}
}

public RepositorySystemSession newRepositorySession(MavenExecutionRequest request) {
return repositorySessionFactory.newRepositorySession(request);
public RepositorySystemSession.CloseableSession newRepositorySession(MavenExecutionRequest request) {
return repositorySessionFactory.newRepositorySession(request).build();
}

private void validateLocalRepository(MavenExecutionRequest request) throws LocalRepositoryNotAccessibleException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataStoreException;
import org.apache.maven.internal.aether.DefaultRepositorySystemSessionFactory;
import org.apache.maven.repository.Proxy;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystem;
Expand Down Expand Up @@ -64,18 +65,21 @@ public static RepositorySystemSession overlay(
return session;
}

if (session != null) {
LocalRepositoryManager lrm = session.getLocalRepositoryManager();
if (lrm != null && lrm.getRepository().getBasedir().equals(new File(repository.getBasedir()))) {
return session;
}
LocalRepositoryManager lrm = session.getLocalRepositoryManager();
if (lrm != null
&& lrm.getRepository()
.getBasePath()
.equals(DefaultRepositorySystemSessionFactory.resolve(repository.getBasedir()))) {
return session;
}
if (repository.getLayout() instanceof DefaultRepositoryLayout) {
return new DefaultRepositorySystemSession(session)
.setLocalRepositoryManager(DefaultRepositorySystemSessionFactory.setUpLocalRepositoryManager(
repository.getBasedir(), system, session));
} else {
session = new DefaultRepositorySystemSession();
return new DefaultRepositorySystemSession(session)
.setLocalRepositoryManager(new LegacyLocalRepositoryManager(repository));
}

final LocalRepositoryManager llrm = new LegacyLocalRepositoryManager(repository);

return new DefaultRepositorySystemSession(session).setLocalRepositoryManager(llrm);
}

private LegacyLocalRepositoryManager(ArtifactRepository delegate) {
Expand Down
Loading