KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > ant > PluginExportTask


1 /*******************************************************************************
2  * Copyright (c) 2003, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.core.ant;
12
13 import java.io.File JavaDoc;
14 import java.util.ArrayList JavaDoc;
15 import java.util.StringTokenizer JavaDoc;
16
17 import org.eclipse.pde.core.plugin.IPluginModelBase;
18 import org.eclipse.pde.core.plugin.PluginRegistry;
19 import org.eclipse.pde.internal.core.exports.FeatureExportInfo;
20 import org.eclipse.pde.internal.core.exports.FeatureExportOperation;
21 import org.eclipse.pde.internal.core.exports.PluginExportOperation;
22
23 public class PluginExportTask extends BaseExportTask {
24     protected IPluginModelBase[] fPlugins = new IPluginModelBase[0];
25
26     protected FeatureExportOperation getExportOperation() {
27         FeatureExportInfo info = new FeatureExportInfo();
28         info.toDirectory = fToDirectory;
29         info.useJarFormat = fUseJarFormat;
30         info.exportSource = fExportSource;
31         info.zipFileName = fZipFilename;
32         info.items = fPlugins;
33         info.qualifier = fQualifier;
34         // if destination is relative, then make it absolute
35
if (!new File JavaDoc(fDestination).isAbsolute()) {
36             File JavaDoc home = new File JavaDoc(getLocation().getFileName()).getParentFile();
37             info.destinationDirectory = new File JavaDoc(home, fDestination).toString();
38         }
39         else
40             info.destinationDirectory = fDestination;
41         return new PluginExportOperation(info);
42     }
43     
44     public void setPlugins(String JavaDoc plugins) {
45         StringTokenizer JavaDoc tok = new StringTokenizer JavaDoc(plugins, ","); //$NON-NLS-1$
46
ArrayList JavaDoc models = new ArrayList JavaDoc();
47         while (tok.hasMoreTokens()) {
48             String JavaDoc id = tok.nextToken().trim();
49             IPluginModelBase model = PluginRegistry.findModel(id);
50             if (model != null)
51                 models.add(model);
52         }
53         fPlugins = (IPluginModelBase[])models.toArray(new IPluginModelBase[models.size()]);
54     }
55     
56 }
57
Popular Tags