Author: fbricon
Date: 2011-05-19 10:13:11 -0400 (Thu, 19 May 2011)
New Revision: 31380
Modified:
trunk/maven/plugins/org.jboss.tools.maven.cdi/src/org/jboss/tools/maven/cdi/Messages.java
trunk/maven/plugins/org.jboss.tools.maven.cdi/src/org/jboss/tools/maven/cdi/configurators/CDIProjectConfigurator.java
trunk/maven/plugins/org.jboss.tools.maven.cdi/src/org/jboss/tools/maven/cdi/messages.properties
Log:
JBIDE-8962 : only add the CDI facet if the correct Web or EJB facets are installed
Modified:
trunk/maven/plugins/org.jboss.tools.maven.cdi/src/org/jboss/tools/maven/cdi/Messages.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.cdi/src/org/jboss/tools/maven/cdi/Messages.java 2011-05-19
13:48:33 UTC (rev 31379)
+++
trunk/maven/plugins/org.jboss.tools.maven.cdi/src/org/jboss/tools/maven/cdi/Messages.java 2011-05-19
14:13:11 UTC (rev 31380)
@@ -19,7 +19,7 @@
*/
public class Messages extends NLS {
private static final String BUNDLE_NAME =
"org.jboss.tools.maven.cdi.messages"; //$NON-NLS-1$
- public static String
CDIProjectConfigurator_The_project_does_not_contain_the_Web_Module_facet;
+ public static String
CDIProjectConfigurator_The_project_does_not_contain_required_facets;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
Modified:
trunk/maven/plugins/org.jboss.tools.maven.cdi/src/org/jboss/tools/maven/cdi/configurators/CDIProjectConfigurator.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.cdi/src/org/jboss/tools/maven/cdi/configurators/CDIProjectConfigurator.java 2011-05-19
13:48:33 UTC (rev 31379)
+++
trunk/maven/plugins/org.jboss.tools.maven.cdi/src/org/jboss/tools/maven/cdi/configurators/CDIProjectConfigurator.java 2011-05-19
14:13:11 UTC (rev 31380)
@@ -45,7 +45,9 @@
private static final String CDI_API_ARTIFACT_ID = "cdi-api"; //$NON-NLS-1$
protected static final IProjectFacet dynamicWebFacet;
+ protected static final IProjectFacet ejbFacet;
protected static final IProjectFacetVersion dynamicWebVersion;
+ protected static final IProjectFacetVersion ejbVersion;
protected static final IProjectFacet cdiFacet;
protected static final IProjectFacetVersion cdiVersion;
@@ -56,6 +58,8 @@
static {
dynamicWebFacet = ProjectFacetsManager.getProjectFacet("jst.web");
//$NON-NLS-1$
dynamicWebVersion = dynamicWebFacet.getVersion("2.5"); //$NON-NLS-1$
+ ejbFacet = ProjectFacetsManager.getProjectFacet("jst.ejb"); //$NON-NLS-1$
+ ejbVersion = ejbFacet.getVersion("3.0"); //$NON-NLS-1$
cdiFacet = ProjectFacetsManager.getProjectFacet("jst.cdi"); //$NON-NLS-1$
cdiVersion = cdiFacet.getVersion("1.0"); //$NON-NLS-1$
m2Facet = ProjectFacetsManager.getProjectFacet("jboss.m2"); //$NON-NLS-1$
@@ -83,7 +87,7 @@
if (cdiVersion != null) {
final IFacetedProject fproj = ProjectFacetsManager.create(project);
if ( (fproj != null) && ("war".equals(packaging) ||
"ejb".equals(packaging)) ) { //$NON-NLS-1$
- installWarFacets(fproj, cdiVersion, monitor);
+ installDefaultFacets(fproj, cdiVersion, monitor);
}
CDIUtil.enableCDI(project, false, new NullProgressMonitor());
}
@@ -117,16 +121,20 @@
}
- private void installWarFacets(IFacetedProject fproj, String cdiVersion,IProgressMonitor
monitor) throws CoreException {
+ private void installDefaultFacets(IFacetedProject fproj, String
cdiVersion,IProgressMonitor monitor) throws CoreException {
+ IProjectFacetVersion currentWebVersion = fproj.getProjectFacetVersion(dynamicWebFacet);
+ IProjectFacetVersion currentEjbVersion = fproj.getProjectFacetVersion(ejbFacet);
- if (!fproj.hasProjectFacet(dynamicWebFacet)) {
+ if ((currentWebVersion != null &&
currentWebVersion.compareTo(dynamicWebVersion)> -1)
+ || (currentEjbVersion != null &&
currentEjbVersion.compareTo(dynamicWebVersion)> -1)) {
+ installCDIFacet(fproj, cdiVersion, monitor);
+ } else {
String name = "";
if (fproj.getProject() != null) {
name = fproj.getProject().getName();
}
- MavenCDIActivator.log(NLS.bind(Messages.CDIProjectConfigurator_The_project_does_not_contain_the_Web_Module_facet,
name));
+ MavenCDIActivator.log(NLS.bind(Messages.CDIProjectConfigurator_The_project_does_not_contain_required_facets,
name));
}
- installCDIFacet(fproj, cdiVersion, monitor);
installM2Facet(fproj, monitor);
}
@@ -143,9 +151,7 @@
}
private String getCDIVersion(MavenProject mavenProject) {
- String version = null;
- version = Activator.getDefault().getDependencyVersion(mavenProject, CDI_API_GROUP_ID,
CDI_API_ARTIFACT_ID);
-
+ String version = Activator.getDefault().getDependencyVersion(mavenProject,
CDI_API_GROUP_ID, CDI_API_ARTIFACT_ID);
return version;
}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.cdi/src/org/jboss/tools/maven/cdi/messages.properties
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.cdi/src/org/jboss/tools/maven/cdi/messages.properties 2011-05-19
13:48:33 UTC (rev 31379)
+++
trunk/maven/plugins/org.jboss.tools.maven.cdi/src/org/jboss/tools/maven/cdi/messages.properties 2011-05-19
14:13:11 UTC (rev 31380)
@@ -1 +1 @@
-CDIProjectConfigurator_The_project_does_not_contain_the_Web_Module_facet=The {0} project
doesn't contain the Web Module facet.
+CDIProjectConfigurator_The_project_does_not_contain_required_facets=The {0} project does
not contain the Dynamic Web Module facet or the EJB Module facet.
Show replies by date