You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2014/06/02 13:07:11 UTC
svn commit: r1599164 [2/3] - in /tomee/deps/tags/openjpa-2.4.0-1598334: ./
openjpa-tools/ openjpa-tools/openjpa-maven-plugin/
openjpa-tools/openjpa-maven-plugin/src/
openjpa-tools/openjpa-maven-plugin/src/it/
openjpa-tools/openjpa-maven-plugin/src/it/d...
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/main/java/org/apache/openjpa/tools/maven/testentity/TestEntity.java
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/main/java/org/apache/openjpa/tools/maven/testentity/TestEntity.java?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/main/java/org/apache/openjpa/tools/maven/testentity/TestEntity.java (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/main/java/org/apache/openjpa/tools/maven/testentity/TestEntity.java Mon Jun 2 11:07:07 2014
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.tools.maven.testentity;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+
+@Entity
+public class TestEntity {
+
+ @Id
+ private int xint1;
+
+ private String string1;
+
+ protected TestEntity() {
+ }
+
+ public TestEntity(int int1, String string1) {
+ this.xint1 = int1;
+ this.string1 = string1;
+ }
+
+ public int getInt1() {
+ return xint1;
+ }
+
+ public void setInt1(int int1) {
+ this.xint1 = int1;
+ }
+
+ public String getString1() {
+ return string1;
+ }
+
+ public void setString1(String string1) {
+ this.string1 = string1;
+ }
+
+ public String toString() {
+ return xint1 + ":" + string1;
+ }
+
+}
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/main/resources/META-INF/anotherPersistence.xml
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/main/resources/META-INF/anotherPersistence.xml?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/main/resources/META-INF/anotherPersistence.xml (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/main/resources/META-INF/anotherPersistence.xml Mon Jun 2 11:07:07 2014
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+
+ <!-- simply all annotated persistent entities will be part of this unit-->
+ <persistence-unit name="TestUnit">
+
+ <properties>
+ <property name="openjpa.jdbc.DBDictionary" value="hsql" />
+ <property name="openjpa.ConnectionDriverName" value="org.hsqldb.jdbcDriver" />
+ <property name="openjpa.ConnectionURL" value="jdbc:hsqldb:mem:test" />
+ <property name="openjpa.ConnectionUserName" value="sa" />
+ <property name="openjpa.ConnectionPassword" value="" />
+
+ </properties>
+
+ </persistence-unit>
+
+</persistence>
+
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/main/resources/log4j.properties
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/main/resources/log4j.properties?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/main/resources/log4j.properties (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/main/resources/log4j.properties Mon Jun 2 11:07:07 2014
@@ -0,0 +1,27 @@
+################################################################################
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+################################################################################
+
+# Root logger
+log4j.rootLogger=DEBUG, stdout
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
+
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/test/java/org/apache/openjpa/tools/maven/test/ItNonDefaultXmlTest.java
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/test/java/org/apache/openjpa/tools/maven/test/ItNonDefaultXmlTest.java?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/test/java/org/apache/openjpa/tools/maven/test/ItNonDefaultXmlTest.java (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/test/java/org/apache/openjpa/tools/maven/test/ItNonDefaultXmlTest.java Mon Jun 2 11:07:07 2014
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.tools.maven.test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.enhance.PersistenceCapable;
+
+import junit.framework.TestCase;
+
+public class ItNonDefaultXmlTest extends TestCase {
+
+ /** contains the directory where all generated results are placed */
+ private final static String TARGET_DIR = "target";
+
+ /** the file containing the generated SQL syntax */
+ private final static String SQL_FILE = "database.sql";
+
+ /** if the SQL generation has been successful, the following result should be in the SQL file */
+ private final static String VALID_SQL = "CREATE TABLE TestEntity (xint1 INTEGER NOT NULL, string1 VARCHAR(255), PRIMARY KEY (xint1));";
+
+ private final static String TEST_ENTITY_CLASS = "org.apache.openjpa.tools.maven.testentity.TestEntity";
+
+ /** the file containing the generated schema XML */
+ private final static String SCHEMA_FILE = "schema.xml";
+
+ /** the name of the schema XML file which should be taken as test reference */
+ private final static String REFERENCE_SCHEMA_XML = "reference_schema.orig_xml";
+
+
+ /**
+ * check if the generated classes have been enhanced.
+ * @throws Exception
+ */
+ public void testEnhancement() throws Exception
+ {
+ Class tec = Thread.currentThread().getContextClassLoader().loadClass( TEST_ENTITY_CLASS );
+
+ boolean isPersistenceCapable = false;
+ Class[] interfaces = tec.getInterfaces();
+ for ( int i = 0; i < interfaces.length; i++ )
+ {
+ if ( interfaces[ i ].getName().equals( PersistenceCapable.class.getName() ) )
+ {
+ isPersistenceCapable = true;
+ break;
+ }
+ }
+
+ assertTrue( "the class " + TEST_ENTITY_CLASS + " does not implement PersistenceCapable!", isPersistenceCapable );
+ }
+
+ /**
+ * check if the generated SQL script is correct.
+ * @throws Exception
+ */
+ public void testSqlGeneration() throws Exception
+ {
+ File sqlFile = new File( TARGET_DIR, SQL_FILE );
+ BufferedReader in = new BufferedReader( new FileReader( sqlFile ) );
+ String sqlIn = in.readLine();
+ assertEquals( VALID_SQL, sqlIn );
+ }
+
+ /**
+ * check if the generated schema.xml is correct.
+ * @throws Exception
+ */
+ public void testSchemaGeneration() throws Exception
+ {
+ File sqlFile = new File( TARGET_DIR, SCHEMA_FILE );
+ BufferedReader schemaGen = new BufferedReader( new FileReader( sqlFile ) );
+
+ InputStream schemaRefIs = Thread.currentThread().getContextClassLoader().getResourceAsStream( REFERENCE_SCHEMA_XML );
+
+ BufferedReader schemaRef = new BufferedReader( new InputStreamReader( schemaRefIs ) );
+
+ String refLine;
+ while ( (refLine = schemaRef.readLine()) != null)
+ {
+ String genLine = schemaGen.readLine();
+ assertEquals("generated schema.xml differs from expected one!", refLine, genLine );
+ }
+ }
+
+
+}
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/test/resources/reference_schema.orig_xml
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/test/resources/reference_schema.orig_xml?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/test/resources/reference_schema.orig_xml (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/test/resources/reference_schema.orig_xml Mon Jun 2 11:07:07 2014
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemas>
+ <schema>
+ <table name="TestEntity">
+ <pk column="xint1"/>
+ <column name="xint1" type="integer" not-null="true"/>
+ <column name="string1" type="varchar" size="255"/>
+ </table>
+ </schema>
+</schemas>
\ No newline at end of file
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/settings.xml
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/settings.xml?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/settings.xml (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/settings.xml Mon Jun 2 11:07:07 2014
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the
+ NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF
+ licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ either express or implied. See the License for the specific language governing permissions and limitations under
+ the License.
+ -->
+
+<settings>
+ <profiles>
+ <profile>
+ <id>it-repo</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <repositories>
+ <repository>
+ <id>local.central</id>
+ <url>file:///@localRepository@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>local.central</id>
+ <url>file:///@localRepository@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <properties>
+ <hsqldb.version>1.8.0.10</hsqldb.version>
+ </properties>
+ </profile>
+ </profiles>
+</settings>
\ No newline at end of file
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/pom.xml
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/pom.xml?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/pom.xml (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/pom.xml Mon Jun 2 11:07:07 2014
@@ -0,0 +1,69 @@
+<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/maven-v4_0_0.xsd">
+
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the
+ NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF
+ licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ either express or implied. See the License for the specific language governing permissions and limitations under
+ the License.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.openejb.patch</groupId>
+ <artifactId>openjpa-tools</artifactId>
+ <version>@pom.version@</version>
+ </parent>
+
+ <groupId>org.apache.openejb.patch.tools.openjpa-maven-plugin.testing</groupId>
+ <artifactId>testDependencies</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <description>
+ This IT tests if JPA classes (in our case an Enum) in a depending artifact can properly
+ be used by the test case of another artifact.
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_2.0_spec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-validation_1.0_spec</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <modules>
+ <module>prjA</module>
+ <module>prjB</module>
+ </modules>
+</project>
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjA/pom.xml
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjA/pom.xml?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjA/pom.xml (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjA/pom.xml Mon Jun 2 11:07:07 2014
@@ -0,0 +1,49 @@
+<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/maven-v4_0_0.xsd">
+
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the
+ NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF
+ licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ either express or implied. See the License for the specific language governing permissions and limitations under
+ the License.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.openejb.patch.tools.openjpa-maven-plugin.testing</groupId>
+ <artifactId>testDependency-A</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <description>
+ This module defines a few Interfaces which includes Enums.
+ This makes problems with the PCEnhancer of OpenJPA-1.2.1 if they are not on the
+ classpath.
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjA/src/main/java/org/apache/openjpa/tools/maven/test/it/dependingartifact/MyEntityInterface.java
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjA/src/main/java/org/apache/openjpa/tools/maven/test/it/dependingartifact/MyEntityInterface.java?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjA/src/main/java/org/apache/openjpa/tools/maven/test/it/dependingartifact/MyEntityInterface.java (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjA/src/main/java/org/apache/openjpa/tools/maven/test/it/dependingartifact/MyEntityInterface.java Mon Jun 2 11:07:07 2014
@@ -0,0 +1,38 @@
+package org.apache.openjpa.tools.maven.test.it.dependingartifact;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+/**
+ * Sample interface which contains an enum
+ */
+public interface MyEntityInterface
+{
+
+ public static enum MessageChannel
+ {
+ /** short message */
+ SMS,
+ /** multimedia message */
+ MMS
+ }
+
+ public MessageChannel getMessageChannel();
+ public void setMessageChannel( MessageChannel messageChannel );
+}
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/pom.xml
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/pom.xml?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/pom.xml (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/pom.xml Mon Jun 2 11:07:07 2014
@@ -0,0 +1,89 @@
+<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/maven-v4_0_0.xsd">
+
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the
+ NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF
+ licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ either express or implied. See the License for the specific language governing permissions and limitations under
+ the License.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.openejb.patch.tools.openjpa-maven-plugin.testing</groupId>
+ <artifactId>testDependency-B</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <description>
+ This IT tests if JPA classes (in our case an Enum) in a depending artifact can properly
+ be used by test classes of another artifact.
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openejb.patch</groupId>
+ <artifactId>openjpa-kernel</artifactId>
+ <version>@pom.version@</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb.patch</groupId>
+ <artifactId>openjpa-jdbc</artifactId>
+ <version>@pom.version@</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb.patch</groupId>
+ <artifactId>openjpa-persistence</artifactId>
+ <version>@pom.version@</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openejb.patch.tools.openjpa-maven-plugin.testing</groupId>
+ <artifactId>testDependency-A</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>${hsqldb.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.openejb.patch</groupId>
+ <artifactId>openjpa-maven-plugin</artifactId>
+ <version>@pom.version@</version>
+ <executions>
+ <execution>
+ <id>mappingtool</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>test-enhance</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/src/test/java/org/apache/openjpa/tools/maven/test/it/dependingartifact/entities/MyEntityImpl.java
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/src/test/java/org/apache/openjpa/tools/maven/test/it/dependingartifact/entities/MyEntityImpl.java?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/src/test/java/org/apache/openjpa/tools/maven/test/it/dependingartifact/entities/MyEntityImpl.java (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/src/test/java/org/apache/openjpa/tools/maven/test/it/dependingartifact/entities/MyEntityImpl.java Mon Jun 2 11:07:07 2014
@@ -0,0 +1,62 @@
+package org.apache.openjpa.tools.maven.test.it.dependingartifact.entities;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.apache.openjpa.tools.maven.test.it.dependingartifact.MyEntityInterface;
+
+/**
+ * This class implements an interface and references to an enum of that interface.
+ * This causes the PCEnhancer of OpenJPA-1.2.1 to demand the interface on
+ * the classpath.
+ */
+@Entity
+public class MyEntityImpl implements MyEntityInterface {
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ private MessageChannel messageChannel;
+
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId( int id ) {
+ this.id = id;
+ }
+
+ public MessageChannel getMessageChannel()
+ {
+ return messageChannel;
+ }
+
+ public void setMessageChannel( MessageChannel messageChannel )
+ {
+ this.messageChannel = messageChannel;
+ }
+
+}
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/src/test/resources/META-INF/persistence.xml?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/src/test/resources/META-INF/persistence.xml (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/src/test/resources/META-INF/persistence.xml Mon Jun 2 11:07:07 2014
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the
+ NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF
+ licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file
+ except in compliance with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ either express or implied. See the License for the specific language governing permissions and limitations under
+ the License.
+ -->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+
+ <!-- simply all annotated persistent entities will be part of this unit-->
+ <persistence-unit name="TestUnit">
+
+ <properties>
+ <property name="openjpa.jdbc.DBDictionary" value="hsql" />
+ <property name="openjpa.ConnectionDriverName" value="org.hsqldb.jdbcDriver" />
+ <property name="openjpa.ConnectionURL" value="jdbc:hsqldb:mem:test" />
+ <property name="openjpa.ConnectionUserName" value="sa" />
+ <property name="openjpa.ConnectionPassword" value="" />
+
+ </properties>
+
+ </persistence-unit>
+
+</persistence>
+
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaEnhancerMojo.java
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaEnhancerMojo.java?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaEnhancerMojo.java (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaEnhancerMojo.java Mon Jun 2 11:07:07 2014
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.tools.maven;
+
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.codehaus.plexus.util.FileUtils;
+
+import org.apache.openjpa.enhance.PCEnhancer;
+import org.apache.openjpa.lib.util.Options;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * The base class for all enhancement mojos.
+ * @version $Id: AbstractOpenJpaTestEnhancerMojo.java 9137 2009-02-28 21:55:03Z struberg $
+ * @since 1.1
+ */
+public abstract class AbstractOpenJpaEnhancerMojo extends AbstractOpenJpaMojo {
+
+ /**
+ * The JPA spec requires that all persistent classes define a no-arg constructor.
+ * This flag tells the enhancer whether to add a protected no-arg constructor
+ * to any persistent classes that don't already have one.
+ *
+ * @parameter default-value="true"
+ */
+ protected boolean addDefaultConstructor;
+ /**
+ * used for passing the addDefaultConstructor parameter to the enhnacer tool
+ */
+ private static final String OPTION_ADD_DEFAULT_CONSTRUCTOR = "addDefaultConstructor";
+
+ /**
+ * Whether to throw an exception when it appears that a property access entity
+ * is not obeying the restrictions placed on property access.
+ *
+ * @parameter default-value="false"
+ */
+ protected boolean enforcePropertyRestrictions;
+ /**
+ * used for passing the enforcePropertyRestrictions parameter to the enhnacer tool
+ */
+ private static final String OPTION_ENFORCE_PROPERTY_RESTRICTION = "enforcePropertyRestrictions";
+
+ /**
+ * Tell the PCEnhancer to use a temporary classloader for enhancement.
+ * If you enable this feature, then no depending artifacts from the classpath will be used!
+ * Please note that you have to disable the tmpClassLoader for some cases in OpenJPA-1.2.1
+ * due to an extended parsing strategy.
+ *
+ * @parameter default-value="false"
+ */
+ protected boolean tmpClassLoader;
+ /**
+ * used for passing the tmpClassLoader parameter to the enhnacer tool
+ */
+ private static final String OPTION_USE_TEMP_CLASSLOADER = "tcl";
+
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.apache.maven.plugin.Mojo#execute()
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ if (skipMojo()) {
+ return;
+ }
+
+ if (!getEntityClasses().exists()) {
+ FileUtils.mkdir(getEntityClasses().getAbsolutePath());
+ }
+
+ List<File> entities = findEntityClassFiles();
+
+ enhance(entities);
+ }
+
+ /**
+ * Get the options for the OpenJPA enhancer tool.
+ *
+ * @return populated Options
+ */
+ protected Options getOptions() throws MojoExecutionException {
+ // options
+ Options opts = createOptions();
+
+ // put the standard options into the list also
+ opts.put(OPTION_ADD_DEFAULT_CONSTRUCTOR, Boolean.toString(addDefaultConstructor));
+ opts.put(OPTION_ENFORCE_PROPERTY_RESTRICTION, Boolean.toString(enforcePropertyRestrictions));
+ opts.put(OPTION_USE_TEMP_CLASSLOADER, Boolean.toString(tmpClassLoader));
+
+ return opts;
+ }
+
+ /**
+ * Processes a list of class file resources that are to be enhanced.
+ *
+ * @param files class file resources to enhance.
+ * @throws MojoExecutionException if the enhancer encountered a failure
+ */
+ private void enhance(List<File> files) throws MojoExecutionException {
+ Options opts = getOptions();
+
+ // list of input files
+ String[] args = getFilePaths(files);
+
+ boolean ok = false;
+
+ if (!tmpClassLoader) {
+ extendRealmClasspath();
+ }
+
+ ok = PCEnhancer.run(args, opts);
+
+ if (!ok) {
+ throw new MojoExecutionException("The OpenJPA Enhancer tool detected an error!");
+ }
+ }
+
+}
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMappingToolMojo.java
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMappingToolMojo.java?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMappingToolMojo.java (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMappingToolMojo.java Mon Jun 2 11:07:07 2014
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.tools.maven;
+
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.persistence.Entity;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.openjpa.enhance.PersistenceCapable;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl;
+import org.apache.openjpa.jdbc.meta.MappingTool;
+import org.apache.openjpa.lib.conf.Configurations;
+import org.apache.openjpa.lib.meta.ClassArgParser;
+import org.apache.openjpa.lib.util.Options;
+import org.apache.openjpa.meta.MetaDataRepository;
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * Processes Application model classes and generate the DDL by running the
+ * OpenJPA MappingTool.
+ *
+ * We have to split the generation of the SQL files and the mapping info
+ * into 2 separate mojos, since the MappingTool struggles to generate both
+ * in one step.
+ *
+ * @version $Id$
+ * @since 1.0
+ */
+public abstract class AbstractOpenJpaMappingToolMojo extends AbstractOpenJpaMojo {
+ /**
+ * Argument to specify the action to take on each class. The available actions are:
+ * buildSchema, validate
+ *
+ * @parameter
+ */
+ protected String action;
+ /**
+ * used for passing the action parameter to the mapping tool
+ */
+ protected static final String OPTION_ACTION = "action";
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.apache.maven.plugin.Mojo#execute()
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ if (skipMojo()) {
+ return;
+ }
+
+ if (!getEntityClasses().exists()) {
+ FileUtils.mkdir(getEntityClasses().getAbsolutePath());
+ }
+
+ List<File> entities = findEntityClassFiles();
+
+ mappingTool(entities);
+ }
+
+ /**
+ * Processes a list of class file resources and perform the proper
+ * mapping action.
+ *
+ * @param files class file resources to map.
+ * @throws MojoExecutionException if the MappingTool detected an error
+ */
+ private void mappingTool(List<File> files) throws MojoExecutionException {
+ extendRealmClasspath();
+
+ Options opts = getOptions();
+
+ filterPersistenceCapable(files, opts);
+
+ // list of input files
+ final String[] args = getFilePaths(files);
+
+ boolean ok = Configurations.runAgainstAllAnchors(opts,
+ new Configurations.Runnable() {
+ public boolean run(Options opts) throws IOException, SQLException {
+ JDBCConfiguration conf = new JDBCConfigurationImpl();
+ try {
+ return MappingTool.run(conf, args, opts);
+ } finally {
+ conf.close();
+ }
+ }
+ }
+ );
+
+ if (!ok) {
+ throw new MojoExecutionException("The OpenJPA MappingTool detected an error!");
+ }
+
+ }
+
+ /**
+ * Filter out all classes which are not PersistenceCapable.
+ * This is needed since the MappingTool fails if it gets non-persistent capable classes.
+ *
+ * @param files List with classPath Files; non persistence classes will be removed
+ * @param opts filled configuration Options
+ */
+ private void filterPersistenceCapable(List<File> files, Options opts) {
+ JDBCConfiguration conf = new JDBCConfigurationImpl();
+ Configurations.populateConfiguration(conf, opts);
+ MetaDataRepository repo = conf.newMetaDataRepositoryInstance();
+ ClassArgParser cap = repo.getMetaDataFactory().newClassArgParser();
+
+ Iterator<File> fileIt = files.iterator();
+ while (fileIt.hasNext()) {
+ File classPath = fileIt.next();
+
+ Class[] classes = cap.parseTypes(classPath.getAbsolutePath());
+
+ if (classes == null) {
+ getLog().info("Found no classes for " + classPath.getAbsolutePath());
+ } else {
+ for (int i = 0; i < classes.length; i++) {
+ Class<?> cls = classes[i];
+
+ if (cls.getAnnotation(Entity.class) != null) {
+ getLog().debug("Found @Entity in class " + classPath);
+ } else if (implementsPersistenceCapable(cls)) {
+ getLog().debug("Found class " + classPath + " that implements interface "
+ + PersistenceCapable.class.getName());
+ } else {
+ getLog().debug("Removing non-entity class " + classPath);
+ fileIt.remove();
+ }
+ }
+ }
+ }
+ }
+
+
+ /**
+ * @param cls the Class to check
+ * @return <code>true</code> if the given Class cls implements the interface {@link PersistenceCapable}
+ */
+ private boolean implementsPersistenceCapable(Class<?> cls) {
+ boolean isPersistenceCapable = false;
+ Class<?>[] interfaces = cls.getInterfaces();
+ for (int i = 0; i < interfaces.length; i++) {
+ if (interfaces[i].getName().equals(PersistenceCapable.class.getName())) {
+ isPersistenceCapable = true;
+ break;
+ }
+ }
+
+ return isPersistenceCapable;
+ }
+
+}
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMojo.java
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMojo.java?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMojo.java (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMojo.java Mon Jun 2 11:07:07 2014
@@ -0,0 +1,430 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.tools.maven;
+
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.openjpa.lib.util.Options;
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * Base class for OpenJPA maven tasks.
+ *
+ * @version $Id$
+ */
+public abstract class AbstractOpenJpaMojo extends AbstractMojo
+{
+ /**
+ * The working directory for putting persistence.xml and
+ * other stuff into if we need to.
+ *
+ *
+ * @parameter expression="${openjpa.workdir}"
+ * default-value="${project.build.directory}/openjpa-work"
+ * @required
+ */
+ protected File workDir;
+
+ /**
+ * Location where <code>persistence-enabled</code> classes are located.
+ *
+ * @parameter expression="${openjpa.classes}"
+ * default-value="${project.build.outputDirectory}"
+ * @required
+ */
+ protected File classes;
+
+ /**
+ * Comma separated list of includes to scan searchDir to pass to the jobs.
+ * This may be used to restrict the OpenJPA tasks to e.g. a single package which
+ * contains all the entities.
+ *
+ * @parameter default-value="**\/*.class"
+ */
+ private String includes;
+
+ /**
+ * Comma separated list of excludes to scan searchDir to pass to the jobs.
+ * This option may be used to stop OpenJPA tasks from scanning non-JPA classes
+ * (which usually leads to warnings such as "Type xxx has no metadata")
+ *
+ * @parameter default-value="";
+ */
+ private String excludes;
+
+ /**
+ * Additional properties passed to the OpenJPA tools.
+ *
+ * @parameter
+ */
+ private Properties toolProperties;
+
+ /**
+ * Used if a non-default file location for the persistence.xml should be used
+ * If not specified, the default one in META-INF/persistence.xml will be used.
+ * Since openjpa-2.3.0 this can also be a resource location. In prior releases
+ * it was only possible to specify a file location.
+ *
+ * @parameter
+ */
+ private String persistenceXmlFile;
+
+ /**
+ * <p>This setting can be used to override any openjpa.ConnectionDriverName set in the
+ * persistence.xml. It can also be used if the persistence.xml contains no connection
+ * information at all.<P>
+ *
+ * Sample:
+ * <pre>
+ * <connectionDriverName>com.mchange.v2.c3p0.ComboPooledDataSource</connectionDriverName>
+ * </pre>
+ *
+ * This is most times used in conjunction with {@link #connectionProperties}.
+ *
+ * @parameter
+ */
+ private String connectionDriverName;
+
+ /** the string used for passing information about the connectionDriverName */
+ protected static final String OPTION_CONNECTION_DRIVER_NAME = "ConnectionDriverName";
+
+ /**
+ * <p>Used to define the credentials or any other connection properties.</p>
+ *
+ * Sample:
+ * <pre>
+ * <connectionProperties>
+ * driverClass=com.mysql.jdbc.Driver,
+ * jdbcUrl=jdbc:mysql://localhost/mydatabase,
+ * user=root,
+ * password=,
+ * minPoolSize=5,
+ * acquireRetryAttempts=3,
+ * maxPoolSize=20
+ * </connectionProperties>
+ * </pre>
+ *
+ * This is most times used in conjunction with {@link #connectionDriverName}.
+ *
+ * @parameter
+ */
+ private String connectionProperties;
+
+ /** the string used for passing information about the connectionProperties */
+ protected static final String OPTION_CONNECTION_PROPERTIES = "ConnectionProperties";
+
+
+ /**
+ * List of all class path elements that will be searched for the
+ * <code>persistence-enabled</code> classes and resources expected by
+ * PCEnhancer.
+ *
+ * @parameter default-value="${project.compileClasspathElements}"
+ * @required
+ * @readonly
+ */
+ protected List<String> compileClasspathElements;
+
+ /**
+ * Setting this parameter to <code>true</code> will force
+ * the execution of this mojo, even if it would get skipped usually.
+ *
+ * @parameter expression="${forceOpenJpaExecution}"
+ * default-value=false
+ * @required
+ */
+ private boolean forceMojoExecution;
+
+ /**
+ * The Maven Project Object
+ *
+ * @parameter default-value="${project}"
+ * @required
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /** the properties option is used for passing information about the persistence.xml file location */
+ protected static final String OPTION_PROPERTIES_FILE = "propertiesFile";
+
+ /**
+ * The properties option is used for passing information about the persistence.xml
+ * classpath resource and the default unit
+ */
+ protected static final String OPTION_PROPERTIES = "properties";
+
+ /**
+ * When <code>true</code>, skip the execution.
+ * @since 1.0
+ * @parameter default-value="false"
+ */
+ private boolean skip;
+
+ /**
+ * default ct
+ */
+ public AbstractOpenJpaMojo()
+ {
+ super();
+ }
+
+ /**
+ * The File where the class files of the entities to enhance reside
+ * @return normaly the entity classes are located in target/classes
+ */
+ protected File getEntityClasses()
+ {
+ return classes;
+ }
+
+ /**
+ * This function retrieves the injected classpath elements for the current mojo.
+ * @return List of classpath elements for the compile phase
+ */
+ protected List<String> getClasspathElements()
+ {
+ return compileClasspathElements;
+ }
+
+ /**
+ * Get the options for the various OpenJPA tools.
+ * @return populated Options
+ */
+ protected abstract Options getOptions() throws MojoExecutionException;
+
+ /**
+ * <p>Determine if the mojo execution should get skipped.</p>
+ * This is the case if:
+ * <ul>
+ * <li>{@link #skip} is <code>true</code></li>
+ * <li>if the mojo gets executed on a project with packaging type 'pom' and
+ * {@link #forceMojoExecution} is <code>false</code></li>
+ * </ul>
+ *
+ * @return <code>true</code> if the mojo execution should be skipped.
+ */
+ protected boolean skipMojo()
+ {
+ if ( skip )
+ {
+ getLog().info( "Skip sql execution" );
+ return true;
+ }
+
+ if ( !forceMojoExecution && project != null && "pom".equals( project.getPackaging() ) )
+ {
+ getLog().info( "Skipping sql execution for project with packaging type 'pom'" );
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * This function will usually get called by {@link #getOptions()}
+ * @return the Options filled with the initial values
+ */
+ protected Options createOptions() throws MojoExecutionException
+ {
+ Options opts = new Options();
+ if ( toolProperties != null )
+ {
+ opts.putAll( toolProperties );
+ }
+
+ if ( persistenceXmlFile != null )
+ {
+ fixPersistenceXmlIfNeeded(Thread.currentThread().getContextClassLoader());
+ opts.put( OPTION_PROPERTIES_FILE, persistenceXmlFile );
+ getLog().debug("using special persistence XML file: " + persistenceXmlFile);
+ }
+ else if (!new File(classes, "META-INF/persistence.xml").exists())
+ { // use default but try from classpath
+ persistenceXmlFile = "META-INF/persistence.xml";
+ if (!fixPersistenceXmlIfNeeded(Thread.currentThread().getContextClassLoader())) {
+ persistenceXmlFile = null;
+ } else {
+ opts.put( OPTION_PROPERTIES_FILE, persistenceXmlFile );
+ }
+ }
+
+ if ( connectionDriverName != null )
+ {
+ opts.put( OPTION_CONNECTION_DRIVER_NAME, connectionDriverName );
+ }
+
+ if ( connectionProperties != null )
+ {
+ opts.put( OPTION_CONNECTION_PROPERTIES, connectionProperties );
+ }
+
+ return opts;
+ }
+
+ /**
+ *
+ *
+ * @param loader
+ * @return
+ * @throws MojoExecutionException
+ */
+ private boolean fixPersistenceXmlIfNeeded(final ClassLoader loader) throws MojoExecutionException
+ {
+ return !new File(persistenceXmlFile).exists() &&
+ (findPersistenceXmlFromLoader(loader)
+ || findPersistenceXmlInArtifacts(project.getCompileArtifacts())
+ || findPersistenceXmlInArtifacts(project.getRuntimeArtifacts()));
+ }
+
+ private boolean findPersistenceXmlFromLoader(final ClassLoader loader) throws MojoExecutionException {
+ final URL url = loader.getResource(persistenceXmlFile);
+ if (url != null) // copy file to be sure to set persistenceXmlFile to a file
+ {
+ final File tmpPersistenceXml = new File(workDir,
+ "persistence" + System.currentTimeMillis() + ".xml");
+ if (!tmpPersistenceXml.getParentFile().exists() && !tmpPersistenceXml.getParentFile().mkdirs())
+ {
+ throw new MojoExecutionException("Can't create "
+ + tmpPersistenceXml.getParentFile().getAbsolutePath());
+ }
+
+ try
+ {
+ FileUtils.copyURLToFile(url, tmpPersistenceXml);
+ }
+ catch (final IOException e)
+ {
+ throw new MojoExecutionException(e.getMessage(), e);
+ }
+
+ persistenceXmlFile = tmpPersistenceXml.getAbsolutePath();
+ return true;
+ }
+ return false;
+ }
+
+ private boolean findPersistenceXmlInArtifacts(final List<Artifact> artifacts) throws MojoExecutionException {
+ for (final Artifact artifact : artifacts) {
+ final File file = artifact.getFile();
+ if (file != null && file.exists())
+ {
+ try // find the persistence.xml using a fake classloader to not need to play with URLs
+ {
+ if (findPersistenceXmlFromLoader(new URLClassLoader(new URL[] { file.toURI().toURL() },
+ ClassLoader.getSystemClassLoader())))
+ {
+ return true;
+ }
+ }
+ catch (final MalformedURLException e)
+ {
+ // no-op
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * This will prepare the current ClassLoader and add all jars and local
+ * classpaths (e.g. target/classes) needed by the OpenJPA task.
+ *
+ * @throws MojoExecutionException on any error inside the mojo
+ */
+ protected void extendRealmClasspath()
+ throws MojoExecutionException
+ {
+ List<URL> urls = new ArrayList<URL>();
+
+ for(String fileName: getClasspathElements()) {
+ File pathElem = new File(fileName);
+ try
+ {
+ URL url = pathElem.toURI().toURL();
+ urls.add( url );
+ getLog().debug( "Added classpathElement URL " + url );
+ }
+ catch ( MalformedURLException e )
+ {
+ throw new MojoExecutionException( "Error in adding the classpath " + pathElem, e );
+ }
+ }
+
+ ClassLoader jpaRealm =
+ new URLClassLoader( (URL[]) urls.toArray( new URL[urls.size()] ), getClass().getClassLoader() );
+
+ // set the new ClassLoader as default for this Thread
+ Thread.currentThread().setContextClassLoader( jpaRealm );
+ }
+
+ /**
+ * Locates and returns a list of class files found under specified class
+ * directory.
+ *
+ * @return list of class files.
+ * @throws MojoExecutionException if there was an error scanning class file
+ * resources.
+ */
+ protected List<File> findEntityClassFiles() throws MojoExecutionException
+ {
+ List<File> files = new ArrayList<File>();
+
+ try
+ {
+ files = (List<File>) FileUtils.getFiles( getEntityClasses(), includes, excludes );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Error while scanning for '" + includes + "' in " + "'"
+ + getEntityClasses().getAbsolutePath() + "'.", e );
+ }
+
+ return files;
+ }
+
+ /**
+ * @param files List of files
+ * @return the paths of the given files as String[]
+ */
+ protected String[] getFilePaths( List<File> files )
+ {
+ String[] args = new String[ files.size() ];
+ for ( int i = 0; i < files.size(); i++ )
+ {
+ File file = files.get( i );
+
+ args[ i ] = file.getAbsolutePath();
+ }
+ return args;
+ }
+
+
+}
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojo.java
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojo.java?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojo.java (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojo.java Mon Jun 2 11:07:07 2014
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.tools.maven;
+
+
+/**
+ * Processes Application model classes and enhances them by running Open JPA
+ * Enhancer tool.
+ * This basically only acts as a container for the xdoclet stuff since all
+ * the required functionality is already in the {@code AbstratOpenJpaEnhancerMojo}.
+ *
+ * @version $Id: OpenJpaEnhancerMojo.java 10954 2009-10-23 22:05:45Z struberg $
+ * @since 1.0
+ * @goal enhance
+ * @phase process-classes
+ * @requiresDependencyResolution compile
+ *
+ */
+public class OpenJpaEnhancerMojo extends AbstractOpenJpaEnhancerMojo {
+}
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSchemaMojo.java
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSchemaMojo.java?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSchemaMojo.java (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSchemaMojo.java Mon Jun 2 11:07:07 2014
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.tools.maven;
+
+
+import java.io.File;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.openjpa.lib.util.Options;
+
+/**
+ * Executes the schema generation via the OpenJPA MappingTool.
+ *
+ * @version $Id$
+ * @since 1.0
+ * @goal schema
+ * @phase process-classes
+ * @requiresDependencyResolution compile
+ *
+ */
+public class OpenJpaSchemaMojo extends AbstractOpenJpaMappingToolMojo {
+
+ /**
+ * The action to take on the schema.
+ * Actions can be composed in a comma-separated list of one of the following items:
+ * <ul>
+ * <li>add (see MappingTool#ACTION_ADD)</li>
+ * <li>refresh (see MappingTool#ACTION_REFRESH)</li>
+ * <li>drop (see MappingTool#ACTION_DROP)</li>
+ * <li>buildSchema (see MappingTool#ACTION_BUILD_SCHEMA)</li>
+ * <li>import (see MappingTool#ACTION_IMPORT)</li>
+ * <li>export (see MappingTool#ACTION_EXPORT)</li>
+ * <li>validate (see MappingTool#ACTION_VALIDATE)</li>
+ * </ul>
+ *
+ * @parameter default-value="add"
+ */
+ protected String schemaAction;
+ /**
+ * used for passing the schemaAction parameter to the mapping tool
+ */
+ protected static final String OPTION_SCHEMA_ACTION = "schemaAction";
+
+ /**
+ * Use this option to write the planned schema to an XML document
+ * rather than modify the database. The document can then be manipulated and
+ * committed to the database with the schema tool
+ *
+ * @parameter default-value="${project.build.directory}/schema.xml"
+ */
+ protected File schemaFile;
+ /**
+ * used for passing the schemaFile parameter to the mapping tool
+ */
+ protected static final String OPTION_SCHEMA_FILE = "schemaFile";
+
+ /**
+ * @return Options filled with all necessary plugin parameters
+ */
+ protected Options getOptions() throws MojoExecutionException {
+ // options
+ Options opts = createOptions();
+
+ // put the standard options into the list also
+ opts.put(OPTION_SCHEMA_ACTION, schemaAction);
+
+ opts.put(OPTION_SCHEMA_FILE, schemaFile.getPath());
+
+ if (action != null) {
+ opts.put(OPTION_ACTION, action);
+ }
+ return opts;
+ }
+}
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSqlMojo.java
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSqlMojo.java?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSqlMojo.java (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSqlMojo.java Mon Jun 2 11:07:07 2014
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.tools.maven;
+
+
+import java.io.File;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.openjpa.lib.util.Options;
+
+/**
+ * Executes the SQL generation via the OpenJPA MappingTool.
+ *
+ * @version $Id$
+ * @since 1.0
+ * @goal sql
+ * @phase process-classes
+ * @requiresDependencyResolution compile
+ */
+public class OpenJpaSqlMojo extends AbstractOpenJpaMappingToolMojo {
+
+ /**
+ * The action to take for generating the SQL.
+ * Actions can be composed in a comma-separated list of one of the following items:
+ * <ul>
+ * <li>add (see MappingTool#ACTION_ADD)</li>
+ * <li>refresh (see MappingTool#ACTION_REFRESH)</li>
+ * <li>drop (see MappingTool#ACTION_DROP)</li>
+ * <li>buildSchema (see MappingTool#ACTION_BUILD_SCHEMA)</li>
+ * <li>import (see MappingTool#ACTION_IMPORT)</li>
+ * <li>export (see MappingTool#ACTION_EXPORT)</li>
+ * <li>validate (see MappingTool#ACTION_VALIDATE)</li>
+ * </ul>
+ * Technically this is the same like the {@code schemaAction}, but we have to
+ * split it for the plugin to allow different actions for generating the mapping
+ * and generating the SQL files.
+ *
+ * @parameter default-value="build"
+ */
+ protected String sqlAction;
+ /**
+ * internally the options is named 'schemaAction'!
+ */
+ protected static final String OPTION_SQL_ACTION = "schemaAction";
+
+ /**
+ * Use this option to write the planned schema modifications to a SQL
+ * script. Combine this with a schemaAction
+ * of "build" to generate a script that recreates the schema for the
+ * current mappings, even if the schema already exists.
+ *
+ * @parameter default-value="${project.build.directory}/database.sql"
+ */
+ protected File sqlFile;
+ /**
+ * used for passing the sqlFile parameter to the mapping tool
+ */
+ protected static final String OPTION_SQL_FILE = "sqlFile";
+
+
+ /**
+ * Use this option to write the planned schema modifications to
+ * the database. If this is set, the sqlFile setting (if any) will
+ * be ignored.
+ *
+ * @parameter default-value="false"
+ */
+ protected boolean modifyDatabase;
+
+
+ /**
+ * @return Options filled with all necessary plugin parameters
+ */
+ protected Options getOptions() throws MojoExecutionException {
+ // options
+ Options opts = createOptions();
+
+
+ if (!modifyDatabase) {
+
+ opts.put(OPTION_SQL_FILE, sqlFile.getPath());
+ } else {
+ if (sqlAction.equals("build")) {
+ // build is not valid if we write to the database directly
+ sqlAction = "refresh";
+ }
+ }
+
+ // put the standard options into the list also
+ opts.put(OPTION_SQL_ACTION, sqlAction);
+
+ return opts;
+ }
+}
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaTestEnhancerMojo.java
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaTestEnhancerMojo.java?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaTestEnhancerMojo.java (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaTestEnhancerMojo.java Mon Jun 2 11:07:07 2014
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.tools.maven;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Processes Application model classes and enhances them by running Open JPA
+ * Enhancer tool.
+ *
+ * @version $Id: OpenJpaTestEnhancerMojo.java 9137 2009-02-28 21:55:03Z struberg $
+ * @since 1.1
+ * @goal test-enhance
+ * @phase process-test-classes
+ * @requiresDependencyResolution test
+ *
+ */
+public class OpenJpaTestEnhancerMojo extends AbstractOpenJpaEnhancerMojo {
+
+ /**
+ * List of all class path elements that will be searched for the
+ * <code>persistence-enabled</code> classes and resources expected by
+ * PCEnhancer.
+ *
+ * @parameter default-value="${project.testClasspathElements}"
+ * @required
+ * @readonly
+ */
+ protected List<String> testClasspathElements;
+
+ /**
+ * This is where compiled test classes go.
+ *
+ * @parameter default-value="${project.build.testOutputDirectory}"
+ * @required
+ * @readonly
+ */
+ private File testClasses;
+
+ /**
+ * Use this flag to skip test enhancement. It will automatically be
+ * set if maven got invoked with the -Dmaven.test.skip=true option
+ * because no compiled test clases are available in this case.
+ *
+ * @parameter default-value="${maven.test.skip}"
+ * @readonly
+ */
+ private boolean skipTestEnhancement;
+
+ /**
+ * This function overloads {@code AbstractOpenJpaMojo#getClasspathElements()} to return the test
+ * classpath elements.
+ *
+ * @return List of classpath elements for the test phase
+ */
+ protected List<String> getClasspathElements() {
+ return testClasspathElements;
+ }
+
+
+ /**
+ * The File where the class files of the entities to enhance reside
+ *
+ * @return normaly the test entity classes are located in target/test-classes
+ */
+ protected File getEntityClasses() {
+ return testClasses;
+ }
+
+ protected boolean skipMojo() {
+ boolean skip = super.skipMojo();
+
+ // we also need to skip enhancing test classes if all
+ // tests got skipped.
+ skip |= skipTestEnhancement;
+
+ return skip;
+ }
+
+
+}
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/credentials.apt
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/credentials.apt?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/credentials.apt (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/credentials.apt Mon Jun 2 11:07:07 2014
@@ -0,0 +1,95 @@
+ ------
+ Enhance
+ ------
+ Mark Struberg
+ <st...@yahoo.de>
+ ------
+ March 19, 2010
+ ------
+
+Specifying connection settings in the plugin section
+
+ Sometimes it's necessary to set (or override) the connection settings
+ which are needed at build time in the plugin section because the persistence.xml
+ doesn't contain the correct information.
+
+ This can be performed with the 2 optional parameters
+
+ * <<<connectionDriverName>>> which defines the driver class
+
+ * <<<connectionProperties>>> which defines further properties
+
+-------------------
+<project>
+ [...]
+ <build>
+ [...]
+ <plugins>
+ <plugin>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-maven-plugin</artifactId>
+ <version>1.2</version>
+ <configuration>
+ <includes>
+ com/mycompany/myproject/myentities/*.class
+ </includes>
+ <addDefaultConstructor>true</addDefaultConstructor>
+ <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
+ <sqlAction>refresh</sqlAction>
+ <sqlFile>${project.build.directory}/database.sql</sqlFile>
+ <connectionDriverName>com.mchange.v2.c3p0.ComboPooledDataSource</connectionDriverName>
+ <connectionProperties>
+ driverClass=com.mysql.jdbc.Driver,
+ jdbcUrl=jdbc:mysql://localhost/TissExamples,
+ user=root,
+ password=,
+ minPoolSize=5,
+ acquireRetryAttempts=3,
+ maxPoolSize=20
+ </connectionProperties>
+ </configuration>
+ <executions>
+ <execution>
+ <id>mappingtool</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>enhance</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.12</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-all</artifactId>
+ <version>2.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sourceforge.cobertura</groupId>
+ <artifactId>cobertura</artifactId>
+ <version>1.9.2</version>
+ </dependency>
+ <dependency>
+ <groupId>c3p0</groupId>
+ <artifactId>c3p0</artifactId>
+ <version>0.9.1</version>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.11</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ [...]
+ </plugins>
+ [...]
+ </build>
+ [...]
+</project>
+-------------------
+
\ No newline at end of file
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/enhance.apt
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/enhance.apt?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/enhance.apt (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/enhance.apt Mon Jun 2 11:07:07 2014
@@ -0,0 +1,50 @@
+ ------
+ Enhance
+ ------
+ Mark Struberg
+ <st...@yahoo.de>
+ ------
+ November 29, 2010
+ ------
+
+Enhance
+
+ The following build configuration shows how to enhance JPA entities
+ at compile time. Please consult the OpenJPA documentation for more
+ details on compiletime enhancement versus runtime enhancement.
+
+ The {{{../enhance-mojo.html}openjpa:enhance}} mojo will typically be
+ called in the <<<process-classes>>> phase.
+
+ Please note that the tmpClassLoader defaults to <<<false>>> to make
+ sure that classes in depending artifacts (like enums in interfaces)
+ can be parsed by the PCEnhancer.
+
+-------------------
+<project>
+ [...]
+ <build>
+ [...]
+ <plugins>
+ <plugin>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-maven-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <id>enhancer</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>enhance</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ [...]
+ </plugins>
+ [...]
+ </build>
+ [...]
+</project>
+-------------------
+
\ No newline at end of file
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/older_versions.apt
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/older_versions.apt?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/older_versions.apt (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/older_versions.apt Mon Jun 2 11:07:07 2014
@@ -0,0 +1,68 @@
+ ------
+ Enhance
+ ------
+ Mark Struberg
+ <st...@yahoo.de>
+ ------
+ Dezember, 7th, 2011
+ ------
+
+Running openjpa-maven-plugin with different OpenJPA verions
+
+ The openjpa-maven-plugin by default uses OpenJPA with exactly the same version
+ as the plugin itself. If you like to use an older OpenJPA version (which doesn't
+ have an org.apache.openjpa:openjpa-maven-plugin), you can just override the
+ plugin dependencies
+
+-------------------
+<project>
+ [...]
+ <build>
+ [...]
+ <plugins>
+ <plugin>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-maven-plugin</artifactId>
+ <version>2.2.0</version>
+ <executions>
+ <execution>
+ <id>enhancer</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>enhance</goal>
+ </goals>
+ </execution>
+
+ <!-- Use your own openjpa dependencies -->
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-kernel</artifactId>
+ <version>${oldopenjpa.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-jdbc</artifactId>
+ <version>${oldopenjpa.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-persistence</artifactId>
+ <version>${oldopenjpa.version}</version>
+ </dependency>
+ <dependency>
+ <!-- needed for db specific hooks -->
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-persistence-jdbc</artifactId>
+ <version>${oldopenjpa.version}</version>
+ </dependency>
+ </dependencies>
+ </executions>
+ </plugin>
+ [...]
+ </plugins>
+ [...]
+ </build>
+ [...]
+</project>
+-------------------
Added: tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/schema.apt
URL: http://svn.apache.org/viewvc/tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/schema.apt?rev=1599164&view=auto
==============================================================================
--- tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/schema.apt (added)
+++ tomee/deps/tags/openjpa-2.4.0-1598334/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/schema.apt Mon Jun 2 11:07:07 2014
@@ -0,0 +1,54 @@
+ ------
+ Schema
+ ------
+ Mark Struberg
+ <st...@yahoo.de>
+ ------
+ November 29, 2010
+ ------
+
+Schema
+
+ The following build configuration shows how to use the OpenJPA
+ MappingTool for generating the schema mapping XML file.
+ Please consult the OpenJPA documentation for more
+ details on the schema mapping XML syntax and usage.
+
+ The {{{../schema-mojo.html}openjpa:schema}} mojo will typically
+ be called manually, so there is no <<<executions>>> section.
+
+-------------------
+<project>
+ [...]
+ <build>
+ [...]
+ <plugins>
+ <plugin>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-maven-plugin</artifactId>
+ <version>1.2</version>
+ <schemaAction></schemaAction>
+ <schemaFile>target/myschema.xml</schemaFile>
+ </plugin>
+ [...]
+ </plugins>
+ [...]
+ </build>
+ [...]
+</project>
+-------------------
+
+
+ * If no <<<schemaFile>>> is set this will default to <<<target/schema.xml>>>
+
+ * If no <<<schemaAction>>> is set it will default to <<<add>>>
+
+ Possible values for <<<schemaAction>>> are:
+ <<<add>>>,
+ <<<refresh>>>,
+ <<<drop>>>,
+ <<<buildSchema>>>,
+ <<<import>>>,
+ <<<export>>>,
+ <<<validate>>>
+
\ No newline at end of file