<?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>io.smallrye</groupId>
        <artifactId>smallrye-graphql-tools-parent</artifactId>
        <version>1.5.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>smallrye-graphql-gradle-plugin</artifactId>
    <name>SmallRye: GraphQL Tools :: Gradle</name>
    <description>a Gradle plugin that can generate the schema on build</description>
    
    <packaging>pom</packaging>

    <properties>
        <gradle.executable>./gradlew</gradle.executable>
        <gradle.task>build</gradle.task>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.smallrye</groupId>
            <artifactId>smallrye-graphql</artifactId>
        </dependency>
        <dependency>
            <groupId>io.smallrye</groupId>
            <artifactId>smallrye-graphql-schema-builder</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.json.bind</groupId>
            <artifactId>jakarta.json.bind-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse</groupId>
            <artifactId>yasson</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss</groupId>
            <artifactId>jandex</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
        </dependency>

        <!-- This is actually added to tests by build.gradle rather than pom.xml, but IDEs might think that the correct dependencies
            are derived from pom.xml -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>gradle</id>
                        <phase>prepare-package</phase>
                        <configuration>
                            <executable>${gradle.executable}</executable>
                            <arguments>
                                <argument>clean</argument>
                                <argument>${gradle.task}</argument>
                                <argument>-Pdescription=${project.description}</argument>
                                <argument>-Pversion=${project.version}</argument>
                                <argument>-S</argument>
                                <argument>--stacktrace</argument>
                            </arguments>
                            <environmentVariables>
                                <MAVEN_LOCAL_REPO>${settings.localRepository}</MAVEN_LOCAL_REPO>
                                <GRADLE_OPTS>${env.MAVEN_OPTS}</GRADLE_OPTS>
                            </environmentVariables>
                            <skip>${skip.gradle.build}</skip>
                        </configuration>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>build/libs/smallrye-graphql-gradle-plugin-${project.version}.jar</file>
                                    <type>jar</type>
                                </artifact>
                                <artifact>
                                    <file>build/libs/smallrye-graphql-gradle-plugin-${project.version}-javadoc.jar</file>
                                    <type>jar</type>
                                    <classifier>javadoc</classifier>
                                </artifact>
                                <artifact>
                                    <file>build/libs/smallrye-graphql-gradle-plugin-${project.version}-sources.jar</file>
                                    <type>jar</type>
                                    <classifier>sources</classifier>
                                </artifact>
                            </artifacts>
                            <skipAttach>${skip.gradle.build}</skipAttach>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- Do not deploy this project-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>3.0.0-M2</version>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>windows</id>
            <activation>
                <os>
                    <family>windows</family>
                </os>
            </activation>
            <properties>
                <gradle.executable>gradlew.bat</gradle.executable>
            </properties>
        </profile>
        <profile>
            <id>skipTests</id>
            <activation>
                <property>
                    <name>skipTests</name>
                    <value>true</value>
                </property>
            </activation>
            <properties>
                <gradle.task>assemble</gradle.task>
            </properties>
        </profile>
        <profile>
            <id>maven.test.skip</id>
            <activation>
                <property>
                    <name>maven.test.skip</name>
                    <value>true</value>
                </property>
            </activation>
            <properties>
                <gradle.task>assemble</gradle.task>
            </properties>
        </profile>
        <profile>
            <id>release</id>
            <properties>
                <skip.gradle.build>true</skip.gradle.build>
            </properties>
        </profile>
    </profiles>

</project>