<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright 2014 - 2019 Blazebit.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->

<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.blazebit</groupId>
        <artifactId>blaze-persistence-entity-view</artifactId>
        <version>1.5.0-Alpha5</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>blaze-persistence-entity-view-processor</artifactId>
    <packaging>jar</packaging>

    <name>Blazebit Persistence Entity-View Annotation Processor</name>

    <properties>
        <!-- We use Java 8 for tests -->
        <test.java.version>1.8</test.java.version>
        <java.version>${test.java.version}</java.version>
        <module.name>com.blazebit.persistence.view.processor</module.name>
        <com.jolira.hickory.version>1.0.0</com.jolira.hickory.version>
        <org.eclipse.tycho.compiler-jdt.version>0.26.0</org.eclipse.tycho.compiler-jdt.version>
    </properties>

    <dependencies>
        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.testing.compile</groupId>
            <artifactId>compile-testing</artifactId>
            <version>0.18</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>blaze-persistence-entity-view-api</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
            <testResource>
                <directory>src/test/java</directory>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.moditect</groupId>
                <artifactId>moditect-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-module-infos</id>
                        <phase>package</phase>
                        <goals>
                            <goal>add-module-info</goal>
                        </goals>
                        <configuration>
                            <module>
                                <moduleInfoSource>
                                    module ${module.name} {
                                        requires transitive com.blazebit.persistence.core;
                                        requires transitive com.blazebit.persistence.view;
                                        provides javax.annotation.processing.Processor with com.blazebit.persistence.view.processor.EntityViewAnnotationProcessor;
                                    }
                                </moduleInfoSource>
                            </module>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>post-10-unsafe-code-non-mac</id>
            <activation>
                <jdk>[11,)</jdk>
                <file>
                    <exists>${jdk8.home}${file.separator}jre${file.separator}lib${file.separator}rt.jar</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <inherited>true</inherited>
                                <configuration>
                                    <!-- When we use a Java 11+ JVM, we need a JDK 8, otherwise we can't compile the old unsafe code -->
                                    <bootclasspath>${jdk8.home}${file.separator}jre${file.separator}lib${file.separator}rt.jar${path.separator}${jdk8.home}${file.separator}lib${file.separator}tools.jar</bootclasspath>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>post-10-unsafe-code-mac</id>
            <activation>
                <jdk>[11,)</jdk>
                <file>
                    <exists>${jdk8.home}${file.separator}jre${file.separator}lib${file.separator}classes.jar</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <inherited>true</inherited>
                                <configuration>
                                    <!-- When we use a Java 11+ JVM, we need a JDK 8, otherwise we can't compile the old unsafe code -->
                                    <bootclasspath>${jdk8.home}${file.separator}jre${file.separator}lib${file.separator}rt.jar${path.separator}${jdk8.home}${file.separator}lib${file.separator}tools.jar</bootclasspath>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
