Community
Participate
Working Groups
I finally dove in to write a small app to add or update the mirrorURL attribute of an artifacts repository, and it kind of works ... but throws an NPE near the end (when the value actually changes). Its from line 1004 of SimpleArtifactRepository. Apparently no 'agent' is ever set. //force repository manager to reload this repository because it caches properties ArtifactRepositoryManager manager = (ArtifactRepositoryManager) getProvisioningAgent().getService(IArtifactRepositoryManager.SERVICE_NAME); I started with the example at the bottom of http://wiki.eclipse.org/Equinox/p2/Publisher I'll attach a team project set to pull in the wtp releng project, but it is a very simple class ... the meaty part below, and it is after/during the "setProperty" that the NPE occurs in SimpleArtifactRepository. private IPublisherInfo createPublisherInfo() throws ProvisionException, URISyntaxException { PublisherInfo result = new PublisherInfo(); String repoURI = "file:/" + getRepositoryDirectory(); SimpleArtifactRepositoryFactory simpleArtifactRepositoryFactory = new SimpleArtifactRepositoryFactory(); // at least from workspace, NPE is thrown during "reload" if the // property is indeed changed (different from what it was) IArtifactRepository artifactRepository = simpleArtifactRepositoryFactory.load(new URI(repoURI), 0, null); if (artifactRepository != null) { artifactRepository.setProperty("p2.mirrorURL", getMirrorURLString()); result.setArtifactRepository(artifactRepository); result.setArtifactOptions(IPublisherInfo.A_OVERWRITE); } return result; }
Created attachment 166907 [details] team project set to pull example code from WTP cvs repository. There's several classes in that tools project, the one in question is AddMirrorURL. The key part of actually using/running it as an application is -application org.eclipse.wtp.releng.tools.addmirrorurl -Dp2.artifact.repo=D:/buildzips/M7/org.eclipse.releng.tools-3.6M7 -Dp2.mirrorURL=http://dddd Hope this helps.
Oh, and in case I wasn't clear, it actually does work. It updates the artifacts.jar at the URI I give it, and does not change anything else (a key part of this working :) I'm sure there's an easier way?
I "fixed" the NPE by setting an agent on the repository. I'd actually tried that before opening this bug, it didn't work, but got new inspiration from bug 305731, and then got it to work without NPE, by following examples/references giving there in that bug (so ... I probably did it wrong the first time). I'll leave this open a short time ... if my day goes well, I'll try and improve the documentation or example at http://wiki.eclipse.org/Equinox/p2/Publisher and then close.
I give up. I was going to update the example at http://wiki.eclipse.org/Equinox/p2/Publisher so it used an agent ... or I could at least point to some documents on getting/using an agent, but couldn't find any I could understand. Seems I'll have to sleep on http://wiki.eclipse.org/Equinox/p2/Multiple_Agents Feel free to close this as you'd like ... just trying to be helpful as always ... you know I'd never complain ... :) I got my agent as follows ... but, that's just following examples, and pretty sure there's other/better ways or complications I don't know about. public static IProvisioningAgent getProvisioningAgent() { IProvisioningAgent result = null; if (bundleContext == null) { throw new IllegalStateException("bundleContext was null. can not get provisioning agenet. Perhaps bundle was not started?"); } ServiceReference reference = bundleContext.getServiceReference(IProvisioningAgent.SERVICE_NAME); if (reference == null) { result = null; System.out.println("Could not get IProvisioningAgent service?"); } result = (IProvisioningAgent) bundleContext.getService(reference); return result; }
I have posted my slides from API talk on slideshare.net/PascalRapicault/discovering-the-p2-api At the end there is a complete example on how to get an agent and install something using the operations.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.
This bug was marked as stalebug a while ago. Marking as worksforme. If this report is still relevant for the current release, please reopen and remove the stalebug whiteboard tag.