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

Project#getBundle only take into account the repositories of the workspace #6481

Open
laeubi opened this issue Feb 20, 2025 · 7 comments · May be fixed by #6488
Open

Project#getBundle only take into account the repositories of the workspace #6481

laeubi opened this issue Feb 20, 2025 · 7 comments · May be fixed by #6488

Comments

@laeubi
Copy link
Contributor

laeubi commented Feb 20, 2025

Project#getBundle only uses the repositories from the workspace here:

List<RepositoryPlugin> plugins = workspace.getRepositories();

because of this if one adds a plugin to the project (or in my case to the bndrun) to only have it locally bnd can not find things when looking for it. resolve then works but calling getRunbundles() do fail...

It would be good if similar to what the Bndrun does it also will query the project plugins.

@chrisrueger
Copy link
Contributor

chrisrueger commented Feb 22, 2025

It would be good if similar to what the Bndrun does it also will query the project plugins.

@laeubi
I was just having a look trying to understand.
Could you link code showing what you are referring to.
I have some difficulty understanding what you expect to happen where.

@laeubi
Copy link
Contributor Author

laeubi commented Feb 23, 2025

You can take a look here:

https://github.com/eclipse-pde/eclipse.pde/blob/0c33ce1fa334d584cdd3bb3cf2d11b7fc0fe8c0a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/PdeBndrun.java#L51-L110

this implementation is (with some simplifications that do not apply for this case) the same as the one in project I linked here with the difference being that I use

List<RepositoryPlugin> plugins = getPlugins(RepositoryPlugin.class);

in contrast to

List<RepositoryPlugin> plugins = workspace.getRepositories();

thats way Lets say we have

Bndrun run = ...
run.addBasicPluging(new MyRepositoryPlugin())

then MyRepositoryPlugin is only valid for this particular run (and not workspace wide).

@chrisrueger
Copy link
Contributor

Lets say we have

Bndrun run = ...
run.addBasicPluging(new MyRepositoryPlugin())

then MyRepositoryPlugin is only valid for this particular run (and not workspace wide).

Ah thanks this makes it more clear. Sorry my brain works with examples like "I want to do this, I expect to happen that, but it happens X, it would be good if Y happens".

So let's see to find out I understand correctly:

You basically want that aQute.bnd.build.Project.getBundle(String, String, Strategy, Map<String, String>)
uses a different List<RepositoryPlugin> plugins than it currently does.
Correct?

So we should find a backwards compatible way to provide a List<RepositoryPlugin> plugins to this getBundle() method.

What about:

Add a protected method protected List<RepositoryPlugin> getRepositories() to Project which does what it is currently doing.

protected List<RepositoryPlugin> getRepositories() {
    return workspace.getRepositories();
}

in BndRun we override it and to this instead:

@Override
protected List<RepositoryPlugin> getRepositories() {
	return getPlugins(RepositoryPlugin.class);
}

Side-effects:

  • there are currently 3 places in Project calling workspace.getRepositories(). They all could be redirected to this new getRepositories() method. Not sure this would be an advantage or disadvantage

Maybe this is non-sense. But just a base for discussion.

@chrisrueger chrisrueger linked a pull request Feb 23, 2025 that will close this issue
@laeubi
Copy link
Contributor Author

laeubi commented Feb 23, 2025

A protected method would be of course good as it allows even more advanced use cases... even better, simply all repositories of workspace and project are used (while I have the impression that project is just a superset of what one gets from the workspace).

@pkriens
Copy link
Member

pkriens commented Feb 24, 2025

I am unhappy to make this automatic. If we consult repositories in the project it must be activated via an explicit instruction so it will be 100% backward compatible. This was also the approach in bndrun with -standalone. And I recall this was a major headache.

@laeubi
Copy link
Contributor Author

laeubi commented Feb 25, 2025

I would be fine with a method

protected List<RepositoryPlugin> getRepositories() {
    return workspace.getRepositories();
}

then I can at least override this more easily and generally useful.

Beside from that having it overridden in BndRun with:

protected List<RepositoryPlugin> getRepositories() {
    if ("-includeProjectRepositories") {
      return workspace.getRepositories() + getPlugins(RepositoryPlugin.class);
    }
    return workspace.getRepositories();
}

because as mentioned before, the resolve already works that way, it is just that *after resolve the runbundle is not found because it behaves differently.

@chrisrueger
Copy link
Contributor

@laeubi @pkriens I have removed the overridden method in BndRun.
https://github.com/bndtools/bnd/pull/6488/files

So now there is only the protected method in Project.

Beside from that having it overridden in BndRun with:

protected List<RepositoryPlugin> getRepositories() {
    if ("-includeProjectRepositories") {
      return workspace.getRepositories() + getPlugins(RepositoryPlugin.class);
    }
    return workspace.getRepositories();
}

because as mentioned before, the resolve already works that way, it is just that *after resolve the runbundle is not found because it behaves differently.

So -includeProjectRepositories would be a new instruction?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants