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 33845 Details for
Bug 34757
Support for other repository
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
34757_pluggable_fetch_script_builder.patch.txt
34757_pluggable_fetch_script_builder.patch.txt (text/plain), 107.64 KB, created by
Gunnar Wagenknecht
on 2006-01-31 03:02:22 EST
(
hide
)
Description:
34757_pluggable_fetch_script_builder.patch.txt
Filename:
MIME Type:
Creator:
Gunnar Wagenknecht
Created:
2006-01-31 03:02:22 EST
Size:
107.64 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.build >Index: src/org/eclipse/pde/internal/build/IXMLConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/IXMLConstants.java,v >retrieving revision 1.61 >diff -u -r1.61 IXMLConstants.java >--- src/org/eclipse/pde/internal/build/IXMLConstants.java 23 Jan 2006 15:55:23 -0000 1.61 >+++ src/org/eclipse/pde/internal/build/IXMLConstants.java 31 Jan 2006 08:02:41 -0000 >@@ -53,7 +53,7 @@ > public static final String TARGET_FETCH_ELEMENT = "fetch.element"; //$NON-NLS-1$ > public static final String TARGET_FETCH_PLUGINS = "fetch.plugins"; //$NON-NLS-1$ > public static final String TARGET_FETCH_RECURSIVELY = "fetch.recursively"; //$NON-NLS-1$ >- public static final String TARGET_GET_FROM_CVS = "getFromCVS"; //$NON-NLS-1$ >+ public static final String TARGET_FETCH_FROM_REPOSITORY = "fetchFromRepository"; //$NON-NLS-1$ > public static final String TARGET_EFFECTIVE_FETCH = "effectiveFetch"; //$NON-NLS-1$ > public static final String TARGET_JARUP = "jarUp"; //$NON-NLS-1$ > public static final String TARGET_JARING = "jarIng"; //$NON-NLS-1$ >Index: src/org/eclipse/pde/internal/build/BuildActivator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/BuildActivator.java,v >retrieving revision 1.4 >diff -u -r1.4 BuildActivator.java >--- src/org/eclipse/pde/internal/build/BuildActivator.java 21 Feb 2005 23:31:25 -0000 1.4 >+++ src/org/eclipse/pde/internal/build/BuildActivator.java 31 Jan 2006 08:02:41 -0000 >@@ -20,5 +20,6 @@ > > public void stop(BundleContext ctx) throws Exception { > BundleHelper.close(); >+ FetchTaskFactoriesRegistry.shutdown(); > } > } >Index: src/org/eclipse/pde/internal/build/FetchScriptGenerator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/FetchScriptGenerator.java,v >retrieving revision 1.46 >diff -u -r1.46 FetchScriptGenerator.java >--- src/org/eclipse/pde/internal/build/FetchScriptGenerator.java 18 Jan 2006 22:16:16 -0000 1.46 >+++ src/org/eclipse/pde/internal/build/FetchScriptGenerator.java 31 Jan 2006 08:02:41 -0000 >@@ -15,40 +15,70 @@ > import org.eclipse.ant.core.AntRunner; > import org.eclipse.core.runtime.*; > import org.eclipse.osgi.util.NLS; >+import org.eclipse.pde.build.FetchTaskFactory; > import org.eclipse.pde.internal.build.ant.AntScript; >+import org.eclipse.pde.internal.build.fetch.CVSFetchTaskFactory; > import org.eclipse.update.core.*; > import org.eclipse.update.internal.core.FeatureExecutableFactory; > > /** >- * Generates Ant scripts which will use the CVS "fetch" element >- * to retrieve plug-ins and features from the CVS repository. >+ * Generates Ant scripts with a repository specific factory >+ * to retrieve plug-ins and features from a repository. > */ > public class FetchScriptGenerator extends AbstractScriptGenerator { >- private static final String BUNDLE = "bundle"; //$NON-NLS-1$ >- private static final String FRAGMENT = "fragment"; //$NON-NLS-1$ >- private static final String PLUGIN = "plugin"; //$NON-NLS-1$ >- private static final String FEATURE = "feature"; //$NON-NLS-1$ >- private static final String ELEMENT = "element"; //$NON-NLS-1$ >- private static final String TYPE = "type"; //$NON-NLS-1$ >- private static final String PATH = "path"; //$NON-NLS-1$ >- private static final String PASSWORD = "password"; //$NON-NLS-1$ >- private static final String CVSROOT = "cvsRoot"; //$NON-NLS-1$ >- private static final String TAG = "tag"; //$NON-NLS-1$ >+ private static final String BUNDLE = FetchTaskFactory.ELEMENT_TYPE_BUNDLE; >+ private static final String FRAGMENT = FetchTaskFactory.ELEMENT_TYPE_FRAGMENT; >+ private static final String PLUGIN = FetchTaskFactory.ELEMENT_TYPE_PLUGIN; >+ private static final String FEATURE = FetchTaskFactory.ELEMENT_TYPE_FEATURE; >+ private static final String ELEMENT = FetchTaskFactory.KEY_ELEMENT_NAME; >+ private static final String TYPE = FetchTaskFactory.KEY_ELEMENT_TYPE; >+ private static final String FETCH_TASK_FACTORY = FetchTaskFactory.KEY_FACTORY; >+ >+ public static final String FEATURE_ONLY = "featureOnly"; //$NON-NLS-1$ >+ >+ public static final String FEATURE_AND_PLUGINS = "featureAndPlugins"; //$NON-NLS-1$ >+ public static final String FEATURES_RECURSIVELY = "featuresRecursively"; //$NON-NLS-1$ >+ >+ public static final String FETCH_FILE_PREFIX = "fetch_"; //$NON-NLS-1$ >+ >+ /** >+ * Deletes all the files and directories from the given root down (inclusive). >+ * Returns false if we could not delete some file or an exception occurred >+ * at any point in the deletion. >+ * Even if an exception occurs, a best effort is made to continue deleting. >+ * >+ * @param root >+ * @return boolean >+ */ >+ public static boolean clear(File root) { >+ boolean result = true; >+ if (root.isDirectory()) { >+ String[] list = root.list(); >+ // for some unknown reason, list() can return null. >+ // Just skip the children If it does. >+ if (list != null) >+ for (int i = 0; i < list.length; i++) >+ result &= clear(new java.io.File(root, list[i])); >+ } >+ try { >+ if (root.exists()) >+ result &= root.delete(); >+ } catch (Exception e) { >+ // ignore any exceptions >+ result = false; >+ } >+ return result; >+ } > > // flag saying if we want to recursively generate the scripts > protected boolean recursiveGeneration = true; >- >- // Points to the map files containing references to cvs repository >+ // Points to the map files containing references to repository > protected String directoryLocation; > protected Properties directory; >- > // The location of the CVS password file. > protected String cvsPassFileLocation; >- > protected boolean fetchChildren = true; >- > protected String fetchTag = ""; //$NON-NLS-1$ >- > // The element (an entry of the map file) for which we create the script > protected String element; > // The feature object representing the element >@@ -63,11 +93,6 @@ > protected Properties repositoryPluginTags = new Properties(); > protected Properties repositoryFeatureTags = new Properties(); > >- public static final String FEATURE_ONLY = "featureOnly"; //$NON-NLS-1$ >- public static final String FEATURE_AND_PLUGINS = "featureAndPlugins"; //$NON-NLS-1$ >- public static final String FEATURES_RECURSIVELY = "featuresRecursively"; //$NON-NLS-1$ >- public static final String FETCH_FILE_PREFIX = "fetch_"; //$NON-NLS-1$ >- > private String scriptName; > > public FetchScriptGenerator() { >@@ -78,10 +103,6 @@ > setElement(element); > } > >- public void setElement(String element) { >- this.element = element; >- } >- > /** > * @see AbstractScriptGenerator#generate() > */ >@@ -101,40 +122,113 @@ > closeScript(); > } > >- if (recursiveGeneration && mapInfos.get(TYPE).equals(FEATURE)) >+ if (recursiveGeneration && mapInfos.get(TYPE).equals(FEATURE)) > generateFetchFilesForIncludedFeatures(); > > saveRepositoryTags(); > } > >- private void saveRepositoryTags(Properties properties, String fileName) throws CoreException { >- try { >- InputStream input = new BufferedInputStream(new FileInputStream(workingDirectory + '/' + fileName)); >- try { >- properties.load(input); >- } finally { >- input.close(); >+ /** >+ * >+ * @throws CoreException >+ */ >+ protected void generateChildrenFetchScript() throws CoreException { >+ IPluginEntry[] allChildren = feature.getRawPluginEntries(); >+ IPluginEntry[] compiledChildren = feature.getPluginEntries(); >+ >+ for (int i = 0; i < allChildren.length; i++) { >+ String elementId = allChildren[i].getVersionedIdentifier().getIdentifier(); >+ // We are not fetching the elements that are said to be generated, but we are fetching some elements that can be associated >+ if (featureProperties.containsKey(GENERATION_SOURCE_PLUGIN_PREFIX + elementId)) { >+ String[] extraElementsToFetch = Utils.getArrayFromString(featureProperties.getProperty(GENERATION_SOURCE_PLUGIN_PREFIX + elementId), ","); //$NON-NLS-1$ >+ for (int j = 1; j < extraElementsToFetch.length; j++) { >+ generateFetchEntry(extraElementsToFetch[j], false); >+ } >+ continue; > } >- } catch (IOException e) { >- //ignore the exception, the same may not exist >+ >+ boolean generated = true; >+ if (allChildren[i].isFragment()) >+ generated = generateFetchEntry(FRAGMENT + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i])); >+ else >+ generated = generateFetchEntry(PLUGIN + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i])); >+ if (generated == false) >+ generateFetchEntry(BUNDLE + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i])); > } >+ } > >+ /** >+ * Just ends the script. >+ */ >+ protected void generateEpilogue() { >+ script.println(); >+ script.printProjectEnd(); >+ } >+ >+ protected void generateFetchElementTarget() { >+ script.printTargetDeclaration(TARGET_FETCH_ELEMENT, null, FEATURE_ONLY, null, null); > try { >- OutputStream os = new BufferedOutputStream(new FileOutputStream(workingDirectory + '/' + fileName)); >- try { >- properties.store(os, null); >- } finally { >- os.close(); >- } >- } catch (IOException e) { >- String message = NLS.bind(Messages.exception_writingFile, workingDirectory + '/' + fileName); >- throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_WRITING_FILE, message, null)); >+ generateFetchEntry(element, false); >+ } catch (CoreException e) { >+ IStatus status = new Status(IStatus.ERROR, PI_PDEBUILD, WARNING_ELEMENT_NOT_FETCHED, NLS.bind(Messages.error_fetchingFailed, element), null); >+ BundleHelper.getDefault().getLog().log(status); > } >+ script.printTargetEnd(); > } >- >- private void saveRepositoryTags() throws CoreException { >- saveRepositoryTags(repositoryPluginTags, DEFAULT_PLUGIN_REPOTAG_FILENAME_DESCRIPTOR); >- saveRepositoryTags(repositoryFeatureTags, DEFAULT_FEATURE_REPOTAG_FILENAME_DESCRIPTOR); >+ >+ protected boolean generateFetchEntry(String entry, boolean manifestFileOnly) throws CoreException { >+ Map mapFileEntry = mapInfos; >+ if (!entry.equals(element)) { >+ mapFileEntry = processMapFileEntry(entry); >+ if (mapFileEntry == null) >+ return false; >+ } >+ >+ FetchTaskFactory factory = (FetchTaskFactory) mapFileEntry.get(FETCH_TASK_FACTORY); >+ String elementToFetch = (String) mapFileEntry.get(ELEMENT); >+ String type = (String) mapFileEntry.get(TYPE); >+ >+ // print authentification task if one is provided >+ CharSequence authTask = factory.generateAuthentificationTask(elementToFetch, type, mapFileEntry); >+ if (null != authTask) >+ script.print(authTask); >+ >+ // the location >+ String location = getElementLocation(type); >+ >+ // the destination >+ // we directly export the content into the correct directory >+ String destination = elementToFetch; >+ >+ // get params from builder >+ Map params = new HashMap(factory.generatePropertiesForFetchTask(elementToFetch, type, mapFileEntry, destination, manifestFileOnly)); >+ >+ String fullLocation = null; >+ if (type.equals(FEATURE)) { >+ fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_FEATURE_FILENAME_DESCRIPTOR; >+ params.put("fileToCheck", fullLocation); //$NON-NLS-1$ >+ repositoryFeatureTags.put(elementToFetch, factory.getTagToFetch(elementToFetch, type, mapFileEntry)); >+ } else if (type.equals(PLUGIN)) { >+ fullLocation = location + '/' + elementToFetch + '/' + DEFAULT_PLUGIN_FILENAME_DESCRIPTOR; >+ params.put("fileToCheck", fullLocation); //$NON-NLS-1$ >+ repositoryPluginTags.put(elementToFetch, factory.getTagToFetch(elementToFetch, type, mapFileEntry)); >+ } else if (type.equals(FRAGMENT)) { >+ fullLocation = location + '/' + elementToFetch + '/' + DEFAULT_FRAGMENT_FILENAME_DESCRIPTOR; >+ params.put("fileToCheck", fullLocation); //$NON-NLS-1$ >+ repositoryPluginTags.put(elementToFetch, factory.getTagToFetch(elementToFetch, type, mapFileEntry)); >+ } else if (type.equals(BUNDLE)) { >+ fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR; >+ params.put("fileToCheck", fullLocation); //$NON-NLS-1$ >+ repositoryPluginTags.put(elementToFetch, factory.getTagToFetch(elementToFetch, type, mapFileEntry)); >+ } >+ >+ // This call create a new property for every feature, plugins or fragments that we must check the existence of >+ script.printAvailableTask(fullLocation, fullLocation); >+ if (type.equals(PLUGIN) || type.equals(FRAGMENT)) { >+ script.printAvailableTask(fullLocation, location + '/' + elementToFetch + '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR); >+ } >+ script.printAntTask("../" + scriptName, Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY) + '/' + (type.equals(FEATURE) ? DEFAULT_FEATURE_LOCATION : DEFAULT_PLUGIN_LOCATION), TARGET_FETCH_FROM_REPOSITORY, null, null, params); //$NON-NLS-1$ >+ return true; > } > > /** >@@ -160,6 +254,38 @@ > } > } > >+ protected void generateFetchPluginsTarget() throws CoreException { >+ script.printTargetDeclaration(TARGET_FETCH_PLUGINS, null, FEATURE_AND_PLUGINS, null, null); >+ retrieveFeature((String) mapInfos.get(ELEMENT), (String) mapInfos.get(TYPE), mapInfos); >+ generateChildrenFetchScript(); >+ script.printTargetEnd(); >+ } >+ >+ protected void generateFetchRecusivelyTarget() throws CoreException { >+ script.printTargetDeclaration(TARGET_FETCH_RECURSIVELY, null, FEATURES_RECURSIVELY, null, null); >+ >+ IIncludedFeatureReference[] compiledFeatures = ((Feature) feature).getFeatureIncluded(); >+ for (int i = 0; i < compiledFeatures.length; i++) { >+ String featureId = compiledFeatures[i].getVersionedIdentifier().getIdentifier(); >+ if (featureProperties.containsKey(GENERATION_SOURCE_FEATURE_PREFIX + featureId)) { >+ String[] extraElementsToFetch = Utils.getArrayFromString(featureProperties.getProperty(GENERATION_SOURCE_FEATURE_PREFIX + featureId), ","); //$NON-NLS-1$ >+ for (int j = 1; j < extraElementsToFetch.length; j++) { >+ generateFetchEntry(extraElementsToFetch[j], false); >+ } >+ continue; >+ } >+ >+ //Included features can be available in the baseLocation. >+ if (getRepositoryInfo(FEATURE + '@' + featureId) != null) >+ script.printAntTask(Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY) + '/' + FETCH_FILE_PREFIX + featureId + ".xml", null, TARGET_FETCH, null, null, null); //$NON-NLS-1$ >+ else if (getSite(false).findFeature(featureId, null, false) == null) { >+ String message = NLS.bind(Messages.error_cannotFetchNorFindFeature, featureId); >+ throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_FEATURE_MISSING, message, null)); >+ } >+ } >+ script.printTargetEnd(); >+ } >+ > /** > * Main call for generating the script. > * >@@ -169,11 +295,11 @@ > generatePrologue(); > generateFetchTarget(); > generateFetchElementTarget(); >- if (mapInfos.get(TYPE).equals(FEATURE)) { >+ if (mapInfos.get(TYPE).equals(FEATURE)) { > generateFetchPluginsTarget(); > generateFetchRecusivelyTarget(); > } >- generateGetFromCVSTarget(); >+ generateGetFromRepositoryTarget(); > generateEpilogue(); > } > >@@ -184,29 +310,76 @@ > script.println(); > script.printTargetDeclaration(TARGET_FETCH, null, null, null, null); > script.printAntCallTask(TARGET_FETCH_ELEMENT, null, null); >- if (mapInfos.get(TYPE).equals(FEATURE)) { >+ if (mapInfos.get(TYPE).equals(FEATURE)) { > script.printAntCallTask(TARGET_FETCH_PLUGINS, null, null); > script.printAntCallTask(TARGET_FETCH_RECURSIVELY, null, null); > } > script.printTargetEnd(); > } > >- protected void generateFetchElementTarget() { >- script.printTargetDeclaration(TARGET_FETCH_ELEMENT, null, FEATURE_ONLY, null, null); >- try { >- generateFetchEntry(element, false); >- } catch (CoreException e) { >- IStatus status = new Status(IStatus.ERROR, PI_PDEBUILD, WARNING_ELEMENT_NOT_FETCHED, NLS.bind(Messages.error_fetchingFailed, element), null); >- BundleHelper.getDefault().getLog().log(status); >+ protected void generateGetFromRepositoryTarget() throws CoreException { >+ script.printTargetDeclaration(TARGET_FETCH_FROM_REPOSITORY, null, null, "${fileToCheck}", null); //$NON-NLS-1$ >+ if (null != mapInfos) { >+ FetchTaskFactory factory = (FetchTaskFactory) mapInfos.get(FETCH_TASK_FACTORY); >+ if (null != factory) { >+ CharSequence getTask = factory.getFetchTask(); >+ if (null != getTask) { >+ script.print(getTask); >+ } >+ } > } > script.printTargetEnd(); > } > >- protected void generateFetchPluginsTarget() throws CoreException { >- script.printTargetDeclaration(TARGET_FETCH_PLUGINS, null, FEATURE_AND_PLUGINS, null, null); >- retrieveFeature((String) mapInfos.get(ELEMENT), (String) mapInfos.get(CVSROOT), (String) mapInfos.get(TAG), (String) mapInfos.get(PASSWORD), (String) mapInfos.get(PATH)); >- generateChildrenFetchScript(); >- script.printTargetEnd(); >+ /** >+ * Helper method to control for what locations a mkdir Ant task was already >+ * generated so we can reduce replication. >+ * >+ * @param location >+ */ >+ protected void generateMkdirs(String location) { >+ if (mkdirLocations.contains(location)) >+ return; >+ mkdirLocations.add(location); >+ script.printMkdirTask(location); >+ } >+ >+ /** >+ * Defines, the XML declaration and Ant project. >+ */ >+ protected void generatePrologue() { >+ script.println(); >+ script.printComment("Fetch script for " + element); //$NON-NLS-1$ >+ script.println(); >+ script.printProjectDeclaration("FetchScript", TARGET_FETCH, null); //$NON-NLS-1$ >+ script.printProperty(PROPERTY_QUIET, "true"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * >+ * @param type >+ * @return String >+ */ >+ protected String getElementLocation(String type) { >+ IPath location = new Path(Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY)); >+ if (type.equals(FEATURE)) >+ location = location.append(DEFAULT_FEATURE_LOCATION); >+ else >+ location = location.append(DEFAULT_PLUGIN_LOCATION); >+ return location.toString(); >+ } >+ >+ /** >+ * Get information stored in the directory file. >+ * >+ * @param elementName >+ * @return String >+ * @throws CoreException >+ */ >+ protected String getRepositoryInfo(String elementName) throws CoreException { >+ if (directory == null) >+ directory = readProperties(directoryLocation, "", IStatus.ERROR); //$NON-NLS-1$ >+ return directory.getProperty(elementName); > } > > /** >@@ -219,158 +392,58 @@ > private Map processMapFileEntry(String entry) throws CoreException { > Map entryInfos = new HashMap(5); > >- String cvsInfo = getCVSInfo(entry); >- if (cvsInfo == null) { >+ // extract type and element from entry >+ int index = entry.indexOf('@'); >+ String type = entry.substring(0, index); >+ String currentElement = entry.substring(index + 1); >+ >+ // read and validate the repository info >+ String repositoryInfo = getRepositoryInfo(entry); >+ if (repositoryInfo == null) { > String message = NLS.bind(Messages.error_missingDirectoryEntry, entry); > BundleHelper.getDefault().getLog().log(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null)); > return null; > } > >- String[] cvsFields = Utils.getArrayFromStringWithBlank(cvsInfo, ","); //$NON-NLS-1$ >- if (cvsFields.length < 2) { >- String message = NLS.bind(Messages.error_incorrectDirectoryEntry, element); >+ // collect and validate the repository info >+ String[] repositoryFields = Utils.getArrayFromStringWithBlank(repositoryInfo, ","); //$NON-NLS-1$ >+ if (repositoryFields.length < 2) { >+ String message = NLS.bind(Messages.error_incorrectDirectoryEntry, currentElement); > throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null)); > } > >- entryInfos.put(TAG, fetchTag.length() == 0 ? cvsFields[0] : fetchTag); >- entryInfos.put(CVSROOT, cvsFields[1]); >- entryInfos.put(PASSWORD, (cvsFields.length > 2 && !cvsFields[2].equals("")) ? cvsFields[2] : null); //$NON-NLS-1$ >- >- entryInfos.put(PATH, (cvsFields.length > 3 && !cvsFields[3].equals("")) ? cvsFields[3] : null); //$NON-NLS-1$ >- >- int index = entry.indexOf('@'); >- entryInfos.put(TYPE, entry.substring(0, index)); >- entryInfos.put(ELEMENT, entry.substring(index + 1)); >- return entryInfos; >- } >+ // determine fetch script builder >+ FetchTaskFactory fetchTaskFactory = null; >+ String[] arguments = null; > >- protected void generateFetchRecusivelyTarget() throws CoreException { >- script.printTargetDeclaration(TARGET_FETCH_RECURSIVELY, null, FEATURES_RECURSIVELY, null, null); >- >- IIncludedFeatureReference[] compiledFeatures = ((Feature) feature).getFeatureIncluded(); >- for (int i = 0; i < compiledFeatures.length; i++) { >- String featureId = compiledFeatures[i].getVersionedIdentifier().getIdentifier(); >- if (featureProperties.containsKey(GENERATION_SOURCE_FEATURE_PREFIX + featureId)) { >- String[] extraElementsToFetch = Utils.getArrayFromString(featureProperties.getProperty(GENERATION_SOURCE_FEATURE_PREFIX + featureId), ","); //$NON-NLS-1$ >- for (int j = 1; j < extraElementsToFetch.length; j++) { >- generateFetchEntry(extraElementsToFetch[j], false); >- } >- continue; >- } >- >- //Included features can be available in the baseLocation. >- if (getCVSInfo(FEATURE + '@' + featureId) != null) >- script.printAntTask(Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY) + '/' + FETCH_FILE_PREFIX + featureId + ".xml", null, TARGET_FETCH, null, null, null); //$NON-NLS-1$ >- else if (getSite(false).findFeature(featureId, null, false) == null) { >- String message = NLS.bind(Messages.error_cannotFetchNorFindFeature, featureId); >- throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_FEATURE_MISSING, message, null)); >- } >- } >- script.printTargetEnd(); >- } >+ // check if first repository field matches a builder id >+ if (FetchTaskFactoriesRegistry.getRegistry().getBuilderIds().contains(repositoryFields[0])) { >+ fetchTaskFactory = FetchTaskFactoriesRegistry.getRegistry().getFactory(repositoryFields[0]); > >- protected boolean generateFetchEntry(String entry, boolean manifestFileOnly) throws CoreException { >- Map mapFileEntry = mapInfos; >- if (!entry.equals(element)) { >- mapFileEntry = processMapFileEntry(entry); >- if (mapFileEntry == null) >- return false; >+ // construct arguments array for registered builder >+ arguments = new String[repositoryFields.length - 1]; >+ System.arraycopy(repositoryFields, 1, arguments, 0, repositoryFields.length - 1); > } > >- String password = (String) mapFileEntry.get(PASSWORD); >- if (password != null) >- script.printCVSPassTask((String) mapFileEntry.get(CVSROOT), password, cvsPassFileLocation); >- >- String type = (String) mapFileEntry.get(TYPE); >- String location = getElementLocation(type); >- Map params = new HashMap(5); >- >- //We directly export the CVS content into the correct directory >- params.put("destination", mapFileEntry.get(ELEMENT)); //$NON-NLS-1$ >- params.put(TAG, mapFileEntry.get(TAG)); >- params.put(CVSROOT, mapFileEntry.get(CVSROOT)); >- params.put("quiet", "${quiet}"); //$NON-NLS-1$ //$NON-NLS-2$ >- >- String cvsPackage = ((String) mapFileEntry.get(PATH) == null ? (String) mapFileEntry.get(ELEMENT) : (String) mapFileEntry.get(PATH)); >- String fullLocation = null; >- if (type.equals(FEATURE)) { >- fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_FEATURE_FILENAME_DESCRIPTOR; >- params.put("fileToCheck", fullLocation); //$NON-NLS-1$ >- cvsPackage += manifestFileOnly ? '/' + DEFAULT_FEATURE_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$ >- repositoryFeatureTags.put(mapFileEntry.get(ELEMENT), mapFileEntry.get(TAG)); >- } else if (type.equals(PLUGIN)) { >- fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_PLUGIN_FILENAME_DESCRIPTOR; >- params.put("fileToCheck", fullLocation); //$NON-NLS-1$ >- cvsPackage += manifestFileOnly ? '/' + DEFAULT_PLUGIN_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$ >- repositoryPluginTags.put(mapFileEntry.get(ELEMENT), mapFileEntry.get(TAG)); >- } else if (type.equals(FRAGMENT)) { >- fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_FRAGMENT_FILENAME_DESCRIPTOR; >- params.put("fileToCheck", fullLocation); //$NON-NLS-1$ >- cvsPackage += manifestFileOnly ? '/' + DEFAULT_FRAGMENT_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$ >- repositoryPluginTags.put(mapFileEntry.get(ELEMENT), mapFileEntry.get(TAG)); >- } else if (type.equals(BUNDLE)) { >- fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR; >- params.put("fileToCheck", fullLocation); //$NON-NLS-1$ >- cvsPackage += manifestFileOnly ? '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR : "";//$NON-NLS-1$ >- repositoryPluginTags.put(mapFileEntry.get(ELEMENT), mapFileEntry.get(TAG)); >- } >- params.put("package", cvsPackage); //$NON-NLS-1$ >+ // default to CVS builder (to be compatible) >+ if (null == fetchTaskFactory) { >+ // fall back to CVS >+ fetchTaskFactory = new CVSFetchTaskFactory(); > >- // This call create a new property for every feature, plugins or fragments that we must check the existence of >- script.printAvailableTask(fullLocation, fullLocation); >- if (type.equals(PLUGIN) || type.equals(FRAGMENT)) { >- script.printAvailableTask(fullLocation, location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR); >+ // construct arguments array for CVS builder >+ arguments = repositoryFields; > } >- script.printAntTask("../" + scriptName, Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY) + '/' + (type.equals(FEATURE) ? DEFAULT_FEATURE_LOCATION : DEFAULT_PLUGIN_LOCATION), TARGET_GET_FROM_CVS, null, null, params); //$NON-NLS-1$ >- return true; >- } >- >- protected void generateGetFromCVSTarget() { >- script.printTargetDeclaration(TARGET_GET_FROM_CVS, null, null, "${fileToCheck}", "{destination}"); //$NON-NLS-1$ //$NON-NLS-2$ >- script.printCVSTask("export -d ${destination} -r ${tag} ${package}", "${cvsRoot}", null, null, null, "${quiet}", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- script.printTargetEnd(); >- } >- >- /** >- * Helper method to control for what locations a mkdir Ant task was already >- * generated so we can reduce replication. >- * >- * @param location >- */ >- protected void generateMkdirs(String location) { >- if (mkdirLocations.contains(location)) >- return; >- mkdirLocations.add(location); >- script.printMkdirTask(location); >- } > >- /** >- * >- * @throws CoreException >- */ >- protected void generateChildrenFetchScript() throws CoreException { >- IPluginEntry[] allChildren = feature.getRawPluginEntries(); >- IPluginEntry[] compiledChildren = feature.getPluginEntries(); >+ // add infos from registered builder >+ fetchTaskFactory.processMapFileEntry(currentElement, type, arguments, fetchTag, entryInfos); > >- for (int i = 0; i < allChildren.length; i++) { >- String elementId = allChildren[i].getVersionedIdentifier().getIdentifier(); >- // We are not fetching the elements that are said to be generated, but we are fetching some elements that can be associated >- if (featureProperties.containsKey(GENERATION_SOURCE_PLUGIN_PREFIX + elementId)) { >- String[] extraElementsToFetch = Utils.getArrayFromString(featureProperties.getProperty(GENERATION_SOURCE_PLUGIN_PREFIX + elementId), ","); //$NON-NLS-1$ >- for (int j = 1; j < extraElementsToFetch.length; j++) { >- generateFetchEntry(extraElementsToFetch[j], false); >- } >- continue; >- } >+ // store builder >+ entryInfos.put(FETCH_TASK_FACTORY, fetchTaskFactory); > >- boolean generated = true; >- if (allChildren[i].isFragment()) >- generated = generateFetchEntry(FRAGMENT + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i])); >- else >- generated = generateFetchEntry(PLUGIN + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i])); >- if (generated == false) >- generateFetchEntry(BUNDLE + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i])); >- } >+ // add general infos (will override builder specific infos) >+ entryInfos.put(TYPE, type); >+ entryInfos.put(ELEMENT, currentElement); >+ return entryInfos; > } > > /** >@@ -379,37 +452,30 @@ > * constructor from Update. > * > * @param elementName the feature to retrieve >- * @param cvsRoot the root in CVS >- * @param tag the CVS tag >- * @param password the CVS password >+ * @param elementType the element type >+ * @param elementInfos the element information > * @throws CoreException > */ >- protected void retrieveFeature(String elementName, String cvsRoot, String tag, String password, String path) throws CoreException { >+ protected void retrieveFeature(String elementName, String elementType, Map elementInfos) throws CoreException { > // Generate a temporary Ant script which retrieves the feature.xml for this > // feature from CVS > File root = new File(workingDirectory); >- File target = new File(root, DEFAULT_RETRIEVE_FILENAME_DESCRIPTOR); >+ File target = new File(root, DEFAULT_RETRIEVE_FILENAME_DESCRIPTOR); > try { > AntScript retrieve = new AntScript(new FileOutputStream(target)); > try { > retrieve.printProjectDeclaration("RetrieveFeature", "main", "."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- retrieve.printTargetDeclaration(TARGET_MAIN, null, null, null, null); >+ retrieve.printTargetDeclaration(TARGET_MAIN, null, null, null, null); > >- IPath moduleFeatureFile; >- IPath moduleFeatureProperties; >- if (path != null) { >- moduleFeatureFile = new Path(path).append(DEFAULT_FEATURE_FILENAME_DESCRIPTOR); >- moduleFeatureProperties = new Path(path).append(PROPERTIES_FILE); >- } else { >- moduleFeatureFile = new Path(elementName).append(DEFAULT_FEATURE_FILENAME_DESCRIPTOR); >- moduleFeatureProperties = new Path(elementName).append(PROPERTIES_FILE); >+ String destination = elementName; >+ String[] files = new String[] {DEFAULT_FEATURE_FILENAME_DESCRIPTOR, PROPERTIES_FILE}; >+ FetchTaskFactory factory = (FetchTaskFactory) elementInfos.get(FETCH_TASK_FACTORY); >+ CharSequence retrieveFeatureTask = factory.generateRetrieveFilesTask(elementName, elementType, elementInfos, destination, files); >+ if (null == retrieveFeatureTask) { >+ String message = NLS.bind(Messages.error_noRetrieveFeatureTask, elementName); >+ throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null)); > } >- >- if (password != null) >- retrieve.printCVSPassTask(cvsRoot, password, cvsPassFileLocation); >- >- retrieve.printCVSTask("export -r " + tag + " " + moduleFeatureFile.toString(), cvsRoot, null, null, null, "true", null); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ >- retrieve.printCVSTask("export -r " + tag + " " + moduleFeatureProperties.toString(), cvsRoot, null, null, null, "true", null); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ >+ retrieve.print(retrieveFeatureTask); > > retrieve.printTargetEnd(); > retrieve.printProjectEnd(); >@@ -427,14 +493,15 @@ > AntRunner runner = new AntRunner(); > runner.setBuildFileLocation(target.getAbsolutePath()); > runner.run(); >+ String destination = elementName; > FeatureExecutableFactory factory = new FeatureExecutableFactory(); >- File featureFolder = new File(root, (path == null ? elementName : path)); >+ File featureFolder = new File(root, destination); > feature = factory.createFeature(featureFolder.toURL(), null, null); > > //We only delete here, so if an exception is thrown the user can still see the retrieve.xml > target.delete(); > featureProperties = new Properties(); >- InputStream featureStream = new FileInputStream(new File(root, (path == null ? elementName : path) + '/' + PROPERTIES_FILE)); >+ InputStream featureStream = new FileInputStream(new File(root, destination + '/' + PROPERTIES_FILE)); > featureProperties.load(featureStream); > featureStream.close(); > clear(featureFolder); >@@ -448,79 +515,47 @@ > } > } > >- /** >- * Deletes all the files and directories from the given root down (inclusive). >- * Returns false if we could not delete some file or an exception occurred >- * at any point in the deletion. >- * Even if an exception occurs, a best effort is made to continue deleting. >- * >- * @param root >- * @return boolean >- */ >- public static boolean clear(File root) { >- boolean result = true; >- if (root.isDirectory()) { >- String[] list = root.list(); >- // for some unknown reason, list() can return null. >- // Just skip the children If it does. >- if (list != null) >- for (int i = 0; i < list.length; i++) >- result &= clear(new java.io.File(root, list[i])); >- } >+ private void saveRepositoryTags() throws CoreException { >+ saveRepositoryTags(repositoryPluginTags, DEFAULT_PLUGIN_REPOTAG_FILENAME_DESCRIPTOR); >+ saveRepositoryTags(repositoryFeatureTags, DEFAULT_FEATURE_REPOTAG_FILENAME_DESCRIPTOR); >+ } >+ >+ private void saveRepositoryTags(Properties properties, String fileName) throws CoreException { > try { >- if (root.exists()) >- result &= root.delete(); >- } catch (Exception e) { >- // ignore any exceptions >- result = false; >+ InputStream input = new BufferedInputStream(new FileInputStream(workingDirectory + '/' + fileName)); >+ try { >+ properties.load(input); >+ } finally { >+ input.close(); >+ } >+ } catch (IOException e) { >+ //ignore the exception, the same may not exist > } >- return result; >- } > >- /** >- * >- * @param type >- * @return String >- */ >- protected String getElementLocation(String type) { >- IPath location = new Path(Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY)); >- if (type.equals(FEATURE)) >- location = location.append(DEFAULT_FEATURE_LOCATION); >- else >- location = location.append(DEFAULT_PLUGIN_LOCATION); >- return location.toString(); >+ try { >+ OutputStream os = new BufferedOutputStream(new FileOutputStream(workingDirectory + '/' + fileName)); >+ try { >+ properties.store(os, null); >+ } finally { >+ os.close(); >+ } >+ } catch (IOException e) { >+ String message = NLS.bind(Messages.exception_writingFile, workingDirectory + '/' + fileName); >+ throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_WRITING_FILE, message, null)); >+ } > } > > /** >- * Get information stored in the directory file. >+ * Sets the CVS password file location to be the given value. > * >- * @param elementName >- * @return String >- * @throws CoreException >- */ >- protected String getCVSInfo(String elementName) throws CoreException { >- if (directory == null) >- directory = readProperties(directoryLocation, "", IStatus.ERROR); //$NON-NLS-1$ >- return directory.getProperty(elementName); >- } >- >- /** >- * Defines, the XML declaration and Ant project. >+ * @param cvsPassFileLocation the CVS password file location > */ >- protected void generatePrologue() { >- script.println(); >- script.printComment("Fetch script for " + element); //$NON-NLS-1$ >- script.println(); >- script.printProjectDeclaration("FetchScript", TARGET_FETCH, null); //$NON-NLS-1$ >- script.printProperty(PROPERTY_QUIET, "true"); //$NON-NLS-1$ >+ public void setCvsPassFileLocation(String cvsPassFileLocation) { >+ this.cvsPassFileLocation = cvsPassFileLocation; > } > >- /** >- * Just ends the script. >- */ >- protected void generateEpilogue() { >- script.println(); >- script.printProjectEnd(); >+ public void setDirectory(Properties dir) { >+ directory = dir; > } > > /** >@@ -532,6 +567,10 @@ > this.directoryLocation = directoryLocation; > } > >+ public void setElement(String element) { >+ this.element = element; >+ } >+ > /** > * Sets whether children of the current element should be fetched. > * >@@ -552,20 +591,7 @@ > fetchTag = value; > } > >- /** >- * Sets the CVS password file location to be the given value. >- * >- * @param cvsPassFileLocation the CVS password file location >- */ >- public void setCvsPassFileLocation(String cvsPassFileLocation) { >- this.cvsPassFileLocation = cvsPassFileLocation; >- } >- > public void setRecursiveGeneration(boolean recursiveGeneration) { > this.recursiveGeneration = recursiveGeneration; > } >- >- public void setDirectory(Properties dir) { >- directory = dir; >- } > } >Index: src/org/eclipse/pde/internal/build/Messages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/Messages.java,v >retrieving revision 1.9 >diff -u -r1.9 Messages.java >--- src/org/eclipse/pde/internal/build/Messages.java 7 Dec 2005 22:31:20 -0000 1.9 >+++ src/org/eclipse/pde/internal/build/Messages.java 31 Jan 2006 08:02:41 -0000 >@@ -33,7 +33,8 @@ > public static String error_configWrongFormat; > public static String error_missingCustomBuildFile; > public static String error_missingSourceFolder; >- >+ public static String error_noRetrieveFeatureTask; >+ > // exception > public static String exception_missingElement; > public static String exception_missingFeature; >Index: src/org/eclipse/pde/internal/build/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/messages.properties,v >retrieving revision 1.39 >diff -u -r1.39 messages.properties >--- src/org/eclipse/pde/internal/build/messages.properties 7 Dec 2005 22:31:20 -0000 1.39 >+++ src/org/eclipse/pde/internal/build/messages.properties 31 Jan 2006 08:02:41 -0000 >@@ -29,7 +29,8 @@ > error_configWrongFormat = {0} is not a valid configuration. > error_missingCustomBuildFile = No custom build file found in {0}. > error_missingSourceFolder = In plugin {0}, the value for property {1} is not set. >- >+error_noRetrieveFeatureTask = No fetch task available for element {0}, check your map files. >+ > ### exception > exception_missingElement = Unable to find element: {0}. > exception_missingFeature = Unable to find feature: {0}. >Index: src/org/eclipse/pde/internal/build/ant/AntScript.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ant/AntScript.java,v >retrieving revision 1.42 >diff -u -r1.42 AntScript.java >--- src/org/eclipse/pde/internal/build/ant/AntScript.java 23 Jan 2006 15:55:23 -0000 1.42 >+++ src/org/eclipse/pde/internal/build/ant/AntScript.java 31 Jan 2006 08:02:41 -0000 >@@ -12,6 +12,8 @@ > > import java.io.*; > import java.util.*; >+import org.eclipse.core.runtime.*; >+import org.eclipse.pde.internal.build.IPDEBuildConstants; > > /** > * Class for producing Ant scripts. Contains convenience methods for creating the >@@ -20,21 +22,55 @@ > */ > public class AntScript { > >+ /** >+ * Converts the specified task to a String. >+ * @param task >+ * @return a String reprecentation of an ITask. >+ */ >+ public static String taskAsString(ITask task) throws CoreException { >+ if (null == task) >+ return null; >+ >+ ByteArrayOutputStream out = new ByteArrayOutputStream(); >+ try { >+ AntScript script = new AntScript(out, false); >+ task.print(script); >+ script.close(); >+ return out.toString("UTF8"); //$NON-NLS-1$ >+ } catch (IOException e) { >+ String message = e.getMessage(); >+ throw new CoreException(new Status(IStatus.ERROR, IPDEBuildConstants.PI_PDEBUILD, IPDEBuildConstants.EXCEPTION_WRITING_SCRIPT, message, null)); >+ } >+ } >+ > protected OutputStream out; > protected PrintWriter output; > protected final String XML_PROLOG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; //$NON-NLS-1$ >+ > protected int indent = 0; > > /** >- * Constructor for the class. >+ * Creates a new Ant script including the XML prolog <code><?xml ... ?></code>. > * > * @param out the output stream to write the script to > * @throws IOException > */ > public AntScript(OutputStream out) throws IOException { >+ this(out, true); >+ } >+ >+ /** >+ * Constructor for the class. >+ * >+ * @param out the output stream to write the script to >+ * @param writeXMLProlog indicates if the XML prolog should be written >+ * @throws IOException >+ */ >+ public AntScript(OutputStream out, boolean writeXMLProlog) throws IOException { > this.out = out; > output = new PrintWriter(new OutputStreamWriter(out, "UTF8")); //$NON-NLS-1$ >- output.println(XML_PROLOG); >+ if(writeXMLProlog) >+ output.println(XML_PROLOG); > } > > /** >@@ -53,6 +89,33 @@ > } > > /** >+ * Print the given char sequence to the Ant script. >+ * >+ * @param charSequence the char sequence to print >+ */ >+ public void print(CharSequence charSequence) { >+ output.print(charSequence.toString()); >+ } >+ >+ /** >+ * Print the given task to the Ant script. >+ * >+ * @param task the task to print >+ */ >+ public void print(ITask task) { >+ task.print(this); >+ } >+ >+ /** >+ * Print the given string to the Ant script. >+ * >+ * @param message >+ */ >+ public void print(String message) { >+ output.print(message); >+ } >+ >+ /** > * Print an <code>antcall</code> task to the script. This calls Ant on the given > * target which is located within the same build file. > * >@@ -81,53 +144,6 @@ > output.println("</antcall>"); //$NON-NLS-1$ > } > } >- >- /** >- * Print a <code>jar</code> Ant task to this script. This jars together a group of >- * files into a single file. >- * >- * @param jarFile the destination file name >- * @param basedir the base directory >- */ >- public void printJarTask(String jarFile, String basedir, String manifestAttribute) { >- printTab(); >- output.print("<jar"); //$NON-NLS-1$ >- printAttribute("destfile", jarFile, true); //$NON-NLS-1$ >- printAttribute("basedir", basedir, false); //$NON-NLS-1$ >- printAttribute("manifest", manifestAttribute, false); //$NON-NLS-1$ >- output.println("/>"); //$NON-NLS-1$ >- } >- >- /** >- * Print the <code>available</code> Ant task to this script. This task sets a property >- * value if the given file exists at runtime. >- * >- * @param property the property to set >- * @param file the file to look for >- */ >- public void printAvailableTask(String property, String file) { >- printTab(); >- output.print("<available"); //$NON-NLS-1$ >- printAttribute("property", property, true); //$NON-NLS-1$ >- printAttribute("file", file, false); //$NON-NLS-1$ >- output.println("/>"); //$NON-NLS-1$ >- } >- >- /** >- * Print the <code>available</code> Ant task to this script. This task sets a property >- * to the given value if the given file exists at runtime. >- * >- * @param property the property to set >- * @param file the file to look for >- */ >- public void printAvailableTask(String property, String file, String value){ >- printTab(); >- output.print("<available"); //$NON-NLS-1$ >- printAttribute("property", property, true); //$NON-NLS-1$ >- printAttribute("file", file, false); //$NON-NLS-1$ >- printAttribute("value", value, false); //$NON-NLS-1$ >- output.println("/>"); //$NON-NLS-1$ >- } > > /** > * Print an <code>ant</code> task to this script. This calls Ant on the specified >@@ -144,7 +160,7 @@ > public void printAntTask(String antfile, String dir, String target, String outputParam, String inheritAll, Map properties ) { > printAntTask(antfile, dir, target, outputParam, inheritAll, properties, null ); > } >- >+ > /** > * Print an <code>ant</code> task to this script. This calls Ant on the specified > * target contained in the specified Ant file with the given parameters. >@@ -196,95 +212,6 @@ > output.println("</ant>"); //$NON-NLS-1$ > } > } >- >- public void printSubantTask(String antfile, String target, String buildpath, String failOnError, Map properties, Map references) { >- printTab(); >- output.print("<subant"); //$NON-NLS-1$ >- printAttribute("antfile", antfile, false); //$NON-NLS-1$ >- printAttribute("target", target, false); //$NON-NLS-1$ >- printAttribute("failonerror", failOnError, false); //$NON-NLS-1$ >- printAttribute("buildpath", buildpath, false); //$NON-NLS-1$ >- if (properties == null && references == null) >- output.println("/>"); //$NON-NLS-1$ >- else { >- output.println(">"); //$NON-NLS-1$ >- indent++; >- if( properties != null ) { >- Set entries = properties.entrySet(); >- for (Iterator iter = entries.iterator(); iter.hasNext();) { >- Map.Entry entry = (Map.Entry) iter.next(); >- printProperty((String) entry.getKey(), (String) entry.getValue()); >- } >- } >- if( references != null ){ >- Set entries = references.entrySet(); >- for (Iterator iter = entries.iterator(); iter.hasNext();) { >- Map.Entry entry = (Map.Entry) iter.next(); >- printTab(); >- print("<reference refid=\"" + (String)entry.getKey() + "\""); //$NON-NLS-1$ //$NON-NLS-2$ >- if( entry.getValue() != null ){ >- print(" torefid=\"" + (String) entry.getValue() + "\""); //$NON-NLS-1$ //$NON-NLS-2$ >- } >- print("/>"); //$NON-NLS-1$ >- println(); >- } >- } >- indent--; >- printTab(); >- output.println("</subant>"); //$NON-NLS-1$ >- } >- } >- /** >- * Print a <code>zip</code> task to this script. >- * >- * @param zipfile the destination file name >- * @param basedir the source directory to start the zip >- * @param filesOnly <code>true</code> if the resulting zip file should contain only files and not directories >- * @param update ndicates whether to update or overwrite the destination file if it already exists >- * @param fileSets the inclusion/exclusion rules to use when zipping >- */ >- public void printZipTask(String zipfile, String basedir, boolean filesOnly, boolean update, FileSet[] fileSets) { >- printTab(); >- output.print("<zip"); //$NON-NLS-1$ >- printAttribute("destfile", zipfile, true); //$NON-NLS-1$ >- printAttribute("basedir", basedir, false); //$NON-NLS-1$ >- printAttribute("filesonly", filesOnly ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- printAttribute("whenempty", "skip", true); //$NON-NLS-1$//$NON-NLS-2$ >- printAttribute("update", update ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- if (fileSets == null) >- output.println("/>"); //$NON-NLS-1$ >- else { >- output.println(">"); //$NON-NLS-1$ >- indent++; >- for (int i = 0; i < fileSets.length; i++) >- if (fileSets[i] != null) >- fileSets[i].print(this); >- indent--; >- printTab(); >- output.println("</zip>"); //$NON-NLS-1$ >- } >- } >- >- public void printTarTask(String zipfile, String basedir, boolean filesOnly, boolean update, FileSet[] fileSets) { >- printTab(); >- output.print("<tar"); //$NON-NLS-1$ >- printAttribute("destfile", zipfile, true); //$NON-NLS-1$ >- printAttribute("basedir", basedir, false); //$NON-NLS-1$ >- printAttribute("compression", "gzip", true); //$NON-NLS-1$//$NON-NLS-2$ >- if (fileSets == null) >- output.println("/>"); //$NON-NLS-1$ >- else { >- output.println(">"); //$NON-NLS-1$ >- indent++; >- for (int i = 0; i < fileSets.length; i++) >- if (fileSets[i] != null) >- fileSets[i].print(this); >- indent--; >- printTab(); >- output.println("</tar>"); //$NON-NLS-1$ >- } >- } >- > /** > * Print an <code>arg</code> element to the Ant file. > * >@@ -298,28 +225,6 @@ > } > > /** >- * Print the given string to the Ant script. >- * >- * @param string the string to write to the file >- */ >- public void printString(String string) { >- printTab(); >- output.println(string); >- } >- >- /** >- * Print the given comment to the Ant script. >- * >- * @param comment the comment to write out >- */ >- public void printComment(String comment) { >- printTab(); >- output.print("<!-- "); //$NON-NLS-1$ >- output.print(comment); >- output.println(" -->"); //$NON-NLS-1$ >- } >- >- /** > * Add the given name/value attribute pair to the script. Do not write the attribute > * if the value is <code>null</code> unless a <code>true</code> is specified > * indicating that it is mandatory. >@@ -341,46 +246,105 @@ > } > > /** >- * Print a <code>copy</code> task to the script. The source file is specified >- * by the <code>file</code> parameter. The destination directory is specified by >- * the <code>todir</code> parameter. >- * @param file the source file >- * @param todir the destination directory >- * @param fileSets the inclusion/exclusion rules to use when copying >- * @param overwrite TODO >+ * Print the <code>available</code> Ant task to this script. This task sets a property >+ * value if the given file exists at runtime. >+ * >+ * @param property the property to set >+ * @param file the file to look for > */ >- public void printCopyTask(String file, String todir, FileSet[] fileSets, boolean failOnError, boolean overwrite) { >+ public void printAvailableTask(String property, String file) { > printTab(); >- output.print("<copy"); //$NON-NLS-1$ >+ output.print("<available"); //$NON-NLS-1$ >+ printAttribute("property", property, true); //$NON-NLS-1$ > printAttribute("file", file, false); //$NON-NLS-1$ >- printAttribute("todir", todir, false); //$NON-NLS-1$ >- printAttribute("failonerror", failOnError ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- printAttribute("overwrite", overwrite ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- if (fileSets == null) >- output.println("/>"); //$NON-NLS-1$ >- else { >- output.println(">"); //$NON-NLS-1$ >- indent++; >- for (int i = 0; i < fileSets.length; i++) >- fileSets[i].print(this); >- indent--; >- printTab(); >- output.println("</copy>"); //$NON-NLS-1$ >- } >+ output.println("/>"); //$NON-NLS-1$ > } > >- public void printMoveTask(String todir, FileSet[] fileSets, boolean failOnError) { >- printTab(); >- output.print("<move"); //$NON-NLS-1$ >- printAttribute("todir", todir, false); //$NON-NLS-1$ >- printAttribute("failonerror", failOnError ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- output.println(">"); //$NON-NLS-1$ >- indent++; >- for (int i = 0; i < fileSets.length; i++) >- fileSets[i].print(this); >- indent--; >+ /** >+ * Print the <code>available</code> Ant task to this script. This task sets a property >+ * to the given value if the given file exists at runtime. >+ * >+ * @param property the property to set >+ * @param file the file to look for >+ */ >+ public void printAvailableTask(String property, String file, String value){ > printTab(); >- output.println("</move>"); //$NON-NLS-1$ >+ output.print("<available"); //$NON-NLS-1$ >+ printAttribute("property", property, true); //$NON-NLS-1$ >+ printAttribute("file", file, false); //$NON-NLS-1$ >+ printAttribute("value", value, false); //$NON-NLS-1$ >+ output.println("/>"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Print a <code>brand</code> task to the Ant script. >+ * >+ * @param root the location of the launcher to brand. >+ * @param icons the list of icons to use in the branding >+ * @param name the name of the resultant launcher >+ */ >+ public void printBrandTask(String root, String icons, String name, String os) { >+ printTab(); >+ print("<eclipse.brand"); //$NON-NLS-1$ >+ printAttribute("root", root, true); //$NON-NLS-1$ >+ if (icons != null) >+ printAttribute("icons", icons, true); //$NON-NLS-1$ >+ printAttribute("name", name, true); //$NON-NLS-1$ >+ printAttribute("os", os, true); //$NON-NLS-1$ >+ println("/>"); //$NON-NLS-1$ >+ } >+ >+ public void printChmod(String dir, String rights, String files) { >+ printTab(); >+ output.print("<chmod perm=\"" + rights + "\" "); //$NON-NLS-1$//$NON-NLS-2$ >+ output.print("dir=\"" + dir + "\" "); //$NON-NLS-1$//$NON-NLS-2$ >+ output.print("includes=\"" + files + "\" /> "); //$NON-NLS-1$ //$NON-NLS-2$ >+ output.println(); >+ } >+ >+ /** >+ * Print the given comment to the Ant script. >+ * >+ * @param comment the comment to write out >+ */ >+ public void printComment(String comment) { >+ printTab(); >+ output.print("<!-- "); //$NON-NLS-1$ >+ output.print(comment); >+ output.println(" -->"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Print a <code>Condition</code> task with isset test to the script >+ * @param property name of the property to set >+ * @param value value to set the property to >+ * @param testProperty name of the property for the isset test >+ */ >+ public void printConditionIsSet(String property, String value, String testProperty) { >+ println("<condition property=\"" + property + "\" value=\"" + value + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ indent++; >+ println("<isset property=\"" + testProperty + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ >+ indent--; >+ printEndTag("condition"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Print a <code> eclipse.convertTask</code> task to the script. This task convert a file path to >+ * an Eclipse resource or vice-versa. >+ * >+ * @param toConvert the entry to convert >+ * @param propertyName the property where to store the result of the convertion >+ * @param isEclipseResource true if toConvert refers to an eclipse resource. >+ */ >+ public void printConvertPathTask(String toConvert, String propertyName, boolean isEclipseResource) { >+ printTab(); >+ output.print("<eclipse.convertPath"); //$NON-NLS-1$ >+ if (isEclipseResource == false) >+ printAttribute("fileSystemPath", toConvert, true); //$NON-NLS-1$ >+ else >+ printAttribute("resourcePath", toConvert, true); //$NON-NLS-1$ >+ printAttribute("property", propertyName, true); //$NON-NLS-1$ >+ output.println("/>"); //$NON-NLS-1$ > } > > /** >@@ -400,6 +364,75 @@ > } > > /** >+ * Print a <code>copy</code> task to the script. The source file is specified >+ * by the <code>file</code> parameter. The destination directory is specified by >+ * the <code>todir</code> parameter. >+ * @param file the source file >+ * @param todir the destination directory >+ * @param fileSets the inclusion/exclusion rules to use when copying >+ * @param overwrite TODO >+ */ >+ public void printCopyTask(String file, String todir, FileSet[] fileSets, boolean failOnError, boolean overwrite) { >+ printTab(); >+ output.print("<copy"); //$NON-NLS-1$ >+ printAttribute("file", file, false); //$NON-NLS-1$ >+ printAttribute("todir", todir, false); //$NON-NLS-1$ >+ printAttribute("failonerror", failOnError ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ printAttribute("overwrite", overwrite ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ if (fileSets == null) >+ output.println("/>"); //$NON-NLS-1$ >+ else { >+ output.println(">"); //$NON-NLS-1$ >+ indent++; >+ for (int i = 0; i < fileSets.length; i++) >+ fileSets[i].print(this); >+ indent--; >+ printTab(); >+ output.println("</copy>"); //$NON-NLS-1$ >+ } >+ } >+ >+ /** >+ * Print a <code>cvspass</code> task to the Ant script. >+ * >+ * @param cvsRoot the name of the repository >+ * @param password the password >+ * @param passFile the name of the password file >+ */ >+ public void printCVSPassTask(String cvsRoot, String password, String passFile) { >+ printTab(); >+ output.print("<cvspass"); //$NON-NLS-1$ >+ printAttribute("cvsRoot", cvsRoot, true); //$NON-NLS-1$ >+ printAttribute("password", password, true); //$NON-NLS-1$ >+ printAttribute("passfile", passFile, false); //$NON-NLS-1$ >+ output.println("/>"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Print a <code>cvs</code> task to the Ant script. >+ * >+ * @param command the CVS command to run >+ * @param cvsRoot value for the CVSROOT variable >+ * @param dest the destination directory for the checked out resources >+ * @param module the module name to check out >+ * @param tag the tag of the module to check out >+ * @param quiet whether or not to print informational messages to the output >+ * @param passFile the name of the password file >+ */ >+ public void printCVSTask(String command, String cvsRoot, String dest, String module, String tag, String quiet, String passFile) { >+ printTab(); >+ output.print("<cvs"); //$NON-NLS-1$ >+ printAttribute("command", command, false); //$NON-NLS-1$ >+ printAttribute("cvsRoot", cvsRoot, false); //$NON-NLS-1$ >+ printAttribute("dest", dest, false); //$NON-NLS-1$ >+ printAttribute("package", module, false); //$NON-NLS-1$ >+ printAttribute("tag", tag, false); //$NON-NLS-1$ >+ printAttribute("quiet", quiet, false); //$NON-NLS-1$ >+ printAttribute("passfile", passFile, false); //$NON-NLS-1$ >+ output.println("/>"); //$NON-NLS-1$ >+ } >+ >+ /** > * Print a <code>delete</code> task to the Ant script. At least one of <code>dir</code> > * or <code>file</code> is required unless some <code>fileSets</code> are > * present. >@@ -427,6 +460,43 @@ > } > > /** >+ * Print a <code> dirname </code> task to the script. >+ * @param property >+ * @param file >+ */ >+ public void printDirName(String property, String file) { >+ printTab(); >+ output.print("<dirname"); //$NON-NLS-1$ >+ printAttribute("property", property, true); //$NON-NLS-1$ >+ printAttribute("file", file, true); //$NON-NLS-1$ >+ output.println("/>"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Print an <code>echo</code> task to the Ant script. >+ * >+ * @param message the message to echo to the output >+ */ >+ public void printEchoTask(String message) { >+ printTab(); >+ output.print("<echo"); //$NON-NLS-1$ >+ printAttribute("message", message, true); //$NON-NLS-1$ >+ output.println("/>"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Print an end tag in the Ant script for the given element name. >+ * >+ * @param tag the name of the element >+ */ >+ public void printEndTag(String tag) { >+ printTab(); >+ output.print("</"); //$NON-NLS-1$ >+ output.print(tag); >+ output.println(">"); //$NON-NLS-1$ >+ } >+ >+ /** > * Print an <code>exec</code> task to the Ant script. > * > * @param executable the program to execute >@@ -452,85 +522,92 @@ > } > } > >+ public void printGet(String source, String destination, String login, String password, boolean usetimestamp) { >+ printTab(); >+ output.print("<get "); //$NON-NLS-1$ >+ printAttribute("username", login, false); //$NON-NLS-1$ >+ printAttribute("password", password, false); //$NON-NLS-1$ >+ printAttribute("src", source, true); //$NON-NLS-1$ >+ printAttribute("dest", destination, true); //$NON-NLS-1$ >+ printAttribute("usetimestamp", usetimestamp ? "true" : null, false); //$NON-NLS-1$ //$NON-NLS-2$ >+ output.println("/>"); //$NON-NLS-1$ >+ } >+ >+ public void printGZip(String source, String destination) { >+ printTab(); >+ output.println("<gzip src=\"" + source + "\" zipfile=\"" + destination + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ } >+ > /** >- * Print a <code>mkdir</code> task to the Ant script. >+ * Print a <code>jar</code> Ant task to this script. This jars together a group of >+ * files into a single file. > * >- * @param dir the name of the directory to create. >+ * @param jarFile the destination file name >+ * @param basedir the base directory > */ >- public void printMkdirTask(String dir) { >+ public void printJarTask(String jarFile, String basedir, String manifestAttribute) { > printTab(); >- output.print("<mkdir"); //$NON-NLS-1$ >- printAttribute("dir", dir, false); //$NON-NLS-1$ >+ output.print("<jar"); //$NON-NLS-1$ >+ printAttribute("destfile", jarFile, true); //$NON-NLS-1$ >+ printAttribute("basedir", basedir, false); //$NON-NLS-1$ >+ printAttribute("manifest", manifestAttribute, false); //$NON-NLS-1$ > output.println("/>"); //$NON-NLS-1$ > } > > /** >- * Print a <code>brand</code> task to the Ant script. >- * >- * @param root the location of the launcher to brand. >- * @param icons the list of icons to use in the branding >- * @param name the name of the resultant launcher >+ * Print a carriage-return to the Ant script. > */ >- public void printBrandTask(String root, String icons, String name, String os) { >- printTab(); >- print("<eclipse.brand"); //$NON-NLS-1$ >- printAttribute("root", root, true); //$NON-NLS-1$ >- if (icons != null) >- printAttribute("icons", icons, true); //$NON-NLS-1$ >- printAttribute("name", name, true); //$NON-NLS-1$ >- printAttribute("os", os, true); //$NON-NLS-1$ >- println("/>"); //$NON-NLS-1$ >+ public void println() { >+ output.println(); > } > > /** >- * Print an <code>echo</code> task to the Ant script. >+ * Print the given string to the Ant script followed by a carriage-return. > * >- * @param message the message to echo to the output >+ * @param message the string to print > */ >- public void printEchoTask(String message) { >+ public void println(String message) { > printTab(); >- output.print("<echo"); //$NON-NLS-1$ >- printAttribute("message", message, true); //$NON-NLS-1$ >- output.println("/>"); //$NON-NLS-1$ >+ output.println(message); > } > > /** >- * Print a <code>cvs</code> task to the Ant script. >+ * Print a <code>mkdir</code> task to the Ant script. > * >- * @param command the CVS command to run >- * @param cvsRoot value for the CVSROOT variable >- * @param dest the destination directory for the checked out resources >- * @param module the module name to check out >- * @param tag the tag of the module to check out >- * @param quiet whether or not to print informational messages to the output >- * @param passFile the name of the password file >+ * @param dir the name of the directory to create. > */ >- public void printCVSTask(String command, String cvsRoot, String dest, String module, String tag, String quiet, String passFile) { >+ public void printMkdirTask(String dir) { > printTab(); >- output.print("<cvs"); //$NON-NLS-1$ >- printAttribute("command", command, false); //$NON-NLS-1$ >- printAttribute("cvsRoot", cvsRoot, false); //$NON-NLS-1$ >- printAttribute("dest", dest, false); //$NON-NLS-1$ >- printAttribute("package", module, false); //$NON-NLS-1$ >- printAttribute("tag", tag, false); //$NON-NLS-1$ >- printAttribute("quiet", quiet, false); //$NON-NLS-1$ >- printAttribute("passfile", passFile, false); //$NON-NLS-1$ >+ output.print("<mkdir"); //$NON-NLS-1$ >+ printAttribute("dir", dir, false); //$NON-NLS-1$ > output.println("/>"); //$NON-NLS-1$ > } > >+ public void printMoveTask(String todir, FileSet[] fileSets, boolean failOnError) { >+ printTab(); >+ output.print("<move"); //$NON-NLS-1$ >+ printAttribute("todir", todir, false); //$NON-NLS-1$ >+ printAttribute("failonerror", failOnError ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ output.println(">"); //$NON-NLS-1$ >+ indent++; >+ for (int i = 0; i < fileSets.length; i++) >+ fileSets[i].print(this); >+ indent--; >+ printTab(); >+ output.println("</move>"); //$NON-NLS-1$ >+ } >+ > /** >- * Print a <code>cvspass</code> task to the Ant script. >+ * Print a <code>param</code> tag to the Ant script. > * >- * @param cvsRoot the name of the repository >- * @param password the password >- * @param passFile the name of the password file >+ * @param name the parameter name >+ * @param value the parameter value > */ >- public void printCVSPassTask(String cvsRoot, String password, String passFile) { >+ protected void printParam(String name, String value) { > printTab(); >- output.print("<cvspass"); //$NON-NLS-1$ >- printAttribute("cvsRoot", cvsRoot, true); //$NON-NLS-1$ >- printAttribute("password", password, true); //$NON-NLS-1$ >- printAttribute("passfile", passFile, false); //$NON-NLS-1$ >+ output.print("<param"); //$NON-NLS-1$ >+ printAttribute("name", name, true); //$NON-NLS-1$ >+ printAttribute("value", value, true); //$NON-NLS-1$ > output.println("/>"); //$NON-NLS-1$ > } > >@@ -564,20 +641,6 @@ > } > printEndTag(tag); > } >- >- /** >- * Print a <code>param</code> tag to the Ant script. >- * >- * @param name the parameter name >- * @param value the parameter value >- */ >- protected void printParam(String name, String value) { >- printTab(); >- output.print("<param"); //$NON-NLS-1$ >- printAttribute("name", name, true); //$NON-NLS-1$ >- printAttribute("value", value, true); //$NON-NLS-1$ >- output.println("/>"); //$NON-NLS-1$ >- } > > /** > * Print a <code>project</code> tag to the Ant script. >@@ -637,70 +700,87 @@ > } > > /** >- * Print a start tag in the Ant script for the given element name. >+ * Print a <code>eclipse.refreshLocal</code> task to the script. This task refreshes >+ * the specified resource in the workspace, to the specified depth. > * >- * @param tag the name of the element >+ * @param resource the resource to refresh >+ * @param depth one of <code>IResource.DEPTH_ZERO</code>, >+ * <code>IResource.DEPTH_ONE</code>, or <code>IResource.DEPTH_INFINITY</code> > */ >- public void printStartTag(String tag) { >+ public void printRefreshLocalTask(String resource, String depth) { > printTab(); >- output.print("<"); //$NON-NLS-1$ >- output.print(tag); >- output.println(">"); //$NON-NLS-1$ >+ output.print("<eclipse.refreshLocal"); //$NON-NLS-1$ >+ printAttribute("resource", resource, true); //$NON-NLS-1$ >+ printAttribute("depth", depth, false); //$NON-NLS-1$ >+ output.println("/>"); //$NON-NLS-1$ > } > > /** >- * Print an end tag in the Ant script for the given element name. >+ * Print a start tag in the Ant script for the given element name. > * > * @param tag the name of the element > */ >- public void printEndTag(String tag) { >+ public void printStartTag(String tag) { > printTab(); >- output.print("</"); //$NON-NLS-1$ >+ output.print("<"); //$NON-NLS-1$ > output.print(tag); > output.println(">"); //$NON-NLS-1$ > } > > /** >- * Print the given number of tabs to the Ant script. >- */ >- protected void printTab() { >- for (int i = 0; i < indent; i++) >- output.print("\t"); //$NON-NLS-1$ >- } >- >- /** >- * Print the given string to the Ant script followed by a carriage-return. >- * >- * @param message the string to print >- */ >- public void println(String message) { >- printTab(); >- output.println(message); >- } >- >- /** > * Print the given string to the Ant script. > * >- * @param message >+ * @param string the string to write to the file > */ >- public void print(String message) { >- output.print(message); >+ public void printString(String string) { >+ printTab(); >+ output.println(string); > } > >- /** >- * Print a carriage-return to the Ant script. >- */ >- public void println() { >- output.println(); >+ public void printSubantTask(String antfile, String target, String buildpath, String failOnError, Map properties, Map references) { >+ printTab(); >+ output.print("<subant"); //$NON-NLS-1$ >+ printAttribute("antfile", antfile, false); //$NON-NLS-1$ >+ printAttribute("target", target, false); //$NON-NLS-1$ >+ printAttribute("failonerror", failOnError, false); //$NON-NLS-1$ >+ printAttribute("buildpath", buildpath, false); //$NON-NLS-1$ >+ if (properties == null && references == null) >+ output.println("/>"); //$NON-NLS-1$ >+ else { >+ output.println(">"); //$NON-NLS-1$ >+ indent++; >+ if( properties != null ) { >+ Set entries = properties.entrySet(); >+ for (Iterator iter = entries.iterator(); iter.hasNext();) { >+ Map.Entry entry = (Map.Entry) iter.next(); >+ printProperty((String) entry.getKey(), (String) entry.getValue()); >+ } >+ } >+ if( references != null ){ >+ Set entries = references.entrySet(); >+ for (Iterator iter = entries.iterator(); iter.hasNext();) { >+ Map.Entry entry = (Map.Entry) iter.next(); >+ printTab(); >+ print("<reference refid=\"" + (String)entry.getKey() + "\""); //$NON-NLS-1$ //$NON-NLS-2$ >+ if( entry.getValue() != null ){ >+ print(" torefid=\"" + (String) entry.getValue() + "\""); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ print("/>"); //$NON-NLS-1$ >+ println(); >+ } >+ } >+ indent--; >+ printTab(); >+ output.println("</subant>"); //$NON-NLS-1$ >+ } > } > > /** >- * Print the given task to the Ant script. >- * >- * @param task the task to print >+ * Print the given number of tabs to the Ant script. > */ >- public void print(ITask task) { >- task.print(this); >+ protected void printTab() { >+ for (int i = 0; i < indent; i++) >+ output.print("\t"); //$NON-NLS-1$ > } > > /** >@@ -732,90 +812,55 @@ > indent--; > printEndTag("target"); //$NON-NLS-1$ > } >- >- /** >- * Print a <code>eclipse.refreshLocal</code> task to the script. This task refreshes >- * the specified resource in the workspace, to the specified depth. >- * >- * @param resource the resource to refresh >- * @param depth one of <code>IResource.DEPTH_ZERO</code>, >- * <code>IResource.DEPTH_ONE</code>, or <code>IResource.DEPTH_INFINITY</code> >- */ >- public void printRefreshLocalTask(String resource, String depth) { >- printTab(); >- output.print("<eclipse.refreshLocal"); //$NON-NLS-1$ >- printAttribute("resource", resource, true); //$NON-NLS-1$ >- printAttribute("depth", depth, false); //$NON-NLS-1$ >- output.println("/>"); //$NON-NLS-1$ >- } >- >- public void printChmod(String dir, String rights, String files) { >- printTab(); >- output.print("<chmod perm=\"" + rights + "\" "); //$NON-NLS-1$//$NON-NLS-2$ >- output.print("dir=\"" + dir + "\" "); //$NON-NLS-1$//$NON-NLS-2$ >- output.print("includes=\"" + files + "\" /> "); //$NON-NLS-1$ //$NON-NLS-2$ >- output.println(); >- } >- >- public void printGet(String source, String destination, String login, String password, boolean usetimestamp) { >- printTab(); >- output.print("<get "); //$NON-NLS-1$ >- printAttribute("username", login, false); //$NON-NLS-1$ >- printAttribute("password", password, false); //$NON-NLS-1$ >- printAttribute("src", source, true); //$NON-NLS-1$ >- printAttribute("dest", destination, true); //$NON-NLS-1$ >- printAttribute("usetimestamp", usetimestamp ? "true" : null, false); //$NON-NLS-1$ //$NON-NLS-2$ >- output.println("/>"); //$NON-NLS-1$ >- } >- >- public void printGZip(String source, String destination) { >- printTab(); >- output.println("<gzip src=\"" + source + "\" zipfile=\"" + destination + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- } >- >- /** >- * Print a <code> eclipse.convertTask</code> task to the script. This task convert a file path to >- * an Eclipse resource or vice-versa. >- * >- * @param toConvert the entry to convert >- * @param propertyName the property where to store the result of the convertion >- * @param isEclipseResource true if toConvert refers to an eclipse resource. >- */ >- public void printConvertPathTask(String toConvert, String propertyName, boolean isEclipseResource) { >+ >+ public void printTarTask(String zipfile, String basedir, boolean filesOnly, boolean update, FileSet[] fileSets) { > printTab(); >- output.print("<eclipse.convertPath"); //$NON-NLS-1$ >- if (isEclipseResource == false) >- printAttribute("fileSystemPath", toConvert, true); //$NON-NLS-1$ >- else >- printAttribute("resourcePath", toConvert, true); //$NON-NLS-1$ >- printAttribute("property", propertyName, true); //$NON-NLS-1$ >- output.println("/>"); //$NON-NLS-1$ >+ output.print("<tar"); //$NON-NLS-1$ >+ printAttribute("destfile", zipfile, true); //$NON-NLS-1$ >+ printAttribute("basedir", basedir, false); //$NON-NLS-1$ >+ printAttribute("compression", "gzip", true); //$NON-NLS-1$//$NON-NLS-2$ >+ if (fileSets == null) >+ output.println("/>"); //$NON-NLS-1$ >+ else { >+ output.println(">"); //$NON-NLS-1$ >+ indent++; >+ for (int i = 0; i < fileSets.length; i++) >+ if (fileSets[i] != null) >+ fileSets[i].print(this); >+ indent--; >+ printTab(); >+ output.println("</tar>"); //$NON-NLS-1$ >+ } > } > > /** >- * Print a <code> dirname </code> task to the script. >- * @param property >- * @param file >+ * Print a <code>zip</code> task to this script. >+ * >+ * @param zipfile the destination file name >+ * @param basedir the source directory to start the zip >+ * @param filesOnly <code>true</code> if the resulting zip file should contain only files and not directories >+ * @param update ndicates whether to update or overwrite the destination file if it already exists >+ * @param fileSets the inclusion/exclusion rules to use when zipping > */ >- public void printDirName(String property, String file) { >+ public void printZipTask(String zipfile, String basedir, boolean filesOnly, boolean update, FileSet[] fileSets) { > printTab(); >- output.print("<dirname"); //$NON-NLS-1$ >- printAttribute("property", property, true); //$NON-NLS-1$ >- printAttribute("file", file, true); //$NON-NLS-1$ >- output.println("/>"); //$NON-NLS-1$ >- } >- >- /** >- * Print a <code>Condition</code> task with isset test to the script >- * @param property name of the property to set >- * @param value value to set the property to >- * @param testProperty name of the property for the isset test >- */ >- public void printConditionIsSet(String property, String value, String testProperty) { >- println("<condition property=\"" + property + "\" value=\"" + value + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- indent++; >- println("<isset property=\"" + testProperty + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ >- indent--; >- printEndTag("condition"); //$NON-NLS-1$ >+ output.print("<zip"); //$NON-NLS-1$ >+ printAttribute("destfile", zipfile, true); //$NON-NLS-1$ >+ printAttribute("basedir", basedir, false); //$NON-NLS-1$ >+ printAttribute("filesonly", filesOnly ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ printAttribute("whenempty", "skip", true); //$NON-NLS-1$//$NON-NLS-2$ >+ printAttribute("update", update ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ if (fileSets == null) >+ output.println("/>"); //$NON-NLS-1$ >+ else { >+ output.println(">"); //$NON-NLS-1$ >+ indent++; >+ for (int i = 0; i < fileSets.length; i++) >+ if (fileSets[i] != null) >+ fileSets[i].print(this); >+ indent--; >+ printTab(); >+ output.println("</zip>"); //$NON-NLS-1$ >+ } > } > } >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.build/plugin.properties,v >retrieving revision 1.12 >diff -u -r1.12 plugin.properties >--- plugin.properties 21 Feb 2005 23:31:25 -0000 1.12 >+++ plugin.properties 31 Jan 2006 08:02:40 -0000 >@@ -10,3 +10,6 @@ > ############################################################################### > pluginName = Plug-in Development Environment Build Support > providerName = Eclipse.org >+ >+ >+fetchTaskFactories.name = Fetch Script Task Factories >Index: .cvsignore >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.build/.cvsignore,v >retrieving revision 1.3 >diff -u -r1.3 .cvsignore >--- .cvsignore 4 Apr 2002 18:44:53 -0000 1.3 >+++ .cvsignore 31 Jan 2006 08:02:40 -0000 >@@ -1,2 +1,8 @@ > bin >-lib >\ No newline at end of file >+lib >+temp* >+build.xml >+pdebuild.jar >+org.eclipse.pde.build_*.zip >+pdebuildsrc.zip >+javaCompiler.pdebuild.jar.args >Index: build.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.build/build.properties,v >retrieving revision 1.30 >diff -u -r1.30 build.properties >--- build.properties 15 Jun 2005 19:11:08 -0000 1.30 >+++ build.properties 31 Jan 2006 08:02:40 -0000 >@@ -22,5 +22,6 @@ > jars.compile.order = pdebuild.jar,\ > lib/pdebuild-ant.jar > source.pdebuild.jar = src/ >-src.includes = about.html >+src.includes = about.html,\ >+ schema/ > source.lib/pdebuild-ant.jar = src_ant/ >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.build/plugin.xml,v >retrieving revision 1.54 >diff -u -r1.54 plugin.xml >--- plugin.xml 17 Jun 2005 15:13:11 -0000 1.54 >+++ plugin.xml 31 Jan 2006 08:02:41 -0000 >@@ -1,6 +1,7 @@ > <?xml version="1.0" encoding="UTF-8"?> > <?eclipse version="3.0"?> > <plugin> >+ <extension-point id="fetchTaskFactories" name="%fetchTaskFactories.name" schema="schema/fetchTaskFactories.exsd"/> > <!-- Tasks --> > <extension > point="org.eclipse.ant.core.antTasks"> >@@ -85,4 +86,14 @@ > </application> > </extension> > >+ <extension >+ point="org.eclipse.pde.build.fetchTaskFactories"> >+ <factory >+ class="org.eclipse.pde.internal.build.fetch.COPYFetchTasksFactory" >+ id="COPY"/> >+ <factory >+ class="org.eclipse.pde.internal.build.fetch.CVSFetchTaskFactory" >+ id="CVS"/> >+ </extension> >+ > </plugin> >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.build/META-INF/MANIFEST.MF,v >retrieving revision 1.12 >diff -u -r1.12 MANIFEST.MF >--- META-INF/MANIFEST.MF 10 Nov 2005 15:25:24 -0000 1.12 >+++ META-INF/MANIFEST.MF 31 Jan 2006 08:02:41 -0000 >@@ -12,7 +12,8 @@ > org.eclipse.update.core, > org.apache.ant, > org.eclipse.core.runtime.compatibility;resolution:=optional >-Export-Package: org.eclipse.pde.internal.build;x-friends:="org.eclipse.pde.ui", >+Export-Package: org.eclipse.pde.build, >+ org.eclipse.pde.internal.build;x-friends:="org.eclipse.pde.ui", > org.eclipse.pde.internal.build.ant;x-friends:="org.eclipse.pde.ui", > org.eclipse.pde.internal.build.builder;x-friends:="org.eclipse.pde.ui", > org.eclipse.pde.internal.build.packager;x-friends:="org.eclipse.pde.ui", >Index: src/org/eclipse/pde/internal/build/fetch/CVSFetchTaskFactory.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/build/fetch/CVSFetchTaskFactory.java >diff -N src/org/eclipse/pde/internal/build/fetch/CVSFetchTaskFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/build/fetch/CVSFetchTaskFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,130 @@ >+/********************************************************************** >+ * Copyright (c) 2000, 2006 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 >+ * Gunnar Wagenknecht - adaption to new fetch script builder API >+ **********************************************************************/ >+package org.eclipse.pde.internal.build.fetch; >+ >+import java.util.HashMap; >+import java.util.Map; >+import org.eclipse.core.runtime.*; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.pde.build.FetchTaskFactory; >+import org.eclipse.pde.internal.build.IPDEBuildConstants; >+import org.eclipse.pde.internal.build.Messages; >+import org.eclipse.pde.internal.build.ant.AntScript; >+import org.eclipse.pde.internal.build.ant.ITask; >+ >+/** >+ * An <code>FetchTaskFactory</code> for building fetch scripts that will >+ * fetch content from a CVS repository (id: <code>CVS</code>). >+ * <p> >+ * Map file arguments: >+ * <code><TAG>,<CVSROOT>[,<PASSWORD>[,<PATH>[,<CVSPASSFILE>]]]</code> >+ * </p> >+ */ >+public class CVSFetchTaskFactory extends FetchTaskFactory implements IPDEBuildConstants { >+ public static final String ID = "CVS"; //$NON-NLS-1$ >+ >+ private static final String CVSPASSFILE = "cvsPassFile"; //$NON-NLS-1$ >+ private static final String CVSROOT = "cvsRoot"; //$NON-NLS-1$ >+ private static final String PASSWORD = "password"; //$NON-NLS-1$ >+ private static final String PATH = "path"; //$NON-NLS-1$ >+ private static final String TAG = "tag"; //$NON-NLS-1$ >+ >+ private static final ITask GET_FROM_CVS_TASK = new ITask() { >+ public void print(AntScript script) { >+ script.printCVSTask("export -d ${destination} -r ${tag} ${package}", "${cvsRoot}", null, null, null, "${quiet}", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ } >+ }; >+ >+ public CharSequence generateAuthentificationTask(final String element, final String type, final Map entryInfos) throws CoreException { >+ return AntScript.taskAsString(new ITask() { >+ public void print(AntScript script) { >+ String password = (String) entryInfos.get(PASSWORD); >+ String cvsPassFileLocation = (String) entryInfos.get(CVSPASSFILE); >+ if (password != null) >+ script.printCVSPassTask((String) entryInfos.get(CVSROOT), password, cvsPassFileLocation); >+ } >+ }); >+ } >+ >+ public Map generatePropertiesForFetchTask(String element, String type, Map entryInfos, String destination, boolean manifestFileOnly) { >+ Map params = new HashMap(5); >+ >+ // we directly export the CVS content into the destination >+ params.put("destination", destination); //$NON-NLS-1$ >+ params.put(TAG, entryInfos.get(TAG)); >+ params.put(CVSROOT, entryInfos.get(CVSROOT)); >+ params.put("quiet", "${quiet}"); //$NON-NLS-1$ //$NON-NLS-2$ >+ >+ String cvsPackage = ((String) entryInfos.get(PATH) == null ? element : (String) entryInfos.get(PATH)); >+ if (type.equals(ELEMENT_TYPE_FEATURE)) { >+ cvsPackage += manifestFileOnly ? '/' + DEFAULT_FEATURE_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$ >+ } else if (type.equals(ELEMENT_TYPE_PLUGIN)) { >+ cvsPackage += manifestFileOnly ? '/' + DEFAULT_PLUGIN_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$ >+ } else if (type.equals(ELEMENT_TYPE_FRAGMENT)) { >+ cvsPackage += manifestFileOnly ? '/' + DEFAULT_FRAGMENT_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$ >+ } else if (type.equals(ELEMENT_TYPE_BUNDLE)) { >+ cvsPackage += manifestFileOnly ? '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR : "";//$NON-NLS-1$ >+ } >+ params.put("package", cvsPackage); //$NON-NLS-1$ >+ >+ return params; >+ } >+ >+ public CharSequence generateRetrieveFilesTask(final String element, final String type, final Map entryInfos, final String destination, final String[] files) throws CoreException { >+ return AntScript.taskAsString(new ITask() { >+ public void print(AntScript script) { >+ String cvsRoot = (String) entryInfos.get(CVSROOT); >+ String tag = (String) entryInfos.get(TAG); >+ String path = (String) entryInfos.get(PATH); >+ String password = (String) entryInfos.get(PASSWORD); >+ String cvsPassFileLocation = (String) entryInfos.get(CVSPASSFILE); >+ >+ if (password != null) >+ script.printCVSPassTask(cvsRoot, password, cvsPassFileLocation); >+ >+ for (int i = 0; i < files.length; i++) { >+ String file = files[i]; >+ IPath filePath; >+ if (path != null) { >+ filePath = new Path(path).append(file); >+ } else { >+ filePath = new Path(element).append(file); >+ } >+ >+ script.printCVSTask("export -d " + destination + " -r " + tag + " " + filePath.toString(), cvsRoot, null, null, null, "true", null); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$ >+ } >+ } >+ }); >+ } >+ >+ public CharSequence getFetchTask() throws CoreException { >+ return AntScript.taskAsString(GET_FROM_CVS_TASK); >+ } >+ >+ public String getTagToFetch(String element, String type, Map entryInfos) { >+ return (String) entryInfos.get(TAG); >+ } >+ >+ public void processMapFileEntry(String element, String type, String[] arguments, String fetchTag, Map entryInfos) throws CoreException { >+ if (arguments.length < 2) { >+ String message = NLS.bind(Messages.error_incorrectDirectoryEntry, element); >+ throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null)); >+ } >+ >+ entryInfos.put(CVSPASSFILE, (arguments.length > 4 && !arguments[4].equals("")) ? arguments[4] : null); //$NON-NLS-1$ >+ entryInfos.put(TAG, (null == fetchTag || fetchTag.trim().length() == 0) ? arguments[0] : fetchTag); >+ entryInfos.put(CVSROOT, arguments[1]); >+ entryInfos.put(PASSWORD, (arguments.length > 2 && !arguments[2].equals("")) ? arguments[2] : null); //$NON-NLS-1$ >+ >+ entryInfos.put(PATH, (arguments.length > 3 && !arguments[3].equals("")) ? arguments[3] : null); //$NON-NLS-1$ >+ } >+} >Index: src/org/eclipse/pde/internal/build/fetch/COPYFetchTasksFactory.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/build/fetch/COPYFetchTasksFactory.java >diff -N src/org/eclipse/pde/internal/build/fetch/COPYFetchTasksFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/build/fetch/COPYFetchTasksFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,132 @@ >+/********************************************************************** >+ * Copyright (c) 2004, 2006 Eclipse Foundation 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: >+ * Gunnar Wagenknecht - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.pde.internal.build.fetch; >+ >+import java.util.HashMap; >+import java.util.Map; >+import org.eclipse.core.runtime.*; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.pde.build.FetchTaskFactory; >+import org.eclipse.pde.internal.build.IPDEBuildConstants; >+import org.eclipse.pde.internal.build.Messages; >+import org.eclipse.pde.internal.build.ant.*; >+ >+/** >+ * An <code>FetchTaskFactory</code> that fetches features and plugins by >+ * copying from a specific location (id: <code>COPY</code>). >+ * <p> >+ * Map file arguments: >+ * <code><ROOT_LOCATION>[,<ELEMENT_LOCATION>]</code> >+ * <dl> >+ * <dt>ROOT_LOCATION</dt> >+ * <dd>The ROOT_LOCATION (eg. <code>/source/eclipse</code>, or >+ * <code>D:/dev/myproduct</code>) is used as root path to determine the >+ * location to fetch. It can be overwritten via the >+ * <code>fetchTag</code> to fetch from another location (for example, on a different machine).</dd> >+ * </dl> >+ * <dt>ELEMENT_LOCATION</dt> >+ * <dd>A path withing the ROOT_LOCATION (eg. >+ * <code>org.eclipse.sdk-feature/features/org.eclipse.rcp</code>) to retrive >+ * the element from if it is not within the root. If this is not provided the >+ * default path will be used which simply maps to the element name.</dd> >+ * </dl> >+ * </p> >+ */ >+public class COPYFetchTasksFactory extends FetchTaskFactory implements IPDEBuildConstants { >+ >+ public static final String ID = "COPY"; //$NON-NLS-1$ >+ >+ private static final String PATH = "path"; //$NON-NLS-1$ >+ private static final String ROOT = "root"; //$NON-NLS-1$ >+ >+ private static final ITask GET_FROM_PATH_TASK = new ITask() { >+ public void print(AntScript script) { >+ FileSet dir = new FileSet("${sourcePath}", null, null, null, null, null, null); //$NON-NLS-1$ >+ script.printCopyTask(null, "${destination}", new FileSet[] {dir}, false, true); //$NON-NLS-1$ >+ } >+ }; >+ >+ public CharSequence generateAuthentificationTask(String element, String type, Map entryInfos) { >+ // not necessary >+ return null; >+ } >+ >+ public Map generatePropertiesForFetchTask(String element, String type, Map entryInfos, String destination, boolean xmlFileOnly) { >+ Map params = new HashMap(2); >+ >+ // we directly export the CVS content into the destination >+ params.put("destination", destination); //$NON-NLS-1$ >+ params.put("quiet", "${quiet}"); //$NON-NLS-1$ //$NON-NLS-2$ >+ >+ String root = (String) entryInfos.get(ROOT); >+ String path = (String) entryInfos.get(PATH); >+ IPath sourcePath = new Path(root); >+ if (path != null) { >+ sourcePath = sourcePath.append(path); >+ } else { >+ sourcePath = sourcePath.append(element); >+ } >+ >+ if (xmlFileOnly) { >+ if (type.equals("feature")) { //$NON-NLS-1$ >+ sourcePath.append(DEFAULT_FEATURE_FILENAME_DESCRIPTOR); >+ } else if (type.equals("plugin")) { //$NON-NLS-1$ >+ sourcePath.append(DEFAULT_PLUGIN_FILENAME_DESCRIPTOR); >+ } else if (type.equals("fragment")) { //$NON-NLS-1$ >+ sourcePath.append(DEFAULT_FRAGMENT_FILENAME_DESCRIPTOR); >+ } >+ } >+ params.put("sourcePath", sourcePath.toString()); //$NON-NLS-1$ >+ >+ return params; >+ } >+ >+ public CharSequence generateRetrieveFilesTask(final String element, final String type, final Map entryInfos, final String destination, final String[] files) throws CoreException { >+ return AntScript.taskAsString(new ITask() { >+ public void print(AntScript script) { >+ String root = (String) entryInfos.get(ROOT); >+ String path = (String) entryInfos.get(PATH); >+ >+ for (int i = 0; i < files.length; i++) { >+ String file = files[i]; >+ IPath filePath = new Path(root); >+ if (path != null) { >+ filePath = filePath.append(path).append(file); >+ } else { >+ filePath = filePath.append(element).append(file); >+ } >+ >+ script.printCopyTask(filePath.toString(), destination, null, false, true); >+ } >+ } >+ }); >+ } >+ >+ public CharSequence getFetchTask() throws CoreException { >+ return AntScript.taskAsString(GET_FROM_PATH_TASK); >+ } >+ >+ public String getTagToFetch(String element, String type, Map entryInfos) { >+ return (String) entryInfos.get(ROOT); >+ } >+ >+ public void processMapFileEntry(String element, String type, String[] arguments, String fetchTag, Map entryInfos) throws CoreException { >+ >+ if (arguments.length < 1) { >+ String message = NLS.bind(Messages.error_incorrectDirectoryEntry, element); >+ throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null)); >+ } >+ >+ entryInfos.put(ROOT, (null == fetchTag || fetchTag.trim().length() == 0) ? arguments[0] : fetchTag); >+ entryInfos.put(PATH, (arguments.length > 1 && arguments[1].trim().length() > 0) ? arguments[1] : null); >+ } >+ >+} >Index: schema/fetchTaskFactories.exsd >=================================================================== >RCS file: schema/fetchTaskFactories.exsd >diff -N schema/fetchTaskFactories.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/fetchTaskFactories.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,130 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.pde.build"> >+<annotation> >+ <appInfo> >+ <meta.schema plugin="org.eclipse.pde.build" id="fetchScriptBuilders" name="Fetch Script Builder"/> >+ </appInfo> >+ <documentation> >+ This extension point provides factories for constructing repository specific fetch script tasks during the PDE Build fetch process. >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <complexType> >+ <sequence> >+ <element ref="factory" minOccurs="1" maxOccurs="unbounded"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="factory"> >+ <annotation> >+ <appInfo> >+ <meta.element labelAttribute="id"/> >+ </appInfo> >+ <documentation> >+ Defines a fetch task factory. >+ </documentation> >+ </annotation> >+ <complexType> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ The factory id (must be unique). >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ The factory implementation (must extend <code>org.eclipse.pde.build.FetchTaskFactory</code> and must provide a parameter less, public constructor). >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="java" basedOn="org.eclipse.pde.build.FetchTaskFactory"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="since"/> >+ </appInfo> >+ <documentation> >+ 3.2 >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="examples"/> >+ </appInfo> >+ <documentation> >+ <pre> >+<extension point="org.eclipse.pde.build.fetchTaskFactories"> >+ <factory >+ class="org.eclipse.pde.internal.build.fetch.COPYFetchTasksFactory" >+ id="COPY"/> >+ <factory >+ class="org.eclipse.pde.internal.build.fetch.CVSFetchTaskFactory" >+ id="CVS"/> >+</extension> >+</pre> >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="apiInfo"/> >+ </appInfo> >+ <documentation> >+ A fetch task factory must extend <code>org.eclipse.pde.build.FetchTaskFactory</code> and must provide a parameter less, public constructor. >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="implementation"/> >+ </appInfo> >+ <documentation> >+ The following fetch task factories are provided by PDE Build. >+<ul> >+<li>a CVS fetch task factroy for fetching features and plug-ins from CVS repositories</li> >+<li>a COPY fetch task factory for copying features and plug-ins from arbitrary file system locations</li> >+</ul> >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="copyright"/> >+ </appInfo> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ >+</schema> >Index: src/org/eclipse/pde/build/FetchTaskFactory.java >=================================================================== >RCS file: src/org/eclipse/pde/build/FetchTaskFactory.java >diff -N src/org/eclipse/pde/build/FetchTaskFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/build/FetchTaskFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,206 @@ >+/********************************************************************** >+ * Copyright (c) 2004, 2006 Eclipse Foundation 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: >+ * Gunnar Wagenknecht - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.pde.build; >+ >+import java.util.Map; >+import org.eclipse.core.runtime.CoreException; >+ >+/** >+ * A <code>FetchTaskFactory</code> constructs a repository specific fetch >+ * script for the PDE build process. >+ * <p> >+ * It is registered via the >+ * <code>org.eclipse.pde.build.fetchScriptBuilder</code> extension point. >+ * </p> >+ * @since 3.2 >+ */ >+public abstract class FetchTaskFactory { >+ >+ /** element type <code>bundle</code> */ >+ public static final String ELEMENT_TYPE_BUNDLE = "bundle"; //$NON-NLS-1$ >+ >+ /** element type <code>feature</code> */ >+ public static final String ELEMENT_TYPE_FEATURE = "feature"; //$NON-NLS-1$ >+ >+ /** element type <code>fragment</code> */ >+ public static final String ELEMENT_TYPE_FRAGMENT = "fragment"; //$NON-NLS-1$ >+ >+ /** element type <code>plugin</code> */ >+ public static final String ELEMENT_TYPE_PLUGIN = "plugin"; //$NON-NLS-1$ >+ >+ /** map key of the element type (value <code>type</code>) */ >+ public static final String KEY_ELEMENT_TYPE = "type"; //$NON-NLS-1$ >+ >+ /** map key of the element name (value <code>element</code>) */ >+ public static final String KEY_ELEMENT_NAME = "element"; //$NON-NLS-1$ >+ >+ /** map key of the fetch task factory (value <code>factory</code>) */ >+ public static final String KEY_FACTORY = "factory"; //$NON-NLS-1$ >+ >+ /** >+ * Generates an ANT task that is necessary for authentificate against the >+ * repository. >+ * >+ * @param element >+ * the element name >+ * @param type >+ * the element type (one of >+ * {@link #ELEMENT_TYPE_FEATURE <code>feature</code>}, >+ * {@link #ELEMENT_TYPE_PLUGIN <code>plugin</code>}, >+ * {@link #ELEMENT_TYPE_FRAGMENT <code>fragment</code>} or >+ * {@link #ELEMENT_TYPE_BUNDLE <code>bundle</code>}) (may not be >+ * <code>null</code>) >+ * @param entryInfos >+ * the map with detailed information collected in >+ * {@link #processMapFileEntry(String, String, String[], String, Map)}, >+ * additional keys that are set by PDE Build are: >+ * {@link #KEY_ELEMENT_NAME}, >+ * {@link #KEY_ELEMENT_TYPE} and >+ * {@link #KEY_FACTORY} >+ * @return the authentification task (maybe <code>null</code> if not >+ * necessary) >+ */ >+ public abstract CharSequence generateAuthentificationTask(String element, String type, Map entryInfos) throws CoreException; >+ >+ /** >+ * Generates a properties for fetching the specified element via the fetch >+ * task. >+ * >+ * @param element >+ * the element name >+ * @param type >+ * the element type (one of >+ * {@link #ELEMENT_TYPE_FEATURE <code>feature</code>}, >+ * {@link #ELEMENT_TYPE_PLUGIN <code>plugin</code>}, >+ * {@link #ELEMENT_TYPE_FRAGMENT <code>fragment</code>} or >+ * {@link #ELEMENT_TYPE_BUNDLE <code>bundle</code>}) (may not be >+ * <code>null</code>) >+ * @param entryInfos >+ * the map with detailed information collected in >+ * {@link #processMapFileEntry(String, String, String[], String, Map)}, >+ * additional keys that are set by PDE Build are: >+ * {@link #KEY_ELEMENT_NAME}, >+ * {@link #KEY_ELEMENT_TYPE} and >+ * {@link #KEY_FACTORY} >+ * @param destination >+ * the destination where the files should be fetched to >+ * @param xmlFileOnly >+ * if <code>true</code> only the element's XML descriptor >+ * should be fetched, otherwise the complete element must be >+ * fetched >+ * @return the map with properties (must be <code>String</code> keys and >+ * <code>String</code> values) >+ * @throws CoreException >+ */ >+ public abstract Map generatePropertiesForFetchTask(String element, String type, Map entryInfos, String destination, boolean xmlFileOnly) throws CoreException; >+ >+ /** >+ * Generates a task for retrieving the specified files only. >+ * >+ * @param element >+ * the element name >+ * @param type >+ * the element type (one of >+ * {@link #ELEMENT_TYPE_FEATURE <code>feature</code>}, >+ * {@link #ELEMENT_TYPE_PLUGIN <code>plugin</code>}, >+ * {@link #ELEMENT_TYPE_FRAGMENT <code>fragment</code>} or >+ * {@link #ELEMENT_TYPE_BUNDLE <code>bundle</code>}) (may not be >+ * <code>null</code>) >+ * @param entryInfos >+ * the map with detailed information collected in >+ * {@link #processMapFileEntry(String, String, String[], String, Map)}, >+ * additional keys that are set by PDE Build are: >+ * {@link #KEY_ELEMENT_NAME}, >+ * {@link #KEY_ELEMENT_TYPE} and >+ * {@link #KEY_FACTORY} >+ * @param destination >+ * the destination where the files should be fetched to >+ * @param files >+ * the list of files to fetch >+ * @return the task for fetching the files >+ */ >+ public abstract CharSequence generateRetrieveFilesTask(String element, String type, Map entryInfos, String destination, String[] files) throws CoreException; >+ >+ /** >+ * Returns the common task that is used to fetch elements specified via Ant >+ * properties. >+ * <p> >+ * This task is called from within the element specific generated fetch >+ * tasks to fetch an elements. >+ * </p> >+ * >+ * @return the common fetch task >+ * @see #generatePropertiesForFetchTask(String, String, Map, String, >+ * boolean) >+ */ >+ public abstract CharSequence getFetchTask() throws CoreException; >+ >+ /** >+ * Returns a version identifyer (eg. TAG name) of the element that will be >+ * fetched. >+ * >+ * @param element >+ * the element name >+ * @param type >+ * the element type (one of >+ * {@link #ELEMENT_TYPE_FEATURE <code>feature</code>}, >+ * {@link #ELEMENT_TYPE_PLUGIN <code>plugin</code>}, >+ * {@link #ELEMENT_TYPE_FRAGMENT <code>fragment</code>} or >+ * {@link #ELEMENT_TYPE_BUNDLE <code>bundle</code>}) (may not be >+ * <code>null</code>) >+ * @param entryInfos >+ * the map with detailed information collected in >+ * {@link #processMapFileEntry(String, String, String[], String, Map)}, >+ * additional keys that are set by PDE Build are: >+ * {@link #KEY_ELEMENT_NAME}, >+ * {@link #KEY_ELEMENT_TYPE} and >+ * {@link #KEY_FACTORY} >+ * @return a version identifyer >+ */ >+ public abstract String getTagToFetch(String element, String type, Map entryInfos) throws CoreException; >+ >+ /** >+ * Processes the specified element with the specified type. >+ * <p> >+ * The arguments specified in the map file are provided. The map with entry >+ * infos should be filled with provider specific information that is >+ * required in later processing to sucessfully generate the fetch script. >+ * </p> >+ * >+ * @param element >+ * the element name (eg. <code>com.my.plugin</code>) (may not >+ * be <code>null</code>) >+ * @param type >+ * the element type (one of >+ * {@link #ELEMENT_TYPE_FEATURE <code>feature</code>}, >+ * {@link #ELEMENT_TYPE_PLUGIN <code>plugin</code>}, >+ * {@link #ELEMENT_TYPE_FRAGMENT <code>fragment</code>} or >+ * {@link #ELEMENT_TYPE_BUNDLE <code>bundle</code>}) (may not be >+ * <code>null</code>) >+ * @param arguments >+ * the arguments specified in the build script (may not be >+ * <code>null</code>) >+ * @param fetchTag >+ * the fetch tag that will overwrite all tags specified in the >+ * repository if set (maybe <code>null</code> or empty) >+ * @param entryInfos >+ * the map to store repository specific information >+ * (eg., label/tag/authentification informationen) >+ * (may not be <code>null</code>); >+ * reserved keys that must not be used are >+ * {@link #KEY_ELEMENT_NAME}, >+ * {@link #KEY_ELEMENT_TYPE} and >+ * {@link #KEY_FACTORY} >+ * @throws CoreException >+ * if the arguments are invalid >+ */ >+ public abstract void processMapFileEntry(String element, String type, String[] arguments, String fetchTag, Map entryInfos) throws CoreException; >+} >Index: src/org/eclipse/pde/internal/build/FetchTaskFactoriesRegistry.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/build/FetchTaskFactoriesRegistry.java >diff -N src/org/eclipse/pde/internal/build/FetchTaskFactoriesRegistry.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/build/FetchTaskFactoriesRegistry.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,161 @@ >+/********************************************************************** >+ * Copyright (c) 2004, 2006 Eclipse Foundation 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: >+ * Gunnar Wagenknecht - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.pde.internal.build; >+ >+import java.util.Collection; >+import java.util.Collections; >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IRegistryChangeEvent; >+import org.eclipse.core.runtime.IRegistryChangeListener; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.pde.build.FetchTaskFactory; >+ >+/** >+ * A registry for acessing fetch script builders. >+ * @since 3.2 >+ */ >+public class FetchTaskFactoriesRegistry implements IRegistryChangeListener { >+ >+ /** the extension point */ >+ private static final String EXT_FETCH_TASK_FACTORIES = "org.eclipse.pde.build.fetchTaskFactories"; //$NON-NLS-1$ >+ >+ /** attribute <code>id</code> */ >+ private static final String ATTR_ID = "id"; //$NON-NLS-1$ >+ >+ /** attribute <code>class</code> */ >+ private static final String ATTR_CLASS = "class"; //$NON-NLS-1$ >+ >+ /** element <code>builder</code> */ >+ private static final String ELEM_FACTORY = "factory"; //$NON-NLS-1$ >+ >+ /** the shared instance */ >+ private static FetchTaskFactoriesRegistry instance; >+ >+ /** >+ * Creates the singleton registry instance. >+ */ >+ private static synchronized void createRegistry() { >+ if (null != instance) >+ return; >+ >+ instance = new FetchTaskFactoriesRegistry(); >+ Platform.getExtensionRegistry().addRegistryChangeListener(instance, "org.eclipse.pde.build"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Returns the singleton registry instance. >+ * >+ * @return the registry instance >+ */ >+ public static FetchTaskFactoriesRegistry getRegistry() { >+ if (null == instance) { >+ createRegistry(); >+ } >+ return instance; >+ } >+ >+ /** >+ * Shuts down the registry. >+ */ >+ static void shutdown() { >+ if (null != instance) { >+ Platform.getExtensionRegistry().removeRegistryChangeListener(instance); >+ } >+ } >+ >+ /** a map of registered builders */ >+ private Map builders; >+ >+ /** >+ * Hidden constructor. >+ */ >+ private FetchTaskFactoriesRegistry() { >+ // hidden constructor >+ } >+ >+ /** >+ * Returns a collection of registered builder ids. >+ * >+ * @return a collection of registered builder ids >+ */ >+ public Collection getBuilderIds() { >+ >+ // ensure initialized >+ initializeRegistry(); >+ >+ return null != builders ? builders.keySet() : Collections.EMPTY_SET; >+ } >+ >+ /** >+ * Returns the builder instance with the specified id. >+ * <p> >+ * The instance is not cached. Each time this method is called, a new >+ * instance is created. >+ * </p> >+ * >+ * @param id >+ * @return the builder instance (maybe <code>null</code>) >+ */ >+ public FetchTaskFactory getFactory(String id) { >+ >+ // ensure initialized >+ initializeRegistry(); >+ >+ IConfigurationElement extension = (IConfigurationElement) builders.get(id); >+ if (null != extension) { >+ try { >+ return (FetchTaskFactory) extension.createExecutableExtension(ATTR_CLASS); >+ } catch (CoreException e) { >+ BundleHelper.getDefault().getLog().log(e.getStatus()); >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * Initializes the registry >+ */ >+ private void initializeRegistry() { >+ >+ // don't initialize twice >+ if (null != builders) >+ return; >+ >+ synchronized (builders = new HashMap()) { >+ IConfigurationElement[] extensions = Platform.getExtensionRegistry().getConfigurationElementsFor(EXT_FETCH_TASK_FACTORIES); >+ for (int i = 0; i < extensions.length; i++) { >+ IConfigurationElement extension = extensions[i]; >+ if (ELEM_FACTORY.equals(extension.getName())) { >+ String id = extension.getAttribute(ATTR_ID); >+ if (null != id && id.trim().length() > 0) { >+ builders.put(id, extension); >+ } >+ } >+ } >+ } >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.core.runtime.IRegistryChangeListener#registryChanged(org.eclipse.core.runtime.IRegistryChangeEvent) >+ */ >+ public void registryChanged(IRegistryChangeEvent event) { >+ >+ // reset list of known builders >+ if (null != builders) >+ builders = null; >+ } >+}
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 34757
:
12626
|
22206
|
30757
|
33845
|
33847
|
34178
|
34179
|
34327
|
34649
|
34650
|
34651
|
34743