<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>

    <groupId>org.vaadin.addons.antlerflow</groupId>
    <artifactId>breadcrumbs</artifactId>
    <version>1.0.0</version>
    <name>Breadcrumbs</name>
    <description>Breadcrumbs component for Vaadin</description>

    <properties>
        <vaadin.version>25.0.7</vaadin.version>
        <vaadin.addon.license>Apache License 2.0</vaadin.addon.license>
        <maven.compiler.release>21</maven.compiler.release>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <organization>
        <name>Antler Flow</name>
    </organization>
    <licenses>
        <license>
            <name>Apache 2</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <type>pom</type>
                <scope>import</scope>
                <version>${vaadin.version}</version>
            </dependency>
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>6.0.1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>flow-server</artifactId>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-core</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-dev</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-testbench-junit6</artifactId>
            <scope>test</scope>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>5.20.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <!-- Define all plugin versions. Plugins are configured in profiles. -->
        <pluginManagement>
            <plugins>
                <!-- Use newer assembly plugin. 2.x has some problems. -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.7.1</version>
                </plugin>
                <plugin>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin-maven-plugin</artifactId>
                    <version>${vaadin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.eclipse.jetty.ee11</groupId>
                    <artifactId>jetty-ee11-maven-plugin</artifactId>
                    <version>12.1.0</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <!-- If no goal is specified, we run local jetty -->
        <defaultGoal>jetty:run</defaultGoal>

        <!-- Configure default build plugins -->
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <index>true</index>
                        <manifest>
                            <addClasspath>false</addClasspath>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <Vaadin-Package-Version>1</Vaadin-Package-Version>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-maven-plugin</artifactId>
                <configuration>
                    <pnpmEnable>false</pnpmEnable>
                    <requireHomeNodeExec>true</requireHomeNodeExec>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-frontend</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.eclipse.jetty.ee11</groupId>
                <artifactId>jetty-ee11-maven-plugin</artifactId>
                <configuration>
                    <httpConnector>
                        <port>8080</port>
                    </httpConnector>
                    <scan>3</scan>
                    <!-- Use test scope because the UI/demo classes are in the test package. -->
                    <useTestScope>true</useTestScope>
                    <supportedPackagings>
                        <supportedPackaging>jar</supportedPackaging>
                    </supportedPackagings>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!-- Plugin configuration for different profiles -->

    <profiles>

        <!-- Build profile for Vaadin Directory compatible package -->
        <profile>
            <id>directory</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
                            <quiet>true</quiet>
                            <doclint>none</doclint>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <configuration>
                            <excludes>
                                <!-- Generated file that shouldn't be included in add-ons -->
                                <exclude>META-INF/VAADIN/config/flow-build-info.json</exclude>
                                <!-- Compiled frontend stuff that shouldn't be in add-ons -->
                                <exclude>META-INF/VAADIN/webapp/**/*</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <configuration>
                            <appendAssemblyId>false</appendAssemblyId>
                            <descriptors>
                                <descriptor>src/main/assembly/assembly.xml</descriptor>
                            </descriptors>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <phase>package</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Integration test profile -->

        <profile>
            <id>it</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.eclipse.jetty.ee10</groupId>
                        <artifactId>jetty-ee10-maven-plugin</artifactId>
                        <configuration>
                            <httpConnector>
                                <port>8099</port>
                            </httpConnector>
                            <useTestScope>true</useTestScope>
                            <stopKey>stop-it</stopKey>
                            <stopPort>8098</stopPort>
                            <scan>0</scan>
                            <supportedPackagings>
                                <supportedPackaging>jar</supportedPackaging>
                            </supportedPackagings>
                        </configuration>
                        <executions>
                            <execution>
                                <id>start-jetty-it</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-jetty-it</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <trimStackTrace>false</trimStackTrace>
                            <enableAssertions>true</enableAssertions>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <!-- Since the view class is defined in test, after compilation copy
                                    it to the runtime classpath to ensure it gets visited by vaadin-maven-plugin -->
                                <id>copy-test-to-classes</id>
                                <phase>process-test-classes</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>${project.build.testOutputDirectory}</directory>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
