JR Utily

duplicate persistence.xml, and choose only one at building time with maven profile

...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
19 <hibernate-commons-annotations.version>5.0.1.Final</hibernate-commons-annotations.version> 19 <hibernate-commons-annotations.version>5.0.1.Final</hibernate-commons-annotations.version>
20 <hibernate-jpa-2.1-api.version>1.0.0.Final</hibernate-jpa-2.1-api.version> 20 <hibernate-jpa-2.1-api.version>1.0.0.Final</hibernate-jpa-2.1-api.version>
21 <solr.version>6.3.0</solr.version> 21 <solr.version>6.3.0</solr.version>
22 +
23 + <!-- Default is production/mysql -->
24 + <persistence.xml.filepath>persistence-production.xml</persistence.xml.filepath>
22 </properties> 25 </properties>
23 26
24 27
...@@ -99,8 +102,79 @@ ...@@ -99,8 +102,79 @@
99 102
100 </dependencies> 103 </dependencies>
101 104
105 + <profiles>
106 +
107 + <profile>
108 + <id>DS-h2-embeded</id>
109 + <!--
110 + When building for Integration, use the integration persistence.xml
111 + -->
112 + <properties>
113 + <persistence.xml.filepath>persistence-integration.xml</persistence.xml.filepath>
114 + </properties>
115 + </profile>
116 +
117 + <!--
118 + MySQL is default, so nothing to do for this profile
119 +
120 + <profile>
121 + <id>DS-mysql-local</id>
122 +
123 + </profile>
124 + -->
125 +
126 + </profiles>
127 +
102 <build> 128 <build>
129 +
130 + <resources>
131 + <resource>
132 + <directory>src/main/resources</directory>
133 + <excludes>
134 + <exclude>**/persistence-*.xml</exclude>
135 + </excludes>
136 + </resource>
137 + </resources>
138 +
103 <plugins> 139 <plugins>
140 +
141 + <plugin>
142 + <artifactId>maven-clean-plugin</artifactId>
143 + <configuration>
144 + <filesets>
145 + <fileset>
146 + <directory>
147 + src/main/resources/META-INF/
148 + </directory>
149 + <includes>
150 + <include>
151 + persistence.xml
152 + </include>
153 + </includes>
154 + </fileset>
155 + </filesets>
156 + </configuration>
157 + </plugin>
158 +
159 + <plugin>
160 + <groupId>com.coderplus.maven.plugins</groupId>
161 + <artifactId>copy-rename-maven-plugin</artifactId>
162 + <version>1.0.1</version>
163 + <executions>
164 + <execution>
165 + <id>copy-file</id>
166 + <phase>generate-resources</phase>
167 + <goals>
168 + <goal>copy</goal>
169 + </goals>
170 + <configuration>
171 + <sourceFile>src/main/resources/META-INF/${persistence.xml.filepath}</sourceFile>
172 + <destinationFile>src/main/resources/META-INF/persistence.xml</destinationFile>
173 + </configuration>
174 + </execution>
175 + </executions>
176 + </plugin>
177 +
104 <plugin> 178 <plugin>
105 <groupId>org.apache.maven.plugins</groupId> 179 <groupId>org.apache.maven.plugins</groupId>
106 <artifactId>maven-jar-plugin</artifactId> 180 <artifactId>maven-jar-plugin</artifactId>
......
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
3 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 + xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
5 +
6 + <!--
7 + INTEGRATION PERSISTENCE UNIT AIMED TO BE USED WITH H2 DB
8 + -->
9 +
10 + <persistence-unit name="Grog-DB" transaction-type="JTA">
11 + <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
12 + <jta-data-source>GrogDatabase</jta-data-source>
13 + <exclude-unlisted-classes>false</exclude-unlisted-classes>
14 + <properties>
15 +
16 + <property name="hibernate.hbm2ddl.auto" value="create"/>
17 + <property name="hibernate.hbm2ddl.import_files" value="import.sql"/>
18 + <property name="hibernate.hbm2ddl.import_files_sql_extractor"
19 + value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor"/>
20 + <!-- DDL control OFF
21 + <property name="hibernate.show_sql" value="true"/>
22 + <property name="hibernate.format_sql" value="true"/>
23 + -->
24 + </properties>
25 + </persistence-unit>
26 +</persistence>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
3 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 + xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
5 +
6 + <!--
7 + PRODUCTION PERSISTENCE UNIT AIMED TO BE USED WITH MYSQL DB
8 + -->
9 +
10 + <persistence-unit name="Grog-DB" transaction-type="JTA">
11 + <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
12 + <jta-data-source>GrogDatabase</jta-data-source>
13 + <exclude-unlisted-classes>false</exclude-unlisted-classes>
14 + <properties>
15 +
16 + <property name="hibernate.connection.CharSet" value="utf8"/>
17 + <property name="hibernate.connection.characterEncoding" value="utf8"/>
18 + <property name="hibernate.connection.useUnicode" value="true"/>
19 +
20 + <!-- DDL control OFF
21 + <property name="hibernate.show_sql" value="true"/>
22 + <property name="hibernate.format_sql" value="true"/>
23 + -->
24 + </properties>
25 + </persistence-unit>
26 +</persistence>
...\ No newline at end of file ...\ No newline at end of file
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
3 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 - xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
5 - <persistence-unit name="development-pu" transaction-type="JTA">
6 - <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
7 - <jta-data-source>H2Database</jta-data-source>
8 - <exclude-unlisted-classes>false</exclude-unlisted-classes>
9 - <properties>
10 -
11 - <property name="hibernate.hbm2ddl.auto" value="create" />
12 - <property name="hibernate.hbm2ddl.import_files" value="import.sql"/>
13 - <property name="hibernate.hbm2ddl.import_files_sql_extractor" value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor" />
14 -<!-- DDL control OFF
15 - <property name="hibernate.show_sql" value="true"/>
16 - <property name="hibernate.format_sql" value="true"/>
17 --->
18 - </properties>
19 - </persistence-unit>
20 -
21 - <persistence-unit name="migration-pu" transaction-type="JTA">
22 - <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
23 - <jta-data-source>migrationDatabase</jta-data-source>
24 - <exclude-unlisted-classes>false</exclude-unlisted-classes>
25 - <properties>
26 - <property name="hibernate.connection.CharSet" value="utf8"/>
27 - <property name="hibernate.connection.characterEncoding" value="utf8"/>
28 - <property name="hibernate.connection.useUnicode" value="true"/>
29 - <property name="hibernate.hbm2ddl.auto" value="create-drop" />
30 - <property name="hibernate.hbm2ddl.import_files" value="nothing.sql"/>
31 - <property name="hibernate.hbm2ddl.import_files_sql_extractor" value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor" />
32 - <!-- DDL control OFF
33 - <property name="hibernate.show_sql" value="true"/>
34 - <property name="hibernate.format_sql" value="true"/>
35 - -->
36 - </properties>
37 - </persistence-unit>
38 -
39 - <persistence-unit name="production-pu" transaction-type="JTA">
40 - <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
41 - <jta-data-source>productionDatabase</jta-data-source>
42 - <exclude-unlisted-classes>false</exclude-unlisted-classes>
43 - <properties>
44 - <property name="hibernate.connection.CharSet" value="utf8"/>
45 - <property name="hibernate.connection.characterEncoding" value="utf8"/>
46 - <property name="hibernate.connection.useUnicode" value="true"/>
47 - <property name="javax.persistence.hibernate.hbm2ddl.import_files" value=""/>
48 - <property name="hibernate.hbm2ddl.import_files_sql_extractor" value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor" />
49 - <!-- DDL control OFF
50 - <property name="hibernate.show_sql" value="true"/>
51 - <property name="hibernate.format_sql" value="true"/>
52 - -->
53 - </properties>
54 - </persistence-unit>
55 -</persistence>
...\ No newline at end of file ...\ No newline at end of file