protected void scheduleExportJob() { FeatureExportInfo info = new FeatureExportInfo(); info.toDirectory = exportPage.doExportToDirectory(); info.exportSource = false; info.exportSourceBundle = false; info.allowBinaryCycles = false; info.exportMetadata = false; info.destinationDirectory = exportPage.getDestination(); info.zipFileName = exportPage.getFileName(); info.items = getPluginModels(); String rootDirectory = "WEB-INF"; // $NON-NLS-1$ WARProductExportOperation job = new WARProductExportOperation( info, PDEUIMessages.ProductExportJob_name, product, rootDirectory); job.setUser(true); job.setRule(ResourcesPlugin.getWorkspace().getRoot()); job.schedule(); job.setProperty(IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_FEATURE_OBJ); }
public byte[] createZippedRepository(List<IModule> modules) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int tempDirNr = new java.util.Random().nextInt(); String javaTmpDir = System.getProperty("java.io.tmpdir"); File tempDir = new File(javaTmpDir + File.separator + modules.get(0).getName() + "_" + tempDirNr); final FeatureExportInfo info = new FeatureExportInfo(); info.toDirectory = false; info.useJarFormat = true; info.exportSource = false; info.exportSourceBundle = false; info.exportMetadata = true; info.allowBinaryCycles = true; info.useWorkspaceCompiledClasses = false; info.destinationDirectory = tempDir.getAbsolutePath(); info.zipFileName = modules.get(0).getName() + ".zip"; info.items = wfModels.toArray(); final FeatureExportOperation job = new FeatureExportOperation(info, PDEUIMessages.FeatureExportJob_name); job.setUser(true); // job.setRule(module.getProject().getWorkspace().getRoot()); job.setRule(null); // setting the workspace root as rule causes deadlock job.setProperty(IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_FEATURE_OBJ); job.addJobChangeListener( new JobChangeAdapter() { public void done(IJobChangeEvent event) { if (job.hasAntErrors()) { // If there were errors when running the ant scripts, inform the user where the logs // can be found. 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(); } }); } } else if (event.getResult().isOK()) { // zip file is created } } }); job.schedule(); try { job.join(); } catch (InterruptedException e) { // e.printStackTrace(); } final File repoLocation = new File(info.destinationDirectory, info.zipFileName); // $NON-NLS-1$ FileInputStream fis; try { fis = new FileInputStream(repoLocation); byte[] buf = new byte[2048]; int len; while ((len = fis.read(buf)) > 0) { baos.write(buf, 0, len); } baos.close(); } catch (Exception e) { 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(); } }); } } tempDir.delete(); return baos.toByteArray(); }
protected void scheduleExportJob() { // NOTE: Any changes to the content here must also be copied to generateAntTask() and // FeatureExportTask final FeatureExportInfo info = new FeatureExportInfo(); info.toDirectory = fPage.doExportToDirectory(); info.useJarFormat = fPage.useJARFormat(); info.exportSource = fPage.doExportSource(); info.exportSourceBundle = fPage.doExportSourceBundles(); info.allowBinaryCycles = fPage.allowBinaryCycles(); info.useWorkspaceCompiledClasses = fPage.useWorkspaceCompiledClasses(); info.destinationDirectory = fPage.getDestination(); info.zipFileName = fPage.getFileName(); if (fPage2 != null && ((FeatureExportWizardPage) fPage).doMultiPlatform()) info.targets = fPage2.getTargets(); info.exportMetadata = ((FeatureExportWizardPage) fPage).doExportMetadata(); info.items = fPage.getSelectedItems(); info.signingInfo = fPage.getSigningInfo(); info.jnlpInfo = ((FeatureExportWizardPage) fPage).getJNLPInfo(); info.qualifier = fPage.getQualifier(); if (((FeatureExportWizardPage) fPage).getCategoryDefinition() != null) info.categoryDefinition = URIUtil.toUnencodedString(((FeatureExportWizardPage) fPage).getCategoryDefinition()); final boolean installAfterExport = fPage.doInstall(); if (installAfterExport) { info.useJarFormat = true; info.exportMetadata = true; if (info.qualifier == null) { // Set the date explicitly since the time can change before the install job runs info.qualifier = QualifierReplacer.getDateQualifier(); } } final FeatureExportOperation job = new FeatureExportOperation(info, PDEUIMessages.FeatureExportJob_name); job.setUser(true); job.setRule(ResourcesPlugin.getWorkspace().getRoot()); job.setProperty(IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_FEATURE_OBJ); job.addJobChangeListener( new JobChangeAdapter() { public void done(IJobChangeEvent event) { if (job.hasAntErrors()) { // If there were errors when running the ant scripts, inform the user where the logs // can be found. 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(); } }); } } else if (event.getResult().isOK() && installAfterExport) { // Install the export into the current running platform RuntimeInstallJob installJob = new RuntimeInstallJob(PDEUIMessages.PluginExportWizard_InstallJobName, info); installJob.setUser(true); installJob.setProperty( IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_FEATURE_OBJ); installJob.schedule(); } } }); job.schedule(); }