<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright (C) 2007 - 2010 GeoSolutions S.A.S.
 http://www.geo-solutions.it

 GPLv3 + Classpath exception

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->
<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>it.geosolutions.geofence</groupId>
        <artifactId>geofence-core</artifactId>
        <version>2.2-SNAPSHOT</version>
    </parent>
  
    <groupId>it.geosolutions.geofence</groupId>
    <artifactId>geofence-model</artifactId>
    <packaging>jar</packaging>
    <name>GeoFence - Core - Model external</name>
    <description>Model used for external deps, cleaned from JPA annotations</description>
  
    <dependencies>
  
        <dependency>
            <groupId>com.vividsolutions</groupId>
            <artifactId>jts</artifactId>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.8</version>

                <executions>
                    <execution>
                        <id>unpack-model</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                    </execution>
                </executions>
                
                <configuration>
                    <artifactItems>
                        <artifactItem>
                            <groupId>it.geosolutions.geofence</groupId>
                            <artifactId>geofence-model-internal</artifactId>
                            <!--<version>[ version ]</version>-->
                            <type>jar</type>
                            <classifier>sources</classifier>
                            <overWrite>true</overWrite>
                            <outputDirectory>${project.build.directory}/generated-sources/original</outputDirectory>
                            <includes>**/*.java, **/*.xml</includes>
                            <!--<excludes>[ comma separated list of file filters ]</excludes>-->
                        </artifactItem>
                    </artifactItems>
                    <!--<includes>**/*.java, **/*.xml</includes>-->
                    <!-- other configurations here -->
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>

                <executions>
                    <execution>
                        <phase>process-sources</phase>
                        <configuration>
                            <target>
                                <replaceregexp byline="true" replace="">
                                    <regexp pattern="import javax\.persistence\..*"/>
                                    <fileset dir="${project.build.directory}/generated-sources/original">
                                        <include name="**/*.java"/>
                                    </fileset>
                                </replaceregexp>

                                <replaceregexp byline="true">
                                    <regexp pattern="import org\.hibernate\.annotations\..*"/>
                                    <substitution expression="" />
                                    <fileset dir="${project.build.directory}/generated-sources/original">
                                        <include name="**/*.java"/>
                                    </fileset>
                                </replaceregexp>

                                <replaceregexp byline="true" replace="">
                                    <regexp pattern="(@Entity|@Cache|@Table|@org.hibernate.annotations.CollectionOfElements|@Fetch|@Index|@Embedded|@Embeddable|@Check).*"/>
                                    <fileset dir="${project.build.directory}/generated-sources/original">
                                        <include name="**/*.java"/>
                                    </fileset>
                                </replaceregexp>

                                <replaceregexp byline="true" replace="">
                                    <regexp pattern="(@Id|@GeneratedValue|@Enumerated|@Column|@Type|@Temporal|@OneToOne|@ManyToOne|@ManyToMany|@ForeignKey|@UniqueConstraint|@AttributeOverride|@JoinTable).*"/>
                                    <fileset dir="${project.build.directory}/generated-sources/original">
                                        <include name="**/*.java"/>
                                    </fileset>
                                </replaceregexp>

                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>

            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.9</version>

                <executions>
                    <execution>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${project.build.directory}/generated-sources/original</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Attach sources ============================================ -->
            <plugin>
                <inherited>true</inherited>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <attach>true</attach>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

</project>
