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-7982] Switch to enable transitivity in depMgr used by Maven #1357

Merged
merged 9 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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 @@ -66,6 +66,7 @@
import org.eclipse.aether.repository.RepositoryPolicy;
import org.eclipse.aether.repository.WorkspaceReader;
import org.eclipse.aether.resolution.ResolutionErrorPolicy;
import org.eclipse.aether.util.graph.manager.ClassicDependencyManager;
import org.eclipse.aether.util.listener.ChainedRepositoryListener;
import org.eclipse.aether.util.repository.AuthenticationBuilder;
import org.eclipse.aether.util.repository.ChainedLocalRepositoryManager;
Expand Down Expand Up @@ -102,6 +103,19 @@ public class DefaultRepositorySystemSessionFactory {
*/
private static final String MAVEN_REPO_LOCAL_RECORD_REVERSE_TREE = "maven.repo.local.recordReverseTree";

/**
* User property for selecting dependency manager behaviour regarding transitive dependencies and dependency
* management entries in their POMs. Maven 3 targeted full backward compatibility with Maven2, hence it ignored
* dependency management entries in transitive dependency POMs. Maven 4 enables "transitivity" by default, hence
* unlike Maven2, obeys dependency management entries deep in dependency graph as well.
* <p>
* Default: {@code "true"}.
*
* @since 4.0.0
*/
private static final String MAVEN_RESOLVER_DEPENDENCY_MANAGER_TRANSITIVITY_KEY =
"maven.resolver.dependencyManagerTransitivity";

private static final String MAVEN_RESOLVER_TRANSPORT_KEY = "maven.resolver.transport";

private static final String MAVEN_RESOLVER_TRANSPORT_DEFAULT = "default";
Expand Down Expand Up @@ -393,6 +407,11 @@ public SessionBuilder newRepositorySessionBuilder(MavenExecutionRequest request)
injectProxy(proxySelector, request.getPluginArtifactRepositories());
injectAuthentication(authSelector, request.getPluginArtifactRepositories());

String resolverDependencyManagerTransitivity = (String)
configProps.getOrDefault(MAVEN_RESOLVER_DEPENDENCY_MANAGER_TRANSITIVITY_KEY, Boolean.TRUE.toString());
session.setDependencyManager(
new ClassicDependencyManager(Boolean.parseBoolean(resolverDependencyManagerTransitivity)));

ArrayList<File> paths = new ArrayList<>();
paths.add(new File(request.getLocalRepository().getBasedir()));
String localRepoTail = (String) configProps.get(MAVEN_REPO_LOCAL_TAIL);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ under the License.
<plexusInterpolationVersion>1.26</plexusInterpolationVersion>
<plexusTestingVersion>1.0.0</plexusTestingVersion>
<plexusXmlVersion>4.0.1</plexusXmlVersion>
<resolverVersion>2.0.0-alpha-5</resolverVersion>
<resolverVersion>2.0.0-alpha-6</resolverVersion>
cstamas marked this conversation as resolved.
Show resolved Hide resolved
<securityDispatcherVersion>2.0</securityDispatcherVersion>
<sisuVersion>0.9.0.M2</sisuVersion>
<slf4jVersion>2.0.11</slf4jVersion>
Expand Down