-
-
Notifications
You must be signed in to change notification settings - Fork 301
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
BndPomRepository should support both bsn and gav like MavenBndRepository #5964
BndPomRepository should support both bsn and gav like MavenBndRepository #5964
Conversation
this PomRepositoryTest. testGetViaBSNAndGAV() will fail, which we try to fix in the next commit. Signed-off-by: Christoph Rueger <[email protected]>
1st draft, base for discussion. I hooked into the indexing of BridgeRepository because commons-cli:commons-cli:1.2 (commons-cli-1.2.jar) is indexed as commons-cli:commons-cli:1.2.0 by bridge repo (notice 1.2 vs. 1.2.0). To satisfy the existing testcase of MavenBndRepo this was the only place where I could get the version as 3 digit semver. To be discussed if it really should be that way Signed-off-by: Christoph Rueger <[email protected]>
Signed-off-by: Christoph Rueger <[email protected]>
Signed-off-by: Christoph Rueger <[email protected]>
1st draft, base for discussion.
I hooked into the indexing of |
I think you're making it too hard but I might be wrong. A non-OSGi artifact has nothing to do with the BridgeRepository. They lack any OSGi metadata. Trying to support them as a first class citizen there feels uncomfortable because they wreak havoc on many different places, the bsn is a pretty big invariant of OSGi. This is a hack only the Maven repositories need, it shouldn't touch code unrelated. That said, to be able to wrap them, and sometimes use in unit tests, we need a way to address them. However, we should keep in mind that they are not the common way to address bundles. This only needs to be supported in the RepositoryPlugin::get method. It is rather easy to check the bsn for a ':' and if it has, you can directly construct the GA, get the versions, and compare the versions to find the best matching. The BndPomRepository already has a list of archives from the POM. Something like this: @Override
public File get(String bsn, Version version, Map<String, String> properties, DownloadListener... listeners)
throws Exception {
if (!init()) {
return null;
}
Archive archive;
if (isMavenGAV(bsn)) {
Archive spec = Archive.valueOf(bsn + ":" + version);
archive = archives.stream()
.filter(a -> matches(a, spec))
.findAny()
.orElse(null);
if (archive == null)
return null;
} else {
ResourceInfo resource = bridge.getInfo(bsn, version);
if (resource == null) {
archive = trySources(bsn, version);
if (archive == null)
return null;
} else {
String from = resource.getInfo()
.from();
archive = Archive.valueOf(from);
}
}
Promise<File> p = repoImpl.getMavenRepository()
.get(archive);
if (listeners.length == 0)
return p.getValue();
Map<String, String> attrs = archive.attributes();
new DownloadListenerPromise(reporter, name + ": get " + bsn + ";" + version, p, attrs, listeners);
return repoImpl.getMavenRepository()
.toLocalFile(archive);
} Notice that the IndexFile in the MavenBndRepository is basically collapsed into the BndPomRepository. The |
Thanks @pkriens for the review.
I think I had something similar in between. I saw the Thanks a lot. I post an update. |
This reverts commit 3e82952. Revert "pass test for GAV" This reverts commit dabeb36. Signed-off-by: Christoph Rueger <[email protected]>
* based on Peter's suggestion. Since BndPomRepository.archives and PomRepository.archives were both null when using a pom.xml (instead of revisions) I populated them in PomRepository.save(). If there is another / better way, we can change that Signed-off-by: Christoph Rueger <[email protected]>
Signed-off-by: Christoph Rueger <[email protected]>
Signed-off-by: Christoph Rueger <[email protected]>
@pkriens I have changed it to something similar to your suggestion. so I can do The |
After testing the initial problem it turned out the ${repo;gav;latest} also runs through repo.versions(gav) so we have to support it too Signed-off-by: Christoph Rueger <[email protected]>
fixes the testcase from previous commit and solves the initial reported issue with (${repo;gav;latest} not working with BndPomRepo) Signed-off-by: Christoph Rueger <[email protected]>
Yeah, much better. It is now restricted to the BndPomRepository and does not pollute the generic code. Thanks! |
pressed the wrong button ... sorry |
Well, officially you cannot have 2 versions in maven so from a pom pov it is problematic. From a BndPomRepository pov it is obviously wrong ... We should be able to support multiple versions. I think this is the culprit:
It explicitly removes multiple versions. I'd expect it would only show the first so it could be something else |
Thanks @pkriens I will create an issue out of it and try digging in during the next days. |
Closes #5961
This PR should fix the problem that for a valid OSGi bundle MavenBndRepository.get(bsnOrGav) can be used with bsn or gav and returns something.
BndPomRepostory.get() instead only works with the bsn for a valid OSGi bundle. (Non OSGi bundles which do not have a bsn meta data can only be looked up by gav wich works as expected)
This PR's goal is to make both repos behave the same and support bsn or gav for OSGi bundles.