<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>eu.dnetlib.dhp</groupId>
        <artifactId>openaire-solr-docker</artifactId>
        <version>2.1.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>openaire-solr-importer</artifactId>
    <version>2.1.0</version>
    <packaging>jar</packaging>

    <description>This module is ...</description>

    <dependencies>

        <dependency>
            <groupId>eu.dnetlib.dhp</groupId>
            <artifactId>dhp-index-schemas</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>commons-io</groupId>
                    <artifactId>commons-io</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.guava</groupId>
                    <artifactId>guava</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.projectlombok</groupId>
                    <artifactId>lombok</artifactId>
                </exclusion>
                <exclusion>
                    <artifactId>slf4j-api</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>eu.dnetlib.dhp</groupId>
            <artifactId>openaire-solr-payload-mapper</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-cli</groupId>
            <artifactId>commons-cli</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_${scala.binary.version}</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>zookeeper</artifactId>
                    <groupId>org.apache.zookeeper</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-catalyst_${scala.binary.version}</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-sql_${scala.binary.version}</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.solr</groupId>
            <artifactId>solr-solrj</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j2-impl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-1.2-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
        </dependency>

    </dependencies>

    <build>
        <directory>target</directory>
        <outputDirectory>target/classes</outputDirectory>
        <finalName>${project.artifactId}-${project.version}</finalName>
        <testOutputDirectory>target/test-classes</testOutputDirectory>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.12.1</version>
                <configuration>
                    <release>17</release>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>java11</id>
            <activation>
                <jdk>[11</jdk>
            </activation>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-plugin</artifactId>
                            <version>3.0.0-M4</version>
                            <configuration>
                                <!-- only for java 11+ to run spark in tests -->
                                <argLine>--add-opens=java.base/java.lang=ALL-UNNAMED
                                    --add-opens=java.base/java.lang.invoke=ALL-UNNAMED
                                    --add-opens=java.base/java.lang.reflect=ALL-UNNAMED
                                    --add-opens=java.base/java.io=ALL-UNNAMED
                                    --add-opens=java.base/java.net=ALL-UNNAMED
                                    --add-opens=java.base/java.nio=ALL-UNNAMED
                                    --add-opens=java.base/java.util=ALL-UNNAMED
                                    --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
                                    --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED
                                    --add-opens=java.base/sun.nio.ch=ALL-UNNAMED
                                    --add-opens=java.base/sun.nio.cs=ALL-UNNAMED
                                    --add-opens=java.base/sun.security.action=ALL-UNNAMED
                                    --add-opens=java.base/sun.util.calendar=ALL-UNNAMED
                                </argLine>
                                <redirectTestOutputToFile>true</redirectTestOutputToFile>
                                <trimStackTrace>false</trimStackTrace>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>
        <profile>
            <id>with-assembly</id>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-plugin</artifactId>
                            <version>3.0.0-M4</version>
                            <configuration>
                                <!-- only for java 11+ to run spark in tests -->
                                <argLine>--add-opens=java.base/java.lang=ALL-UNNAMED
                                    --add-opens=java.base/java.lang.invoke=ALL-UNNAMED
                                    --add-opens=java.base/java.lang.reflect=ALL-UNNAMED
                                    --add-opens=java.base/java.io=ALL-UNNAMED
                                    --add-opens=java.base/java.net=ALL-UNNAMED
                                    --add-opens=java.base/java.nio=ALL-UNNAMED
                                    --add-opens=java.base/java.util=ALL-UNNAMED
                                    --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
                                    --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED
                                    --add-opens=java.base/sun.nio.ch=ALL-UNNAMED
                                    --add-opens=java.base/sun.nio.cs=ALL-UNNAMED
                                    --add-opens=java.base/sun.security.action=ALL-UNNAMED
                                    --add-opens=java.base/sun.util.calendar=ALL-UNNAMED
                                </argLine>
                                <redirectTestOutputToFile>true</redirectTestOutputToFile>
                                <trimStackTrace>false</trimStackTrace>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
                <plugins>
                    <plugin>
                        <artifactId>maven-compiler-plugin</artifactId>
                    </plugin>
                    <!-- assembly plugin -->
                    <!-- the assembly plugin is used to define your
                    final deploy output (jar, zip, dir, war, etc..)-->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <version>3.7.1</version>
                        <executions>
                            <execution>
                                <id>assembly:package</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <!-- The filename of the assembled distribution
                                    file defualt ${project.build.finalName}-->
                                    <finalName>openaire-solr-importer</finalName>
                                    <appendAssemblyId>false</appendAssemblyId>
                                    <!--    A list of descriptor files path to generate from-->
                                    <descriptors>
                                        <descriptor>assembly/assembly.xml</descriptor>
                                    </descriptors>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- jar plug in -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>3.3.0</version>
                        <configuration>
                            <finalName>importer</finalName>
                            <archive>
                                <manifest>
                                    <mainClass>eu.dnetlib.dhp.RecordImporterApplication</mainClass>
                                    <!-- to create a class path to your
                                    dependencies you have to fill true in this field-->
                                    <addClasspath>true</addClasspath>
                                    <!-- if you put your dependencySet/outputDirectory
                                    in the assembly file is in a specific folder (lib for example),
                                    you need to add classpathPrefix-->
                                    <classpathPrefix>lib/</classpathPrefix>
                                </manifest>

                                <manifestEntries>
                                    <Class-Path>conf/</Class-Path>
                                </manifestEntries>
                            </archive>

                        </configuration>
                    </plugin>

                </plugins>
            </build>
        </profile>
    </profiles>

</project>