The following function worked perfectly in Eclipse Neon 4.6.x target runtime for a very long time:
public static boolean addRepository(IProvisioningAgent agent, String repo) {
Utils.log(String.format("adding repository at %s", repo));
IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
if (metadataManager == null || artifactManager == null) {
Utils.log("P2Utils.addRepository - missing metadata or artifact manager");
return false;
}
try {
URI uri = new URI(repo);
metadataManager.addRepository(uri);
artifactManager.addRepository(uri);
return true;
} catch (Exception e) {
Utils.log(e);
return false;
}
}
It stopped working with Eclipse Oxygen 4.7.2 target, the artifactManager returned is always null. Does anyone involved knows what was changed and how to fix this? It breaks our updates.., I am at a loss where to look.
Got the response from eclipse forum, there were some plugins missing:
org.eclipse.equinox.p2.artifact.repository
org.eclipse.equinox.p2.transport.ecf