2. I’m using the “-roots” parameter as an argument, in order to call the dependency resolution mechanism in the mirror application and to download only the root and all its dependencies.
The metadata mirroring works perfectly. However, in the artifact mirror case I found an issue:
The ”-roots” parameter does not work and always downloads the whole artifact repository.
I debugged the case and the problem is that in theorg.eclipse.equinox.p2.internal.repository.tools.MirrorApplication.initializeIUs() method, the queryResult variable does not get populated with correct result. It should return, in the example case, installable unit “FirstPlugin” with the version it found in the metadata repository.
The root cause:
And the root cause is that the metadata repository is not initialized.
The source repository (the one we want to mirror from) is not added as a child to the compositeMetadataRepository, because of a check.
The check is:
If medatada application: the source repository is added only to the compositeMetadataRepository
If artifact application: the source repository is added only to the compositeArtifactRepository
This is done in the getCompositeMetadataRepository() method of theorg.eclipse.equinox.p2.internal.repository.tool.AbstractApplication class.
Actually, the metadata repository has to be added in both cases, because the metadata is needed for the dependency resolution.
When I changed the check in the artifact case, everything worked perfectly and only the needed plugins were mirrored.