<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright 2014 - 2023 Blazebit.

  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/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">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.blazebit</groupId>
        <artifactId>blaze-persistence-core</artifactId>
        <version>1.6.9</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>blaze-persistence-core-impl-jakarta</artifactId>
    <packaging>jar</packaging>

    <properties>
        <module.name>com.blazebit.persistence.core.impl</module.name>
    </properties>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>blaze-persistence-core-impl</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.persistence</groupId>
            <artifactId>jakarta.persistence-api</artifactId>
            <version>${version.jakarta-jpa-api}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>blaze-persistence-core-api-jakarta</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>blaze-persistence-core-parser-jakarta</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>blaze-common-utils</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>transform-jar</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <property name="plugin_classpath" refid="maven.plugin.classpath" />
                                <java classname="org.eclipse.transformer.jakarta.JakartaTransformer" fork="true">
                                    <!--suppress UnresolvedMavenProperty -->
                                    <arg value="${com.blazebit:blaze-persistence-core-impl:jar}" />
                                    <arg value="${project.build.directory}/${project.build.finalName}.jar" />
                                    <arg value="-q" />
                                    <arg value="-o" />
                                    <arg value="-tr" />
                                    <arg value="${project.basedir}/../../rules/jakarta-renames.properties" />
                                    <classpath>
                                        <!--suppress UnresolvedMavenProperty -->
                                        <pathelement path="${plugin_classpath}" />
                                    </classpath>
                                </java>
                            </target>
                        </configuration>
                    </execution>
                    <execution>
                        <id>transform-sources-jar</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <property name="plugin_classpath" refid="maven.plugin.classpath" />
                                <!--suppress UnresolvedMavenProperty -->
                                <ac:propertyregex xmlns:ac="antlib:net.sf.antcontrib" property="source" input="${com.blazebit:blaze-persistence-core-impl:jar}" regexp="\.jar$" replace="-sources.jar" global="true" />
                                <java classname="org.eclipse.transformer.jakarta.JakartaTransformer" fork="true">
                                    <!--suppress UnresolvedMavenProperty -->
                                    <arg value="${source}" />
                                    <arg value="${project.build.directory}/${project.build.finalName}-sources.jar" />
                                    <arg value="-q" />
                                    <arg value="-o" />
                                    <arg value="-tr" />
                                    <arg value="${project.basedir}/../../rules/jakarta-renames.properties" />
                                    <classpath>
                                        <!--suppress UnresolvedMavenProperty -->
                                        <pathelement path="${plugin_classpath}" />
                                    </classpath>
                                </java>
                            </target>
                        </configuration>
                    </execution>
                    <execution>
                        <id>transform-javadoc</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <property name="plugin_classpath" refid="maven.plugin.classpath" />
                                <!--suppress UnresolvedMavenProperty -->
                                <ac:propertyregex xmlns:ac="antlib:net.sf.antcontrib" property="source" input="${com.blazebit:blaze-persistence-core-impl:jar}" regexp="\.jar$" replace="-javadoc.jar" global="true" />
                                <java classname="org.eclipse.transformer.jakarta.JakartaTransformer" fork="true">
                                    <!--suppress UnresolvedMavenProperty -->
                                    <arg value="${source}" />
                                    <arg value="${project.build.directory}/${project.build.finalName}-javadoc.jar" />
                                    <arg value="-q" />
                                    <arg value="-o" />
                                    <arg value="-tr" />
                                    <arg value="${project.basedir}/../../rules/jakarta-renames.properties" />
                                    <classpath>
                                        <!--suppress UnresolvedMavenProperty -->
                                        <pathelement path="${plugin_classpath}" />
                                    </classpath>
                                </java>
                            </target>
                        </configuration>
                    </execution>
                    <!-- Unpack JAR because Quarkus relies on the directory contents for class loading -->
                    <execution>
                        <id>unpack-classes</id>
                        <phase>package</phase>
                        <configuration>
                            <target>
                                <unzip src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.directory}/classes/" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.eclipse.transformer</groupId>
                        <artifactId>org.eclipse.transformer.cli</artifactId>
                        <version>0.2.0</version>
                    </dependency>
                    <dependency>
                        <groupId>ant-contrib</groupId>
                        <artifactId>ant-contrib</artifactId>
                        <version>1.0b3</version>
                        <exclusions>
                            <exclusion>
                                <groupId>ant</groupId>
                                <artifactId>ant</artifactId>
                            </exclusion>
                        </exclusions>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>${project.build.directory}/${project.build.finalName}-sources.jar</file>
                                    <classifier>sources</classifier>
                                    <type>jar</type>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>blazebit-release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-artifacts</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <configuration>
                                    <artifacts>
                                        <artifact>
                                            <file>${project.build.directory}/${project.build.finalName}-sources.jar</file>
                                            <classifier>sources</classifier>
                                            <type>jar</type>
                                        </artifact>
                                        <artifact>
                                            <file>${project.build.directory}/${project.build.finalName}-javadoc.jar</file>
                                            <classifier>javadoc</classifier>
                                            <type>jar</type>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
