From: <jsa...@us...> - 2008-10-28 13:55:50
|
Revision: 50 http://flexotask.svn.sourceforge.net/flexotask/?rev=50&view=rev Author: jsauerbach Date: 2008-10-28 13:55:43 +0000 (Tue, 28 Oct 2008) Log Message: ----------- Switch to using separate source plugins rather than internal *src.zip files ... this is arbitrary but the separate plugins approach works better with the standard update site build in eclipse, which doesn't seem to want to put source zips into update site plugins. Modified Paths: -------------- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/FlexotaskClasspathInitializer.java trunk/flexotask-features/build.properties trunk/flexotask-features/feature-build.xml trunk/flexotask-features/feature.xml Property Changed: ---------------- trunk/flexotask-features/ Modified: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/FlexotaskClasspathInitializer.java =================================================================== --- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/FlexotaskClasspathInitializer.java 2008-10-28 13:55:27 UTC (rev 49) +++ trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/FlexotaskClasspathInitializer.java 2008-10-28 13:55:43 UTC (rev 50) @@ -30,10 +30,16 @@ import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; +import org.eclipse.pde.core.plugin.IPluginBase; +import org.eclipse.pde.core.plugin.IPluginElement; +import org.eclipse.pde.core.plugin.IPluginExtension; import org.eclipse.pde.core.plugin.IPluginLibrary; import org.eclipse.pde.core.plugin.IPluginModelBase; +import org.eclipse.pde.core.plugin.IPluginObject; +import org.eclipse.pde.core.plugin.ISharedPluginModel; import org.eclipse.pde.core.plugin.PluginRegistry; import org.osgi.framework.Bundle; +import org.osgi.framework.Version; import com.ibm.realtime.flexotask.editor.model.GlobalTiming; @@ -57,12 +63,13 @@ /** File that is used as the debugging assistance file (built by all flexotask projects that may be put in a classpath container) */ public static final String DEBUG_FILE = "debug.zip"; - /** The local file name suffix to use for source attachments, when present */ - private final static String SRC_NAME = "src.zip"; - /** Special flag to allow the mechanism for running under a debugger itself to be debugged */ private static final boolean DEBUG_DEBUGGING = Boolean.valueOf(System.getProperty("FLEXOTASK_DEBUG_DEBUGGING")); + private static final String SOURCE_EXTENSION_POINT = "org.eclipse.pde.core.source"; + + private static IPath[] sourcePaths; + /** * A 0-argument constructor is required */ @@ -140,37 +147,110 @@ e.printStackTrace(); } } + IPluginBase pluginBase = model.getPluginBase(); /* If we could not use a project either in the current workspace or the parent workspace, then use the plugin directly. */ if (new File(location).isFile()) { /* This plugin comes zipped up. We make the simplifying assumption that it serves as its own source attachment (the PDE supports * a wider range of source attachment options, which we can explore later if necessary). */ IPath pluginPath = new Path(location); - accumulator.add(JavaCore.newLibraryEntry(pluginPath, pluginPath, null)); + accumulator.add(JavaCore.newLibraryEntry(pluginPath, findSourceArchive(pluginBase, ""), null)); return; } /* This plugin comes unzipped as a directory. We use similar processing to the PDE but do not consider all the cases. Basically, * we make the libraries of the plugin into library entries, using the standard source naming convention. Processing a more complex * set of source conventions might be desirable but is deferred for now. */ - IPluginLibrary[] libraries = model.getPluginBase().getLibraries(); + IPluginLibrary[] libraries = pluginBase.getLibraries(); for (int i = 0; i < libraries.length; i++) { if (IPluginLibrary.RESOURCE.equals(libraries[i].getType())) continue; String name = libraries[i].getName(); IPath path = new Path(location).append(name); if (!path.toFile().isDirectory()) - accumulator.add(JavaCore.newLibraryEntry(path, new Path(makeSrcName(path.toString())), null)); + accumulator.add(JavaCore.newLibraryEntry(path, findSourceArchive(pluginBase, name), null)); } } /** - * Apply the source suffix convention to a .jar name + * Find the name of the source file associated with a jar + * @param pluginBase the IPluginBase of the plugin containing the jar * @param jarName the name of the jar (assumed without checking to end in ".jar") - * @return the source name + * @return the path to the source archive */ - private static String makeSrcName(String jarName) - { - return jarName.substring(0, jarName.length() - 4).concat(SRC_NAME); + private static IPath findSourceArchive(IPluginBase pluginBase, String jarName) { + int dot = jarName.lastIndexOf('.'); + String sourceName = (dot != -1) ? jarName.substring(0, dot) + "src.zip" : jarName.length() > 1 ? jarName : "src.zip"; + IPath sourcePath = getRelativePath(pluginBase, sourceName); + IPath[] locations = getSourcePaths(); + for (int i = 0; i < locations.length; i++) { + IPath fullPath = locations[i].append(sourcePath); + File file = fullPath.toFile(); + if (file.exists()) + return fullPath; + } + return null; } + + /** + * Convert a source archive name to a full relative path using Eclipse conventions for source plugins. + * This closely resembles a similar function in the PDE that is not accessible from outside the PDE + * implementation. + * @param pluginBase the plugin project containing the jar whose source is desired + * @param sourcePath the src.zip transformation of the jar's name + * @return the full relative path to look for in source plugins + */ + private static IPath getRelativePath(IPluginBase pluginBase, String sourcePath) { + try { + String pluginDir = pluginBase.getId(); + if (pluginDir == null) + return null; + String version = pluginBase.getVersion(); + if (version != null) { + Version vid = new Version(version); + pluginDir += "_" + vid.toString(); + } + IPath path = new Path(pluginDir); + return sourcePath == null ? path : path.append(sourcePath); + } catch (IllegalArgumentException e) { + return null; + } + } + + /** + * Compute all the paths to places that might have source. This code is based on similar code in the + * PDE that is not accessible from outside. It is not actually as complete since it does not take into + * account everyplace that source might live. It is adequate for the usual packaging conventions for + * Flexotask plugins + * @return the array of all paths containing source + */ + private static IPath[] getSourcePaths() { + if (sourcePaths == null) { + ArrayList<IPath> list = new ArrayList<IPath>(); + IPluginModelBase[] models = PluginRegistry.getExternalModels(); + for (int i = 0; i < models.length; i++) { + IPluginExtension[] extensions = models[i].getPluginBase().getExtensions(); + for (int j = 0; j < extensions.length; j++) { + IPluginExtension extension = extensions[j]; + if (SOURCE_EXTENSION_POINT.equals(extension.getPoint())) { + IPluginObject[] children = extension.getChildren(); + for (int k = 0; k < children.length; k++) { + if (children[k].getName().equals("location")) { + IPluginElement element = (IPluginElement) children[k]; + String pathValue = element.getAttribute("path").getValue(); + ISharedPluginModel model = extension.getModel(); + IPath path = new Path(model.getInstallLocation()).append(pathValue); + if (path.toFile().exists()) { + if (!list.contains(path)) + list.add(path); + } + } + } + } + } + } + sourcePaths = (IPath[]) list.toArray(new IPath[list.size()]); + } + return sourcePaths; + } } Property changes on: trunk/flexotask-features ___________________________________________________________________ Modified: svn:ignore - latest-build extra.clean extra.features + latest-build extra.clean extra.features features plugins Modified: trunk/flexotask-features/build.properties =================================================================== --- trunk/flexotask-features/build.properties 2008-10-28 13:55:27 UTC (rev 49) +++ trunk/flexotask-features/build.properties 2008-10-28 13:55:43 UTC (rev 50) @@ -1 +1,3 @@ bin.includes = feature.xml + +ge...@co...urce = com.ibm.realtime.flexotask.feature Modified: trunk/flexotask-features/feature-build.xml =================================================================== --- trunk/flexotask-features/feature-build.xml 2008-10-28 13:55:27 UTC (rev 49) +++ trunk/flexotask-features/feature-build.xml 2008-10-28 13:55:43 UTC (rev 50) @@ -36,7 +36,7 @@ ${extra.clean}"/> </target> <target name="feature_export" depends="clean,setproperties"> - <pde.exportFeatures destination="latest-build" exportSource="true" exportType="directory" + <pde.exportFeatures destination="latest-build" exportType="directory" features="${flexotask.features}" useJARFormat="false"/> </target> <target name="clean" depends="setproperties"> Modified: trunk/flexotask-features/feature.xml =================================================================== --- trunk/flexotask-features/feature.xml 2008-10-28 13:55:27 UTC (rev 49) +++ trunk/flexotask-features/feature.xml 2008-10-28 13:55:43 UTC (rev 50) @@ -1,80 +1,82 @@ -<?xml version="1.0" encoding="UTF-8"?> -<feature - id="com.ibm.realtime.flexotask.feature" - label="Flexible Task Graphs Feature" - version="2.0.0" - provider-name="IBM Research"> - - <description> - Core Features of the Flexible Task Graphs System - </description> - - <copyright> +<?xml version="1.0" encoding="UTF-8"?> +<feature + id="com.ibm.realtime.flexotask.feature" + label="Flexible Task Graphs Feature" + version="2.0.0" + provider-name="IBM Research"> + + <description> + Core Features of the Flexible Task Graphs System + </description> + + <copyright> Copyright (c) 2006 - 2008 IBM Corporation. -All rights reserved. - </copyright> - - <license> +All rights reserved. + </copyright> + + <license> 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 - </license> - - <url> - <update label="Flexible Task Graphs" url="http://flexotask.sourceforge.net/update-site"/> - </url> - - <requires> - <import plugin="com.ibm.realtime.analysis"/> - <import plugin="com.ibm.realtime.flexotask.generic"/> - <import plugin="com.ibm.realtime.flexotask"/> - <import plugin="org.eclipse.gef" version="3.2.0" match="compatible"/> - <import plugin="org.eclipse.ui" version="3.2.0" match="compatible"/> - <import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/> - <import plugin="org.eclipse.core.resources" version="3.2.0" match="compatible"/> - <import plugin="org.eclipse.ui.views" version="3.2.0" match="compatible"/> - <import plugin="org.eclipse.ui.ide" version="3.2.0" match="compatible"/> - <import plugin="org.eclipse.jdt.ui"/> - <import plugin="org.eclipse.jdt.core"/> - <import plugin="org.eclipse.ant.core"/> - <import plugin="org.eclipse.pde.core"/> - <import plugin="org.eclipse.ui.console"/> - <import plugin="com.ibm.realtime.flexotask.editor"/> - <import plugin="org.eclipse.jdt.launching"/> - <import feature="org.eclipse.pde" version="3.3.2.R33x_r20071022-7N7M4CYWLBCz-yHkMIuHN"/> - <import feature="org.eclipse.gef" version="3.3.1.v20070814"/> - </requires> - - <plugin - id="com.ibm.realtime.analysis" - download-size="0" - install-size="0" - version="2.0.0"/> - - <plugin - id="com.ibm.realtime.flexotask" - download-size="0" - install-size="0" - version="2.0.0"/> - - <plugin - id="com.ibm.realtime.flexotask.editor" - download-size="0" - install-size="0" - version="2.0.0"/> - - <plugin - id="com.ibm.realtime.flexotask.generic" - download-size="0" - install-size="0" - version="2.0.0"/> - - <plugin - id="com.ibm.realtime.flexotask.development" - download-size="0" - install-size="0" - version="2.0.0"/> - -</feature> +http://www.eclipse.org/legal/epl-v10.html + </license> + + <url> + <update label="Flexible Task Graphs" url="http://flexotask.sourceforge.net/update-site"/> + </url> + + <requires> + <import plugin="com.ibm.realtime.analysis"/> + <import plugin="com.ibm.realtime.flexotask.generic"/> + <import plugin="com.ibm.realtime.flexotask"/> + <import plugin="org.eclipse.gef" version="3.2.0" match="compatible"/> + <import plugin="org.eclipse.ui" version="3.2.0" match="compatible"/> + <import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/> + <import plugin="org.eclipse.core.resources" version="3.2.0" match="compatible"/> + <import plugin="org.eclipse.ui.views" version="3.2.0" match="compatible"/> + <import plugin="org.eclipse.ui.ide" version="3.2.0" match="compatible"/> + <import plugin="org.eclipse.jdt.ui"/> + <import plugin="org.eclipse.jdt.core"/> + <import plugin="org.eclipse.ant.core"/> + <import plugin="org.eclipse.pde.core"/> + <import plugin="org.eclipse.ui.console"/> + <import plugin="com.ibm.realtime.flexotask.editor"/> + <import plugin="org.eclipse.jdt.launching"/> + <import feature="org.eclipse.pde" version="3.3.2.R33x_r20071022-7N7M4CYWLBCz-yHkMIuHN"/> + <import feature="org.eclipse.gef" version="3.3.1.v20070814"/> + </requires> + + <plugin + id="com.ibm.realtime.analysis" + download-size="0" + install-size="0" + version="2.0.0"/> + + <plugin + id="com.ibm.realtime.flexotask" + download-size="0" + install-size="0" + version="2.0.0"/> + + <plugin + id="com.ibm.realtime.flexotask.editor" + download-size="0" + install-size="0" + version="2.0.0"/> + + <plugin + id="com.ibm.realtime.flexotask.generic" + download-size="0" + install-size="0" + version="2.0.0"/> + + <plugin + id="com.ibm.realtime.flexotask.development" + download-size="0" + install-size="0" + version="2.0.0"/> + + <plugin id="com.ibm.realtime.flexotask.source" version="2.0.0"/> + +</feature> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |