diff --git a/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java b/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java
index aa6402c9124..3fa8e627254 100644
--- a/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java
+++ b/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java
@@ -15,6 +15,7 @@ import java.io.StringReader;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import junit.framework.Test;
import junit.framework.TestCase;
@@ -41,6 +42,7 @@ import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.ITarget;
import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolReference;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
import org.eclipse.cdt.managedbuilder.internal.core.OptionReference;
@@ -104,6 +106,7 @@ public class ManagedBuildTests extends TestCase {
ITarget testForwardChild = null;
ITarget testForwardParent = null;
ITarget testForwardGrandchild = null;
+ int numProviderTargets = 0;
// Note secret null parameter which means just extensions
ITarget[] targets = ManagedBuildManager.getDefinedTargets(null);
@@ -126,6 +129,9 @@ public class ManagedBuildTests extends TestCase {
testForwardParent = target;
} else if (target.getName().equals("Forward Grandchild")) {
testForwardGrandchild = target;
+ } else if (target.getId().startsWith("test.provider.Test_")) {
+ numProviderTargets++;
+ checkProviderTarget(target);
}
}
// check that the forward references are properly resolved.
@@ -134,6 +140,9 @@ public class ManagedBuildTests extends TestCase {
assertNotNull(testForwardGrandchild);
checkForwardTargets(testForwardParent, testForwardChild, testForwardGrandchild);
+ // check that the proper number of target were dynamically provided
+ assertEquals(3, numProviderTargets);
+
// All these targets are defines in the plugin files, so none
// of them should be null at this point
assertNotNull(testRoot);
@@ -1133,6 +1142,26 @@ public class ManagedBuildTests extends TestCase {
}
+ public void checkProviderTarget(ITarget target) throws Exception {
+ Properties props = new Properties();
+ props.load(getClass().getResourceAsStream("test_commands"));
+
+ // check that this target is in the file
+ String command = props.getProperty(target.getId());
+ assertNotNull(command);
+
+ ITarget parent = target.getParent();
+ assertNotNull(parent);
+ assertEquals("test.forward.parent.target", parent.getId());
+
+ ITool[] tools = target.getTools();
+ assertEquals(2, tools.length);
+ ITool toolRef = tools[1];
+ assertTrue(toolRef instanceof IToolReference);
+ assertEquals(toolRef.getId(), "test.forward.tool");
+ assertEquals(command, toolRef.getToolCommand());
+ }
+
/**
* Remove all the project information associated with the project used during test.
*/
diff --git a/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/StandardBuildTests.java b/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/StandardBuildTests.java
index 7dfadf69453..03fe96c725f 100644
--- a/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/StandardBuildTests.java
+++ b/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/StandardBuildTests.java
@@ -1,4 +1,14 @@
package org.eclipse.cdt.core.build.managed.tests;
+/**********************************************************************
+ * Copyright (c) 2002,2004 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
import java.util.Arrays;
import java.util.Map;
@@ -10,7 +20,6 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature;
-import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
@@ -20,7 +29,6 @@ import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.MakeProjectNature;
import org.eclipse.cdt.make.core.MakeScannerInfo;
import org.eclipse.cdt.make.core.MakeScannerProvider;
-import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
@@ -29,17 +37,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
-
public class StandardBuildTests extends TestCase {
private static final String DEFAULT_BUILD_COMMAND = "make";
private static final String EMPTY_STRING = "";
diff --git a/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/TestConfigElement.java b/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/TestConfigElement.java
new file mode 100644
index 00000000000..29d486fa2f6
--- /dev/null
+++ b/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/TestConfigElement.java
@@ -0,0 +1,69 @@
+/**********************************************************************
+ * Copyright (c) 2004 TimeSys Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * TimeSys Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.core.build.managed.tests;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+
+public class TestConfigElement implements IManagedConfigElement {
+
+ private String name;
+ private Map attributeMap;
+ private IManagedConfigElement[] children;
+
+ public TestConfigElement(String name, String[][] attributes,
+ IManagedConfigElement[] children) {
+ this.name = name;
+ this.children = children;
+ this.attributeMap = new TreeMap();
+ for (int i = 0; i < attributes.length; i++) {
+ attributeMap.put(attributes[i][0], attributes[i][1]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedConfigElement#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedConfigElement#getAttribute(java.lang.String)
+ */
+ public String getAttribute(String name) {
+ return (String)attributeMap.get(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedConfigElement#getChildren()
+ */
+ public IManagedConfigElement[] getChildren() {
+ return children;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedConfigElement#getChildren(java.lang.String)
+ */
+ public IManagedConfigElement[] getChildren(String elementName) {
+ List ret = new ArrayList(children.length);
+ for (int i = 0; i < children.length; i++) {
+ if (children[i].getName().equals(elementName)) {
+ ret.add(children[i]);
+ }
+ }
+ return (IManagedConfigElement[])ret.toArray(new IManagedConfigElement[ret.size()]);
+ }
+}
diff --git a/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/TestManagedConfigProvider.java b/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/TestManagedConfigProvider.java
new file mode 100644
index 00000000000..d40cf3e00aa
--- /dev/null
+++ b/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/TestManagedConfigProvider.java
@@ -0,0 +1,67 @@
+/**********************************************************************
+ * Copyright (c) 2004 TimeSys Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * TimeSys Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.core.build.managed.tests;
+
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElementProvider;
+import org.eclipse.cdt.managedbuilder.core.ITarget;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+
+public class TestManagedConfigProvider implements IManagedConfigElementProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedConfigProvider#getConfigElements()
+ */
+ public IManagedConfigElement[] getConfigElements() {
+ try {
+ Properties props = new Properties();
+ props.load(getClass().getResourceAsStream("test_commands"));
+ IManagedConfigElement[] ret = new IManagedConfigElement[props.size()];
+ Iterator it = props.keySet().iterator();
+ int i = 0;
+ while (it.hasNext()) {
+ String targetId = (String)it.next();
+ String command = props.getProperty(targetId);
+ ret[i++] = createTarget(targetId, command);
+ }
+ return ret;
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ return new IManagedConfigElement[0];
+ }
+
+ private IManagedConfigElement createTarget(String targetId, String command) {
+ IManagedConfigElement toolRef = new TestConfigElement(
+ IConfiguration.TOOLREF_ELEMENT_NAME,
+ new String[][] {
+ {ITool.ID, "test.forward.tool"},
+ {ITool.COMMAND, command}},
+ new IManagedConfigElement[0]);
+
+ IManagedConfigElement target = new TestConfigElement(
+ ITarget.TARGET_ELEMENT_NAME,
+ new String[][] {
+ {ITarget.ID, targetId},
+ {ITarget.NAME, targetId.substring(targetId.lastIndexOf('.')+1).
+ replace('_', ' ')},
+ {ITarget.PARENT, "test.forward.parent.target"},
+ {ITarget.IS_TEST, "true"},
+ {ITarget.OS_LIST, "win32,linux,solaris"}},
+ new IManagedConfigElement[] {toolRef});
+
+ return target;
+ }
+}
diff --git a/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/test_commands b/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/test_commands
new file mode 100644
index 00000000000..067d069e1c9
--- /dev/null
+++ b/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/test_commands
@@ -0,0 +1,3 @@
+test.provider.Test_One=cmd1
+test.provider.Test_Two=cmd2
+test.provider.Test_Three=cmd
\ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/plugin.xml b/core/org.eclipse.cdt.core.tests/plugin.xml
index c30a72873a1..8a6c29e7e9b 100644
--- a/core/org.eclipse.cdt.core.tests/plugin.xml
+++ b/core/org.eclipse.cdt.core.tests/plugin.xml
@@ -33,12 +33,12 @@
point="org.eclipse.cdt.managedbuilder.core.ManagedBuildInfo">
+ valueType="string"
+ id="org.eclipse.cdt.core.tests.option1">
+ valueType="boolean"
+ id="org.eclipse.cdt.core.tests.option2">
+ valueType="stringList"
+ id="list.option">
+ value="b"
+ builtIn="false">
+ value="c"
+ builtIn="true">