[jbosstools-commits] JBoss Tools SVN: r43504 - in trunk/maven: tests/org.jboss.tools.maven.configurators.tests and 4 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Fri Sep 7 07:58:38 EDT 2012
Author: fbricon
Date: 2012-09-07 07:58:37 -0400 (Fri, 07 Sep 2012)
New Revision: 43504
Added:
trunk/maven/tests/org.jboss.tools.maven.configurators.tests/projects/cdi/unsupported-cdi-version/
trunk/maven/tests/org.jboss.tools.maven.configurators.tests/projects/cdi/unsupported-cdi-version/pom.xml
Modified:
trunk/maven/plugins/org.jboss.tools.maven.cdi/src/org/jboss/tools/maven/cdi/configurators/CDIProjectConfigurator.java
trunk/maven/tests/org.jboss.tools.maven.configurators.tests/.classpath
trunk/maven/tests/org.jboss.tools.maven.configurators.tests/.settings/org.eclipse.jdt.core.prefs
trunk/maven/tests/org.jboss.tools.maven.configurators.tests/src/org/jboss/tools/maven/configurators/tests/CDIConfiguratorTest.java
Log:
JBIDE-12558 : fallback on default CDI Facet if CDI version infered from project dependencies is not supported
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 2012-09-07 11:45:36 UTC (rev 43503)
+++ trunk/maven/plugins/org.jboss.tools.maven.cdi/src/org/jboss/tools/maven/cdi/configurators/CDIProjectConfigurator.java 2012-09-07 11:58:37 UTC (rev 43504)
@@ -53,11 +53,10 @@
protected static final IProjectFacetVersion ejbVersion;
protected static final IProjectFacet cdiFacet;
- protected static final IProjectFacetVersion cdiVersion;
protected static final IProjectFacet m2Facet;
protected static final IProjectFacetVersion m2Version;
- private static final String DEFAULT_CDI_VERSION = "1.0";
+ private static final String DEFAULT_CDI_VERSION;
static {
dynamicWebFacet = ProjectFacetsManager.getProjectFacet("jst.web"); //$NON-NLS-1$
@@ -65,7 +64,7 @@
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(DEFAULT_CDI_VERSION); //$NON-NLS-1$
+ DEFAULT_CDI_VERSION = cdiFacet.getDefaultVersion().getVersionString();
m2Facet = ProjectFacetsManager.getProjectFacet("jboss.m2"); //$NON-NLS-1$
m2Version = m2Facet.getVersion("1.0"); //$NON-NLS-1$
}
@@ -145,13 +144,35 @@
private void installCDIFacet(IFacetedProject fproj, String cdiVersionString, IProgressMonitor monitor)
throws CoreException {
if (!fproj.hasProjectFacet(cdiFacet)) {
- if (cdiVersionString.startsWith("1.0")) { //$NON-NLS-1$
- IDataModel model = MavenCDIActivator.getDefault().createCDIDataModel(fproj,cdiVersion);
- fproj.installProjectFacet(cdiVersion, model, monitor);
+ IProjectFacetVersion facetVersion = getCdiFacetVersion(cdiVersionString);
+ if (facetVersion != null) { //$NON-NLS-1$
+ IDataModel model = MavenCDIActivator.getDefault().createCDIDataModel(fproj,facetVersion);
+ fproj.installProjectFacet(facetVersion, model, monitor);
}
}
}
+ private IProjectFacetVersion getCdiFacetVersion(String cdiVersionString) {
+ String majorMinor = getMajorMinorVersion(cdiVersionString);
+ IProjectFacetVersion facetVersion;
+ try {
+ facetVersion = cdiFacet.getVersion(majorMinor);
+ } catch(IllegalArgumentException iae) {
+ //ignore missing version
+ facetVersion = cdiFacet.getDefaultVersion();
+ MavenCDIActivator.log("CDI version " + majorMinor + " has no corresponding Facet, falling back to "+facetVersion.getVersionString());
+ }
+ return facetVersion;
+ }
+
+ private String getMajorMinorVersion(String versionString) {
+ String[] pointVersions = versionString.split("\\.");
+ if (pointVersions.length > 1) {
+ return pointVersions[0] + "." + pointVersions[1];
+ }
+ return versionString;
+ }
+
private String getCDIVersion(MavenProject mavenProject) {
String version = Activator.getDefault().getDependencyVersion(mavenProject, CDI_API_GROUP_ID, CDI_API_ARTIFACT_ID);
if (version == null) {
Modified: trunk/maven/tests/org.jboss.tools.maven.configurators.tests/.classpath
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.configurators.tests/.classpath 2012-09-07 11:45:36 UTC (rev 43503)
+++ trunk/maven/tests/org.jboss.tools.maven.configurators.tests/.classpath 2012-09-07 11:58:37 UTC (rev 43504)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/"/>
<classpathentry kind="output" path="target/classes"/>
Modified: trunk/maven/tests/org.jboss.tools.maven.configurators.tests/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.configurators.tests/.settings/org.eclipse.jdt.core.prefs 2012-09-07 11:45:36 UTC (rev 43503)
+++ trunk/maven/tests/org.jboss.tools.maven.configurators.tests/.settings/org.eclipse.jdt.core.prefs 2012-09-07 11:58:37 UTC (rev 43504)
@@ -1,8 +1,7 @@
-#Tue Aug 02 13:44:10 CEST 2011
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: trunk/maven/tests/org.jboss.tools.maven.configurators.tests/projects/cdi/unsupported-cdi-version/pom.xml
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.configurators.tests/projects/cdi/unsupported-cdi-version/pom.xml (rev 0)
+++ trunk/maven/tests/org.jboss.tools.maven.configurators.tests/projects/cdi/unsupported-cdi-version/pom.xml 2012-09-07 11:58:37 UTC (rev 43504)
@@ -0,0 +1,27 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>foo.bar</groupId>
+ <artifactId>unsupported-cdi-version</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>war</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <version>1.1.EDR1.1</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Modified: trunk/maven/tests/org.jboss.tools.maven.configurators.tests/src/org/jboss/tools/maven/configurators/tests/CDIConfiguratorTest.java
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.configurators.tests/src/org/jboss/tools/maven/configurators/tests/CDIConfiguratorTest.java 2012-09-07 11:45:36 UTC (rev 43503)
+++ trunk/maven/tests/org.jboss.tools.maven.configurators.tests/src/org/jboss/tools/maven/configurators/tests/CDIConfiguratorTest.java 2012-09-07 11:58:37 UTC (rev 43504)
@@ -34,6 +34,15 @@
assertIsCDIProject(cdiProject, DEFAULT_CDI_VERSION);
}
+ @Test
+ public void testJBIDE12558_unsupportedCdiVersion() throws Exception {
+ String projectLocation = "projects/cdi/unsupported-cdi-version";
+ IProject cdiProject = importProject(projectLocation+"/pom.xml");
+ waitForJobsToComplete();
+ assertNoErrors(cdiProject);
+ assertIsCDIProject(cdiProject, DEFAULT_CDI_VERSION);
+ }
+
private void assertIsCDIProject(IProject project, IProjectFacetVersion expectedCdiVersion) throws Exception {
assertNoErrors(project);
assertTrue("CDI nature is missing", project.hasNature(CDICoreNature.NATURE_ID));
More information about the jbosstools-commits
mailing list