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

    Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.

    This program and the accompanying materials are made available under the
    terms of the Eclipse Public License v. 2.0, which is available at
    http://www.eclipse.org/legal/epl-2.0.

    This Source Code may also be made available under the following Secondary
    Licenses when the conditions for such availability set forth in the
    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
    version 2 with the GNU Classpath Exception, which is available at
    https://www.gnu.org/software/classpath/license.html.

    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0

-->

<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.glassfish.main.admin</groupId>
        <artifactId>nucleus-admin</artifactId>
        <version>7.0.0</version>
    </parent>

    <artifactId>server-mgmt</artifactId>
    <packaging>glassfish-jar</packaging>

    <name>admin-server-management</name>
    <description>Server Management</description>

    <properties>
        <findbugs.exclude>${project.basedir}/exclude.xml</findbugs.exclude>
    </properties>

    <dependencies>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-osgi</artifactId>
        </dependency>

        <dependency>
            <groupId>org.glassfish.main.common</groupId>
            <artifactId>common-util</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.main.admin</groupId>
            <artifactId>admin-util</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.main.admin</groupId>
            <artifactId>admin-cli</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.annotations</groupId>
            <artifactId>logging-annotation-processor</artifactId>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.template</include>
                    <include>**/*.properties</include>
                    <include>**/*.exe</include>
                    <include>**/*.xsd</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <!-- XXX: no maven plugin for jakarta xml binding impl exists, so we have to stick with Ant and attach source
                root to the build ourselves... -->
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-xjc</artifactId>
                        <version>${jakarta.jaxb-impl.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>xjc</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask" />
                                <property name="dest"
                                    location="${project.build.directory}/generated-sources/xjc" />
                                <mkdir dir="${dest}" />
                                <xjc destdir="${dest}"
                                    schema="${project.basedir}/src/main/resources/xsd/schema/template-info.xsd"
                                    package="com.sun.enterprise.admin.servermgmt.xml.templateinfo" />
                                <xjc destdir="${dest}"
                                    schema="${project.basedir}/src/main/resources/xsd/schema/domain-info.xsd"
                                    package="com.sun.enterprise.admin.servermgmt.xml.domaininfo" />
                                <xjc destdir="${dest}"
                                    schema="${project.basedir}/src/main/resources/xsd/schema/stringsubs.xsd"
                                    package="com.sun.enterprise.admin.servermgmt.xml.stringsubs" />
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${project.build.directory}/generated-sources/xjc</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
