Creating an installer job in p2 [message #692606] |
Mon, 04 July 2011 16:36  |
Eclipse User |
|
|
|
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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04348 seconds