Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Creating an installer job in p2(This is pertaining to small issues being faced in creating an installer job using p2 framwork)
Creating an installer job in p2 [message #692606] Mon, 04 July 2011 16:36 Go to next message
Rajendra Kolli is currently offline Rajendra Kolli
Messages: 9
Registered: July 2011
Junior Member
Hi all,

I am new to Eclipse development and facing some problems in writing my plug-ins. I need to create an installer job which installs specific IUs like languages into an IDE. I am using the following source code obtained on eclipse documentation

Job job = null;
// get the agent
ServiceReference sr = Activator.context
.getServiceReference(IProvisioningAgentProvider.SERVICE_NAME);
IProvisioningAgentProvider agentProvider = null;
if (sr == null)

return agentProvider;

agentProvider = (IProvisioningAgentProvider) Activator.context
.getService(sr);
try {
agent = agentProvider.createAgent(new URI(
"file:/Applications/eclipse36/p2"));
} catch (ProvisionException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
} catch (URISyntaxException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
// get the repository managers and define our repositories
IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent
.getService(IMetadataRepositoryManager.SERVICE_NAME);
IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent
.getService(IArtifactRepositoryManager.SERVICE_NAME);
try {
manager.addRepository(new URI("file:/Users/Pascal/tmp/demo/"));
} catch (URISyntaxException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
artifactManager.addRepository(new URI(
"file:/Users/Pascal/tmp/demo/"));
} catch (URISyntaxException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

// Load and query the metadata
IMetadataRepository metadataRepo = null;
try {
metadataRepo = manager.loadRepository(new URI(
"file:/Users/Pascal/tmp/demo/"), new NullProgressMonitor());
} catch (ProvisionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (OperationCanceledException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Collection toInstall = metadataRepo
.query(QueryUtil
.createIUQuery("org.eclipse.equinox.p2.demo.feature.group"),
new NullProgressMonitor()).toUnmodifiableSet();

// Creating an operation
InstallOperation installOperation = new InstallOperation(
new ProvisioningSession(agent), toInstall);
if (installOperation.resolveModal(new NullProgressMonitor()).isOK()) {
job = installOperation
.getProvisioningJob(new NullProgressMonitor());
job.addJobChangeListener(new JobChangeAdapter() {
public void done(IJobChangeEvent event) {
agent.stop();
}
});

}
job.schedule();
return null;
}

The paths are defined here. If I want to export this into an application and make others use it. How should this be done?? Is there any method in which we can know the above defined paths??

Thanks,
Rajendra Kolli
Re: Creating an installer job in p2 [message #692608 is a reply to message #692606] Mon, 04 July 2011 16:44 Go to previous messageGo to next message
Anthony Dahanne is currently offline Anthony Dahanne
Messages: 9
Registered: March 2010
Location: Montreal
Junior Member
Hello Rajendra,



  1. I've noticed you're using the IProvisioningAgentProvider to then create an agent...
    Why don't you directly consume the IProvisioningAgent, which is registered as an osgi service as org.eclipse.equinox.p2.core.IProvisioningAgent (you could use a service tracker or DS component.xml) ?
    It would give you access to the default agent, then you would not have to specify a path where to save your p2 runtime artifacts...
  2. the repo URI, file:/Users/Pascal/tmp/demo/, I think you should find a way to specify it through an argument (vm or system) or provide a user interface to deal with it


Hope that helps, if not, try the p2 dev mailing list : p2-dev@eclipse.org



Re: Creating an installer job in p2 [message #692752 is a reply to message #692608] Tue, 05 July 2011 03:17 Go to previous messageGo to next message
Rajendra Kolli is currently offline Rajendra Kolli
Messages: 9
Registered: July 2011
Junior Member
Hello Anthony,

Thanks for such a prompt reply. I was able to solve for the second point you have mentioned. I provided an UI which deals with a list of repos. The users selects one and the procedure is continued.

But the first point you have made, I couldnot get that. I have contacted the Eclipse Documentation, but I could only find that IProvisioningAgentProvider is the only way to create instances of agent. Please help me out in this.



Re: Creating an installer job in p2 [message #692766 is a reply to message #692752] Tue, 05 July 2011 03:45 Go to previous message
Rajendra Kolli is currently offline Rajendra Kolli
Messages: 9
Registered: July 2011
Junior Member
Hello Anthony,

Found some documentation in Eclipse help. I really think this should suffice with me. Thanks for your help
It is present in wiki eclipse under Equinox/p2/MultipleAgents

Previous Topic:Does equinox support to define parent class loader for a installed Bundle?
Next Topic:Why doesn't the Eclipse Marketplace client find my plug-in?
Goto Forum:
  


Current Time: Fri Jul 25 07:35:25 EDT 2014

Powered by FUDForum. Page generated in 0.01562 seconds