<?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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.vaadin.addons.fileviewer</groupId>
    <artifactId>file-viewer</artifactId>
    <version>3.1.0</version>
    <name>File viewer for Vaadin</name>
    <description>File viewer</description>

    <properties>
        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.target>21</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <java.version>17</java.version>
        <vaadin.version>25.3.0</vaadin.version>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>
    <organization>
        <name>radoslaw.pakula</name>
    </organization>
    <licenses>
        <license>
            <name>Apache 2</name>
            <url>https://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>
                <!-- Consider limiting the dependencies to flow-server only something, but for most end users depending on vaadin-core is ok -->
                <artifactId>vaadin-core</artifactId>
            </dependency>
            <dependency>
                <groupId>jakarta.servlet</groupId>
                <artifactId>jakarta.servlet-api</artifactId>
                <version>6.1.0</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-simple</artifactId>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-dev</artifactId>
                <scope>test</scope>
                <optional>true</optional>
            </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>
        </dependencies>

        <build>
            <defaultGoal>jetty:run</defaultGoal>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.5.0</version>
                    <configuration>
                        <archive>
                            <index>true</index>
                            <manifest>
                                <addClasspath>false</addClasspath>
                                <addDefaultImplementationEntries>true
                                </addDefaultImplementationEntries>
                            </manifest>
                            <manifestEntries>
                                <Vaadin-Package-Version>1</Vaadin-Package-Version>
                            </manifestEntries>
                        </archive>
                        <!-- Generated file that shouldn't be included in add-ons -->
                        <excludes>
                            <exclude>META-INF/VAADIN/config/flow-build-info.json</exclude>
                        </excludes>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.eclipse.jetty.ee11</groupId>
                    <artifactId>jetty-ee11-maven-plugin</artifactId>
                    <version>12.1.0</version>
                    <configuration>
                        <scan>-1</scan>
                        <!-- Use test scope because the UI/test classes are in
                            the test package. -->
                        <useTestScope>true</useTestScope>
                        <supportedPackagings>
                            <supportedPackaging>jar</supportedPackaging>
                        </supportedPackagings>
                            <webApp>
                                <resourceBases>
                                    <resourceBase>${project.build.outputDirectory}/META-INF/resources</resourceBase>
                                </resourceBases>
                            </webApp>
                    </configuration>
                </plugin>

                <!--
                 Take care of synchronizing java dependencies and imports in
                 package.json and main.js files.
                 It also creates webpack.config.js if not exists yet.
                 -->
                <plugin>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin-maven-plugin</artifactId>
                    <version>${vaadin.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>prepare-frontend</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>

        <profiles>
            <profile>
                <id>directory</id>
                <build>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-assembly-plugin</artifactId>
                            <version>3.7.1</version>
                            <configuration>
                                <appendAssemblyId>false</appendAssemblyId>
                                <descriptors>
                                    <descriptor>src/main/assembly/assembly.xml</descriptor>
                                </descriptors>
                            </configuration>
                            <executions>
                                <execution>
                                    <goals>
                                        <goal>single</goal>
                                    </goals>
                                    <phase>install</phase>
                                </execution>
                            </executions>
                        </plugin>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-source-plugin</artifactId>
                            <version>3.3.1</version>
                            <executions>
                                <execution>
                                    <id>attach-sources</id>
                                    <phase>verify</phase>
                                    <goals>
                                        <goal>jar-no-fork</goal>
                                    </goals>
                                </execution>
                            </executions>
                        </plugin>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-javadoc-plugin</artifactId>
                            <version>3.12.0</version>
                            <executions>
                                <execution>
                                    <id>attach-javadocs</id>
                                    <phase>verify</phase>
                                    <goals>
                                        <goal>jar</goal>
                                    </goals>
                                </execution>
                            </executions>
                            <configuration>
                                <quiet>true</quiet>
                                <doclint>none</doclint>
                            </configuration>
                        </plugin>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-jar-plugin</artifactId>
                            <version>3.5.0</version>
                            <configuration>
                                <!-- Generated file that shouldn't be included in add-ons -->
                                <excludes>
                                    <exclude>META-INF/VAADIN/config/flow-build-info.json</exclude>
                                    <exclude>META-INF/VAADIN/webapp/**/*</exclude>
                                </excludes>
                            </configuration>
                        </plugin>
                    </plugins>
                </build>
            </profile>
            <profile>
                <id>it</id>
                <build>
                    <plugins>
                        <plugin>
                            <groupId>org.eclipse.jetty.ee11</groupId>
                            <artifactId>jetty-ee11-maven-plugin</artifactId>
                            <configuration>
                                <scan>0</scan>
                                <stopPort>8081</stopPort>
                                <useTestScope>true</useTestScope>
                                <supportedPackagings>
                                    <supportedPackaging>jar</supportedPackaging>
                                </supportedPackagings>
                                <stopWait>15</stopWait>
                                <stopKey>${project.artifactId}</stopKey>
                            </configuration>
                            <executions>
                                <execution>
                                    <id>start-jetty</id>
                                    <phase>pre-integration-test</phase>
                                    <goals>
                                        <goal>start</goal>
                                    </goals>
                                </execution>
                                <execution>
                                    <id>stop-jetty</id>
                                    <phase>post-integration-test</phase>
                                    <goals>
                                        <goal>stop</goal>
                                    </goals>
                                </execution>
                            </executions>
                        </plugin>

                        <plugin>
                            <artifactId>maven-surefire-plugin</artifactId>
                            <configuration>
                                <skip>true</skip>
                            </configuration>
                        </plugin>

                        <!-- Runs the integration tests (*IT) after the server is started -->
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-failsafe-plugin</artifactId>
                            <version>3.5.4</version>
                            <executions>
                                <execution>
                                    <goals>
                                        <goal>integration-test</goal>
                                        <goal>verify</goal>
                                    </goals>
                                </execution>
                            </executions>
                            <configuration>
                                <trimStackTrace>false</trimStackTrace>
                                <enableAssertions>true</enableAssertions>
                            </configuration>
                        </plugin>
                    </plugins>
                </build>
            </profile>
        </profiles>
    </project>
