KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > build > BuildPluginAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.build;
12
13 import java.lang.reflect.InvocationTargetException JavaDoc;
14 import org.eclipse.core.resources.IProject;
15 import org.eclipse.core.runtime.CoreException;
16 import org.eclipse.core.runtime.IProgressMonitor;
17 import org.eclipse.jface.dialogs.MessageDialog;
18 import org.eclipse.osgi.service.resolver.BundleDescription;
19 import org.eclipse.pde.core.plugin.IPluginModelBase;
20 import org.eclipse.pde.core.plugin.PluginRegistry;
21 import org.eclipse.pde.internal.build.AbstractScriptGenerator;
22 import org.eclipse.pde.internal.build.BuildScriptGenerator;
23 import org.eclipse.pde.internal.core.ClasspathHelper;
24 import org.eclipse.pde.internal.core.TargetPlatformHelper;
25 import org.eclipse.pde.internal.ui.PDEUIMessages;
26
27 public class BuildPluginAction extends BaseBuildAction {
28
29     protected void makeScripts(IProgressMonitor monitor)
30         throws InvocationTargetException JavaDoc, CoreException {
31     
32         BuildScriptGenerator generator = new BuildScriptGenerator();
33         AbstractScriptGenerator.setEmbeddedSource(AbstractScriptGenerator.getDefaultEmbeddedSource());
34         AbstractScriptGenerator.setForceUpdateJar(AbstractScriptGenerator.getForceUpdateJarFormat());
35         AbstractScriptGenerator.setConfigInfo(AbstractScriptGenerator.getDefaultConfigInfos());
36         
37         IProject project = fManifestFile.getProject();
38         generator.setWorkingDirectory(project.getLocation().toOSString());
39         String JavaDoc url = ClasspathHelper.getDevEntriesProperties(project.getLocation().addTrailingSeparator().toString() + "dev.properties", false); //$NON-NLS-1$
40
generator.setDevEntries(url);
41         generator.setPDEState(TargetPlatformHelper.getState());
42         generator.setNextId(TargetPlatformHelper.getPDEState().getNextId());
43         generator.setStateExtraData(TargetPlatformHelper.getBundleClasspaths(TargetPlatformHelper.getPDEState()), TargetPlatformHelper.getPatchMap(TargetPlatformHelper.getPDEState()));
44         generator.setBuildingOSGi(true);
45         IPluginModelBase model = PluginRegistry.findModel(project);
46         if(model != null && model.getPluginBase().getId() != null) {
47             generator.setBundles(new BundleDescription[] {model.getBundleDescription()});
48             generator.generate();
49         }
50         else
51         { MessageDialog.openError(null,
52                     PDEUIMessages.BuildPluginAction_ErrorDialog_Title,
53                     PDEUIMessages.BuildPluginAction_ErrorDialog_Message);
54         }
55     }
56
57 }
58
Popular Tags