Author: fbricon
Date: 2012-05-24 12:18:49 -0400 (Thu, 24 May 2012)
New Revision: 41359
Added:
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/HibernateLibValidator.java
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenHibernateLibraryProviderInstallOperationConfig.java
Modified:
trunk/maven/plugins/org.jboss.tools.maven.core/META-INF/MANIFEST.MF
trunk/maven/plugins/org.jboss.tools.maven.core/plugin.properties
trunk/maven/plugins/org.jboss.tools.maven.core/plugin.xml
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperationConfig.java
Log:
JBIDE-11624 fix for "The variable jpaPlatform is not defined" error when
importing Java EE Projects.
This fix requires adding a dependency on Dali (in order to implement a Library Validator).
Most likely, the Hibernate templates and Lib providers will have to be moved to the maven
hibernate plugin,
in order to remain Dali agnostic in the future.
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/META-INF/MANIFEST.MF 2012-05-24
16:13:32 UTC (rev 41358)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/META-INF/MANIFEST.MF 2012-05-24
16:18:49 UTC (rev 41359)
@@ -24,7 +24,9 @@
org.eclipse.m2e.model.edit;bundle-version="[1.0,1.2)";visibility:=reexport,
org.eclipse.core.expressions,
org.maven.ide.eclipse.wtp;bundle-version="[0.13.0,0.17.0)";visibility:=reexport,
- org.eclipse.jdt.ui;bundle-version="3.7.0"
+ org.eclipse.jdt.ui;bundle-version="3.7.0",
+ org.eclipse.jpt.common.core;bundle-version="1.0.0",
+ org.eclipse.jpt.jpa.core
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %Bundle-Vendor
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/plugin.properties
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/plugin.properties 2012-05-24 16:13:32
UTC (rev 41358)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/plugin.properties 2012-05-24 16:18:49
UTC (rev 41359)
@@ -4,6 +4,7 @@
JBoss_Maven_Integration=JBoss Maven Integration
Adds_support_for_Maven=Adds support for Maven.
Maven_library_provider=Maven library provider
+Maven_Hibernate_library_provider=Maven Hibernate library provider
Maven_JSF_1_2_Libraries=Maven JSF 1.2 Libraries
Maven_JSF_1_1_Libraries=Maven JSF 1.1 Libraries
Maven_JSF_2_0_Libraries=Maven JSF 2.0 Libraries
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/plugin.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/plugin.xml 2012-05-24 16:13:32 UTC (rev
41358)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/plugin.xml 2012-05-24 16:18:49 UTC (rev
41359)
@@ -75,6 +75,15 @@
</action>
</provider>
+
+ <provider id="maven-hibernate-library-provider"
abstract="true" extends="maven-library-provider">
+ <label>%Maven_Hibernate_library_provider</label>
+ <priority>500</priority>
+ <action type="INSTALL">
+ <config
class="org.jboss.tools.maven.core.libprov.MavenHibernateLibraryProviderInstallOperationConfig"/>
+ <operation
class="org.jboss.tools.maven.core.libprov.MavenLibraryProviderInstallOperation"/>
+ </action>
+ </provider>
</extension>
<extension point="org.eclipse.core.expressions.propertyTesters">
@@ -138,7 +147,7 @@
</provider>
</extension>
<extension
point="org.eclipse.jst.common.project.facet.core.libraryProviders">
- <provider id="hibernate332-maven-library-provider"
extends="maven-library-provider">
+ <provider id="hibernate332-maven-library-provider"
extends="maven-hibernate-library-provider">
<label>%Hibernate_3_3_2_Libraries</label>
<param name="template"
value="platform:/plugin/org.jboss.tools.maven.core/poms/hibernate332-template.xml"/>
<enablement>
@@ -157,7 +166,7 @@
</provider>
</extension>
<extension
point="org.eclipse.jst.common.project.facet.core.libraryProviders">
- <provider id="hibernate41X-maven-library-provider"
extends="maven-library-provider">
+ <provider id="hibernate41X-maven-library-provider"
extends="maven-hibernate-library-provider">
<label>%Hibernate_4_1_X_Libraries</label>
<param name="template"
value="platform:/plugin/org.jboss.tools.maven.core/poms/hibernate41X-template.xml"/>
<enablement>
@@ -168,15 +177,12 @@
<with variable="requestingProjectFacet">
<test
property="org.eclipse.wst.common.project.facet.core.projectFacet"
value="jpt.jpa:2.0" forcePluginActivation="true"/>
</with>
- <with variable="jpaPlatform">
- <equals value="hibernate2_0"/>
- </with>
</and>
</enablement>
</provider>
</extension>
<extension
point="org.eclipse.jst.common.project.facet.core.libraryProviders">
- <provider id="hibernate36X-maven-library-provider"
extends="maven-library-provider">
+ <provider id="hibernate36X-maven-library-provider"
extends="maven-hibernate-library-provider">
<label>%Hibernate_3_6_X_Libraries</label>
<param name="template"
value="platform:/plugin/org.jboss.tools.maven.core/poms/hibernate36X-template.xml"/>
<enablement>
@@ -188,9 +194,6 @@
<with variable="requestingProjectFacet">
<test
property="org.eclipse.wst.common.project.facet.core.projectFacet"
value="jpt.jpa:2.0" forcePluginActivation="true"/>
</with>
- <with variable="jpaPlatform">
- <equals value="hibernate2_0"/>
- </with>
</and>
<and>
<with variable="projectFacets">
@@ -199,14 +202,36 @@
<with variable="requestingProjectFacet">
<test
property="org.eclipse.wst.common.project.facet.core.projectFacet"
value="jpt.jpa:1.0" forcePluginActivation="true"/>
</with>
- <with variable="jpaPlatform">
- <equals value="hibernate"/>
- </with>
</and>
</or>
</enablement>
</provider>
</extension>
+
+ <extension
+ point="org.eclipse.jpt.common.core.libraryValidators">
+ <!-- Using a noop validator to fix
https://issues.jboss.org/browse/JBIDE-11624
-->
+ <libraryValidator
+ id="jpaMavenLibraryValidator"
+
class="org.jboss.tools.maven.core.libprov.HibernateLibValidator">
+ <enablement>
+ <or>
+ <with variable="libraryProvider">
+ <test
property="org.eclipse.jpt.common.core.extendsId"
value="hibernate41X-maven-library-provider"/>
+ </with>
+ <with variable="libraryProvider">
+ <test
property="org.eclipse.jpt.common.core.extendsId"
value="hibernate36X-maven-library-provider"/>
+ </with>
+ <with variable="libraryProvider">
+ <test
property="org.eclipse.jpt.common.core.extendsId"
value="hibernate332-maven-library-provider"/>
+ </with>
+ </or>
+ </enablement>
+ </libraryValidator>
+ </extension>
+
+
+
<extension
point="org.eclipse.jst.common.project.facet.core.libraryProviders">
<provider id="portlet10-maven-library-provider"
extends="maven-library-provider">
<label>%Maven_Portlet_1_0_Libraries</label>
Added:
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/HibernateLibValidator.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/HibernateLibValidator.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/HibernateLibValidator.java 2012-05-24
16:18:49 UTC (rev 41359)
@@ -0,0 +1,34 @@
+/*************************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.core.libprov;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jpt.common.core.libprov.JptLibraryProviderInstallOperationConfig;
+import org.eclipse.jpt.common.core.libval.LibraryValidator;
+import org.eclipse.jpt.jpa.core.libprov.JpaLibraryProviderInstallOperationConfig;
+import org.jboss.tools.maven.core.MavenCoreActivator;
+
+public class HibernateLibValidator implements LibraryValidator {
+
+ @SuppressWarnings("nls")
+ public IStatus validate(JptLibraryProviderInstallOperationConfig config) {
+ JpaLibraryProviderInstallOperationConfig jpaConfig =
(JpaLibraryProviderInstallOperationConfig) config;
+ IStatus status;
+ if (jpaConfig.getJpaPlatform().getId().contains("hibernate")) {
+ status = Status.OK_STATUS;
+ } else {
+ status = new Status(IStatus.ERROR, MavenCoreActivator.PLUGIN_ID, "This JPA
implementation requires an Hibernate-based Platform");
+ }
+ return status;
+ }
+
+}
Added:
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenHibernateLibraryProviderInstallOperationConfig.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenHibernateLibraryProviderInstallOperationConfig.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenHibernateLibraryProviderInstallOperationConfig.java 2012-05-24
16:18:49 UTC (rev 41359)
@@ -0,0 +1,54 @@
+/*************************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.core.libprov;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jpt.common.core.JptCommonCorePlugin;
+import org.eclipse.jpt.common.core.libval.LibraryValidator;
+import org.eclipse.jpt.jpa.core.libprov.JpaLibraryProviderInstallOperationConfig;
+import org.eclipse.jpt.jpa.core.platform.JpaPlatformDescription;
+
+/**
+ * @author Fred Bricon
+ *
+ */
+public class MavenHibernateLibraryProviderInstallOperationConfig extends
MavenLibraryProviderInstallOperationConfig implements
JpaLibraryProviderInstallOperationConfig {
+
+ private JpaPlatformDescription jpaPlatformDescription;
+
+ public JpaPlatformDescription getJpaPlatform() {
+ return jpaPlatformDescription;
+ }
+
+ public void setJpaPlatform(JpaPlatformDescription jpaPlatform) {
+ this.jpaPlatformDescription = jpaPlatform;
+ }
+
+ @Override
+ public synchronized IStatus validate() {
+ IStatus status = super.validate();
+ if (! status.isOK()) {
+ return status;
+ }
+ if (getJpaPlatform() != null) {
+ for (LibraryValidator libraryValidator :
JptCommonCorePlugin.getLibraryValidators(this)) {
+ status = libraryValidator.validate(this);
+ if (! status.isOK()) {
+ return status;
+ }
+ }
+ }
+
+ return Status.OK_STATUS;
+ }
+
+}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperationConfig.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperationConfig.java 2012-05-24
16:13:32 UTC (rev 41358)
+++
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperationConfig.java 2012-05-24
16:18:49 UTC (rev 41359)
@@ -17,8 +17,7 @@
* @author snjeza
*
*/
-public class MavenLibraryProviderInstallOperationConfig extends
- LibraryProviderInstallOperationConfig {
+public class MavenLibraryProviderInstallOperationConfig extends
LibraryProviderInstallOperationConfig {
private Model model;