mirror of https://github.com/apache/openjpa.git
OPENJPA-1934: Add a maven plugin for PCEnhancement.
Submitted By: Mark Struberg, Rahul Thankar git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1090086 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
985a59afbd
commit
e35178f645
|
@ -0,0 +1,171 @@
|
||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<!--
|
||||||
|
Maven release plugin requires the project tag to be on a single line.
|
||||||
|
-->
|
||||||
|
<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">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.openjpa</groupId>
|
||||||
|
<artifactId>openjpa-tools</artifactId>
|
||||||
|
<version>2.2.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>openjpa-maven-plugin</artifactId>
|
||||||
|
<packaging>maven-plugin</packaging>
|
||||||
|
|
||||||
|
<name>OpenJPA Maven Plugin</name>
|
||||||
|
<description>
|
||||||
|
OpenJPA tasks for enhancing, SQL creation and schema mapping creation using
|
||||||
|
Apache maven (see http://maven.apache.org).
|
||||||
|
</description>
|
||||||
|
<inceptionYear>2011</inceptionYear>
|
||||||
|
|
||||||
|
<prerequisites>
|
||||||
|
<maven>2.0.6</maven>
|
||||||
|
</prerequisites>
|
||||||
|
|
||||||
|
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<id>rahul</id>
|
||||||
|
<name>Rahul Thakur</name>
|
||||||
|
<email>rahul@codehaus.org</email>
|
||||||
|
<roles>
|
||||||
|
<role>Developer</role>
|
||||||
|
</roles>
|
||||||
|
<timezone>+12</timezone>
|
||||||
|
</developer>
|
||||||
|
<developer>
|
||||||
|
<id>msx</id>
|
||||||
|
<name>Mark Struberg</name>
|
||||||
|
<email>struberg@yahoo.de</email>
|
||||||
|
<roles>
|
||||||
|
<role>Developer</role>
|
||||||
|
</roles>
|
||||||
|
<timezone>+1</timezone>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
<dependencies>
|
||||||
|
<!-- dependencies needed for building maven plugins -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-plugin-api</artifactId>
|
||||||
|
<version>2.0.6</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-project</artifactId>
|
||||||
|
<version>2.0.6</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
|
<artifactId>plexus-utils</artifactId>
|
||||||
|
<version>1.5.7</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- dependencies for OpenJPA itself -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.openjpa</groupId>
|
||||||
|
<artifactId>openjpa-kernel</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.openjpa</groupId>
|
||||||
|
<artifactId>openjpa-jdbc</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.openjpa</groupId>
|
||||||
|
<artifactId>openjpa-persistence</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<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>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
<version>1.2.14</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- For Tests -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.plugin-testing</groupId>
|
||||||
|
<artifactId>maven-plugin-testing-harness</artifactId>
|
||||||
|
<version>1.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>Apache License 2.0</name>
|
||||||
|
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||||
|
<distribution>repo</distribution>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>1.5</source>
|
||||||
|
<target>1.5</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-invoker-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<debug>true</debug>
|
||||||
|
<projectsDirectory>src/it</projectsDirectory>
|
||||||
|
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
|
||||||
|
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
|
||||||
|
<settingsFile>src/it/settings.xml</settingsFile>
|
||||||
|
<pomIncludes>
|
||||||
|
<pomInclude>*/pom.xml</pomInclude>
|
||||||
|
</pomIncludes>
|
||||||
|
<goals>
|
||||||
|
<goal>install</goal>
|
||||||
|
</goals>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>integration-test</id>
|
||||||
|
<goals>
|
||||||
|
<goal>install</goal>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,83 @@
|
||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<!--
|
||||||
|
Maven release plugin requires the project tag to be on a single line.
|
||||||
|
-->
|
||||||
|
<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">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.apache.openjpa.tools.openjpa-maven-plugin.testing</groupId>
|
||||||
|
<artifactId>enhance</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<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>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-classes</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>enhance</goal>
|
||||||
|
<goal>sql</goal>
|
||||||
|
<goal>schema</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<toolProperties>
|
||||||
|
<property>
|
||||||
|
<name>someSetting</name>
|
||||||
|
<value>someValue</value>
|
||||||
|
</property>
|
||||||
|
</toolProperties>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>1.5</source>
|
||||||
|
<target>1.5</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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>
|
||||||
|
|
|
@ -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.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 javax.persistence.EntityManagerFactory;
|
||||||
|
import javax.persistence.Persistence;
|
||||||
|
|
||||||
|
import org.apache.openjpa.enhance.PersistenceCapable;
|
||||||
|
import org.apache.openjpa.tools.maven.testentity.TestEntity;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
public class ItDefaultSettingsTest 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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test will execute a few statements to the database
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void testPersistence() throws Exception
|
||||||
|
|
||||||
|
{
|
||||||
|
EntityManagerFactory emf = Persistence.createEntityManagerFactory("TestUnit");
|
||||||
|
EntityManager em = emf.createEntityManager();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
em.getTransaction().begin();
|
||||||
|
|
||||||
|
TestEntity te = new TestEntity(1, "testentry");
|
||||||
|
|
||||||
|
em.getTransaction().commit();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (em.getTransaction().isActive())
|
||||||
|
{
|
||||||
|
em.getTransaction().rollback();
|
||||||
|
}
|
||||||
|
em.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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>
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<!--
|
||||||
|
Maven release plugin requires the project tag to be on a single line.
|
||||||
|
-->
|
||||||
|
<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">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.apache.openjpa.tools.openjpa-maven-plugin.testing</groupId>
|
||||||
|
<artifactId>dependingProjects</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 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>
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<!--
|
||||||
|
Maven release plugin requires the project tag to be on a single line.
|
||||||
|
-->
|
||||||
|
<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">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.apache.openjpa.tools.openjpa-maven-plugin.testing</groupId>
|
||||||
|
<artifactId>dependingProject-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>
|
|
@ -0,0 +1,35 @@
|
||||||
|
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
|
||||||
|
{
|
||||||
|
SMS, MMS
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageChannel getMessageChannel();
|
||||||
|
|
||||||
|
public void setMessageChannel( MessageChannel messageChannel );
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<!--
|
||||||
|
Maven release plugin requires the project tag to be on a single line.
|
||||||
|
-->
|
||||||
|
<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">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.apache.openjpa.tools.openjpa-maven-plugin.testing</groupId>
|
||||||
|
<artifactId>dependingProject-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 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>dependingProject-A</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</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-classes</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>enhance</goal>
|
||||||
|
<goal>sql</goal>
|
||||||
|
<goal>schema</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>
|
|
@ -0,0 +1,61 @@
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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>
|
||||||
|
|
|
@ -0,0 +1,130 @@
|
||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<!--
|
||||||
|
Maven release plugin requires the project tag to be on a single line.
|
||||||
|
-->
|
||||||
|
<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">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.apache.openjpa.tools.openjpa-maven-plugin.testing</groupId>
|
||||||
|
<artifactId>modifyDatabase</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<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>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>5.1.11</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>1.5</source>
|
||||||
|
<target>1.5</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>sql-maven-plugin</artifactId>
|
||||||
|
<version>1.4</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>dropdatabase</id>
|
||||||
|
<phase>process-resources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>execute</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<driver>com.mysql.jdbc.Driver</driver>
|
||||||
|
<url>jdbc:mysql://localhost/testdb</url>
|
||||||
|
<username>root</username>
|
||||||
|
<enableAnonymousPassword>true</enableAnonymousPassword>
|
||||||
|
<sqlCommand>DROP TABLE TestEntity;</sqlCommand>
|
||||||
|
</configuration>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>5.1.11</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.openjpa</groupId>
|
||||||
|
<artifactId>openjpa-maven-plugin</artifactId>
|
||||||
|
<version>@pom.version@</version>
|
||||||
|
<configuration>
|
||||||
|
<include>
|
||||||
|
org/apache/openjpa/tools/maven/testentity/TestEntity.class
|
||||||
|
</include>
|
||||||
|
<sqlAction>refresh</sqlAction>
|
||||||
|
<modifyDatabase>true</modifyDatabase>
|
||||||
|
<connectionProperties>
|
||||||
|
driverClass=com.mysql.jdbc.Driver,
|
||||||
|
jdbcUrl=jdbc:mysql://localhost/testdb,
|
||||||
|
user=root,
|
||||||
|
password=
|
||||||
|
</connectionProperties>
|
||||||
|
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>mappingtool</id>
|
||||||
|
<phase>process-classes</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>enhance</goal>
|
||||||
|
<goal>sql</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>5.1.11</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,54 @@
|
||||||
|
package org.apache.openjpa.tools.maven.testentity;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.Id;
|
||||||
|
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class TestEntity {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private int xint1;
|
||||||
|
|
||||||
|
private String 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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="mysql" />
|
||||||
|
<property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver" />
|
||||||
|
<property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost/testdb" />
|
||||||
|
<property name="openjpa.ConnectionUserName" value="root" />
|
||||||
|
<property name="openjpa.ConnectionPassword" value="" />
|
||||||
|
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</persistence-unit>
|
||||||
|
|
||||||
|
</persistence>
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
package org.apache.openjpa.tools.maven.test;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 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 javax.persistence.EntityManagerFactory;
|
||||||
|
import javax.persistence.Persistence;
|
||||||
|
|
||||||
|
import org.apache.openjpa.enhance.PersistenceCapable;
|
||||||
|
import org.apache.openjpa.tools.maven.testentity.TestEntity;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
public class ModifyDatabaseTest extends TestCase {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check if the generated classes have been enhanced.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void testDatabaseWrite() throws Exception
|
||||||
|
{
|
||||||
|
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "TestUnit" );
|
||||||
|
assertNotNull( emf );
|
||||||
|
|
||||||
|
EntityManager em = emf.createEntityManager();
|
||||||
|
assertNotNull( em );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
em.getTransaction().begin();
|
||||||
|
|
||||||
|
TestEntity entity = new TestEntity();
|
||||||
|
entity.setInt1( 4711 );
|
||||||
|
entity.setString1( "myVal" );
|
||||||
|
|
||||||
|
em.persist( entity );
|
||||||
|
em.getTransaction().commit();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
em.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<!--
|
||||||
|
Maven release plugin requires the project tag to be on a single line.
|
||||||
|
-->
|
||||||
|
<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">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.apache.openjpa.tools.openjpa-maven-plugin.testing</groupId>
|
||||||
|
<artifactId>nonDefaultPersistenceXml</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<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>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>
|
||||||
|
<configuration>
|
||||||
|
<persistenceXmlFile>${basedir}/src/main/resources/META-INF/anotherPersistence.xml</persistenceXmlFile>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>mappingtool</id>
|
||||||
|
<phase>process-classes</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>enhance</goal>
|
||||||
|
<goal>sql</goal>
|
||||||
|
<goal>schema</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>
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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>
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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 );
|
||||||
|
}
|
|
@ -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>
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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>
|
||||||
|
|
|
@ -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!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -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 {
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -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>
|
||||||
|
-------------------
|
||||||
|
|
|
@ -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>
|
||||||
|
-------------------
|
||||||
|
|
|
@ -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>>>
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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>
|
||||||
|
-------------------
|
||||||
|
|
|
@ -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 }}
|
||||||
|
|
||||||
|
[]
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
----------
|
|
@ -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>
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
public 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?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">
|
||||||
|
<class>org.apache.openjpa.tools.maven.testentity.TestEntity</class>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<property name="openjpa.jdbc.DBDictionary" value="hsql" />
|
||||||
|
<property name="openjpa.ConnectionDriverName" value="org.hsqldb.jdbcDriver" />
|
||||||
|
<property name="openjpa.ConnectionURL" value="jdbc:hsqldb:file:target/db" />
|
||||||
|
<property name="openjpa.ConnectionUserName" value="sa" />
|
||||||
|
<property name="openjpa.ConnectionPassword" value="" />
|
||||||
|
<property name="openjpa.Log" value="DefaultLevel=TRACE" />
|
||||||
|
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" />
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</persistence-unit>
|
||||||
|
|
||||||
|
</persistence>
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<project>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>openjpa-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?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"
|
||||||
|
version="1.0">
|
||||||
|
<persistence-unit name="openjpa-test">
|
||||||
|
<provider>
|
||||||
|
org.apache.openjpa.persistence.PersistenceProviderImpl
|
||||||
|
</provider>
|
||||||
|
|
||||||
|
<class>org.apache.openjpa.tools.maven.testentity.Person</class>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<property name="openjpa.ConnectionURL"
|
||||||
|
value="jdbc:hsqldb:mem:test" />
|
||||||
|
<property name="openjpa.ConnectionDriverName"
|
||||||
|
value="org.hsqldb.jdbcDriver" />
|
||||||
|
<property name="openjpa.ConnectionUserName" value="sa" />
|
||||||
|
<property name="openjpa.ConnectionPassword" value="" />
|
||||||
|
<property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO" />
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</persistence-unit>
|
||||||
|
</persistence>
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
|
||||||
|
version="1.0">
|
||||||
|
|
||||||
|
<entity class="org.apache.openjpa.tools.maven.testentity.Person">
|
||||||
|
<table name="PERSON" />
|
||||||
|
<attributes>
|
||||||
|
<id name="id">
|
||||||
|
<column name="ID" />
|
||||||
|
<generated-value />
|
||||||
|
</id>
|
||||||
|
<basic name="name">
|
||||||
|
<column name="NAME" />
|
||||||
|
</basic>
|
||||||
|
<basic name="age">
|
||||||
|
<column name="AGE" />
|
||||||
|
</basic>
|
||||||
|
</attributes>
|
||||||
|
</entity>
|
||||||
|
|
||||||
|
</entity-mappings>
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<!--
|
||||||
|
Maven release plugin requires the project tag to be on a single line.
|
||||||
|
-->
|
||||||
|
<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">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.openjpa</groupId>
|
||||||
|
<artifactId>openjpa-parent</artifactId>
|
||||||
|
<version>2.2.0-SNAPSHOT</version>
|
||||||
|
<!-- <relativePath>../pom.xml</relativePath>-->
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>openjpa-tools</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<name>OpenJPA tools</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<checkstyle.config.location>${project.basedir}/../../openjpa-project/checkstyle.xml</checkstyle.config.location>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>openjpa-maven-plugin</module>
|
||||||
|
</modules>
|
||||||
|
</project>
|
1
pom.xml
1
pom.xml
|
@ -159,6 +159,7 @@
|
||||||
<module>openjpa-examples</module>
|
<module>openjpa-examples</module>
|
||||||
<module>openjpa-integration</module>
|
<module>openjpa-integration</module>
|
||||||
<module>openjpa-all</module>
|
<module>openjpa-all</module>
|
||||||
|
<module>openjpa-tools</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
|
Loading…
Reference in New Issue