<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <parent>
        <groupId>com.github.database-rider</groupId>
        <artifactId>rider-parent</artifactId>
        <!-- tag::version[] -->
        <version>1.38.0</version>
        <!-- end::version[] -->
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>rider-cdi</artifactId>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <src.dir>src/main/java</src.dir>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.github.database-rider</groupId>
            <artifactId>rider-core</artifactId>
            <version>${project.parent.version}</version>
        </dependency>

        <dependency>
            <groupId>org.dbunit</groupId>
            <artifactId>dbunit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.3.5.Final</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>eclipselink</artifactId>
            <version>2.5.2</version>
            <scope>provided</scope>
        </dependency>

        <!-- test dependencies-->

        <!--tag::deltaspike-cdi-deps[]-->
        <dependency> <!--1-->
            <groupId>org.apache.deltaspike.modules</groupId>
            <artifactId>deltaspike-test-control-module-api</artifactId>
            <version>${ds.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency> <!--1-->
            <groupId>org.apache.deltaspike.core</groupId>
            <artifactId>deltaspike-core-impl</artifactId>
            <version>${ds.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency> <!--1-->
            <groupId>org.apache.deltaspike.modules</groupId>
            <artifactId>deltaspike-test-control-module-impl</artifactId>
            <version>${ds.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency> <!--2-->
            <groupId>org.apache.deltaspike.cdictrl</groupId>
            <artifactId>deltaspike-cdictrl-owb</artifactId>
            <version>${ds.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>  <!--2-->
            <groupId>org.apache.openwebbeans</groupId>
            <artifactId>openwebbeans-impl</artifactId>
            <version>2.0.27</version>
            <scope>test</scope>
        </dependency>
        <!--end::deltaspike-cdi-deps[]-->
    </dependencies>

    <build>
        <sourceDirectory>${src.dir}</sourceDirectory>
        <resources>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
    </build>

    <profiles>
        <profile>
            <id>javax</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>javax.enterprise</groupId>
                    <artifactId>cdi-api</artifactId>
                    <version>2.0</version>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>jakarta</id>
            <properties>
                <src.dir>${project.build.directory}/classes</src.dir>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>jakarta.enterprise</groupId>
                    <artifactId>jakarta.enterprise.cdi-api</artifactId>
                    <version>4.0.1</version>
                </dependency>
                <dependency>
                    <groupId>org.hibernate</groupId>
                    <artifactId>hibernate-core</artifactId>
                    <version>6.2.3.Final</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>org.eclipse.persistence</groupId>
                    <artifactId>eclipselink</artifactId>
                    <version>4.0.1</version>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
            <build>
                <resources>
                    <resource>
                        <directory>src/main/java</directory>
                        <includes>
                            <include>**/*.java</include>
                            <include>**/*.jv</include>
                        </includes>
                    </resource>
                </resources>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>3.0.2</version>
                        <configuration>
                            <classifier>jakarta</classifier>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>com.coderplus.maven.plugins</groupId>
                        <artifactId>copy-rename-maven-plugin</artifactId>
                        <version>1.0.1</version>
                        <executions>
                            <execution>
                                <id>copy-and-rename-sources</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <fileSets>
                                        <fileSet>
                                            <sourceFile>
                                                ${project.basedir}/src/main/java/com/github/database/rider/cdi/JakartaDataSetProcessor.jv
                                            </sourceFile>
                                            <destinationFile>
                                                ${project.build.outputDirectory}/com/github/database/rider/cdi/DataSetProcessor.java
                                            </destinationFile>
                                        </fileSet>
                                    </fileSets>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-and-rename-resources</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <fileSets>
                                        <fileSet>
                                            <sourceFile>${project.basedir}/src/main/resources/META-INF/beans-jakarta.xml
                                            </sourceFile>
                                            <destinationFile>
                                                ${project.build.outputDirectory}/META-INF/beans.xml
                                            </destinationFile>
                                        </fileSet>
                                    </fileSets>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.github.floverfelt</groupId>
                        <artifactId>find-and-replace-maven-plugin</artifactId>
                        <version>1.1.0</version>
                        <executions>
                            <execution>
                                <id>exec</id>
                                <phase>process-sources</phase>
                                <goals>
                                    <goal>find-and-replace</goal>
                                </goals>
                                <configuration>
                                    <replacementType>file-contents</replacementType>
                                    <baseDir>target/classes/</baseDir>
                                    <fileMask>.java</fileMask>
                                    <findRegex>javax</findRegex>
                                    <replaceValue>jakarta</replaceValue>
                                    <recursive>true</recursive>
                                </configuration>
                            </execution>
                            <execution>
                                <id>exec-sql</id>
                                <phase>process-sources</phase>
                                <goals>
                                    <goal>find-and-replace</goal>
                                </goals>
                                <configuration>
                                    <replacementType>file-contents</replacementType>
                                    <baseDir>target/classes/</baseDir>
                                    <fileMask>.java</fileMask>
                                    <findRegex>jakarta.sql.DataSource</findRegex>
                                    <replaceValue>javax.sql.DataSource</replaceValue>
                                    <recursive>true</recursive>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.7</version>
                        <executions>
                            <execution>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <delete>
                                           <!-- <fileset dir="${project.build.directory}/classes" includes="**/*.java"/>-->
                                            <fileset dir="${project.build.directory}/classes" includes="**/*.jv"/>
                                            <fileset dir="${project.build.directory}/classes"
                                                     includes="**/beans-jakarta.xml"/>
                                        </delete>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>3.1.0</version>
                        <configuration>
                            <skipTests>true</skipTests>
                        </configuration>
                    </plugin>
                    <!-- Override version for maven-install-plugin because there is a bug in
 3.0.0-M1 preventing installing of modules with packaging of feature
 see: https://issues.apache.org/jira/browse/MINSTALL-151 -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-install-plugin</artifactId>
                        <version>2.5.2</version>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
