Author: fbricon
Date: 2012-02-07 05:54:17 -0500 (Tue, 07 Feb 2012)
New Revision: 38456
Added:
trunk/maven/features/org.jboss.tools.maven.jpa.feature/
trunk/maven/features/org.jboss.tools.maven.jpa.feature/.project
trunk/maven/features/org.jboss.tools.maven.jpa.feature/build.properties
trunk/maven/features/org.jboss.tools.maven.jpa.feature/feature.properties
trunk/maven/features/org.jboss.tools.maven.jpa.feature/feature.xml
trunk/maven/features/org.jboss.tools.maven.jpa.feature/license.html
trunk/maven/features/org.jboss.tools.maven.jpa.feature/pom.xml
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/MavenUtil.java
trunk/maven/plugins/org.jboss.tools.maven.jpa/
trunk/maven/plugins/org.jboss.tools.maven.jpa/.classpath
trunk/maven/plugins/org.jboss.tools.maven.jpa/.project
trunk/maven/plugins/org.jboss.tools.maven.jpa/.settings/
trunk/maven/plugins/org.jboss.tools.maven.jpa/.settings/org.eclipse.jdt.core.prefs
trunk/maven/plugins/org.jboss.tools.maven.jpa/.settings/org.eclipse.m2e.core.prefs
trunk/maven/plugins/org.jboss.tools.maven.jpa/META-INF/
trunk/maven/plugins/org.jboss.tools.maven.jpa/META-INF/MANIFEST.MF
trunk/maven/plugins/org.jboss.tools.maven.jpa/about.html
trunk/maven/plugins/org.jboss.tools.maven.jpa/about.ini
trunk/maven/plugins/org.jboss.tools.maven.jpa/about.mappings
trunk/maven/plugins/org.jboss.tools.maven.jpa/about.properties
trunk/maven/plugins/org.jboss.tools.maven.jpa/build.properties
trunk/maven/plugins/org.jboss.tools.maven.jpa/jboss_about.png
trunk/maven/plugins/org.jboss.tools.maven.jpa/lifecycle-mapping-metadata.xml
trunk/maven/plugins/org.jboss.tools.maven.jpa/plugin.properties
trunk/maven/plugins/org.jboss.tools.maven.jpa/plugin.xml
trunk/maven/plugins/org.jboss.tools.maven.jpa/pom.xml
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/MavenJpaActivator.java
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/AbstractPlatformIdentifier.java
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/IPlatformIdentifier.java
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/JpaProjectConfigurator.java
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/JptUtils.java
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/MavenResourceLocator.java
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/PlatformIdentifierManager.java
Modified:
trunk/maven/features/pom.xml
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/Activator.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/Messages.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/messages.properties
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/preferences/ConfiguratorPreferencePage.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/preferences/ConfiguratorPreferencesInitializer.java
trunk/maven/plugins/pom.xml
Log:
JBIDE-10750 : add new JPA maven configurator
Added: trunk/maven/features/org.jboss.tools.maven.jpa.feature/.project
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jpa.feature/.project
(rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jpa.feature/.project 2012-02-07 10:54:17
UTC (rev 38456)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.maven.jpa.feature</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.pde.FeatureBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.FeatureNature</nature>
+ </natures>
+</projectDescription>
Added: trunk/maven/features/org.jboss.tools.maven.jpa.feature/build.properties
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jpa.feature/build.properties
(rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jpa.feature/build.properties 2012-02-07
10:54:17 UTC (rev 38456)
@@ -0,0 +1,3 @@
+bin.includes = feature.xml,\
+ license.html,\
+ feature.properties
Added: trunk/maven/features/org.jboss.tools.maven.jpa.feature/feature.properties
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jpa.feature/feature.properties
(rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jpa.feature/feature.properties 2012-02-07
10:54:17 UTC (rev 38456)
@@ -0,0 +1,53 @@
+###############################################################################
+# Copyright (c) 2010-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.
+##############################################################################
+# feature.properties
+# contains externalized strings for feature.xml
+# "%foo" in feature.xml corresponds to the key "foo" in this file
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file should be translated.
+
+# "featureName" property - name of the feature
+featureName=JBoss Maven JPA Configurator
+
+# "providerName" property - name of the company that provides the feature
+providerName=JBoss by Red Hat
+
+# "updateSiteName" property - label for the update site
+updateSiteName=JBossTools Update Site
+
+# "description" property - description of the feature
+description=JBoss Maven JPA Configurator
+
+# "copyright" property - text of the "Feature Update Copyright"
+copyright=Copyright (c) 2010-2012 Red Hat, Inc. and others.\n\
+All rights reserved. This program and the accompanying materials\n\
+are made available under the terms of the Eclipse Public License v1.0\n\
+which accompanies this distribution, and is available at\n\
+http\://www.eclipse.org/legal/epl-v10.html\n\nContributors\:\n\
+JBoss by Red Hat - Initial implementation.
+ ############### end of copyright property ####################################
+
+# "licenseURL" property - URL of the "Feature License"
+# do not translate value - just change to point to a locale-specific HTML page
+licenseURL=license.html
+
+# START NON-TRANSLATABLE
+# "license" property - text of the "Feature Update License"
+# should be plain text version of license agreement pointed to be "licenseURL"
+license=Red Hat, Inc. licenses these features and plugins to you under \
+certain open source licenses (or aggregations of such licenses), which \
+in a particular case may include the Eclipse Public License, the GNU \
+Lesser General Public License, and/or certain other open source \
+licenses. For precise licensing details, consult the corresponding \
+source code, or contact Red Hat Legal Affairs, 1801 Varsity Drive, \
+Raleigh NC 27606 USA.
+# END NON-TRANSLATABLE
+########### end of license property ##########################################
Added: trunk/maven/features/org.jboss.tools.maven.jpa.feature/feature.xml
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jpa.feature/feature.xml
(rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jpa.feature/feature.xml 2012-02-07 10:54:17
UTC (rev 38456)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.jboss.tools.maven.jpa.feature"
+ label="%featureName"
+ version="1.3.0.qualifier"
+ provider-name="%providerName"
+ plugin="org.jboss.tools.maven.jpa">
+
+ <description>
+ %description
+ </description>
+
+ <copyright>
+ %copyright
+ </copyright>
+
+ <license url="%licenseURL">
+ %license
+ </license>
+
+ <requires>
+ <import feature="org.eclipse.m2e.feature" version="0.13.0"
match="greaterOrEqual"/>
+ </requires>
+
+ <plugin
+ id="org.jboss.tools.maven.jpa"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
Added: trunk/maven/features/org.jboss.tools.maven.jpa.feature/license.html
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jpa.feature/license.html
(rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jpa.feature/license.html 2012-02-07
10:54:17 UTC (rev 38456)
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html>
+
+<body>
+<p>Red Hat, Inc. licenses these features and plugins to you under
+certain open source licenses (or aggregations of such licenses), which
+in a particular case may include the Eclipse Public License, the GNU
+Lesser General Public License, and/or certain other open source
+licenses. For precise licensing details, consult the corresponding
+source code, or contact Red Hat Legal Affairs, 1801 Varsity Drive,
+Raleigh NC 27606 USA.
+</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/maven/features/org.jboss.tools.maven.jpa.feature/pom.xml
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jpa.feature/pom.xml
(rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jpa.feature/pom.xml 2012-02-07 10:54:17 UTC
(rev 38456)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+ <parent>
+ <groupId>org.jboss.tools.maven</groupId>
+ <artifactId>features</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools.maven.features</groupId>
+ <artifactId>org.jboss.tools.maven.jpa.feature</artifactId>
+
+ <packaging>eclipse-feature</packaging>
+</project>
\ No newline at end of file
Modified: trunk/maven/features/pom.xml
===================================================================
--- trunk/maven/features/pom.xml 2012-02-07 10:08:37 UTC (rev 38455)
+++ trunk/maven/features/pom.xml 2012-02-07 10:54:17 UTC (rev 38456)
@@ -23,6 +23,7 @@
<module>org.jboss.tools.maven.test.feature</module>
<module>org.jboss.tools.maven.jaxrs.feature</module>
<module>org.jboss.tools.maven.jbosspackaging.feature</module>
- </modules>
+ <module>org.jboss.tools.maven.jpa.feature</module>
+ </modules>
</project>
Added:
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/MavenUtil.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/MavenUtil.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/MavenUtil.java 2012-02-07
10:54:17 UTC (rev 38456)
@@ -0,0 +1,49 @@
+/*************************************************************************************
+ * 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;
+
+import org.apache.maven.model.Parent;
+import org.apache.maven.project.MavenProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+
+/**
+ * Utility class for Maven related operations.
+ *
+ * @author Fred Bricon
+ *
+ */
+public class MavenUtil {
+
+ /**
+ * Refresh the mavenProject parent, if it exists in the workspace.
+ *
+ * @param mavenProject
+ * @throws CoreException
+ */
+ public static void refreshParent(MavenProject mavenProject) throws CoreException {
+ if (mavenProject == null || mavenProject.getModel()== null) {
+ return;
+ }
+ Parent parent = mavenProject.getModel().getParent();
+ if (parent != null) {
+ IMavenProjectFacade parentFacade =
MavenPlugin.getMavenProjectRegistry().getMavenProject(parent.getGroupId(),
+ parent.getArtifactId(),
+ parent.getVersion());
+ if (parentFacade != null) {
+ parentFacade.getProject().refreshLocal(IResource.DEPTH_INFINITE, new
NullProgressMonitor());
+ }
+ }
+ }
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.jpa/.classpath
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jpa/.classpath (rev
0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jpa/.classpath 2012-02-07 10:54:17 UTC (rev
38456)
@@ -0,0 +1,7 @@
+<?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.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: trunk/maven/plugins/org.jboss.tools.maven.jpa/.project
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jpa/.project (rev
0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jpa/.project 2012-02-07 10:54:17 UTC (rev
38456)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.maven.jpa</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/maven/plugins/org.jboss.tools.maven.jpa/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jpa/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jpa/.settings/org.eclipse.jdt.core.prefs 2012-02-07
10:54:17 UTC (rev 38456)
@@ -0,0 +1,8 @@
+#Wed Feb 01 17:28:41 CET 2012
+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
Added: trunk/maven/plugins/org.jboss.tools.maven.jpa/.settings/org.eclipse.m2e.core.prefs
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jpa/.settings/org.eclipse.m2e.core.prefs
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jpa/.settings/org.eclipse.m2e.core.prefs 2012-02-07
10:54:17 UTC (rev 38456)
@@ -0,0 +1,5 @@
+#Wed Feb 01 17:28:40 CET 2012
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
Added: trunk/maven/plugins/org.jboss.tools.maven.jpa/META-INF/MANIFEST.MF
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jpa/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jpa/META-INF/MANIFEST.MF 2012-02-07 10:54:17
UTC (rev 38456)
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.jboss.tools.maven.jpa;singleton:=true
+Bundle-Version: 1.3.0.qualifier
+Bundle-Activator: org.jboss.tools.maven.jpa.MavenJpaActivator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.jboss.tools.maven.core,
+ org.jboss.tools.maven.ui,
+ org.jboss.tools.common.model,
+ org.eclipse.jst.j2ee.core,
+ org.eclipse.jst.j2ee,
+ org.eclipse.wst.common.emfworkbench.integration,
+ org.eclipse.jpt.jpa.core,
+ org.eclipse.jpt.common.core
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,
+ JavaSE-1.6
+Bundle-Localization: plugin
+Bundle-Vendor: %Bundle-Vendor
Added: trunk/maven/plugins/org.jboss.tools.maven.jpa/about.html
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jpa/about.html (rev
0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jpa/about.html 2012-02-07 10:54:17 UTC (rev
38456)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1" />
+<title>JBoss Maven JPA Configurator</title>
+<style type="text/css" media="screen">
+<!--
+ body {
+ font-family: Sans-serif, Arial, Helvetica;
+ }
+
+-->
+</style>
+</head>
+<body>
+<h1>JBoss Maven JPA Configurator</h1>
+
+<p>
+This plugin is part of the JBoss Tools developed by the <a
href="http://www.jboss.com">JBoss Inc.</a>
+</p>
+
+<p>Information about this plugin is available at <a
href="http://www.jboss.org/tools">JBoss Tools project
page</a></p>
+
+<p>
+This software is distributed under the terms of the Eclipse Public License - v 1.0
+(see <a
href="www.eclipse.org/legal/epl-v10.html">Eclipse Public License
- Version 1.0</a>).
+</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/maven/plugins/org.jboss.tools.maven.jpa/about.ini
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jpa/about.ini (rev
0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jpa/about.ini 2012-02-07 10:54:17 UTC (rev
38456)
@@ -0,0 +1,27 @@
+# about.ini
+# contains information about a feature
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# "%key" are externalized strings defined in about.properties
+# This file does not need to be translated.
+# test
+# Property "aboutText" contains blurb for "About" dialog
(translated)
+aboutText=%blurb
+
+# Property "windowImage" contains path to window icon (16x16)
+# needed for primary features only
+
+# Property "featureImage" contains path to feature image (32x32)
+featureImage=jboss_about.png
+
+# Property "aboutImage" contains path to product image (500x330 or 115x164)
+# needed for primary features only
+
+# Property "appName" contains name of the application (not translated)
+# needed for primary features only
+
+# Property "welcomePerspective" contains the id of the perspective in which
the
+# welcome page is to be opened.
+# optional
+
+
+
Added: trunk/maven/plugins/org.jboss.tools.maven.jpa/about.mappings
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jpa/about.mappings
(rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jpa/about.mappings 2012-02-07 10:54:17 UTC
(rev 38456)
@@ -0,0 +1,5 @@
+# about.mappings
+# contains fill-ins for about.properties
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file does not need to be translated.
+
Added: trunk/maven/plugins/org.jboss.tools.maven.jpa/about.properties
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jpa/about.properties
(rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jpa/about.properties 2012-02-07 10:54:17 UTC
(rev 38456)
@@ -0,0 +1,2 @@
+blurb=JBoss Maven JPA Configurator\n\nVersion\: {featureVersion}\n\n(c) Copyright (c) Red
Hat, Inc., contributors and others 2004 - 2012. All rights reserved.\nVisit
http\://jboss.org/tools
+
Added: trunk/maven/plugins/org.jboss.tools.maven.jpa/build.properties
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jpa/build.properties
(rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jpa/build.properties 2012-02-07 10:54:17 UTC
(rev 38456)
@@ -0,0 +1,12 @@
+source.. = src/
+output.. = target/classes/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties,\
+ about.html,\
+ about.ini,\
+ about.mappings,\
+ about.properties,\
+ jboss_about.png,\
+ lifecycle-mapping-metadata.xml
Added: trunk/maven/plugins/org.jboss.tools.maven.jpa/jboss_about.png
===================================================================
(Binary files differ)
Property changes on: trunk/maven/plugins/org.jboss.tools.maven.jpa/jboss_about.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/maven/plugins/org.jboss.tools.maven.jpa/lifecycle-mapping-metadata.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jpa/lifecycle-mapping-metadata.xml
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jpa/lifecycle-mapping-metadata.xml 2012-02-07
10:54:17 UTC (rev 38456)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lifecycleMappingMetadata>
+
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <versionRange>[2.0,)</versionRange>
+ <goals>
+ <goal>compile</goal>
+ <goal>testCompile</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <configurator>
+ <id>org.jboss.tools.maven.jpa.configurator</id>
+ </configurator>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+
+</lifecycleMappingMetadata>
\ No newline at end of file
Added: trunk/maven/plugins/org.jboss.tools.maven.jpa/plugin.properties
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jpa/plugin.properties
(rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jpa/plugin.properties 2012-02-07 10:54:17
UTC (rev 38456)
@@ -0,0 +1,4 @@
+Bundle-Vendor = JBoss by Red Hat
+Bundle-Name = JBoss Maven JPA Configurator
+jpa_project_configurator = JPA
+
Added: trunk/maven/plugins/org.jboss.tools.maven.jpa/plugin.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jpa/plugin.xml (rev
0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jpa/plugin.xml 2012-02-07 10:54:17 UTC (rev
38456)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.m2e.core.lifecycleMappingMetadataSource">
+ </extension>
+
+ <extension point="org.eclipse.m2e.core.projectConfigurators">
+ <configurator
+ id="org.jboss.tools.maven.jpa.configurator"
+
class="org.jboss.tools.maven.jpa.configurators.JpaProjectConfigurator"
+ name="%jpa_project_configurator"
+ secondaryTo="org.eclipse.m2e.jdt.javaConfigurator"/>
+ </extension>
+
+
+ <extension
+ point="org.eclipse.jpt.common.core.resourceLocators">
+ <resourceLocator
+
class="org.jboss.tools.maven.jpa.configurators.MavenResourceLocator"
+ id="mavenResourceLocator"
+ priority="lowest"
+ >
+ <enablement>
+ <with variable="project">
+ <and>
+ <test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.jdt.core.javanature"
forcePluginActivation="true"/>
+ <test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.m2e.core.maven2Nature"
forcePluginActivation="true"/>
+ </and>
+ </with>
+ </enablement>
+ </resourceLocator>
+ </extension>
+
+</plugin>
Added: trunk/maven/plugins/org.jboss.tools.maven.jpa/pom.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jpa/pom.xml (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jpa/pom.xml 2012-02-07 10:54:17 UTC (rev
38456)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+ <parent>
+ <groupId>org.jboss.tools.maven</groupId>
+ <artifactId>plugins</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools.maven.plugins</groupId>
+ <artifactId>org.jboss.tools.maven.jpa</artifactId>
+
+ <packaging>eclipse-plugin</packaging>
+</project>
Added:
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/MavenJpaActivator.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/MavenJpaActivator.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/MavenJpaActivator.java 2012-02-07
10:54:17 UTC (rev 38456)
@@ -0,0 +1,69 @@
+/*************************************************************************************
+ * 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.jpa;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.jboss.tools.maven.jpa.configurators.PlatformIdentifierManager;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class MavenJpaActivator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.maven.jpa";
//$NON-NLS-1$
+
+ // The shared instance
+ private static MavenJpaActivator plugin;
+
+ private PlatformIdentifierManager platformIdentifierManager;
+
+ public PlatformIdentifierManager getPlatformIdentifierManager() {
+ return platformIdentifierManager;
+ }
+
+ /**
+ * The constructor
+ */
+ public MavenJpaActivator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ platformIdentifierManager = new PlatformIdentifierManager();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ platformIdentifierManager = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static MavenJpaActivator getDefault() {
+ return plugin;
+ }
+
+}
Added:
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/AbstractPlatformIdentifier.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/AbstractPlatformIdentifier.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/AbstractPlatformIdentifier.java 2012-02-07
10:54:17 UTC (rev 38456)
@@ -0,0 +1,43 @@
+/*************************************************************************************
+ * 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.jpa.configurators;
+
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlProperties;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlProperty;
+
+public abstract class AbstractPlatformIdentifier implements IPlatformIdentifier {
+
+ public String getPlatformId(XmlPersistenceUnit xmlPersistenceUnit) {
+ if (xmlPersistenceUnit == null) {
+ return null;
+ }
+ String platformId = identifyProvider(xmlPersistenceUnit.getProvider());
+ if (platformId != null) {
+ return platformId;
+ }
+ XmlProperties properties = xmlPersistenceUnit.getProperties();
+ if (properties != null && properties.getProperties() != null) {
+ for (XmlProperty property : properties.getProperties()){
+ platformId = identifyProperty(property);
+ if (platformId != null) {
+ return platformId;
+ }
+ }
+ }
+ return null;
+ }
+
+ protected abstract String identifyProvider(String provider);
+
+ protected abstract String identifyProperty(XmlProperty property);
+
+}
Added:
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/IPlatformIdentifier.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/IPlatformIdentifier.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/IPlatformIdentifier.java 2012-02-07
10:54:17 UTC (rev 38456)
@@ -0,0 +1,18 @@
+/*************************************************************************************
+ * 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.jpa.configurators;
+
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit;
+
+public interface IPlatformIdentifier {
+
+ String getPlatformId(XmlPersistenceUnit persistenceUnit);
+}
Added:
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/JpaProjectConfigurator.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/JpaProjectConfigurator.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/JpaProjectConfigurator.java 2012-02-07
10:54:17 UTC (rev 38456)
@@ -0,0 +1,180 @@
+/*************************************************************************************
+ * 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.jpa.configurators;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jpt.jpa.core.JpaFacet;
+import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
+import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetDataModelProperties;
+import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties;
+import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProvider;
+import
org.eclipse.jpt.jpa.core.internal.resource.persistence.PersistenceXmlResourceProvider;
+import org.eclipse.jpt.jpa.core.platform.JpaPlatformDescription;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit;
+import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource;
+import org.eclipse.jst.common.project.facet.core.JavaFacet;
+import org.eclipse.jst.common.project.facet.core.internal.JavaFacetUtil;
+import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderFramework;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
+import org.eclipse.m2e.core.project.configurator.ILifecycleMappingConfiguration;
+import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
+import org.eclipse.m2e.core.project.configurator.ProjectConfigurationRequest;
+import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.jboss.tools.maven.core.MavenUtil;
+import org.jboss.tools.maven.jpa.MavenJpaActivator;
+import org.jboss.tools.maven.ui.Activator;
+
+/**
+ * JPA Project configurator. Will install the JPA facet on a maven project containing a
persistence.xml.
+ *
+ * @author Fred Bricon
+ */
+@SuppressWarnings("restriction")
+public class JpaProjectConfigurator extends AbstractProjectConfigurator {
+
+ private static final String JPA_NO_OP_LIBRARY_PROVIDER =
"jpa-no-op-library-provider";
+
+ @Override
+ public void configure(ProjectConfigurationRequest request,
+ IProgressMonitor monitor) throws CoreException {
+ IProject project = request.getProject();
+
+ if(!canConfigure(project)) {
+ return;
+ }
+
+ IFile persistenceXml = JptUtils.getPersistenceXml(project);
+ if (persistenceXml == null || !persistenceXml.exists()) {
+ //No persistence.xml => not a JPA project
+ return;
+ }
+
+ IFacetedProject facetedProject = ProjectFacetsManager.create(project, true, monitor);
+ if (facetedProject != null) {
+ //Refresh parent in multi-module setups, or Dali pukes
+ MavenUtil.refreshParent(request.getMavenProject());
+
+ configureFacets(monitor, project, facetedProject, persistenceXml);
+ }
+ }
+
+ private void configureFacets(IProgressMonitor monitor, IProject project,
+ IFacetedProject facetedProject, IFile persistenceXml)
+ throws CoreException {
+
+ //Need to refresh the persistence.xml as the resource provider might crash badly on
some occasions
+ //if it finds the file is out-of-sync
+ persistenceXml.refreshLocal(IResource.DEPTH_ZERO, null);
+
+ PersistenceXmlResourceProvider provider =
PersistenceXmlResourceProvider.getXmlResourceProvider(persistenceXml);
+
+ JpaXmlResource jpaXmlResource = provider.getXmlResource();
+
+ IProjectFacetVersion version = JptUtils.getVersion(jpaXmlResource);
+
+ JpaPlatformDescription platform = getPlatform(jpaXmlResource, version);
+
+ IDataModel dataModel = getDataModel(facetedProject, version, platform);
+
+ Set<Action> actions = new LinkedHashSet<Action>();
+ installJavaFacet(actions, project, facetedProject);
+ actions.add(new IFacetedProject.Action(IFacetedProject.Action.Type.INSTALL,
+ version,
+ dataModel));
+ facetedProject.modify(actions, monitor);
+ }
+
+
+ private JpaPlatformDescription getPlatform(JpaXmlResource persistenceXml,
IProjectFacetVersion facetVersion) {
+ XmlPersistenceUnit xmlPersistenceUnit =
JptUtils.getFirstXmlPersistenceUnit(persistenceXml);
+ if (xmlPersistenceUnit == null) {
+ return null;
+ }
+ PlatformIdentifierManager identifierManager =
MavenJpaActivator.getDefault().getPlatformIdentifierManager();
+ String platformType = identifierManager.identify(xmlPersistenceUnit);
+ if (platformType != null) {
+ for (JpaPlatformDescription platform :
JptJpaCorePlugin.getJpaPlatformManager().getJpaPlatforms()) {
+ if (platform.supportsJpaFacetVersion(facetVersion) &&
platform.getId().contains(platformType)) {
+ return platform;
+ }
+ }
+ }
+ //If no adequate platform found, Dali will use a default one.
+ return null;
+ }
+
+ private IDataModel getDataModel(IFacetedProject facetedProject,
+ IProjectFacetVersion version,
+ JpaPlatformDescription platform) {
+
+ IDataModel dm = DataModelFactory.createDataModel(new
JpaFacetInstallDataModelProvider());
+
+ dm.setProperty(IFacetDataModelProperties.FACET_VERSION_STR,
version.getVersionString());
+ dm.setProperty(JpaFacetDataModelProperties.PLATFORM, platform);
+ dm.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, false);
+ dm.setProperty(JpaFacetInstallDataModelProperties.DISCOVER_ANNOTATED_CLASSES, true);
+
+ LibraryInstallDelegate libraryInstallDelegate = getNoOpLibraryProvider(facetedProject,
version);
+ dm.setProperty(JpaFacetInstallDataModelProperties.LIBRARY_PROVIDER_DELEGATE,
libraryInstallDelegate);
+
+ return dm;
+ }
+
+ private boolean canConfigure(IProject project) throws CoreException {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ boolean configureJpa = store.getBoolean(Activator.CONFIGURE_JPA);
+ return configureJpa
+ && !JpaFacet.isInstalled(project)
+ && project.hasNature(JavaCore.NATURE_ID);
+ }
+
+ private LibraryInstallDelegate getNoOpLibraryProvider(IFacetedProject facetedProject,
IProjectFacetVersion facetVersion) {
+ LibraryInstallDelegate libraryDelegate = new LibraryInstallDelegate(facetedProject,
facetVersion);
+ ILibraryProvider provider =
LibraryProviderFramework.getProvider(JPA_NO_OP_LIBRARY_PROVIDER);
+ libraryDelegate.setLibraryProvider(provider);
+ return libraryDelegate;
+ }
+
+ @Override
+ public boolean hasConfigurationChanged(IMavenProjectFacade newFacade,
+ ILifecycleMappingConfiguration oldProjectConfiguration,
+ MojoExecutionKey key, IProgressMonitor monitor) {
+ //Changes to maven-compiler-plugin in pom.xml don't make it "dirty" wrt
JPA config
+ return false;
+ }
+
+ private void installJavaFacet(Set<Action> actions, IProject project,
IFacetedProject facetedProject) {
+ IProjectFacetVersion javaFv =
JavaFacet.FACET.getVersion(JavaFacetUtil.getCompilerLevel(project));
+ if(!facetedProject.hasProjectFacet(JavaFacet.FACET)) {
+ actions.add(new IFacetedProject.Action(IFacetedProject.Action.Type.INSTALL,
javaFv, null));
+ } else if(!facetedProject.hasProjectFacet(javaFv)) {
+ actions.add(new IFacetedProject.Action(IFacetedProject.Action.Type.VERSION_CHANGE,
javaFv, null));
+ }
+ }
+}
Added:
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/JptUtils.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/JptUtils.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/JptUtils.java 2012-02-07
10:54:17 UTC (rev 38456)
@@ -0,0 +1,79 @@
+/*************************************************************************************
+ * 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.jpa.configurators;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jpt.common.core.JptCommonCorePlugin;
+import org.eclipse.jpt.common.core.resource.ResourceLocator;
+import org.eclipse.jpt.jpa.core.JpaFacet;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit;
+import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+
+/**
+ * Utility class related to the the Java Persistence Toolkit
+ *
+ * @author Fred Bricon
+ */
+public class JptUtils {
+
+ /**
+ * @return the IFile persitence.xml handle. Can be null.
+ */
+ public static IFile getPersistenceXml(IProject project) {
+ ResourceLocator resourceLocator = JptCommonCorePlugin.getResourceLocator(project);
+ if (resourceLocator == null) {
+ return null;
+ }
+ IPath path = resourceLocator.getResourcePath(project, new
Path("META-INF/persistence.xml"));
+ IFile persistenceXml = null;
+ if (path != null) {
+ persistenceXml = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ }
+ return persistenceXml;
+ }
+
+ /**
+ * @return the first persistence unit found in persistenceXml
+ */
+ public static XmlPersistenceUnit getFirstXmlPersistenceUnit(JpaXmlResource
persistenceXml) {
+ if (persistenceXml != null && persistenceXml.getRootObject() instanceof
XmlPersistence) {
+ XmlPersistence xmlPersistence = (XmlPersistence)persistenceXml.getRootObject();
+ List<XmlPersistenceUnit> persistenceUnits =
xmlPersistence.getPersistenceUnits();
+ if (persistenceUnits != null && !persistenceUnits.isEmpty()) {
+ return persistenceUnits.get(0);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @return the JPA Facet version corresponding to the version attribute of a
JpaXmlResource
+ */
+ public static IProjectFacetVersion getVersion(JpaXmlResource persistenceXml) {
+ if (persistenceXml == null) {
+ return null;
+ }
+ String version = persistenceXml.getVersion();
+ if (version == null || version.trim().length() == 0) {
+ return JpaFacet.FACET.getDefaultVersion();
+ }
+ return JpaFacet.FACET.getVersion(version);
+ }
+
+}
Added:
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/MavenResourceLocator.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/MavenResourceLocator.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/MavenResourceLocator.java 2012-02-07
10:54:17 UTC (rev 38456)
@@ -0,0 +1,208 @@
+/*************************************************************************************
+ * 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.jpa.configurators;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.model.Resource;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jpt.common.core.internal.resource.ModuleResourceLocator;
+import org.eclipse.jpt.common.core.internal.resource.SimpleJavaResourceLocator;
+import org.eclipse.jpt.common.core.internal.resource.WebModuleResourceLocator;
+import org.eclipse.jpt.common.core.resource.ResourceLocator;
+import org.eclipse.jst.j2ee.web.project.facet.WebFacetUtils;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.internal.IMavenConstants;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+
+/**
+ * Maven resource Locator
+ *
+ * @author Fred Bricon
+ */
+@SuppressWarnings("restriction")
+public class MavenResourceLocator implements ResourceLocator {
+
+ private static IPath META_INF_PATH = new Path("META-INF");
+
+ /**
+ * Accepts all resources not under the build output and test build output
+ * folders
+ */
+ public boolean acceptResourceLocation(IProject project, IContainer container) {
+ IMavenProjectFacade mavenProjectFacade = getMavenProjectFacade(project);
+ boolean accept = true;
+ if (mavenProjectFacade != null
+ && mavenProjectFacade.getMavenProject() != null) {
+ IPath classesPath = mavenProjectFacade.getOutputLocation();
+ IPath testClassesPath = mavenProjectFacade.getTestOutputLocation();
+ if (classesPath.isPrefixOf(container.getFullPath())
+ || testClassesPath.isPrefixOf(container.getFullPath())) {
+ // Reject everything coming from target/classes and
+ // target/testClasses
+ accept = false;
+ }
+ } else {
+ // Maven project not loaded yet, fallback to default behaviour.
+ accept = getDelegate(project).acceptResourceLocation(project, container);
+ }
+ // Sometimes src/main/resources/META-INF is not even sent immediately to
+ // this method, resulting in persistence.xml not being added to the jpaFiles
+ // of the jpaProject hence the creation of a
+ // "The persistence.xml file does not have recognized content." error
+ // marker
+
+ return accept;
+ }
+
+ private ResourceLocator getDelegate(IProject project) {
+ if (ModuleCoreNature.isFlexibleProject(project)) {
+ try {
+ IFacetedProject facetedProject = ProjectFacetsManager.create(project);
+ if (facetedProject != null &&
facetedProject.hasProjectFacet(WebFacetUtils.WEB_FACET)) {
+ return new WebModuleResourceLocator();
+ }
+ } catch (CoreException e) {
+ //Ignore
+ }
+ return new ModuleResourceLocator();
+ }
+ return new SimpleJavaResourceLocator();
+ }
+
+ /**
+ * Returns the resource path from Maven's resource folders mapped to theP
+ * runtimePath.
+ */
+ public IPath getResourcePath(IProject project, IPath runtimePath) {
+ IPath resourcePath = null;
+ IMavenProjectFacade mavenProjectFacade = getMavenProjectFacade(project);
+ if (mavenProjectFacade != null && mavenProjectFacade.getMavenProject() !=
null) {
+ List<Resource> resources =
mavenProjectFacade.getMavenProject().getBuild().getResources();
+ for (Resource resourceFolder : resources) {
+ resourcePath = getFilePath(getWorkspaceRelativePath(resourceFolder), runtimePath);
+ if (resourcePath != null) {
+ break;
+ }
+ }
+ } else {
+ // Maven project not loaded yet, we fallback on the JavaProject
+ // source folders lookup
+ IJavaProject javaProject = JavaCore.create(project);
+ try {
+ for (IClasspathEntry entry : javaProject.getRawClasspath()) {
+ if (IClasspathEntry.CPE_SOURCE == entry.getEntryKind()) {
+ resourcePath = getFilePath(entry.getPath(), runtimePath);
+ if (resourcePath != null) {
+ break;
+ }
+ }
+ }
+ } catch (JavaModelException e) {
+ e.printStackTrace();
+ }
+ }
+
+ // System.err.println("getResourcePath (" + project + ", " +
runtimePath
+ // + ") = " + resourcePath);
+ if (resourcePath == null) {
+ resourcePath = getDelegate(project).getResourcePath(project,
+ runtimePath);
+ }
+ return resourcePath;
+ }
+
+ private IPath getFilePath(IPath containerPath, IPath runtimePath) {
+ if (containerPath != null) {
+ final IWorkspaceRoot root = ResourcesPlugin.getWorkspace()
+ .getRoot();
+ IFile resource = root.getFile(containerPath.append(runtimePath));
+ if (resource.exists()) {
+ return resource.getFullPath();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the META-INF folder found in one of Maven's resource.
+ */
+ public IContainer getDefaultResourceLocation(IProject project) {
+ IMavenProjectFacade mavenProjectFacade = getMavenProjectFacade(project);
+ IContainer defaultLocation = null;
+ if (mavenProjectFacade != null && mavenProjectFacade.getMavenProject() != null)
{
+ final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ for (Resource resourceFolder :
mavenProjectFacade.getMavenProject().getBuild().getResources()) {
+ IPath p = getWorkspaceRelativePath(resourceFolder);
+ if (p != null) {
+ IFolder candidate = root.getFolder(p.append(META_INF_PATH));
+ if (candidate.exists()) {
+ return candidate;
+ }
+ if (defaultLocation == null) {
+ defaultLocation = candidate;
+ }
+ }
+ }
+ }
+
+ if (defaultLocation == null) {
+ defaultLocation = getDelegate(project).getDefaultResourceLocation(project);
+ }
+ return defaultLocation;
+ }
+
+ private IPath getWorkspaceRelativePath(Resource mavenResourceFolder) {
+ File resourceDirectory = new File(mavenResourceFolder.getDirectory());
+ IPath relativePath = null;
+ if (resourceDirectory.exists() && resourceDirectory.isDirectory()) {
+ relativePath = getWorkspaceRelativePath(mavenResourceFolder.getDirectory());
+ }
+ return relativePath;
+ }
+
+ private IPath getWorkspaceRelativePath(String absolutePath) {
+ final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IPath relativePath = new Path(absolutePath).makeRelativeTo(root
+ .getLocation());
+ return relativePath;
+ }
+
+ /**
+ * Returns the cached IMavenProjectFacade in m2e's project registry
+ */
+ private IMavenProjectFacade getMavenProjectFacade(IProject project) {
+ return
MavenPlugin.getMavenProjectRegistry().create(project.getFile(IMavenConstants.POM_FILE_NAME),
true, new NullProgressMonitor());
+ }
+
+ public IPath getRuntimePath(IProject project, IPath resourcePath) {
+ IPath runtimePath = getDelegate(project).getRuntimePath(project, resourcePath);
+ System.err.println("getRuntimePath("+resourcePath+") ="+
runtimePath);
+ return runtimePath;
+ }
+}
\ No newline at end of file
Added:
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/PlatformIdentifierManager.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/PlatformIdentifierManager.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.jpa/src/org/jboss/tools/maven/jpa/configurators/PlatformIdentifierManager.java 2012-02-07
10:54:17 UTC (rev 38456)
@@ -0,0 +1,65 @@
+/*************************************************************************************
+ * 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.jpa.configurators;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlProperty;
+
+/**
+ * JPA Platform manager, used to identify a JPA Platform from the content of a
persistence.xml
+ *
+ * @author Fred Bricon
+ */
+public class PlatformIdentifierManager {
+
+ List<IPlatformIdentifier> platformIdentifiers = new
ArrayList<IPlatformIdentifier>();
+
+ public PlatformIdentifierManager() {
+ platformIdentifiers.add(new ReallySimplePlatformIdentifer("hibernate"));
+ platformIdentifiers.add(new ReallySimplePlatformIdentifer("eclipse"));
+ }
+
+ public String identify(XmlPersistenceUnit xmlPersistenceUnit) {
+ String platformId = null;
+ for (IPlatformIdentifier identifier : platformIdentifiers) {
+ platformId = identifier.getPlatformId(xmlPersistenceUnit);
+ if (platformId != null) {
+ return platformId;
+ }
+ }
+ return null;
+ }
+
+ private class ReallySimplePlatformIdentifer extends AbstractPlatformIdentifier {
+
+ private final String platformName;
+
+ ReallySimplePlatformIdentifer(String platformName) {
+ this.platformName = platformName;
+ }
+
+ @Override
+ protected String identifyProvider(String provider) {
+ if (provider != null && provider.contains(platformName)) {
+ return platformName;
+ }
+ return null;
+ }
+
+ @Override
+ protected String identifyProperty(XmlProperty property) {
+ return identifyProvider(property.getName());
+ }
+ }
+}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/Activator.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/Activator.java 2012-02-07
10:08:37 UTC (rev 38455)
+++
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/Activator.java 2012-02-07
10:54:17 UTC (rev 38456)
@@ -82,6 +82,11 @@
public static final String CONFIGURE_JAXRS = "configureJAX-RS"; //$NON-NLS-1$
public static final boolean CONFIGURE_JAXRS_VALUE = true;
+
+ public static final String CONFIGURE_JPA = "configureJPA"; //$NON-NLS-1$
+
+ public static final boolean CONFIGURE_JPA_VALUE = true;
+
// The shared instance
private static Activator plugin;
Modified:
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/Messages.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/Messages.java 2012-02-07
10:08:37 UTC (rev 38455)
+++
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/Messages.java 2012-02-07
10:54:17 UTC (rev 38456)
@@ -48,6 +48,7 @@
public static String ConfiguratorPreferencePage_Configure_JBoss_JSF_Portlet_facet;
public static String ConfiguratorPreferencePage_Configure_JBoss_Portlet_Core_facet;
public static String ConfiguratorPreferencePage_Configure_JBoss_Seam_Portlet_facet;
+ public static String ConfiguratorPreferencePage_Configure_JPA_facet;
public static String ConfiguratorPreferencePage_Configure_JSF_facet;
public static String ConfiguratorPreferencePage_Configure_CDI_facet;
public static String ConfiguratorPreferencePage_Configure_Hibernate;
Modified:
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/messages.properties
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/messages.properties 2012-02-07
10:08:37 UTC (rev 38455)
+++
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/messages.properties 2012-02-07
10:54:17 UTC (rev 38456)
@@ -23,6 +23,7 @@
MavenUserLibraryProviderInstallPanel_Type=Type
MavenUserLibraryProviderInstallPanel_Version=Version
ConfiguratorPreferencePage_Configure_JAX_RS_facet=JAX-RS facet
+ConfiguratorPreferencePage_Configure_JPA_facet=JPA facet
ConfiguratorPreferencePage_Configure_JBoss_JSF_Portlet_facet=JBoss JSF Portlet facet
ConfiguratorPreferencePage_Configure_JBoss_Portlet_Core_facet=JBoss Portlet Core facet
ConfiguratorPreferencePage_Configure_JBoss_Seam_Portlet_facet=JBoss Seam Portlet facet
Modified:
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/preferences/ConfiguratorPreferencePage.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/preferences/ConfiguratorPreferencePage.java 2012-02-07
10:08:37 UTC (rev 38455)
+++
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/preferences/ConfiguratorPreferencePage.java 2012-02-07
10:54:17 UTC (rev 38456)
@@ -42,6 +42,7 @@
private static final String ORG_JBOSS_TOOLS_MAVEN_HIBERNATE =
"org.jboss.tools.maven.hibernate"; //$NON-NLS-1$
private static final String ORG_JBOSS_TOOLS_MAVEN_SEAM =
"org.jboss.tools.maven.seam"; //$NON-NLS-1$
private static final String ORG_JBOSS_TOOLS_MAVEN_JAXRS =
"org.jboss.tools.maven.jaxrs"; //$NON-NLS-1$
+ private static final String ORG_JBOSS_TOOLS_MAVEN_JPA =
"org.jboss.tools.maven.jpa"; //$NON-NLS-1$
private Button configureSeamButton;
private Button configureSeamRuntimeButton;
@@ -54,7 +55,8 @@
private Button configureCDIButton;
private Button configureHibernateButton;
private Button configureJaxRsButton;
-
+ private Button configureJpaButton;
+
@Override
protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
@@ -147,6 +149,13 @@
configureJaxRsButton.setSelection(configureJaxRs);
}
+ if (bundleExists(ORG_JBOSS_TOOLS_MAVEN_JPA)) {
+ configureJpaButton = new Button(composite,SWT.CHECK);
+ configureJpaButton.setText(Messages.ConfiguratorPreferencePage_Configure_JPA_facet);
+ boolean configureJpa = store.getBoolean(Activator.CONFIGURE_JPA);
+ configureJpaButton.setSelection(configureJpa);
+ }
+
return composite;
}
@@ -219,6 +228,10 @@
if (bundleExists(ORG_JBOSS_TOOLS_MAVEN_JAXRS)) {
store.setValue(Activator.CONFIGURE_JAXRS, Activator.CONFIGURE_JAXRS_VALUE);
}
+
+ if (bundleExists(ORG_JBOSS_TOOLS_MAVEN_JPA)) {
+ store.setValue(Activator.CONFIGURE_JPA, Activator.CONFIGURE_JPA_VALUE);
+ }
super.performDefaults();
}
@@ -255,6 +268,10 @@
store.setValue(Activator.CONFIGURE_JAXRS, configureJaxRsButton.getSelection());
}
+ if (bundleExists(ORG_JBOSS_TOOLS_MAVEN_JPA)) {
+ store.setValue(Activator.CONFIGURE_JPA, configureJpaButton.getSelection());
+ }
+
return super.performOk();
}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/preferences/ConfiguratorPreferencesInitializer.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/preferences/ConfiguratorPreferencesInitializer.java 2012-02-07
10:08:37 UTC (rev 38455)
+++
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/preferences/ConfiguratorPreferencesInitializer.java 2012-02-07
10:54:17 UTC (rev 38456)
@@ -60,6 +60,9 @@
node.putBoolean(
Activator.CONFIGURE_JAXRS,
Activator.CONFIGURE_JAXRS_VALUE);
+ node.putBoolean(
+ Activator.CONFIGURE_JPA,
+ Activator.CONFIGURE_JPA_VALUE);
}
}
Modified: trunk/maven/plugins/pom.xml
===================================================================
--- trunk/maven/plugins/pom.xml 2012-02-07 10:08:37 UTC (rev 38455)
+++ trunk/maven/plugins/pom.xml 2012-02-07 10:54:17 UTC (rev 38456)
@@ -23,6 +23,7 @@
<module>org.jboss.tools.maven.project.examples</module>
<module>org.jboss.tools.maven.jaxrs</module>
<module>org.jboss.tools.maven.jbosspackaging</module>
+ <module>org.jboss.tools.maven.jpa</module>
</modules>
</project>