Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 130629 Details for
Bug 267127
Change export to use new p2 publishing for metadata
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch for products and multi-platform export
267127-b.txt (text/plain), 95.83 KB, created by
Andrew Niefer
on 2009-04-01 18:26:59 EDT
(
hide
)
Description:
Patch for products and multi-platform export
Filename:
MIME Type:
Creator:
Andrew Niefer
Created:
2009-04-01 18:26:59 EDT
Size:
95.83 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.build >Index: src/org/eclipse/pde/internal/build/AssembleScriptGenerator.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/build/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AssembleScriptGenerator.java,v >retrieving revision 1.45 >diff -u -r1.45 AssembleScriptGenerator.java >--- src/org/eclipse/pde/internal/build/AssembleScriptGenerator.java 12 Mar 2009 19:05:40 -0000 1.45 >+++ src/org/eclipse/pde/internal/build/AssembleScriptGenerator.java 1 Apr 2009 22:13:16 -0000 >@@ -123,8 +123,7 @@ > if (configScriptGenerator.getProductFile() != null) > return false; > >- //export from UI can't be grouped >- return !havePDEUIState(); >+ return true; > } > > protected Collection[] getConfigInfos(Config aConfig) { >Index: src/org/eclipse/pde/internal/build/ProductGenerator.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/build/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ProductGenerator.java,v >retrieving revision 1.31 >diff -u -r1.31 ProductGenerator.java >--- src/org/eclipse/pde/internal/build/ProductGenerator.java 12 Mar 2009 19:06:00 -0000 1.31 >+++ src/org/eclipse/pde/internal/build/ProductGenerator.java 1 Apr 2009 22:13:16 -0000 >@@ -202,6 +202,8 @@ > P2InfUtils.printBundleCU(buffer, index++, BUNDLE_EQUINOX_LAUNCHER, launcher.getVersion(), null, instructions); > > BuildTimeFeature executableFeature = assembly.getRootProvider(FEATURE_EQUINOX_EXECUTABLE, null); >+ if (executableFeature == null && havePDEUIState()) >+ executableFeature = assembly.getRootProvider("org.eclipse.pde.container.feature", null); //$NON-NLS-1$ > List configs = getConfigInfos(); > for (int i = 0; i < configs.size(); i++) { > Config config = (Config) configs.get(i); >Index: src/org/eclipse/pde/internal/build/AssembleConfigScriptGenerator.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/build/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AssembleConfigScriptGenerator.java,v >retrieving revision 1.126 >diff -u -r1.126 AssembleConfigScriptGenerator.java >--- src/org/eclipse/pde/internal/build/AssembleConfigScriptGenerator.java 22 Mar 2009 00:36:41 -0000 1.126 >+++ src/org/eclipse/pde/internal/build/AssembleConfigScriptGenerator.java 1 Apr 2009 22:13:16 -0000 >@@ -466,6 +466,7 @@ > script.printProperty(PROPERTY_ARCHIVE_FULLPATH, Utils.getPropertyFormat(PROPERTY_BASEDIR) + '/' + Utils.getPropertyFormat(PROPERTY_BUILD_LABEL) + '/' + Utils.getPropertyFormat(PROPERTY_ARCHIVE_NAME)); > printLauncherJarProperty(); > script.printProperty(PROPERTY_P2_BUILD_REPO, "file:" + Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY) + "/buildRepo"); //$NON-NLS-1$ //$NON-NLS-2$ >+ script.printProperty(PROPERTY_GENERIC_TARGETS, Utils.getPropertyFormat("eclipse.pdebuild.scripts") + '/' + "/genericTargets.xml"); //$NON-NLS-1$//$NON-NLS-2$ > script.printAvailableTask(PROPERTY_CUSTOM_ASSEMBLY, "${builder}/customAssembly.xml", "${builder}/customAssembly.xml"); //$NON-NLS-1$ //$NON-NLS-2$ > if (productQualifier != null) > script.printProperty(PROPERTY_P2_PRODUCT_QUALIFIER, productQualifier); >Index: src/org/eclipse/pde/internal/build/builder/FeatureBuildScriptGenerator.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/build/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/FeatureBuildScriptGenerator.java,v >retrieving revision 1.131 >diff -u -r1.131 FeatureBuildScriptGenerator.java >--- src/org/eclipse/pde/internal/build/builder/FeatureBuildScriptGenerator.java 5 Mar 2009 23:29:12 -0000 1.131 >+++ src/org/eclipse/pde/internal/build/builder/FeatureBuildScriptGenerator.java 1 Apr 2009 22:13:16 -0000 >@@ -477,8 +477,10 @@ > fileSet[j] = new FileSet(fromDir + file, null, "**", null, null, null, null); //$NON-NLS-1$ > } > } >- script.printMkdirTask(Utils.getPropertyFormat(PROPERTY_FEATURE_BASE) + '/' + configName + '/' + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER) + '/' + folder); >- script.printCopyTask(null, Utils.getPropertyFormat(PROPERTY_FEATURE_BASE) + '/' + configName + '/' + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER) + '/' + folder, fileSet, true, overwrite); >+ if (fileSet.length > 0) { >+ script.printMkdirTask(Utils.getPropertyFormat(PROPERTY_FEATURE_BASE) + '/' + configName + '/' + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER) + '/' + folder); >+ script.printCopyTask(null, Utils.getPropertyFormat(PROPERTY_FEATURE_BASE) + '/' + configName + '/' + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER) + '/' + folder, fileSet, true, overwrite); >+ } > } > } > >Index: src/org/eclipse/pde/internal/build/site/BuildTimeSite.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/build/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/BuildTimeSite.java,v >retrieving revision 1.49 >diff -u -r1.49 BuildTimeSite.java >--- src/org/eclipse/pde/internal/build/site/BuildTimeSite.java 12 Jan 2009 19:08:16 -0000 1.49 >+++ src/org/eclipse/pde/internal/build/site/BuildTimeSite.java 1 Apr 2009 22:13:16 -0000 >@@ -97,6 +97,7 @@ > if (provider.getInitialState() != null) { > state = new PDEState(provider.getInitialState()); > state.setEESources(eeSources); >+ state.resolveState(); > return state; > } > >#P org.eclipse.pde.core >Index: src/org/eclipse/pde/internal/core/exports/FeatureBasedExportOperation.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/exports/FeatureBasedExportOperation.java,v >retrieving revision 1.9 >diff -u -r1.9 FeatureBasedExportOperation.java >--- src/org/eclipse/pde/internal/core/exports/FeatureBasedExportOperation.java 3 Feb 2009 19:56:01 -0000 1.9 >+++ src/org/eclipse/pde/internal/core/exports/FeatureBasedExportOperation.java 1 Apr 2009 22:13:17 -0000 >@@ -1,124 +1,124 @@ >-/******************************************************************************* >- * Copyright (c) 2006, 2009 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.core.exports; >- >-import java.io.File; >-import java.io.IOException; >-import java.lang.reflect.InvocationTargetException; >-import java.util.*; >-import org.eclipse.core.runtime.*; >-import org.eclipse.osgi.service.resolver.BundleDescription; >-import org.eclipse.pde.core.IModel; >-import org.eclipse.pde.core.plugin.IPluginModelBase; >-import org.eclipse.pde.core.plugin.TargetPlatform; >-import org.eclipse.pde.internal.core.PDECore; >-import org.eclipse.pde.internal.core.PDECoreMessages; >-import org.eclipse.pde.internal.core.ifeature.IFeature; >-import org.eclipse.pde.internal.core.ifeature.IFeatureModel; >- >-public abstract class FeatureBasedExportOperation extends FeatureExportOperation { >- >- protected String fFeatureLocation; >- >- public FeatureBasedExportOperation(FeatureExportInfo info, String name) { >- super(info, name); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.core.exports.FeatureExportOperation#run(org.eclipse.core.runtime.IProgressMonitor) >- */ >- protected IStatus run(IProgressMonitor monitor) { >- try { >- createDestination(); >- monitor.beginTask("Exporting...", 33); //$NON-NLS-1$ >- // create a feature to contain all plug-ins >- String featureID = "org.eclipse.pde.container.feature"; //$NON-NLS-1$ >- fFeatureLocation = fBuildTempLocation + File.separator + featureID; >- String[] config = new String[] {TargetPlatform.getOS(), TargetPlatform.getWS(), TargetPlatform.getOSArch(), TargetPlatform.getNL()}; >- createFeature(featureID, fFeatureLocation, config, false); >- createBuildPropertiesFile(fFeatureLocation); >- if (fInfo.useJarFormat) >- createPostProcessingFiles(); >- IStatus status = testBuildWorkspaceBeforeExport(new SubProgressMonitor(monitor, 10)); >- doExport(featureID, null, fFeatureLocation, TargetPlatform.getOS(), TargetPlatform.getWS(), TargetPlatform.getOSArch(), new SubProgressMonitor(monitor, 20)); >- if (monitor.isCanceled()) { >- return Status.CANCEL_STATUS; >- } >- return status; >- } catch (IOException e) { >- return new Status(IStatus.ERROR, PDECore.PLUGIN_ID, PDECoreMessages.FeatureBasedExportOperation_ProblemDuringExport, e); >- } catch (CoreException e) { >- return e.getStatus(); >- } catch (InvocationTargetException e) { >- return new Status(IStatus.ERROR, PDECore.PLUGIN_ID, PDECoreMessages.FeatureBasedExportOperation_ProblemDuringExport, e.getTargetException()); >- } finally { >- for (int i = 0; i < fInfo.items.length; i++) { >- if (fInfo.items[i] instanceof IModel) >- try { >- deleteBuildFiles(fInfo.items[i]); >- } catch (CoreException e) { >- PDECore.log(e); >- } >- } >- cleanup(null, new SubProgressMonitor(monitor, 3)); >- monitor.done(); >- } >- } >- >- protected abstract void createPostProcessingFiles(); >- >- protected String[] getPaths() { >- String[] paths = super.getPaths(); >- String[] all = new String[paths.length + 1]; >- all[0] = fFeatureLocation + File.separator + "feature.xml"; //$NON-NLS-1$ >- System.arraycopy(paths, 0, all, 1, paths.length); >- return all; >- } >- >- private void createBuildPropertiesFile(String featureLocation) { >- File file = new File(featureLocation); >- if (!file.exists() || !file.isDirectory()) >- file.mkdirs(); >- Properties prop = new Properties(); >- prop.put("pde", "marker"); //$NON-NLS-1$ //$NON-NLS-2$ >- >- if (fInfo.exportSource && fInfo.exportSourceBundle) { >- prop.put("individualSourceBundles", "true"); //$NON-NLS-1$ //$NON-NLS-2$ >- Dictionary environment = new Hashtable(4); >- environment.put("osgi.os", TargetPlatform.getOS()); //$NON-NLS-1$ >- environment.put("osgi.ws", TargetPlatform.getWS()); //$NON-NLS-1$ >- environment.put("osgi.arch", TargetPlatform.getOSArch()); //$NON-NLS-1$ >- environment.put("osgi.nl", TargetPlatform.getNL()); //$NON-NLS-1$ >- >- for (int i = 0; i < fInfo.items.length; i++) { >- if (fInfo.items[i] instanceof IFeatureModel) { >- IFeature feature = ((IFeatureModel) fInfo.items[i]).getFeature(); >- prop.put("generate.feature@" + feature.getId() + ".source", feature.getId()); //$NON-NLS-1$ //$NON-NLS-2$ >- } else { >- BundleDescription bundle = null; >- if (fInfo.items[i] instanceof IPluginModelBase) { >- bundle = ((IPluginModelBase) fInfo.items[i]).getBundleDescription(); >- } >- if (bundle == null) { >- if (fInfo.items[i] instanceof BundleDescription) >- bundle = (BundleDescription) fInfo.items[i]; >- } >- if (bundle == null) >- continue; >- if (shouldAddPlugin(bundle, environment)) { >- prop.put("generate.plugin@" + bundle.getSymbolicName() + ".source", bundle.getSymbolicName()); //$NON-NLS-1$ //$NON-NLS-2$ >- } >- } >- } >- } >- save(new File(file, "build.properties"), prop, "Marker File"); //$NON-NLS-1$ //$NON-NLS-2$ >- } >-} >+/******************************************************************************* >+ * Copyright (c) 2006, 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.core.exports; >+ >+import java.io.File; >+import java.io.IOException; >+import java.lang.reflect.InvocationTargetException; >+import java.util.*; >+import org.eclipse.core.runtime.*; >+import org.eclipse.osgi.service.resolver.BundleDescription; >+import org.eclipse.pde.core.IModel; >+import org.eclipse.pde.core.plugin.IPluginModelBase; >+import org.eclipse.pde.core.plugin.TargetPlatform; >+import org.eclipse.pde.internal.core.PDECore; >+import org.eclipse.pde.internal.core.PDECoreMessages; >+import org.eclipse.pde.internal.core.ifeature.IFeature; >+import org.eclipse.pde.internal.core.ifeature.IFeatureModel; >+ >+public abstract class FeatureBasedExportOperation extends FeatureExportOperation { >+ >+ protected String fFeatureLocation; >+ >+ public FeatureBasedExportOperation(FeatureExportInfo info, String name) { >+ super(info, name); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.exports.FeatureExportOperation#run(org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ protected IStatus run(IProgressMonitor monitor) { >+ try { >+ createDestination(); >+ monitor.beginTask("Exporting...", 33); //$NON-NLS-1$ >+ // create a feature to contain all plug-ins >+ String featureID = "org.eclipse.pde.container.feature"; //$NON-NLS-1$ >+ fFeatureLocation = fBuildTempLocation + File.separator + featureID; >+ String[][] config = new String[][] {{TargetPlatform.getOS(), TargetPlatform.getWS(), TargetPlatform.getOSArch(), TargetPlatform.getNL()}}; >+ createFeature(featureID, fFeatureLocation, config, false); >+ createBuildPropertiesFile(fFeatureLocation); >+ if (fInfo.useJarFormat) >+ createPostProcessingFiles(); >+ IStatus status = testBuildWorkspaceBeforeExport(new SubProgressMonitor(monitor, 10)); >+ doExport(featureID, null, fFeatureLocation, config, new SubProgressMonitor(monitor, 20)); >+ if (monitor.isCanceled()) { >+ return Status.CANCEL_STATUS; >+ } >+ return status; >+ } catch (IOException e) { >+ return new Status(IStatus.ERROR, PDECore.PLUGIN_ID, PDECoreMessages.FeatureBasedExportOperation_ProblemDuringExport, e); >+ } catch (CoreException e) { >+ return e.getStatus(); >+ } catch (InvocationTargetException e) { >+ return new Status(IStatus.ERROR, PDECore.PLUGIN_ID, PDECoreMessages.FeatureBasedExportOperation_ProblemDuringExport, e.getTargetException()); >+ } finally { >+ for (int i = 0; i < fInfo.items.length; i++) { >+ if (fInfo.items[i] instanceof IModel) >+ try { >+ deleteBuildFiles(fInfo.items[i]); >+ } catch (CoreException e) { >+ PDECore.log(e); >+ } >+ } >+ cleanup(null, new SubProgressMonitor(monitor, 3)); >+ monitor.done(); >+ } >+ } >+ >+ protected abstract void createPostProcessingFiles(); >+ >+ protected String[] getPaths() { >+ String[] paths = super.getPaths(); >+ String[] all = new String[paths.length + 1]; >+ all[0] = fFeatureLocation + File.separator + "feature.xml"; //$NON-NLS-1$ >+ System.arraycopy(paths, 0, all, 1, paths.length); >+ return all; >+ } >+ >+ private void createBuildPropertiesFile(String featureLocation) { >+ File file = new File(featureLocation); >+ if (!file.exists() || !file.isDirectory()) >+ file.mkdirs(); >+ Properties prop = new Properties(); >+ prop.put("pde", "marker"); //$NON-NLS-1$ //$NON-NLS-2$ >+ >+ if (fInfo.exportSource && fInfo.exportSourceBundle) { >+ prop.put("individualSourceBundles", "true"); //$NON-NLS-1$ //$NON-NLS-2$ >+ Dictionary environment = new Hashtable(4); >+ environment.put("osgi.os", TargetPlatform.getOS()); //$NON-NLS-1$ >+ environment.put("osgi.ws", TargetPlatform.getWS()); //$NON-NLS-1$ >+ environment.put("osgi.arch", TargetPlatform.getOSArch()); //$NON-NLS-1$ >+ environment.put("osgi.nl", TargetPlatform.getNL()); //$NON-NLS-1$ >+ >+ for (int i = 0; i < fInfo.items.length; i++) { >+ if (fInfo.items[i] instanceof IFeatureModel) { >+ IFeature feature = ((IFeatureModel) fInfo.items[i]).getFeature(); >+ prop.put("generate.feature@" + feature.getId() + ".source", feature.getId()); //$NON-NLS-1$ //$NON-NLS-2$ >+ } else { >+ BundleDescription bundle = null; >+ if (fInfo.items[i] instanceof IPluginModelBase) { >+ bundle = ((IPluginModelBase) fInfo.items[i]).getBundleDescription(); >+ } >+ if (bundle == null) { >+ if (fInfo.items[i] instanceof BundleDescription) >+ bundle = (BundleDescription) fInfo.items[i]; >+ } >+ if (bundle == null) >+ continue; >+ if (shouldAddPlugin(bundle, environment)) { >+ prop.put("generate.plugin@" + bundle.getSymbolicName() + ".source", bundle.getSymbolicName()); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ } >+ } >+ } >+ save(new File(file, "build.properties"), prop, "Marker File"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+} >Index: src/org/eclipse/pde/internal/core/exports/SiteBuildOperation.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/exports/SiteBuildOperation.java,v >retrieving revision 1.12 >diff -u -r1.12 SiteBuildOperation.java >--- src/org/eclipse/pde/internal/core/exports/SiteBuildOperation.java 19 Mar 2009 16:01:33 -0000 1.12 >+++ src/org/eclipse/pde/internal/core/exports/SiteBuildOperation.java 1 Apr 2009 22:13:17 -0000 >@@ -1,218 +1,219 @@ >-/******************************************************************************* >- * Copyright (c) 2006, 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.core.exports; >- >-import java.io.File; >-import java.net.MalformedURLException; >-import java.util.Map; >-import java.util.regex.Pattern; >-import org.eclipse.core.resources.*; >-import org.eclipse.core.runtime.*; >-import org.eclipse.core.runtime.jobs.MultiRule; >-import org.eclipse.pde.internal.build.IBuildPropertiesConstants; >-import org.eclipse.pde.internal.build.IXMLConstants; >-import org.eclipse.pde.internal.core.P2Utils; >-import org.eclipse.pde.internal.core.PDECore; >-import org.eclipse.pde.internal.core.ifeature.IFeature; >-import org.eclipse.pde.internal.core.ifeature.IFeatureModel; >-import org.eclipse.pde.internal.core.isite.*; >-import org.eclipse.pde.internal.core.site.WorkspaceSiteModel; >-import org.eclipse.pde.internal.core.util.PatternConstructor; >-import org.osgi.framework.Version; >- >-/** >- * Performs a site build operation that will build any features needed by the site and generate >- * p2 metadata for those features. >- * >- * @see FeatureBasedExportOperation >- * @see FeatureExportOperation >- */ >-public class SiteBuildOperation extends FeatureBasedExportOperation { >- >- private long fBuildTime; >- >- private IFeatureModel[] fFeatureModels; >- private ISiteModel fSiteModel; >- private IContainer fSiteContainer; >- >- public SiteBuildOperation(IFeatureModel[] features, ISiteModel site, String jobName) { >- super(getInfo(features, site), jobName); >- fFeatureModels = features; >- fSiteModel = site; >- fSiteContainer = site.getUnderlyingResource().getParent(); >- setRule(MultiRule.combine(fSiteContainer.getProject(), getRule())); >- } >- >- private static FeatureExportInfo getInfo(IFeatureModel[] models, ISiteModel siteModel) { >- FeatureExportInfo info = new FeatureExportInfo(); >- info.useJarFormat = true; >- info.toDirectory = true; >- info.allowBinaryCycles = true; >- info.destinationDirectory = siteModel.getUnderlyingResource().getParent().getLocation().toOSString(); >- info.items = models; >- return info; >- } >- >- protected IStatus run(IProgressMonitor monitor) { >- fBuildTime = System.currentTimeMillis(); >- IStatus status = super.run(monitor); >- try { >- fSiteContainer.refreshLocal(IResource.DEPTH_INFINITE, monitor); >- updateSiteFeatureVersions(); >- } catch (CoreException ce) { >- return ce.getStatus(); >- } >- return status; >- } >- >- private void updateSiteFeatureVersions() throws CoreException { >- for (int i = 0; i < fFeatureModels.length; i++) { >- IFeature feature = fFeatureModels[i].getFeature(); >- Version pvi = Version.parseVersion(feature.getVersion()); >- >- if ("qualifier".equals(pvi.getQualifier())) { //$NON-NLS-1$ >- String newVersion = findBuiltVersion(feature.getId(), pvi.getMajor(), pvi.getMinor(), pvi.getMicro()); >- if (newVersion == null) { >- continue; >- } >- ISiteFeature reVersionCandidate = findSiteFeature(feature, pvi); >- if (reVersionCandidate != null) { >- reVersionCandidate.setVersion(newVersion); >- reVersionCandidate.setURL("features/" + feature.getId() + "_" //$NON-NLS-1$ //$NON-NLS-2$ >- + newVersion + ".jar"); //$NON-NLS-1$ >- } >- } >- } >- ((WorkspaceSiteModel) fSiteModel).save(); >- } >- >- private ISiteFeature findSiteFeature(IFeature feature, Version pvi) { >- ISiteFeature reversionCandidate = null; >- // first see if version with qualifier being qualifier is present among >- // site features >- ISiteFeature[] siteFeatures = fSiteModel.getSite().getFeatures(); >- for (int s = 0; s < siteFeatures.length; s++) { >- if (siteFeatures[s].getId().equals(feature.getId()) && siteFeatures[s].getVersion().equals(feature.getVersion())) { >- return siteFeatures[s]; >- } >- } >- String highestQualifier = null; >- // then find feature with the highest qualifier >- for (int s = 0; s < siteFeatures.length; s++) { >- if (siteFeatures[s].getId().equals(feature.getId())) { >- Version candidatePvi = Version.parseVersion(siteFeatures[s].getVersion()); >- if (pvi.getMajor() == candidatePvi.getMajor() && pvi.getMinor() == candidatePvi.getMinor() && pvi.getMicro() == candidatePvi.getMicro()) { >- if (reversionCandidate == null || candidatePvi.getQualifier().compareTo(highestQualifier) > 0) { >- reversionCandidate = siteFeatures[s]; >- highestQualifier = candidatePvi.getQualifier(); >- } >- } >- } >- } >- return reversionCandidate; >- } >- >- /** >- * Finds the highest version from feature jars. ID and version components >- * are constant. Qualifier varies >- * >- * @param builtJars >- * candidate jars in format id_version.jar >- * @param id >- * @param major >- * @param minor >- * @param service >- */ >- private String findBuiltVersion(String id, int major, int minor, int service) { >- IFolder featuresFolder = fSiteContainer.getFolder(new Path("features")); //$NON-NLS-1$ >- if (!featuresFolder.exists()) { >- return null; >- } >- IResource[] featureJars = null; >- try { >- featureJars = featuresFolder.members(); >- } catch (CoreException ce) { >- return null; >- } >- Pattern pattern = PatternConstructor.createPattern(id + "_" //$NON-NLS-1$ >- + major + "." //$NON-NLS-1$ >- + minor + "." //$NON-NLS-1$ >- + service + "*.jar", true); //$NON-NLS-1$ >- // finding the newest feature archive >- String newestName = null; >- long newestTime = 0; >- for (int i = 0; i < featureJars.length; i++) { >- File file = new File(featureJars[i].getLocation().toOSString()); >- long jarTime = file.lastModified(); >- String jarName = featureJars[i].getName(); >- >- if (jarTime < fBuildTime) { >- continue; >- } >- if (jarTime <= newestTime) { >- continue; >- } >- if (pattern.matcher(jarName).matches()) { >- newestName = featureJars[i].getName(); >- newestTime = jarTime; >- } >- } >- if (newestName == null) { >- return null; >- } >- >- return newestName.substring(id.length() + 1, newestName.length() - 4); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.core.exports.FeatureBasedExportOperation#createPostProcessingFiles() >- */ >- protected void createPostProcessingFiles() { >- createPostProcessingFile(new File(fFeatureLocation, FEATURE_POST_PROCESSING)); >- createPostProcessingFile(new File(fFeatureLocation, PLUGIN_POST_PROCESSING)); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.core.exports.FeatureExportOperation#publishingP2Metadata() >- */ >- protected boolean publishingP2Metadata() { >- return true; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.core.exports.FeatureExportOperation#setP2MetaDataProperties(java.util.Map) >- */ >- protected void setP2MetaDataProperties(Map map) { >- if (fInfo.toDirectory) { >- map.put(IXMLConstants.TARGET_P2_METADATA, IBuildPropertiesConstants.TRUE); >- map.put(IBuildPropertiesConstants.PROPERTY_P2_FLAVOR, P2Utils.P2_FLAVOR_DEFAULT); >- map.put(IBuildPropertiesConstants.PROPERTY_P2_PUBLISH_ARTIFACTS, IBuildPropertiesConstants.FALSE); >- map.put(IBuildPropertiesConstants.PROPERTY_P2_FINAL_MODE_OVERRIDE, IBuildPropertiesConstants.TRUE); >- map.put(IBuildPropertiesConstants.PROPERTY_P2_COMPRESS, IBuildPropertiesConstants.TRUE); >- IResource siteXML = fSiteModel.getUnderlyingResource(); >- if (siteXML.exists() && siteXML.getLocationURI() != null) { >- map.put(IBuildPropertiesConstants.PROPERTY_P2_CATEGORY_SITE, URIUtil.toUnencodedString(siteXML.getLocationURI())); >- } >- ISiteDescription description = fSiteModel.getSite().getDescription(); >- if (description != null && description.getName() != null && description.getName().length() > 0) { >- map.put(IBuildPropertiesConstants.PROPERTY_P2_METADATA_REPO_NAME, description.getName()); >- map.put(IBuildPropertiesConstants.PROPERTY_P2_ARTIFACT_REPO_NAME, description.getName()); >- } >- try { >- String destination = new File(fBuildTempMetadataLocation).toURL().toString(); >- map.put(IBuildPropertiesConstants.PROPERTY_P2_BUILD_REPO, destination); >- } catch (MalformedURLException e) { >- PDECore.log(e); >- } >- } >- } >- >-} >+/******************************************************************************* >+ * Copyright (c) 2006, 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.core.exports; >+ >+import java.io.File; >+import java.net.MalformedURLException; >+import java.util.Map; >+import java.util.regex.Pattern; >+import org.eclipse.core.resources.*; >+import org.eclipse.core.runtime.*; >+import org.eclipse.core.runtime.jobs.MultiRule; >+import org.eclipse.pde.internal.build.IBuildPropertiesConstants; >+import org.eclipse.pde.internal.build.IXMLConstants; >+import org.eclipse.pde.internal.core.P2Utils; >+import org.eclipse.pde.internal.core.PDECore; >+import org.eclipse.pde.internal.core.ifeature.IFeature; >+import org.eclipse.pde.internal.core.ifeature.IFeatureModel; >+import org.eclipse.pde.internal.core.isite.*; >+import org.eclipse.pde.internal.core.site.WorkspaceSiteModel; >+import org.eclipse.pde.internal.core.util.PatternConstructor; >+import org.osgi.framework.Version; >+ >+/** >+ * Performs a site build operation that will build any features needed by the site and generate >+ * p2 metadata for those features. >+ * >+ * @see FeatureBasedExportOperation >+ * @see FeatureExportOperation >+ */ >+public class SiteBuildOperation extends FeatureBasedExportOperation { >+ >+ private long fBuildTime; >+ >+ private IFeatureModel[] fFeatureModels; >+ private ISiteModel fSiteModel; >+ private IContainer fSiteContainer; >+ >+ public SiteBuildOperation(IFeatureModel[] features, ISiteModel site, String jobName) { >+ super(getInfo(features, site), jobName); >+ fFeatureModels = features; >+ fSiteModel = site; >+ fSiteContainer = site.getUnderlyingResource().getParent(); >+ setRule(MultiRule.combine(fSiteContainer.getProject(), getRule())); >+ } >+ >+ private static FeatureExportInfo getInfo(IFeatureModel[] models, ISiteModel siteModel) { >+ FeatureExportInfo info = new FeatureExportInfo(); >+ info.useJarFormat = true; >+ info.toDirectory = true; >+ info.allowBinaryCycles = true; >+ info.destinationDirectory = siteModel.getUnderlyingResource().getParent().getLocation().toOSString(); >+ info.items = models; >+ return info; >+ } >+ >+ protected IStatus run(IProgressMonitor monitor) { >+ fBuildTime = System.currentTimeMillis(); >+ IStatus status = super.run(monitor); >+ try { >+ fSiteContainer.refreshLocal(IResource.DEPTH_INFINITE, monitor); >+ updateSiteFeatureVersions(); >+ } catch (CoreException ce) { >+ return ce.getStatus(); >+ } >+ return status; >+ } >+ >+ private void updateSiteFeatureVersions() throws CoreException { >+ for (int i = 0; i < fFeatureModels.length; i++) { >+ IFeature feature = fFeatureModels[i].getFeature(); >+ Version pvi = Version.parseVersion(feature.getVersion()); >+ >+ if ("qualifier".equals(pvi.getQualifier())) { //$NON-NLS-1$ >+ String newVersion = findBuiltVersion(feature.getId(), pvi.getMajor(), pvi.getMinor(), pvi.getMicro()); >+ if (newVersion == null) { >+ continue; >+ } >+ ISiteFeature reVersionCandidate = findSiteFeature(feature, pvi); >+ if (reVersionCandidate != null) { >+ reVersionCandidate.setVersion(newVersion); >+ reVersionCandidate.setURL("features/" + feature.getId() + "_" //$NON-NLS-1$ //$NON-NLS-2$ >+ + newVersion + ".jar"); //$NON-NLS-1$ >+ } >+ } >+ } >+ ((WorkspaceSiteModel) fSiteModel).save(); >+ } >+ >+ private ISiteFeature findSiteFeature(IFeature feature, Version pvi) { >+ ISiteFeature reversionCandidate = null; >+ // first see if version with qualifier being qualifier is present among >+ // site features >+ ISiteFeature[] siteFeatures = fSiteModel.getSite().getFeatures(); >+ for (int s = 0; s < siteFeatures.length; s++) { >+ if (siteFeatures[s].getId().equals(feature.getId()) && siteFeatures[s].getVersion().equals(feature.getVersion())) { >+ return siteFeatures[s]; >+ } >+ } >+ String highestQualifier = null; >+ // then find feature with the highest qualifier >+ for (int s = 0; s < siteFeatures.length; s++) { >+ if (siteFeatures[s].getId().equals(feature.getId())) { >+ Version candidatePvi = Version.parseVersion(siteFeatures[s].getVersion()); >+ if (pvi.getMajor() == candidatePvi.getMajor() && pvi.getMinor() == candidatePvi.getMinor() && pvi.getMicro() == candidatePvi.getMicro()) { >+ if (reversionCandidate == null || candidatePvi.getQualifier().compareTo(highestQualifier) > 0) { >+ reversionCandidate = siteFeatures[s]; >+ highestQualifier = candidatePvi.getQualifier(); >+ } >+ } >+ } >+ } >+ return reversionCandidate; >+ } >+ >+ /** >+ * Finds the highest version from feature jars. ID and version components >+ * are constant. Qualifier varies >+ * >+ * @param builtJars >+ * candidate jars in format id_version.jar >+ * @param id >+ * @param major >+ * @param minor >+ * @param service >+ */ >+ private String findBuiltVersion(String id, int major, int minor, int service) { >+ IFolder featuresFolder = fSiteContainer.getFolder(new Path("features")); //$NON-NLS-1$ >+ if (!featuresFolder.exists()) { >+ return null; >+ } >+ IResource[] featureJars = null; >+ try { >+ featureJars = featuresFolder.members(); >+ } catch (CoreException ce) { >+ return null; >+ } >+ Pattern pattern = PatternConstructor.createPattern(id + "_" //$NON-NLS-1$ >+ + major + "." //$NON-NLS-1$ >+ + minor + "." //$NON-NLS-1$ >+ + service + "*.jar", true); //$NON-NLS-1$ >+ // finding the newest feature archive >+ String newestName = null; >+ long newestTime = 0; >+ for (int i = 0; i < featureJars.length; i++) { >+ File file = new File(featureJars[i].getLocation().toOSString()); >+ long jarTime = file.lastModified(); >+ String jarName = featureJars[i].getName(); >+ >+ if (jarTime < fBuildTime) { >+ continue; >+ } >+ if (jarTime <= newestTime) { >+ continue; >+ } >+ if (pattern.matcher(jarName).matches()) { >+ newestName = featureJars[i].getName(); >+ newestTime = jarTime; >+ } >+ } >+ if (newestName == null) { >+ return null; >+ } >+ >+ return newestName.substring(id.length() + 1, newestName.length() - 4); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.exports.FeatureBasedExportOperation#createPostProcessingFiles() >+ */ >+ protected void createPostProcessingFiles() { >+ createPostProcessingFile(new File(fFeatureLocation, FEATURE_POST_PROCESSING)); >+ createPostProcessingFile(new File(fFeatureLocation, PLUGIN_POST_PROCESSING)); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.exports.FeatureExportOperation#publishingP2Metadata() >+ */ >+ protected boolean publishingP2Metadata() { >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.exports.FeatureExportOperation#setP2MetaDataProperties(java.util.Map) >+ */ >+ protected void setP2MetaDataProperties(Map map) { >+ if (fInfo.toDirectory) { >+ map.put(IXMLConstants.TARGET_P2_METADATA, IBuildPropertiesConstants.TRUE); >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_FLAVOR, P2Utils.P2_FLAVOR_DEFAULT); >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_PUBLISH_ARTIFACTS, IBuildPropertiesConstants.TRUE); >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_FINAL_MODE_OVERRIDE, IBuildPropertiesConstants.TRUE); >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_COMPRESS, IBuildPropertiesConstants.TRUE); >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_GATHERING, Boolean.toString(publishingP2Metadata())); >+ IResource siteXML = fSiteModel.getUnderlyingResource(); >+ if (siteXML.exists() && siteXML.getLocationURI() != null) { >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_CATEGORY_SITE, URIUtil.toUnencodedString(siteXML.getLocationURI())); >+ } >+ ISiteDescription description = fSiteModel.getSite().getDescription(); >+ if (description != null && description.getName() != null && description.getName().length() > 0) { >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_METADATA_REPO_NAME, description.getName()); >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_ARTIFACT_REPO_NAME, description.getName()); >+ } >+ try { >+ String destination = new File(fBuildTempMetadataLocation).toURL().toString(); >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_BUILD_REPO, destination); >+ } catch (MalformedURLException e) { >+ PDECore.log(e); >+ } >+ } >+ } >+ >+} >Index: src/org/eclipse/pde/internal/core/exports/ProductExportOperation.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/exports/ProductExportOperation.java,v >retrieving revision 1.46 >diff -u -r1.46 ProductExportOperation.java >--- src/org/eclipse/pde/internal/core/exports/ProductExportOperation.java 19 Mar 2009 16:01:33 -0000 1.46 >+++ src/org/eclipse/pde/internal/core/exports/ProductExportOperation.java 1 Apr 2009 22:13:17 -0000 >@@ -1,486 +1,479 @@ >-/******************************************************************************* >- * Copyright (c) 2006, 2009 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.core.exports; >- >-import java.io.*; >-import java.lang.reflect.InvocationTargetException; >-import java.net.MalformedURLException; >-import java.net.URL; >-import java.util.*; >-import javax.xml.parsers.*; >-import org.eclipse.ant.core.AntRunner; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.runtime.*; >-import org.eclipse.osgi.service.resolver.BundleDescription; >-import org.eclipse.osgi.util.NLS; >-import org.eclipse.pde.core.plugin.*; >-import org.eclipse.pde.internal.build.*; >-import org.eclipse.pde.internal.build.packager.PackageScriptGenerator; >-import org.eclipse.pde.internal.core.*; >-import org.eclipse.pde.internal.core.ifeature.IFeature; >-import org.eclipse.pde.internal.core.ifeature.IFeatureModel; >-import org.eclipse.pde.internal.core.iproduct.*; >-import org.eclipse.pde.internal.core.iproduct.IProduct; >-import org.eclipse.pde.internal.core.util.CoreUtility; >-import org.w3c.dom.Document; >-import org.w3c.dom.Element; >- >-public class ProductExportOperation extends FeatureExportOperation { >- >- private String fFeatureLocation; >- private String fRoot; >- private IProduct fProduct; >- >- public ProductExportOperation(FeatureExportInfo info, String name, IProduct product, String root) { >- super(info, name); >- fProduct = product; >- fRoot = root; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.core.exports.FeatureExportOperation#run(org.eclipse.core.runtime.IProgressMonitor) >- */ >- protected IStatus run(IProgressMonitor monitor) { >- String[][] configurations = fInfo.targets; >- if (configurations == null) >- configurations = new String[][] {{TargetPlatform.getOS(), TargetPlatform.getWS(), TargetPlatform.getOSArch(), TargetPlatform.getNL()}}; >- >- Properties versionAdvice = new Properties(); >- try { >- monitor.beginTask("", 10 * configurations.length); //$NON-NLS-1$ >- for (int i = 0; i < configurations.length; i++) { >- try { >- String[] config = configurations[i]; >- if (config[0].equals("macosx") && fInfo.targets == null) //$NON-NLS-1$ >- createMacScript(config, new SubProgressMonitor(monitor, 1)); >- // create a feature to wrap all plug-ins and features >- String featureID = "org.eclipse.pde.container.feature"; //$NON-NLS-1$ >- fFeatureLocation = fBuildTempLocation + File.separator + featureID; >- >- createFeature(featureID, fFeatureLocation, config, true); >- createBuildPropertiesFile(fFeatureLocation, config); >- doExport(featureID, null, fFeatureLocation, config[0], config[1], config[2], new SubProgressMonitor(monitor, 8)); >- } catch (IOException e) { >- PDECore.log(e); >- } catch (InvocationTargetException e) { >- return new Status(IStatus.ERROR, PDECore.PLUGIN_ID, PDECoreMessages.FeatureBasedExportOperation_ProblemDuringExport, e.getTargetException()); >- } catch (CoreException e) { >- return e.getStatus(); >- } finally { >- >- // Append platform specific version information so that it is available for the p2 post script >- String versionsPrefix = fProduct.useFeatures() ? IPDEBuildConstants.DEFAULT_FEATURE_VERSION_FILENAME_PREFIX : IPDEBuildConstants.DEFAULT_PLUGIN_VERSION_FILENAME_PREFIX; >- File versionFile = new File(fFeatureLocation, versionsPrefix + IPDEBuildConstants.PROPERTIES_FILE_SUFFIX); >- InputStream stream = null; >- try { >- stream = new BufferedInputStream(new FileInputStream(versionFile)); >- versionAdvice.load(stream); >- } catch (IOException e) { >- } finally { >- try { >- if (stream != null) >- stream.close(); >- } catch (IOException e) { >- } >- } >- >- // Clean up generated files >- for (int j = 0; j < fInfo.items.length; j++) { >- try { >- deleteBuildFiles(fInfo.items[j]); >- } catch (CoreException e) { >- PDECore.log(e); >- } >- } >- cleanup(fInfo.targets == null ? null : configurations[i], new SubProgressMonitor(monitor, 1)); >- } >- } >- >- try { >- // Run postscript to generate p2 metadata for product >- String postScript = PackageScriptGenerator.generateP2ProductScript(fFeatureLocation, fProduct.getModel().getInstallLocation(), versionAdvice); >- if (postScript != null) { >- try { >- Map properties = new HashMap(); >- setP2MetaDataProperties(properties); >- runScript(postScript, null, properties, monitor); >- } catch (InvocationTargetException e) { >- return new Status(IStatus.ERROR, PDECore.PLUGIN_ID, PDECoreMessages.FeatureBasedExportOperation_ProblemDuringExport, e.getTargetException()); >- } >- } >- } catch (CoreException e) { >- return e.getStatus(); >- } >- >- cleanup(null, new SubProgressMonitor(monitor, 1)); >- if (hasAntErrors()) { >- return new Status(IStatus.WARNING, PDECore.PLUGIN_ID, NLS.bind(PDECoreMessages.FeatureExportOperation_CompilationErrors, fInfo.destinationDirectory)); >- } >- >- } finally { >- monitor.done(); >- } >- return Status.OK_STATUS; >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.pde.internal.ui.wizards.exports.FeatureExportJob#getPaths() >- */ >- protected String[] getPaths() { >- String[] paths = super.getPaths(); >- String[] all = new String[paths.length + 1]; >- all[0] = fFeatureLocation + File.separator + "feature.xml"; //$NON-NLS-1$ >- System.arraycopy(paths, 0, all, 1, paths.length); >- return all; >- } >- >- private void createBuildPropertiesFile(String featureLocation, String[] config) { >- File file = new File(featureLocation); >- if (!file.exists() || !file.isDirectory()) >- file.mkdirs(); >- >- boolean hasLaunchers = PDECore.getDefault().getFeatureModelManager().getDeltaPackFeature() != null; >- Properties properties = new Properties(); >- properties.put(IBuildPropertiesConstants.ROOT, getRootFileLocations(hasLaunchers)); //To copy a folder >- if (!hasLaunchers) { >- properties.put("root.permissions.755", getLauncherName()); //$NON-NLS-1$ >- if (TargetPlatform.getWS().equals("motif") && TargetPlatform.getOS().equals("linux")) { //$NON-NLS-1$ //$NON-NLS-2$ >- properties.put("root.linux.motif.x86.permissions.755", "libXm.so.2"); //$NON-NLS-1$ //$NON-NLS-2$ >- } else if (TargetPlatform.getOS().equals("macosx")) { //$NON-NLS-1$ >- properties.put("root.macosx.carbon.ppc.permissions.755", //$NON-NLS-1$ >- "${launcherName}.app/Contents/MacOS/${launcherName}"); //$NON-NLS-1$ >- } >- } >- >- IJREInfo jreInfo = fProduct.getJREInfo(); >- File vm = jreInfo != null ? jreInfo.getJVMLocation(config[0]) : null; >- if (vm != null) { >- properties.put("root." + config[0] + //$NON-NLS-1$ >- "." + config[1] + //$NON-NLS-1$ >- "." + config[2] + //$NON-NLS-1$ >- ".folder.jre", //$NON-NLS-1$ >- "absolute:" + vm.getAbsolutePath()); //$NON-NLS-1$ >- String perms = (String) properties.get("root.permissions.755"); //$NON-NLS-1$ >- if (perms != null) { >- StringBuffer buffer = new StringBuffer(perms); >- buffer.append(","); //$NON-NLS-1$ >- buffer.append("jre/bin/java"); //$NON-NLS-1$ >- properties.put("root.permissions.755", buffer.toString()); //$NON-NLS-1$ >- } >- } >- >- if (fInfo.exportSource && fInfo.exportSourceBundle) { >- properties.put("individualSourceBundles", "true"); //$NON-NLS-1$ //$NON-NLS-2$ >- Dictionary environment = new Hashtable(4); >- environment.put("osgi.os", TargetPlatform.getOS()); //$NON-NLS-1$ >- environment.put("osgi.ws", TargetPlatform.getWS()); //$NON-NLS-1$ >- environment.put("osgi.arch", TargetPlatform.getOSArch()); //$NON-NLS-1$ >- environment.put("osgi.nl", TargetPlatform.getNL()); //$NON-NLS-1$ >- List workspacePlugins = Arrays.asList(PluginRegistry.getWorkspaceModels()); >- for (int i = 0; i < fInfo.items.length; i++) { >- if (fInfo.items[i] instanceof IFeatureModel) { >- IFeature feature = ((IFeatureModel) fInfo.items[i]).getFeature(); >- properties.put("generate.feature@" + feature.getId() + ".source", feature.getId()); //$NON-NLS-1$ //$NON-NLS-2$ >- } else { >- BundleDescription bundle = null; >- if (fInfo.items[i] instanceof IPluginModelBase) { >- bundle = ((IPluginModelBase) fInfo.items[i]).getBundleDescription(); >- } >- if (bundle == null) { >- if (fInfo.items[i] instanceof BundleDescription) >- bundle = (BundleDescription) fInfo.items[i]; >- } >- if (bundle == null) >- continue; >- >- if (shouldAddPlugin(bundle, environment) && workspacePlugins.contains(PluginRegistry.findModel(bundle))) { >- properties.put("generate.plugin@" + bundle.getSymbolicName() + ".source", bundle.getSymbolicName()); //$NON-NLS-1$ //$NON-NLS-2$ >- } >- } >- } >- } >- save(new File(file, "build.properties"), properties, "Build Configuration"); //$NON-NLS-1$ //$NON-NLS-2$ >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.core.exports.FeatureExportOperation#publishingP2Metadata() >- */ >- protected boolean publishingP2Metadata() { >- //not supported yet >- return false; >- } >- >- private String getRootFileLocations(boolean hasLaunchers) { >- StringBuffer buffer = new StringBuffer(); >- >- File homeDir = new File(TargetPlatform.getLocation()); >- if (!hasLaunchers) { >- if (homeDir.exists() && homeDir.isDirectory()) { >- appendAbsolutePath(buffer, new File(homeDir, "startup.jar")); //$NON-NLS-1$ >- if (!TargetPlatform.getOS().equals("macosx")) { //$NON-NLS-1$ >- // try to retrieve the exact eclipse launcher path >- // see bug 205833 >- File file = null; >- if (System.getProperties().get("eclipse.launcher") != null) { //$NON-NLS-1$ >- String launcherPath = System.getProperties().get("eclipse.launcher").toString(); //$NON-NLS-1$ >- file = new File(launcherPath); >- if (file.exists() && !file.isDirectory()) { >- appendAbsolutePath(buffer, file); >- } else { // just assume traditional eclipse paths >- appendEclipsePath(buffer, homeDir); >- } >- } else { // just assume traditional eclipse paths >- appendEclipsePath(buffer, homeDir); >- } >- file = new File(homeDir, "libXm.so.2"); //$NON-NLS-1$ >- if (file.exists()) { >- appendAbsolutePath(buffer, file); >- } >- } >- } >- } >- >- return buffer.toString(); >- } >- >- private void appendEclipsePath(StringBuffer buffer, File homeDir) { >- File file = null; >- file = new File(homeDir, "eclipse"); //$NON-NLS-1$ >- if (file.exists()) { >- appendAbsolutePath(buffer, file); >- } >- file = new File(homeDir, "eclipse.exe"); //$NON-NLS-1$ >- if (file.exists()) { >- appendAbsolutePath(buffer, file); >- } >- } >- >- private void appendAbsolutePath(StringBuffer buffer, File file) { >- if (buffer.length() > 0) >- buffer.append(","); //$NON-NLS-1$ >- >- buffer.append("absolute:file:"); //$NON-NLS-1$ >- buffer.append(file.getAbsolutePath()); >- } >- >- protected HashMap createAntBuildProperties(String os, String ws, String arch) { >- HashMap properties = super.createAntBuildProperties(os, ws, arch); >- properties.put(IXMLConstants.PROPERTY_LAUNCHER_NAME, getLauncherName()); >- >- if (fProduct.includeLaunchers()) { >- properties.put("excludeLaunchers", IBuildPropertiesConstants.TRUE); //$NON-NLS-1$ >- } >- >- ILauncherInfo info = fProduct.getLauncherInfo(); >- if (info != null) { >- String images = null; >- if (os.equals("win32")) { //$NON-NLS-1$ >- images = getWin32Images(info); >- } else if (os.equals("solaris")) { //$NON-NLS-1$ >- images = getSolarisImages(info); >- } else if (os.equals("linux")) { //$NON-NLS-1$ >- images = getExpandedPath(info.getIconPath(ILauncherInfo.LINUX_ICON)); >- } else if (os.equals("macosx")) { //$NON-NLS-1$ >- images = getExpandedPath(info.getIconPath(ILauncherInfo.MACOSX_ICON)); >- } >- if (images != null && images.length() > 0) >- properties.put(IXMLConstants.PROPERTY_LAUNCHER_ICONS, images); >- } >- >- fAntBuildProperties.put(IXMLConstants.PROPERTY_COLLECTING_FOLDER, fRoot); >- fAntBuildProperties.put(IXMLConstants.PROPERTY_ARCHIVE_PREFIX, fRoot); >- >- return properties; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.core.exports.FeatureExportOperation#setP2MetaDataProperties(java.util.Map) >- */ >- protected void setP2MetaDataProperties(Map map) { >- if (fInfo.exportMetadata) { >- map.put(IXMLConstants.TARGET_P2_METADATA, IBuildPropertiesConstants.TRUE); >- map.put(IBuildPropertiesConstants.PROPERTY_P2_FLAVOR, P2Utils.P2_FLAVOR_DEFAULT); >- map.put(IBuildPropertiesConstants.PROPERTY_P2_PUBLISH_ARTIFACTS, IBuildPropertiesConstants.TRUE); >- map.put(IBuildPropertiesConstants.PROPERTY_P2_COMPRESS, IBuildPropertiesConstants.TRUE); >- try { >- map.put(IBuildPropertiesConstants.PROPERTY_P2_METADATA_REPO, new File(fInfo.destinationDirectory + "/repository").toURL().toString()); //$NON-NLS-1$ >- map.put(IBuildPropertiesConstants.PROPERTY_P2_ARTIFACT_REPO, new File(fInfo.destinationDirectory + "/repository").toURL().toString()); //$NON-NLS-1$ >- map.put(IBuildPropertiesConstants.PROPERTY_P2_METADATA_REPO_NAME, NLS.bind(PDECoreMessages.ProductExportOperation_0, fProduct.getProductId())); >- map.put(IBuildPropertiesConstants.PROPERTY_P2_ARTIFACT_REPO_NAME, NLS.bind(PDECoreMessages.ProductExportOperation_0, fProduct.getProductId())); >- } catch (MalformedURLException e) { >- PDECore.log(e); >- } >- } >- } >- >- private String getLauncherName() { >- ILauncherInfo info = fProduct.getLauncherInfo(); >- if (info != null) { >- String name = info.getLauncherName(); >- if (name != null && name.length() > 0) { >- name = name.trim(); >- if (name.endsWith(".exe")) //$NON-NLS-1$ >- name = name.substring(0, name.length() - 4); >- return name; >- } >- } >- return "eclipse"; //$NON-NLS-1$ >- } >- >- private String getWin32Images(ILauncherInfo info) { >- StringBuffer buffer = new StringBuffer(); >- if (info.usesWinIcoFile()) { >- append(buffer, info.getIconPath(ILauncherInfo.P_ICO_PATH)); >- } else { >- append(buffer, info.getIconPath(ILauncherInfo.WIN32_16_LOW)); >- append(buffer, info.getIconPath(ILauncherInfo.WIN32_16_HIGH)); >- append(buffer, info.getIconPath(ILauncherInfo.WIN32_32_HIGH)); >- append(buffer, info.getIconPath(ILauncherInfo.WIN32_32_LOW)); >- append(buffer, info.getIconPath(ILauncherInfo.WIN32_48_HIGH)); >- append(buffer, info.getIconPath(ILauncherInfo.WIN32_48_LOW)); >- } >- return buffer.length() > 0 ? buffer.toString() : null; >- } >- >- private String getSolarisImages(ILauncherInfo info) { >- StringBuffer buffer = new StringBuffer(); >- append(buffer, info.getIconPath(ILauncherInfo.SOLARIS_LARGE)); >- append(buffer, info.getIconPath(ILauncherInfo.SOLARIS_MEDIUM)); >- append(buffer, info.getIconPath(ILauncherInfo.SOLARIS_SMALL)); >- append(buffer, info.getIconPath(ILauncherInfo.SOLARIS_TINY)); >- return buffer.length() > 0 ? buffer.toString() : null; >- } >- >- private void append(StringBuffer buffer, String path) { >- path = getExpandedPath(path); >- if (path != null) { >- if (buffer.length() > 0) >- buffer.append(","); //$NON-NLS-1$ >- buffer.append(path); >- } >- } >- >- private String getExpandedPath(String path) { >- if (path == null || path.length() == 0) >- return null; >- IResource resource = PDECore.getWorkspace().getRoot().findMember(new Path(path)); >- if (resource != null) { >- IPath fullPath = resource.getLocation(); >- return fullPath == null ? null : fullPath.toOSString(); >- } >- return null; >- } >- >- protected void setupGenerator(BuildScriptGenerator generator, String featureID, String versionId, String os, String ws, String arch, String featureLocation) throws CoreException { >- super.setupGenerator(generator, featureID, versionId, os, ws, arch, featureLocation); >- generator.setGenerateVersionsList(true); >- if (fProduct != null) >- generator.setProduct(fProduct.getModel().getInstallLocation()); >- } >- >- private void createMacScript(String[] config, IProgressMonitor monitor) { >- String entryName = TargetPlatformHelper.getTargetVersion() >= 3.3 ? "macosx/Info.plist" //$NON-NLS-1$ >- : "macosx/Info.plist.32"; //$NON-NLS-1$ >- URL url = PDECore.getDefault().getBundle().getEntry(entryName); >- if (url == null) >- return; >- >- File scriptFile = null; >- File plist = null; >- InputStream in = null; >- String location = PDECore.getDefault().getStateLocation().toOSString(); >- try { >- in = url.openStream(); >- File dir = new File(location, "Eclipse.app/Contents"); //$NON-NLS-1$ >- dir.mkdirs(); >- plist = new File(dir, "Info.plist"); //$NON-NLS-1$ >- CoreUtility.readFile(in, plist); >- scriptFile = createScriptFile("macbuild.xml"); //$NON-NLS-1$ >- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); >- Document doc = factory.newDocumentBuilder().newDocument(); >- >- Element root = doc.createElement("project"); //$NON-NLS-1$ >- root.setAttribute("name", "project"); //$NON-NLS-1$ //$NON-NLS-2$ >- root.setAttribute("default", "default"); //$NON-NLS-1$ //$NON-NLS-2$ >- doc.appendChild(root); >- >- Element property = doc.createElement("property"); //$NON-NLS-1$ >- property.setAttribute("name", "eclipse.base"); //$NON-NLS-1$ //$NON-NLS-2$ >- property.setAttribute("value", "${assemblyTempDir}/${collectingFolder}"); //$NON-NLS-1$ //$NON-NLS-2$ >- root.appendChild(property); >- >- Element target = doc.createElement("target"); //$NON-NLS-1$ >- target.setAttribute("name", "default"); //$NON-NLS-1$ //$NON-NLS-2$ >- root.appendChild(target); >- >- Element copy = doc.createElement("copy"); //$NON-NLS-1$ >- StringBuffer toDir = new StringBuffer("${eclipse.base}/"); //$NON-NLS-1$ >- toDir.append(config[0]); >- toDir.append("."); //$NON-NLS-1$ >- toDir.append(config[1]); >- toDir.append("."); //$NON-NLS-1$ >- toDir.append(config[2]); >- toDir.append("/${collectingFolder}"); //$NON-NLS-1$ >- copy.setAttribute("todir", toDir.toString()); //$NON-NLS-1$ >- copy.setAttribute("failonerror", "false"); //$NON-NLS-1$ //$NON-NLS-2$ >- copy.setAttribute("overwrite", "true"); //$NON-NLS-1$ //$NON-NLS-2$ >- target.appendChild(copy); >- >- Element fileset = doc.createElement("fileset"); //$NON-NLS-1$ >- fileset.setAttribute("dir", "${installFolder}"); //$NON-NLS-1$ //$NON-NLS-2$ >- fileset.setAttribute("includes", "Eclipse.app/Contents/MacOS/eclipse"); //$NON-NLS-1$ //$NON-NLS-2$ >- copy.appendChild(fileset); >- >- fileset = doc.createElement("fileset"); //$NON-NLS-1$ >- fileset.setAttribute("dir", "${template}"); //$NON-NLS-1$ //$NON-NLS-2$ >- fileset.setAttribute("includes", "Eclipse.app/Contents/Info.plist"); //$NON-NLS-1$ //$NON-NLS-2$ >- copy.appendChild(fileset); >- >- XMLPrintHandler.writeFile(doc, scriptFile); >- >- AntRunner runner = new AntRunner(); >- HashMap map = new HashMap(); >- if (!fInfo.toDirectory) { >- String filename = fInfo.zipFileName; >- map.put(IXMLConstants.PROPERTY_ARCHIVE_FULLPATH, fInfo.destinationDirectory + File.separator + filename); >- } else { >- map.put(IXMLConstants.PROPERTY_ASSEMBLY_TMP, fInfo.destinationDirectory); >- } >- map.put(IXMLConstants.PROPERTY_COLLECTING_FOLDER, fRoot); >- map.put("installFolder", TargetPlatform.getLocation()); //$NON-NLS-1$ >- map.put("template", location); //$NON-NLS-1$ >- runner.addUserProperties(map); >- runner.setBuildFileLocation(scriptFile.getAbsolutePath()); >- runner.setExecutionTargets(new String[] {"default"}); //$NON-NLS-1$ >- runner.run(new SubProgressMonitor(monitor, 1)); >- } catch (FactoryConfigurationError e) { >- } catch (ParserConfigurationException e) { >- } catch (CoreException e) { >- } catch (IOException e) { >- } finally { >- try { >- if (in != null) >- in.close(); >- } catch (IOException e) { >- } >- CoreUtility.deleteContent(new File(location, "Eclipse.app")); //$NON-NLS-1$ >- if (scriptFile != null && scriptFile.exists()) >- scriptFile.delete(); >- monitor.done(); >- } >- } >- >- protected void setAdditionalAttributes(Element plugin, BundleDescription bundle) { >- plugin.setAttribute("unpack", Boolean.toString(CoreUtility.guessUnpack(bundle))); //$NON-NLS-1$ >- } >-} >+/******************************************************************************* >+ * Copyright (c) 2006, 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.core.exports; >+ >+import java.io.*; >+import java.lang.reflect.InvocationTargetException; >+import java.net.MalformedURLException; >+import java.net.URL; >+import java.util.*; >+import javax.xml.parsers.*; >+import org.eclipse.ant.core.AntRunner; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.*; >+import org.eclipse.osgi.service.resolver.BundleDescription; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.pde.core.plugin.*; >+import org.eclipse.pde.internal.build.*; >+import org.eclipse.pde.internal.core.*; >+import org.eclipse.pde.internal.core.ifeature.IFeature; >+import org.eclipse.pde.internal.core.ifeature.IFeatureModel; >+import org.eclipse.pde.internal.core.iproduct.*; >+import org.eclipse.pde.internal.core.iproduct.IProduct; >+import org.eclipse.pde.internal.core.util.CoreUtility; >+import org.w3c.dom.Document; >+import org.w3c.dom.Element; >+ >+public class ProductExportOperation extends FeatureExportOperation { >+ >+ private String fFeatureLocation; >+ private String fRoot; >+ private IProduct fProduct; >+ >+ public ProductExportOperation(FeatureExportInfo info, String name, IProduct product, String root) { >+ super(info, name); >+ fProduct = product; >+ fRoot = root; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.exports.FeatureExportOperation#run(org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ protected IStatus run(IProgressMonitor monitor) { >+ String[][] configurations = fInfo.targets; >+ if (configurations == null) >+ configurations = new String[][] {{TargetPlatform.getOS(), TargetPlatform.getWS(), TargetPlatform.getOSArch(), TargetPlatform.getNL()}}; >+ >+ cleanupBuildRepo(); >+ >+ try { >+ monitor.beginTask("", 10); //$NON-NLS-1$ >+ try { >+ if (fInfo.targets == null && configurations.length > 0) { >+ String[] config = configurations[0]; >+ if (config[0].equals("macosx")) //$NON-NLS-1$ >+ createMacScript(config, new SubProgressMonitor(monitor, 1)); >+ } >+ // create a feature to wrap all plug-ins and features >+ String featureID = "org.eclipse.pde.container.feature"; //$NON-NLS-1$ >+ fFeatureLocation = fBuildTempLocation + File.separator + featureID; >+ >+ createFeature(featureID, fFeatureLocation, configurations, true); >+ createBuildPropertiesFile(fFeatureLocation, configurations); >+ doExport(featureID, null, fFeatureLocation, configurations, new SubProgressMonitor(monitor, 8)); >+ } catch (IOException e) { >+ PDECore.log(e); >+ } catch (InvocationTargetException e) { >+ return new Status(IStatus.ERROR, PDECore.PLUGIN_ID, PDECoreMessages.FeatureBasedExportOperation_ProblemDuringExport, e.getTargetException()); >+ } catch (CoreException e) { >+ return e.getStatus(); >+ } finally { >+ // Clean up generated files >+ for (int j = 0; j < fInfo.items.length; j++) { >+ try { >+ deleteBuildFiles(fInfo.items[j]); >+ } catch (CoreException e) { >+ PDECore.log(e); >+ } >+ } >+ cleanup(null, new SubProgressMonitor(monitor, 1)); >+ } >+ >+ if (hasAntErrors()) { >+ return new Status(IStatus.WARNING, PDECore.PLUGIN_ID, NLS.bind(PDECoreMessages.FeatureExportOperation_CompilationErrors, fInfo.destinationDirectory)); >+ } >+ >+ } finally { >+ monitor.done(); >+ } >+ return Status.OK_STATUS; >+ } >+ >+ protected boolean groupedConfigurations() { >+ // we never group product exports >+ return false; >+ } >+ >+ private void cleanupBuildRepo() { >+ File metadataTemp = new File(fBuildTempMetadataLocation); >+ if (metadataTemp.exists()) { >+ //make sure our build metadata repo is clean >+ deleteDir(metadataTemp); >+ } >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.pde.internal.ui.wizards.exports.FeatureExportJob#getPaths() >+ */ >+ protected String[] getPaths() { >+ String[] paths = super.getPaths(); >+ String[] all = new String[paths.length + 1]; >+ all[0] = fFeatureLocation + File.separator + "feature.xml"; //$NON-NLS-1$ >+ System.arraycopy(paths, 0, all, 1, paths.length); >+ return all; >+ } >+ >+ private void createBuildPropertiesFile(String featureLocation, String[][] configurations) { >+ File file = new File(featureLocation); >+ if (!file.exists() || !file.isDirectory()) >+ file.mkdirs(); >+ >+ boolean hasLaunchers = PDECore.getDefault().getFeatureModelManager().getDeltaPackFeature() != null; >+ Properties properties = new Properties(); >+ if (!hasLaunchers && configurations.length > 0) { >+ String rootPrefix = "root." + configurations[0][0] + //$NON-NLS-1$ >+ "." + configurations[0][1] + //$NON-NLS-1$ >+ "." + configurations[0][2]; //$NON-NLS-1$ >+ properties.put(rootPrefix, getRootFileLocations(hasLaunchers)); //To copy a folder >+ properties.put("root.permissions.755", getLauncherName()); //$NON-NLS-1$ >+ if (TargetPlatform.getWS().equals("motif") && TargetPlatform.getOS().equals("linux")) { //$NON-NLS-1$ //$NON-NLS-2$ >+ properties.put("root.linux.motif.x86.permissions.755", "libXm.so.2"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } else if (TargetPlatform.getOS().equals("macosx")) { //$NON-NLS-1$ >+ properties.put("root.macosx.carbon.ppc.permissions.755", //$NON-NLS-1$ >+ "${launcherName}.app/Contents/MacOS/${launcherName}"); //$NON-NLS-1$ >+ } >+ } >+ >+ IJREInfo jreInfo = fProduct.getJREInfo(); >+ for (int i = 0; i < configurations.length; i++) { >+ String[] config = configurations[i]; >+ File vm = jreInfo != null ? jreInfo.getJVMLocation(config[0]) : null; >+ >+ if (vm != null) { >+ String rootPrefix = "root." + config[0] + //$NON-NLS-1$ >+ "." + config[1] + //$NON-NLS-1$ >+ "." + config[2]; //$NON-NLS-1$ >+ properties.put(rootPrefix + ".folder.jre", "absolute:" + vm.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$ >+ String perms = (String) properties.get(rootPrefix + ".permissions.755"); //$NON-NLS-1$ >+ if (perms != null) { >+ StringBuffer buffer = new StringBuffer(perms); >+ buffer.append(","); //$NON-NLS-1$ >+ buffer.append("jre/bin/java"); //$NON-NLS-1$ >+ properties.put(rootPrefix + ".permissions.755", buffer.toString()); //$NON-NLS-1$ >+ } >+ } >+ } >+ >+ if (fInfo.exportSource && fInfo.exportSourceBundle) { >+ properties.put("individualSourceBundles", "true"); //$NON-NLS-1$ //$NON-NLS-2$ >+ List workspacePlugins = Arrays.asList(PluginRegistry.getWorkspaceModels()); >+ for (int i = 0; i < fInfo.items.length; i++) { >+ if (fInfo.items[i] instanceof IFeatureModel) { >+ IFeature feature = ((IFeatureModel) fInfo.items[i]).getFeature(); >+ properties.put("generate.feature@" + feature.getId() + ".source", feature.getId()); //$NON-NLS-1$ //$NON-NLS-2$ >+ } else { >+ BundleDescription bundle = null; >+ if (fInfo.items[i] instanceof IPluginModelBase) { >+ bundle = ((IPluginModelBase) fInfo.items[i]).getBundleDescription(); >+ } >+ if (bundle == null) { >+ if (fInfo.items[i] instanceof BundleDescription) >+ bundle = (BundleDescription) fInfo.items[i]; >+ } >+ if (bundle == null) >+ continue; >+ >+ //it doesn't matter if we generate extra properties for platforms we aren't exporting for >+ if (workspacePlugins.contains(PluginRegistry.findModel(bundle))) { >+ properties.put("generate.plugin@" + bundle.getSymbolicName() + ".source", bundle.getSymbolicName()); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ } >+ } >+ } >+ save(new File(file, "build.properties"), properties, "Build Configuration"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.exports.FeatureExportOperation#publishingP2Metadata() >+ */ >+ protected boolean publishingP2Metadata() { >+ return fInfo.exportMetadata; >+ } >+ >+ private String getRootFileLocations(boolean hasLaunchers) { >+ StringBuffer buffer = new StringBuffer(); >+ >+ File homeDir = new File(TargetPlatform.getLocation()); >+ if (!hasLaunchers) { >+ if (homeDir.exists() && homeDir.isDirectory()) { >+ appendAbsolutePath(buffer, new File(homeDir, "startup.jar")); //$NON-NLS-1$ >+ if (!TargetPlatform.getOS().equals("macosx")) { //$NON-NLS-1$ >+ // try to retrieve the exact eclipse launcher path >+ // see bug 205833 >+ File file = null; >+ if (System.getProperties().get("eclipse.launcher") != null) { //$NON-NLS-1$ >+ String launcherPath = System.getProperties().get("eclipse.launcher").toString(); //$NON-NLS-1$ >+ file = new File(launcherPath); >+ if (file.exists() && !file.isDirectory()) { >+ appendAbsolutePath(buffer, file); >+ } else { // just assume traditional eclipse paths >+ appendEclipsePath(buffer, homeDir); >+ } >+ } else { // just assume traditional eclipse paths >+ appendEclipsePath(buffer, homeDir); >+ } >+ file = new File(homeDir, "libXm.so.2"); //$NON-NLS-1$ >+ if (file.exists()) { >+ appendAbsolutePath(buffer, file); >+ } >+ } >+ } >+ } >+ >+ return buffer.toString(); >+ } >+ >+ private void appendEclipsePath(StringBuffer buffer, File homeDir) { >+ File file = null; >+ file = new File(homeDir, "eclipse"); //$NON-NLS-1$ >+ if (file.exists()) { >+ appendAbsolutePath(buffer, file); >+ } >+ file = new File(homeDir, "eclipse.exe"); //$NON-NLS-1$ >+ if (file.exists()) { >+ appendAbsolutePath(buffer, file); >+ } >+ } >+ >+ private void appendAbsolutePath(StringBuffer buffer, File file) { >+ if (buffer.length() > 0) >+ buffer.append(","); //$NON-NLS-1$ >+ >+ buffer.append("absolute:file:"); //$NON-NLS-1$ >+ buffer.append(file.getAbsolutePath()); >+ } >+ >+ protected HashMap createAntBuildProperties(String[][] configs) { >+ HashMap properties = super.createAntBuildProperties(configs); >+ properties.put(IXMLConstants.PROPERTY_LAUNCHER_NAME, getLauncherName()); >+ >+ if (fProduct.includeLaunchers()) { >+ properties.put("excludeLaunchers", IBuildPropertiesConstants.TRUE); //$NON-NLS-1$ >+ } >+ >+ ILauncherInfo info = fProduct.getLauncherInfo(); >+ if (info != null) { >+ String icons = ""; //$NON-NLS-1$ >+ for (int i = 0; i < configs.length; i++) { >+ String images = null; >+ if (configs[i][0].equals("win32")) { //$NON-NLS-1$ >+ images = getWin32Images(info); >+ } else if (configs[i][0].equals("solaris")) { //$NON-NLS-1$ >+ images = getSolarisImages(info); >+ } else if (configs[i][0].equals("linux")) { //$NON-NLS-1$ >+ images = getExpandedPath(info.getIconPath(ILauncherInfo.LINUX_ICON)); >+ } else if (configs[i][0].equals("macosx")) { //$NON-NLS-1$ >+ images = getExpandedPath(info.getIconPath(ILauncherInfo.MACOSX_ICON)); >+ } >+ if (images != null) { >+ if (icons.length() > 0) >+ icons += ","; //$NON-NLS-1$ >+ icons += images; >+ } >+ >+ } >+ if (icons != null && icons.length() > 0) >+ properties.put(IXMLConstants.PROPERTY_LAUNCHER_ICONS, icons); >+ } >+ >+ fAntBuildProperties.put(IXMLConstants.PROPERTY_COLLECTING_FOLDER, fRoot); >+ fAntBuildProperties.put(IXMLConstants.PROPERTY_ARCHIVE_PREFIX, fRoot); >+ >+ return properties; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.core.exports.FeatureExportOperation#setP2MetaDataProperties(java.util.Map) >+ */ >+ protected void setP2MetaDataProperties(Map map) { >+ if (fInfo.exportMetadata) { >+ if (PDECore.getDefault().getFeatureModelManager().getDeltaPackFeature() == null) >+ map.put(IXMLConstants.PROPERTY_LAUNCHER_PROVIDER, "org.eclipse.pde.container.feature"); //$NON-NLS-1$ >+ map.put(IXMLConstants.TARGET_P2_METADATA, IBuildPropertiesConstants.TRUE); >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_FLAVOR, P2Utils.P2_FLAVOR_DEFAULT); >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_PUBLISH_ARTIFACTS, IBuildPropertiesConstants.TRUE); >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_COMPRESS, IBuildPropertiesConstants.TRUE); >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_GATHERING, Boolean.toString(publishingP2Metadata())); >+ try { >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_BUILD_REPO, new File(fBuildTempMetadataLocation).toURL().toString()); >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_METADATA_REPO, new File(fInfo.destinationDirectory + "/repository").toURL().toString()); //$NON-NLS-1$ >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_ARTIFACT_REPO, new File(fInfo.destinationDirectory + "/repository").toURL().toString()); //$NON-NLS-1$ >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_METADATA_REPO_NAME, NLS.bind(PDECoreMessages.ProductExportOperation_0, fProduct.getProductId())); >+ map.put(IBuildPropertiesConstants.PROPERTY_P2_ARTIFACT_REPO_NAME, NLS.bind(PDECoreMessages.ProductExportOperation_0, fProduct.getProductId())); >+ } catch (MalformedURLException e) { >+ PDECore.log(e); >+ } >+ } >+ } >+ >+ private String getLauncherName() { >+ ILauncherInfo info = fProduct.getLauncherInfo(); >+ if (info != null) { >+ String name = info.getLauncherName(); >+ if (name != null && name.length() > 0) { >+ name = name.trim(); >+ if (name.endsWith(".exe")) //$NON-NLS-1$ >+ name = name.substring(0, name.length() - 4); >+ return name; >+ } >+ } >+ return "eclipse"; //$NON-NLS-1$ >+ } >+ >+ private String getWin32Images(ILauncherInfo info) { >+ StringBuffer buffer = new StringBuffer(); >+ if (info.usesWinIcoFile()) { >+ append(buffer, info.getIconPath(ILauncherInfo.P_ICO_PATH)); >+ } else { >+ append(buffer, info.getIconPath(ILauncherInfo.WIN32_16_LOW)); >+ append(buffer, info.getIconPath(ILauncherInfo.WIN32_16_HIGH)); >+ append(buffer, info.getIconPath(ILauncherInfo.WIN32_32_HIGH)); >+ append(buffer, info.getIconPath(ILauncherInfo.WIN32_32_LOW)); >+ append(buffer, info.getIconPath(ILauncherInfo.WIN32_48_HIGH)); >+ append(buffer, info.getIconPath(ILauncherInfo.WIN32_48_LOW)); >+ } >+ return buffer.length() > 0 ? buffer.toString() : null; >+ } >+ >+ private String getSolarisImages(ILauncherInfo info) { >+ StringBuffer buffer = new StringBuffer(); >+ append(buffer, info.getIconPath(ILauncherInfo.SOLARIS_LARGE)); >+ append(buffer, info.getIconPath(ILauncherInfo.SOLARIS_MEDIUM)); >+ append(buffer, info.getIconPath(ILauncherInfo.SOLARIS_SMALL)); >+ append(buffer, info.getIconPath(ILauncherInfo.SOLARIS_TINY)); >+ return buffer.length() > 0 ? buffer.toString() : null; >+ } >+ >+ private void append(StringBuffer buffer, String path) { >+ path = getExpandedPath(path); >+ if (path != null) { >+ if (buffer.length() > 0) >+ buffer.append(","); //$NON-NLS-1$ >+ buffer.append(path); >+ } >+ } >+ >+ private String getExpandedPath(String path) { >+ if (path == null || path.length() == 0) >+ return null; >+ IResource resource = PDECore.getWorkspace().getRoot().findMember(new Path(path)); >+ if (resource != null) { >+ IPath fullPath = resource.getLocation(); >+ return fullPath == null ? null : fullPath.toOSString(); >+ } >+ return null; >+ } >+ >+ protected void setupGenerator(BuildScriptGenerator generator, String featureID, String versionId, String[][] configs, String featureLocation) throws CoreException { >+ super.setupGenerator(generator, featureID, versionId, configs, featureLocation); >+ generator.setGenerateVersionsList(true); >+ if (fProduct != null) >+ generator.setProduct(fProduct.getModel().getInstallLocation()); >+ } >+ >+ private void createMacScript(String[] config, IProgressMonitor monitor) { >+ String entryName = TargetPlatformHelper.getTargetVersion() >= 3.3 ? "macosx/Info.plist" //$NON-NLS-1$ >+ : "macosx/Info.plist.32"; //$NON-NLS-1$ >+ URL url = PDECore.getDefault().getBundle().getEntry(entryName); >+ if (url == null) >+ return; >+ >+ File scriptFile = null; >+ File plist = null; >+ InputStream in = null; >+ String location = PDECore.getDefault().getStateLocation().toOSString(); >+ try { >+ in = url.openStream(); >+ File dir = new File(location, "Eclipse.app/Contents"); //$NON-NLS-1$ >+ dir.mkdirs(); >+ plist = new File(dir, "Info.plist"); //$NON-NLS-1$ >+ CoreUtility.readFile(in, plist); >+ scriptFile = createScriptFile("macbuild.xml"); //$NON-NLS-1$ >+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); >+ Document doc = factory.newDocumentBuilder().newDocument(); >+ >+ Element root = doc.createElement("project"); //$NON-NLS-1$ >+ root.setAttribute("name", "project"); //$NON-NLS-1$ //$NON-NLS-2$ >+ root.setAttribute("default", "default"); //$NON-NLS-1$ //$NON-NLS-2$ >+ doc.appendChild(root); >+ >+ Element property = doc.createElement("property"); //$NON-NLS-1$ >+ property.setAttribute("name", "eclipse.base"); //$NON-NLS-1$ //$NON-NLS-2$ >+ property.setAttribute("value", "${assemblyTempDir}/${collectingFolder}"); //$NON-NLS-1$ //$NON-NLS-2$ >+ root.appendChild(property); >+ >+ Element target = doc.createElement("target"); //$NON-NLS-1$ >+ target.setAttribute("name", "default"); //$NON-NLS-1$ //$NON-NLS-2$ >+ root.appendChild(target); >+ >+ Element copy = doc.createElement("copy"); //$NON-NLS-1$ >+ StringBuffer toDir = new StringBuffer("${eclipse.base}/"); //$NON-NLS-1$ >+ toDir.append(config[0]); >+ toDir.append("."); //$NON-NLS-1$ >+ toDir.append(config[1]); >+ toDir.append("."); //$NON-NLS-1$ >+ toDir.append(config[2]); >+ toDir.append("/${collectingFolder}"); //$NON-NLS-1$ >+ copy.setAttribute("todir", toDir.toString()); //$NON-NLS-1$ >+ copy.setAttribute("failonerror", "false"); //$NON-NLS-1$ //$NON-NLS-2$ >+ copy.setAttribute("overwrite", "true"); //$NON-NLS-1$ //$NON-NLS-2$ >+ target.appendChild(copy); >+ >+ Element fileset = doc.createElement("fileset"); //$NON-NLS-1$ >+ fileset.setAttribute("dir", "${installFolder}"); //$NON-NLS-1$ //$NON-NLS-2$ >+ fileset.setAttribute("includes", "Eclipse.app/Contents/MacOS/eclipse"); //$NON-NLS-1$ //$NON-NLS-2$ >+ copy.appendChild(fileset); >+ >+ fileset = doc.createElement("fileset"); //$NON-NLS-1$ >+ fileset.setAttribute("dir", "${template}"); //$NON-NLS-1$ //$NON-NLS-2$ >+ fileset.setAttribute("includes", "Eclipse.app/Contents/Info.plist"); //$NON-NLS-1$ //$NON-NLS-2$ >+ copy.appendChild(fileset); >+ >+ XMLPrintHandler.writeFile(doc, scriptFile); >+ >+ AntRunner runner = new AntRunner(); >+ HashMap map = new HashMap(); >+ if (!fInfo.toDirectory) { >+ String filename = fInfo.zipFileName; >+ map.put(IXMLConstants.PROPERTY_ARCHIVE_FULLPATH, fInfo.destinationDirectory + File.separator + filename); >+ } else { >+ map.put(IXMLConstants.PROPERTY_ASSEMBLY_TMP, fInfo.destinationDirectory); >+ } >+ map.put(IXMLConstants.PROPERTY_COLLECTING_FOLDER, fRoot); >+ map.put("installFolder", TargetPlatform.getLocation()); //$NON-NLS-1$ >+ map.put("template", location); //$NON-NLS-1$ >+ runner.addUserProperties(map); >+ runner.setBuildFileLocation(scriptFile.getAbsolutePath()); >+ runner.setExecutionTargets(new String[] {"default"}); //$NON-NLS-1$ >+ runner.run(new SubProgressMonitor(monitor, 1)); >+ } catch (FactoryConfigurationError e) { >+ } catch (ParserConfigurationException e) { >+ } catch (CoreException e) { >+ } catch (IOException e) { >+ } finally { >+ try { >+ if (in != null) >+ in.close(); >+ } catch (IOException e) { >+ } >+ CoreUtility.deleteContent(new File(location, "Eclipse.app")); //$NON-NLS-1$ >+ if (scriptFile != null && scriptFile.exists()) >+ scriptFile.delete(); >+ monitor.done(); >+ } >+ } >+ >+ protected void setAdditionalAttributes(Element plugin, BundleDescription bundle) { >+ plugin.setAttribute("unpack", Boolean.toString(CoreUtility.guessUnpack(bundle))); //$NON-NLS-1$ >+ } >+} >Index: src/org/eclipse/pde/internal/core/exports/FeatureExportOperation.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/exports/FeatureExportOperation.java,v >retrieving revision 1.28 >diff -u -r1.28 FeatureExportOperation.java >--- src/org/eclipse/pde/internal/core/exports/FeatureExportOperation.java 19 Mar 2009 16:01:33 -0000 1.28 >+++ src/org/eclipse/pde/internal/core/exports/FeatureExportOperation.java 1 Apr 2009 22:13:17 -0000 >@@ -57,6 +57,7 @@ > protected static String FEATURE_POST_PROCESSING = "features.postProcessingSteps.properties"; //$NON-NLS-1$ > protected static String PLUGIN_POST_PROCESSING = "plugins.postProcessingSteps.properties"; //$NON-NLS-1$ > >+ private static final String[] GENERIC_CONFIG = new String[] {"*", "*", "*", ""}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ > protected FeatureExportInfo fInfo; > > public FeatureExportOperation(FeatureExportInfo info, String name) { >@@ -80,7 +81,7 @@ > if (configurations == null) > configurations = new String[][] {null}; > >- monitor.beginTask("Exporting...", (configurations.length * fInfo.items.length * 23) + (configurations.length * 5) + 10); //$NON-NLS-1$ >+ monitor.beginTask("Exporting...", (fInfo.items.length * 23) + 5 + 10); //$NON-NLS-1$ > IStatus status = testBuildWorkspaceBeforeExport(new SubProgressMonitor(monitor, 10)); > > if (fInfo.exportSource && fInfo.exportSourceBundle) { >@@ -100,20 +101,15 @@ > doExport(model, null, new SubProgressMonitor(monitor, 20)); > > } else { >- for (int i = 0; i < configurations.length; i++) { >- for (int j = 0; j < fInfo.items.length; j++) { >- if (monitor.isCanceled()) >- return Status.CANCEL_STATUS; >- try { >- doExport((IFeatureModel) fInfo.items[j], configurations[i], new SubProgressMonitor(monitor, 20)); >- } catch (CoreException e) { >- return e.getStatus(); >- } finally { >- cleanup(configurations[i], new SubProgressMonitor(monitor, 3)); >- } >- } >- if (fInfo.exportMetadata && !fInfo.toDirectory) { >- appendMetadataToArchive(configurations[i], new SubProgressMonitor(monitor, 5)); >+ for (int j = 0; j < fInfo.items.length; j++) { >+ if (monitor.isCanceled()) >+ return Status.CANCEL_STATUS; >+ try { >+ doExport((IFeatureModel) fInfo.items[j], configurations, new SubProgressMonitor(monitor, 20)); >+ } catch (CoreException e) { >+ return e.getStatus(); >+ } finally { >+ cleanup(null, new SubProgressMonitor(monitor, 3)); > } > } > } >@@ -201,7 +197,7 @@ > } > > private void createDestination(String os, String ws, String arch) throws InvocationTargetException { >- if (!fInfo.toDirectory) >+ if (!fInfo.toDirectory || groupedConfigurations()) > return; > File file = new File(fInfo.destinationDirectory, os + '.' + ws + '.' + arch); > if (!file.exists() || !file.isDirectory()) { >@@ -210,15 +206,22 @@ > } > } > >- private void doExport(IFeatureModel model, String os, String ws, String arch, IProgressMonitor monitor) throws CoreException, InvocationTargetException { >+ private void doExport(IFeatureModel model, String[][] configs, IProgressMonitor monitor) throws CoreException, InvocationTargetException { >+ IFeature feature = model.getFeature(); >+ if (configs == null || configs.length == 0 || configs[0] == null) { >+ configs = new String[][] {{getOS(feature), getWS(feature), getOSArch(feature)}}; >+ } else { >+ for (int i = 0; i < configs.length; i++) { >+ createDestination(configs[i][0], configs[i][1], configs[i][2]); >+ } >+ } > try { > String location = model.getInstallLocation(); > if (fInfo.useJarFormat) { > createPostProcessingFile(new File(location, FEATURE_POST_PROCESSING)); > createPostProcessingFile(new File(location, PLUGIN_POST_PROCESSING)); > } >- IFeature feature = model.getFeature(); >- doExport(feature.getId(), feature.getVersion(), location, os, ws, arch, monitor); >+ doExport(feature.getId(), feature.getVersion(), location, configs, monitor); > } finally { > deleteBuildFiles(model); > } >@@ -242,15 +245,15 @@ > } > } > >- protected void doExport(String featureID, String version, String featureLocation, String os, String ws, String arch, IProgressMonitor monitor) throws CoreException, InvocationTargetException { >+ protected void doExport(String featureID, String version, String featureLocation, String[][] configs, IProgressMonitor monitor) throws CoreException, InvocationTargetException { > fHasErrors = false; > > try { >- monitor.beginTask("", 10 + (publishingP2Metadata() ? 2 : 0)); //$NON-NLS-1$ >+ monitor.beginTask("", 6 + (configs.length * 4) + (publishingP2Metadata() ? 2 : 0)); //$NON-NLS-1$ > monitor.setTaskName(PDECoreMessages.FeatureExportJob_taskName); >- HashMap properties = createAntBuildProperties(os, ws, arch); >+ HashMap properties = createAntBuildProperties(configs); > BuildScriptGenerator generator = new BuildScriptGenerator(); >- setupGenerator(generator, featureID, version, os, ws, arch, featureLocation); >+ setupGenerator(generator, featureID, version, configs, featureLocation); > generator.generate(); > monitor.worked(1); > monitor.setTaskName(PDECoreMessages.FeatureExportOperation_runningBuildScript); >@@ -263,20 +266,53 @@ > if (publishingP2Metadata()) { > monitor.setTaskName(PDECoreMessages.FeatureExportOperation_publishingMetadata); > runScript(getAssembleP2ScriptName(featureID, featureLocation), new String[] {"main"}, properties, new SubProgressMonitor(monitor, 2)); //$NON-NLS-1$ >+ >+ //metadata implies groups if we aren't exporting products >+ if (groupedConfigurations()) { >+ configs = new String[][] {{"group", "group", "group"}}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ } > } > > monitor.setTaskName(PDECoreMessages.FeatureExportOperation_runningAssemblyScript); >- runScript(getAssemblyScriptName(featureID, os, ws, arch, featureLocation), new String[] {"main"}, //$NON-NLS-1$ >- properties, new SubProgressMonitor(monitor, 2)); >+ for (int i = 0; i < configs.length; i++) { >+ setArchiveLocation(properties, configs[i][0], configs[i][1], configs[i][2]); >+ runScript(getAssemblyScriptName(featureID, configs[i][0], configs[i][1], configs[i][2], featureLocation), new String[] {"main"}, //$NON-NLS-1$ >+ properties, new SubProgressMonitor(monitor, 2)); >+ } >+ > monitor.setTaskName(PDECoreMessages.FeatureExportOperation_runningPackagerScript); >- runScript(getPackagerScriptName(featureID, os, ws, arch, featureLocation), null, properties, new SubProgressMonitor(monitor, 2)); >+ for (int i = 0; i < configs.length; i++) { >+ setArchiveLocation(properties, configs[i][0], configs[i][1], configs[i][2]); >+ runScript(getPackagerScriptName(featureID, configs[i][0], configs[i][1], configs[i][2], featureLocation), null, properties, new SubProgressMonitor(monitor, 2)); >+ } > properties.put("destination.temp.folder", fBuildTempLocation + "/pde.logs"); //$NON-NLS-1$ //$NON-NLS-2$ >- runScript(getBuildScriptName(featureLocation), new String[] {"gather.logs"}, properties, new SubProgressMonitor(monitor, 2)); //$NON-NLS-1$ >+ runScript(getBuildScriptName(featureLocation), new String[] {"gather.logs"}, properties, new SubProgressMonitor(monitor, 2)); //$NON-NLS-1$ > } finally { > monitor.done(); > } > } > >+ protected boolean groupedConfigurations() { >+ //feature export with p2 metadata results in a grouped repo >+ return publishingP2Metadata(); >+ } >+ >+ private void setArchiveLocation(Map antProperties, String os, String ws, String arch) { >+ if (!fInfo.toDirectory) { >+ String filename = fInfo.zipFileName; >+ if (fInfo.targets != null && !groupedConfigurations()) { >+ int i = filename.lastIndexOf('.'); >+ filename = filename.substring(0, i) + '.' + os + '.' + ws + '.' + arch + filename.substring(i); >+ } >+ antProperties.put(IXMLConstants.PROPERTY_ARCHIVE_FULLPATH, fInfo.destinationDirectory + File.separator + filename); >+ } else { >+ String dir = fInfo.destinationDirectory; >+ if (fInfo.targets != null && !groupedConfigurations()) >+ dir += File.separatorChar + os + '.' + ws + '.' + arch; >+ antProperties.put(IXMLConstants.PROPERTY_ASSEMBLY_TMP, dir); >+ } >+ } >+ > public void deleteBuildFiles(Object object) throws CoreException { > IModel model = null; > if (object instanceof BundleDescription) { >@@ -393,7 +429,7 @@ > + ".xml"; //$NON-NLS-1$ > } > >- protected HashMap createAntBuildProperties(String os, String ws, String arch) { >+ protected HashMap createAntBuildProperties(String[][] configs) { > if (fAntBuildProperties == null) { > fAntBuildProperties = new HashMap(15); > >@@ -420,9 +456,9 @@ > fAntBuildProperties.put(IXMLConstants.PROPERTY_INCLUDE_CHILDREN, "true"); //$NON-NLS-1$ > fAntBuildProperties.put("eclipse.running", "true"); //$NON-NLS-1$ //$NON-NLS-2$ > fAntBuildProperties.put(IXMLConstants.PROPERTY_GENERATE_API_DESCRIPTION, "true"); //$NON-NLS-1$ >- fAntBuildProperties.put(IXMLConstants.PROPERTY_BASE_OS, os); >- fAntBuildProperties.put(IXMLConstants.PROPERTY_BASE_WS, ws); >- fAntBuildProperties.put(IXMLConstants.PROPERTY_BASE_ARCH, arch); >+ fAntBuildProperties.put(IXMLConstants.PROPERTY_BASE_OS, TargetPlatform.getOS()); >+ fAntBuildProperties.put(IXMLConstants.PROPERTY_BASE_WS, TargetPlatform.getWS()); >+ fAntBuildProperties.put(IXMLConstants.PROPERTY_BASE_ARCH, TargetPlatform.getOSArch()); > fAntBuildProperties.put(IXMLConstants.PROPERTY_BASE_NL, TargetPlatform.getNL()); > fAntBuildProperties.put(IXMLConstants.PROPERTY_BOOTCLASSPATH, BuildUtilities.getBootClasspath()); > IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); >@@ -459,22 +495,8 @@ > fAntBuildProperties.put(IXMLConstants.PROPERTY_COLLECTING_FOLDER, "."); //$NON-NLS-1$ > String prefix = Platform.getOS().equals("macosx") ? "." : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > fAntBuildProperties.put(IXMLConstants.PROPERTY_ARCHIVE_PREFIX, prefix); >- >- if (!fInfo.toDirectory) { >- String filename = fInfo.zipFileName; >- if (fInfo.targets != null) { >- int i = filename.lastIndexOf('.'); >- filename = filename.substring(0, i) + '.' + os + '.' + ws + '.' + arch + filename.substring(i); >- } >- fAntBuildProperties.put(IXMLConstants.PROPERTY_ARCHIVE_FULLPATH, fInfo.destinationDirectory + File.separator + filename); >- } else { >- String dir = fInfo.destinationDirectory; >- if (fInfo.targets != null) >- dir += File.separatorChar + os + '.' + ws + '.' + arch; >- fAntBuildProperties.put(IXMLConstants.PROPERTY_ASSEMBLY_TMP, dir); >- } > fAntBuildProperties.put(IXMLConstants.PROPERTY_TAR_ARGS, ""); //$NON-NLS-1$ >- >+ fAntBuildProperties.put(IXMLConstants.PROPERTY_RUN_PACKAGER, "true"); //$NON-NLS-1$ > } > > setP2MetaDataProperties(fAntBuildProperties); >@@ -486,8 +508,7 @@ > * Whether or not to use new metadata publishing or old generation > */ > protected boolean publishingP2Metadata() { >- //for now we can only support when exporting a single platform >- return fInfo.useJarFormat && fInfo.exportMetadata && (fInfo.targets == null || fInfo.targets.length == 1); >+ return fInfo.useJarFormat && fInfo.exportMetadata; > } > > /** >@@ -555,13 +576,13 @@ > } > > File metadataTemp = new File(fBuildTempMetadataLocation); >- if (file.exists()) { >+ if (metadataTemp.exists()) { > //make sure our build metadata repo is clean > deleteDir(metadataTemp); > } > } > >- private void deleteDir(File dir) { >+ protected void deleteDir(File dir) { > if (dir.exists()) { > if (dir.isDirectory()) { > File[] children = dir.listFiles(); >@@ -575,17 +596,44 @@ > } > } > >- protected void doExport(IFeatureModel model, String[] config, IProgressMonitor monitor) throws CoreException, InvocationTargetException { >- if (config == null) { >- IFeature feature = model.getFeature(); >- doExport(model, getOS(feature), getWS(feature), getOSArch(feature), monitor); >- } else { >- createDestination(config[0], config[1], config[2]); >- doExport(model, config[0], config[1], config[2], monitor); >+ private String getConfigInfo(String[][] configs) { >+ StringBuffer buffer = new StringBuffer(); >+ for (int i = 0; i < configs.length; i++) { >+ if (i > 0) >+ buffer.append('&'); >+ buffer.append(configs[i][0]); >+ buffer.append(','); >+ buffer.append(configs[i][1]); >+ buffer.append(','); >+ buffer.append(configs[i][2]); >+ } >+ return buffer.toString(); >+ } >+ >+ private String getArchivesFormat(String[][] configs) { >+ StringBuffer buffer = new StringBuffer(); >+ for (int i = 0; i < configs.length; i++) { >+ if (i > 0) >+ buffer.append('&'); >+ buffer.append(configs[i][0]); >+ buffer.append(','); >+ buffer.append(configs[i][1]); >+ buffer.append(','); >+ buffer.append(configs[i][2]); >+ buffer.append('-'); >+ buffer.append(fInfo.toDirectory ? IXMLConstants.FORMAT_FOLDER : IXMLConstants.FORMAT_ANTZIP); >+ } >+ >+ if (groupedConfigurations()) { >+ buffer.append('&'); >+ buffer.append("group,group,group-"); //$NON-NLS-1$ >+ buffer.append(fInfo.toDirectory ? IXMLConstants.FORMAT_FOLDER : IXMLConstants.FORMAT_ANTZIP); > } >+ >+ return buffer.toString(); > } > >- protected void setupGenerator(BuildScriptGenerator generator, String featureID, String versionId, String os, String ws, String arch, String featureLocation) throws CoreException { >+ protected void setupGenerator(BuildScriptGenerator generator, String featureID, String versionId, String[][] configs, String featureLocation) throws CoreException { > generator.setBuildingOSGi(true); > generator.setChildren(true); > generator.setWorkingDirectory(featureLocation); >@@ -598,15 +646,9 @@ > generator.setGenerateJnlp(fInfo.jnlpInfo != null); > generator.setFlattenDependencies(true); > >- String config = os + ',' + ws + ',' + arch; >- AbstractScriptGenerator.setConfigInfo(config); //This needs to be set before we set the format >- String format; >- if (fInfo.toDirectory) >- format = config + '-' + IXMLConstants.FORMAT_FOLDER; >- else >- format = config + '-' + IXMLConstants.FORMAT_ANTZIP; >- generator.setArchivesFormat(format); >- generator.setPDEState(getState(os, ws, arch)); >+ AbstractScriptGenerator.setConfigInfo(getConfigInfo(configs)); //This needs to be set before we set the format >+ generator.setArchivesFormat(getArchivesFormat(configs)); >+ generator.setPDEState(getBuildState()); > generator.setNextId(TargetPlatformHelper.getPDEState().getNextId()); > > if (fInfo.useWorkspaceCompiledClasses) { >@@ -623,6 +665,14 @@ > Properties properties = new Properties(); > properties.put(IBuildPropertiesConstants.PROPERTY_ALLOW_BINARY_CYCLES, Boolean.toString(fInfo.allowBinaryCycles)); > properties.put(IBuildPropertiesConstants.PROPERTY_P2_GATHERING, Boolean.toString(publishingP2Metadata())); >+ //TODO this is duplicate from createAntBuildProperties >+ IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); >+ IExecutionEnvironment[] envs = manager.getExecutionEnvironments(); >+ for (int i = 0; i < envs.length; i++) { >+ String id = envs[i].getId(); >+ if (id != null) >+ properties.put(id, BuildUtilities.getBootClasspath(id)); >+ } > generator.setImmutableAntProperties(properties); > > // allow for custom execution environments >@@ -652,6 +702,15 @@ > return fStateCopy; > } > >+ protected State getBuildState() { >+ State main = TargetPlatformHelper.getState(); >+ if (fStateCopy == null) >+ copyState(main); >+ //this state is expected to get platform properties set by pde.build and re-resolved there. >+ //TODO should main.getPlatformProperties() be passed to pde/build? >+ return fStateCopy; >+ } >+ > protected void copyState(State state) { > fStateCopy = state.getFactory().createState(state); > fStateCopy.setResolver(Platform.getPlatformAdmin().createResolver()); >@@ -839,7 +898,24 @@ > } > } > >- protected void createFeature(String featureID, String featureLocation, String[] config, boolean includeLauncher) throws IOException { >+ private Dictionary getEnvironment(String[] config) { >+ Dictionary environment = new Hashtable(4); >+ environment.put("osgi.os", config[0]); //$NON-NLS-1$ >+ environment.put("osgi.ws", config[1]); //$NON-NLS-1$ >+ environment.put("osgi.arch", config[2]); //$NON-NLS-1$ >+ environment.put("osgi.nl", config[3]); //$NON-NLS-1$ >+ return environment; >+ } >+ >+ private void setFilterAttributes(Element plugin, String[] config) { >+ if (config != GENERIC_CONFIG) { >+ plugin.setAttribute("os", config[0]); //$NON-NLS-1$ >+ plugin.setAttribute("ws", config[1]); //$NON-NLS-1$ >+ plugin.setAttribute("arch", config[2]); //$NON-NLS-1$ >+ } >+ } >+ >+ protected void createFeature(String featureID, String featureLocation, String[][] configurations, boolean includeLauncher) throws IOException { > File file = new File(featureLocation); > if (!file.exists() || !file.isDirectory()) > file.mkdirs(); >@@ -862,11 +938,7 @@ > root.appendChild(includes); > } > } >- Dictionary environment = new Hashtable(4); >- environment.put("osgi.os", config[0]); //$NON-NLS-1$ >- environment.put("osgi.ws", config[1]); //$NON-NLS-1$ >- environment.put("osgi.arch", config[2]); //$NON-NLS-1$ >- environment.put("osgi.nl", config[3]); //$NON-NLS-1$ >+ > List workspacePlugins = Arrays.asList(PluginRegistry.getWorkspaceModels()); > > for (int i = 0; i < fInfo.items.length; i++) { >@@ -894,32 +966,52 @@ > } > if (bundle == null) > continue; >- if (shouldAddPlugin(bundle, environment)) { >- Element plugin = doc.createElement("plugin"); //$NON-NLS-1$ >- plugin.setAttribute("id", bundle.getSymbolicName()); //$NON-NLS-1$ >- plugin.setAttribute("version", bundle.getVersion().toString()); //$NON-NLS-1$ >- setAdditionalAttributes(plugin, bundle); >- root.appendChild(plugin); >- >- if (fInfo.exportSource && fInfo.exportSourceBundle) { >- if (workspacePlugins.contains(PluginRegistry.findModel(bundle))) { // Is it a workspace plugin? >- plugin = doc.createElement("plugin"); //$NON-NLS-1$ >- plugin.setAttribute("id", bundle.getSymbolicName() + ".source"); //$NON-NLS-1$ //$NON-NLS-2$ >- plugin.setAttribute("version", bundle.getVersion().toString()); //$NON-NLS-1$ >- setAdditionalAttributes(plugin, bundle); >- root.appendChild(plugin); >- } else // include the .source plugin, if available >- { >- IPluginModelBase model = PluginRegistry.findModel(bundle.getSymbolicName() + ".source"); //$NON-NLS-1$ >- if (model != null) { >- bundle = model.getBundleDescription(); >+ >+ List configs = new ArrayList(); >+ if (configurations.length > 1) >+ configs.add(GENERIC_CONFIG); >+ configs.addAll(Arrays.asList(configurations)); >+ >+ //when doing multiplatform we need filters set on the plugin elements that need them >+ //so check the Bundle's platfrom filter against each config >+ for (Iterator iterator = configs.iterator(); iterator.hasNext();) { >+ String[] currentConfig = (String[]) iterator.next(); >+ Dictionary environment = getEnvironment(currentConfig); >+ if (shouldAddPlugin(bundle, environment)) { >+ Element plugin = doc.createElement("plugin"); //$NON-NLS-1$ >+ plugin.setAttribute("id", bundle.getSymbolicName()); //$NON-NLS-1$ >+ plugin.setAttribute("version", bundle.getVersion().toString()); //$NON-NLS-1$ >+ setFilterAttributes(plugin, currentConfig); >+ setAdditionalAttributes(plugin, bundle); >+ root.appendChild(plugin); >+ >+ if (fInfo.exportSource && fInfo.exportSourceBundle) { >+ if (workspacePlugins.contains(PluginRegistry.findModel(bundle))) { // Is it a workspace plugin? > plugin = doc.createElement("plugin"); //$NON-NLS-1$ >- plugin.setAttribute("id", bundle.getSymbolicName()); //$NON-NLS-1$ >+ plugin.setAttribute("id", bundle.getSymbolicName() + ".source"); //$NON-NLS-1$ //$NON-NLS-2$ > plugin.setAttribute("version", bundle.getVersion().toString()); //$NON-NLS-1$ >+ setFilterAttributes(plugin, currentConfig); > setAdditionalAttributes(plugin, bundle); > root.appendChild(plugin); >+ } else // include the .source plugin, if available >+ { >+ IPluginModelBase model = PluginRegistry.findModel(bundle.getSymbolicName() + ".source"); //$NON-NLS-1$ >+ if (model != null) { >+ bundle = model.getBundleDescription(); >+ plugin = doc.createElement("plugin"); //$NON-NLS-1$ >+ plugin.setAttribute("id", bundle.getSymbolicName()); //$NON-NLS-1$ >+ plugin.setAttribute("version", bundle.getVersion().toString()); //$NON-NLS-1$ >+ setFilterAttributes(plugin, currentConfig); >+ setAdditionalAttributes(plugin, bundle); >+ root.appendChild(plugin); >+ } > } > } >+ if (currentConfig == GENERIC_CONFIG) { >+ //if the bundle matched the generic configuration, we don't need to generated additional inclusions >+ //for the rest of the configs >+ break; >+ } > } > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 267127
:
127849
|
130628
| 130629