Skip to content

[EXPERIMENT] Proper remote repository scoping during dependency resolution #87

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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 @@ -55,6 +55,12 @@ List<RemoteRepository> aggregateRepositories( RepositorySystemSession session,
List<RemoteRepository> recessiveRepositories,
boolean recessiveIsRaw );

List<RemoteRepository> aggregateRepositories( RepositorySystemSession session,
List<RemoteRepository> dominantRepositories,
List<RemoteRepository> recessiveRepositories,
boolean recessiveIsRaw,
boolean prepend );

/**
* Gets the effective repository policy for the specified remote repository by merging the applicable
* snapshot/release policy of the repository with global settings from the supplied session.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ public List<RemoteRepository> aggregateRepositories( RepositorySystemSession ses
List<RemoteRepository> dominantRepositories,
List<RemoteRepository> recessiveRepositories,
boolean recessiveIsRaw )
{
return aggregateRepositories( session, dominantRepositories, recessiveRepositories, recessiveIsRaw, false );
}

public List<RemoteRepository> aggregateRepositories( RepositorySystemSession session,
List<RemoteRepository> dominantRepositories,
List<RemoteRepository> recessiveRepositories,
boolean recessiveIsRaw,
boolean prepend )
{
if ( recessiveRepositories.isEmpty() )
{
Expand Down Expand Up @@ -201,7 +210,14 @@ public List<RemoteRepository> aggregateRepositories( RepositorySystemSession ses
}
}

result.add( repository );
if ( prepend )
{
result.add( 0, repository );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't that reverse prepend?

Copy link
Member Author

@cstamas cstamas Jan 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Project model build invokes this method with "false", so all as before: the list of repositories are in same exact order as before. If your project defines prj-repo1, prj-repo2, prj-repo3 the result will be [prj-repo1, prj-repo2, prj-repo3] (let's neglect central from super pom for now, but it is last).

Now, if we call level0 the project model, and level1 the 1st sibling dependency of level0, and level2 the first sibling of level1, then: as ModelResolver is recursively being cloned/copied, and modified (by adding reposes of downloaded and parsed POMs), AND if we assume each level is adding new repo (as in my example), you will end up with these lists in different instances of ModelResolver on each level:
level1: [level1-repo, prj-repo1, prj-repo2, prj-repo3]
level2: [level2-repo, level1-repo, prj-repo1, prj-repo2, prj-repo3]
and so on.

In short, as you "dive in" recursively into resolving dependencies, you want "nearest" repo to prevail, and those are prepended to list...

Maybe the name is not clear, but that's above is the idea.

}
else
{
result.add( repository );
}
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ private void doRecurse( Args args, Results results, List<RemoteRepository> repos
args.ignoreRepos
? repositories
: remoteRepositoryManager.aggregateRepositories( args.session, repositories,
descriptorResult.getRepositories(), true );
descriptorResult.getRepositories(), true, true );

Object key =
args.pool.toKey( d.getArtifact(), childRepos, childSelector, childManager, childTraverser, childFilter );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ public List<RemoteRepository> aggregateRepositories( RepositorySystemSession ses
return dominantRepositories;
}

public List<RemoteRepository> aggregateRepositories( RepositorySystemSession session,
List<RemoteRepository> dominantRepositories,
List<RemoteRepository> recessiveRepositories,
boolean recessiveIsRaw,
boolean prepend )
{
return dominantRepositories;
}

public RepositoryPolicy getPolicy( RepositorySystemSession session, RemoteRepository repository, boolean releases,
boolean snapshots )
{
Expand Down