Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 34757 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/build/ant/ITask.java (-25 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2004 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.build.ant;
12
13
/**
14
 * Interface for tasks.
15
 */
16
public interface ITask {
17
18
	/**
19
	 * Print the information for this task to the given script. Use the given
20
	 * tab index for indenting.
21
	 * 
22
	 * @param script the script to print to
23
	 */
24
	public void print(AntScript script);
25
}
(-)src/org/eclipse/pde/internal/build/ant/AntScript.java (-5 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-24 Link Here
12
12
13
import java.io.*;
13
import java.io.*;
14
import java.util.*;
14
import java.util.*;
15
import org.eclipse.pde.build.ant.IAntScript;
16
import org.eclipse.pde.build.ant.AntTask;
15
17
16
/**
18
/**
17
 * Class for producing Ant scripts. Contains convenience methods for creating the
19
 * Class for producing Ant scripts. Contains convenience methods for creating the
18
 * XML elements required for Ant scripts. See the <a href="http://jakarta.apache.org/ant">Ant</a> 
20
 * XML elements required for Ant scripts. See the <a href="http://jakarta.apache.org/ant">Ant</a> 
19
 * website for more details on Ant scripts and the particular Ant tasks.
21
 * website for more details on Ant scripts and the particular Ant tasks.
20
 */
22
 */
21
public class AntScript {
23
public class AntScript implements IAntScript {
22
24
23
	protected OutputStream out;
25
	protected OutputStream out;
24
	protected PrintWriter output;
26
	protected PrintWriter output;
Lines 697-706 Link Here
697
	/**
699
	/**
698
	 * Print the given task to the Ant script.
700
	 * Print the given task to the Ant script.
699
	 * 
701
	 * 
700
	 * @param task the task to print
702
	 * @param antTask the task to print
701
	 */
703
	 */
702
	public void print(ITask task) {
704
	public void print(AntTask antTask) {
703
		task.print(this);
705
		antTask.print(this);
704
	}
706
	}
705
707
706
	/**
708
	/**
(-)src/org/eclipse/pde/internal/build/ant/JavacTask.java (-4 / +14 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2004 IBM Corporation and others.
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-21 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.build.ant;
11
package org.eclipse.pde.internal.build.ant;
12
12
13
import org.eclipse.pde.build.ant.IAntScript;
14
import org.eclipse.pde.build.ant.AntTask;
13
import org.eclipse.pde.internal.build.IXMLConstants;
15
import org.eclipse.pde.internal.build.IXMLConstants;
14
16
15
/**
17
/**
16
 * Wrapper class for the Ant javac task.
18
 * Wrapper class for the Ant javac task.
17
 */
19
 */
18
public class JavacTask implements ITask {
20
public class JavacTask extends AntTask {
19
21
20
	protected String classpathId;
22
	protected String classpathId;
21
	protected String bootclasspath;
23
	protected String bootclasspath;
Lines 40-48 Link Here
40
	}
42
	}
41
43
42
	/**
44
	/**
43
	 * @see ITask#print(AntScript)
45
	 * @param script
46
	 * @see AntTask#print(IAntScript)
44
	 */
47
	 */
45
	public void print(AntScript script) {
48
	public void print(IAntScript script) {
49
		internalPrint((AntScript) script);
50
	}
51
	
52
	/**
53
	 * @see AntTask#print(AntScript)
54
	 */
55
	public void internalPrint(AntScript script) {
46
		script.printTab();
56
		script.printTab();
47
		script.print("<javac"); //$NON-NLS-1$
57
		script.print("<javac"); //$NON-NLS-1$
48
		script.printAttribute("destdir", destdir, false); //$NON-NLS-1$
58
		script.printAttribute("destdir", destdir, false); //$NON-NLS-1$
(-)src/org/eclipse/pde/internal/build/ant/ConditionTask.java (-4 / +15 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2004 IBM Corporation and others.
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-19 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.build.ant;
11
package org.eclipse.pde.internal.build.ant;
12
12
13
import org.eclipse.pde.build.ant.IAntScript;
14
import org.eclipse.pde.build.ant.AntTask;
15
13
/**
16
/**
14
 * Represents an Ant condition.
17
 * Represents an Ant condition.
15
 */
18
 */
16
public class ConditionTask implements ITask {
19
public class ConditionTask extends AntTask {
17
20
18
	protected String property;
21
	protected String property;
19
	protected String value;
22
	protected String value;
Lines 33-41 Link Here
33
	}
36
	}
34
37
35
	/**
38
	/**
36
	 * @see ITask#print(AntScript)
39
	 * @see AntTask#print(IAntScript)
37
	 */
40
	 */
38
	public void print(AntScript script) {
41
	private void internalPrint(AntScript script) {
39
		script.printTab();
42
		script.printTab();
40
		script.print("<condition"); //$NON-NLS-1$
43
		script.print("<condition"); //$NON-NLS-1$
41
		script.printAttribute("property", property, true); //$NON-NLS-1$
44
		script.printAttribute("property", property, true); //$NON-NLS-1$
Lines 44-47 Link Here
44
		condition.print(script);
47
		condition.print(script);
45
		script.println("</condition>"); //$NON-NLS-1$
48
		script.println("</condition>"); //$NON-NLS-1$
46
	}
49
	}
50
51
	/**
52
	 * @param script
53
	 * @see AntTask#print(IAntScript)
54
	 */
55
	public void print(IAntScript script) {
56
		internalPrint((AntScript) script);
57
	}
47
}
58
}
(-)src_ant/org/eclipse/pde/internal/build/tasks/FetchFileGeneratorTask.java (-1 / +1 lines)
Lines 17-23 Link Here
17
import org.eclipse.pde.internal.build.packager.FetchFileGenerator;
17
import org.eclipse.pde.internal.build.packager.FetchFileGenerator;
18
18
19
/**
19
/**
20
 * Internal Task.
20
 * Internal AntTask.
21
 * Generate fetch script to get files from a URL based on a packager map.
21
 * Generate fetch script to get files from a URL based on a packager map.
22
 * @since 3.0
22
 * @since 3.0
23
 */
23
 */
(-)src_ant/org/eclipse/pde/internal/build/tasks/UnzipperGeneratorTask.java (-1 / +1 lines)
Lines 17-23 Link Here
17
import org.eclipse.pde.internal.build.packager.UnzipperGenerator;
17
import org.eclipse.pde.internal.build.packager.UnzipperGenerator;
18
18
19
/**
19
/**
20
 * Internal Task.
20
 * Internal AntTask.
21
 * This task generates an unzipper script that unzip a files.
21
 * This task generates an unzipper script that unzip a files.
22
 * @since 3.0
22
 * @since 3.0
23
 */
23
 */
(-).cvsignore (+6 lines)
Lines 1-3 Link Here
1
bin
1
bin
2
lib
2
lib
3
bin_ant
3
bin_ant
4
temp*
5
build.xml
6
pdebuild.jar
7
org.eclipse.pde.build_*.zip
8
pdebuildsrc.zip
9
javaCompiler.pdebuild.jar.args
(-)plugin.xml (+11 lines)
Lines 1-6 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.0"?>
2
<?eclipse version="3.0"?>
3
<plugin>
3
<plugin>
4
   <extension-point id="fetchTaskFactories" name="%fetchTaskFactories.name" schema="schema/fetchTaskFactories.exsd"/>
4
<!-- Tasks -->
5
<!-- Tasks -->
5
   <extension
6
   <extension
6
         point="org.eclipse.ant.core.antTasks">
7
         point="org.eclipse.ant.core.antTasks">
Lines 85-88 Link Here
85
      </application>
86
      </application>
86
   </extension>
87
   </extension>
87
88
89
   <extension
90
         point="org.eclipse.pde.build.fetchTaskFactories">
91
      <factory
92
            class="org.eclipse.pde.internal.build.fetch.COPYFetchTasksFactory"
93
            id="COPY"/>
94
      <factory
95
            class="org.eclipse.pde.internal.build.fetch.CVSFetchTaskFactory"
96
            id="CVS"/>
97
   </extension>
98
88
</plugin>
99
</plugin>
(-)plugin.properties (+3 lines)
Lines 10-12 Link Here
10
###############################################################################
10
###############################################################################
11
pluginName = Plug-in Development Environment Build Support
11
pluginName = Plug-in Development Environment Build Support
12
providerName = Eclipse.org
12
providerName = Eclipse.org
13
14
15
fetchTaskFactories.name = Fetch Script Task Factories
(-)build.properties (-1 / +2 lines)
Lines 22-27 Link Here
22
jars.compile.order = pdebuild.jar,\
22
jars.compile.order = pdebuild.jar,\
23
                     lib/pdebuild-ant.jar
23
                     lib/pdebuild-ant.jar
24
source.pdebuild.jar = src/
24
source.pdebuild.jar = src/
25
src.includes = about.html
25
src.includes = about.html,\
26
               schema/
26
source.lib/pdebuild-ant.jar = src_ant/
27
source.lib/pdebuild-ant.jar = src_ant/
27
jars.extra.classpath=platform:/plugin/org.apache.ant/lib/ant.jar
28
jars.extra.classpath=platform:/plugin/org.apache.ant/lib/ant.jar
(-)META-INF/MANIFEST.MF (-2 / +6 lines)
Lines 11-21 Link Here
11
 org.eclipse.ant.core,
11
 org.eclipse.ant.core,
12
 org.eclipse.update.core,
12
 org.eclipse.update.core,
13
 org.eclipse.core.runtime.compatibility;resolution:=optional
13
 org.eclipse.core.runtime.compatibility;resolution:=optional
14
Export-Package: org.eclipse.pde.internal.build;x-friends:="org.eclipse.pde.ui",
14
Export-Package: org.eclipse.pde.build,
15
 org.eclipse.pde.build.ant,
16
 org.eclipse.pde.internal.build;x-friends:="org.eclipse.pde.ui",
15
 org.eclipse.pde.internal.build.ant;x-friends:="org.eclipse.pde.ui",
17
 org.eclipse.pde.internal.build.ant;x-friends:="org.eclipse.pde.ui",
16
 org.eclipse.pde.internal.build.builder;x-friends:="org.eclipse.pde.ui",
18
 org.eclipse.pde.internal.build.builder;x-friends:="org.eclipse.pde.ui",
19
 org.eclipse.pde.internal.build.fetch;x-friends:="org.eclipse.pde.ui",
17
 org.eclipse.pde.internal.build.packager;x-friends:="org.eclipse.pde.ui",
20
 org.eclipse.pde.internal.build.packager;x-friends:="org.eclipse.pde.ui",
18
 org.eclipse.pde.internal.build.site;x-friends:="org.eclipse.pde.ui"
21
 org.eclipse.pde.internal.build.site;x-friends:="org.eclipse.pde.ui",
22
 org.eclipse.swt.tools.internal
19
Bundle-Localization: plugin
23
Bundle-Localization: plugin
20
Eclipse-LazyStart: true
24
Eclipse-LazyStart: true
21
Bundle-RequiredExecutionEnvironment: J2SE-1.4
25
Bundle-RequiredExecutionEnvironment: J2SE-1.4
(-)src/org/eclipse/pde/internal/build/messages.properties (-1 / +2 lines)
Lines 29-35 Link Here
29
error_configWrongFormat = {0} is not a valid configuration.
29
error_configWrongFormat = {0} is not a valid configuration.
30
error_missingCustomBuildFile = No custom build file found in {0}.
30
error_missingCustomBuildFile = No custom build file found in {0}.
31
error_missingSourceFolder = In plugin {0}, the value for property {1} is not set.
31
error_missingSourceFolder = In plugin {0}, the value for property {1} is not set.
32
32
error_noRetrieveFeatureTask = No fetch task available for element {0}, check your map files.
33
  
33
### exception
34
### exception
34
exception_missingElement = Unable to find element: {0}.
35
exception_missingElement = Unable to find element: {0}.
35
exception_missingFeature = Unable to find feature: {0}.
36
exception_missingFeature = Unable to find feature: {0}.
(-)src/org/eclipse/pde/internal/build/IPDEBuildConstants.java (+6 lines)
Lines 113-116 Link Here
113
	public final static String OSGI_OS = "osgi.os";  //$NON-NLS-1$
113
	public final static String OSGI_OS = "osgi.os";  //$NON-NLS-1$
114
	public final static String OSGI_ARCH = "osgi.arch";  //$NON-NLS-1$
114
	public final static String OSGI_ARCH = "osgi.arch";  //$NON-NLS-1$
115
	public final static String OSGI_NL = "osgi.nl";  //$NON-NLS-1$
115
	public final static String OSGI_NL = "osgi.nl";  //$NON-NLS-1$
116
	
117
	// fetch task extension point
118
	public final static String EXT_FETCH_TASK_FACTORIES = "org.eclipse.pde.build.fetchTaskFactories"; //$NON-NLS-1$
119
	public final static String ATTR_ID = "id"; //$NON-NLS-1$
120
	public final static String ATTR_CLASS = "class"; //$NON-NLS-1$
121
	public final static String ELEM_FACTORY = "factory"; //$NON-NLS-1$
116
}
122
}
(-)src/org/eclipse/pde/internal/build/IXMLConstants.java (-1 / +1 lines)
Lines 53-59 Link Here
53
	public static final String TARGET_FETCH_ELEMENT = "fetch.element"; //$NON-NLS-1$
53
	public static final String TARGET_FETCH_ELEMENT = "fetch.element"; //$NON-NLS-1$
54
	public static final String TARGET_FETCH_PLUGINS = "fetch.plugins"; //$NON-NLS-1$
54
	public static final String TARGET_FETCH_PLUGINS = "fetch.plugins"; //$NON-NLS-1$
55
	public static final String TARGET_FETCH_RECURSIVELY = "fetch.recursively"; //$NON-NLS-1$
55
	public static final String TARGET_FETCH_RECURSIVELY = "fetch.recursively"; //$NON-NLS-1$
56
	public static final String TARGET_GET_FROM_CVS = "getFromCVS"; //$NON-NLS-1$
56
	public static final String TARGET_FETCH_FROM_REPOSITORY = "fetchFromRepository"; //$NON-NLS-1$
57
	public static final String TARGET_EFFECTIVE_FETCH = "effectiveFetch"; //$NON-NLS-1$
57
	public static final String TARGET_EFFECTIVE_FETCH = "effectiveFetch"; //$NON-NLS-1$
58
	public static final String TARGET_JARUP = "jarUp"; //$NON-NLS-1$
58
	public static final String TARGET_JARUP = "jarUp"; //$NON-NLS-1$
59
	public static final String TARGET_JARING = "jarIng"; //$NON-NLS-1$
59
	public static final String TARGET_JARING = "jarIng"; //$NON-NLS-1$
(-)src/org/eclipse/pde/internal/build/FetchScriptGenerator.java (-91 / +138 lines)
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
(-)src/org/eclipse/pde/internal/build/Messages.java (-1 / +2 lines)
Lines 33-39 Link Here
33
	public static String error_configWrongFormat;
33
	public static String error_configWrongFormat;
34
	public static String error_missingCustomBuildFile;
34
	public static String error_missingCustomBuildFile;
35
	public static String error_missingSourceFolder;
35
	public static String error_missingSourceFolder;
36
	
36
	public static String error_noRetrieveFeatureTask;
37
37
	// exception
38
	// exception
38
	public static String exception_missingElement;
39
	public static String exception_missingElement;
39
	public static String exception_missingFeature;
40
	public static String exception_missingFeature;
(-)src/org/eclipse/pde/internal/build/fetch/CVSFetchTaskFactory.java (+138 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2000, 2006 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
 *     Gunnar Wagenknecht - adaption to new fetch script builder API
11
 **********************************************************************/
12
package org.eclipse.pde.internal.build.fetch;
13
14
import java.util.HashMap;
15
import java.util.Map;
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.osgi.util.NLS;
18
import org.eclipse.pde.build.FetchTaskFactory;
19
import org.eclipse.pde.build.ant.AntTask;
20
import org.eclipse.pde.build.ant.IAntScript;
21
import org.eclipse.pde.internal.build.IPDEBuildConstants;
22
import org.eclipse.pde.internal.build.Messages;
23
import org.eclipse.pde.internal.build.ant.AntScript;
24
25
/**
26
 * An <code>FetchTaskFactory</code> for building fetch scripts that will
27
 * fetch content from a CVS repository (id: <code>CVS</code>).
28
 * <p>
29
 * Map file arguments:
30
 * <code>&lt;TAG&gt;,&lt;CVSROOT&gt;[,&lt;PASSWORD&gt;[,&lt;PATH&gt;[,&lt;CVSPASSFILE&gt;]]]</code>
31
 * </p>
32
 */
33
public class CVSFetchTaskFactory extends FetchTaskFactory implements IPDEBuildConstants {
34
	public static final String ID = "CVS"; //$NON-NLS-1$
35
	
36
	private static final String CVSPASSFILE = "cvsPassFile"; //$NON-NLS-1$
37
	private static final String CVSROOT = "cvsRoot"; //$NON-NLS-1$
38
	private static final String PASSWORD = "password"; //$NON-NLS-1$
39
	private static final String PATH = "path"; //$NON-NLS-1$
40
	private static final String TAG = "tag"; //$NON-NLS-1$
41
42
	private static final AntTask GET_FROM_CVS_TASK = new AntTask() {
43
		public void print(IAntScript antScript) {
44
			AntScript script = (AntScript) antScript;
45
			script.printCVSTask("export -d ${destination} -r ${tag} ${package}", "${cvsRoot}", null, null, null, "${quiet}", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
46
		}
47
	};
48
49
	public AntTask generateAuthentificationAntTask(final String element, final String type, final Map entryInfos) {
50
		return new AntTask() {
51
			public void print(IAntScript antScript) {
52
				AntScript script = (AntScript) antScript;
53
				String password = (String) entryInfos.get(PASSWORD);
54
				String cvsPassFileLocation = (String) entryInfos.get(CVSPASSFILE);
55
				if (password != null)
56
					script.printCVSPassTask((String) entryInfos.get(CVSROOT), password, cvsPassFileLocation);
57
			}
58
		};
59
	}
60
61
	public Map generatePropertiesForFetchTask(String element, String type, Map entryInfos, String destination, boolean manifestFileOnly) {
62
		Map params = new HashMap(5);
63
64
		// we directly export the CVS content into the destination
65
		params.put("destination", destination); //$NON-NLS-1$
66
		params.put(TAG, entryInfos.get(TAG));
67
		params.put(CVSROOT, entryInfos.get(CVSROOT));
68
		params.put("quiet", "${quiet}"); //$NON-NLS-1$ //$NON-NLS-2$
69
70
		String cvsPackage = ((String) entryInfos.get(PATH) == null ? element : (String) entryInfos.get(PATH));
71
		if (type.equals(ELEMENT_TYPE_FEATURE)) {
72
			cvsPackage += manifestFileOnly ? '/' + DEFAULT_FEATURE_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$
73
		} else if (type.equals(ELEMENT_TYPE_PLUGIN)) {
74
			cvsPackage += manifestFileOnly ? '/' + DEFAULT_PLUGIN_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$
75
		} else if (type.equals(ELEMENT_TYPE_FRAGMENT)) {
76
			cvsPackage += manifestFileOnly ? '/' + DEFAULT_FRAGMENT_FILENAME_DESCRIPTOR : ""; //$NON-NLS-1$
77
		} else if (type.equals(ELEMENT_TYPE_BUNDLE)) {
78
			cvsPackage += manifestFileOnly ? '/' + DEFAULT_BUNDLE_FILENAME_DESCRIPTOR : "";//$NON-NLS-1$ 
79
		}
80
		params.put("package", cvsPackage); //$NON-NLS-1$
81
82
		return params;
83
	}
84
85
	public AntTask generateRetrieveFilesAntTask(final String element, final String type, final Map entryInfos, final String destination, final String[] files) {
86
		return new AntTask() {
87
			public void print(IAntScript antScript) {
88
				AntScript script = (AntScript) antScript;
89
				String cvsRoot = (String) entryInfos.get(CVSROOT);
90
				String tag = (String) entryInfos.get(TAG);
91
				String path = (String) entryInfos.get(PATH);
92
				String password = (String) entryInfos.get(PASSWORD);
93
				String cvsPassFileLocation = (String) entryInfos.get(CVSPASSFILE);
94
95
				if (password != null)
96
					script.printCVSPassTask(cvsRoot, password, cvsPassFileLocation);
97
98
				for (int i = 0; i < files.length; i++) {
99
					String file = files[i];
100
					IPath filePath;
101
					if (path != null) {
102
						filePath = new Path(path).append(file);
103
					} else {
104
						filePath = new Path(element).append(file);
105
					}
106
107
					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$
108
				}
109
			}
110
		};
111
	}
112
113
	public AntTask getAdditionalTasks() {
114
		return null;
115
	}
116
117
	public AntTask getFetchAntTask() {
118
		return GET_FROM_CVS_TASK;
119
	}
120
121
	public String getTagToFetch(String element, String type, Map entryInfos) {
122
		return (String) entryInfos.get(TAG);
123
	}
124
125
	public void processMapFileEntry(String element, String type, String[] arguments, String fetchTag, Map entryInfos) throws CoreException {
126
		if (arguments.length < 2) {
127
			String message = NLS.bind(Messages.error_incorrectDirectoryEntry, element);
128
			throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null));
129
		}
130
131
		entryInfos.put(CVSPASSFILE, (arguments.length > 4 && !arguments[4].equals("")) ? arguments[4] : null); //$NON-NLS-1$
132
		entryInfos.put(TAG, (null == fetchTag || fetchTag.trim().length() == 0) ? arguments[0] : fetchTag);
133
		entryInfos.put(CVSROOT, arguments[1]);
134
		entryInfos.put(PASSWORD, (arguments.length > 2 && !arguments[2].equals("")) ? arguments[2] : null); //$NON-NLS-1$
135
136
		entryInfos.put(PATH, (arguments.length > 3 && !arguments[3].equals("")) ? arguments[3] : null); //$NON-NLS-1$ 
137
	}
138
}
(-)src/org/eclipse/pde/build/ant/IAntScript.java (+47 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.build.ant;
12
13
/**
14
 * An interface for producing Ant scripts. 
15
 * <p> 
16
 * It contains convenience methods for creating the XML elements 
17
 * required for Ant scripts. See the <a href="http://jakarta.apache.org/ant">Ant</a> 
18
 * website for more details on Ant scripts and the particular Ant tasks.
19
 * </p>
20
 * <p>
21
 * This interface is not intended to be implemented by clients.
22
 * </p>
23
 * @see AntTask
24
 */
25
public interface IAntScript {
26
27
	/**
28
	 * Print the given string to the Ant script.
29
	 * 
30
	 * @param string
31
	 */
32
	public abstract void print(String string);
33
34
	/**
35
	 * Print the given comment to the Ant script.
36
	 * 
37
	 * @param comment the comment to write out
38
	 */
39
	public abstract void printComment(String comment);
40
41
	/**
42
	 * Print the given string to the Ant script followed by a carriage-return.
43
	 * 
44
	 * @param string the string to print
45
	 */
46
	public abstract void println(String string);
47
}
(-)src/org/eclipse/pde/internal/build/fetch/COPYFetchTasksFactory.java (+140 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2004, 2006 Eclipse Foundation 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
 *     Gunnar Wagenknecht - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.pde.internal.build.fetch;
12
13
import java.util.HashMap;
14
import java.util.Map;
15
import org.eclipse.core.runtime.*;
16
import org.eclipse.osgi.util.NLS;
17
import org.eclipse.pde.build.FetchTaskFactory;
18
import org.eclipse.pde.build.ant.AntTask;
19
import org.eclipse.pde.build.ant.IAntScript;
20
import org.eclipse.pde.internal.build.IPDEBuildConstants;
21
import org.eclipse.pde.internal.build.Messages;
22
import org.eclipse.pde.internal.build.ant.*;
23
24
/**
25
 * An <code>FetchTaskFactory</code> that fetches features and plugins by
26
 * copying from a specific location (id: <code>COPY</code>).
27
 * <p>
28
 * Map file arguments:
29
 * <code>&lt;ROOT_LOCATION&gt;[,&lt;ELEMENT_LOCATION&gt;]</code>
30
 * <dl>
31
 * <dt>ROOT_LOCATION</dt>
32
 * <dd>The ROOT_LOCATION (eg. <code>/source/eclipse</code>, or
33
 * <code>D:/dev/myproduct</code>) is used as root path to determine the
34
 * location to fetch. It can be overwritten via the
35
 * <code>fetchTag</code> to fetch from another location (for example, on a different machine).</dd>
36
 * </dl>
37
 * <dt>ELEMENT_LOCATION</dt>
38
 * <dd>A path withing the ROOT_LOCATION (eg.
39
 * <code>org.eclipse.sdk-feature/features/org.eclipse.rcp</code>) to retrive
40
 * the element from if it is not within the root. If this is not provided the
41
 * default path will be used which simply maps to the element name.</dd>
42
 * </dl>
43
 * </p>
44
 */
45
public class COPYFetchTasksFactory extends FetchTaskFactory implements IPDEBuildConstants {
46
47
	public static final String ID = "COPY"; //$NON-NLS-1$
48
49
	private static final String PATH = "path"; //$NON-NLS-1$
50
	private static final String ROOT = "root"; //$NON-NLS-1$
51
52
	private static final AntTask GET_FROM_PATH_TASK = new AntTask() {
53
		public void print(IAntScript antScript) {
54
			AntScript script = (AntScript) antScript;
55
			FileSet dir = new FileSet("${sourcePath}", null, null, null, null, null, null); //$NON-NLS-1$
56
			script.printCopyTask(null, "${destination}", new FileSet[] {dir}, false, true); //$NON-NLS-1$ 
57
		}
58
	};
59
60
	public AntTask generateAuthentificationAntTask(String element, String type, Map entryInfos) {
61
		// not necessary
62
		return null;
63
	}
64
65
	public Map generatePropertiesForFetchTask(String element, String type, Map entryInfos, String destination, boolean xmlFileOnly) {
66
		Map params = new HashMap(2);
67
68
		// we directly export the CVS content into the destination
69
		params.put("destination", destination); //$NON-NLS-1$
70
		params.put("quiet", "${quiet}"); //$NON-NLS-1$ //$NON-NLS-2$
71
72
		String root = (String) entryInfos.get(ROOT);
73
		String path = (String) entryInfos.get(PATH);
74
		IPath sourcePath = new Path(root);
75
		if (path != null) {
76
			sourcePath = sourcePath.append(path);
77
		} else {
78
			sourcePath = sourcePath.append(element);
79
		}
80
81
		if (xmlFileOnly) {
82
			if (type.equals("feature")) { //$NON-NLS-1$
83
				sourcePath.append(DEFAULT_FEATURE_FILENAME_DESCRIPTOR);
84
			} else if (type.equals("plugin")) { //$NON-NLS-1$
85
				sourcePath.append(DEFAULT_PLUGIN_FILENAME_DESCRIPTOR);
86
			} else if (type.equals("fragment")) { //$NON-NLS-1$
87
				sourcePath.append(DEFAULT_FRAGMENT_FILENAME_DESCRIPTOR);
88
			}
89
		}
90
		params.put("sourcePath", sourcePath.toString()); //$NON-NLS-1$
91
92
		return params;
93
	}
94
95
	public AntTask generateRetrieveFilesAntTask(final String element, final String type, final Map entryInfos, final String destination, final String[] files) {
96
		return new AntTask() {
97
			public void print(IAntScript antScript) {
98
				AntScript script = (AntScript) antScript;
99
				String root = (String) entryInfos.get(ROOT);
100
				String path = (String) entryInfos.get(PATH);
101
102
				for (int i = 0; i < files.length; i++) {
103
					String file = files[i];
104
					IPath filePath = new Path(root);
105
					if (path != null) {
106
						filePath = filePath.append(path).append(file);
107
					} else {
108
						filePath = filePath.append(element).append(file);
109
					}
110
111
					script.printCopyTask(filePath.toString(), destination, null, false, true);
112
				}
113
			}
114
		};
115
	}
116
117
	public AntTask getAdditionalTasks() {
118
		return null;
119
	}
120
121
	public AntTask getFetchAntTask() {
122
		return GET_FROM_PATH_TASK;
123
	}
124
125
	public String getTagToFetch(String element, String type, Map entryInfos) {
126
		return (String) entryInfos.get(ROOT);
127
	}
128
129
	public void processMapFileEntry(String element, String type, String[] arguments, String fetchTag, Map entryInfos) throws CoreException {
130
131
		if (arguments.length < 1) {
132
			String message = NLS.bind(Messages.error_incorrectDirectoryEntry, element);
133
			throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_ENTRY_MISSING, message, null));
134
		}
135
136
		entryInfos.put(ROOT, (null == fetchTag || fetchTag.trim().length() == 0) ? arguments[0] : fetchTag);
137
		entryInfos.put(PATH, (arguments.length > 1 && arguments[1].trim().length() > 0) ? arguments[1] : null);
138
	}
139
140
}
(-)schema/fetchTaskFactories.exsd (+130 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.pde.build">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.pde.build" id="fetchScriptBuilders" name="Fetch Script Builder"/>
7
      </appInfo>
8
      <documentation>
9
         This extension point provides factories for constructing repository specific fetch script tasks during the PDE Build fetch process.
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <complexType>
15
         <sequence>
16
            <element ref="factory" minOccurs="1" maxOccurs="unbounded"/>
17
         </sequence>
18
         <attribute name="point" type="string" use="required">
19
            <annotation>
20
               <documentation>
21
                  
22
               </documentation>
23
            </annotation>
24
         </attribute>
25
         <attribute name="id" type="string">
26
            <annotation>
27
               <documentation>
28
                  
29
               </documentation>
30
            </annotation>
31
         </attribute>
32
         <attribute name="name" type="string">
33
            <annotation>
34
               <documentation>
35
                  
36
               </documentation>
37
            </annotation>
38
         </attribute>
39
      </complexType>
40
   </element>
41
42
   <element name="factory">
43
      <annotation>
44
         <appInfo>
45
            <meta.element labelAttribute="id"/>
46
         </appInfo>
47
         <documentation>
48
            Defines a fetch task factory.
49
         </documentation>
50
      </annotation>
51
      <complexType>
52
         <attribute name="id" type="string" use="required">
53
            <annotation>
54
               <documentation>
55
                  The factory id (must be unique).
56
               </documentation>
57
            </annotation>
58
         </attribute>
59
         <attribute name="class" type="string" use="required">
60
            <annotation>
61
               <documentation>
62
                  The factory implementation (must extend &lt;code&gt;org.eclipse.pde.build.FetchTaskFactory&lt;/code&gt; and must provide a parameter less, public constructor).
63
               </documentation>
64
               <appInfo>
65
                  <meta.attribute kind="java" basedOn="org.eclipse.pde.build.FetchTaskFactory"/>
66
               </appInfo>
67
            </annotation>
68
         </attribute>
69
      </complexType>
70
   </element>
71
72
   <annotation>
73
      <appInfo>
74
         <meta.section type="since"/>
75
      </appInfo>
76
      <documentation>
77
         3.2
78
      </documentation>
79
   </annotation>
80
81
   <annotation>
82
      <appInfo>
83
         <meta.section type="examples"/>
84
      </appInfo>
85
      <documentation>
86
         &lt;pre&gt;
87
&lt;extension point=&quot;org.eclipse.pde.build.fetchTaskFactories&quot;&gt;
88
    &lt;factory
89
        class=&quot;org.eclipse.pde.internal.build.fetch.COPYFetchTasksFactory&quot;
90
        id=&quot;COPY&quot;/&gt;
91
    &lt;factory
92
        class=&quot;org.eclipse.pde.internal.build.fetch.CVSFetchTaskFactory&quot;
93
        id=&quot;CVS&quot;/&gt;
94
&lt;/extension&gt;
95
&lt;/pre&gt;
96
      </documentation>
97
   </annotation>
98
99
   <annotation>
100
      <appInfo>
101
         <meta.section type="apiInfo"/>
102
      </appInfo>
103
      <documentation>
104
         A fetch task factory must extend &lt;code&gt;org.eclipse.pde.build.FetchTaskFactory&lt;/code&gt; and must provide a parameter less, public constructor.
105
      </documentation>
106
   </annotation>
107
108
   <annotation>
109
      <appInfo>
110
         <meta.section type="implementation"/>
111
      </appInfo>
112
      <documentation>
113
         The following fetch task factories are provided by PDE Build.
114
&lt;ul&gt;
115
&lt;li&gt;a CVS fetch task factroy for fetching features and plug-ins from CVS repositories&lt;/li&gt;
116
&lt;li&gt;a COPY fetch task factory for copying features and plug-ins from arbitrary file system locations&lt;/li&gt;
117
&lt;/ul&gt;
118
      </documentation>
119
   </annotation>
120
121
   <annotation>
122
      <appInfo>
123
         <meta.section type="copyright"/>
124
      </appInfo>
125
      <documentation>
126
         
127
      </documentation>
128
   </annotation>
129
130
</schema>
(-)src/org/eclipse/pde/build/FetchTaskFactory.java (+241 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2004, 2006 Eclipse Foundation 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
 *     Gunnar Wagenknecht - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.pde.build;
12
13
import java.util.Map;
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.pde.build.ant.AntTask;
16
17
/**
18
 * A <code>FetchTaskFactory</code> constructs a repository specific fetch
19
 * script for the PDE build process.
20
 * <p>
21
 * It is registered via the
22
 * <code>org.eclipse.pde.build.fetchScriptBuilder</code> extension point.
23
 * </p>
24
 * @since 3.2
25
 */
26
public abstract class FetchTaskFactory {
27
28
	/** element type <code>bundle</code> */
29
	public static final String ELEMENT_TYPE_BUNDLE = "bundle"; //$NON-NLS-1$
30
31
	/** element type <code>feature</code> */
32
	public static final String ELEMENT_TYPE_FEATURE = "feature"; //$NON-NLS-1$
33
34
	/** element type <code>fragment</code> */
35
	public static final String ELEMENT_TYPE_FRAGMENT = "fragment"; //$NON-NLS-1$
36
37
	/** element type <code>plugin</code> */
38
	public static final String ELEMENT_TYPE_PLUGIN = "plugin"; //$NON-NLS-1$
39
40
	/** map key of the element type (value <code>type</code>) */
41
	public static final String KEY_ELEMENT_TYPE = "type"; //$NON-NLS-1$
42
43
	/** map key of the element name (value <code>element</code>) */
44
	public static final String KEY_ELEMENT_NAME = "element"; //$NON-NLS-1$
45
46
	/** map key of the fetch task factory (value <code>factory</code>) */
47
	public static final String KEY_FACTORY = "factory"; //$NON-NLS-1$
48
49
	/**
50
	 * Generates an ANT task that is necessary for authentificate against the
51
	 * repository.
52
	 * <p>
53
	 * Note that this task is wrapped into an Ant target by the caller. 
54
	 * The implementor is NOT allowed to create Ant targets inside the returned task.
55
	 * See the <a href="http://jakarta.apache.org/ant">Ant</a> 
56
     * website for more details on Ant scripts and Ant tasks.
57
	 * </p>
58
	 * 
59
	 * @param element
60
	 *            the element name
61
	 * @param type
62
	 *            the element type (one of
63
	 *            {@link #ELEMENT_TYPE_FEATURE <code>feature</code>},
64
	 *            {@link #ELEMENT_TYPE_PLUGIN <code>plugin</code>},
65
	 *            {@link #ELEMENT_TYPE_FRAGMENT <code>fragment</code>} or
66
	 *            {@link #ELEMENT_TYPE_BUNDLE <code>bundle</code>}) (may not be
67
	 *            <code>null</code>)
68
	 * @param entryInfos
69
	 *            the map with detailed information collected in
70
	 *            {@link #processMapFileEntry(String, String, String[], String, Map)},
71
	 *            additional keys that are set by PDE Build are:
72
	 *            {@link #KEY_ELEMENT_NAME}, 
73
	 *            {@link #KEY_ELEMENT_TYPE} and
74
	 *            {@link #KEY_FACTORY}
75
	 * @return the authentification task (maybe <code>null</code> if not
76
	 *         necessary)
77
	 */
78
	public abstract AntTask generateAuthentificationAntTask(String element, String type, Map entryInfos);
79
80
	/**
81
	 * Generates properties for fetching the specified element via the fetch
82
	 * task.
83
	 * <p>
84
	 * The properties will be set in the fetch script before the fetch task 
85
	 * returned by {@link #getFetchAntTask()} is executed. This allows to make 
86
	 * the fetch task callable with different arguments.
87
	 * </p>
88
	 * 
89
	 * @param element
90
	 *            the element name
91
	 * @param type
92
	 *            the element type (one of
93
	 *            {@link #ELEMENT_TYPE_FEATURE <code>feature</code>},
94
	 *            {@link #ELEMENT_TYPE_PLUGIN <code>plugin</code>},
95
	 *            {@link #ELEMENT_TYPE_FRAGMENT <code>fragment</code>} or
96
	 *            {@link #ELEMENT_TYPE_BUNDLE <code>bundle</code>}) (may not be
97
	 *            <code>null</code>)
98
	 * @param entryInfos
99
	 *            the map with detailed information collected in
100
	 *            {@link #processMapFileEntry(String, String, String[], String, Map)},
101
	 *            additional keys that are set by PDE Build are:
102
	 *            {@link #KEY_ELEMENT_NAME}, 
103
	 *            {@link #KEY_ELEMENT_TYPE} and
104
	 *            {@link #KEY_FACTORY}
105
	 * @param destination
106
	 *            the destination where the files should be fetched to
107
	 * @param xmlFileOnly
108
	 *            if <code>true</code> only the element's XML descriptor
109
	 *            should be fetched, otherwise the complete element must be
110
	 *            fetched
111
	 * @return the map with properties (must be a <code>Map</code> with 
112
	 *         <code>String</code> keys and <code>String</code> values)
113
	 */
114
	public abstract Map generatePropertiesForFetchTask(String element, String type, Map entryInfos, String destination, boolean xmlFileOnly);
115
116
	/**
117
	 * Generates a task for retrieving the specified files only.
118
	 * <p>
119
	 * Note that this task is wrapped into an Ant target by the caller. 
120
	 * The implementor is NOT allowed to create Ant targets inside the returned task.
121
	 * See the <a href="http://jakarta.apache.org/ant">Ant</a> 
122
     * website for more details on Ant scripts and Ant tasks.
123
	 * </p>
124
	 * 
125
	 * @param element
126
	 *            the element name
127
	 * @param type
128
	 *            the element type (one of
129
	 *            {@link #ELEMENT_TYPE_FEATURE <code>feature</code>},
130
	 *            {@link #ELEMENT_TYPE_PLUGIN <code>plugin</code>},
131
	 *            {@link #ELEMENT_TYPE_FRAGMENT <code>fragment</code>} or
132
	 *            {@link #ELEMENT_TYPE_BUNDLE <code>bundle</code>}) (may not be
133
	 *            <code>null</code>)
134
	 * @param entryInfos
135
	 *            the map with detailed information collected in
136
	 *            {@link #processMapFileEntry(String, String, String[], String, Map)},
137
	 *            additional keys that are set by PDE Build are:
138
	 *            {@link #KEY_ELEMENT_NAME}, 
139
	 *            {@link #KEY_ELEMENT_TYPE} and
140
	 *            {@link #KEY_FACTORY}
141
	 * @param destination
142
	 *            the destination where the files should be fetched to
143
	 * @param files
144
	 *            the list of files to fetch
145
	 * @return the task for fetching the files
146
	 */
147
	public abstract AntTask generateRetrieveFilesAntTask(String element, String type, Map entryInfos, String destination, String[] files);
148
149
	/**
150
	 * Returns a task that contains additional targets.
151
	 * The additional targets will be included in the fetch script.
152
	 * <p>
153
	 * Note that this task is NOT wrapped into an Ant target. The implementor
154
	 * is required to create Ant targets inside the returned task.
155
	 * See the <a href="http://jakarta.apache.org/ant">Ant</a> 
156
     * website for more details on Ant scripts and Ant tasks.
157
	 * </p>
158
	 * 
159
	 * @return a task with additional targets to include in the fetch script 
160
	 *         (maybe <code>null</code> if no additional targets are necessary)
161
	 */
162
	public abstract AntTask getAdditionalTasks();
163
164
	/**
165
	 * Returns the common task that is used to fetch elements specified via Ant
166
	 * properties.
167
	 * <p>
168
	 * This task is wrapped into a target, which is called from within 
169
	 * the generated element specific fetch tasks to fetch an element.
170
	 * Before this task is executed properties collected in 
171
	 * {@link #generatePropertiesForFetchTask(String, String, Map, String, boolean)}
172
	 * are set allowing to pass "arguments" to this task.
173
	 * </p>
174
	 * 
175
	 * @return the common fetch task
176
	 * @see #generatePropertiesForFetchTask(String, String, Map, String,
177
	 *      boolean)
178
	 */
179
	public abstract AntTask getFetchAntTask();
180
181
	/**
182
	 * Returns a version identifyer (eg. TAG name) of the element that will be
183
	 * fetched.
184
	 * 
185
	 * @param element
186
	 *            the element name
187
	 * @param type
188
	 *            the element type (one of
189
	 *            {@link #ELEMENT_TYPE_FEATURE <code>feature</code>},
190
	 *            {@link #ELEMENT_TYPE_PLUGIN <code>plugin</code>},
191
	 *            {@link #ELEMENT_TYPE_FRAGMENT <code>fragment</code>} or
192
	 *            {@link #ELEMENT_TYPE_BUNDLE <code>bundle</code>}) (may not be
193
	 *            <code>null</code>)
194
	 * @param entryInfos
195
	 *            the map with detailed information collected in
196
	 *            {@link #processMapFileEntry(String, String, String[], String, Map)},
197
	 *            additional keys that are set by PDE Build are:
198
	 *            {@link #KEY_ELEMENT_NAME}, 
199
	 *            {@link #KEY_ELEMENT_TYPE} and
200
	 *            {@link #KEY_FACTORY}
201
	 * @return a version identifyer
202
	 */
203
	public abstract String getTagToFetch(String element, String type, Map entryInfos);
204
205
	/**
206
	 * Processes the specified element with the specified type.
207
	 * <p>
208
	 * The arguments specified in the map file are provided. The map with entry
209
	 * infos should be filled with provider specific information that is
210
	 * required in later processing to sucessfully generate the fetch script.
211
	 * </p>
212
	 * 
213
	 * @param element
214
	 *            the element name (eg. <code>com.my.plugin</code>) (may not
215
	 *            be <code>null</code>)
216
	 * @param type
217
	 *            the element type (one of
218
	 *            {@link #ELEMENT_TYPE_FEATURE <code>feature</code>},
219
	 *            {@link #ELEMENT_TYPE_PLUGIN <code>plugin</code>},
220
	 *            {@link #ELEMENT_TYPE_FRAGMENT <code>fragment</code>} or
221
	 *            {@link #ELEMENT_TYPE_BUNDLE <code>bundle</code>}) (may not be
222
	 *            <code>null</code>)
223
	 * @param arguments
224
	 *            the arguments specified in the build script (may not be
225
	 *            <code>null</code>)
226
	 * @param fetchTag
227
	 *            the fetch tag that will overwrite all tags specified in the
228
	 *            repository if set (maybe <code>null</code> or empty)
229
	 * @param entryInfos
230
	 *            the map to store repository specific information 
231
	 *            (eg., label/tag/authentification informationen)
232
	 *            (may not be <code>null</code>);
233
	 *            reserved keys that must not be used are 
234
	 *            {@link #KEY_ELEMENT_NAME}, 
235
	 *            {@link #KEY_ELEMENT_TYPE} and
236
	 *            {@link #KEY_FACTORY}
237
	 * @throws CoreException
238
	 *             if the arguments are invalid
239
	 */
240
	public abstract void processMapFileEntry(String element, String type, String[] arguments, String fetchTag, Map entryInfos) throws CoreException;
241
}
(-)src/org/eclipse/pde/internal/build/FetchTaskFactoriesRegistry.java (+108 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2004, 2006 Eclipse Foundation 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
 *     Gunnar Wagenknecht - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.pde.internal.build;
12
13
import java.util.*;
14
import org.eclipse.core.runtime.*;
15
import org.eclipse.pde.build.FetchTaskFactory;
16
17
/**
18
 * A registry for acessing fetch task factories.
19
 * @since 3.2
20
 */
21
public class FetchTaskFactoriesRegistry implements IPDEBuildConstants {
22
23
	/** the shared instance */
24
	private static FetchTaskFactoriesRegistry instance;
25
26
	/**
27
	 * Returns the singleton registry instance.
28
	 * 
29
	 * @return the registry instance
30
	 */
31
	public static FetchTaskFactoriesRegistry getRegistry() {
32
		if (null == instance) {
33
			instance = new FetchTaskFactoriesRegistry();
34
		}
35
		return instance;
36
	}
37
38
	/**
39
	 * Closes the registry, i.e. clears any caches.
40
	 */
41
	static void close() {
42
		instance = null;
43
	}
44
	
45
	/** a map of registered factories */
46
	private Map factories;
47
48
	/**
49
	 * Hidden constructor.
50
	 */
51
	private FetchTaskFactoriesRegistry() {
52
		initializeRegistry();
53
	}
54
55
	/**
56
	 * Returns the factory instance with the specified id.
57
	 * <p>
58
	 * The instance is not cached. Each time this method is called, a new
59
	 * instance is created.
60
	 * </p>
61
	 * 
62
	 * @param id
63
	 * @return the factory instance (maybe <code>null</code>)
64
	 */
65
	public FetchTaskFactory getFactory(String id) {
66
		IConfigurationElement extension = (IConfigurationElement) factories.get(id);
67
		if (null != extension) {
68
			try {
69
				return (FetchTaskFactory) extension.createExecutableExtension(ATTR_CLASS);
70
			} catch (CoreException e) {
71
				BundleHelper.getDefault().getLog().log(e.getStatus());
72
			}
73
		}
74
		return null;
75
	}
76
77
	/**
78
	 * Returns a collection of registered factory ids.
79
	 * 
80
	 * @return a collection of registered factory ids
81
	 */
82
	public Collection getFactoryIds() {
83
		return factories.keySet();
84
	}
85
86
	/**
87
	 * Initializes the registry
88
	 */
89
	void initializeRegistry() {
90
91
		// don't initialize twice
92
		if (null != factories)
93
			return;
94
95
		synchronized (factories = new HashMap()) {
96
			IConfigurationElement[] extensions = Platform.getExtensionRegistry().getConfigurationElementsFor(EXT_FETCH_TASK_FACTORIES);
97
			for (int i = 0; i < extensions.length; i++) {
98
				IConfigurationElement extension = extensions[i];
99
				if (ELEM_FACTORY.equals(extension.getName())) {
100
					String id = extension.getAttribute(ATTR_ID);
101
					if (null != id && id.trim().length() > 0) {
102
						factories.put(id, extension);
103
					}
104
				}
105
			}
106
		}
107
	}
108
}
(-)src/org/eclipse/pde/build/ant/AntTask.java (+30 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.build.ant;
12
13
14
/**
15
 * Abstract base class for Ant tasks.
16
 * <p> 
17
 * See the <a href="http://jakarta.apache.org/ant">Ant</a> 
18
 * website for more details on Ant scripts and Ant tasks.
19
 * </p>
20
 * @since 3.2
21
 */
22
public abstract class AntTask {
23
24
	/**
25
	 * Print the information for this task to the given script.
26
	 * 
27
	 * @param script the script to print to
28
	 */
29
	public abstract void print(IAntScript script);
30
}

Return to bug 34757