Added: openjpa/trunk/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/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/test/java/org/apache/openjpa/tools/maven/test/ItNonDefaultXmlTest.java?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/test/java/org/apache/openjpa/tools/maven/test/ItNonDefaultXmlTest.java (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/test/java/org/apache/openjpa/tools/maven/test/ItNonDefaultXmlTest.java Fri Apr 8 01:59:02 2011
@@ -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 );
+ }
+ }
+
+
+}
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/test/java/org/apache/openjpa/tools/maven/test/ItNonDefaultXmlTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/test/resources/reference_schema.orig_xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/test/resources/reference_schema.orig_xml?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/test/resources/reference_schema.orig_xml (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/nonDefaultPersistenceXml/src/test/resources/reference_schema.orig_xml Fri Apr 8 01:59:02 2011
@@ -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: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/settings.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/settings.xml?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/settings.xml (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/settings.xml Fri Apr 8 01:59:02 2011
@@ -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.7</hsqldb.version>
+ </properties>
+ </profile>
+ </profiles>
+</settings>
\ No newline at end of file
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/settings.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/pom.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/pom.xml?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/pom.xml (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/pom.xml Fri Apr 8 01:59:02 2011
@@ -0,0 +1,40 @@
+<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.openjpa.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>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ </dependency>
+ </dependencies>
+ <modules>
+ <module>prjA</module>
+ <module>prjB</module>
+ </modules>
+</project>
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjA/pom.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjA/pom.xml?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjA/pom.xml (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjA/pom.xml Fri Apr 8 01:59:02 2011
@@ -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.openjpa.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>
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjA/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/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/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjA/src/main/java/org/apache/openjpa/tools/maven/test/it/dependingartifact/MyEntityInterface.java?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjA/src/main/java/org/apache/openjpa/tools/maven/test/it/dependingartifact/MyEntityInterface.java (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjA/src/main/java/org/apache/openjpa/tools/maven/test/it/dependingartifact/MyEntityInterface.java Fri Apr 8 01:59:02 2011
@@ -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 );
+}
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjA/src/main/java/org/apache/openjpa/tools/maven/test/it/dependingartifact/MyEntityInterface.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/pom.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/pom.xml?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/pom.xml (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/pom.xml Fri Apr 8 01:59:02 2011
@@ -0,0 +1,79 @@
+<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.openjpa.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.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>@pom.version@</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openjpa.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.openjpa</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>
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/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/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/src/test/java/org/apache/openjpa/tools/maven/test/it/dependingartifact/entities/MyEntityImpl.java?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/src/test/java/org/apache/openjpa/tools/maven/test/it/dependingartifact/entities/MyEntityImpl.java (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/src/test/java/org/apache/openjpa/tools/maven/test/it/dependingartifact/entities/MyEntityImpl.java Fri Apr 8 01:59:02 2011
@@ -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;
+ }
+
+}
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/src/test/java/org/apache/openjpa/tools/maven/test/it/dependingartifact/entities/MyEntityImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/src/test/resources/META-INF/persistence.xml?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/src/test/resources/META-INF/persistence.xml (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/src/test/resources/META-INF/persistence.xml Fri Apr 8 01:59:02 2011
@@ -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>
+
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/it/testDependencies/prjB/src/test/resources/META-INF/persistence.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaEnhancerMojo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaEnhancerMojo.java?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaEnhancerMojo.java (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaEnhancerMojo.java Fri Apr 8 01:59:02 2011
@@ -0,0 +1,139 @@
+/*
+ * 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.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 entities = findEntityClassFiles();
+
+ enhance(entities);
+ }
+
+ /**
+ * Get the options for the OpenJPA enhancer tool.
+ *
+ * @return populated Options
+ */
+ protected Options getOptions() {
+ // 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 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!");
+ }
+ }
+
+}
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaEnhancerMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMappingToolMojo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMappingToolMojo.java?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMappingToolMojo.java (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMappingToolMojo.java Fri Apr 8 01:59:02 2011
@@ -0,0 +1,179 @@
+/*
+ * 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.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 java.io.File;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.persistence.Entity;
+
+/**
+ * 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 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 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 files, Options opts) {
+ JDBCConfiguration conf = new JDBCConfigurationImpl();
+ Configurations.populateConfiguration(conf, opts);
+ MetaDataRepository repo = conf.newMetaDataRepositoryInstance();
+ ClassArgParser cap = repo.getMetaDataFactory().newClassArgParser();
+
+ Iterator fileIt = files.iterator();
+ while (fileIt.hasNext()) {
+ File classPath = (File) 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;
+ }
+
+}
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMappingToolMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMojo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMojo.java?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMojo.java (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMojo.java Fri Apr 8 01:59:02 2011
@@ -0,0 +1,347 @@
+/*
+ * 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.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.FileUtils;
+
+import org.apache.openjpa.lib.util.Options;
+
+/**
+ * Base class for OpenJPA maven tasks.
+ *
+ * @version $Id$
+ */
+public abstract class AbstractOpenJpaMojo extends AbstractMojo
+{
+
+ /**
+ * 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.
+ * Please note that this is not a resource location but a file path!
+ *
+ * @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 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 getClasspathElements()
+ {
+ return compileClasspathElements;
+ }
+
+ /**
+ * Get the options for the various OpenJPA tools.
+ * @return populated Options
+ */
+ protected abstract Options getOptions();
+
+ /**
+ * <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()
+ {
+ Options opts = new Options();
+ if ( toolProperties != null )
+ {
+ opts.putAll( toolProperties );
+ }
+
+ if ( persistenceXmlFile != null )
+ {
+ opts.put( OPTION_PROPERTIES_FILE, persistenceXmlFile );
+ getLog().debug( "using special persistence XML file: " + persistenceXmlFile );
+ }
+
+ if ( connectionDriverName != null )
+ {
+ opts.put( OPTION_CONNECTION_DRIVER_NAME, connectionDriverName );
+ }
+
+ if ( connectionProperties != null )
+ {
+ opts.put( OPTION_CONNECTION_PROPERTIES, connectionProperties );
+ }
+
+ return opts;
+ }
+
+ /**
+ * 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 urls = new ArrayList();
+
+ for ( Iterator itor = getClasspathElements().iterator(); itor.hasNext(); )
+ {
+ File pathElem = new File( (String) itor.next() );
+ 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 findEntityClassFiles() throws MojoExecutionException
+ {
+ List files = new ArrayList();
+
+ try
+ {
+ files = 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 files )
+ {
+ String[] args = new String[ files.size() ];
+ for ( int i = 0; i < files.size(); i++ )
+ {
+ File file = (File) files.get( i );
+
+ args[ i ] = file.getAbsolutePath();
+ }
+ return args;
+ }
+
+
+}
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojo.java?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojo.java (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojo.java Fri Apr 8 01:59:02 2011
@@ -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 {
+}
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSchemaMojo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSchemaMojo.java?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSchemaMojo.java (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSchemaMojo.java Fri Apr 8 01:59:02 2011
@@ -0,0 +1,89 @@
+/*
+ * 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.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() {
+ // 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;
+ }
+}
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSchemaMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSqlMojo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSqlMojo.java?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSqlMojo.java (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSqlMojo.java Fri Apr 8 01:59:02 2011
@@ -0,0 +1,109 @@
+/*
+ * 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.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() {
+ // 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;
+ }
+}
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaSqlMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaTestEnhancerMojo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaTestEnhancerMojo.java?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaTestEnhancerMojo.java (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaTestEnhancerMojo.java Fri Apr 8 01:59:02 2011
@@ -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 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 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;
+ }
+
+
+}
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaTestEnhancerMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/credentials.apt
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/credentials.apt?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/credentials.apt (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/credentials.apt Fri Apr 8 01:59:02 2011
@@ -0,0 +1,95 @@
+ ------
+ Enhance
+ ------
+ Mark Struberg
+ <struberg@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: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/enhance.apt
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/enhance.apt?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/enhance.apt (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/enhance.apt Fri Apr 8 01:59:02 2011
@@ -0,0 +1,50 @@
+ ------
+ Enhance
+ ------
+ Mark Struberg
+ <struberg@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: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/schema.apt
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/schema.apt?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/schema.apt (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/schema.apt Fri Apr 8 01:59:02 2011
@@ -0,0 +1,54 @@
+ ------
+ Schema
+ ------
+ Mark Struberg
+ <struberg@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
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/sql.apt
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/sql.apt?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/sql.apt (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/sql.apt Fri Apr 8 01:59:02 2011
@@ -0,0 +1,47 @@
+ ------
+ SQL
+ ------
+ Mark Struberg
+ <struberg@yahoo.de>
+ ------
+ November 29, 2010
+ ------
+
+SQL
+
+ The following build configuration shows how to use the OpenJPA
+ MappingTool for generating the SQL file for creating a fresh database.
+ Please consult the OpenJPA documentation for more
+ details on the SQL file creation.
+
+ The {{{../sql-mojo.html}openjpa:sql}} 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>
+ <sqlAction>build</sqlAction>
+ <sqlFile>src/main/sql/create.sql</sqlFile>
+ </plugin>
+ [...]
+ </plugins>
+ [...]
+ </build>
+ [...]
+</project>
+-------------------
+
+
+ * If no <<<sqlFile>>> is set this will default to <<<target/database.sql>>>
+
+ * If no <<<sqlAction>>> is set it will default to <<<build>>>
+
+ Please consult the OpenJPA documentation for a list of valid <<<sqlAction>>>s.
+
\ No newline at end of file
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/testenhance.apt
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/testenhance.apt?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/testenhance.apt (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/examples/testenhance.apt Fri Apr 8 01:59:02 2011
@@ -0,0 +1,49 @@
+ ------
+ Enhance
+ ------
+ Mark Struberg
+ <struberg@yahoo.de>
+ ------
+ April 03, 2009
+ ------
+
+Test Enhance
+
+ The following build configuration shows how to enhance JPA entities
+ which are needed for testing only.
+
+ The {{{../test-enhance-mojo.html}openjpa:test-enhance}} mojo will typically be
+ called in the <<<process-test-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>testEnhancer</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>test-enhance</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ [...]
+ </plugins>
+ [...]
+ </build>
+ [...]
+</project>
+-------------------
+
\ No newline at end of file
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/index.apt?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/index.apt (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/index.apt Fri Apr 8 01:59:02 2011
@@ -0,0 +1,47 @@
+ ------
+ Introduction
+ ------
+ Rahul Thakur, Mark Struberg
+ ------
+ November 29, 2010
+ ------
+
+OpenJPA Maven Plugin
+
+ This plugin provides useful tasks for building and maintaining
+ an OpenJPA project with maven. All goals work on a given set of
+ JPA entities.
+
+* Goals Overview
+
+ * {{{enhance-mojo.html}openjpa:enhance}} Enhance the entity classes with persistence functionality.
+
+ * {{{sql-mojo.html}openjpa:sql}} Create a file with SQL statements, with e.g. CREATE TABLE statements
+
+ * {{{schema-mojo.html}openjpa:schema}} Create a file which contains the schema mapping XML
+
+ * {{{test-enhance-mojo.html}openjpa:test-enhance}} Enhance the entity classes in the test classpath with persistence functionality.
+
+ []
+
+
+* Usage
+
+ Instructions on how to use the OpenJPA Maven Plugin can be found on the {{{usage.html}usage page}}.
+
+
+* Examples
+
+ * {{{examples/enhance.html} JPA enhancement example.}}
+
+ * {{{examples/sql.html} SQL maintenance strategies.}}
+
+ * {{{examples/schema.html} Schema mapping example.}}
+
+ * {{{examples/testenhance.html} JPA enhancement for test classes example.}}
+
+ * {{{examples/credentials.html} Manually setting.the credentials for accessing the database at build time }}
+
+ []
+
+
\ No newline at end of file
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/usage.apt
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/usage.apt?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/usage.apt (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/apt/usage.apt Fri Apr 8 01:59:02 2011
@@ -0,0 +1,116 @@
+ ------
+ Introduction
+ ------
+ Rahul Thakur, Mark Struberg
+ ------
+ November 29, 2010
+ ------
+
+OpenJPA Maven Plugin
+
+ As of this writing the OpenJPA Plugin provides 3 goals to
+ cope with persistence-enabled classes in a project using Maven 2.
+
+
+* Goals Overview
+
+ * <<<openjpa:enhance>>> enhances the persistence-enabled classes in a
+ project.
+
+ * <<<openjpa:test-enhance>>> enhances the persistence-enabled test classes in a
+ project. This is typically bound to the process-test-classes phase.
+
+ * <<<openjpa:sql>>> creates a file which contains the SQL statements
+ for creating or updating the database or directly create the schema
+ in the database.
+
+ * <<<openjpa:schema>>> create the schema mapping XML file
+
+ All these OpenJPA Mojos expect the following resources to be
+ present on classpath:
+
+ * <<<META-INF/persistence.xml>>>, or
+
+ * <<<META-INF/openjpa.xml>>>
+
+ OpenJPA documentation is available
+ {{{http://openjpa.apache.org/documentation.html}here}}.
+
+
+* Examples
+
+ Below is an OpenJPA plugin configuration example.
+
++----------+
+ <plugin>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-maven-plugin</artifactId>
+ <version>1.2</version>
+ <configuration>
+ <includes>com/myproject/entities/**/*.class</includes>
+ <addDefaultConstructor>true</addDefaultConstructor>
+ <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
+
+ <!-- Pass additional properties to the Plugin here -->
+ <toolProperties>
+ <property>
+ <name>directory</name>
+ <value>otherdirectoryvalue</value>
+ </property>
+ </toolProperties>
+
+ </configuration>
+ <executions>
+ <execution>
+ <id>enhancer</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>enhance</goal>
+ </goals>
+ </execution>
+ </executions>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>2.0.1</version>
+ </dependency>
+ </dependencies>
+
+ </plugin>
++-----------+
+
+ * You have to explicitly specify an OpenJPA dependency in the dependencies section
+ of the plugin! This has been changed to make sure that the correct OpenJPA version is
+ used for compile time enhancement and other tasks.
+
+ * The <<<openjpa:enhance>>> mojo will automatically be called in the
+ <<<process-classes>>> phase.
+
+ From the command prompt/terminal window.
+
+ * Change directory to the project's root directory.
+
+ * Run the following goal to run OpenJPA PCEnhancer on persistence-enabled
+ classes manually.
+
+----------
+ mvn openjpa:enhance
+----------
+
+
+ * Run the following goal to run OpenJPA MappingTool for creating the
+ database creation SQL statements for all persistence-enabled classes manually.
+
+----------
+ mvn openjpa:sql
+----------
+
+
+ * Run the following goal to run OpenJPA MappingTool for creating the
+ schema mapping XML file for all persistence-enabled classes manually.
+
+----------
+ mvn openjpa:schema
+----------
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/site.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/site.xml?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/site.xml (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/site.xml Fri Apr 8 01:59:02 2011
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!--
+ | Copyright 2007-2010 The Apache Software Foundation.
+ |
+ | Licensed 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.
+ |
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd">
+ <body>
+ <menu name="Overview">
+ <item name="Introduction" href="index.html" />
+ <item name="Usage" href="usage.html" />
+ <item name="Goals" href="plugin-info.html" />
+ </menu>
+ <menu name="Examples">
+ <item name="Enhance" href="examples/enhance.html" />
+ <item name="SQL" href="examples/sql.html" />
+ <item name="Schema" href="examples/schema.html" />
+ <item name="TestEnhance" href="examples/testenhance.html" />
+ </menu>
+ </body>
+</project>
\ No newline at end of file
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/site/site.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/test/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojoTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/test/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojoTest.java?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/test/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojoTest.java (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/test/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojoTest.java Fri Apr 8 01:59:02 2011
@@ -0,0 +1,51 @@
+/*
+ * 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.ArrayList;
+
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.openjpa.tools.maven.OpenJpaEnhancerMojo;
+
+/**
+ * @version $Id: OpenJpaEnhancerMojoTest.java 9348 2009-04-03 22:59:47Z struberg $
+ * @since 1.0.0
+ */
+public class OpenJpaEnhancerMojoTest extends AbstractMojoTestCase {
+
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+
+ public void testExecution() throws Exception {
+ File testPom = new File( getBasedir(), "target/test-classes/projects/project-01/plugin-config.xml" );
+
+ OpenJpaEnhancerMojo mojo = (OpenJpaEnhancerMojo) lookupMojo( "enhance", testPom );
+ assertNotNull( mojo );
+
+ mojo.classes = new File( getBasedir(), "target/test-classes/" );
+ mojo.compileClasspathElements = new ArrayList();
+ mojo.compileClasspathElements.add( mojo.classes.getAbsolutePath() );
+
+ mojo.execute();
+ }
+
+}
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/test/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojoTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/test/java/org/apache/openjpa/tools/maven/testentity/Person.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/test/java/org/apache/openjpa/tools/maven/testentity/Person.java?rev=1090086&view=auto
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/test/java/org/apache/openjpa/tools/maven/testentity/Person.java (added)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/test/java/org/apache/openjpa/tools/maven/testentity/Person.java Fri Apr 8 01:59:02 2011
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+@Entity
+public class Person {
+
+ private long id;
+
+ private String name;
+
+ private int age;
+
+ public Person() {
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Person(String name, int age) {
+ this.name = name;
+
+ this.age = age;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+}
Propchange: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/test/java/org/apache/openjpa/tools/maven/testentity/Person.java
------------------------------------------------------------------------------
svn:eol-style = native
|