|
Lines 15-44
Link Here
|
| 15 |
import org.eclipse.ant.core.AntRunner; |
15 |
import org.eclipse.ant.core.AntRunner; |
| 16 |
import org.eclipse.core.runtime.*; |
16 |
import org.eclipse.core.runtime.*; |
| 17 |
import org.eclipse.osgi.util.NLS; |
17 |
import org.eclipse.osgi.util.NLS; |
|
|
18 |
import org.eclipse.pde.build.FetchTaskFactory; |
| 19 |
import org.eclipse.pde.build.ant.AntTask; |
| 18 |
import org.eclipse.pde.internal.build.ant.AntScript; |
20 |
import org.eclipse.pde.internal.build.ant.AntScript; |
|
|
21 |
import org.eclipse.pde.internal.build.fetch.CVSFetchTaskFactory; |
| 19 |
import org.eclipse.update.core.*; |
22 |
import org.eclipse.update.core.*; |
| 20 |
import org.eclipse.update.internal.core.FeatureExecutableFactory; |
23 |
import org.eclipse.update.internal.core.FeatureExecutableFactory; |
| 21 |
|
24 |
|
| 22 |
/** |
25 |
/** |
| 23 |
* Generates Ant scripts which will use the CVS "fetch" element |
26 |
* Generates Ant scripts with a repository specific factory |
| 24 |
* to retrieve plug-ins and features from the CVS repository. |
27 |
* to retrieve plug-ins and features from a repository. |
| 25 |
*/ |
28 |
*/ |
| 26 |
public class FetchScriptGenerator extends AbstractScriptGenerator { |
29 |
public class FetchScriptGenerator extends AbstractScriptGenerator { |
| 27 |
private static final String BUNDLE = "bundle"; //$NON-NLS-1$ |
30 |
private static final String BUNDLE = FetchTaskFactory.ELEMENT_TYPE_BUNDLE; |
| 28 |
private static final String FRAGMENT = "fragment"; //$NON-NLS-1$ |
31 |
private static final String FRAGMENT = FetchTaskFactory.ELEMENT_TYPE_FRAGMENT; |
| 29 |
private static final String PLUGIN = "plugin"; //$NON-NLS-1$ |
32 |
private static final String PLUGIN = FetchTaskFactory.ELEMENT_TYPE_PLUGIN; |
| 30 |
private static final String FEATURE = "feature"; //$NON-NLS-1$ |
33 |
private static final String FEATURE = FetchTaskFactory.ELEMENT_TYPE_FEATURE; |
| 31 |
private static final String ELEMENT = "element"; //$NON-NLS-1$ |
34 |
private static final String ELEMENT = FetchTaskFactory.KEY_ELEMENT_NAME; |
| 32 |
private static final String TYPE = "type"; //$NON-NLS-1$ |
35 |
private static final String TYPE = FetchTaskFactory.KEY_ELEMENT_TYPE; |
| 33 |
private static final String PATH = "path"; //$NON-NLS-1$ |
36 |
private static final String FETCH_TASK_FACTORY = FetchTaskFactory.KEY_FACTORY; |
| 34 |
private static final String PASSWORD = "password"; //$NON-NLS-1$ |
|
|
| 35 |
private static final String CVSROOT = "cvsRoot"; //$NON-NLS-1$ |
| 36 |
private static final String TAG = "tag"; //$NON-NLS-1$ |
| 37 |
|
37 |
|
| 38 |
// flag saying if we want to recursively generate the scripts |
38 |
// flag saying if we want to recursively generate the scripts |
| 39 |
protected boolean recursiveGeneration = true; |
39 |
protected boolean recursiveGeneration = true; |
| 40 |
|
40 |
|
| 41 |
// Points to the map files containing references to cvs repository |
41 |
// Points to the map files containing references to repository |
| 42 |
protected String directoryLocation; |
42 |
protected String directoryLocation; |
| 43 |
protected Properties directory; |
43 |
protected Properties directory; |
| 44 |
|
44 |
|
|
Lines 101-115
Link Here
|
| 101 |
closeScript(); |
101 |
closeScript(); |
| 102 |
} |
102 |
} |
| 103 |
|
103 |
|
| 104 |
if (recursiveGeneration && mapInfos.get(TYPE).equals(FEATURE)) |
104 |
if (recursiveGeneration && mapInfos.get(TYPE).equals(FEATURE)) |
| 105 |
generateFetchFilesForIncludedFeatures(); |
105 |
generateFetchFilesForIncludedFeatures(); |
| 106 |
|
106 |
|
| 107 |
saveRepositoryTags(); |
107 |
saveRepositoryTags(); |
|
|
108 |
FetchTaskFactoriesRegistry.close(); |
| 108 |
} |
109 |
} |
| 109 |
|
110 |
|
| 110 |
private void saveRepositoryTags(Properties properties, String fileName) throws CoreException { |
111 |
private void saveRepositoryTags(Properties properties, String fileName) throws CoreException { |
| 111 |
try { |
112 |
try { |
| 112 |
InputStream input = new BufferedInputStream(new FileInputStream(workingDirectory + '/' + fileName)); |
113 |
InputStream input = new BufferedInputStream(new FileInputStream(workingDirectory + '/' + fileName)); |
| 113 |
try { |
114 |
try { |
| 114 |
properties.load(input); |
115 |
properties.load(input); |
| 115 |
} finally { |
116 |
} finally { |
|
Lines 131-137
Link Here
|
| 131 |
throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_WRITING_FILE, message, null)); |
132 |
throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_WRITING_FILE, message, null)); |
| 132 |
} |
133 |
} |
| 133 |
} |
134 |
} |
| 134 |
|
135 |
|
| 135 |
private void saveRepositoryTags() throws CoreException { |
136 |
private void saveRepositoryTags() throws CoreException { |
| 136 |
saveRepositoryTags(repositoryPluginTags, DEFAULT_PLUGIN_REPOTAG_FILENAME_DESCRIPTOR); |
137 |
saveRepositoryTags(repositoryPluginTags, DEFAULT_PLUGIN_REPOTAG_FILENAME_DESCRIPTOR); |
| 137 |
saveRepositoryTags(repositoryFeatureTags, DEFAULT_FEATURE_REPOTAG_FILENAME_DESCRIPTOR); |
138 |
saveRepositoryTags(repositoryFeatureTags, DEFAULT_FEATURE_REPOTAG_FILENAME_DESCRIPTOR); |
|
Lines 169-179
Link Here
|
| 169 |
generatePrologue(); |
170 |
generatePrologue(); |
| 170 |
generateFetchTarget(); |
171 |
generateFetchTarget(); |
| 171 |
generateFetchElementTarget(); |
172 |
generateFetchElementTarget(); |
| 172 |
if (mapInfos.get(TYPE).equals(FEATURE)) { |
173 |
if (mapInfos.get(TYPE).equals(FEATURE)) { |
| 173 |
generateFetchPluginsTarget(); |
174 |
generateFetchPluginsTarget(); |
| 174 |
generateFetchRecusivelyTarget(); |
175 |
generateFetchRecusivelyTarget(); |
| 175 |
} |
176 |
} |
| 176 |
generateGetFromCVSTarget(); |
177 |
generateGetFromRepositoryTarget(); |
|
|
178 |
generateAdditionalTargets(); |
| 177 |
generateEpilogue(); |
179 |
generateEpilogue(); |
| 178 |
} |
180 |
} |
| 179 |
|
181 |
|
|
Lines 184-190
Link Here
|
| 184 |
script.println(); |
186 |
script.println(); |
| 185 |
script.printTargetDeclaration(TARGET_FETCH, null, null, null, null); |
187 |
script.printTargetDeclaration(TARGET_FETCH, null, null, null, null); |
| 186 |
script.printAntCallTask(TARGET_FETCH_ELEMENT, null, null); |
188 |
script.printAntCallTask(TARGET_FETCH_ELEMENT, null, null); |
| 187 |
if (mapInfos.get(TYPE).equals(FEATURE)) { |
189 |
if (mapInfos.get(TYPE).equals(FEATURE)) { |
| 188 |
script.printAntCallTask(TARGET_FETCH_PLUGINS, null, null); |
190 |
script.printAntCallTask(TARGET_FETCH_PLUGINS, null, null); |
| 189 |
script.printAntCallTask(TARGET_FETCH_RECURSIVELY, null, null); |
191 |
script.printAntCallTask(TARGET_FETCH_RECURSIVELY, null, null); |
| 190 |
} |
192 |
} |
|
Lines 204-210
Link Here
|
| 204 |
|
206 |
|
| 205 |
protected void generateFetchPluginsTarget() throws CoreException { |
207 |
protected void generateFetchPluginsTarget() throws CoreException { |
| 206 |
script.printTargetDeclaration(TARGET_FETCH_PLUGINS, null, FEATURE_AND_PLUGINS, null, null); |
208 |
script.printTargetDeclaration(TARGET_FETCH_PLUGINS, null, FEATURE_AND_PLUGINS, null, null); |
| 207 |
retrieveFeature((String) mapInfos.get(ELEMENT), (String) mapInfos.get(CVSROOT), (String) mapInfos.get(TAG), (String) mapInfos.get(PASSWORD), (String) mapInfos.get(PATH)); |
209 |
retrieveFeature((String) mapInfos.get(ELEMENT), (String) mapInfos.get(TYPE), mapInfos); |
| 208 |
generateChildrenFetchScript(); |
210 |
generateChildrenFetchScript(); |
| 209 |
script.printTargetEnd(); |
211 |
script.printTargetEnd(); |
| 210 |
} |
212 |
} |
|
Lines 219-246
Link Here
|
| 219 |
private Map processMapFileEntry(String entry) throws CoreException { |
221 |
private Map processMapFileEntry(String entry) throws CoreException { |
| 220 |
Map entryInfos = new HashMap(5); |
222 |
Map entryInfos = new HashMap(5); |
| 221 |
|
223 |
|
| 222 |
String cvsInfo = getCVSInfo(entry); |
224 |
// extract type and element from entry |
| 223 |
if (cvsInfo == null) { |
225 |
int index = entry.indexOf('@'); |
|
|
226 |
String type = entry.substring(0, index); |
| 227 |
String currentElement = entry.substring(index + 1); |
| 228 |
|
| 229 |
// read and validate the repository info |
| 230 |
String repositoryInfo = getRepositoryInfo(entry); |
| 231 |
if (repositoryInfo == null) { |
| 224 |
String message = NLS.bind(Messages.error_missingDirectoryEntry, entry); |
232 |
String message = NLS.bind(Messages.error_missingDirectoryEntry, entry); |
| 225 |
BundleHelper.getDefault().getLog().log(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null)); |
233 |
BundleHelper.getDefault().getLog().log(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null)); |
| 226 |
return null; |
234 |
return null; |
| 227 |
} |
235 |
} |
| 228 |
|
236 |
|
| 229 |
String[] cvsFields = Utils.getArrayFromStringWithBlank(cvsInfo, ","); //$NON-NLS-1$ |
237 |
// collect and validate the repository info |
| 230 |
if (cvsFields.length < 2) { |
238 |
String[] repositoryFields = Utils.getArrayFromStringWithBlank(repositoryInfo, ","); //$NON-NLS-1$ |
| 231 |
String message = NLS.bind(Messages.error_incorrectDirectoryEntry, element); |
239 |
if (repositoryFields.length < 2) { |
|
|
240 |
String message = NLS.bind(Messages.error_incorrectDirectoryEntry, currentElement); |
| 232 |
throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null)); |
241 |
throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null)); |
| 233 |
} |
242 |
} |
| 234 |
|
243 |
|
| 235 |
entryInfos.put(TAG, fetchTag.length() == 0 ? cvsFields[0] : fetchTag); |
244 |
// determine fetch script builder |
| 236 |
entryInfos.put(CVSROOT, cvsFields[1]); |
245 |
FetchTaskFactory fetchTaskFactory = null; |
| 237 |
entryInfos.put(PASSWORD, (cvsFields.length > 2 && !cvsFields[2].equals("")) ? cvsFields[2] : null); //$NON-NLS-1$ |
246 |
String[] arguments = null; |
| 238 |
|
247 |
|
| 239 |
entryInfos.put(PATH, (cvsFields.length > 3 && !cvsFields[3].equals("")) ? cvsFields[3] : null); //$NON-NLS-1$ |
248 |
// check if first repository field matches a builder id |
| 240 |
|
249 |
if (FetchTaskFactoriesRegistry.getRegistry().getFactoryIds().contains(repositoryFields[0])) { |
| 241 |
int index = entry.indexOf('@'); |
250 |
fetchTaskFactory = FetchTaskFactoriesRegistry.getRegistry().getFactory(repositoryFields[0]); |
| 242 |
entryInfos.put(TYPE, entry.substring(0, index)); |
251 |
|
| 243 |
entryInfos.put(ELEMENT, entry.substring(index + 1)); |
252 |
// construct arguments array for registered builder |
|
|
253 |
arguments = new String[repositoryFields.length - 1]; |
| 254 |
System.arraycopy(repositoryFields, 1, arguments, 0, repositoryFields.length - 1); |
| 255 |
} |
| 256 |
|
| 257 |
// default to CVS builder (to be compatible) |
| 258 |
if (null == fetchTaskFactory) { |
| 259 |
// fall back to CVS |
| 260 |
fetchTaskFactory = new CVSFetchTaskFactory(); |
| 261 |
|
| 262 |
// construct arguments array for CVS builder |
| 263 |
arguments = repositoryFields; |
| 264 |
} |
| 265 |
|
| 266 |
// add infos from registered builder |
| 267 |
fetchTaskFactory.processMapFileEntry(currentElement, type, arguments, fetchTag, entryInfos); |
| 268 |
|
| 269 |
// store builder |
| 270 |
entryInfos.put(FETCH_TASK_FACTORY, fetchTaskFactory); |
| 271 |
|
| 272 |
// add general infos (will override builder specific infos) |
| 273 |
entryInfos.put(TYPE, type); |
| 274 |
entryInfos.put(ELEMENT, currentElement); |
| 244 |
return entryInfos; |
275 |
return entryInfos; |
| 245 |
} |
276 |
} |
| 246 |
|
277 |
|
|
Lines 257-265
Link Here
|
| 257 |
} |
288 |
} |
| 258 |
continue; |
289 |
continue; |
| 259 |
} |
290 |
} |
| 260 |
|
291 |
|
| 261 |
//Included features can be available in the baseLocation. |
292 |
//Included features can be available in the baseLocation. |
| 262 |
if (getCVSInfo(FEATURE + '@' + featureId) != null) |
293 |
if (getRepositoryInfo(FEATURE + '@' + featureId) != null) |
| 263 |
script.printAntTask(Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY) + '/' + FETCH_FILE_PREFIX + featureId + ".xml", null, TARGET_FETCH, null, null, null); //$NON-NLS-1$ |
294 |
script.printAntTask(Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY) + '/' + FETCH_FILE_PREFIX + featureId + ".xml", null, TARGET_FETCH, null, null, null); //$NON-NLS-1$ |
| 264 |
else if (getSite(false).findFeature(featureId, null, false) == null) { |
295 |
else if (getSite(false).findFeature(featureId, null, false) == null) { |
| 265 |
String message = NLS.bind(Messages.error_cannotFetchNorFindFeature, featureId); |
296 |
String message = NLS.bind(Messages.error_cannotFetchNorFindFeature, featureId); |
|
Lines 277-333
Link Here
|
| 277 |
return false; |
308 |
return false; |
| 278 |
} |
309 |
} |
| 279 |
|
310 |
|
| 280 |
String password = (String) mapFileEntry.get(PASSWORD); |
311 |
FetchTaskFactory factory = (FetchTaskFactory) mapFileEntry.get(FETCH_TASK_FACTORY); |
| 281 |
if (password != null) |
312 |
String elementToFetch = (String) mapFileEntry.get(ELEMENT); |
| 282 |
script.printCVSPassTask((String) mapFileEntry.get(CVSROOT), password, cvsPassFileLocation); |
|
|
| 283 |
|
| 284 |
String type = (String) mapFileEntry.get(TYPE); |
313 |
String type = (String) mapFileEntry.get(TYPE); |
|
|
314 |
|
| 315 |
// print authentification task if one is provided |
| 316 |
AntTask authTask = factory.generateAuthentificationAntTask(elementToFetch, type, mapFileEntry); |
| 317 |
if (null != authTask) |
| 318 |
script.print(authTask); |
| 319 |
|
| 320 |
// the location |
| 285 |
String location = getElementLocation(type); |
321 |
String location = getElementLocation(type); |
| 286 |
Map params = new HashMap(5); |
|
|
| 287 |
|
322 |
|
| 288 |
//We directly export the CVS content into the correct directory |
323 |
// the destination |
| 289 |
params.put("destination", mapFileEntry.get(ELEMENT)); //$NON-NLS-1$ |
324 |
// we directly export the content into the correct directory |
| 290 |
params.put(TAG, mapFileEntry.get(TAG)); |
325 |
String destination = elementToFetch; |
| 291 |
params.put(CVSROOT, mapFileEntry.get(CVSROOT)); |
326 |
|
| 292 |
params.put("quiet", "${quiet}"); //$NON-NLS-1$ //$NON-NLS-2$ |
327 |
// get params from builder |
|
|
328 |
Map params = new HashMap(factory.generatePropertiesForFetchTask(elementToFetch, type, mapFileEntry, destination, manifestFileOnly)); |
| 293 |
|
329 |
|
| 294 |
String cvsPackage = ((String) mapFileEntry.get(PATH) == null ? (String) mapFileEntry.get(ELEMENT) : (String) mapFileEntry.get(PATH)); |
|
|
| 295 |
String fullLocation = null; |
330 |
String fullLocation = null; |
| 296 |
if (type.equals(FEATURE)) { |
331 |
if (type.equals(FEATURE)) { |
| 297 |
fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_FEATURE_FILENAME_DESCRIPTOR; |
332 |
fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_FEATURE_FILENAME_DESCRIPTOR; |
| 298 |
params.put("fileToCheck", fullLocation); //$NON-NLS-1$ |
333 |
params.put("fileToCheck", fullLocation); //$NON-NLS-1$ |
| 299 |
cvsPackage += manifestFileOnly ? '/' + DEFAULT_FEATURE_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$ |
334 |
repositoryFeatureTags.put(elementToFetch, factory.getTagToFetch(elementToFetch, type, mapFileEntry)); |
| 300 |
repositoryFeatureTags.put(mapFileEntry.get(ELEMENT), mapFileEntry.get(TAG)); |
|
|
| 301 |
} else if (type.equals(PLUGIN)) { |
335 |
} else if (type.equals(PLUGIN)) { |
| 302 |
fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_PLUGIN_FILENAME_DESCRIPTOR; |
336 |
fullLocation = location + '/' + elementToFetch + '/' + DEFAULT_PLUGIN_FILENAME_DESCRIPTOR; |
| 303 |
params.put("fileToCheck", fullLocation); //$NON-NLS-1$ |
337 |
params.put("fileToCheck", fullLocation); //$NON-NLS-1$ |
| 304 |
cvsPackage += manifestFileOnly ? '/' + DEFAULT_PLUGIN_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$ |
338 |
repositoryPluginTags.put(elementToFetch, factory.getTagToFetch(elementToFetch, type, mapFileEntry)); |
| 305 |
repositoryPluginTags.put(mapFileEntry.get(ELEMENT), mapFileEntry.get(TAG)); |
|
|
| 306 |
} else if (type.equals(FRAGMENT)) { |
339 |
} else if (type.equals(FRAGMENT)) { |
| 307 |
fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_FRAGMENT_FILENAME_DESCRIPTOR; |
340 |
fullLocation = location + '/' + elementToFetch + '/' + DEFAULT_FRAGMENT_FILENAME_DESCRIPTOR; |
| 308 |
params.put("fileToCheck", fullLocation); //$NON-NLS-1$ |
341 |
params.put("fileToCheck", fullLocation); //$NON-NLS-1$ |
| 309 |
cvsPackage += manifestFileOnly ? '/' + DEFAULT_FRAGMENT_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$ |
342 |
repositoryPluginTags.put(elementToFetch, factory.getTagToFetch(elementToFetch, type, mapFileEntry)); |
| 310 |
repositoryPluginTags.put(mapFileEntry.get(ELEMENT), mapFileEntry.get(TAG)); |
|
|
| 311 |
} else if (type.equals(BUNDLE)) { |
343 |
} else if (type.equals(BUNDLE)) { |
| 312 |
fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR; |
344 |
fullLocation = location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR; |
| 313 |
params.put("fileToCheck", fullLocation); //$NON-NLS-1$ |
345 |
params.put("fileToCheck", fullLocation); //$NON-NLS-1$ |
| 314 |
cvsPackage += manifestFileOnly ? '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR : "";//$NON-NLS-1$ |
346 |
repositoryPluginTags.put(elementToFetch, factory.getTagToFetch(elementToFetch, type, mapFileEntry)); |
| 315 |
repositoryPluginTags.put(mapFileEntry.get(ELEMENT), mapFileEntry.get(TAG)); |
|
|
| 316 |
} |
347 |
} |
| 317 |
params.put("package", cvsPackage); //$NON-NLS-1$ |
|
|
| 318 |
|
348 |
|
| 319 |
// This call create a new property for every feature, plugins or fragments that we must check the existence of |
349 |
// This call create a new property for every feature, plugins or fragments that we must check the existence of |
| 320 |
script.printAvailableTask(fullLocation, fullLocation); |
350 |
script.printAvailableTask(fullLocation, fullLocation); |
| 321 |
if (type.equals(PLUGIN) || type.equals(FRAGMENT)) { |
351 |
if (type.equals(PLUGIN) || type.equals(FRAGMENT)) { |
| 322 |
script.printAvailableTask(fullLocation, location + '/' + (String) mapFileEntry.get(ELEMENT) + '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR); |
352 |
script.printAvailableTask(fullLocation, location + '/' + elementToFetch + '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR); |
| 323 |
} |
353 |
} |
| 324 |
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$ |
354 |
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$ |
| 325 |
return true; |
355 |
return true; |
| 326 |
} |
356 |
} |
| 327 |
|
357 |
|
| 328 |
protected void generateGetFromCVSTarget() { |
358 |
protected void generateGetFromRepositoryTarget() { |
| 329 |
script.printTargetDeclaration(TARGET_GET_FROM_CVS, null, null, "${fileToCheck}", "{destination}"); //$NON-NLS-1$ //$NON-NLS-2$ |
359 |
script.printTargetDeclaration(TARGET_FETCH_FROM_REPOSITORY, null, null, "${fileToCheck}", null); //$NON-NLS-1$ |
| 330 |
script.printCVSTask("export -d ${destination} -r ${tag} ${package}", "${cvsRoot}", null, null, null, "${quiet}", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
360 |
if (null != mapInfos) { |
|
|
361 |
FetchTaskFactory factory = (FetchTaskFactory) mapInfos.get(FETCH_TASK_FACTORY); |
| 362 |
if (null != factory) { |
| 363 |
AntTask getTask = factory.getFetchAntTask(); |
| 364 |
if (null != getTask) { |
| 365 |
script.print(getTask); |
| 366 |
} |
| 367 |
} |
| 368 |
} |
| 331 |
script.printTargetEnd(); |
369 |
script.printTargetEnd(); |
| 332 |
} |
370 |
} |
| 333 |
|
371 |
|
|
Lines 365-375
Link Here
|
| 365 |
|
403 |
|
| 366 |
boolean generated = true; |
404 |
boolean generated = true; |
| 367 |
if (allChildren[i].isFragment()) |
405 |
if (allChildren[i].isFragment()) |
| 368 |
generated = generateFetchEntry(FRAGMENT + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i])); |
406 |
generated = generateFetchEntry(FRAGMENT + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i])); |
| 369 |
else |
407 |
else |
| 370 |
generated = generateFetchEntry(PLUGIN + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i])); |
408 |
generated = generateFetchEntry(PLUGIN + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i])); |
| 371 |
if (generated == false) |
409 |
if (generated == false) |
| 372 |
generateFetchEntry(BUNDLE + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i])); |
410 |
generateFetchEntry(BUNDLE + '@' + elementId, !Utils.isIn(compiledChildren, allChildren[i])); |
| 373 |
} |
411 |
} |
| 374 |
} |
412 |
} |
| 375 |
|
413 |
|
|
Lines 379-415
Link Here
|
| 379 |
* constructor from Update. |
417 |
* constructor from Update. |
| 380 |
* |
418 |
* |
| 381 |
* @param elementName the feature to retrieve |
419 |
* @param elementName the feature to retrieve |
| 382 |
* @param cvsRoot the root in CVS |
420 |
* @param elementType the element type |
| 383 |
* @param tag the CVS tag |
421 |
* @param elementInfos the element information |
| 384 |
* @param password the CVS password |
|
|
| 385 |
* @throws CoreException |
422 |
* @throws CoreException |
| 386 |
*/ |
423 |
*/ |
| 387 |
protected void retrieveFeature(String elementName, String cvsRoot, String tag, String password, String path) throws CoreException { |
424 |
protected void retrieveFeature(String elementName, String elementType, Map elementInfos) throws CoreException { |
| 388 |
// Generate a temporary Ant script which retrieves the feature.xml for this |
425 |
// Generate a temporary Ant script which retrieves the feature.xml for this |
| 389 |
// feature from CVS |
426 |
// feature from CVS |
| 390 |
File root = new File(workingDirectory); |
427 |
File root = new File(workingDirectory); |
| 391 |
File target = new File(root, DEFAULT_RETRIEVE_FILENAME_DESCRIPTOR); |
428 |
File target = new File(root, DEFAULT_RETRIEVE_FILENAME_DESCRIPTOR); |
| 392 |
try { |
429 |
try { |
| 393 |
AntScript retrieve = new AntScript(new FileOutputStream(target)); |
430 |
AntScript retrieve = new AntScript(new FileOutputStream(target)); |
| 394 |
try { |
431 |
try { |
| 395 |
retrieve.printProjectDeclaration("RetrieveFeature", "main", "."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
432 |
retrieve.printProjectDeclaration("RetrieveFeature", "main", "."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
| 396 |
retrieve.printTargetDeclaration(TARGET_MAIN, null, null, null, null); |
433 |
retrieve.printTargetDeclaration(TARGET_MAIN, null, null, null, null); |
| 397 |
|
434 |
|
| 398 |
IPath moduleFeatureFile; |
435 |
String destination = elementName; |
| 399 |
IPath moduleFeatureProperties; |
436 |
String[] files = new String[] {DEFAULT_FEATURE_FILENAME_DESCRIPTOR, PROPERTIES_FILE}; |
| 400 |
if (path != null) { |
437 |
FetchTaskFactory factory = (FetchTaskFactory) elementInfos.get(FETCH_TASK_FACTORY); |
| 401 |
moduleFeatureFile = new Path(path).append(DEFAULT_FEATURE_FILENAME_DESCRIPTOR); |
438 |
AntTask retrieveFeatureTask = factory.generateRetrieveFilesAntTask(elementName, elementType, elementInfos, destination, files); |
| 402 |
moduleFeatureProperties = new Path(path).append(PROPERTIES_FILE); |
439 |
if (null == retrieveFeatureTask) { |
| 403 |
} else { |
440 |
String message = NLS.bind(Messages.error_noRetrieveFeatureTask, elementName); |
| 404 |
moduleFeatureFile = new Path(elementName).append(DEFAULT_FEATURE_FILENAME_DESCRIPTOR); |
441 |
throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null)); |
| 405 |
moduleFeatureProperties = new Path(elementName).append(PROPERTIES_FILE); |
|
|
| 406 |
} |
442 |
} |
| 407 |
|
443 |
retrieve.print(retrieveFeatureTask); |
| 408 |
if (password != null) |
|
|
| 409 |
retrieve.printCVSPassTask(cvsRoot, password, cvsPassFileLocation); |
| 410 |
|
| 411 |
retrieve.printCVSTask("export -r " + tag + " " + moduleFeatureFile.toString(), cvsRoot, null, null, null, "true", null); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ |
| 412 |
retrieve.printCVSTask("export -r " + tag + " " + moduleFeatureProperties.toString(), cvsRoot, null, null, null, "true", null); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ |
| 413 |
|
444 |
|
| 414 |
retrieve.printTargetEnd(); |
445 |
retrieve.printTargetEnd(); |
| 415 |
retrieve.printProjectEnd(); |
446 |
retrieve.printProjectEnd(); |
|
Lines 427-440
Link Here
|
| 427 |
AntRunner runner = new AntRunner(); |
458 |
AntRunner runner = new AntRunner(); |
| 428 |
runner.setBuildFileLocation(target.getAbsolutePath()); |
459 |
runner.setBuildFileLocation(target.getAbsolutePath()); |
| 429 |
runner.run(); |
460 |
runner.run(); |
|
|
461 |
String destination = elementName; |
| 430 |
FeatureExecutableFactory factory = new FeatureExecutableFactory(); |
462 |
FeatureExecutableFactory factory = new FeatureExecutableFactory(); |
| 431 |
File featureFolder = new File(root, (path == null ? elementName : path)); |
463 |
File featureFolder = new File(root, destination); |
| 432 |
feature = factory.createFeature(featureFolder.toURL(), null, null); |
464 |
feature = factory.createFeature(featureFolder.toURL(), null, null); |
| 433 |
|
465 |
|
| 434 |
//We only delete here, so if an exception is thrown the user can still see the retrieve.xml |
466 |
//We only delete here, so if an exception is thrown the user can still see the retrieve.xml |
| 435 |
target.delete(); |
467 |
target.delete(); |
| 436 |
featureProperties = new Properties(); |
468 |
featureProperties = new Properties(); |
| 437 |
InputStream featureStream = new FileInputStream(new File(root, (path == null ? elementName : path) + '/' + PROPERTIES_FILE)); |
469 |
InputStream featureStream = new FileInputStream(new File(root, destination + '/' + PROPERTIES_FILE)); |
| 438 |
featureProperties.load(featureStream); |
470 |
featureProperties.load(featureStream); |
| 439 |
featureStream.close(); |
471 |
featureStream.close(); |
| 440 |
clear(featureFolder); |
472 |
clear(featureFolder); |
|
Lines 484-490
Link Here
|
| 484 |
*/ |
516 |
*/ |
| 485 |
protected String getElementLocation(String type) { |
517 |
protected String getElementLocation(String type) { |
| 486 |
IPath location = new Path(Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY)); |
518 |
IPath location = new Path(Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY)); |
| 487 |
if (type.equals(FEATURE)) |
519 |
if (type.equals(FEATURE)) |
| 488 |
location = location.append(DEFAULT_FEATURE_LOCATION); |
520 |
location = location.append(DEFAULT_FEATURE_LOCATION); |
| 489 |
else |
521 |
else |
| 490 |
location = location.append(DEFAULT_PLUGIN_LOCATION); |
522 |
location = location.append(DEFAULT_PLUGIN_LOCATION); |
|
Lines 498-504
Link Here
|
| 498 |
* @return String |
530 |
* @return String |
| 499 |
* @throws CoreException |
531 |
* @throws CoreException |
| 500 |
*/ |
532 |
*/ |
| 501 |
protected String getCVSInfo(String elementName) throws CoreException { |
533 |
protected String getRepositoryInfo(String elementName) throws CoreException { |
| 502 |
if (directory == null) |
534 |
if (directory == null) |
| 503 |
directory = readProperties(directoryLocation, "", IStatus.ERROR); //$NON-NLS-1$ |
535 |
directory = readProperties(directoryLocation, "", IStatus.ERROR); //$NON-NLS-1$ |
| 504 |
return directory.getProperty(elementName); |
536 |
return directory.getProperty(elementName); |
|
Lines 524-529
Link Here
|
| 524 |
} |
556 |
} |
| 525 |
|
557 |
|
| 526 |
/** |
558 |
/** |
|
|
559 |
* Generates additional targets submitted by the fetch task factory. |
| 560 |
*/ |
| 561 |
private void generateAdditionalTargets() { |
| 562 |
if (null != mapInfos) { |
| 563 |
FetchTaskFactory factory = (FetchTaskFactory) mapInfos.get(FETCH_TASK_FACTORY); |
| 564 |
if (null != factory) { |
| 565 |
AntTask additionalTasks = factory.getAdditionalTasks(); |
| 566 |
if (null != additionalTasks) { |
| 567 |
script.print(additionalTasks); |
| 568 |
} |
| 569 |
} |
| 570 |
} |
| 571 |
} |
| 572 |
|
| 573 |
/** |
| 527 |
* Set the directory location to be the given value. |
574 |
* Set the directory location to be the given value. |
| 528 |
* |
575 |
* |
| 529 |
* @param directoryLocation |
576 |
* @param directoryLocation |