<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2022, Red Hat, Inc., and individual contributors
  ~ as indicated by the @author tags. See the copyright.txt file in the
  ~ distribution for a full listing of individual contributors.
  ~
  ~ This is free software; you can redistribute it and/or modify it
  ~ under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2.1 of
  ~ the License, or (at your option) any later version.
  ~
  ~ This software 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
  ~ Lesser General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public
  ~ License along with this software; if not, write to the Free
  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -->

<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>org.jboss</groupId>
        <artifactId>jboss-iiop-client-parent</artifactId>
        <version>1.0.2.Final</version>
    </parent>

    <groupId>org.jboss</groupId>
    <artifactId>jboss-iiop-client-jakarta</artifactId>
    <version>1.0.2.Final</version>

    <name>JBoss IIOP Client (Jakarta Namespace)</name>

    <properties>
        <transformer-input-dir>${project.basedir}/../javax</transformer-input-dir>

        <version.jakarta.ejb.jakarta-ejb-api>4.0.0</version.jakarta.ejb.jakarta-ejb-api>
    </properties>

    <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">
                                    <arg value="${org.jboss:jboss-iiop-client: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>
                                        <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"/>
                                <ac:propertyregex xmlns:ac="antlib:net.sf.antcontrib" property="source"
                                                  input="${org.jboss:jboss-iiop-client:jar}"
                                                  regexp="\.jar$"
                                                  replace="-sources.jar"
                                                  global="true"/>
                                <java classname="org.eclipse.transformer.jakarta.JakartaTransformer">
                                    <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>
                                        <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"/>
                                <ac:propertyregex xmlns:ac="antlib:net.sf.antcontrib" property="source"
                                                  input="${org.jboss:jboss-iiop-client:jar}"
                                                  regexp="\.jar$"
                                                  replace="-javadoc.jar"
                                                  global="true"/>
                                <java classname="org.eclipse.transformer.jakarta.JakartaTransformer">
                                    <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>
                                        <pathelement path="${plugin_classpath}"/>
                                    </classpath>
                                </java>
                            </target>
                        </configuration>
                    </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>
        </plugins>
    </build>


    <dependencies>

        <!-- Jakarta-namespace specific deps -->

        <dependency>
            <groupId>jakarta.ejb</groupId>
            <artifactId>jakarta.ejb-api</artifactId>
            <version>${version.jakarta.ejb.jakarta-ejb-api}</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.openjdk-orb</groupId>
            <artifactId>openjdk-orb-jakarta</artifactId>
            <version>${version.org.jboss.openjdk-orb}</version>
        </dependency>

        <!-- Other deps -->

        <dependency>
            <groupId>org.jboss</groupId>
            <artifactId>jboss-iiop-client</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${version.junit}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <profiles>
        <profile>
            <id>jboss-release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <inherited>false</inherited>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>javadoc</id>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <phase>package</phase>
                                <configuration>
                                    <artifacts>
                                        <artifact>
                                            <file>
                                                ${project.build.directory}/${project.artifactId}-${project.version}-javadoc.jar
                                            </file>
                                            <type>jar</type>
                                            <classifier>javadoc</classifier>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                            <execution>
                                <id>sources</id>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <phase>package</phase>
                                <configuration>
                                    <artifacts>
                                        <artifact>
                                            <file>
                                                ${project.build.directory}/${project.artifactId}-${project.version}-sources.jar
                                            </file>
                                            <type>jar</type>
                                            <classifier>sources</classifier>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-install-plugin</artifactId>
                        <inherited>false</inherited>
                        <executions>
                            <execution>
                                <id>default-install</id>
                                <phase>install</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
