Eclipse插件开发-不使用对话框,使用代码方式生成bundle jar

private void genJar(String addProjectName){
		//转project
		IProject project = getProject(addProjectName);
		PluginModelManager pmm = PDECore.getDefault().getModelManager();
		IPluginModelBase thePluginModel= pmm.findModel(project);
		IPluginModel pluginModel = (IPluginModel) thePluginModel;
		BundlePluginModel bpm = (BundlePluginModel) pluginModel;
		
		final FeatureExportInfo info = new FeatureExportInfo();
		info.toDirectory = true; //true
		info.useJarFormat = true; // true
		info.allowBinaryCycles = true; //true
		info.useWorkspaceCompiledClasses = false; //false
		info.destinationDirectory = "C:\\Users\\~~\\Desktop"; //C:\Users\liuyi\Desktop
		Object [] pmObj = new Object[1];
		pmObj[0] = bpm;
		info.items = pmObj;
		
		final PluginExportOperation job = new PluginExportOperation(info, PDEUIMessages.PluginExportJob_name);
		job.setUser(true);
		job.setRule(ResourcesPlugin.getWorkspace().getRoot());
		job.setProperty(IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_PLUGIN_OBJ);
		job.addJobChangeListener(new JobChangeAdapter() {
			public void done(IJobChangeEvent event) {
				if (job.hasAntErrors()) {
					final File logLocation = new File(info.destinationDirectory, "logs.zip"); //$NON-NLS-1$
					if (logLocation.exists()) {
						PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
							public void run() {
//								AntErrorDialog dialog = new AntErrorDialog(logLocation);
//								dialog.open();
								System.out.println();
							}
						});
					}
				}
//				else if (event.getResult().isOK() && installAfterExport) {
//					RuntimeInstallJob installJob = new RuntimeInstallJob(PDEUIMessages.PluginExportWizard_InstallJobName, info);
//					installJob.setUser(true);
//					installJob.setProperty(IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_FEATURE_OBJ);
//					installJob.schedule();
//				}
			}
		});
		job.schedule();
	}

你可能感兴趣的:(Eclipse插件开发-不使用对话框,使用代码方式生成bundle jar)