01: /*******************************************************************************
02: * Copyright (c) 2000, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.build;
11:
12: import java.lang.reflect.InvocationTargetException;
13: import org.eclipse.core.resources.IProject;
14: import org.eclipse.core.runtime.CoreException;
15: import org.eclipse.core.runtime.IProgressMonitor;
16: import org.eclipse.jface.dialogs.MessageDialog;
17: import org.eclipse.osgi.service.resolver.BundleDescription;
18: import org.eclipse.pde.core.plugin.IPluginModelBase;
19: import org.eclipse.pde.core.plugin.PluginRegistry;
20: import org.eclipse.pde.internal.build.AbstractScriptGenerator;
21: import org.eclipse.pde.internal.build.BuildScriptGenerator;
22: import org.eclipse.pde.internal.core.ClasspathHelper;
23: import org.eclipse.pde.internal.core.TargetPlatformHelper;
24: import org.eclipse.pde.internal.ui.PDEUIMessages;
25:
26: public class BuildPluginAction extends BaseBuildAction {
27:
28: protected void makeScripts(IProgressMonitor monitor)
29: throws InvocationTargetException, CoreException {
30:
31: BuildScriptGenerator generator = new BuildScriptGenerator();
32: AbstractScriptGenerator
33: .setEmbeddedSource(AbstractScriptGenerator
34: .getDefaultEmbeddedSource());
35: AbstractScriptGenerator
36: .setForceUpdateJar(AbstractScriptGenerator
37: .getForceUpdateJarFormat());
38: AbstractScriptGenerator.setConfigInfo(AbstractScriptGenerator
39: .getDefaultConfigInfos());
40:
41: IProject project = fManifestFile.getProject();
42: generator.setWorkingDirectory(project.getLocation()
43: .toOSString());
44: String url = ClasspathHelper.getDevEntriesProperties(project
45: .getLocation().addTrailingSeparator().toString()
46: + "dev.properties", false); //$NON-NLS-1$
47: generator.setDevEntries(url);
48: generator.setPDEState(TargetPlatformHelper.getState());
49: generator.setNextId(TargetPlatformHelper.getPDEState()
50: .getNextId());
51: generator.setStateExtraData(
52: TargetPlatformHelper
53: .getBundleClasspaths(TargetPlatformHelper
54: .getPDEState()),
55: TargetPlatformHelper.getPatchMap(TargetPlatformHelper
56: .getPDEState()));
57: generator.setBuildingOSGi(true);
58: IPluginModelBase model = PluginRegistry.findModel(project);
59: if (model != null && model.getPluginBase().getId() != null) {
60: generator.setBundles(new BundleDescription[] { model
61: .getBundleDescription() });
62: generator.generate();
63: } else {
64: MessageDialog
65: .openError(
66: null,
67: PDEUIMessages.BuildPluginAction_ErrorDialog_Title,
68: PDEUIMessages.BuildPluginAction_ErrorDialog_Message);
69: }
70: }
71:
72: }
|