<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-tools-parent</artifactId>
        <version>3.26.2</version>
    </parent>

    <artifactId>quarkus-devtools-base-codestarts</artifactId>
    <name>Quarkus - Dev tools - Base Codestarts</name>

    <properties>
        <gradle-wrapper.path>${maven.multiModuleProjectDirectory}/devtools/gradle</gradle-wrapper.path>
        <gradle.executable>gradlew</gradle.executable>
    </properties>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <resource>
                <directory>src/main/filtered</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>init-gradle-project</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <executable>${gradle-wrapper.path}/${gradle.executable}</executable>
                            <environmentVariables>
                                <!-- Force a higher value than the default 64m, used by
                                 gradlew script, to make sure the no-daemon option is honoured
                                -->
                                <JAVA_OPTS>-Xmx512m</JAVA_OPTS>
                            </environmentVariables>
                            <arguments>
                                <argument>init</argument>
                                <argument>--type</argument>
                                <argument>basic</argument>
                                <argument>--no-daemon</argument>
                                <argument>--overwrite</argument>
                            </arguments>
                            <workingDirectory>${project.build.directory}/gradle-wrapper</workingDirectory>
                            <addOutputToClasspath>true</addOutputToClasspath>
                        </configuration>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>install-gradle-wrapper</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <executable>${gradle-wrapper.path}/${gradle.executable}</executable>
                            <environmentVariables>
                                <!-- Force a higher value than the default 64m, used by
                                 gradlew script, to make sure the no-daemon option is honoured
                                -->
                                <JAVA_OPTS>-Xmx512m</JAVA_OPTS>
                            </environmentVariables>
                            <arguments>
                                <argument>wrapper</argument>
                                <argument>--gradle-version</argument>
                                <argument>${gradle-wrapper.version}</argument>
                                <argument>--no-daemon</argument>
                            </arguments>
                            <workingDirectory>${project.build.directory}/gradle-wrapper</workingDirectory>
                            <addOutputToClasspath>true</addOutputToClasspath>
                        </configuration>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-gradle-wrapper</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <propertiesEncoding>UTF-8</propertiesEncoding>
                            <outputDirectory>${project.build.outputDirectory}/codestarts/quarkus/tooling/gradle-wrapper/base/</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.build.directory}/gradle-wrapper/</directory>
                                    <includes>
                                        <include>gradle/wrapper/**</include>
                                        <include>gradlew</include>
                                        <include>gradlew.bat</include>
                                    </includes>
                                    <filtering>false</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>windows</id>
            <activation>
                <os>
                    <family>windows</family>
                </os>
            </activation>
            <properties>
                <gradle.executable>gradlew.bat</gradle.executable>
            </properties>
        </profile>
    </profiles>

</project>
