<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.4-SNAPSHOT</version>
    </parent>

    <artifactId>vaadin-jandex</artifactId>
    <packaging>jar</packaging>
    <name>Vaadin Jandex index</name>
    <description>Jandex index for all Vaadin packages</description>

    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-internal</artifactId>
            <version>${project.version}</version>
            <exclusions>
                <!-- Potentially optional dependencies according to online documentation -->
                <exclusion>
                    <groupId>com.vaadin</groupId>
                    <artifactId>flow-react</artifactId>
                </exclusion>
            </exclusions>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.smallrye</groupId>
            <artifactId>jandex</artifactId>
            <version>3.6.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.5.1</version>
                <executions>
                    <execution>
                        <!-- Unpack only classes from artifacts that do not ship their own Jandex index -->
                        <id>unpack-non-indexed-dependencies</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${env.JAVA_HOME}/bin/java</executable>
                            <classpathScope>compile</classpathScope>
                            <arguments>
                                <argument>${project.basedir}/../scripts/jandex/UnpackNonIndexedJars.java</argument>
                                <argument>${project.build.directory}/jandex-classes</argument>
                                <classpath/>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>io.smallrye</groupId>
                <artifactId>jandex-maven-plugin</artifactId>
                <version>3.6.0</version>
                <executions>
                    <execution>
                        <id>make-index</id>
                        <goals>
                            <goal>jandex</goal>
                        </goals>
                        <configuration>
                            <!-- Index only the unpacked classes, the index is still written to target/classes/META-INF -->
                            <processDefaultFileSet>false</processDefaultFileSet>
                            <fileSets>
                                <fileSet>
                                    <directory>${project.build.directory}/jandex-classes</directory>
                                </fileSet>
                            </fileSets>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <excludes>
                        <exclude>com</exclude>
                        <exclude>com/**/*</exclude>
                        <exclude>OSGI-INF</exclude>
                        <exclude>OSGI-INF/*</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
