<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.vaadin</groupId>
        <artifactId>vaadin-platform-parent</artifactId>
        <version>25.2-SNAPSHOT</version>
    </parent>
    <artifactId>vaadin-dev-bundle</artifactId>
    <packaging>jar</packaging>
    <name>Vaadin Dev Bundle</name>
    <description>Vaadin Dev Bundle</description>
    <url>https://vaadin.com</url>

    <distributionManagement>
        <repository>
            <id>vaadin-prereleases</id>
            <url>https://maven.vaadin.com/vaadin-prereleases/</url>
        </repository>
    </distributionManagement>

    <properties>
                <flow.version>25.2-SNAPSHOT</flow.version>
        <flow.components.version>25.2-SNAPSHOT</flow.components.version>
        <hilla.version>25.2-SNAPSHOT</hilla.version>
        <copilot.version>25.2-SNAPSHOT</copilot.version>

    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>flow-bom</artifactId>
                <version>${flow.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>flow-components-bom</artifactId>
                <version>${flow.components.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>hilla-bom</artifactId>
                <version>${hilla.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!--
            vaadin-hybrid-dev-bundle must be a project dependency otherwise it will be built
            after vaadin-dev-bundle because of modules configuration in root pom.
            Configuring the dependency with provided scope will prevent it to be scanned by
            flow-dev-bundle-plugin.
        -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>vaadin-hybrid-dev-bundle</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-internal</artifactId>
            <version>${project.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-spreadsheet-flow</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-dev-server</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>copilot</artifactId>
            <version>${copilot.version}</version>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>2.0.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>2.0.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <excludes>
                        <exclude>**/*Fake*</exclude>
                        <exclude>vaadin-featureflags.properties</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.vaadin</groupId>
                <artifactId>flow-dev-bundle-plugin</artifactId>
                <version>${flow.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>build-dev-bundle</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.6.1</version>
                <executions>
                    <execution>
                        <id>copy-hilla-package-lock-to-bundle</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>vaadin-hybrid-dev-bundle</artifactId>
                                    <version>${project.version}</version>
                                    <type>jar</type>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>${project.build.directory}/dev-bundle</outputDirectory>
                                    <includes>**/package-lock.json</includes>
                                    <fileMappers>
                                        <org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                            <pattern>^\Qvaadin-dev-bundle/package-lock.json\E</pattern>
                                            <replacement>hybrid-package-lock.json</replacement>
                                        </org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                    </fileMappers>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.2</version>
                <executions>
                    <execution>
                        <id>copy-dev-bundle-to-target</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.outputDirectory}/vaadin-dev-bundle</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.build.directory}/dev-bundle</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>${project.basedir}/src/main/bundles</directory>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                  <execution>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                      <target>
                        <!-- Remove application class file, so as IT modules do not read @Theme annotations when
                             maven configures the classpath for multimodule projects -->
                        <delete dir="target/classes/com/vaadin/devbundle" includeemptydirs="true"></delete>
                      </target>
                    </configuration>
                  </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
