[422481] Add a new preference to consider the target runtime when
deciding to check or not 'Add to EAR' by default
diff --git a/plugins/org.eclipse.jst.j2ee.web/META-INF/MANIFEST.MF b/plugins/org.eclipse.jst.j2ee.web/META-INF/MANIFEST.MF
index 5c6c3e8..74c62b4 100644
--- a/plugins/org.eclipse.jst.j2ee.web/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.jst.j2ee.web/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: Web Plug-in
 Bundle-SymbolicName: org.eclipse.jst.j2ee.web; singleton:=true
-Bundle-Version: 1.1.700.qualifier
+Bundle-Version: 1.1.701.qualifier
 Bundle-Activator: org.eclipse.jst.j2ee.internal.web.plugin.WebPlugin
 Bundle-Vendor: Eclipse.org
 Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDataModelProvider.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDataModelProvider.java
index b9a1205..5dbc45f 100644
--- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDataModelProvider.java
+++ b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDataModelProvider.java
@@ -29,14 +29,18 @@
 import org.eclipse.jst.j2ee.internal.plugin.J2EEPreferences;
 import org.eclipse.jst.j2ee.internal.project.ProjectSupportResourceHandler;
 import org.eclipse.jst.j2ee.project.facet.J2EEModuleFacetInstallDataModelProvider;
+import org.eclipse.jst.server.core.FacetUtil;
 import org.eclipse.wst.common.componentcore.ComponentCore;
 import org.eclipse.wst.common.componentcore.ModuleCoreNature;
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
 import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
 import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
 import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
 import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
 import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.runtime.IRuntime;
 import org.eclipse.wst.project.facet.ProductManager;
+import org.eclipse.wst.server.core.IRuntimeType;
 
 import com.ibm.icu.text.UTF16;
 import com.ibm.icu.util.StringTokenizer;
@@ -106,9 +110,35 @@
 			return Boolean.TRUE;
 		}else if (propertyName.equals(INSTALL_WEB_LIBRARY)){
 			return J2EEComponentClasspathContainerUtils.getDefaultUseWebAppLibraries();
+		} 
+		else if (propertyName.equals(ADD_TO_EAR)) {
+			Object result = super.getDefaultProperty(propertyName);
+			if (result instanceof Boolean) {
+				return ((Boolean) result).booleanValue() && isEARDefaultForRuntime();
+			}
 		}
 		return super.getDefaultProperty(propertyName);
 	}
+	
+	private boolean isEARDefaultForRuntime() {
+	boolean result = true;
+	IRuntime rt = (IRuntime) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
+	if (rt != null) {
+		IRuntimeType rtType = FacetUtil.getRuntime(rt).getRuntimeType();
+		if (rtType.getId() != null) {
+			for(String excluded :
+					J2EEPlugin.getDefault().getJ2EEPreferences().getString(J2EEPreferences.Keys.ADD_TO_EAR_RUNTIME_EXCEPTIONS).split(",")) { //$NON-NLS-1$
+				
+				if (rtType.getId().equals(excluded)) {
+					result = false;
+					break;
+				}
+			}
+		}
+	}
+	
+	return result;
+}
 
 	@Override
 	public boolean propertySet(String propertyName, Object propertyValue) {
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/JavaEEPreferencesInitializer.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/JavaEEPreferencesInitializer.java
index ccbd44d..06b3c3b 100644
--- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/JavaEEPreferencesInitializer.java
+++ b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/JavaEEPreferencesInitializer.java
@@ -70,6 +70,11 @@
 		 * @since 2.0
 		 */
 		static final String ADD_TO_EAR_BY_DEFAULT = IProductConstants.ADD_TO_EAR_BY_DEFAULT;
+		
+		/**
+		 * @since 2.0
+		 */
+		static final String ADD_TO_EAR_RUNTIME_EXCEPTIONS = IProductConstants.ADD_TO_EAR_RUNTIME_EXCEPTIONS;
 		/**
 		 * @since 2.0
 		 */
@@ -237,6 +242,7 @@
 		node.put(Keys.EJB_CONTENT_FOLDER, ProductManager.getProperty(IProductConstants.EJB_CONTENT_FOLDER));
 		node.put(Keys.JCA_CONTENT_FOLDER, ProductManager.getProperty(IProductConstants.JCA_CONTENT_FOLDER));
 		node.put(Keys.ADD_TO_EAR_BY_DEFAULT, ProductManager.getProperty(IProductConstants.ADD_TO_EAR_BY_DEFAULT));
+		node.put(Keys.ADD_TO_EAR_RUNTIME_EXCEPTIONS, ProductManager.getProperty(IProductConstants.ADD_TO_EAR_RUNTIME_EXCEPTIONS));
 		// done in CommonFrameworksPref..Initializer
 		//node.put(Keys.OUTPUT_FOLDER, ProductManager.getProperty(IProductConstants.OUTPUT_FOLDER));
 		
diff --git a/plugins/org.eclipse.wst.web/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.web/META-INF/MANIFEST.MF
index 982f367..764e283 100644
--- a/plugins/org.eclipse.wst.web/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.wst.web/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %Bundle-Name.0
 Bundle-SymbolicName: org.eclipse.wst.web; singleton:=true
-Bundle-Version: 1.1.700.qualifier
+Bundle-Version: 1.1.701.qualifier
 Bundle-Activator: org.eclipse.wst.web.internal.WSTWebPlugin
 Bundle-Vendor: %Bundle-Vendor.0
 Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/project/facet/IProductConstants.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/project/facet/IProductConstants.java
index 3418475..a1dac21 100644
--- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/project/facet/IProductConstants.java
+++ b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/project/facet/IProductConstants.java
@@ -32,6 +32,7 @@
 	public static final String JCA_CONTENT_FOLDER = "jcaContent"; //$NON-NLS-1$
 	public static final String DEFAULT_SOURCE_FOLDER = "defaultSource"; //$NON-NLS-1$
 	public static final String ADD_TO_EAR_BY_DEFAULT = "addToEarByDefault"; //$NON-NLS-1$
+	public static final String ADD_TO_EAR_RUNTIME_EXCEPTIONS = "addToEARruntimeExceptions"; //$NON-NLS-1$
 	public static final String OUTPUT_FOLDER = "outputFolder"; //$NON-NLS-1$
 	public static final String USE_SINGLE_ROOT_STRUCTURE = "useSingleRootStructure"; //$NON-NLS-1$
 	public static final String ID_PERSPECTIVE_HIERARCHY_VIEW = "idPerspectiveHierarchyView"; //$NON-NLS-1$
diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/project/facet/ProductManager.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/project/facet/ProductManager.java
index 53583f5..9fdbfe9 100644
--- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/project/facet/ProductManager.java
+++ b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/project/facet/ProductManager.java
@@ -34,6 +34,7 @@
 	private static final String JCA_CONTENT_FOLDER = "connectorModule"; //$NON-NLS-1$
 	private static final String DEFAULT_SOURCE_FOLDER = "src"; //$NON-NLS-1$
 	private static final String ADD_TO_EAR_BY_DEFAULT = "false"; //$NON-NLS-1$
+	private static final String ADD_TO_EAR_RUNTIME_EXCEPTIONS = ""; //$NON-NLS-1$
 	private static final String OUTPUT_FOLDER = "build/classes"; //$NON-NLS-1$
 	private static final String USE_SINGLE_ROOT_STRUCTURE = "false"; //$NON-NLS-1$
 	private static final String VIEWER_SYNC_FOR_WEBSERVICES = "true"; //$NON-NLS-1$
@@ -81,6 +82,8 @@
 				return DEFAULT_SOURCE_FOLDER;
 			else if (key.equals(IProductConstants.ADD_TO_EAR_BY_DEFAULT))
 				return ADD_TO_EAR_BY_DEFAULT;
+			else if (key.equals(IProductConstants.ADD_TO_EAR_RUNTIME_EXCEPTIONS))
+				return ADD_TO_EAR_RUNTIME_EXCEPTIONS;
 			else if (key.equals(IProductConstants.USE_SINGLE_ROOT_STRUCTURE))
 				return USE_SINGLE_ROOT_STRUCTURE;
 			else if (key.equals(IProductConstants.VIEWER_SYNC_FOR_WEBSERVICES))